/* =============================================================
   123 Food Science — Main Stylesheet
   Design: Clean, readable, fast. Not a recipe blog.
   Accent: Deep teal (#0f766e). Trustworthy, not flashy.
   ============================================================= */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --teal:       #0f766e;
  --teal-light: #ccfbf1;
  --teal-dark:  #065f46;
  --blue:       #1d4ed8;
  --blue-light: #dbeafe;
  --red:        #dc2626;
  --red-light:  #fee2e2;
  --yellow:     #d97706;
  --yellow-light: #fef3c7;
  --green:      #16a34a;
  --green-light: #dcfce7;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-500:   #6b7280;
  --gray-700:   #374151;
  --gray-900:   #111827;
  --text:       #1a1a1a;
  --text-muted: #6b7280;
  --border:     #e5e7eb;
  --bg:         #ffffff;
  --max-width:  720px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --line-height: 1.7;
}

html { font-size: 16px; scroll-behavior: smooth; }

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

/* --- Focus styles (keyboard accessibility) --- */
:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
  border-radius: 2px;
}

/* --- Container --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* For wider sections like the homepage silo grid */
.container--wide { max-width: 1000px; }

/* --- Typography --- */
h1, h2, h3, h4 {
  line-height: 1.3;
  font-weight: 700;
  color: var(--gray-900);
}
h1 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); margin-bottom: 0.5rem; }
h2 { font-size: clamp(1.25rem, 2.5vw, 1.6rem); margin-top: 2rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.15rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }

p { margin-bottom: 1.1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--teal-dark); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--teal); }

ul, ol { margin-left: 1.5rem; margin-bottom: 1.1rem; }
li { margin-bottom: 0.3rem; }

strong { font-weight: 600; }

/* --- Site Header / Nav --- */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .container {
  max-width: 1000px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
}

.logo-badge {
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.logo-text {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--gray-900);
}

.main-nav ul {
  display: flex;
  list-style: none;
  margin: 0;
  gap: 0.25rem;
}

.main-nav a {
  display: block;
  padding: 0.35rem 0.65rem;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--gray-700);
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.main-nav a:hover,
.main-nav a.active {
  background: var(--teal-light);
  color: var(--teal-dark);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--gray-700);
  border-radius: 2px;
}

/* --- Step Badges --- */
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

/* --- Step Blocks (1-2-3 structure) --- */
.step-block {
  margin: 2rem 0;
  padding: 1.5rem;
  border-radius: 8px;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.step-header h2 {
  margin: 0;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-700);
}

.quick-answer {
  background: var(--teal-light);
  border-left: 4px solid var(--teal);
}

.quick-answer .step-badge { background: var(--teal); }

.the-science {
  background: var(--gray-50);
  border: 1px solid var(--border);
}

.the-science .step-header h2 { color: var(--gray-700); }
.the-science .step-badge { background: var(--gray-700); }

.practical-takeaway {
  background: var(--blue-light);
  border-left: 4px solid var(--blue);
}

.practical-takeaway .step-badge { background: var(--blue); }

/* --- Prose Content (inside The Science) --- */
.prose { font-size: 1rem; }
.prose h2 { color: var(--gray-900); }
.prose h3 { color: var(--gray-700); }
.prose a { color: var(--teal-dark); }

/* Details / Accordion */
details {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 1rem 0;
  padding: 0.75rem 1rem;
}

summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

summary::after {
  content: "+";
  font-size: 1.25rem;
  color: var(--teal);
  font-weight: 400;
}

details[open] summary::after { content: "−"; }

details > *:not(summary) { margin-top: 0.75rem; }

/* Callout boxes inside prose */
.callout {
  padding: 1rem 1.25rem;
  border-radius: 6px;
  margin: 1.25rem 0;
}

.callout-key { background: var(--blue-light); border-left: 3px solid var(--blue); }
.callout-warning { background: var(--red-light); border-left: 3px solid var(--red); }
.callout-note { background: var(--yellow-light); border-left: 3px solid var(--yellow); }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.9rem;
}

th {
  background: var(--gray-100);
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
}

td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }

/* --- Page Header --- */
.page-header { margin: 1.5rem 0 1.25rem; }
.page-header h1 { margin-bottom: 0.5rem; }

