/* ════════════════════════════════════════════════════════════════════
   Spark Twice — Shared design foundation
   Forest direction, derived from the "Amber Resonance" handoff.
   Loaded by every HTML page via <link rel="stylesheet" href="/spark-twice.css">.
   ════════════════════════════════════════════════════════════════════ */

/* ── Font imports ──────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;0,6..72,700;1,6..72,400;1,6..72,500;1,6..72,600&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ════════════════════════════════════════════════════════════════════
   Light theme (default)
   ════════════════════════════════════════════════════════════════════ */
:root {
  /* Surfaces — warm paper, never cold white */
  --espresso:     #FDFCF9;
  --espresso-2:   #FFFFFF;
  --umber:        #FDFCF9;
  --coffee:       #F4F1E9;
  --hairline:     rgba(28, 20, 16, 0.07);
  --hairline-2:   rgba(28, 20, 16, 0.16);

  /* Ink — warm near-black */
  --ivory:        #1B1410;
  --ivory-2:      #2D241B;
  --ash:          #4A3F32;
  --stone:        #6F6353;
  --stone-2:      #C4B7A0;

  /* Brand — forest green */
  --green:        #2F6A48;
  --green-light:  #5C9476;
  --green-bright: #97C5A8;
  --green-dark:   #1F4F33;
  --green-deep:   #143424;
  --green-tint:   rgba(47, 106, 72, 0.08);
  --green-border: rgba(47, 106, 72, 0.25);
  --green-glow:   rgba(47, 106, 72, 0.18);

  /* Secondary warm — used sparingly */
  --rose:         #B86A4A;
  --copper:       #C0845C;
  --terracotta:   #A8542A;
  --aubergine:    #5E3240;

  /* Zone accents (admin only) */
  --zone-matching: var(--green);
  --zone-members:  var(--copper);
  --zone-verify:   #B97538;
  --zone-care:     #B14B42;
  --zone-support:  #3D7682;
  --zone-insights: var(--aubergine);

  /* Semantic */
  --success:      var(--green);
  --warn:         #B97538;
  --danger:       #C24A3E;

  /* Typography families */
  --font-d:       'Newsreader', 'Charter', 'Iowan Old Style', Georgia, serif;
  --font-u:       'Inter', 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-m:       'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;

  /* Type scale (mobile minimums respected) */
  --t-xs:    13px;
  --t-sm:    15px;
  --t-base:  17px;
  --t-md:    19px;
  --t-lg:    22px;
  --t-xl:    28px;
  --d-sm:    32px;
  --d-md:    42px;
  --d-lg:    56px;
  --d-xl:    76px;

  /* Line height */
  --lh-tight: 1.15;
  --lh-snug:  1.35;
  --lh-body:  1.6;
  --lh-loose: 1.75;

  /* Weights */
  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semi:    600;
  --fw-bold:    700;

  /* Spacing (4px scale) */
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;
  --s-6:  24px;
  --s-8:  32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;
  --s-24: 96px;

  /* Radii */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   16px;
  --r-xl:   24px;
  --r-full: 9999px;

  /* Shadows (light theme) */
  --shadow-soft:  0 1px 2px rgba(20, 52, 36, 0.06);
  --shadow-card:  0 1px 3px rgba(20, 52, 36, 0.08), 0 1px 2px rgba(20, 52, 36, 0.05);
  --shadow-raise: 0 6px 16px rgba(20, 52, 36, 0.10), 0 2px 4px rgba(20, 52, 36, 0.05);
  --shadow-hero:  0 24px 48px -12px rgba(20, 52, 36, 0.18);
  --glow-green:   0 0 0 3px rgba(47, 106, 72, 0.14);

  /* Container widths */
  --container-narrow:  640px;
  --container-default: 960px;
  --container-wide:    1200px;
}

/* ════════════════════════════════════════════════════════════════════
   Dark theme
   ════════════════════════════════════════════════════════════════════ */
