/* ============================================================
   Nutriscopio — Base styles
   Reset + typography defaults. Depends on tokens.css.
   ============================================================ */

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  -moz-tab-size: 4; tab-size: 4;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}
body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; margin: 0; }
h1, h2, h3, h4, h5, h6 { font-size: inherit; font-weight: inherit; }
img, picture, svg, video, canvas { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }

/* Document */
body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--brand-weak); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  left: var(--space-4); top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--ink);
  color: var(--surface);
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 9999;
  transform: translateY(-200%);
  transition: transform 0.2s ease;
}
.skip-link:focus { transform: translateY(0); }

/* Containers */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
.container-narrow {
  width: 100%;
  max-width: var(--container-narrow);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
.container-mid {
  width: 100%;
  max-width: var(--container-mid);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

/* Typography helpers */
.font-display { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.01em; }
.font-sans    { font-family: var(--font-sans); }
.font-mono    { font-family: var(--font-mono); }

.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.mono-accent { color: var(--accent); letter-spacing: 0.1em; font-weight: 500; }

/* Headings */
.h-display {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-display);
  line-height: 1.02;
  letter-spacing: -0.028em;
  color: var(--ink);
  font-variation-settings: "opsz" 144;
}
.h-1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-h1);
  line-height: 1.08;
  letter-spacing: -0.022em;
  color: var(--ink);
  font-variation-settings: "opsz" 96;
}
.h-2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-h2);
  line-height: 1.18;
  letter-spacing: -0.018em;
  color: var(--ink);
  font-variation-settings: "opsz" 48;
}

/* Accent underline on key phrases inside headings */
.accent-mark {
  background-image: linear-gradient(to top, var(--accent) 0%, var(--accent) 28%, transparent 28%, transparent 100%);
  padding: 0 0.12em;
}
.accent-underline {
  background-image: linear-gradient(to bottom, transparent 78%, var(--accent) 78%, var(--accent) 96%, transparent 96%);
  padding-bottom: 2px;
}
.h-3 { font-family: var(--font-display); font-weight: 500; font-size: var(--fs-h3); line-height: 1.3; }
.h-4 { font-weight: 600; font-size: var(--fs-h4); line-height: 1.3; }
.h-5 { font-weight: 600; font-size: var(--fs-h5); line-height: 1.4; }

.lead {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 450;
  font-size: 1.2rem;
  line-height: 1.65;
  color: var(--ink);
  max-width: 60ch;
  letter-spacing: 0.005em;
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 18;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prose (article body) */
.prose { max-width: 72ch; }
.prose p + p { margin-top: var(--space-4); }
.prose h2 { margin: var(--space-10) 0 var(--space-4); }
.prose h3 { margin: var(--space-8) 0 var(--space-3); }
.prose ul, .prose ol { margin: var(--space-4) 0; padding-left: 1.25em; list-style-position: outside; }
.prose ul { list-style-type: disc; }
.prose ol { list-style-type: decimal; }
.prose li { padding-left: 0.25em; }
.prose li::marker { color: var(--ink-muted); }
.prose li + li { margin-top: var(--space-2); }
.prose a { color: var(--brand-strong); text-decoration: underline; text-underline-offset: 3px; }
.prose a:hover { color: var(--brand); }

/* Dividers */
hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-10) 0;
}

/* Utility */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-muted { color: var(--ink-muted); }
.text-soft  { color: var(--ink-soft); }
.text-brand { color: var(--brand); }
.text-accent{ color: var(--accent); }

.bg-alt { background: var(--surface-alt); }
.bg-inv { background: var(--surface-inv); color: var(--header-fg); }

/* Reveal: scroll-triggered tinted-light sections (was dark, now airy) */
.reveal-dark {
  background: var(--reveal-bg);
  color: var(--reveal-fg);
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
/* Force all text inside reveal to dark — overrides legacy inline whites */
.reveal-dark h1,
.reveal-dark h2,
.reveal-dark h3,
.reveal-dark h4,
.reveal-dark p,
.reveal-dark span,
.reveal-dark label,
.reveal-dark li,
.reveal-dark strong,
.reveal-dark .mono {
  color: var(--reveal-fg) !important;
}
.reveal-dark .mono,
.reveal-dark .mono-accent {
  color: var(--reveal-accent) !important;
}
.reveal-dark a {
  color: var(--reveal-accent) !important;
}
.reveal-dark a:hover { color: var(--brand-strong) !important; }
.reveal-dark.is-revealed { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal-dark { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}
