/* Fidra landing page styles
   Design tokens are defined once here and shared by every markup task.
   Contrast verification (WCAG 2.1 AA), computed against the surfaces each
   color actually sits on:

   Light theme (page #F6F2EA, cards/fields #FFFFFF):
     --ink    #1E2A33 on parchment 13.11:1 | on paper 14.64:1
     --muted  #5E6468 on parchment  5.38:1  | on paper  6.00:1
     --forest #1E3B33 on parchment 10.88:1 (wordmark, links)
     link hover #16312A on parchment 12.48:1, on paper 13.94:1
     button: white text on --forest 12.15:1, on --forest-hover 9.13:1
     --focus  #2F6F5E on parchment 5.29:1, on paper 5.91:1 (non-text 3:1 ok)
     --error  #8A2B2B on paper 8.53:1, on parchment 7.64:1 (invented, see form)
     --brass  #A8864B vs parchment 3.04:1; decorative numerals and 1px
              hairlines only, never text that must be read
     --stone  #D9D3C7 vs parchment 1.33:1; borders and placeholder bars only

   Dark theme (page #1A242C, elevated surfaces #212D36):
     text --ink -> #F6F2EA      on page 14.11:1, on elevated 12.59:1
     --muted -> #A7ADB1         on page 6.95:1,  on elevated 6.20:1
     links --forest-link -> #6FAE99
                                on page 6.15:1,  on elevated 5.48:1
     link hover -> #8DC9B7      on page 8.38:1,  on elevated 7.48:1
     button fill -> #4E7F6E with white text 4.58:1; fill vs page 3.44:1,
                    vs elevated 3.07:1 (non-text 3:1). Derived: the lightest
                    fill with white text at >= 4.5:1 is luminance-bound at
                    ~0.183 while >= 4.5:1 against the page needs ~0.250, so no
                    single fill satisfies both text-at-4.5 constraints;
                    buttons therefore hold white text at 4.58:1 and the fill
                    at non-text 3:1+, while all link text keeps 4.5:1.
     button hover -> #507D6E with white text 4.67:1
     borders --stone -> #747877 (stone blended 45% over the page surface):
                    vs page 3.52:1, vs elevated 3.14:1 (non-text 3:1 ok)
     placeholder bars --record-bar -> #BEB8AC vs elevated 7.13:1
     --brass -> #BFA06A         vs page 6.34:1  (decorative)
     --focus -> #42927C         vs page 4.23:1, vs elevated 3.77:1
     --error -> #C78282         vs elevated 4.65:1, vs page 5.21:1

   Breakpoints: 320px floor, 639px (masthead nav collapse), 640px,
   768px, 900px, 1120px (wrap max). */

*,
*::before,
*::after {
  box-sizing: border-box;
}

