/* ===========================================================
   Nah Foods — Design Tokens & Base Stylesheet
   Palette derived from konjac (forest green) + bakery warm cream
   =========================================================== */

/* Size-adjusted fallback fonts — eliminates CLS while Fraunces / Inter load.
   Metrics chosen so the fallback occupies the same box as the web font. */
@font-face {
  font-family: 'Fraunces Fallback';
  src: local('Georgia');
  size-adjust: 105%;
  ascent-override: 92%;
  descent-override: 24%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial');
  size-adjust: 107%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

:root,
[data-theme="light"] {
  /* Surfaces — warm off-white / cream */
  --color-bg: #f6f2ea;
  --color-surface: #fbf7ef;
  --color-surface-2: #ffffff;
  --color-surface-offset: #eee7d9;
  --color-surface-offset-2: #e6dfcf;
  --color-divider: #d9cfbb;
  --color-border: #c9bfa7;

  /* Text */
  --color-text: #17241b;            /* very dark forest */
  --color-text-muted: #5b6a5e;
  --color-text-faint: #8c9a8f;
  --color-text-inverse: #f6f2ea;

  /* Primary accent — deep forest green (konjac leaves) */
  --color-primary: #1e4d35;
  --color-primary-hover: #133626;
  --color-primary-active: #0b2318;
  --color-primary-highlight: #cddcc9;

  /* Secondary — burnt terracotta (earth / root) */
  --color-accent: #b44a1e;
  --color-accent-hover: #8e3714;

  /* Status */
  --color-success: #437a22;
  --color-warning: #a8700e;
  --color-error: #a12c2c;

  /* Radii */
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 8px;
  --radius-full: 9999px;

  /* Shadows tuned to warm cream */
  --shadow-sm: 0 1px 2px rgba(30, 40, 25, 0.06);
  --shadow-md: 0 6px 18px rgba(30, 40, 25, 0.08);
  --shadow-lg: 0 18px 44px rgba(30, 40, 25, 0.12);

  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Content widths */
  --content-narrow: 680px;
  --content-default: 1040px;
  --content-wide: 1280px;

  /* Type scale — fluid clamp() */
  --text-xs:   clamp(0.75rem,  0.70rem + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.82rem + 0.30vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.1rem);
  --text-lg:   clamp(1.125rem, 1.02rem + 0.6vw,  1.4rem);
  --text-xl:   clamp(1.5rem,   1.25rem + 1.1vw,  2.15rem);
  --text-2xl:  clamp(2rem,     1.4rem + 2.4vw,   3.25rem);
  --text-hero: clamp(2.75rem,  1.5rem + 5vw,     5.5rem);

  /* Spacing (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  --font-display: 'Fraunces', 'Fraunces Fallback', 'Source Serif Pro', Georgia, serif;
  --font-body:    'Inter', 'Inter Fallback', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
  --color-bg: #0f1711;
  --color-surface: #141d16;
  --color-surface-2: #1a241c;
  --color-surface-offset: #1f2a22;
  --color-surface-offset-2: #273529;
  --color-divider: #2c3a2f;
  --color-border: #3a4a3d;

  --color-text: #e8e4d7;
  --color-text-muted: #9ba696;
  --color-text-faint: #68746a;
  --color-text-inverse: #0f1711;

  --color-primary: #79b08a;
  --color-primary-hover: #95c5a4;
  --color-primary-active: #a9d2b6;
  --color-primary-highlight: #1e3929;

  --color-accent: #e28158;
  --color-accent-hover: #eb9674;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #0f1711;
    --color-surface: #141d16;
    --color-surface-2: #1a241c;
    --color-surface-offset: #1f2a22;
    --color-surface-offset-2: #273529;
    --color-divider: #2c3a2f;
    --color-border: #3a4a3d;
    --color-text: #e8e4d7;
    --color-text-muted: #9ba696;
    --color-text-faint: #68746a;
    --color-text-inverse: #0f1711;
    --color-primary: #79b08a;
    --color-primary-hover: #95c5a4;
    --color-primary-active: #a9d2b6;
    --color-primary-highlight: #1e3929;
    --color-accent: #e28158;
    --color-accent-hover: #eb9674;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  overflow-x: hidden;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}
ul[role="list"], ol[role="list"] { list-style: none; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.1;
  text-wrap: balance;
  color: var(--color-text);
}

p, li, figcaption { text-wrap: pretty; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--color-primary); }

::selection {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

a, button, [role="button"], input, textarea, select {
  transition:
    color var(--transition-interactive),
    background var(--transition-interactive),
    border-color var(--transition-interactive),
    transform var(--transition-interactive),
    box-shadow var(--transition-interactive);
}

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