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

/* ============================================
   RESET — Modern minimal CSS reset
   ============================================ */
@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  * {
    margin: 0;
    padding: 0;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    min-height: 100dvh;
    -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;
  }
}

/* ============================================
   TOKENS — Design tokens from UI-SPEC
   ============================================ */
@layer tokens {
  :root {
    /* --- Spacing --- */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Component-scoped (not part of standard scale) */
    --hero-padding-y: 96px; /* Phase 2+ hero sections only */

    /* --- Typography --- */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text',
      'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --text-sm: 14px;
    --text-body: 17px;
    --text-heading: 28px;
    --text-display: clamp(32px, 5vw, 48px);
    --weight-regular: 400;
    --weight-semibold: 600;
    --leading-sm: 1.43;
    --leading-body: 1.47;
    --leading-heading: 1.14;
    --leading-display: 1.08;
    --tracking-sm: -0.003em;
    --tracking-body: -0.022em;
    --tracking-heading: 0.007em;
    --tracking-display: -0.003em;

    /* --- Layout --- */
    --container-max: 980px;
    --container-padding: 20px;
    --header-height: 48px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* --- Colors (Light Mode) --- */
    --color-bg: #FFFFFF;
    --color-surface: #F5F5F7;
    --color-accent: #0071E3;
    --color-text: #1D1D1F;
    --color-text-secondary: #6E6E73;
    --color-border: rgba(0, 0, 0, 0.08);
    --color-destructive: #FF3B30;

    /* --- Transitions --- */
    --transition-fast: 150ms ease-out;

    /* --- Phase 2 tokens --- */
    --content-width: 680px;
    --color-star: #FF9500;
    --color-star-empty: #D1D1D6;
  }

  /* Dark Mode overrides (system preference only, D-10) */
  @media (prefers-color-scheme: dark) {
    :root {
      --color-bg: #000000;
      --color-surface: #1D1D1F;
      --color-accent: #2997FF;
      --color-text: #F5F5F7;
      --color-text-secondary: #86868B;
      --color-border: rgba(255, 255, 255, 0.08);
      --color-destructive: #FF453A;
      --color-star: #FF9F0A;
      --color-star-empty: #48484A;
    }
  }

  /* Tablet+ container padding increase */
  @media (min-width: 768px) {
    :root {
      --container-padding: 24px;
    }
  }
}

/* ============================================
   BASE — Element-level styles
   ============================================ */
@layer base {
  body {
    font-family: var(--font-family);
    font-size: var(--text-body);
    line-height: var(--leading-body);
    letter-spacing: var(--tracking-body);
    color: var(--color-text);
    background-color: var(--color-bg);
    font-weight: var(--weight-regular);
  }

  h1,
  h2,
  h3 {
    font-weight: var(--weight-semibold);
    line-height: var(--leading-heading);
    letter-spacing: var(--tracking-heading);
  }

  h1 {
    font-size: var(--text-display);
    line-height: var(--leading-display);
    letter-spacing: var(--tracking-display);
  }

  h2 {
    font-size: var(--text-heading);
  }

  small {
    font-size: var(--text-sm);
    line-height: var(--leading-sm);
    letter-spacing: var(--tracking-sm);
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  a:hover,
  a:focus {
    color: var(--color-accent);
  }

  :focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
  }
}