.page-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Breadcrumbs --- */
.breadcrumbs {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 1rem 0 0.5rem;
}

.breadcrumbs ol {
  list-style: none;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.breadcrumbs li + li::before {
  content: "›";
  margin-right: 0.25rem;
  color: var(--gray-500);
}

.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--teal); }

/* --- Difficulty & Evidence Badges --- */
.difficulty-badge, .evidence-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  vertical-align: middle;
}

.difficulty-beginner { background: var(--green-light); color: var(--green); }
.difficulty-intermediate { background: var(--yellow-light); color: var(--yellow); }
.difficulty-advanced { background: var(--red-light); color: var(--red); }

.evidence-strong { background: var(--green-light); color: var(--green); }
.evidence-moderate { background: var(--yellow-light); color: var(--yellow); }
.evidence-emerging { background: var(--blue-light); color: var(--blue); }
.evidence-mixed { background: var(--gray-100); color: var(--gray-500); }

/* --- Food Additives: Verdict Badge --- */
.verdict-badge {
  display: inline-block;
  padding: 0.4rem 1rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.verdict-safe { background: var(--green-light); color: var(--green); border: 1px solid var(--green); }
.verdict-caution { background: var(--yellow-light); color: var(--yellow); border: 1px solid var(--yellow); }
.verdict-avoid { background: var(--red-light); color: var(--red); border: 1px solid var(--red); }

/* --- Food Safety: Safety Callout --- */
.safety-callout {
  background: var(--red-light);
  border: 1px solid var(--red);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  font-size: 0.95rem;
}

/* --- Nutrition Science: YMYL Disclaimer --- */
.ymyl-disclaimer {
  background: var(--yellow-light);
  border: 1px solid var(--yellow);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  font-size: 0.85rem;
  color: var(--gray-700);
}

/* --- Related Reading --- */
.related-reading {
  border-top: 1px solid var(--border);
  margin-top: 2.5rem;
  padding-top: 1.5rem;
}

.related-reading h2 {
  font-size: 1.1rem;
  margin-top: 0;
  color: var(--gray-700);
}

.related-reading h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.related-reading ul {
  list-style: none;
  margin: 0;
}

.related-reading li { margin-bottom: 0.4rem; }

.related-reading a {
  font-size: 0.95rem;
  color: var(--teal-dark);
}

/* --- Article List (section pages) --- */
.article-list {
  list-style: none;
  margin: 1.5rem 0 0;
  display: grid;
  gap: 1rem;
}

.article-card a {
  display: block;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.article-card a:hover {
  border-color: var(--teal);
  box-shadow: 0 2px 8px rgba(15,118,110,0.08);
}

.article-card h2, .article-card h3 {
  font-size: 1.05rem;
  margin: 0 0 0.35rem;
  color: var(--teal-dark);
}

.article-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 0.4rem;
}

/* --- Section Header --- */
.section-header { margin: 1.5rem 0 2rem; }
.section-description { font-size: 1.05rem; color: var(--text-muted); margin-top: 0.5rem; }

/* --- Homepage --- */
.home-hero {
  background: var(--teal-light);
  border-bottom: 1px solid var(--border);
  padding: 3rem 0;
  text-align: center;
}

.home-hero .container { max-width: 640px; }
.home-hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); color: var(--teal-dark); }
.hero-sub { font-size: 1.1rem; color: var(--gray-700); margin: 0.75rem 0 2rem; }

.step-intro {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.step-intro-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.step-intro-item p {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-700);
  margin: 0;
}

.step-intro-arrow {
  font-size: 1.25rem;
  color: var(--teal);
  font-weight: 300;
}

.home-silos {
  padding: 3rem 0;
}

.home-silos .container { max-width: 1000px; }

.silo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-top: 0;
}

