/* ==========================================================================
   First Line · styles.css
   Editorial-leaning utility tool. Warm neutral surfaces, one ink accent.
   All color pairs verified ≥ 4.5:1 contrast for AA body and ≥ 3:1 large text.
   ========================================================================== */

:root {
  /* type */
  --font-sans: "General Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;

  /* fluid scale */
  --text-xs: clamp(0.75rem, 0.72rem + 0.2vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.83rem + 0.25vw, 0.9375rem);
  --text-base: clamp(1rem, 0.96rem + 0.3vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1.06rem + 0.4vw, 1.25rem);
  --text-xl: clamp(1.375rem, 1.28rem + 0.6vw, 1.5rem);
  --text-2xl: clamp(1.75rem, 1.55rem + 1vw, 2.125rem);
  --text-3xl: clamp(2.25rem, 1.9rem + 1.8vw, 3rem);

  /* space */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px; --sp-20: 80px; --sp-24: 96px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --wrap-max: 1120px;
  --wrap-pad: clamp(20px, 4vw, 48px);

  /* palette (light) */
  --bg: #f7f4ee;          /* warm cream */
  --bg-elev: #ffffff;
  --ink: #14161a;         /* near-black */
  --ink-soft: #3a3d44;    /* body soft */
  --ink-muted: #5a5e67;   /* meta/help */
  --ink-subtle: #8b8f98;
  --line: rgba(20, 22, 26, 0.12);
  --line-strong: rgba(20, 22, 26, 0.22);
  --accent: #7a3b2e;      /* ink-red, classic editorial */
  --accent-soft: #f1d7cf;
  --accent-ink: #4a2019;
  --ok: #1f5d3a;
  --warn: #8a5a00;
  --warn-soft: #fbeecd;
  --danger: #7d1f1f;
  --danger-soft: #f5d6d6;
  --focus: #1e66b8;

  /* shadows (tone-matched to warm surface) */
  --shadow-sm: 0 1px 2px rgba(60, 40, 30, 0.06), 0 2px 6px rgba(60, 40, 30, 0.05);
  --shadow-md: 0 4px 10px rgba(60, 40, 30, 0.08), 0 12px 28px rgba(60, 40, 30, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --bg-elev: #1d2026;
    --ink: #f3efe6;
    --ink-soft: #d4d0c6;
    --ink-muted: #a8a69e;
    --ink-subtle: #7c7a74;
    --line: rgba(243, 239, 230, 0.14);
    --line-strong: rgba(243, 239, 230, 0.28);
    --accent: #e8a795;
    --accent-soft: #3a221c;
    --accent-ink: #f7d7cc;
    --ok: #86d3a3;
    --warn: #ecc26a;
    --warn-soft: #3a2e14;
    --danger: #f0a3a3;
    --danger-soft: #3a1d1d;
    --focus: #7ab7ff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 10px rgba(0,0,0,0.45), 0 12px 28px rgba(0,0,0,0.35);
  }
}

/* --------------------------------------------------------------------------
   Reset + base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  font-feature-settings: "ss01", "ss02";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--accent-ink); }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--ink);
  margin: 0 0 var(--sp-4);
}
h1 { font-size: var(--text-3xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-lg); letter-spacing: -0.005em; }

p { margin: 0 0 var(--sp-4); color: var(--ink-soft); max-width: 62ch; }

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

em { font-style: italic; color: var(--ink); }

/* --------------------------------------------------------------------------
   Accessibility primitives
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -40px;
  left: var(--sp-4);
  background: var(--ink);
  color: var(--bg);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-sm);
  text-decoration: none;
  z-index: 100;
  transition: top 0.15s ease;
}
.skip-link:focus { top: var(--sp-4); outline: 2px solid var(--focus); outline-offset: 2px; }

.sr-live,
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   Layout helpers
   -------------------------------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--wrap-max);
  margin-inline: auto;
  padding-inline: var(--wrap-pad);
}

.eyebrow {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
  margin: 0 0 var(--sp-4);
}

.section-title { font-size: var(--text-2xl); margin-bottom: var(--sp-4); }

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.site-header {
  padding: var(--sp-5) 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: saturate(140%) blur(6px);
}
.header-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-6);
}
.brand {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  text-decoration: none; color: var(--ink); font-weight: 600;
  font-family: var(--font-serif); font-size: var(--text-lg);
}
.brand:hover { color: var(--ink); }
.logo { color: var(--ink); flex-shrink: 0; }
.nav-links {
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: var(--sp-6);
}
.nav-links a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: var(--text-sm);
  padding: var(--sp-2) 0;
  border-bottom: 1.5px solid transparent;
  min-height: 44px;
  display: inline-flex; align-items: center;
}
.nav-links a:hover { color: var(--ink); border-bottom-color: var(--ink); }
@media (max-width: 620px) {
  .nav-links { gap: var(--sp-4); }
  .nav-links a { font-size: var(--text-xs); }
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */
.hero {
  padding: var(--sp-16) 0 var(--sp-12);
}
.hero-title {
  font-size: var(--text-3xl);
  max-width: 22ch;
  margin-bottom: var(--sp-5);
}
.hero-title br { display: none; }
@media (min-width: 760px) {
  .hero-title br { display: inline; }
}
.hero-lede {
  font-size: var(--text-lg);
  color: var(--ink-soft);
  max-width: 58ch;
  margin-bottom: var(--sp-8);
}
.hero-cta { display: flex; flex-wrap: wrap; gap: var(--sp-3); }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.button {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  padding: 14px 22px;
  border-radius: var(--radius-md);
  border: 1.5px solid transparent;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  text-decoration: none;
  min-height: 48px; /* WCAG 2.2 target size (≥24 and comfortably above) */
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.08s;
}
.button:active { transform: translateY(1px); }

