/* Redline OS — questionnaire.
 *
 * CLAUDE.md section 7: it must not look like a SaaS startup and must not look like the
 * dark-terminal developer aesthetic. It should look like it came from an engineering office.
 * The visual world is the marked-up drawing — title blocks, hairlines, clause numbering.
 *
 * "Not a startup" is not a licence for flat. The craft here is meant to sit alongside a
 * well-made product page: a real type scale with contrast, deliberate vertical rhythm,
 * hairline structure instead of soft shadows, and one accent used once.
 *
 * No images, no webfonts, no JavaScript. The page must work with images blocked, and a
 * prospect on a jobsite connection should not wait on a font CDN to read question one.
 */

:root {
  /* Section 7 tokens, plus the tints needed to build depth without leaving the palette. */
  --paper:    #F4F2EE;  /* drawing paper, not cream */
  --surface:  #FCFBF9;  /* the sheet laid on the paper */
  --ink:      #101418;  /* drafting ink */
  --ink-2:    #3D454D;
  --ink-3:    #6B747C;
  --rule:     #D6D2CA;  /* hairline, borders and grid */
  --rule-2:   #E7E4DE;
  --redline:  #C4342B;  /* accent — findings and the CTA only, never decorative */
  --redline-2:#A32A22;
  --stamp:    #1F5C74;  /* approval-stamp blue, labels and eyebrows */
  --stamp-2:  #E8EFF2;
  --flag:     #D08C1A;  /* amber, used once, on the money figure */

  /* Three type roles, no more (section 7). System stacks — a webfont is an M6 decision. */
  --display: "Oswald", "Roboto Condensed", "Arial Narrow", ui-sans-serif, system-ui, sans-serif;
  --body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  /* One spacing scale. Every margin below comes from it. */
  --s1: 0.25rem;  --s2: 0.5rem;   --s3: 0.75rem;  --s4: 1rem;
  --s5: 1.5rem;   --s6: 2rem;     --s7: 3rem;     --s8: 4rem;

  --gutter: 1.25rem;
  --measure: 34rem;   /* body text never runs wider than this */
  --sheet: 44rem;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.6;
  letter-spacing: -0.003em;
  font-feature-settings: "kern" 1;
  text-rendering: optimizeLegibility;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* Uppercase micro-label. The one repeated device that carries the drawing-office feel. */
.label, .eyebrow, .tb-label, legend, .lenses caption, .lenses thead th, .bandline, .cta, .flag {
  font-family: var(--display);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-weight: 600;
}

/* ============================================================ title block header */

.titleblock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "project rev" "date sheet";
  background: var(--surface);
  border-bottom: 1.5px solid var(--ink);
  position: sticky;
  top: 0;
  z-index: 10;
}

.tb-cell {
  padding: var(--s2) var(--gutter);
  border-top: 1px solid var(--rule-2);
  min-width: 0;
}
.tb-cell:first-child, .tb-cell:nth-child(2) { border-top: 0; }
.tb-project { grid-area: project; }
.tb-rev     { grid-area: rev;   border-left: 1px solid var(--rule-2); }
.tb-date    { grid-area: date; }
.tb-sheet   { grid-area: sheet; border-left: 1px solid var(--rule-2); }

