/* FCR appearance modes. Dark remains the default; the switch stores a choice. */
:root { color-scheme: dark; }
:root[data-theme="light"] {
  color-scheme: light;
  --gold: #765a16;
  --gold-light: #806019;
  --gold-dim: #a38c59;
  --gold-muted: #6b5830;
  --gold-tint: #f3ecd9;
  --cream: #211d16;
  --cream-dim: #4a4439;
  --text-muted: #625b50;
  --dark0: #eeeae1;
  --dark: #f8f6f0;
  --dark2: #f0ece3;
  --dark3: #e7e1d6;
  --dark4: #ddd5c7;
  --brown: #c9beaa;
  --red: #a3311b;
  --green: #176b3d;
  --red-tint: #f7e6e0;
  --green-tint: #e3f0e6;
  --robusta-text: #754018;
  --robusta-tint: #f1e5d5;
  --holo: #006579;
  --holo-tint: #dceff2;
  --holo-line: rgba(0, 101, 121, 0.26);
  --holo-line-strong: rgba(0, 101, 121, 0.46);
  --ember: #bd4f27;
  --violet: #68518e;
  --surface-raised: #fffefa;
  --surface-soft: #f1ede4;
  --surface-glass: rgba(255, 254, 250, 0.9);
}

html[data-theme="light"] body { background: var(--dark); color: var(--cream); }
html[data-theme="light"] .ticker-bar {
  background: var(--dark0);
  color: var(--cream);
  border-color: var(--brown);
}
html[data-theme="light"] nav {
  background: linear-gradient(to bottom, rgba(248, 246, 240, 0.97), rgba(248, 246, 240, 0));
}
html[data-theme="light"] nav.scrolled {
  background: rgba(248, 246, 240, 0.94);
  border-bottom-color: rgba(118, 90, 22, 0.2);
}
html[data-theme="light"] .mobile-menu-toggle {
  background: rgba(255, 254, 250, 0.96);
}
html[data-theme="light"] .nav-emblem circle { stroke: var(--gold); }
html[data-theme="light"] .nav-emblem text { fill: var(--gold); }
html[data-theme="light"] footer { background: var(--dark2); }
html[data-theme="light"] .fcr-stars { opacity: 0.16; }
html[data-theme="light"] #fcr-space { opacity: 0.2; }
html[data-theme="light"] ::selection { background: #d9c688; color: #211d16; }
html[data-theme="light"] :focus-visible { outline-color: var(--holo); }

/* Accessible switch injected into the shared navigation. */
.theme-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 38px;
  margin: 0 20px;
  padding: 5px 9px 5px 11px;
  border: 1px solid var(--holo-line);
  border-radius: 999px;
  background: var(--dark2);
  color: var(--cream-dim);
  cursor: pointer;
  font: 600 0.52rem/1 'JetBrains Mono', monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}
.theme-toggle:hover { border-color: var(--holo); color: var(--cream); }
.theme-toggle:focus-visible { outline: 2px solid var(--holo); outline-offset: 3px; }
.theme-toggle__track {
  position: relative;
  display: block;
  width: 30px;
  height: 16px;
  flex: 0 0 30px;
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  background: var(--dark4);
}
.theme-toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px color-mix(in srgb, var(--gold) 40%, transparent);
  transition: transform 0.22s var(--ease-out), background-color 0.22s;
}
html[data-theme="light"] .theme-toggle__thumb {
  transform: translateX(14px);
  background: var(--holo);
}

/* Page-specific dark surfaces are softened into the same warm paper palette. */
html[data-theme="light"] .hero-bg {
  background: radial-gradient(ellipse 60% 70% at 50% 40%, rgba(201, 168, 76, 0.09), transparent 70%),
    linear-gradient(180deg, var(--dark2), var(--dark));
}
html[data-theme="light"] .hero-grid { opacity: 0.34; }

/* Home: the coffee planet stays espresso-dark while the surrounding interface brightens. */
html[data-theme="light"] .bean-hero,
html[data-theme="light"] #mandat,
html[data-theme="light"] #news,
html[data-theme="light"] .coffee-cinema {
  background: linear-gradient(180deg, var(--dark2), var(--dark));
}
html[data-theme="light"] .price-card,
html[data-theme="light"] .stat-box,
html[data-theme="light"] .news-featured,
html[data-theme="light"] .market-readout,
html[data-theme="light"] .market-dock__button,
html[data-theme="light"] .coffee-film {
  background: var(--surface-raised);
  box-shadow: 0 14px 36px rgba(56, 43, 18, 0.09);
}
html[data-theme="light"] .hero-badge,
html[data-theme="light"] .btn-outline { background-color: rgba(255, 254, 250, 0.78); }
html[data-theme="light"] .market-readout__venue,
html[data-theme="light"] .market-dock__venue { color: var(--text-muted); }
html[data-theme="light"] .coffee-film__media,
html[data-theme="light"] .coffee-film video { background: #e7e1d6; }
html[data-theme="light"] #cookieBanner {
  background: var(--surface-raised) !important;
  border-top-color: var(--brown) !important;
  box-shadow: 0 -12px 36px rgba(56, 43, 18, 0.12);
}
html[data-theme="light"] #cookieBanner p { color: var(--cream) !important; }
html[data-theme="light"] #cookieBanner button { background: var(--gold-tint) !important; color: var(--cream) !important; border-color: var(--gold-dim) !important; }
html[data-theme="light"] #cookieBanner a { color: var(--gold) !important; }