@font-face {
  font-family: "Source Serif 4";
  src: url("/fonts/source-serif-4-latin-var.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* Palette (contract tokens) */
  --ink: #1e2a33;
  --forest: #1e3b33;
  --forest-hover: #2a4f44;
  --parchment: #f6f2ea;
  --paper: #ffffff;
  --stone: #d9d3c7;
  --muted: #5e6468;
  --brass: #a8864b;
  --focus: #2f6f5e;

  /* Derived palette (documented above): link color distinct from button
     fill so dark mode can lighten links without breaking button contrast */
  --forest-link: #1e3b33;
  --forest-link-hover: #16312a;
  --error: #8a2b2b;
  --record-bar: #d9d3c7;

  /* Spacing and measure tokens */
  --wrap-max: 1120px;
  --wrap-pad: clamp(20px, 5vw, 40px);
  --section-y: clamp(56px, 8vw, 96px);
  --measure: 68ch;
}

html {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-optical-sizing: auto;
}

body {
  margin: 0;
  background-color: var(--parchment);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

p {
  margin: 0;
}

::selection {
  background-color: var(--forest);
  color: #ffffff;
}

/* Single global focus treatment. Outlines are never removed. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Utilities                                                            */
/* ------------------------------------------------------------------ */

.wrap {
  max-width: var(--wrap-max);
  margin-inline: auto;
  padding-inline: var(--wrap-pad);
}

.measure {
  max-width: var(--measure);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 0;
  left: 16px;
  z-index: 100;
  transform: translateY(-200%);
  background-color: var(--forest);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 6px;
  text-decoration: none;
  transition: transform 150ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* ------------------------------------------------------------------ */
/* Type                                                                 */
/* ------------------------------------------------------------------ */

.h1,
.h2,
.wordmark,
.steps__num,
.steps__title,
.vis-col__title,
.feature__title,
.success__title {
  font-family: "Source Serif 4", Georgia, serif;
  font-optical-sizing: auto;
}

.h1 {
  margin: 0;
  font-size: clamp(34px, 2.125rem + 1.2vw, 56px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.h2 {
  margin: 0 0 20px;
  font-size: clamp(26px, 1.625rem + 0.4vw, 34px);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}

.body {
  font-size: clamp(17px, 1.0625rem + 0.08vw, 18px);
  color: var(--ink);
}

.body + .body {
  margin-top: 16px;
}

.note {
  font-size: 15px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ */
/* Sections                                                             */
/* ------------------------------------------------------------------ */

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

.section + .section {
  border-top: 1px solid var(--stone);
}

.section--hero {
  padding-top: clamp(40px, 6vw, 96px);
}

.section--form {
  /* The form card is the only --paper surface on the page */
  background-color: transparent;
}

/* ------------------------------------------------------------------ */
/* Masthead                                                             */
/* ------------------------------------------------------------------ */

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  height: clamp(64px, 8vw, 72px);
  background-color: var(--parchment);
  border-bottom: 1px solid var(--stone);
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 100%;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--forest-link);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.wordmark__mark {
  display: block;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.wordmark__text {
  white-space: nowrap;
}

.wordmark--sm {
  font-size: 18px;
}

.wordmark--sm .wordmark__mark {
  width: 18px;
  height: 18px;
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.5vw, 20px);
}

.nav__link {
  color: var(--forest-link);
  font-size: 15px;
  font-weight: 500;
  padding: 8px 10px;
  text-decoration: none;
  transition: color 150ms ease;
}

.nav__link:hover {
  color: var(--forest-link-hover);
}

/* Below 640px: wordmark plus CTA button only, the two nav links hide */
@media (max-width: 639px) {
  .nav__link {
    display: none;
  }
}

/* ------------------------------------------------------------------ */
/* Buttons                                                              */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap; /* labels never wrap */
  cursor: pointer;
  transition:
    color 150ms ease,
    background-color 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.btn--primary {
  background-color: var(--forest);
  border-color: var(--forest);
  color: #ffffff;
}

.btn--primary:hover {
  background-color: var(--forest-hover);
  border-color: var(--forest-hover);
  box-shadow: 0 2px 8px rgba(30, 59, 51, 0.18);
}

.btn--primary:active {
  transform: translateY(1px);
  box-shadow: 0 1px 4px rgba(30, 59, 51, 0.12);
}

.btn--sm {
  padding: 8px 16px;
  font-size: 15px;
}

.btn--block {
  display: flex;
  width: 100%;
}

/* ------------------------------------------------------------------ */
/* Hero                                                                 */
/* ------------------------------------------------------------------ */

.hero {
  display: grid;
  gap: clamp(32px, 5vw, 64px);
}

.hero__copy {
  min-width: 0;
}

.hero__sub {
  margin: 20px 0 0;
  max-width: 56ch;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0 0;
}

.hero__note {
  margin: 12px 0 0;
  font-size: 15px;
  color: var(--muted);
}

.hero__figure {
  min-width: 0;
  margin: 0;
  max-width: 460px;
}

/* ------------------------------------------------------------------ */
/* Record panel (hero figure)                                           */
/* ------------------------------------------------------------------ */

.record {
  background-color: var(--paper);
  border: 1px solid var(--stone);
  border-radius: 6px;
  padding: clamp(20px, 3vw, 28px);
}

.record__head {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
}

.record__row {
  display: grid;
  grid-template-columns: minmax(5.5rem, max-content) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  min-width: 0;
  padding: 14px 0;
}

.record__row + .record__row {
  border-top: 1px solid var(--stone);
}

.record__label {
  font-size: 15px;
  color: var(--muted);
}

/* 3px radius is a deliberate departure from the 6px system: a 10px-tall
   placeholder bar reads better with a softer cap. Documented exception. */
.record__bar {
  height: 10px;
  border-radius: 3px;
  background-color: var(--record-bar);
}

.record__bar--w1 { width: 35%; }
.record__bar--w2 { width: 48%; }
.record__bar--w3 { width: 60%; }
.record__bar--w4 { width: 72%; }
.record__bar--w5 { width: 86%; }

.record__caption {
  margin: 18px 0 0;
  font-size: 15px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ */
/* How it works                                                         */
/* ------------------------------------------------------------------ */

.steps {
  list-style: none;
  margin: clamp(28px, 4vw, 48px) 0 0;
  padding: 0;
  display: grid;
  gap: clamp(32px, 6vw, 56px);
}

.steps__item {
  min-width: 0;
}

.steps__num {
  display: inline-block;
  padding-bottom: 12px;
  margin-bottom: 24px;
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 600;
  line-height: 1;
  color: var(--brass); /* decorative only */
  border-bottom: 1px solid var(--brass);
}

.steps__title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}

.steps__body {
  max-width: 36ch;
}

.steps__note {
  margin-top: clamp(24px, 4vw, 40px);
  font-size: 15px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ */
/* What we can and can't see                                            */
/* ------------------------------------------------------------------ */

.visibility {
  display: grid;
  margin-top: clamp(28px, 4vw, 48px);
}

.vis-col {
  min-width: 0;
}

.vis-col__title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}

.vis-col__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.vis-col__list li {
  padding: 13px 0;
  border-bottom: 1px solid var(--stone);
}

.vis-col__list li:last-child {
  border-bottom: none;
}

.visibility__close {
  margin-top: 20px;
}

/* ------------------------------------------------------------------ */
/* Built for                                                            */
/* ------------------------------------------------------------------ */

.roles {
  list-style: none;
  margin: clamp(20px, 3vw, 32px) 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.roles__item {
  font-size: clamp(16px, 1rem + 0.08vw, 17px);
  color: var(--ink);
}

.roles + .body {
  margin-top: clamp(20px, 3vw, 28px);
}

/* ------------------------------------------------------------------ */
/* What's included                                                      */
/* ------------------------------------------------------------------ */

.features {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin-top: clamp(28px, 4vw, 48px);
  column-gap: clamp(40px, 6vw, 64px);
  row-gap: 0;
}

.feature {
  min-width: 0;
  padding: 22px 0 36px;
  border-top: 1px solid var(--stone);
}

.feature__title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}

.feature__body {
  font-size: clamp(16px, 1rem + 0.08vw, 17px);
  color: var(--ink);
  max-width: 38ch;
}

.features__note {
  margin-top: clamp(24px, 4vw, 40px);
  font-size: 15px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ */
/* Recovery                                                             */
/* ------------------------------------------------------------------ */

.recovery {
  display: grid;
  gap: clamp(32px, 5vw, 64px);
  align-items: center;
}

.recovery__copy {
  min-width: 0;
}

.recovery__figure {
  min-width: 0;
  margin: 0;
  display: flex;
  justify-content: center;
}

/* Simple printed-sheet line work, inheriting the brand color */
.sheet {
  display: block;
  width: 100%;
  max-width: 220px;
  height: auto;
  color: var(--forest-link);
  opacity: 0.9;
}

/* ------------------------------------------------------------------ */
/* FAQ                                                                  */
/* ------------------------------------------------------------------ */

.faq {
  margin-top: clamp(24px, 4vw, 40px);
  border-top: 1px solid var(--stone);
}

.faq__item {
  min-width: 0;
  border-bottom: 1px solid var(--stone);
}

.faq__q {
  position: relative;
  display: block;
  padding: 18px 44px 18px 0;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
  cursor: pointer;
  list-style: none; /* hide the native disclosure marker */
}

.faq__q::-webkit-details-marker {
  display: none;
}

.faq__q:hover {
  color: var(--forest-link-hover);
}

/* Plus/minus indicator drawn with CSS bars, brass like the numerals */
.faq__q::before,
.faq__q::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  background-color: var(--brass);
  border-radius: 1px;
}

.faq__q::before {
  width: 14px;
  height: 2px;
  transform: translateY(-50%);
}

/* Vertical bar is centred on the 14px horizontal bar, not right-aligned to it */
.faq__q::after {
  width: 2px;
  height: 14px;
  right: 6px;
  transform: translateY(-50%);
}

.faq__a {
  max-width: var(--measure);
  padding: 0 0 24px;
  font-size: clamp(16px, 1rem + 0.08vw, 17px);
  color: var(--ink);
}

.faq__a p {
  margin: 0;
}

/* ------------------------------------------------------------------ */
/* Early access form                                                    */
/* ------------------------------------------------------------------ */

.form-card {
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
  background-color: var(--paper);
  border: 1px solid var(--stone);
  border-radius: 6px;
  padding: clamp(24px, 5vw, 40px);
}

.form {
  display: grid;
  gap: 20px;
  margin-top: 28px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field__label {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}

.field__input,
.field__select,
.field__textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 16px; /* 16px minimum prevents iOS autozoom */
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--paper);
  border: 1px solid var(--stone);
  border-radius: 6px;
  transition:
    color 150ms ease,
    background-color 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.field__input::placeholder,
.field__textarea::placeholder {
  color: var(--muted); /* 6.00:1 on paper (light), 6.20:1 on elevated (dark) */
  opacity: 1; /* Firefox default opacity */
}

.field__textarea {
  min-height: 128px;
  resize: vertical;
}

/* Real validation errors only; color plus a thicker border, never color alone */
.field__input[aria-invalid="true"],
.field__select[aria-invalid="true"],
.field__textarea[aria-invalid="true"] {
  border-width: 2px;
  border-color: var(--error); /* light #8A2B2B 8.53:1 on paper; dark #C78282 4.65:1 on elevated */
}

.field__error {
  font-size: 14px;
  color: var(--error);
}

.form__privacy {
  margin-top: 4px;
  font-size: 15px;
  color: var(--muted);
}

.form__status {
  font-size: 15px;
  color: var(--muted);
}

/* Honeypot: clipped, not display:none, so robots interact with a real
   field; tabindex="-1" in the markup keeps it out of the focus order. */
.hp {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  white-space: nowrap;
}

.success__title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
}

/* ------------------------------------------------------------------ */
/* Footer                                                               */
/* ------------------------------------------------------------------ */

.footer {
  border-top: 1px solid var(--stone);
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding-block: clamp(24px, 4vw, 40px);
}

.footer__legal {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}

.footer__links {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 8px 20px;
}

.footer__links a {
  font-size: 15px;
  color: var(--forest-link);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 150ms ease;
}

.footer__links a:hover {
  color: var(--forest-link-hover);
}

/* Inline links inside body copy, including the server-rendered
   no-JS form response page from functions/api/early-access.js */
.body a {
  color: var(--forest-link);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 150ms ease;
}

.body a:hover {
  color: var(--forest-link-hover);
}

/* ------------------------------------------------------------------ */
/* Legal pages (/privacy)                                               */
/* ------------------------------------------------------------------ */

.legal .h1 {
  margin-bottom: clamp(24px, 4vw, 36px);
}

.legal .body + .body {
  margin-top: 20px;
}

/* ------------------------------------------------------------------ */
/* Responsive layouts                                                   */
/* ------------------------------------------------------------------ */

@media (min-width: 640px) {
  .roles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: clamp(32px, 6vw, 56px);
  }
}

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

  .visibility {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* One hairline between the two columns, generous space either side */
  .vis-col:first-child {
    padding-right: clamp(32px, 6vw, 72px);
  }

  .vis-col + .vis-col {
    padding-left: clamp(32px, 6vw, 72px);
    border-left: 1px solid var(--stone);
  }
}

@media (min-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    align-items: center;
    gap: clamp(40px, 6vw, 72px);
  }

  .recovery {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  }

  .features {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 640px) and (max-width: 899px) {
  .features {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ------------------------------------------------------------------ */
/* Dark mode: derived from the brand palette only                       */
/* ------------------------------------------------------------------ */

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --ink: #f6f2ea; /* parchment text on #1A242C page: 14.11:1 */
    --parchment: #1a242c; /* page surface, toned from --ink family */
    --paper: #212d36; /* elevated surface, toned from --ink family */
    --stone: #747877; /* stone blended 45% over the page: 3.52:1 vs page, 3.14:1 vs elevated */
    --muted: #a7adb1; /* 6.95:1 vs page, 6.20:1 vs elevated */
    --brass: #bfa06a; /* lightened brass, 6.34:1 vs page (decorative) */
    --focus: #42927c; /* 4.23:1 vs page, 3.77:1 vs elevated (non-text 3:1) */
    --error: #c78282; /* 4.65:1 vs elevated, 5.21:1 vs page */
    --forest-link: #6fae99; /* 6.15:1 vs page, 5.48:1 vs elevated */
    --forest-link-hover: #8dc9b7; /* 8.38:1 vs page */
    --record-bar: #beb8ac; /* 7.13:1 vs elevated */
  }

  /* Buttons keep white text at >= 4.5:1: fill #4E7F6E (white 4.58:1,
     vs page 3.44:1, vs elevated 3.07:1), hover #507D6E (white 4.67:1).
     See the header comment for why the fill cannot also reach 4.5:1
     against the page. */
  .btn--primary {
    background-color: #4e7f6e;
    border-color: #4e7f6e;
  }

  .btn--primary:hover {
    background-color: #507d6e;
    border-color: #507d6e;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  }

  .btn--primary:active {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  }

  .skip-link {
    background-color: #4e7f6e;
  }

  .sheet {
    color: var(--forest-link);
    opacity: 0.8;
  }

  ::selection {
    background-color: #4e7f6e;
  }
}

/* ------------------------------------------------------------------ */
/* Motion                                                               */
/* ------------------------------------------------------------------ */

/* The indicator rotation happens only when motion is allowed */
@media (prefers-reduced-motion: no-preference) {
  .faq__q::after {
    transition: transform 150ms ease;
  }

  .faq__item[open] .faq__q::after {
    transform: translateY(-50%) rotate(90deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }

  /* Under reduced motion the plus becomes a minus by hiding the
     vertical bar instead of rotating it */
  .faq__item[open] .faq__q::after {
    opacity: 0;
  }
}

/* [hidden] must win over component display rules; author rule placed last */
[hidden] {
  display: none;
}
