/* ==========================================================================
   Carafe & Gilt — design tokens + foundation
   The single shared foundation stylesheet. Holds:
     1. Design tokens (CSS custom properties) for dark + light themes
     2. Base element resets / typography
     3. cg-* utility classes consumed across every page
   Brand values are LOCKED in DECISIONS.md (§ Brand). Do not drift the gold.
   ========================================================================== */

/* ---- 1. Tokens ---------------------------------------------------------- */

:root {
  /* Type */
  --font-display: 'PT Serif', Georgia, 'Times New Roman', serif;
  --font-body: 'PT Sans', system-ui, -apple-system, sans-serif;
  --font-caption: 'PT Sans Caption', 'PT Sans', sans-serif;

  --fs-xs: 0.72rem;
  --fs-sm: 0.85rem;
  --fs-lg: 1.12rem;

  /* Spacing scale */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1.25rem;
  --sp-5: 2rem;
  --sp-6: 3.25rem;

  /* Layout */
  --container: 1080px;
  --transition: 160ms ease;

  /* ---- Theme: dark (brand default, matches the coming-soon page) ---- */
  --gold: #e0b15e;              /* LOCKED accent */
  --bg: #0F0E0C;               /* warm near-black ground (never pure black) */
  --surface: #141210;          /* panel */
  --surface-2: #1b1813;
  --text: #E8E0D0;             /* bone */
  --text-muted: #8A8272;       /* tan */
  --display-ink: #e0b15e;      /* serif display renders gold on dark */
  --kicker-ink: #e0b15e;       /* small tracked-caps kicker: gold on dark (crisp) */
  --mark-ink: #e0b15e;         /* the brand mark stroke */
  --on-gold: #0F0E0C;          /* text/ink sitting on a gold fill */
  --border: rgba(224, 177, 94, 0.22);
  --border-strong: rgba(224, 177, 94, 0.38);
  --rule: rgba(224, 177, 94, 0.22);
}

/* Light theme values, shared by system-preference and the explicit toggle */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #F4EDDF;
    --surface: #FBF6EC;
    --surface-2: #EEE5D4;
    --text: #2B2720;
    --text-muted: #6F6A60;
    --display-ink: #2B2720;    /* serif titles + wordmark: dark ink on cream (gold reads
                                  too yellow here; gold is reserved for fills/rules/accents) */
    --kicker-ink: #6F6A60;     /* kicker reads muted grey on cream (gold is too pale here) */
    --mark-ink: #a97f2e;
    --on-gold: #0F0E0C;
    --border: rgba(43, 39, 32, 0.14);
    --border-strong: rgba(43, 39, 32, 0.28);
    --rule: rgba(224, 177, 94, 0.45);
  }
}

:root[data-theme="light"] {
  --bg: #F4EDDF;
  --surface: #FBF6EC;
  --surface-2: #EEE5D4;
  --text: #2B2720;
  --text-muted: #6F6A60;
  --display-ink: #2B2720;
  --kicker-ink: #6F6A60;
  --mark-ink: #a97f2e;
  --on-gold: #0F0E0C;
  --border: rgba(43, 39, 32, 0.14);
  --border-strong: rgba(43, 39, 32, 0.28);
  --rule: rgba(224, 177, 94, 0.45);
}

/* data-theme="dark" re-asserts the :root defaults so the toggle can force dark
   even when the OS prefers light. */
:root[data-theme="dark"] {
  --bg: #0F0E0C;
  --surface: #141210;
  --surface-2: #1b1813;
  --text: #E8E0D0;
  --text-muted: #8A8272;
  --display-ink: #e0b15e;
  --kicker-ink: #e0b15e;
  --mark-ink: #e0b15e;
  --on-gold: #0F0E0C;
  --border: rgba(224, 177, 94, 0.22);
  --border-strong: rgba(224, 177, 94, 0.38);
  --rule: rgba(224, 177, 94, 0.22);
}

/* ---- Header controls: theme toggle icon swap ---------------------------- */
/* The single sun/moon button carries BOTH icons; CSS shows the one matching the
   live theme (sun in dark, moon in light). Layout of .toggle / .menu-btn lives
   in the per-page header CSS (recipe.css, home.css); only this state-driven
   icon visibility is shared here so it can't drift between pages. Before JS sets
   [data-theme], the prefers-color-scheme fallbacks keep the right icon showing. */
.toggle .icon-sun, .toggle .icon-moon { display: none; }
:root[data-theme="dark"] .toggle .icon-sun { display: block; }
:root[data-theme="light"] .toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark)  { :root:not([data-theme]) .toggle .icon-sun  { display: block; } }
@media (prefers-color-scheme: light) { :root:not([data-theme]) .toggle .icon-moon { display: block; } }

/* ---- 2. Base ------------------------------------------------------------ */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
h2 { font-size: clamp(1.4rem, 3vw, 1.85rem); margin: 0 0 var(--sp-3); }

a { color: var(--gold); }

img, svg { max-width: 100%; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- 3. cg-* utilities -------------------------------------------------- */

.cg-container { max-width: var(--container); margin-inline: auto; padding-inline: var(--sp-4); }

.cg-kicker {
  font-family: var(--font-caption); text-transform: uppercase;
  letter-spacing: 0.22em; font-size: var(--fs-xs); color: var(--kicker-ink);
}

.cg-display {
  font-family: var(--font-display); font-weight: 400; color: var(--display-ink);
  font-size: clamp(2.2rem, 6vw, 3.4rem); line-height: 1.02;
  letter-spacing: 0.01em; margin: 0;
}

.cg-lead {
  font-family: var(--font-display); font-size: var(--fs-lg);
  line-height: 1.6; color: var(--text); margin: 0;
}

.cg-label {
  display: block; font-family: var(--font-caption); text-transform: uppercase;
  letter-spacing: 0.18em; font-size: var(--fs-xs); color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

.cg-card { background: var(--surface); padding: var(--sp-4); }
.cg-card--framed { border: 1px solid var(--border-strong); }

.cg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  font-family: var(--font-caption); text-transform: uppercase; letter-spacing: 0.14em;
  font-size: var(--fs-xs); padding: 0.75em 1.1em; border: 1px solid transparent;
  background: transparent; color: var(--text); cursor: pointer; text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition), filter var(--transition);
}
.cg-btn--primary { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.cg-btn--primary:hover { filter: brightness(1.07); }
.cg-btn--outline { border-color: var(--border-strong); color: var(--text); }
.cg-btn--outline:hover { border-color: var(--gold); color: var(--gold); }

.cg-quote {
  font-family: var(--font-display); font-style: italic; font-size: var(--fs-lg);
  line-height: 1.6; color: var(--text); border-left: 2px solid var(--gold);
  margin: var(--sp-5) 0 0; padding-left: var(--sp-4);
}

.cg-rule { height: 1px; background: var(--gold); opacity: 0.6; border: 0; }

.cg-tagline {
  font-family: var(--font-caption); text-transform: uppercase;
  letter-spacing: 0.28em; font-size: var(--fs-xs); color: var(--text-muted);
}

.cg-mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

.cg-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;
}