[data-theme="dark"] {
  /* Surfaces — warm darks */
  --espresso:     #15110D;
  --espresso-2:   #1F1A14;
  --umber:        #15110D;
  --coffee:       #2A2218;
  --hairline:     rgba(244, 239, 228, 0.08);
  --hairline-2:   rgba(244, 239, 228, 0.18);

  /* Ink — warm ivory */
  --ivory:        #F4EFE4;
  --ivory-2:      #DCD3C2;
  --ash:          #B5ADA4;
  --stone:        #8A8074;
  --stone-2:      #5C5650;

  /* Brand — forest green, lightened for dark surface */
  --green:        #6BA383;
  --green-light:  #97C5A8;
  --green-bright: #BDE4CC;
  --green-dark:   #4A8062;
  --green-deep:   #345C46;
  --green-tint:   rgba(107, 163, 131, 0.12);
  --green-border: rgba(107, 163, 131, 0.32);
  --green-glow:   rgba(107, 163, 131, 0.20);

  /* Secondary warm */
  --rose:         #D4856A;
  --copper:       #D49B7A;
  --terracotta:   #C97053;
  --aubergine:    #8C5567;

  /* Zone accents */
  --zone-matching: var(--green);
  --zone-members:  var(--copper);
  --zone-verify:   #D4A06A;
  --zone-care:     #E27B6F;
  --zone-support:  #6FA2AE;
  --zone-insights: var(--aubergine);

  /* Semantic */
  --success:      var(--green);
  --warn:         #D4A06A;
  --danger:       #E27B6F;

  /* Shadows muted in dark mode (rely on borders) */
  --shadow-soft:  0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-card:  0 1px 3px rgba(0, 0, 0, 0.30), 0 1px 2px rgba(0, 0, 0, 0.20);
  --shadow-raise: 0 6px 16px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.25);
  --shadow-hero:  0 24px 48px -12px rgba(0, 0, 0, 0.45);
  --glow-green:   0 0 0 3px rgba(107, 163, 131, 0.20);
}

/* Respect system preference unless overridden */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --espresso:     #15110D;
    --espresso-2:   #1F1A14;
    --umber:        #15110D;
    --coffee:       #2A2218;
    --hairline:     rgba(244, 239, 228, 0.08);
    --hairline-2:   rgba(244, 239, 228, 0.18);
    --ivory:        #F4EFE4;
    --ivory-2:      #DCD3C2;
    --ash:          #B5ADA4;
    --stone:        #8A8074;
    --stone-2:      #5C5650;
    --green:        #6BA383;
    --green-light:  #97C5A8;
    --green-bright: #BDE4CC;
    --green-dark:   #4A8062;
    --green-deep:   #345C46;
    --green-tint:   rgba(107, 163, 131, 0.12);
    --green-border: rgba(107, 163, 131, 0.32);
    --green-glow:   rgba(107, 163, 131, 0.20);
    --rose:         #D4856A;
    --copper:       #D49B7A;
    --terracotta:   #C97053;
    --aubergine:    #8C5567;
    --zone-verify:   #D4A06A;
    --zone-care:     #E27B6F;
    --zone-support:  #6FA2AE;
    --warn:         #D4A06A;
    --danger:       #E27B6F;
    --shadow-soft:  0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-card:  0 1px 3px rgba(0, 0, 0, 0.30), 0 1px 2px rgba(0, 0, 0, 0.20);
    --shadow-raise: 0 6px 16px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.25);
    --shadow-hero:  0 24px 48px -12px rgba(0, 0, 0, 0.45);
    --glow-green:   0 0 0 3px rgba(107, 163, 131, 0.20);
  }
}

/* ════════════════════════════════════════════════════════════════════
   Base typography
   ════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-family: var(--font-u);
  font-size: var(--t-base);
  line-height: var(--lh-body);
  color: var(--ivory);
  background: var(--espresso);
}

/* Display serif for headlines and ritual moments */
.stw-display,
h1.stw-display, h2.stw-display, h3.stw-display {
  font-family: var(--font-d);
  font-weight: var(--fw-medium);
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
  color: var(--ivory);
}

.stw-display-lg { font-size: var(--d-lg); }
.stw-display-md { font-size: var(--d-md); }
.stw-display-sm { font-size: var(--d-sm); }

/* Eyebrow caps */
.stw-eyebrow {
  font-family: var(--font-u);
  font-size: var(--t-xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--green);
}

/* Italic body is forbidden, italic appears only on signatures */
.stw-sig {
  font-family: var(--font-d);
  font-style: italic;
  font-weight: var(--fw-medium);
  color: var(--ivory-2);
}

/* ════════════════════════════════════════════════════════════════════
   Brand motifs — the three permitted gradients
   ════════════════════════════════════════════════════════════════════ */

