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

/* ============================================================
   RESET — minimal, Comeau-flavored
   ============================================================ */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html, body { height: 100%; }
  body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
  img, picture, video, canvas, svg { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; color: inherit; }
  p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
  button { background: none; border: 0; cursor: pointer; }
  a { color: inherit; }
}

/* ============================================================
   TOKENS — design system
   ============================================================ */
@layer tokens {
  :root {
    /* Palette (architect-locked) */
    --color-ink: #0E1116;
    --color-paper: #F7F5F0;
    --color-paper-stripe: #EDE9E0;
    --color-accent: #FF5A1F;
    --color-accent-deep: #E04E1A;
    --color-muted: #5A6473;
    --color-success: #2F855A;
    --color-on-accent: #FFFFFF;

    /* Hairline borders */
    --hairline-10: rgba(14, 17, 22, 0.10);
    --hairline-20: rgba(14, 17, 22, 0.20);
    --tint-ink-04: rgba(14, 17, 22, 0.04);

    /* Typography */
    --font-heading: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;

    --type-h1: clamp(2.75rem, 4.5vw + 1rem, 4.5rem);
    --type-h2: clamp(1.875rem, 2.4vw + 1rem, 2.5rem);
    --type-h3: 1.5rem;
    --type-body: 1.125rem;
    --type-small: 0.875rem;
    --type-eyebrow: 0.8125rem;

    --lh-heading: 1.15;
    --lh-body: 1.55;

    /* Spacing scale */
    --space-section-y: clamp(48px, 8vw, 96px);
    --space-stack-lg: 48px;
    --space-stack-md: 32px;
    --space-stack-sm: 24px;
    --space-card-pad: 32px;
    --container-max: 1200px;
    --container-pad: clamp(24px, 4vw, 48px);
    --narrow-max: 760px;

    /* Effects */
    --radius-sm: 8px;
    --radius-md: 12px;
    --transition-fast: 120ms ease-out;
    --transition-reveal: 400ms ease-out;
  }
}

/* ============================================================
   BASE — element-level
   ============================================================ */
