/* The Scale Check · styles. Tokens from brand/DESIGN.md. */

@font-face {
  font-family: "Libre Baskerville";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/libre-baskerville.woff2") format("woff2");
}
@font-face {
  font-family: "Libre Baskerville";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/libre-baskerville-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("fonts/inter.woff2") format("woff2");
}
@font-face {
  font-family: "Caveat";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/caveat-600.woff2") format("woff2");
}

:root {
  --paper: #FAF9F6;
  --sand: #EFE7D9;
  --linen: #ECE7E1;
  --sage: #929C88;
  --dusty-blue: #9DA6A3;
  --charcoal: #5B5A5A;
  --clay: #BFA98E;
  --siena: #B0552F; /* marks what is off (Ariana, Oct 21 2026). On Paper: 4.8:1 */
  --honey: #F0C696;
  --charcoal-deep: #4A4948;
  --sage-deep: #78826E;

  /* Text-safe shades: same hues, deep enough for WCAG AA (Ariana, Oct 19 2026, question 5).
     The brand colors above stay for fills, lines and the drawing. */
  --clay-ink: #A78964; /* the italic turn, title size on Paper: 3.1:1 */
  --sage-ink: #6A7460; /* small sage text on Paper 4.7:1; fill under white text 4.9:1 */

  --rule: #D9D3CA;
  --font-title: "Libre Baskerville", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-note: "Caveat", "Bradley Hand", cursive;
  --gutter: 16px;
  --radius: 4px;
}

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

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--charcoal-deep);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  position: relative;
  max-width: 34rem;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  flex-direction: column;
}

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

.title {
  margin: 0 0 12px;
  font-family: var(--font-title);
  font-weight: 400;
  font-size: clamp(1.625rem, 1.3rem + 1.4vw, 2.125rem);
  line-height: 1.24;
  color: var(--charcoal);
  text-wrap: balance;
}
.title:focus { outline: none; }
.title--hero { font-size: clamp(2rem, 1.5rem + 2.4vw, 2.75rem); line-height: 1.18; }
.turn { font-style: italic; color: var(--clay-ink); }

.label {
  margin: 0 0 10px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.75rem;
  line-height: 1.4;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sage-ink);
}

.body,
.help { margin: 0 0 16px; max-width: 32em; }
.help { font-size: 1rem; }

.fine {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* ---------- Name tab ---------- */

.name-tab {
  position: absolute;
  top: 0;
  right: var(--gutter);
  margin: 0;
  padding: 9px 14px 8px;
  background: var(--sage-ink);
  color: #FFFFFF;
  border-radius: 0 0 var(--radius) var(--radius);
  font-weight: 500;
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ---------- Progress ruler ---------- */

.ruler {
  --steps: 11;
  --progress: 0;
  padding-top: max(16px, env(safe-area-inset-top));
}
.ruler__phases {
  position: relative;
  height: 18px;
  font-weight: 500;
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sage-ink);
}
.ruler__phase { position: absolute; top: 0; } /* left: set by src/app.js, above the phase's first step */
.ruler__phase.is-current { color: var(--charcoal-deep); }
.ruler__track {
  position: relative;
  height: 9px;
  border-bottom: 1px solid var(--charcoal);
  border-right: 1px solid var(--charcoal);
  background-image: repeating-linear-gradient(
    90deg,
    var(--charcoal) 0 1px,
    transparent 1px calc(100% / var(--steps))
  );
  background-size: 100% 5px;
  background-position: bottom left;
  background-repeat: no-repeat;
}
.ruler__fill {
  position: absolute;
  left: 0;
  bottom: -2px;
  height: 3px;
  width: calc(var(--progress) / var(--steps) * 100%);
  background: var(--sage-ink);
  transition: width 400ms ease;
}

/* ---------- Drawing (src/drawing.js) ---------- */

.drawing { margin: 12px 0 8px; }
.drawing__sheet {
  position: relative;
  height: clamp(150px, 30dvh, 300px);
  overflow: hidden;
}
.drawing__sheet svg { display: block; }
.dw-drag { cursor: ns-resize; touch-action: none; }
.drawing__note { margin: 8px 0 0; font-size: 0.8125rem; }
.app[data-at="result"] .drawing { margin-top: 52px; }

/* ---------- Screens ---------- */

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: 8px;
}
.screen__form { flex: 1; display: flex; flex-direction: column; }
.screen__body { flex: 1; }