/* History timeline and its floating information panels. */
html[data-theme="light"] .history-hero,
html[data-theme="light"] .history-timeline {
  background: linear-gradient(180deg, var(--dark2), var(--dark));
}
html[data-theme="light"] .history-timeline .timeline-content,
html[data-theme="light"] .timeline-hud,
html[data-theme="light"] .timeline-quicknav a {
  background: var(--surface-glass);
  box-shadow: 0 12px 36px rgba(56, 43, 18, 0.09);
}
html[data-theme="light"] .history-timeline .timeline::before { opacity: 0.45; }
html[data-theme="light"] .tag-growth { color: var(--green) !important; background: var(--green-tint) !important; }
html[data-theme="light"] .tag-crisis { color: var(--red) !important; background: var(--red-tint) !important; }
html[data-theme="light"] .tag-reform { color: var(--holo) !important; background: var(--holo-tint) !important; }
html[data-theme="light"] .tag-annual { color: var(--green) !important; background: var(--green-tint) !important; }

/* Manufacturer analyses use light panels while their bean illustrations retain depth. */
html[data-theme="light"] .analysis-section--shade { background: var(--dark2); }
html[data-theme="light"] .analysis-context__bar,
html[data-theme="light"] .analysis-product,
html[data-theme="light"] .analysis-insight,
html[data-theme="light"] .analysis-lab__panel,
html[data-theme="light"] .analysis-lens__card {
  background: var(--surface-raised);
  box-shadow: 0 12px 36px rgba(56, 43, 18, 0.08);
}
html[data-theme="light"] .analysis-product__visual { background: radial-gradient(ellipse at 50% 42%, var(--brand-glow), transparent 69%), linear-gradient(150deg, #f0e8d8, #e6dfd2); }
html[data-theme="light"] .analysis-context__bar { border-color: var(--brown); }
html[data-theme="light"] .analysis-method { background: var(--holo-tint); }
html[data-theme="light"] .bean-art__token { background: rgba(255, 254, 250, 0.94); color: var(--cream); }

/* KPI dashboard. */
html[data-theme="light"] .kpi-period,
html[data-theme="light"] .kpi-stat,
html[data-theme="light"] .kpi-panel {
  background: var(--surface-raised);
  box-shadow: 0 12px 36px rgba(56, 43, 18, 0.08);
}
html[data-theme="light"] .kpi-chart { background-color: var(--surface-soft); }

/* Specialty recommendation uses a single dark glass panel in the default theme. */
html[data-theme="light"] .hero-panel {
  background: linear-gradient(180deg, var(--surface-raised), var(--surface-soft));
  box-shadow: 0 20px 70px rgba(56, 43, 18, 0.1);
}

/* JURA W4: keep the machine render dark and photorealistic; brighten its lab UI. */
html[data-theme="light"] .w4-hero,
html[data-theme="light"] .w4-intro,
html[data-theme="light"] .w4-assembly-track,
html[data-theme="light"] .w4-finale,
html[data-theme="light"] .w4-system {
  background-color: var(--dark);
  background-image: radial-gradient(ellipse 56% 52% at 72% 35%, rgba(0, 101, 121, 0.075), transparent 72%),
    linear-gradient(180deg, var(--dark2), var(--dark));
}
html[data-theme="light"] .w4-button:not(.w4-button--primary),
html[data-theme="light"] .w4-hero__spec,
html[data-theme="light"] .w4-hero__model-tag,
html[data-theme="light"] .w4-stage-art__label,
html[data-theme="light"] .w4-selected-part,
html[data-theme="light"] .w4-part-selector button,
html[data-theme="light"] .w4-source-note {
  background: var(--surface-glass);
}
html[data-theme="light"] .w4-stage-panel,
html[data-theme="light"] .w4-flow-card { background: var(--surface-raised); }

html[data-theme="light"] .timeline-quicknav a,
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea {
  color: var(--cream);
}
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea {
  background-color: var(--surface-raised);
  border-color: var(--brown);
}

@media (max-width: 900px) {
  .theme-toggle { margin: 0 0 0 6px; }
  html[data-theme="light"] nav { background: rgba(248, 246, 240, 0.98); }
}
@media (max-width: 640px) {
  .theme-toggle { width: 42px; min-height: 40px; margin-left: 0; padding: 5px; }
  .theme-toggle__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .theme-toggle__track { width: 28px; flex-basis: 28px; }
  html[data-theme="light"] .theme-toggle__thumb { transform: translateX(12px); }
  html[data-theme="light"] nav { background: rgba(248, 246, 240, 0.99); }
  html[data-theme="light"] nav .nav-links { background: var(--dark2); }
}