.silo-card a {
  display: block;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  height: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.silo-card a:hover {
  border-color: var(--teal);
  box-shadow: 0 2px 12px rgba(15,118,110,0.1);
}

.silo-card h2 {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
  color: var(--teal-dark);
}

.silo-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.home-recent {
  padding: 0 0 3rem;
  border-top: 1px solid var(--border);
}

.home-recent .container { max-width: 1000px; }
.home-recent h2 { padding-top: 2rem; margin-top: 0; }

/* --- Footer --- */
.site-footer {
  background: var(--gray-50);
  border-top: 1px solid var(--border);
  padding: 2.5rem 0 1.5rem;
  font-size: 0.9rem;
}

.site-footer .container { max-width: 1000px; }

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-brand p {
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.footer-nav h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.footer-nav ul {
  list-style: none;
  margin: 0;
}

.footer-nav li { margin-bottom: 0.35rem; }

.footer-nav a {
  color: var(--gray-700);
  text-decoration: none;
  font-size: 0.875rem;
}

.footer-nav a:hover { color: var(--teal); }

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* --- Content page layout --- */
.content-page { padding: 1rem 0 3rem; }

/* --- Terms page --- */
.terms-list {
  list-style: none;
  margin: 1.5rem 0 0;
  columns: 2;
  gap: 0.5rem;
}

.terms-list li { margin-bottom: 0.5rem; break-inside: avoid; }
.term-count { color: var(--text-muted); font-size: 0.8rem; }

/* --- Table of Contents --- */
.toc-block {
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}

.toc-title {
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.6rem;
}

.toc-block nav ul {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.toc-block nav ul ul {
  padding-left: 1rem;
  margin-top: 0.2rem;
}

.toc-block nav li { margin-bottom: 0.3rem; }

.toc-block nav a {
  color: var(--teal-dark);
  text-decoration: none;
  font-size: 0.875rem;
}

.toc-block nav a:hover { text-decoration: underline; }

/* --- References --- */
.references {
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  padding-top: 1.5rem;
}

.references h2 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 0;
}

.references-list {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-left: 1.25rem;
  line-height: 1.5;
}

.references-list li { margin-bottom: 0.5rem; }

.references-list a {
  color: var(--text-muted);
  word-break: break-all;
}

/* --- Section filter bar --- */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0 0.5rem;
}

.filter-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--gray-700);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.filter-btn:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.filter-btn.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

/* --- Search page --- */
.search-page { padding: 1.5rem 0 3rem; }

.search-page h1 { margin-bottom: 1.25rem; }

/* --- Responsive --- */
@media (max-width: 640px) {
  .nav-toggle { display: flex; }

  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
  }

  .main-nav.open { display: block; }

  .main-nav ul {
    flex-direction: column;
    gap: 0;
  }

  .main-nav a {
    padding: 0.6rem 0.5rem;
    border-radius: 4px;
  }

  .site-header { position: relative; }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .terms-list { columns: 1; }

  .step-intro { gap: 0.5rem; flex-direction: column; align-items: center; }
  .step-intro-arrow { display: block; transform: rotate(90deg); }
  .verdict-badge { display: block; text-align: center; }
}

/* --- Dark Mode --- */
@media (prefers-color-scheme: dark) {
  :root {
    --teal:         #14b8a6;
    --teal-light:   #042f2e;
    --teal-dark:    #5eead4;
    --blue:         #60a5fa;
    --blue-light:   #172554;
    --red:          #f87171;
    --red-light:    #450a0a;
    --yellow:       #fbbf24;
    --yellow-light: #451a03;
    --green:        #4ade80;
    --green-light:  #052e16;
    --gray-50:      #171717;
    --gray-100:     #262626;
    --gray-200:     #404040;
    --gray-500:     #a3a3a3;
    --gray-700:     #d4d4d4;
    --gray-900:     #f5f5f5;
    --text:         #e5e5e5;
    --text-muted:   #a3a3a3;
    --border:       #404040;
    --bg:           #0f0f0f;
  }
}

/* --- Print --- */
@media print {
  .site-header,
  .site-footer,
  .related-reading,
  .nav-toggle,
  .breadcrumbs,
  .filter-bar,
  .toc-block { display: none !important; }

  body { font-size: 11pt; color: #000; background: #fff; }
  a { color: #000; }

  .step-badge {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .step-block { border: 1px solid #ccc; break-inside: avoid; }

  details { display: block; }
  details > *:not(summary) { display: block !important; }
  summary::after { display: none; }
}
