
@layer tokens, overrides;

@layer tokens {
  :root {
    color-scheme: dark;

    /* Brand seed: oxidized iron, between Rhodesian-flag copper and tabasco.
       Anchored to this seed, the rest of the palette is composed. */
    --color-rust: oklch(0.55 0.16 50);
    --color-olive: oklch(0.7 0.08 130);

    /* Surfaces — warm-tinted near-black, not OLED pure-black, not the cream
       SaaS-default. Lightness 0.18 with chroma 0.012 toward the brand hue
       keeps the surface warm without drifting into the brown band. */
    --bg: oklch(0.18 0.012 60);
    --surface: oklch(0.225 0.014 60);
    --surface-raised: oklch(0.26 0.014 60);

    /* Ink — parchment-leaning, chroma just above zero. NOT the cream/sand
       2026 default; chroma 0.02 toward the brand hue only. */
    --ink: oklch(0.94 0.02 75);
    --ink-soft: oklch(0.94 0.02 75 / 0.72);
    /* Bumped from 0.45 to 0.6 so faint secondary copy still passes 4.5:1
       against --bg and --surface. */
    --ink-faint: oklch(0.94 0.02 75 / 0.6);

    /* Lines + state colors. */
    --rule: oklch(0.94 0.02 75 / 0.12);
    --rule-strong: oklch(0.94 0.02 75 / 0.22);
    --color-success: oklch(0.72 0.18 165);
    --color-error: oklch(0.62 0.22 35);

    /* Typography. Single mono family for prices, plan codes, status badges,
       and meta labels. */
    --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
    --max-w: 58rem;

    /* Honor the "no 32px cards" cap. We use 6px on cards. */
    --radius-card: 6px;
    /* Note: we intentionally DON'T override Graffiti's --br-m globally;
       doing so would flatten pill buttons and inputs. The card radius is
       scoped to .plan below via direct border-radius declarations. */

  }
}