.screen--intro { padding-top: 56px; }
.welcome__art { margin: 0 0 20px; }
.welcome__art svg { display: block; width: 100%; height: auto; }
/* Screens with no ruler and no drawing above them. */
.screen[data-screen="ready"],
.screen[data-screen="furniture"],
.screen[data-screen="notYet"],
.screen[data-screen="chart"] { padding-top: max(56px, env(safe-area-inset-top)); }
.actions--stack { flex-direction: column; gap: 10px; }
.actions--stack .fine { margin: 0; text-align: center; }

.needs {
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--rule);
}
.needs li { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.needs__label { margin-top: 28px; }

/* Buttons sit in thumb reach and stay there while the page scrolls. */
.actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding: 12px 0 max(16px, env(safe-area-inset-bottom));
  background: var(--paper);
}
/* On the choice screens Back is the only button; let it scroll so it never covers a choice. */
.actions:not(:has(.btn--primary)) { position: static; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--charcoal-deep);
  font: 500 1rem/1.2 var(--font-body);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn--primary { flex: 1; background: var(--charcoal-deep); color: var(--paper); }
.btn--primary:active { background: #3A3938; }
.btn--primary:disabled { opacity: 0.35; cursor: default; }
.btn--secondary { border-color: var(--charcoal-deep); }
.btn--back { padding: 0 14px; min-width: 44px; }
.btn--quiet {
  min-height: 44px;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

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

/* ---------- Measuring ---------- */

/* How to measure: three numbered steps in white circles, then the common slip. */
.steps { margin: 4px 0 0; padding: 0; list-style: none; counter-reset: step; max-width: 32em; }
.steps li { position: relative; padding: 5px 0 5px 40px; counter-increment: step; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 4px;
  width: 27px;
  height: 27px;
  border: 1px solid var(--charcoal-deep);
  border-radius: 50%;
  background: #FFFFFF;
  color: var(--charcoal-deep);
  font: 500 0.8125rem/25px var(--font-body);
  text-align: center;
}
.slip {
  margin: 12px 0 0;
  padding: 10px 14px;
  max-width: 32em;
  border-left: 2px solid var(--clay);
  background: var(--sand);
  font-size: 0.9375rem;
}
.screen[data-screen="notYet"] .btn--quiet { margin-top: 4px; }

/* Watch: "from the side, at their height", handwritten under each check's title. */
.watch-note {
  margin: -4px 0 4px;
  font-family: "Caveat", "Bradley Hand", cursive;
  font-weight: 600;
  font-size: 1.3125rem;
  line-height: 1.2;
  color: var(--sage-ink);
}

.measure {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0 4px;
}
.stepper {
  flex: none;
  width: 52px;
  height: 52px;
  border: 1px solid var(--charcoal-deep);
  border-radius: 50%;
  background: none;
  color: var(--charcoal-deep);
  font: 400 1.5rem/1 var(--font-body);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.stepper:active { background: var(--linen); }
.measure__field {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  border-bottom: 1.5px solid var(--charcoal);
  padding-bottom: 4px;
}
.measure__field input {
  width: 5.4ch;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--charcoal-deep);
  font: 400 2.25rem/1.2 var(--font-title);
  text-align: center;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
}
.measure__field input:focus { outline: none; }
.measure__field:focus-within { border-bottom-color: var(--charcoal-deep); box-shadow: 0 1.5px 0 var(--charcoal-deep); }
.measure__unit { font-size: 0.9375rem; }

.error { min-height: 1.5em; margin: 8px 0; font-size: 0.9375rem; color: var(--charcoal-deep); }
.error:not(:empty)::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 8px 2px 0; border-radius: 50%; background: var(--siena); }

.flags { margin-top: 8px; border-top: 1px solid var(--rule); }
.check {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  border-bottom: 1px solid var(--rule);
  font-size: 1rem;
  cursor: pointer;
}
.check input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--sage-ink); }