/* Letter paper — for any moment signed by a matchmaker */
.stw-letter {
  background: linear-gradient(180deg, #FFFCF5, #FBF7EE);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-lg);
  padding: var(--s-6) var(--s-6) var(--s-8);
  box-shadow: var(--shadow-card);
  color: var(--ivory-2);
}
[data-theme="dark"] .stw-letter,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .stw-letter {
    background: var(--coffee);
  }
}
.stw-letter p { margin: 0 0 var(--s-4); font-size: var(--t-base); line-height: var(--lh-body); }
.stw-letter p:last-of-type { margin-bottom: 0; }
.stw-letter .stw-sig { display: block; margin-top: var(--s-4); text-align: right; font-size: var(--t-base); }

/* Wax seal — ritual marker, single decorative gradient */
.stw-seal {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, var(--green-bright), var(--green), var(--green-deep));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px var(--green-glow), 0 1px 3px rgba(20, 52, 36, 0.15);
  color: rgba(253, 252, 249, 0.85);
  flex-shrink: 0;
}
.stw-seal.stw-seal-sm { width: 36px; height: 36px; }
.stw-seal.stw-seal-md { width: 48px; height: 48px; }
.stw-seal.stw-seal-lg { width: 96px; height: 96px; }

/* Portrait placeholder — warm tonal gradient when a photo hasn't loaded */
.stw-portrait-placeholder {
  background: linear-gradient(145deg, #D4C0A8, #B89070, #7A6A56);
  border-radius: var(--r-lg);
  aspect-ratio: 4 / 5;
  width: 100%;
}

/* ════════════════════════════════════════════════════════════════════
   Buttons (no gradients permitted)
   ════════════════════════════════════════════════════════════════════ */
.stw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font-family: var(--font-u);
  font-size: var(--t-base);
  font-weight: var(--fw-medium);
  line-height: 1;
  padding: 14px 22px;
  min-height: 48px;
  border-radius: var(--r-md);
  border: 1.5px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
  -webkit-appearance: none;
  appearance: none;
}
.stw-btn:focus-visible {
  outline: none;
  box-shadow: var(--glow-green);
}

.stw-btn-primary {
  background: var(--green);
  color: #FFFFFF;
}
.stw-btn-primary:hover { background: var(--green-dark); }

.stw-btn-secondary {
  background: transparent;
  color: var(--green);
  border-color: var(--green-border);
}
.stw-btn-secondary:hover { background: var(--green-tint); border-color: var(--green); }

.stw-btn-tertiary {
  background: transparent;
  color: var(--ivory-2);
  border-color: transparent;
}
.stw-btn-tertiary:hover { background: var(--green-tint); color: var(--green); }

.stw-btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}
.stw-btn-danger:hover { filter: brightness(0.92); }

/* ════════════════════════════════════════════════════════════════════
   Inputs
   ════════════════════════════════════════════════════════════════════ */
.stw-input,
.stw-textarea,
.stw-select {
  width: 100%;
  font-family: var(--font-u);
  font-size: var(--t-base);
  line-height: var(--lh-body);
  color: var(--ivory);
  background: var(--espresso-2);
  border: 1.5px solid var(--hairline-2);
  border-radius: var(--r-md);
  padding: 12px 14px;
  min-height: 48px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  -webkit-appearance: none;
  appearance: none;
}
.stw-textarea { min-height: 140px; resize: vertical; }
.stw-input:focus,
.stw-textarea:focus,
.stw-select:focus {
  outline: none;
  border-color: var(--green-border);
  box-shadow: var(--glow-green);
}
.stw-input::placeholder,
.stw-textarea::placeholder { color: var(--stone); }

.stw-label {
  display: block;
  font-family: var(--font-u);
  font-size: var(--t-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ivory-2);
  margin-bottom: var(--s-2);
}
.stw-help {
  font-size: var(--t-xs);
  color: var(--stone);
  margin-top: var(--s-2);
}

/* ════════════════════════════════════════════════════════════════════
   Card
   ════════════════════════════════════════════════════════════════════ */
.stw-card {
  background: var(--espresso-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-card);
}
@media (min-width: 768px) {
  .stw-card { padding: var(--s-6); }
}

/* ════════════════════════════════════════════════════════════════════
   Containers and layout
   ════════════════════════════════════════════════════════════════════ */
.stw-container {
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--s-5);
  max-width: var(--container-default);
}
.stw-container-narrow { max-width: var(--container-narrow); }
.stw-container-wide   { max-width: var(--container-wide); }

.stw-stack > * + * { margin-top: var(--s-5); }
.stw-stack-sm > * + * { margin-top: var(--s-3); }
.stw-stack-lg > * + * { margin-top: var(--s-8); }

/* ════════════════════════════════════════════════════════════════════
   Accessibility
   ════════════════════════════════════════════════════════════════════ */
*:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
.stw-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

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