/* ============================================================
   app-base.css — Tokens, reset, element base
   Load first. Declares cascade @layer order for the design system.
   ============================================================ */

@layer reset, base, layout, components, utilities;


/* ============================================================
   Tokens — outside layers so every layer can reference them
   ============================================================ */

:root {
  /* Spacing (4 px base unit) */
  --sp-1:  0.25rem;
  --sp-2:  0.5rem;
  --sp-3:  0.75rem;
  --sp-4:  1rem;
  --sp-5:  1.25rem;
  --sp-6:  1.5rem;
  --sp-8:  2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;

  /* Type scale */
  --text-xs:   0.6875rem;   /*  11 px */
  --text-sm:   0.8125rem;   /*  13 px */
  --text-base: 1rem;        /*  16 px */
  --text-lg:   1.125rem;   /*  18 px */
  --text-xl:   1.25rem;    /*  20 px */
  --text-2xl:  1.5rem;     /*  24 px */
  --text-3xl:  1.875rem;   /*  30 px */

  /* Neutral palette (warm undertone) */
  --n-50:  #f9f8f6;
  --n-100: #f0ede8;
  --n-150: #e5e1da;
  --n-200: #d5d0c8;
  --n-300: #bab3a9;
  --n-400: #9e9689;
  --n-500: #7d746a;
  --n-600: #5d5750;
  --n-700: #3b3830;
  --n-800: #201e18;
  --n-900: #0d0c0a;

  /* Surfaces */
  --bg:        white;
  --bg-subtle: hsl(44 15% 93%);
  --surface:   hsl(44 35% 99%);

  /* Borders */
  --border:        #7d746a;   /* ~8:1 on bg */
  --border-subtle: #a8a299;   /* ~5:1 on bg */

  /* Text */
  --text:        #1c1b18;
  --text-muted:  #3b3830;   /* ~14:1 on bg */
  --text-faint:  #5d5750;   /* ~10:1 on bg */

  /* Interactive */
  --link:         #1a4e8a;
  --link-visited: #5b2d8a;

  /* Status colors */
  --success:    #14532d;
  --success-bg: #f0fdf4;
  --success-bd: #bbf7d0;

  --error:    #991b1b;
  --error-bg: #fef2f2;
  --error-bd: #fecaca;

  --warning:    #7c2d12;
  --warning-bg: #fff7ed;
  --warning-bd: #fed7aa;

  /* Typography */
  --font:      system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;

  /* Shape */
  --radius: 3px;

  /* Layout */
  --max-w:    72rem;
  --page-px:  clamp(var(--sp-4), 4vw, var(--sp-8));
  --header-h: 2.75rem;
}


/* ============================================================
   Reset
   ============================================================ */

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }

  @media (prefers-reduced-motion: no-preference) {
    html { interpolate-size: allow-keywords; }
  }

  body {
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }

  img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
  }

  input, button, textarea, select { font: inherit; }

  p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
  p   { text-wrap: pretty; }
  h1, h2, h3, h4, h5, h6 { text-wrap: balance; }

  #root, #__next { isolation: isolate; }
}


/* ============================================================
   Base — element selectors only, no classes
   ============================================================ */

@layer base {
  html {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: var(--text-base);
  }

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

  a:visited { color: var(--link-visited); }
  a:hover   { text-decoration-thickness: 2px; }

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

  h1 { font-size: var(--text-2xl);  line-height: 1.2;  font-weight: 700; }
  h2 { font-size: var(--text-xl);   line-height: 1.25; font-weight: 600; }
  h3 { font-size: var(--text-lg);   line-height: 1.3;  font-weight: 600; }
  h4 { font-size: var(--text-base); line-height: 1.4;  font-weight: 600; }
  h5 { font-size: var(--text-sm);   line-height: 1.4;  font-weight: 600; }
  h6 {
    font-size: var(--text-xs);
    line-height: 1.4;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }

  code, kbd, samp {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--n-100);
    padding: 0.1em 0.35em;
    border-radius: var(--radius);
    border: 1px solid var(--border-subtle);
  }

  pre {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    background: var(--n-100);
    padding: var(--sp-4);
    border-radius: var(--radius);
    border: 1px solid var(--border-subtle);
    overflow-x: auto;
  }

  pre code { background: none; border: none; padding: 0; font-size: inherit; }

  hr {
    border: none;
    border-top: 1px solid var(--border);
  }

  small { font-size: var(--text-sm); color: var(--text-muted); }
}
