/* ============================================================
   composer-theme.css
   Editorial overlay for The Composer · Recipes (index.html).
   Maps the existing Tailwind/amber consumer palette to the
   sage/gold/Cormorant editorial register from planner.css.

   Strategy: the React components keep their Tailwind utility
   classes intact. This stylesheet uses high-specificity rules
   to remap the rendered colors and typography to the editorial
   palette. Reversible — remove the link tag to fall back to
   the original.
   ============================================================ */

:root {
  /* Pull the same tokens planner.css defines */
  --bg-dark:    #1a2622;
  --bg-warm:    #243430;
  --bg-card:    rgba(255,255,255,0.04);
  --bg-card-2:  rgba(255,255,255,0.06);
  --bg-card-hi: rgba(255,255,255,0.08);
  --line:       rgba(255,255,255,0.08);
  --line-strong:rgba(255,255,255,0.14);
  --sage:       #9AAE7C;
  --sage-lt:    #B8C89E;
  --sage-dk:    #566449;
  --gold:       #C9A96E;
  --gold-lt:    #E0C690;
  --gold-dim:   rgba(201,169,110,0.35);
  --teal:       #134e4a;
  --cream:      #FAFAF5;
  --warm-gray:  #9CA3AF;
  --muted:      rgba(255,255,255,0.58);
  --text:       rgba(255,255,255,0.88);
  --danger:     #E86A58;
  --ok:         #9AAE7C;

  --font-h:      'Cormorant Garamond', Georgia, serif;
  --font-b:      'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-ui:     'Space Grotesk', 'Inter', system-ui, sans-serif;

  /* Compose column + chrome: match the 1200px topbar (75rem).
     Tailwind max-w-5xl is 64rem / 1024px — raise toward 1000–1200px
     so iPad landscape uses the screen. Phones never reach this cap. */
  --composer-page-max: 75rem;
  --composer-card-max: 48rem;
}

/* ----------------------------------------------------------
   BODY — dark walnut canvas matching planner.css exactly
   ---------------------------------------------------------- */
html {
  -webkit-text-size-adjust: 100%;
  width: 100%;
  max-width: none;
}

html, body {
  background: radial-gradient(circle at 0% 0%, rgba(154,174,124,0.06), transparent 60%), var(--bg-dark) !important;
  color: var(--cream) !important;
  font-family: var(--font-b) !important;
  font-weight: 300 !important;
  -webkit-font-smoothing: antialiased;
  width: 100%;
  max-width: none;
}

#root {
  background: transparent !important;
  color: var(--cream) !important;
  min-height: calc(100vh - 76px); /* topbar height */
  /* contentInset is never — clear the home indicator / landscape notch. */
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Outer page wrapper — kill any Tailwind bg- on the top-level container */
#root > div,
#root > div > div {
  background: transparent !important;
}

/* ----------------------------------------------------------
   TYPOGRAPHY — Cormorant for headings, Inter for body
   ---------------------------------------------------------- */
#root h1, #root h2, #root h3 {
  font-family: var(--font-h) !important;
  font-weight: 500 !important;
  letter-spacing: -0.005em !important;
  color: var(--cream) !important;
}
#root h1 { font-style: italic; font-size: 2.4rem; line-height: 1.15; }
#root h2 { font-style: italic; font-size: 1.6rem; line-height: 1.2; }
#root h3 { font-size: 1.15rem; }

#root p, #root li, #root span, #root div {
  font-family: var(--font-b);
}

/* Section labels / kickers — uppercase Space Grotesk */
#root .text-xs.uppercase,
#root [class*="text-[10px]"][class*="uppercase"],
#root .uppercase.tracking-wide,
#root .uppercase.tracking-wider,
#root .uppercase.tracking-widest {
  font-family: var(--font-ui) !important;
  letter-spacing: 0.22em !important;
  color: var(--gold) !important;
  font-weight: 500 !important;
}

/* ----------------------------------------------------------
   CARDS / SURFACES — replace bg-white with translucent walnut
   ---------------------------------------------------------- */
#root .bg-white {
  background: var(--bg-card) !important;
  border: 1px solid var(--line) !important;
  color: var(--cream) !important;
  border-radius: 6px !important;
  box-shadow: none !important;
}
#root .bg-gray-50 {
  background: var(--bg-card) !important;
  color: var(--cream) !important;
}
#root .bg-gray-100 {
  background: var(--bg-card-2) !important;
  color: var(--cream) !important;
}