@layer base {
  body {
    font-family: var(--font-body);
    font-size: var(--type-body);
    line-height: var(--lh-body);
    color: var(--color-ink);
    background: var(--color-paper);
  }

  h1, h2, h3 {
    font-family: var(--font-heading);
    line-height: var(--lh-heading);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 0.5em;
  }
  h1 { font-size: var(--type-h1); font-weight: 600; letter-spacing: -0.025em; }
  h1 em { font-style: italic; }
  h2 { font-size: var(--type-h2); }
  h3 { font-size: var(--type-h3); }

  p { margin-bottom: 1.25em; }
  p:last-child { margin-bottom: 0; }

  strong { font-weight: 600; color: var(--color-ink); }

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

  /* Focus ring — visible on every interactive element */
  :focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
    border-radius: 2px;
  }

  /* Skip link — only visible on focus */
  .skip-link {
    position: absolute;
    top: -40px;
    left: 12px;
    padding: 8px 16px;
    background: var(--color-ink);
    color: var(--color-paper);
    z-index: 1000;
    border-radius: var(--radius-sm);
    transition: top var(--transition-fast);
  }
  .skip-link:focus { top: 12px; }
}

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

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

  .section {
    padding-block: var(--space-section-y);
    opacity: 0;
    transform: translateY(16px);
    transition: opacity var(--transition-reveal), transform var(--transition-reveal);
  }
  .section[data-revealed="true"] { opacity: 1; transform: none; }
  .section-stripe { background: var(--color-paper-stripe); }

  /* Eyebrow */
  .eyebrow {
    font-family: var(--font-body);
    font-size: var(--type-eyebrow);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--color-accent-deep);
    margin-bottom: 1.5em;
  }

  .section-subhead {
    color: var(--color-muted);
    font-size: 1.25rem;
    line-height: 1.5;
    max-width: 640px;
    margin-bottom: var(--space-stack-md);
  }

  /* ----- HEADER ----- */
  .site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--color-paper) 92%, transparent);
    backdrop-filter: saturate(180%) blur(8px);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-fast);
  }
  .site-header[data-state="scrolled"] { border-bottom-color: var(--hairline-10); }
  /* Hide CTA until past hero */
  .site-header[data-state="top"] .header-inner > .button { opacity: 0; pointer-events: none; visibility: hidden; }

  .header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    height: 64px;
  }
  .wordmark {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.375rem;
    letter-spacing: -0.01em;
  }
  .wordmark-accent { color: var(--color-accent); }

  .header-nav {
    display: none;
    gap: 32px;
    font-size: 0.9375rem;
    color: var(--color-muted);
  }
  .header-nav a:hover { color: var(--color-ink); }

  @media (min-width: 1024px) {
    .header-nav { display: flex; }
  }

  /* ----- BUTTONS ----- */
  .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 24px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
    white-space: nowrap;
    text-align: center;
  }
  .button-sm { height: 40px; padding: 0 16px; font-size: 0.9375rem; }

  .button-primary {
    background: var(--color-accent-deep);
    color: var(--color-on-accent);
    border: 1px solid var(--color-accent-deep);
  }
  .button-primary:hover { background: var(--color-ink); border-color: var(--color-ink); }

  .button-secondary {
    background: transparent;
    color: var(--color-ink);
    border: 1px solid var(--color-ink);
  }
  .button-secondary:hover { background: var(--tint-ink-04); }

  .cta-pair {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
  }
  .cta-helper {
    color: var(--color-muted);
    font-size: var(--type-small);
    margin-bottom: 0;
  }

  /* ----- HERO ----- */
  .section-hero {
    padding-top: clamp(48px, 6vw, 80px);
    padding-bottom: clamp(64px, 8vw, 120px);
  }
  .hero-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(40px, 6vw, 80px);
    align-items: center;
  }
  @media (min-width: 1024px) {
    .hero-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
  }
  .hero-h1 {
    margin-bottom: 24px;
  }
  .accent-underline {
    color: var(--color-accent);
    position: relative;
    white-space: nowrap;
  }
  .accent-underline::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -0.04em;
    height: 4px;
    background: var(--color-accent);
    border-radius: 2px;
  }
  .hero-subhead {
    font-size: 1.25rem;
    line-height: 1.5;
    color: var(--color-muted);
    margin-bottom: 32px;
    max-width: 600px;
  }

  /* Hero CSS-art composition */
  .hero-figure { margin: 0; }
  .hero-art {
    position: relative;
    aspect-ratio: 1 / 1;
    max-width: 600px;
    margin-inline: auto;
    background: linear-gradient(140deg, #EDE9E0 0%, #F7F5F0 100%);
    border: 1px solid var(--hairline-10);
    border-radius: var(--radius-md);
    overflow: hidden;
  }
  .hero-art__paper {
    position: absolute;
    background: #FFFFFF;
    border: 1px solid var(--hairline-20);
    border-radius: 4px;
  }
  .hero-art__paper--back {
    width: 38%; height: 50%;
    left: 8%; top: 14%;
    transform: rotate(-7deg);
    background: #FAFAF7;
  }
  .hero-art__paper--mid {
    width: 40%; height: 54%;
    left: 14%; top: 22%;
    transform: rotate(-2deg);
    background: #FFFFFF;
  }
  .hero-art__paper--front {
    width: 42%; height: 56%;
    left: 18%; top: 28%;
    transform: rotate(3deg);
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 10px;
  }
  .hero-art__line {
    height: 4px;
    background: var(--hairline-20);
    border-radius: 2px;
  }
  .hero-art__line--short { width: 60%; }
  .hero-art__paper--front .hero-art__line:first-child {
    background: var(--color-ink);
    width: 70%;
    height: 6px;
    margin-bottom: 4px;
  }

  .hero-art__calendar {
    position: absolute;
    width: 50%;
    height: 44%;
    right: 6%;
    top: 12%;
    background: #FFFFFF;
    border: 1.5px solid var(--color-ink);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(14,17,22,0.06);
    transform: rotate(2deg);
  }
  .hero-art__cal-header {
    height: 18%;
    background: var(--color-ink);
    border-bottom: 1.5px solid var(--color-ink);
    display: flex;
    align-items: center;
    padding-left: 8px;
  }
  .hero-art__cal-header::after {
    content: "";
    width: 32%; height: 30%;
    background: var(--color-paper);
    border-radius: 1px;
  }
  .hero-art__cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: 1fr;
    height: 82%;
  }
  .hero-art__cal-grid > span {
    border-right: 1px solid var(--hairline-10);
    border-bottom: 1px solid var(--hairline-10);
    position: relative;
  }
  .hero-art__cal-grid > span.is-marked::after {
    content: "";
    position: absolute;
    inset: 22% 22%;
    background: var(--hairline-20);
    border-radius: 50%;
  }
  .hero-art__cal-grid > span.is-marked--accent::after {
    background: var(--color-accent);
  }

  .hero-art__bubble {
    position: absolute;
    right: 4%;
    bottom: 8%;
    width: 38%;
    height: 28%;
    background: var(--color-accent);
    border-radius: 12px 12px 4px 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
  }
  .hero-art__bubble::after {
    content: "";
    position: absolute;
    left: -8px;
    bottom: 12px;
    border: 6px solid transparent;
    border-right-color: var(--color-accent);
    border-bottom: 0;
  }
  .hero-art__bubble span {
    height: 4px;
    background: rgba(255,255,255,0.85);
    border-radius: 2px;
  }
  .hero-art__bubble span:first-child { width: 80%; }
  .hero-art__bubble span:nth-child(2) { width: 100%; }
  .hero-art__bubble span:last-child { width: 50%; }

  /* ----- PROBLEM / pull-quote ----- */
  .pull-quote {
    margin: var(--space-stack-lg) 0;
    padding: 32px;
    background: var(--color-paper);
    border-left: 4px solid var(--color-accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  }
  .pull-quote__stat {
    font-family: var(--font-heading);
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    font-weight: 600;
    line-height: 1;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
  }
  .pull-quote__arrow {
    color: var(--color-accent);
    margin: 0 0.25em;
  }
  .pull-quote__caption {
    color: var(--color-muted);
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 0;
  }
  .pull-quote sup a, .footnotes a {
    color: var(--color-accent-deep);
    font-weight: 500;
    text-decoration: none;
  }
  .footnotes {
    list-style: none;
    padding: 0;
    margin-top: var(--space-stack-md);
    border-top: 1px solid var(--hairline-10);
    padding-top: 16px;
    font-size: var(--type-small);
    color: var(--color-muted);
    counter-reset: fn;
  }
  .footnotes li { counter-increment: fn; }
  .footnotes li::before { content: "[" counter(fn) "] "; color: var(--color-accent-deep); font-weight: 500; }
  .footnotes a { text-decoration: underline; text-underline-offset: 2px; }

  /* ----- FEATURES ----- */
  .feature-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: var(--space-stack-md);
  }
  @media (min-width: 768px) {
    .feature-grid { grid-template-columns: repeat(2, 1fr); }
  }
  @media (min-width: 1024px) {
    .feature-grid { grid-template-columns: repeat(2, 1fr); gap: 32px; }
  }
  .card {
    padding: var(--space-card-pad);
    background: transparent;
    border: 1px solid var(--hairline-10);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .card:hover { border-color: var(--hairline-20); }
  .card-icon { width: 64px; height: 64px; margin-bottom: 4px; }
  .card h3 { margin-bottom: 0; }
  .card p { margin-bottom: 0; }
  .card-footnote {
    font-size: var(--type-small);
    color: var(--color-muted);
    margin-top: 8px;
  }

  /* ----- COMPARISON ----- */
  .table-wrap {
    overflow-x: auto;
    margin: var(--space-stack-md) 0;
    border: 1px solid var(--hairline-10);
    border-radius: var(--radius-md);
    background: var(--color-paper);
  }
  .comparison {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
    min-width: 640px;
  }
  .comparison th,
  .comparison td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--hairline-10);
    vertical-align: middle;
  }
  .comparison thead th {
    font-family: var(--font-body);
    font-size: var(--type-eyebrow);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--color-muted);
    background: transparent;
    border-bottom: 1px solid var(--hairline-20);
  }
  .comparison tbody th {
    font-weight: 500;
    color: var(--color-ink);
    width: 44%;
  }
  .comparison td {
    text-align: center;
  }
  .comparison .is-us {
    background: color-mix(in srgb, var(--color-accent) 6%, transparent);
    font-weight: 600;
  }
  .comparison thead th.is-us { color: var(--color-accent-deep); }
  .comparison tbody tr:last-child th,
  .comparison tbody tr:last-child td { border-bottom: 0; }
  .cell-no { color: var(--color-muted); }
  .cell-yes { color: var(--color-accent); font-weight: 700; font-size: 1.25rem; }
  .cell-yes-muted { color: var(--color-muted); font-weight: 600; font-size: 1.125rem; }

  .comparison-closing {
    color: var(--color-muted);
    max-width: 640px;
    margin-top: var(--space-stack-md);
  }

  /* ----- TRUST ----- */
  .trust-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    margin-top: var(--space-stack-md);
  }
  @media (min-width: 768px) {
    .trust-grid { grid-template-columns: repeat(2, 1fr); gap: 40px; }
  }
  .trust-block {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .trust-icon { width: 40px; height: 40px; }
  .trust-block h3 {
    font-size: 1.25rem;
    margin-bottom: 0;
  }
  .trust-block p { margin-bottom: 0; color: var(--color-muted); }
  .trust-cta {
    margin-top: var(--space-stack-lg);
    padding-top: var(--space-stack-md);
    border-top: 1px solid var(--hairline-10);
  }

  /* ----- TEAM ----- */
  .team-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    margin-top: var(--space-stack-md);
  }
  @media (min-width: 768px) {
    .team-grid { grid-template-columns: repeat(2, 1fr); gap: 48px; }
  }
  .team-block h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    line-height: 1.3;
  }
  .team-role {
    color: var(--color-muted);
    font-weight: 500;
    font-style: italic;
  }
  .team-block p { margin-bottom: 0; color: var(--color-muted); }

  /* ----- FORMS ----- */
  .section-final h2 { margin-bottom: 0.25em; }
  .form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: var(--space-stack-lg);
  }
  @media (min-width: 900px) {
    .form-grid { grid-template-columns: repeat(2, 1fr); gap: 32px; }
  }
  .form-card {
    padding: var(--space-card-pad);
    background: var(--color-paper);
    border: 1px solid var(--hairline-10);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .form-headline { font-size: 1.375rem; margin-bottom: 0; }
  .form-subhead { color: var(--color-muted); font-size: 0.9375rem; margin-bottom: 8px; }

  .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .field-label {
    font-size: var(--type-small);
    font-weight: 500;
    color: var(--color-ink);
  }
  .field-optional { color: var(--color-muted); font-weight: 400; }

  .field input[type="email"],
  .field input[type="text"] {
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--hairline-20);
    border-radius: var(--radius-sm);
    background: #FFFFFF;
    font-size: 1rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  }
  .field input[type="email"]:hover,
  .field input[type="text"]:hover {
    border-color: var(--color-ink);
  }
  .field input[type="email"]:focus,
  .field input[type="text"]:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 18%, transparent);
    outline: none;
  }
  .field input[type="email"]:user-invalid {
    border-color: var(--color-accent-deep);
  }

  .field input[type="file"] {
    padding: 12px;
    border: 1px dashed var(--hairline-20);
    border-radius: var(--radius-sm);
    background: var(--color-paper-stripe);
    font-size: 0.9375rem;
    cursor: pointer;
  }
  .field input[type="file"]:hover { border-color: var(--color-ink); }
  .field input[type="file"]:focus {
    border-color: var(--color-accent);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 18%, transparent);
  }

  .honeypot {
    position: absolute !important;
    left: -10000px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none;
  }

  .form-submit { margin-top: 8px; align-self: flex-start; }

  .form-status {
    margin-bottom: 0;
    font-size: 0.9375rem;
    min-height: 1.5em;
  }
  .form-status[data-state="idle"] { display: none; }
  .form-status[data-state="loading"] { color: var(--color-muted); }
  .form-status[data-state="success"] { color: var(--color-success); font-weight: 500; }
  .form-status[data-state="error"] { color: var(--color-accent-deep); }

  .form-card[data-form-state="success"] .field,
  .form-card[data-form-state="success"] .form-submit { display: none; }

  .privacy-note {
    margin-top: var(--space-stack-md);
    font-size: var(--type-small);
    color: var(--color-muted);
  }
  .privacy-note summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--color-ink);
    padding: 8px 0;
  }
  .privacy-note summary:hover { color: var(--color-accent-deep); }
  .privacy-note p { margin-top: 8px; margin-bottom: 0; }
  .privacy-note a { color: var(--color-accent-deep); text-decoration: underline; text-underline-offset: 2px; }

  /* ----- FOOTER ----- */
  .site-footer {
    padding-block: 48px;
    border-top: 1px solid var(--hairline-10);
    font-size: var(--type-small);
    color: var(--color-muted);
  }
  .footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 32px;
    justify-content: space-between;
    align-items: center;
  }
  .site-footer a { color: var(--color-muted); transition: color var(--transition-fast); }
  .site-footer a:hover { color: var(--color-accent-deep); }
  .footer-contact a { color: var(--color-ink); }
  .site-footer p { margin-bottom: 0; }
}

/* ============================================================
   UTILITIES + REDUCED MOTION
   ============================================================ */
@layer utilities {
  @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;
    }
    .section { transform: none !important; }
  }
}
