/* ═══════════════════════════════════════════════════════════════════════
   FOUNDATION.CSS — a reusable starter stylesheet
   ───────────────────────────────────────────────────────────────────────
   A brand-agnostic base for new projects: design tokens, modern reset,
   typography, layout helpers, core components (buttons, cards, chips,
   fields, nav, footer), scroll-reveal motion, and a11y utilities.

   HOW TO USE
   1. Link it first, before any project-specific CSS:
        <link rel="stylesheet" href="foundation.css" />
   2. Override the tokens in :root to match your brand (only the tokens —
      never the component rules). Everything downstream re-themes itself.
   3. Dark mode is driven by  <html data-theme="dark">.  To avoid a flash
      of the wrong theme, set it before first paint with this inline script
      in <head>:

        <script>
          (function () {
            try {
              var t = localStorage.getItem('theme')
                || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
              document.documentElement.setAttribute('data-theme', t);
            } catch (e) { document.documentElement.setAttribute('data-theme', 'light'); }
          })();
        </script>
   ═══════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════
   1. DESIGN TOKENS
   Override these per project. Everything else reads from them.
   ═══════════════════════════════════════════════════════════ */
:root {
  /* — Brand accent (teal→emerald; app theme reconciled) ───── */
  --accent:          #0f766e;
  --accent-strong:   #0b5d56;
  --accent-soft:     #99f6e4;
  --accent-tint:     rgba(15, 118, 110, 0.08);

  /* — Surfaces & ink (light theme) ───────────────────────── */
  --bg:              #FAFBFC;   /* page background          */
  --bg-2:            #F2F4F7;   /* raised surface / cards   */
  --bg-3:            #FFFFFF;   /* highest surface          */
  --text:            #0F1419;   /* primary text             */
  --text-2:          #3A424D;   /* strong secondary         */
  --muted:           #646E7B;   /* labels, captions         */
  --muted-2:         #98A1AD;   /* placeholders, hints      */
  --border:          #E8EBEE;   /* hairlines                */
  --border-2:        #D6DBE1;   /* stronger hairlines       */

  /* — Semantic feedback ──────────────────────────────────── */
  --success:         #157f3c;
  --warning:         #b45309;
  --danger:          #c0392f;
  --info:            #1d4ed8;

  /* — Typography ─────────────────────────────────────────── */
  --font-sans:       'Inter', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display:    var(--font-sans);
  --font-serif:      ui-serif, Georgia, "Times New Roman", serif;
  --font-mono:       ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  /* Fluid type scale (clamp: min, preferred, max) */
  --text-xs:         0.75rem;                              /* 12px  */
  --text-sm:         0.875rem;                             /* 14px  */
  --text-base:       1rem;                                 /* 16px  */
  --text-lg:         1.125rem;                             /* 18px  */
  --text-xl:         clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  --text-2xl:        clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
  --text-3xl:        clamp(1.875rem, 1.4rem + 2.2vw, 2.75rem);
  --text-4xl:        clamp(2.25rem, 1.5rem + 3.6vw, 4rem);
  --text-5xl:        clamp(3rem, 1.8rem + 5.4vw, 6rem);

  --leading-tight:   1.1;
  --leading-snug:    1.3;
  --leading-normal:  1.6;
  --tracking-tight:  -0.025em;
  --tracking-normal: 0;
  --tracking-wide:   0.14em;

  /* — Spacing scale (rem-based, 4px grid) ────────────────── */
  --space-1:         0.25rem;   /* 4   */
  --space-2:         0.5rem;    /* 8   */
  --space-3:         0.75rem;   /* 12  */
  --space-4:         1rem;      /* 16  */
  --space-6:         1.5rem;    /* 24  */
  --space-8:         2rem;      /* 32  */
  --space-12:        3rem;      /* 48  */
  --space-16:        4rem;      /* 64  */
  --space-24:        6rem;      /* 96  */
  --space-32:        8rem;      /* 128 */

  /* — Radius ─────────────────────────────────────────────── */
  --radius-sm:       6px;
  --radius:          10px;
  --radius-md:       14px;
  --radius-lg:       20px;
  --radius-full:     999px;

  /* — Shadows ────────────────────────────────────────────── */
  --shadow-sm:       0 1px 2px rgba(10, 14, 26, 0.04);
  --shadow-md:       0 4px 12px rgba(10, 14, 26, 0.06), 0 1px 2px rgba(10, 14, 26, 0.04);
  --shadow-lg:       0 12px 40px rgba(10, 14, 26, 0.08), 0 4px 12px rgba(10, 14, 26, 0.04);
  --shadow-xl:       0 24px 56px -20px rgba(10, 14, 26, 0.20);

  /* — Motion ─────────────────────────────────────────────── */
  --ease-out:        cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-2:      cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out:     cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast:        0.2s;
  --dur:             0.4s;
  --dur-slow:        0.7s;

  /* — Layout ─────────────────────────────────────────────── */
  --container:       1200px;
  --container-pad:   24px;

  /* — z-index scale ──────────────────────────────────────── */
  --z-base:          1;
  --z-dropdown:      100;
  --z-sticky:        200;
  --z-nav:           500;
  --z-overlay:       800;
  --z-modal:         900;
  --z-top:           9999;
}