.button-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.button-primary:hover { background: #000; color: var(--bg); }
@media (prefers-color-scheme: dark) {
  .button-primary:hover { background: #fff; color: var(--ink); border-color: #fff; }
}

.button-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.button-ghost:hover { border-color: var(--ink); background: rgba(20,22,26,0.04); }
@media (prefers-color-scheme: dark) {
  .button-ghost:hover { background: rgba(243,239,230,0.05); border-color: var(--ink); color: var(--ink); }
}

.button[disabled] { opacity: 0.55; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   Generator grid (form + budget)
   -------------------------------------------------------------------------- */
.generator { padding: var(--sp-6) 0 var(--sp-16); }
.generator-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-6);
}
@media (min-width: 920px) {
  .generator-grid {
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    align-items: start;
  }
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(22px, 3vw, 32px);
  box-shadow: var(--shadow-sm);
}
.card-title { font-size: var(--text-xl); margin-bottom: var(--sp-2); }
.card-help { color: var(--ink-muted); font-size: var(--text-sm); margin-bottom: var(--sp-6); }

/* form fields */
.field { margin-bottom: var(--sp-5); }
.field:last-child { margin-bottom: 0; }
.field label,
.field legend {
  display: block;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--ink);
  margin-bottom: var(--sp-2);
}
.field-note {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin: var(--sp-2) 0 0;
  max-width: none;
}

input[type="text"],
select,
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line-strong);
  min-height: 48px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%),
                    linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 22px, calc(100% - 16px) 22px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 44px;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--focus);
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
input::placeholder,
textarea::placeholder { color: var(--ink-subtle); }

/* segmented control */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  padding: 4px;
  background: var(--bg);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-md);
}
.seg { position: relative; cursor: pointer; min-height: 48px; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg > span {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-soft);
  min-height: 48px;
  height: 100%;
}
.seg-note {
  font-weight: 400;
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: 3px;
}
.seg input:checked + span {
  background: var(--ink);
  color: var(--bg);
}
.seg input:checked + span .seg-note { color: var(--bg); opacity: 0.8; }
.seg input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* voice sample <details> */
.voice-sample summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-sm);
  padding: var(--sp-3) 0;
  min-height: 44px;
  display: flex; align-items: center; gap: var(--sp-2);
  list-style: none;
  border-top: 1px solid var(--line);
}
.voice-sample summary::-webkit-details-marker { display: none; }
.voice-sample summary::before {
  content: "+";
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  line-height: 1;
}
.voice-sample[open] summary::before { content: "−"; }
.optional {
  margin-left: auto;
  font-weight: 400;
  font-size: var(--text-xs);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.voice-label {
  display: block;
  font-weight: 400;
  font-size: var(--text-sm);
  color: var(--ink-soft);
  margin-bottom: var(--sp-3);
}

.form-actions {
  display: flex; flex-wrap: wrap; gap: var(--sp-3);
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--line);
}