@layer overrides {
  html, body { background: var(--bg); color: var(--ink); }
  body { line-height: 1.55; }

  /* KILL the ghost-card pattern explicitly: Graffiti's element layer
     doesn't apply borders + drop-shadows to bare <section>/<article>, so
     cards stay surface-bound with a single 1px border, no shadow. */
  article, section, aside { background: transparent; }

  /* ---------------------------------------------------------------------
     Layout primitives (Graffiti minimal ships NO layout helpers)
     --------------------------------------------------------------------- */
  .stack > * + * { margin-block-start: var(--vs-s, 0.5rem); }
  .stack-l > * + * { margin-block-start: var(--vs-m, 1rem); }
  .stack-xl > * + * { margin-block-start: var(--vs-l, 2rem); }
  .row { display: flex; gap: var(--vs-s, 0.5rem); align-items: center; flex-wrap: wrap; }

  .grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
    gap: var(--vs-m, 1rem);
    align-items: start;
  }

  .center-page {
    width: min(100%, var(--max-w, 58rem));
    margin-inline: auto;
    padding: clamp(1rem, 3vw, 2.5rem) clamp(1rem, 3vw, 2rem);
  }

  /* Skip-to-content link */
  .skip {
    position: absolute;
    inset-inline-start: var(--pad-s);
    inset-block-start: var(--pad-s);
    background: var(--bg);
    color: var(--ink);
    padding: var(--pad-s);
    translate: 0 -150%;
    z-index: 100;
    text-decoration: none;
  }
  .skip:focus-visible { translate: 0 0; }

  /* ---------------------------------------------------------------------
     Page header / primary nav
     --------------------------------------------------------------------- */
  .page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: var(--vs-m, 1rem) clamp(1rem, 3vw, 2rem);
    border-block-end: 1px solid var(--rule);
    background: var(--surface);
  }
  .page-header .brand {
    font-weight: var(--fw-semibold, 600);
    text-decoration: none;
    color: var(--ink);
    letter-spacing: 0.02em;
  }
  .page-header nav { display: flex; gap: var(--vs-m, 1rem); }
  .page-header nav a {
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.9375rem;
  }
  .page-header nav a:hover,
  .page-header nav a:focus-visible { color: var(--ink); }
  .page-header nav a[aria-current="page"] {
    color: var(--color-rust);
  }

  /* ---------------------------------------------------------------------
     Hero
     --------------------------------------------------------------------- */
  .hero { padding-block: clamp(3rem, 8vh, 5rem); }
  .hero h1 {
    font-size: clamp(2rem, 4.2vw, 3.5rem); /* clamp max ≤ 6rem enforced */
    line-height: 1.05;
    max-inline-size: 22ch;
    text-wrap: balance;
    margin: 0;
  }
  .hero p {
    color: var(--ink-soft);
    max-inline-size: 50ch;
    text-wrap: pretty;
    margin: var(--vs-s, 0.5rem) 0 0;
  }

  /* Swiper hero slider */
  .hero-swiper { overflow: hidden; border-radius: var(--radius-card, 6px); }
  .hero-slide { padding: clamp(2rem, 6vw, 4rem) clamp(1rem, 4vw, 2.5rem); box-sizing: border-box; }
  .hero-slide h1 { font-size: clamp(2rem, 4.2vw, 3.5rem); line-height: 1.05; max-inline-size: 22ch; text-wrap: balance; margin: 0; }
  .hero-slide p { color: var(--ink-soft); max-inline-size: 50ch; text-wrap: pretty; margin: var(--vs-s, 0.5rem) 0 0; }
  .swiper-pagination-bullet { background: var(--ink-soft); opacity: 0.5; }
  .swiper-pagination-bullet-active { background: var(--color-rust); opacity: 1; }

  .hero .cta {
    margin-block-start: var(--vs-m, 1rem);
    display: flex;
    gap: var(--vs-s, 0.5rem);
    flex-wrap: wrap;
    align-items: center;
  }
  .hero .cta a { color: var(--ink-faint); text-decoration: none; }

  /* ---------------------------------------------------------------------
     Lead form (email collector)
     --------------------------------------------------------------------- */
  .lead-form {
    display: flex;
    gap: var(--vs-s, 0.5rem);
    flex-wrap: wrap;
    max-inline-size: 30rem;
  }
  .lead-form input { flex: 1 1 14rem; min-inline-size: 0; }

  /* ---------------------------------------------------------------------
     Benefits (semantic <dl>, NOT icon-card grid)
     --------------------------------------------------------------------- */
  dl.benefits {
    display: grid;
    gap: var(--vs-m, 1rem);
    margin: var(--vs-s, 0.5rem) 0 0;
  }
  dl.benefits > div {
    padding-block-start: var(--vs-s, 0.5rem);
    border-block-start: 1px solid var(--rule);
  }
  dl.benefits dt {
    font-weight: var(--fw-semibold, 600);
    color: var(--ink);
    margin-block-end: var(--pad-xs, 0.25rem);
    font-size: 0.9375rem;
  }
  dl.benefits dd {
    margin: 0;
    color: var(--ink-soft);
    max-inline-size: 60ch;
    text-wrap: pretty;
  }

  /* ---------------------------------------------------------------------
     Section + heading rhythm
     --------------------------------------------------------------------- */
  h1 {
    font-size: clamp(1.75rem, 3.6vw, 2.625rem);
    letter-spacing: var(--ls-h1);
    line-height: 1.1;
    margin: 0;
  }
  h2 {
    font-size: clamp(1.125rem, 1.4vw, 1.3125rem);
    letter-spacing: var(--ls-h2);
    line-height: 1.2;
    margin-block: var(--vs-l, 2rem) var(--vs-s, 0.5rem);
    font-weight: var(--fw-semibold, 600);
  }
  h3 {
    font-size: 1rem;
    letter-spacing: var(--ls-h3);
    font-weight: var(--fw-semibold, 600);
  }

  /* ---------------------------------------------------------------------
     Pricing grid
     --------------------------------------------------------------------- */
  .plans-grid {
    display: grid;
    gap: var(--vs-m, 1rem);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
    /* CRITICAL anti-pattern guard: cards grow from their own content height
       rather than stretching to match a tallest sibling. */
    align-items: start;
  }
  .plan {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-card, 6px);
    padding: var(--vs-m, 1rem);
    display: flex;
    flex-direction: column;
    gap: var(--vs-s, 0.5rem);
    min-inline-size: 0;
  }
  .plan[data-recommended] {
    border-color: var(--color-rust);
    /* Single source of emphasis: nested outline only, NO drop-shadow on
       the title block. Distinct from the spec violation of pairing a 1px
       border with a wide spread drop-shadow. */
    box-shadow: inset 0 0 0 1px var(--color-rust);
  }
  .plan h3 {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: var(--fw-semibold, 600);
    letter-spacing: var(--ls-h3);
  }
  .plan data.price {
    display: block;
    font-family: var(--font-mono);
    font-weight: var(--fw-medium, 500);
    font-size: 2rem;
    line-height: 1.1;
    color: var(--ink);
    margin-block: var(--pad-xs, 0.25rem) var(--vs-s, 0.5rem);
  }
  .plan data.price .currency { color: var(--ink-soft); font-size: 0.65em; vertical-align: 0.6em; margin-inline-end: 1px; }
  .plan data.price .period { color: var(--ink-soft); font-size: 0.45em; margin-inline-start: 2px; }
  .plan dl.features {
    margin: 0;
    display: grid;
    gap: var(--pad-xs, 0.25rem);
  }
  .plan dl.features > div { display: grid; gap: 2px; }
  .plan dt {
    color: var(--ink);
    font-weight: var(--fw-medium, 500);
    font-size: 0.875rem;
  }
  .plan dd {
    color: var(--ink-soft);
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    text-wrap: pretty;
  }
  .plan .ribbon {
    display: inline-flex;
    align-self: flex-start;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--color-rust);
    border: 1px solid var(--color-rust);
    padding: 2px var(--pad-s, 0.5rem);
    margin-block-end: -2px;
  }
  .plan button { margin-block-start: var(--vs-s, 0.5rem); }

  /* ---------------------------------------------------------------------
     Auth tab strip (role=tablist pattern)
     --------------------------------------------------------------------- */
  .tablist {
    display: inline-flex;
    gap: 1px;
    background: var(--rule);
    border: 1px solid var(--rule);
    border-radius: 2px;
    padding: 1px;
  }
  .tablist button {
    background: var(--surface);
    color: var(--ink-soft);
    border: 0;
    padding: var(--pad-s, 0.5rem) var(--pad-m, 0.75rem);
    font: inherit;
    font-weight: var(--fw-medium, 500);
    font-size: 0.875rem;
    cursor: pointer;
    border-radius: 0;
  }
  .tablist button.is-active {
    background: var(--bg);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--rule-strong);
  }
  .tablist button:hover { color: var(--ink); }
  .tablist button:focus-visible {
    outline: 2px solid var(--color-rust);
    outline-offset: -2px;
  }

  /* ---------------------------------------------------------------------
     Profile info (signed-in state) — semantic <dl>
     --------------------------------------------------------------------- */
  dl.profile {
    border: 1px solid var(--rule);
    border-radius: var(--radius-card, 6px);
    padding: var(--vs-s, 0.5rem) var(--vs-m, 1rem);
    background: var(--surface);
    display: grid;
    gap: var(--pad-s, 0.5rem);
  }
  dl.profile > div {
    display: grid;
    grid-template-columns: minmax(7rem, max-content) 1fr;
    gap: var(--vs-m, 1rem);
    align-items: baseline;
  }
  dl.profile dt {
    color: var(--ink-soft);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    align-self: center;
    margin: 0;
  }
  dl.profile dd { margin: 0; color: var(--ink); }

  hr {
    border: 0;
    border-block-start: 1px solid var(--rule);
    margin-block: var(--vs-l, 2rem);
  }

  /* ---------------------------------------------------------------------
     Status chip (success / error / etc.)
     --------------------------------------------------------------------- */
  .status {
    display: inline-flex;
    align-items: center;
    gap: var(--pad-xs);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 2px var(--pad-s);
    border-radius: 999px;
    border: 1px solid currentColor;
    color: var(--ink-soft);
  }
  .status--active { color: var(--color-success); }
  .status--error { color: var(--color-error); }
  .status::before {
    content: "";
    inline-size: 0.5em;
    block-size: 0.5em;
    border-radius: 50%;
    background: currentColor;
  }

  /* ---------------------------------------------------------------------
     Forms
     --------------------------------------------------------------------- */
  form.stack { display: grid; gap: var(--vs-s, 0.5rem); max-inline-size: 24rem; }
  form.stack label {
    display: grid;
    gap: var(--pad-xs, 0.25rem);
    color: var(--ink-soft);
    font-size: 0.8125rem;
  }
  form.stack input { width: 100%; box-sizing: border-box; }

  /* Use the platform's :user-valid / :user-invalid for free validation
     styling. Native Graffiti element styles still apply on top. */
  input:user-invalid,
  textarea:user-invalid,
  select:user-invalid {
    border-color: var(--color-error);
    box-shadow: inset 0 0 0 1px var(--color-error);
  }
  input:user-valid {
    border-color: var(--rule-strong);
  }

  /* ---------------------------------------------------------------------
     Auth button (header) and dialog
     --------------------------------------------------------------------- */
  .auth-btn {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--rule-strong);
    padding: var(--pad-xs, 0.25rem) var(--pad-m, 0.75rem);
    font: inherit;
    font-size: 0.8125rem;
    font-weight: var(--fw-medium, 500);
    cursor: pointer;
    border-radius: 4px;
  }
  .auth-btn:hover,
  .auth-btn:focus-visible {
    border-color: var(--ink-soft);
    background: var(--surface-raised);
  }

  /* Profile picture fallback (initial letter) */
  .pfp-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 32px;
    block-size: 32px;
    border-radius: 50%;
    background: var(--color-rust);
    color: var(--bg);
    font-weight: var(--fw-semibold, 600);
    font-size: 0.875rem;
    text-transform: uppercase;
  }

  /* Profile picture dropdown */
  .pfp-dropdown {
    position: absolute;
    inset-block-start: calc(100% + 4px);
    inset-inline-end: 0;
    background: var(--surface-raised);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-card, 6px);
    padding: var(--pad-xs, 0.25rem) 0;
    min-inline-size: 10rem;
    z-index: 50;
  }
  .pfp-dropdown a,
  .pfp-dropdown button {
    display: block;
    inline-size: 100%;
    padding: var(--pad-xs, 0.25rem) var(--pad-m, 0.75rem);
    background: transparent;
    border: 0;
    color: var(--ink);
    font: inherit;
    font-size: 0.8125rem;
    text-align: start;
    text-decoration: none;
    cursor: pointer;
  }
  .pfp-dropdown a:hover,
  .pfp-dropdown button:hover,
  .pfp-dropdown a:focus-visible,
  .pfp-dropdown button:focus-visible {
    background: var(--surface);
    color: var(--color-rust);
  }
  .pfp-dropdown hr {
    margin: var(--pad-xs, 0.25rem) 0;
  }
  .pfp-signout { color: var(--ink-soft); }
  .pfp-signout:hover { color: var(--color-error); }

  /* Native <dialog> styling */
  dialog {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-card, 6px);
    padding: 0;
    max-inline-size: 24rem;
    inline-size: calc(100% - 2rem);
  }
  dialog::backdrop {
    background: oklch(0 0 0 / 0.6);
  }
  .dialog-panel {
    padding: var(--vs-m, 1rem);
    position: relative;
  }
  .dialog-close {
    position: absolute;
    inset-block-start: var(--pad-s, 0.5rem);
    inset-inline-end: var(--pad-s, 0.5rem);
    background: transparent;
    border: 0;
    color: var(--ink-soft);
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
  }
  .dialog-close:hover { color: var(--ink); }
  .dialog-panel h2 {
    margin: 0 0 var(--vs-s, 0.5rem);
    font-size: 1.125rem;
  }

  /* Google sign-in button */
  .google-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--pad-s, 0.5rem);
    background: var(--bg);
    color: var(--ink);
    border: 1px solid var(--rule-strong);
    padding: var(--pad-s, 0.5rem) var(--pad-m, 0.75rem);
    font: inherit;
    font-size: 0.9375rem;
    font-weight: var(--fw-medium, 500);
    cursor: pointer;
    border-radius: 4px;
  }
  .google-btn:hover,
  .google-btn:focus-visible {
    border-color: var(--ink-soft);
    background: var(--surface-raised);
  }

  /* ---------------------------------------------------------------------
     Buttons
     --------------------------------------------------------------------- */
  button.secondary {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--rule-strong);
  }
  button.secondary:hover,
  button.secondary:focus-visible {
    border-color: var(--ink-soft);
  }

  /* Anchor styled to look like a primary button (used in the hero CTA
     where nesting <button> inside <a> is invalid HTML). */
  .button-link {
    display: inline-flex;
    align-items: center;
    padding: var(--pad-s, 0.5rem) var(--pad-l, 1rem);
    background: var(--color-rust);
    color: var(--bg);
    font-weight: var(--fw-semibold, 600);
    font-size: 0.9375rem;
    text-decoration: none;
    border-radius: 4px;
    border: 1px solid var(--color-rust);
  }
  .button-link:hover,
  .button-link:focus-visible {
    color: var(--bg);
    border-color: var(--color-olive);
    background: var(--color-olive);
  }

  /* Visually hidden heading for accessibility (used to give named
     sections a heading without adding visual noise). */
  .sr-only {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* ---------------------------------------------------------------------
     Utilities
     --------------------------------------------------------------------- */
  .mono { font-family: var(--font-mono); }
  .ink-faint { color: var(--ink-faint); }
  .label-kicker {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-soft);
    margin: 0;
  }

  /* ---------------------------------------------------------------------
     Motion — reveal only animate already-visible content; nothing depends
     on the animation completing to be readable. Reduced-motion is honored.
     --------------------------------------------------------------------- */
  @media (prefers-reduced-motion: no-preference) {
    .hero h1,
    .hero p,
    .hero .cta { animation: rise 600ms cubic-bezier(0.16, 1, 0.3, 1) both; }
    .hero p { animation-delay: 60ms; }
    .hero .cta { animation-delay: 120ms; }
    section { animation: rise 600ms 80ms cubic-bezier(0.16, 1, 0.3, 1) both; }
    @keyframes rise {
      from { opacity: 0; translate: 0 0.5rem; }
      to   { opacity: 1; translate: 0; }
    }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.001ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.001ms !important;
    }
  }

  /* ---------------------------------------------------------------------
     Body links
     --------------------------------------------------------------------- */
  main a {
    color: var(--ink);
    text-decoration-color: var(--color-rust);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
  }
  main a:hover,
  main a:focus-visible {
    color: var(--color-rust);
  }
}