/* — Dark theme: override only the surface/ink tokens ──────── */
[data-theme="dark"] {
  --accent:          #2dd4bf;
  --accent-strong:   #5eead4;
  --accent-soft:     #134e4a;
  --accent-tint:     rgba(45, 212, 191, 0.16);

  --bg:              #0B0D10;
  --bg-2:            #14171C;
  --bg-3:            #16191F;
  --text:            #E9ECEF;
  --text-2:          #C2C8D0;
  --muted:           #8B94A0;
  --muted-2:         #5D6671;
  --border:          #232830;
  --border-2:        #2F3641;

  --shadow-sm:       0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-md:       0 4px 12px rgba(0, 0, 0, 0.40), 0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-lg:       0 12px 40px rgba(0, 0, 0, 0.50), 0 4px 12px rgba(0, 0, 0, 0.30);
  --shadow-xl:       0 24px 56px -20px rgba(0, 0, 0, 0.55);
}

/* ═══════════════════════════════════════════════════════════
   2. MODERN RESET
   ═══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
a { color: inherit; text-decoration: none; }

/* ═══════════════════════════════════════════════════════════
   3. TYPOGRAPHY
   ═══════════════════════════════════════════════════════════ */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
}
h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); line-height: var(--leading-snug); }
h4 { font-size: var(--text-xl);  line-height: var(--leading-snug); }

a:not([class]) {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--dur-fast) var(--ease-out);
}
a:not([class]):hover { color: var(--accent-strong); }

small { font-size: var(--text-sm); }
strong, b { font-weight: 600; color: var(--text); }
code, pre, kbd { font-family: var(--font-mono); font-size: 0.9em; }
code {
  background: var(--accent-tint);
  color: var(--accent);
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
}

/* Utility text classes */
.font-display { font-family: var(--font-display); }
.font-serif   { font-family: var(--font-serif); }
.font-mono    { font-family: var(--font-mono); }
.text-muted   { color: var(--muted); }
.text-center  { text-align: center; }
.text-balance { text-wrap: balance; }
.tabular      { font-variant-numeric: tabular-nums; }

.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--muted);
}

/* ═══════════════════════════════════════════════════════════
   4. LAYOUT HELPERS
   ═══════════════════════════════════════════════════════════ */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}
@media (min-width: 1024px) { .container { padding-inline: 40px; } }

.section { padding-block: var(--space-24); }

/* Vertical rhythm: adds space between flow children */
.stack > * + * { margin-top: var(--space-4); }
.stack-lg > * + * { margin-top: var(--space-8); }

