/*
 * JumpStartMD Landing Page — Design System Foundation
 * Plain HTML + CSS, no frameworks
 * 2026 best practices: cascade layers, nesting, clamp(), color-mix()
 */

/* ============================================================
   0. CASCADE LAYERS
   ============================================================ */
@layer reset, base, components, utilities;

/* ============================================================
   1. RESET (Josh Comeau modern reset + fixes)
   ============================================================ */
@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  * {
    margin: 0;
  }

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

  html:focus-within {
    scroll-behavior: smooth;
  }

  body {
    min-height: 100dvh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-wrap: anywhere;
  }

  img,
  picture,
  video {
    display: block;
    max-width: 100%;
    height: auto;
  }

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

  h1,
  h2,
  h3,
  h4 {
    text-wrap: balance;
  }

  p {
    text-wrap: pretty;
  }
}

/* ============================================================
   2. BASE — Design tokens, typography, layout
   ============================================================ */
@layer base {

  /* --- Colors (JSMD brand) --- */
  :root {
    /* Brand */
    --navy: #002A3A;
    --cream: #e6cbb2;
    --gold: #aa8764;
    --orange: #FFB26A;
    --sage: #4E5D48;
    --sage-bright: #4a7a60;

    /* Text */
    --text-dark: #002A3A;
    --text-body: #2c2c2c;
    --text-muted: #64748b;
    --text-light: #8a8a8a;

    /* Surfaces */
    --bg-white: #ffffff;
    --bg-alt: #f9fafb;

    /* Hover shades — hardcoded fallbacks */
    --navy-hover: #1a3f4c;
    --orange-hover: #d9974f;

    /* Border */
    --color-border: rgba(100, 114, 139, 0.35);

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
  }

  /* color-mix upgrade for browsers that support it */
  @supports (color: color-mix(in oklch, white, black)) {
    :root {
      --navy-hover: color-mix(in oklch, var(--navy) 85%, white);
      --orange-hover: color-mix(in oklch, var(--orange) 85%, black);
    }
  }

  /* --- Typography scale (fluid clamp) --- */
  :root {
    --font-h1: clamp(2.25rem, 1.5rem + 3vw, 3.5rem);
    --font-h2: clamp(1.75rem, 1.2rem + 2.5vw, 2.5rem);
    --font-h3: clamp(1.375rem, 1rem + 1.5vw, 1.75rem);
    --font-h4: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
    --font-body: 1rem;
    --font-small: 0.875rem;
    --font-xs: 0.75rem;

    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --font-display: var(--font-sans);
  }

  /* --- Spacing scale (8px base) --- */
  :root {
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
    --space-2xl: 4rem;
    --space-3xl: 6rem;
  }

  /* --- Layout tokens --- */
  :root {
    --gutter: 20px;
    --container-max: 1200px;
    --header-height: 0px;
  }

  @media (min-width: 768px) {
    :root {
      --gutter: 32px;
    }
  }

  @media (min-width: 1024px) {
    :root {
      --gutter: 40px;
    }
  }

  /* --- Body --- */
  body {
    font-family: var(--font-sans);
    font-size: var(--font-body);
    color: var(--text-body);
    background: var(--bg-white);
  }

  /* --- Headings --- */
  h1,
  h2,
  h3,
  h4 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.2;
    color: var(--navy);
  }

  h1 { font-size: var(--font-h1); }
  h2 { font-size: var(--font-h2); }
  h3 { font-size: var(--font-h3); }
  h4 { font-size: var(--font-h4); }

  /* --- Links --- */
  a {
    color: var(--gold);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
  }

  a:hover {
    color: var(--navy);
  }

  /* --- Keyboard focus rings --- */
  :focus-visible {
    outline: 2px solid var(--navy);
    outline-offset: 2px;
  }

  :focus:not(:focus-visible) {
    outline: none;
  }

  /* --- Anchor scroll offset --- */
  :target {
    scroll-margin-top: var(--header-height);
  }

  /* --- Reduced motion --- */
  @media (prefers-reduced-motion: reduce) {
    html:focus-within {
      scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      transition-duration: 0.01ms !important;
    }
  }

  /* --- High contrast --- */
  @media (prefers-contrast: more) {
    :root {
      --text-muted: #4a4a4a;
      --text-light: #5a5a5a;
    }
  }
}

/* ============================================================
   3. COMPONENTS
   ============================================================ */
@layer components {

  /* --- Container --- */
  .container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--gutter);
  }

  /* --- Section --- */
  .section {
    padding-block: clamp(3rem, 6vw, 6rem);
  }

  .section--dark {
    background: var(--navy);
    color: var(--bg-white);

    & :is(h1, h2, h3, h4) {
      color: var(--bg-white);
    }

    & a {
      color: var(--orange);
    }

    & a:hover {
      color: var(--cream);
    }

    & :focus-visible {
      outline-color: var(--orange);
    }
  }

  .section--alt {
    background: var(--bg-alt);
  }

  .section--cream {
    background: var(--cream);
  }

  /* --- Grid --- */
  .grid {
    display: grid;
    gap: var(--space-md);
  }

  .grid--2 { grid-template-columns: 1fr; }
  .grid--3 { grid-template-columns: 1fr; }
  .grid--4 { grid-template-columns: 1fr; }

  @media (min-width: 768px) {
    .grid--2 { grid-template-columns: repeat(2, 1fr); }
    .grid--3 { grid-template-columns: repeat(2, 1fr); }
    .grid--4 { grid-template-columns: repeat(2, 1fr); }
  }

  @media (min-width: 1024px) {
    .grid--3 { grid-template-columns: repeat(3, 1fr); }
    .grid--4 { grid-template-columns: repeat(4, 1fr); }
  }

  /* --- Buttons --- */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: 0.75rem 1.5rem;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: var(--font-body);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
  }

  .btn--primary {
    background: var(--orange);
    color: var(--navy);

    &:hover {
      background: var(--orange-hover);
    }
  }

  .btn--secondary {
    background: transparent;
    color: var(--navy);
    border-color: var(--navy);

    &:hover {
      background: var(--navy);
      color: var(--bg-white);
    }
  }

  .btn--dark {
    background: var(--navy);
    color: var(--bg-white);

    &:hover {
      background: var(--navy-hover);
    }
  }

  /* --- Card --- */
  .card {
    container-type: inline-size;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  }

  /* --- Form Inputs --- */
  .input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-body);
    transition: border-color 0.2s;

    &:focus {
      outline: 2px solid var(--navy);
      outline-offset: 2px;
      border-color: var(--navy);
    }
  }
}

/* ============================================================
   4. UTILITIES
   ============================================================ */
@layer utilities {

  .text-center {
    text-align: center;
  }

  .flow > * + * {
    margin-top: var(--space-md);
  }

  .prose {
    max-width: 65ch;
  }

  .icon {
    display: inline-block;
    vertical-align: -0.125em;
  }

  .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;
  }

  /* Disabled states */
  .btn:disabled,
  .btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
  }

  .input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-alt);
  }
}