.tb-label {
  display: block;
  font-size: 0.625rem;
  color: var(--stamp);
  line-height: 1.4;
}
.tb-value {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

/* ==================================================================== page shell */

main { padding: 0 var(--gutter); }

.sheet {
  max-width: var(--sheet);
  margin: 0 auto;
  padding: var(--s7) 0 var(--s8);
}

.eyebrow {
  display: block;
  font-size: 0.6875rem;
  color: var(--stamp);
  margin: 0 0 var(--s3);
}

h1 {
  font-family: var(--display);
  font-size: clamp(2.25rem, 8vw, 3.5rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  font-weight: 700;
  margin: 0 0 var(--s4);
  text-wrap: balance;
}

.lede {
  font-size: 1.1875rem;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: var(--measure);
  margin: 0 0 var(--s5);
}

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

.note {
  color: var(--ink-3);
  font-size: 0.875rem;
  line-height: 1.5;
  max-width: var(--measure);
}
.hint { color: var(--ink-3); font-size: 0.875rem; margin: 0 0 var(--s2); }
.optional { color: var(--ink-3); font-weight: 400; font-size: 0.8125rem; letter-spacing: 0; }

/* The hero rule: a heavy line under the title, like a drawing sheet division. */
.rule-heavy {
  border: 0;
  border-top: 3px solid var(--ink);
  margin: var(--s6) 0 var(--s6);
  max-width: 4rem;
}

/* ------------------------------------------------- what you get (intake only) */

.promises {
  display: grid;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin: var(--s6) 0;
}
.promise { background: var(--surface); padding: var(--s4) var(--s4) var(--s5); }
.promise .n {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--redline);
  display: block;
  margin-bottom: var(--s2);
}
.promise h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 var(--s1);
}
.promise p { font-size: 0.9375rem; color: var(--ink-2); margin: 0; }

/* ===================================================================== progress */

.progress { margin: 0 0 var(--s6); }

.stepper {
  display: flex;
  gap: 3px;
  margin: 0 0 var(--s2);
  padding: 0;
  list-style: none;
}
.stepper li {
  flex: 1 1 0;
  height: 3px;
  background: var(--rule);
}
.stepper li.done { background: var(--stamp); }
.stepper li.now  { background: var(--redline); }

.progress-text {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-3);
  letter-spacing: 0.02em;
  margin: 0;
}

/* ======================================================================== forms */

fieldset {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: var(--s5) var(--gutter);
  margin: 0 0 var(--s4);
}

legend {
  font-size: 0.6875rem;
  color: var(--stamp);
  background: var(--surface);
  padding: 0 var(--s2);
  margin-left: calc(var(--s2) * -1);
}

.field { margin: 0 0 var(--s5); }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block;
  font-weight: 650;
  font-size: 0.9375rem;
  letter-spacing: -0.005em;
  margin-bottom: var(--s2);
}

input[type="text"], input[type="email"], input[type="number"], select {
  width: 100%;
  padding: 0.75rem 0.875rem;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #FFFFFF;
  border: 1px solid var(--rule);
  border-bottom-color: var(--ink-3);
  border-radius: 0;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:hover, select:hover { border-color: var(--ink-3); }
input:focus, select:focus {
  outline: none;
  border-color: var(--stamp);
  box-shadow: inset 0 -2px 0 var(--stamp);
}
input[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--redline);
  box-shadow: inset 0 -2px 0 var(--redline);
}

/* -------------------------------------------------------------- question cards */

.question {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--rule);
  background: var(--surface);
  padding: var(--s5) var(--gutter);
  margin: 0 0 var(--s5);
}
.question:has(input:checked) { border-left-color: var(--stamp); }
.question.has-error { border-left-color: var(--redline); }

.qtext {
  font-size: 1.125rem;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0 0 var(--s4);
  max-width: none;
  text-wrap: pretty;
}

.qid {
  display: block;
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--stamp);
  margin-bottom: var(--s2);
}

/* Answer options.
 *
 * The native radio was the problem: at 17px beside two lines of text it reads as a bullet,
 * not as something you press. This draws the control at 22px with a hard ink ring, and
 * makes the whole row a target — on a phone you hit the sentence, not the dot. */

.options { display: flex; flex-direction: column; gap: var(--s2); }

.option {
  display: grid;
  grid-template-columns: 1.375rem 1fr;
  gap: var(--s3);
  align-items: start;
  padding: var(--s3) var(--s3);
  border: 1.5px solid var(--rule);
  background: #FFFFFF;
  cursor: pointer;
  min-height: 3rem;
  transition: background 120ms ease, border-color 120ms ease;
}

/* The real input stays in the accessibility tree and keeps keyboard behaviour; it is the
   painted dot beside it that the eye reads. */