/* Auto-responsive grid: cards wrap based on a min width */
.grid-auto {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
}

.flex      { display: flex; gap: var(--space-4); }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════════
   5. COMPONENTS
   ═══════════════════════════════════════════════════════════ */

/* — Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 500;
  font-size: var(--text-sm);
  line-height: 1;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur) var(--ease-out),
              box-shadow var(--dur) var(--ease-out);
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -4px var(--accent-tint);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-2);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: 0.5rem 0.875rem; font-size: var(--text-xs); }
.btn-lg { padding: 0.95rem 1.6rem; font-size: var(--text-base); }

/* — Card ───────────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease-out),
              border-color var(--dur) var(--ease-out),
              box-shadow var(--dur) var(--ease-out);
}
.card-hover:hover {
  transform: translateY(-2px);
  border-color: var(--border-2);
  box-shadow: var(--shadow-lg);
}

/* — Chip / tag ─────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border-2);
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-tint);
}

/* — Form fields ────────────────────────────────────────── */
.field {
  width: 100%;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 0.75rem 0.875rem;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.field::placeholder { color: var(--muted-2); }
.field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.field-underline {
  border: 0;
  border-bottom: 1px solid var(--border-2);
  border-radius: 0;
  background: transparent;
  padding-inline: 0;
}
.field-underline:focus { box-shadow: none; border-bottom-color: var(--accent); }
textarea.field { resize: vertical; min-height: 6rem; }

.label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: var(--space-2);
}

/* — Nav scaffold ───────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}
.nav.scrolled { border-bottom-color: var(--border); }
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  max-width: var(--container);
  margin-inline: auto;
  padding: var(--space-4) var(--container-pad);
}
.nav-links {
  display: none;
  gap: var(--space-6);
  list-style: none;
  padding: 0; margin: 0;
}
@media (min-width: 900px) { .nav-links { display: flex; } }
.nav-links a {
  font-size: var(--text-sm);
  color: var(--text-2);
  transition: color var(--dur-fast) var(--ease-out);
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }

/* — Footer scaffold ────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding-block: var(--space-16);
  color: var(--muted);
  font-size: var(--text-sm);
}

/* — Divider ────────────────────────────────────────────── */
.hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin-block: var(--space-12);
}

/* ═══════════════════════════════════════════════════════════
   6. MOTION — scroll reveal
   Add  data-reveal  to any element; toggle  .is-visible  with an
   IntersectionObserver (snippet below the styles).
   ═══════════════════════════════════════════════════════════ */
[data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity var(--dur-slow) var(--ease-out),
              transform var(--dur-slow) var(--ease-out);
}
[data-reveal].is-visible { opacity: 1; transform: none; }

/* Stagger children: set --i on each child (style="--i:1") */
[data-reveal-stagger] > * {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity var(--dur-slow) var(--ease-out),
              transform var(--dur-slow) var(--ease-out);
  transition-delay: calc(var(--i, 0) * 80ms);
}
[data-reveal-stagger].is-visible > * { opacity: 1; transform: none; }

/*  IntersectionObserver snippet — paste into your JS:

    document.querySelectorAll('[data-reveal], [data-reveal-stagger]').forEach(el => {
      const io = new IntersectionObserver((entries) => {
        entries.forEach(e => {
          if (e.isIntersecting) { e.target.classList.add('is-visible'); io.unobserve(e.target); }
        });
      }, { threshold: 0.1 });
      io.observe(el);
    });
*/

/* ═══════════════════════════════════════════════════════════
   7. ACCESSIBILITY & UTILITIES
   ═══════════════════════════════════════════════════════════ */
:where(a, button, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Visually hidden but available to screen readers */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.no-scroll { overflow: hidden; }

/* Respect user motion preference everywhere */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  [data-reveal], [data-reveal-stagger] > * { opacity: 1; transform: none; }
}