/* ---------- Choices ---------- */

.options { display: grid; gap: 10px; margin-top: 16px; }
.option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 60px;
  padding: 12px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--charcoal-deep);
  font: 400 1rem/1.4 var(--font-body);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.option:active { border-color: var(--charcoal-deep); }
.option[aria-pressed="true"] { border-color: var(--sage-ink); box-shadow: inset 0 0 0 1px var(--sage-ink); background: #F2F3EF; }
.card { padding: 10px 16px 10px 10px; }
.card__art { flex: none; width: 72px; height: 72px; border-radius: 2px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--rule); }
.card__art svg { display: block; }
.option--unsure { min-height: 52px; border-style: dashed; }

/* ---------- Result ---------- */

.screen--result { padding-top: 0; }
.app[data-at="result"] .drawing[hidden] ~ .screen--result { padding-top: 64px; } /* room under the name tab */

/* Seat, Table and Leg room at a glance. */
.chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 28px;
  padding: 0;
  list-style: none;
}
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 4px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-align: center;
}
.chip__name { font-weight: 500; font-size: 0.6875rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--sage-ink); }
.chip__state { font-size: 0.9375rem; line-height: 1.3; }
.chip[data-state="ok"] .chip__state::before { content: "✓"; margin-right: 4px; color: var(--sage-ink); }
.chip[data-state="look"] { border-color: var(--siena); box-shadow: inset 0 0 0 1px var(--siena); background: #F6F1EA; }
.chip[data-state="look"] .chip__name { color: var(--charcoal-deep); } /* sage on the tint reads under 4.5:1 */
.chip[data-state="unsure"] { border-style: dashed; }

/* Seat, Table and Leg room against Today, For your child and What to do. */
.result-table { margin: 8px 0 24px; }
.fit-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.4; }
.fit-table th,
.fit-table td { padding: 10px 10px 10px 0; text-align: left; vertical-align: top; border-top: 1px solid var(--rule); }
.fit-table thead th,
.fit-table td::before {
  font-weight: 500;
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sage-ink);
}
.fit-table thead th,
.fit-table thead td { padding-top: 0; border-top: 0; }
.fit-table__name { font-weight: 500; white-space: nowrap; }
/* Today and For your child stay on one line; What to do takes what is left. */
.fit-table--three td:nth-of-type(1),
.fit-table--three td:nth-of-type(2) { white-space: nowrap; }
.fit-table__line { display: block; }
.fit-table__line + .fit-table__line { margin-top: 4px; }
/* On a phone each row stacks: its name, then each column's name beside its value. */
@media (max-width: 499px) {
  .fit-table--three thead { display: none; }
  .fit-table--three,
  .fit-table--three tbody,
  .fit-table--three tr,
  .fit-table--three th,
  .fit-table--three td { display: block; }
  .fit-table--three tr { padding: 12px 0 10px; border-top: 1px solid var(--rule); }
  .fit-table--three th,
  .fit-table--three td { padding: 2px 0; border: 0; }
  .fit-table--three .fit-table__name { margin-bottom: 4px; }
  .fit-table--three td { display: grid; grid-template-columns: 8.5em 1fr; gap: 12px; }
  .fit-table--three td::before { content: attr(data-col); padding-top: 2px; }
}

.do-box {
  margin: 8px 0 20px;
  padding: 18px 20px 20px;
  border-radius: var(--radius);
  background: var(--sage-ink);
  color: #FFFFFF;
}
.do-box__label { margin: 0 0 8px; font-weight: 500; font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; }
.do-box__text { margin: 0; }

.notes { margin: 0 0 20px; padding: 0; list-style: none; }
.notes li { padding: 10px 0; border-top: 1px solid var(--rule); font-size: 0.9375rem; }
.notes:empty { display: none; }