/* Amber/cream cards — the warm consumer accent */
#root .bg-amber-50,
#root .bg-amber-100,
#root .bg-orange-50,
#root .bg-orange-100,
#root .bg-yellow-50 {
  background: rgba(201,169,110,0.08) !important;
  border-color: var(--gold-dim) !important;
  color: var(--cream) !important;
}

/* Teal/cyan blocks (rare-finds drawer) — re-tint to sage */
#root .bg-teal-50,
#root .bg-cyan-50,
#root .from-teal-50,
#root .to-cyan-50 {
  background: rgba(154,174,124,0.08) !important;
  border-color: rgba(154,174,124,0.3) !important;
  color: var(--cream) !important;
}

/* ----------------------------------------------------------
   PAIRING CARD CALLOUTS — wine + zero-proof sommelier notes
   These light-pastel callouts (added in the May 2 readability
   pass) need a dark-walnut translation so the cream-remapped
   body text stays readable on top of them. Pattern matches
   bg-amber-50 / bg-teal-50 above: low-alpha color-tint on dark.
   ---------------------------------------------------------- */
#root .bg-rose-50 {
  background: rgba(244,63,94,0.10) !important;
  border-color: rgba(244,63,94,0.30) !important;
  color: var(--cream) !important;
}
#root .bg-purple-50 {
  background: rgba(168,85,247,0.10) !important;
  border-color: rgba(168,85,247,0.30) !important;
  color: var(--cream) !important;
}
#root .bg-emerald-50 {
  background: rgba(16,185,129,0.10) !important;
  border-color: rgba(16,185,129,0.30) !important;
  color: var(--cream) !important;
}

/* The pairing-card title labels (palette.label = text-X-900) read as
   deep-dark on light theme, near-invisible on dark. Brighten them. */
#root .text-rose-900    { color: #fda4af !important; }
#root .text-purple-900  { color: #d8b4fe !important; }
#root .text-emerald-900 { color: #6ee7b7 !important; }
#root .text-teal-900    { color: #5eead4 !important; }

/* Border colors used by the callouts and the card outer (palette.border
   = border-X-300). Remap to dim sage-toned borders so the cards and
   callouts have a visible but quiet edge on the dark canvas. */
#root .border-rose-300    { border-color: rgba(244,63,94,0.30) !important; }
#root .border-purple-300  { border-color: rgba(168,85,247,0.30) !important; }
#root .border-emerald-300 { border-color: rgba(16,185,129,0.30) !important; }
#root .border-teal-300    { border-color: rgba(154,174,124,0.30) !important; }

/* Chips (palette.chip = bg-X-100 + text-X-900). Already covered by the
   text-X-900 remap above; ensure the chip background sits in the right
   tonal range on dark — slightly brighter than the callout, so the chip
   reads as a pill rather than fading into the surface. */
#root .bg-rose-100    { background: rgba(244,63,94,0.18) !important; }
#root .bg-purple-100  { background: rgba(168,85,247,0.18) !important; }
#root .bg-emerald-100 { background: rgba(16,185,129,0.18) !important; }
#root .bg-teal-100    { background: rgba(154,174,124,0.18) !important; }
#root .bg-gradient-to-r.from-teal-600,
#root .bg-gradient-to-r.from-teal-600.to-cyan-600,
#root .bg-gradient-to-br.from-teal-50,
#root .bg-gradient-to-br.from-teal-50.to-cyan-50 {
  background: linear-gradient(to right, var(--sage-dk), var(--teal)) !important;
}

/* ----------------------------------------------------------
   PRIMARY ACCENT — amber-500 / orange-500 → gold
   ---------------------------------------------------------- */