.option input {
  position: absolute;
  width: 1px; height: 1px;
  margin: 0; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.option .dot {
  width: 1.375rem;
  height: 1.375rem;
  margin-top: 0.0625rem;
  border: 2px solid var(--ink-3);
  border-radius: 50%;
  background: #FFFFFF;
  display: block;
  position: relative;
  flex: 0 0 auto;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.option .dot::after {
  content: "";
  position: absolute;
  inset: 0.25rem;
  border-radius: 50%;
  background: var(--stamp);
  transform: scale(0);
  transition: transform 140ms cubic-bezier(.16,.84,.44,1);
}

.option-text { font-size: 0.9375rem; line-height: 1.45; color: var(--ink-2); }

.option:hover { background: var(--stamp-2); border-color: var(--ink-3); }
.option:hover .dot { border-color: var(--stamp); }

.option:has(input:checked) {
  background: var(--stamp-2);
  border-color: var(--stamp);
}
.option:has(input:checked) .dot { border-color: var(--stamp); }
.option:has(input:checked) .dot::after { transform: scale(1); }
.option:has(input:checked) .option-text { color: var(--ink); font-weight: 550; }

/* Keyboard focus has to be obvious, since the native control is visually hidden. */
.option:has(input:focus-visible) {
  outline: 3px solid var(--stamp);
  outline-offset: 2px;
}

/* ----------------------------------------------------------------- validation */

.error {
  color: var(--redline);
  font-size: 0.875rem;
  font-weight: 600;
  margin: var(--s2) 0 0;
}
.error-summary {
  border: 1px solid var(--redline);
  border-left-width: 3px;
  background: var(--surface);
  padding: var(--s3) var(--s4);
  font-weight: 600;
  font-size: 0.9375rem;
  margin: 0 0 var(--s5);
  max-width: none;
}

/* ========================================================================== CTA */

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  width: 100%;
  padding: 1.0625rem var(--s5);
  font-size: 0.8125rem;
  letter-spacing: 0.14em;
  text-align: center;
  text-decoration: none;
  color: #FFFFFF;
  background: var(--redline);
  border: 0;
  cursor: pointer;
  transition: background 120ms ease, transform 80ms ease;
}
.cta:hover { background: var(--redline-2); }
.cta:active { transform: translateY(1px); }
.cta::after { content: "→"; font-family: var(--body); letter-spacing: 0; }

.nav { display: flex; flex-direction: column; gap: var(--s3); margin: var(--s6) 0 var(--s4); }
.back {
  order: 2;
  text-align: center;
  color: var(--ink-3);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  padding: var(--s2);
  border-bottom: 1px solid transparent;
}
.back:hover { color: var(--ink); border-bottom-color: var(--rule); }

/* ================================================================== score page */

.scoreblock {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--ink);
  padding: var(--s6) var(--gutter) var(--s5);
  margin: 0 0 var(--s6);
  text-align: center;
}
.score {
  font-family: var(--mono);
  font-size: clamp(4.5rem, 22vw, 7rem);
  line-height: 0.9;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.score .of { font-size: 0.25em; color: var(--ink-3); font-weight: 400; letter-spacing: 0; }
.bandline {
  font-size: 0.75rem;
  color: var(--stamp);
  margin: var(--s4) 0 0;
}
.bandscale {
  display: flex;
  gap: 2px;
  margin: var(--s4) auto 0;
  max-width: 18rem;
}
.bandscale span { flex: 1; height: 4px; background: var(--rule); }
.bandscale span.on { background: var(--stamp); }

.lenses { width: 100%; border-collapse: collapse; margin: var(--s6) 0; }
.lenses caption {
  font-size: 0.6875rem;
  color: var(--stamp);
  text-align: left;
  padding-bottom: var(--s3);
}
.lenses th, .lenses td {
  border-bottom: 1px solid var(--rule-2);
  padding: 0.75rem var(--s2);
  text-align: left;
  font-weight: 400;
  font-size: 0.9375rem;
}
.lenses thead th {
  font-size: 0.625rem;
  color: var(--ink-3);
  border-bottom-color: var(--ink);
}
.lenses td { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.lenses tbody th { font-weight: 550; }
.lenses tr.capped th { color: var(--redline); }

.flag {
  display: inline-block;
  font-size: 0.5625rem;
  color: var(--flag);
  border: 1px solid var(--flag);
  padding: 0.0625rem 0.3125rem;
  margin-left: var(--s2);
  vertical-align: 0.1em;
}

.rationale {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--redline);
  padding: var(--s4);
  background: var(--surface);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 0 0 var(--s4);
  max-width: none;
}

.callout {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: var(--s4);
  margin: var(--s5) 0;
  font-size: 0.9375rem;
  max-width: none;
}
.callout .label { display: block; font-size: 0.625rem; color: var(--stamp); margin-bottom: var(--s2); }
.callout .link { font-family: var(--mono); font-size: 0.8125rem; overflow-wrap: anywhere; color: var(--ink-2); }

/* ====================================================================== footer */

.foot {
  border-top: 1px solid var(--rule);
  margin-top: var(--s8);
  padding: var(--s5) var(--gutter) var(--s7);
  color: var(--ink-3);
  font-size: 0.8125rem;
}
.foot p { max-width: var(--sheet); margin: 0 auto; }

/* ================================================================ a11y basics */

a { color: var(--stamp); }

:focus-visible {
  outline: 2px solid var(--stamp);
  outline-offset: 3px;
}

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

@media (prefers-contrast: more) {
  :root { --rule: #8A8A8A; --rule-2: #A9A9A9; --ink-2: #1A1A1A; --ink-3: #444444; }
}

/* ============================================================== wider screens */

@media (min-width: 34rem) {
  :root { --gutter: 2rem; }

  .titleblock {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    grid-template-areas: "project rev date sheet";
  }
  .tb-cell { border-top: 0; }
  .tb-date { border-left: 1px solid var(--rule-2); }

  .sheet { padding: var(--s8) 0; }
  fieldset, .question { padding-inline: var(--s5); }
  .option { padding-inline: var(--s4); }

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

  .cta { width: auto; min-width: 16rem; }
  .nav { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: var(--s6); }
  .back { order: 0; }
}

/* ================================================================== MOTION
 *
 * CLAUDE.md section 7 asks for a static hero. Nayyer overruled that on 2026-08-01
 * (docs/decisions.md D-015), so there is motion here — but it obeys three rules:
 *
 *   1. Nothing moves that carries meaning on its own. Motion sequences attention,
 *      it never *is* the information.
 *   2. Every animation ends in the state the page would have had without it, so a
 *      browser without scroll timelines or JS shows a finished page, not a blank one.
 *   3. prefers-reduced-motion switches all of it off, in one block at the end.
 */

@property --sweep { syntax: "<percentage>"; inherits: false; initial-value: 0%; }

/* Cross-document view transitions: navigating between lens screens morphs rather than
   blinks. Progressive — browsers without it just navigate normally. */
@view-transition { navigation: auto; }

::view-transition-group(titleblock) { animation-duration: 260ms; }
::view-transition-old(sheet) { animation: vt-out 200ms cubic-bezier(.4, 0, 1, 1) both; }
::view-transition-new(sheet) { animation: vt-in 320ms cubic-bezier(0, 0, .2, 1) both; }

@keyframes vt-out { to { opacity: 0; transform: translateX(-1.5rem); } }
@keyframes vt-in { from { opacity: 0; transform: translateX(2rem); } }

.titleblock { view-transition-name: titleblock; }
.sheet { view-transition-name: sheet; }

/* --- entrance primitive ----------------------------------------------------------
   Elements carrying .rise start shifted and fade up. --i staggers them. The animation
   is `both`, so the end state is the resting state and nothing is left invisible. */

@keyframes rise {
  from { opacity: 0; transform: translateY(0.875rem); }
  to   { opacity: 1; transform: none; }
}

.rise {
  animation: rise 620ms cubic-bezier(.16, .84, .44, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}

/* Word-by-word headline reveal — the mask means letters climb out of a hard edge
   rather than fading in place, which reads as typeset rather than as a web effect. */
.reveal-line { display: block; overflow: hidden; }
.reveal-word {
  display: inline-block;
  animation: word-up 780ms cubic-bezier(.16, .84, .44, 1) both;
  animation-delay: calc(120ms + var(--i, 0) * 65ms);
}
@keyframes word-up {
  from { transform: translateY(105%) rotate(2deg); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* --- scroll-driven reveals -------------------------------------------------------
   Native scroll timelines where supported. `.js-inview` is the fallback the tiny
   progressive-enhancement script toggles; without either, content is simply visible. */

@supports (animation-timeline: view()) {
  .onscroll {
    animation: rise 700ms cubic-bezier(.16, .84, .44, 1) both;
    animation-timeline: view();
    animation-range: entry 8% cover 26%;
  }
}
@supports not (animation-timeline: view()) {
  .onscroll { opacity: 0; transform: translateY(0.875rem); transition: opacity 620ms ease, transform 620ms cubic-bezier(.16,.84,.44,1); }
  .onscroll.js-inview { opacity: 1; transform: none; }
  html.no-js .onscroll { opacity: 1; transform: none; }
}

/* Weight bars on the lens table fill as they scroll into view. */
.weightbar { display: block; height: 3px; background: var(--rule-2); position: relative; }
.weightbar::after {
  content: "";
  position: absolute; inset: 0 auto 0 0;
  width: var(--sweep);
  background: var(--stamp);
}
@supports (animation-timeline: view()) {
  .weightbar::after {
    animation: sweep-to 900ms cubic-bezier(.16,.84,.44,1) both;
    animation-timeline: view();
    animation-range: entry 10% cover 34%;
  }
}
@supports not (animation-timeline: view()) {
  .weightbar::after { width: var(--w); }
}
@keyframes sweep-to { from { --sweep: 0%; } to { --sweep: var(--w); } }

/* --- selection feedback ----------------------------------------------------------- */

.question { transition: border-left-color 200ms ease, background 200ms ease; }

/* Stepper segments grow into place. */
.stepper li { transition: background 260ms ease; transform-origin: left; }
.stepper li.now { animation: seg-in 420ms cubic-bezier(.16,.84,.44,1) both; }
@keyframes seg-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* --- the score entrance ------------------------------------------------------------
   The number is real text in the HTML, always. The count-up is added by redline.js as
   pure enhancement, so a blocked script shows the finished figure rather than nothing. */

.score { animation: score-in 700ms cubic-bezier(.16,.84,.44,1) both 120ms; }
@keyframes score-in {
  from { opacity: 0; transform: translateY(0.5rem) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.bandscale span { animation: seg-in 500ms cubic-bezier(.16,.84,.44,1) both; animation-delay: calc(420ms + var(--i, 0) * 90ms); transform-origin: left; }

/* --- reduced motion: everything above, off ------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .rise, .reveal-word, .onscroll, .stepper li.now, .score, .bandscale span { animation: none !important; }
  .onscroll { opacity: 1 !important; transform: none !important; }
  .reveal-word { opacity: 1; transform: none; }
  .weightbar::after { width: var(--w); animation: none; }
}

/* Currency unit either side of the rate input. The prefix is filled in from the selected
   country by redline.js; with the script blocked it stays an em dash and the label still
   explains what the field wants. */
.withunit {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: stretch;
  border: 1px solid var(--rule);
  border-bottom-color: var(--ink-3);
  background: #FFFFFF;
}
.withunit:focus-within { border-color: var(--stamp); box-shadow: inset 0 -2px 0 var(--stamp); }
.withunit input { border: 0 !important; box-shadow: none !important; background: transparent; }
.withunit .unit {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  background: var(--paper);
  white-space: nowrap;
}
.withunit .unit:first-child { border-right: 1px solid var(--rule-2); min-width: 3.75rem; justify-content: center; }
.withunit .suffix { border-left: 1px solid var(--rule-2); }