.result-measure { width: 100%; margin: 0 0 24px; }

/* The size chart: how to buy before they can be measured. */
.buying { margin: 8px 0 24px; padding-top: 18px; border-top: 1px solid var(--rule); }
.buying__lead { margin: 0 0 10px; font-weight: 500; color: var(--charcoal-deep); }
.buying__rules { margin: 0; padding-left: 1.4em; }
.buying__rules li { margin-bottom: 8px; padding-left: 4px; }
.buying__rules li::marker { color: var(--sage-ink); font-weight: 500; }

.fix { margin: 8px 0 24px; padding-top: 18px; border-top: 1px solid var(--rule); }
.fix__text { margin-bottom: 10px; }
.fix__chapter { margin: 0; }

.result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  margin: 4px 0 32px;
}
.screen--result .fine:last-child { padding-bottom: max(16px, env(safe-area-inset-bottom)); }

/* Pilot mode only (?pilot=1): the summary to copy and send. */
.pilot { margin: 0 0 28px; padding: 18px 20px 20px; border-radius: var(--radius); background: var(--linen); }
.pilot__title { margin: 0 0 8px; font: 400 1.25rem/1.3 var(--font-title); color: var(--charcoal); }
.pilot .body { margin: 0 0 14px; }
.pilot__summary {
  display: block;
  width: 100%;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--charcoal-deep);
  font: 400 0.8125rem/1.55 var(--font-body);
  resize: none;
}
.pilot .btn { width: 100%; }

/* ---------- Result card, full screen ---------- */

.card-view {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) var(--gutter) max(16px, env(safe-area-inset-bottom));
  background: var(--paper);
}
.card-view__img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 150px);
  border: 1px solid var(--rule);
  border-radius: 2px;
  -webkit-touch-callout: default; /* keep the iPhone's press-and-hold menu */
}
.card-view__note { margin: 0; text-align: center; }
[aria-busy="true"] { opacity: 0.6; }

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

@media (prefers-reduced-motion: no-preference) {
  .is-entering .title { animation: rise 600ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .is-entering .title .turn { animation: land 500ms ease 350ms both; }
  .is-entering .screen__body > :not(.title),
  .is-entering .actions { animation: fade 500ms ease 150ms both; }
  .is-entering .welcome__art { animation: fade 700ms ease both; }
  .is-entering .chip { animation: fade 400ms ease both; }
  .is-entering .chip:nth-child(2) { animation-delay: 120ms; }
  .is-entering .chip:nth-child(3) { animation-delay: 240ms; }

  /* The drawing: dimension lines draw in, notes arrive last. */
  .dw-draw { stroke-dasharray: 1; animation: dw-draw 700ms cubic-bezier(0.4, 0, 0.2, 1) both; }
  .dw-fade { animation: fade 450ms ease both; }
  .dw-land { transform-box: fill-box; transform-origin: center; animation: dw-land 500ms cubic-bezier(0.3, 1.4, 0.5, 1) both; }
  /* The furniture slides in when it first appears; the child crossfades between poses. */
  .dw-from-left { animation: dw-from-left 600ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .dw-from-right { animation: dw-from-right 650ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .dw-pose-in { animation: dw-pose-in 450ms ease both; }
  .dw-pose-out { animation: dw-pose-out 450ms ease both; }
}

@keyframes dw-from-left { from { opacity: 0; transform: translateX(-14px); } }
@keyframes dw-from-right { from { opacity: 0; transform: translateX(18px); } }
@keyframes dw-pose-in { from { opacity: 0; transform: translateY(3px); } }
@keyframes dw-pose-out { to { opacity: 0; } }

@keyframes dw-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes dw-land { from { opacity: 0; transform: scale(1.5); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes land { from { opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes settle { from { opacity: 0; transform: rotate(-6deg) scale(1.12); } }

/* ---------- How to measure (src/howto.js) ---------- */

.howto { height: clamp(150px, 26dvh, 230px); margin: 4px 0 12px; }
.howto svg { display: block; width: 100%; height: 100%; }