#root .bg-amber-500,
#root .bg-amber-600,
#root .bg-orange-500,
#root .bg-orange-600,
#root .from-amber-500,
#root .to-orange-500,
#root .to-orange-600 {
  background: var(--gold) !important;
  color: var(--bg-dark) !important;
  border-color: var(--gold) !important;
}
#root .bg-gradient-to-r.from-amber-500,
#root .bg-gradient-to-r.from-amber-500.to-orange-500,
#root .bg-gradient-to-br.from-amber-500,
#root .bg-gradient-to-br.from-amber-500.to-orange-500 {
  background: linear-gradient(135deg, var(--gold), var(--gold-lt)) !important;
  color: var(--bg-dark) !important;
}
#root .text-amber-500,
#root .text-amber-600,
#root .text-amber-700,
#root .text-amber-800,
#root .text-amber-900,
#root .text-orange-500,
#root .text-orange-600,
#root .text-orange-700 {
  color: var(--gold) !important;
}
#root .text-amber-100,
#root .text-amber-400 {
  color: var(--gold-lt) !important;
}
#root .border-amber-200,
#root .border-amber-300,
#root .border-amber-500 {
  border-color: var(--gold-dim) !important;
}
#root .hover\:border-amber-300:hover {
  border-color: var(--gold) !important;
}

/* ----------------------------------------------------------
   GRAY TEXT — re-tint for dark canvas
   ---------------------------------------------------------- */
#root .text-gray-900 { color: var(--cream) !important; }
#root .text-gray-800,
#root .text-gray-700 { color: var(--text) !important; }
#root .text-gray-600,
#root .text-gray-500 { color: var(--muted) !important; }
#root .text-gray-400,
#root .text-gray-300 { color: var(--warm-gray) !important; }
#root .text-white { color: var(--cream) !important; }

#root .border-gray-200,
#root .border-gray-300 { border-color: var(--line) !important; }
#root .divide-gray-200 > * + * { border-color: var(--line) !important; }

/* Hover states on neutral surfaces */
#root .hover\:bg-gray-50:hover,
#root .hover\:bg-gray-100:hover {
  background: var(--bg-card-hi) !important;
}

/* ----------------------------------------------------------
   BUTTONS — give the primary CTA the editorial pill treatment
   ---------------------------------------------------------- */
#root button {
  font-family: var(--font-ui) !important;
}

/* The big Generate / Fuse button — full-bleed with gold gradient */
#root button.bg-amber-500,
#root button.bg-orange-500,
#root button[class*="from-amber-500"],
#root button[class*="bg-gradient-to-r"][class*="from-amber-500"] {
  background: var(--gold) !important;
  color: var(--bg-dark) !important;
  font-family: var(--font-ui) !important;
  font-weight: 600 !important;
  letter-spacing: 0.18em !important;
  text-transform: uppercase !important;
  font-size: 0.78rem !important;
  border: none !important;
  border-radius: 999px !important;
  transition: all 0.2s !important;
  box-shadow: 0 1px 0 rgba(0,0,0,0.2) !important;
}
#root button.bg-amber-500:hover,
#root button.bg-orange-500:hover,
#root button[class*="from-amber-500"]:hover {
  background: transparent !important;
  color: var(--gold) !important;
  box-shadow: inset 0 0 0 1px var(--gold) !important;
}

/* Pill toggles (in-season chips, dietary chips, etc.) */
#root .rounded-full {
  border-radius: 999px !important;
}

/* ----------------------------------------------------------
   INPUTS — match planner.css editorial input style
   ---------------------------------------------------------- */
#root input[type="text"],
#root input[type="email"],
#root input[type="password"],
#root input[type="search"],
#root input[type="number"],
#root textarea,
#root select {
  background: rgba(0,0,0,0.35) !important;
  border: 1px solid var(--line-strong) !important;
  color: var(--cream) !important;
  font-family: var(--font-b) !important;
  border-radius: 6px !important;
  transition: border-color 0.2s !important;
}
#root input:focus,
#root textarea:focus,
#root select:focus {
  outline: none !important;
  border-color: var(--gold) !important;
}
#root input::placeholder,
#root textarea::placeholder {
  color: var(--warm-gray) !important;
}

/* ----------------------------------------------------------
   SHADOWS — soften them for dark canvas
   ---------------------------------------------------------- */
#root .shadow,
#root .shadow-sm,
#root .shadow-md {
  box-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
}
#root .shadow-lg,
#root .shadow-xl,
#root .shadow-2xl {
  box-shadow: 0 8px 24px rgba(0,0,0,0.45) !important;
}

/* ----------------------------------------------------------
   TABS / NAV — sage hover, gold active border
   ---------------------------------------------------------- */