/* budget card */
.budget-card { position: sticky; top: 88px; }
.budget-archetype { font-size: var(--text-sm); color: var(--ink-muted); margin-bottom: var(--sp-4); }
.budget-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin-bottom: var(--sp-4);
}
.budget-bar-fill {
  height: 100%;
  width: var(--pct, 0%);
  background: var(--ink);
  border-radius: 999px;
  transition: width 0.25s ease;
}
.budget-bar-fill[data-state="warn"] { background: var(--warn); }
.budget-bar-fill[data-state="over"] { background: var(--danger); }
.budget-readout { font-size: var(--text-sm); color: var(--ink-soft); }
.budget-readout strong { color: var(--ink); font-weight: 600; }
.budget-hint {
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
  font-size: var(--text-sm);
  color: var(--ink-muted);
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Results
   -------------------------------------------------------------------------- */
.results {
  padding: var(--sp-12) 0;
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.results-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}
.results-sub { color: var(--ink-muted); font-size: var(--text-sm); margin-bottom: var(--sp-8); max-width: 58ch; }
.results-footnote {
  margin-top: var(--sp-6);
  color: var(--ink-muted);
  font-size: var(--text-xs);
  max-width: 70ch;
}
.hook-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: var(--sp-5);
}

.hook {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 2.5vw, 28px);
  display: grid;
  gap: var(--sp-4);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.hook:hover { border-color: var(--line-strong); }
.hook.is-selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--ink) inset;
}

.hook-top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
}
.hook-index {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  color: var(--ink-muted);
  font-weight: 500;
}
.hook-style {
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
}

.hook-text {
  font-family: var(--font-serif);
  font-size: clamp(1.15rem, 0.95rem + 0.6vw, 1.4rem);
  line-height: 1.4;
  color: var(--ink);
  margin: 0;
  max-width: none;
}
.hook-text [data-placeholder] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: 0 4px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 0.88em;
  font-style: normal;
}

.hook-explainer {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
  background: rgba(20,22,26,0.03);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--line-strong);
  max-width: none;
}
@media (prefers-color-scheme: dark) {
  .hook-explainer { background: rgba(243,239,230,0.04); }
}

.hook-checks {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
}
.check {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid transparent;
  line-height: 1.2;
}
.check-ok { background: transparent; color: var(--ok); border-color: color-mix(in oklab, var(--ok) 40%, transparent); }
.check-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in oklab, var(--warn) 40%, transparent); }
.check-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in oklab, var(--danger) 40%, transparent); }
.check-info { background: transparent; color: var(--ink-muted); border-color: var(--line-strong); }

.check-icon { width: 12px; height: 12px; flex-shrink: 0; }

.hook-actions {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
}
.hook-actions .button {
  min-height: 40px;
  padding: 8px 14px;
  font-size: var(--text-xs);
}

/* --------------------------------------------------------------------------
   How it works
   -------------------------------------------------------------------------- */
.how { padding: var(--sp-16) 0; }
.how-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-10);
}
@media (min-width: 860px) {
  .how-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: var(--sp-16); }
}
.how-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-8); }
.how-list h3 { margin-bottom: var(--sp-2); font-size: var(--text-lg); font-family: var(--font-serif); }
.how-list p { margin: 0; font-size: var(--text-sm); }

/* --------------------------------------------------------------------------
   Explainer (AI detection)
   -------------------------------------------------------------------------- */
.explainer {
  padding: var(--sp-12) 0;
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.explainer p { font-size: var(--text-base); max-width: 62ch; }
.explainer-footer { color: var(--ink-muted); font-size: var(--text-sm); border-top: 1px solid var(--line); padding-top: var(--sp-5); margin-top: var(--sp-6); }

/* --------------------------------------------------------------------------
   FAQ
   -------------------------------------------------------------------------- */
.faq { padding: var(--sp-16) 0; }
.faq-list { display: grid; gap: var(--sp-2); }
.faq details {
  border-top: 1px solid var(--line);
  padding: var(--sp-4) 0;
}
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary {
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--ink);
  list-style: none;
  min-height: 44px;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-2) 0;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  font-family: var(--font-sans);
  font-size: var(--text-xl);
  color: var(--ink-muted);
  transition: transform 0.15s;
}
.faq details[open] summary::after { content: "−"; }
.faq details p { margin-top: var(--sp-3); font-size: var(--text-sm); }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
  padding: var(--sp-10) 0 var(--sp-12);
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.footer-row {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-4);
  align-items: baseline;
}
.footer-line, .footer-meta { margin: 0; font-size: var(--text-xs); color: var(--ink-muted); max-width: 60ch; }
.footer-meta a { color: var(--ink-soft); text-decoration: none; border-bottom: 1px solid var(--line-strong); padding-bottom: 1px; }
.footer-meta a:hover { color: var(--ink); border-color: var(--ink); }
.footer-meta > * + * { margin-left: var(--sp-3); }

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */
@media print {
  .site-header, .site-footer, .hero, .how, .explainer, .faq, .form-actions, .results-actions { display: none; }
  body { background: #fff; color: #000; }
  .hook { break-inside: avoid; border: 1px solid #ccc; }
}