#root .border-b-2.border-amber-500 {
  border-color: var(--gold) !important;
}
#root nav button.bg-amber-100,
#root nav button.bg-orange-100 {
  background: rgba(201,169,110,0.12) !important;
  color: var(--gold) !important;
}

/* ----------------------------------------------------------
   IMAGES / RECIPE CARDS — subtle ornament
   ---------------------------------------------------------- */
#root img {
  border-radius: 6px;
}

/* Headings inside the loaded recipe card */
#root .text-2xl.font-bold,
#root .text-3xl.font-bold {
  font-family: var(--font-h) !important;
  font-style: italic !important;
  font-weight: 500 !important;
  letter-spacing: -0.005em !important;
  color: var(--cream) !important;
}

/* ----------------------------------------------------------
   LANG TOGGLE / EN-ES — tucked away in topbar register
   ---------------------------------------------------------- */
#root .text-xs button {
  font-family: var(--font-ui) !important;
  letter-spacing: 0.14em !important;
}

/* ----------------------------------------------------------
   Loose ends: spinners, badges, dividers
   ---------------------------------------------------------- */
#root .border-t,
#root .border-b,
#root .border {
  border-color: var(--line) !important;
}

/* Strong success / danger states */
#root .text-green-700,
#root .text-green-600,
#root .text-emerald-600 { color: var(--sage-lt) !important; }
#root .text-red-700,
#root .text-red-600 { color: var(--danger) !important; }
#root .bg-green-100 { background: rgba(154,174,124,0.12) !important; }
#root .bg-red-100 { background: rgba(232,106,88,0.12) !important; }

/* ----------------------------------------------------------
   IPAD / TABLET — fill horizontal real estate
   Page chrome aligns with the 1200px topbar. Recipe plate
   figures are Tailwind max-w-xl / max-w-2xl (36–42rem); bump
   those on iPad landscape (≥42rem) to 48rem so the card is
   readable. Settings panel and notices stay at max-w-xl.
   ≤640px stacking lives in index.html and is unchanged.
   ---------------------------------------------------------- */
#root .max-w-5xl {
  max-width: var(--composer-page-max) !important;
}

@media (min-width: 42rem) {
  /* Recipe / Fusion result media: drop the 36–42rem Tailwind cap so
     the card reads at ≥48rem and can fill the 1000–1200px column. */
  #root figure.w-full.max-w-xl,
  #root figure.w-full.max-w-2xl,
  #root .w-full.max-w-2xl.aspect-\[3\/2\] {
    max-width: 100% !important;
    min-width: min(var(--composer-card-max), 100%);
  }
  /* Cost Analysis: 5 tight columns clip labels; let chips wrap. */
  #root .grid.grid-cols-5.gap-3.text-center {
    grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)) !important;
    overflow: visible !important;
  }
}

@media (min-width: 1100px) {
  #root .grid.grid-cols-2.sm\:grid-cols-3.md\:grid-cols-4 {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  }
}

/* In-app Capacitor print: hide the live studio, show only the sheet. */
html.composer-printing,
html.composer-printing body {
  background: #fff !important;
  color: #1a1a1a !important;
}
html.composer-printing body > *:not(#composer-print-root) {
  display: none !important;
}
#composer-print-root { display: none; }
html.composer-printing #composer-print-root {
  display: block;
  background: #fff;
  color: #1a1a1a;
}

/* Live-page print fallback (window.print on the studio, not the iframe).
   Hide chrome; let the recipe card + plate + cost labels fill letter/A4. */
@media print {
  @page { size: auto; margin: 0.45in; }
  html.composer-printing body > *:not(#composer-print-root) {
    display: none !important;
  }
  html.composer-printing #composer-print-root,
  html.composer-printing #composer-print-root .sheet {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
  }
  .composer-topbar,
  #root .print\:hidden { display: none !important; }
  html, body, #root {
    background: #fff !important;
    color: #1a1a1a !important;
    width: 100% !important;
    max-width: none !important;
  }
  #root .max-w-5xl,
  #root .max-w-xl,
  #root .max-w-2xl {
    max-width: none !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  #root .overflow-hidden { overflow: visible !important; }
  #root .grid.grid-cols-5 {
    grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)) !important;
  }
}

