/*
 * The landing's layout (D-SITE-5, the owner-approved B2 mockup): phone-first (390 px, 16 px gutters),
 * the hero's equation beside its phone from 900 px, the six sections' words beside their replica.
 * Every colour, space and radius is a tokens.css variable (INV-205); dark comes from tokens.css's
 * prefers-color-scheme block only - the site carries no theme switch.
 */

:root { color-scheme: light dark; }

/* the page's own measures — every one built from the app's spaces */
:root {
  --gutter: var(--space16);
  --rowAir: calc(var(--space24) * 2);
  --bigAir: calc(var(--space24) * 4);
  --page: 1200px;
}
@media (min-width: 640px) { :root { --gutter: var(--space24); } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  /* the hub, the how page and the 404 load neither ui.css nor page.css: the system face is their word face (D-FONT-2) */
  font-family: var(--wordFace, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  font-size: 17px;
  line-height: 1.55;
  overflow-wrap: break-word;
}
h1, h2, p { margin: 0; }
a { color: inherit; }
a:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: var(--chipRadius); }
.wrap { max-width: calc(var(--page) + 2 * var(--gutter)); margin: 0 auto; padding-inline: var(--gutter); }

/* ---- header (B): icon + wordmark, the four languages with a 44 px hit */
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; column-gap: var(--space24); padding-block: var(--space12); }
.brand { display: inline-flex; align-items: center; gap: var(--space10); min-height: 44px; font-weight: var(--weight-emphasis); font-size: 19px; letter-spacing: -0.01em; text-decoration: none; }
.brand img { border-radius: var(--chipRadius); }
/* a long language name («Українська (Україна)») does not fit beside the wordmark on a 320-360 px phone: the
   menu wraps under it rather than running off the screen, and its panel hangs from the header's edge,
   the screen's width less the gutters, instead of from a pill that now sits left */
@media (max-width: 599px) {
  .head { position: relative; }
  .head .lang-menu { position: static; }
}

/* ---- the language menu (components/LangMenu.astro): one button, a panel with a filter and every
   language in its own name; built for 40+ languages, the same on the phone and the desktop */
.lang-menu { position: relative; flex: none; }
.lang-menu summary { list-style: none; display: inline-flex; align-items: center; gap: var(--space8); min-height: 44px; padding-inline: var(--space12) var(--space10); font-size: 15px; cursor: pointer; border: var(--border-card) solid var(--outline); border-radius: var(--pillRadius); user-select: none; }
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary:hover { background: var(--surfaceLow); }
.lang-menu summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.lang-menu .nn-icon { width: 18px; height: 18px; flex: none; }
.lang-menu .lang-chev { transition: transform var(--roll, 200ms) ease; }
.lang-menu[open] .lang-chev { transform: rotate(180deg); }
.lang-panel { position: absolute; inset-inline-end: 0; top: calc(100% + var(--space8)); z-index: 30; width: min(560px, calc(100vw - 2 * var(--gutter))); max-height: min(70vh, 520px); display: flex; flex-direction: column; background: var(--surfaceHigh); border: var(--border-card) solid var(--outline); border-radius: var(--cardRadius, 16px); box-shadow: 0 12px 32px rgb(0 0 0 / 0.14); overflow: hidden; }
.lang-find { display: flex; align-items: center; gap: var(--space8); margin: var(--space8); padding-inline: var(--space12); min-height: 44px; background: var(--ground); border: var(--border-card) solid var(--outline); border-radius: var(--pillRadius); color: var(--onSurfaceLow); }
.lang-find[hidden] { display: none; }
.lang-find:focus-within { border-color: var(--ink); }
.lang-find input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: 16px; color: var(--ink); }
.lang-panel ul { margin: 0; padding: var(--space4) var(--space8) var(--space8); list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 2px var(--space4); }
.lang-panel .lang-all { overflow-y: auto; overscroll-behavior: contain; }
.lang-panel .lang-top { flex: none; padding-bottom: var(--space8); border-bottom: var(--border-row) solid var(--ghostOutline); }
.lang-panel .lang-top[hidden] { display: none; }
.lang-menu.is-up .lang-panel { top: auto; bottom: calc(100% + var(--space8)); inset-inline-end: auto; inset-inline-start: 0; }
.lang-panel li[hidden] { display: none; }
.lang-panel a { display: flex; flex-direction: column; justify-content: center; min-height: 44px; padding: var(--space4) var(--space12); text-decoration: none; border-radius: var(--chipRadius); line-height: 1.25; }
.lang-panel a:hover { background: var(--surfaceLow); }
.lang-panel a:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.lang-panel a[aria-current="page"] { background: var(--accentContainer); color: var(--onAccentContainer); font-weight: var(--weight-title); }
.lang-self { font-size: 15px; }
.lang-alt { font-size: 12px; color: var(--onSurfaceLow); }
.lang-alt:empty { display: none; }
a[aria-current="page"] .lang-alt { color: inherit; opacity: 0.75; }
@media (max-width: 639px) {
  .lang-panel { position: fixed; inset-inline: var(--gutter); top: 64px; width: auto; max-height: calc(100dvh - 88px); }
  .lang-menu.is-up .lang-panel { top: auto; bottom: 64px; }
}

/* ---- hero: the words, the equation, the door — and the phone with the SAME equation */
.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: calc(var(--space24) * 2); padding-block: var(--space24) var(--bigAir); }
.hero-words { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
h1 { font-size: clamp(38px, 5.2vw, 68px); line-height: 1.04; font-weight: var(--weight-emphasis); letter-spacing: -0.035em; max-width: 15ch; text-wrap: balance; }
.short { margin-top: var(--space24); font-size: clamp(20px, 2.3vw, 30px); line-height: 1.3; letter-spacing: -0.01em; max-width: 38ch; }

/* The equation as the canvas sets it: the expression on one line, «= result» beneath it in the result
   weight (two lines in every phase, so its height never moves). Five measures, data-phases="5": the
   numbers and units ROLL (.nn-term, ui.css § 2), the operator rolls when it changes, «=» glides. */
.eq {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  width: 100%;
  margin-top: calc(var(--space24) + var(--space16));
  font-family: var(--mathFace);
  font-size: clamp(40px, 4.9vw, 64px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-body);
}
.eq-expr, .eq-res { display: inline-flex; align-items: baseline; gap: 0.28em; white-space: nowrap; }
.eq-res { flex-basis: 100%; font-weight: var(--weight-emphasis); }
.eq .nn-term { padding-block: 0.06em; }
.eq .nn-unit-tag, .eq .nn-result-unit {
  display: inline-block;
  margin-inline-start: 0.12em;
  padding: 0.02em 0.16em 0.06em;
  font-size: 0.62em;
  line-height: 1;
  font-weight: var(--weight-body);
  letter-spacing: 0;
  vertical-align: 0.06em;
  color: var(--unitContent);
  background: var(--unitContainer);
  border-radius: var(--chipRadius);
}
.eq-res .nn-result-unit { font-weight: var(--weight-title); }

.doors { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space12) var(--space24); margin-top: calc(var(--space24) * 2); }
.try {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--rowHeight);
  padding-inline: calc(var(--space24) + var(--space4));
  background: var(--equalsFill); color: var(--equalsInk);
  font-size: 18px; font-weight: var(--weight-title);
  text-decoration: none; border-radius: var(--pillRadius);
}
.try[aria-disabled="true"] { cursor: default; }
/* SITE5-6: until the release the door is a status, not a button - the quiet badge of the formula pages (SITE7-4), the fill returns with the link */
.doors .try[aria-disabled="true"] { width: auto; min-height: calc(var(--space24) + var(--space16)); padding-inline: var(--space16); background: transparent; color: var(--onAccentContainer); border: var(--border-card) solid var(--accentContainer); font-size: 16px; font-weight: var(--weight-body); }
/* D-SITE-33: the QUIET door beside the filled one (the site calculator's, the documentation's) - the same box, an outline
   in place of the fill, so the store's door stays the first; the text link of the home row's «how it works». */
.try.quiet { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 var(--border-card) var(--outline); }
.doors .more { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); font-weight: var(--weight-title); text-underline-offset: 3px; }
.row .doors { margin-top: var(--space12); }
/* The live frame of the site calculator (SiteCalcDemo): the frame's own width, a ring so its ground reads as a card on the page's. */
.site-demo { display: block; width: 100%; max-width: 360px; border: 0; border-radius: var(--panelRadius); box-shadow: 0 0 0 var(--border-card) var(--ghostOutline); }
.site-side { display: flex; justify-content: center; min-width: 0; }
.hero .nn-phone { justify-self: center; }
@media (min-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
  .hero .nn-phone { justify-self: end; }
  .site-side { justify-content: flex-end; }
}

/* ---- the site calculator's short landing (D-SITE-33): a part is a heading over a grid - three numbered steps as cards
   (the ground groups a step's two lines, the number says the order), four facts in two columns. One column under 760 px. */
.part { display: grid; gap: var(--space24); padding-block: var(--rowAir); border-top: 1px solid var(--ghostOutline); }
/* the guide (SITE33-8): one sentence under a part's heading, and the note that closes the steps */
.part-lead { margin: 0; max-width: 62ch; color: var(--onSurfaceLow); }
.part-note { padding: var(--space24); border-radius: var(--panelRadius); box-shadow: inset 0 0 0 var(--border-card) var(--ghostOutline); }
.part-note b { display: block; margin-bottom: var(--space4); font-weight: var(--weight-title); }
.part-note p { margin: 0; color: var(--onSurfaceLow); }
.steps, .facts { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space24); }
.steps { counter-reset: step; }
.steps li { padding: var(--space24); background: var(--surfaceLow); border-radius: var(--panelRadius); }
.steps li::before {
  counter-increment: step; content: counter(step);
  display: grid; place-items: center; width: calc(var(--space24) + var(--space8)); height: calc(var(--space24) + var(--space8));
  margin-bottom: var(--space12); border-radius: 50%;
  background: var(--accentContainer); color: var(--onAccentContainer); font-weight: var(--weight-emphasis);
}
/* the guide's steps (SITE33-9): one step per row, its screenshot of the constructor beside the words (a tall frame of
   the editor) or under them (a wide frame of the page's right side); the outline parts the frame from the step's card */
.steps.shots { grid-template-columns: minmax(0, 1fr); }
.steps.shots li { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space24); align-items: start; }
.steps.shots li::before { margin-bottom: 0; }
.step-shot {
  display: block; max-width: 100%; height: auto; justify-self: start;
  border-radius: var(--panelRadius); box-shadow: 0 0 0 var(--border-card) var(--ghostOutline);
}
.steps.shots .tall .step-shot { width: min(100%, 320px); }
@media (min-width: 900px) {
  .steps.shots .tall { grid-template-columns: minmax(0, 1fr) auto; column-gap: calc(var(--space24) * 2); }
  .steps.shots .tall::before { grid-column: 1; }
  .steps.shots .tall .step-words { grid-column: 1; }
  .steps.shots .tall .step-shot { grid-column: 2; grid-row: 1 / span 3; }
}
.part li b { display: block; margin-bottom: var(--space4); font-size: clamp(17px, 1.55vw, 20px); font-weight: var(--weight-title); }
.part li p { margin: 0; color: var(--onSurfaceLow); }
.part li a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-underline-offset: 3px; }
@media (min-width: 760px) {
  .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: calc(var(--space24) * 2); }
}
@media (max-width: 639px) {
  :root { --bigAir: calc(var(--space24) * 3); }
  .eq { font-size: clamp(30px, 10vw, 56px); }
  .try { width: 100%; }
}

/* ---- the lead: B's two lines, one quiet step below the hero */
.rows { border-top: 1px solid var(--ghostOutline); }
.lead { display: grid; gap: var(--space16); padding-block: var(--rowAir); }
.promo { font-size: clamp(22px, 2.5vw, 32px); line-height: 1.3; letter-spacing: -0.012em; max-width: 34ch; }
.intro { font-size: clamp(17px, 1.6vw, 20px); color: var(--onSurfaceLow); max-width: 44ch; }

/* ---- the six: words left (they stay in view while the replica runs), the living replica right */
.row { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space24); padding-block: var(--rowAir); border-top: 1px solid var(--ghostOutline); }
.row .words { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space12); align-content: start; }   /* the column is the screen, never the longest example */
h2 { font-size: clamp(28px, 3.1vw, 40px); line-height: 1.08; font-weight: var(--weight-emphasis); letter-spacing: -0.025em; }
.body { font-size: clamp(17px, 1.55vw, 20px); max-width: 40ch; }

/* ---- the three examples under the bodies of s1-s3 (D-SITE-13, look A): the hero's math a size down, the result in
   emphasis, a muted note where one is owed; the dot at the start marks the one the phone shows (aria-current).
   Every value is a token; the motion stops under reduced motion. */
.examples { list-style: none; margin: var(--space12) 0 0; padding: 0; display: grid; gap: var(--space12); max-width: 44ch; }
.examples .ex {
  position: relative;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3em;
  padding-inline-start: var(--space16);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.examples.is-eq { font-family: var(--mathFace); font-size: 24px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.examples .ex::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 0.525em;
  width: 0.3em; height: 0.3em; border-radius: 50%;
  background: var(--accent);
  opacity: 0; transform: scale(0.4);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.examples .ex[aria-current="true"]::before { opacity: 1; transform: none; }
.examples .ex-result { font-weight: var(--weight-emphasis); }
.examples .ex-note { flex-basis: 100%; font-family: var(--wordFace, inherit); font-size: 13px; letter-spacing: 0; font-weight: var(--weight-body); color: var(--onSurfaceLow); }
.examples .nn-measured { display: inline-flex; align-items: baseline; gap: 0; } /* the canvas writes a digit per span: no gap inside a number; the tag keeps its own margin */
.examples .nn-chip { border: 1px solid var(--outline); border-radius: var(--pillRadius); padding: 0 0.45em; font-size: 0.92em; background: none; color: inherit; flex-wrap: wrap; white-space: normal; }   /* a long formula chip wraps on a 320 px phone, never runs off it */
.examples .nn-digit, .examples .nn-op { color: inherit; padding: 0; }
.examples .nn-formula .nn-op { margin-inline-end: 0.35em; } /* the chip is a flex row: the «;» between places keeps its space */
.examples .nn-unit-tag, .examples .nn-result-unit {
  display: inline-block; margin-inline-start: 0.12em; padding: 0.02em 0.16em 0.06em;
  font-size: 0.62em; line-height: 1; font-weight: var(--weight-body); letter-spacing: 0; vertical-align: 0.06em;
  color: var(--unitContent); background: var(--unitContainer); border-radius: var(--chipRadius);
}
@media (max-width: 639px) {
  .examples.is-eq { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  .examples .ex::before { transition: none; }
}
html[data-still] .examples .ex::before { transition: none; }
.demo { display: flex; justify-content: center; min-width: 0; }
.demo > * { min-width: 0; max-width: 100%; }   /* the 360 px phone replica shrinks to a 320 px screen (.nn-phone max-width: 100%) instead of running past both edges */
.demo:empty { display: none; }
@media (min-width: 900px) {
  .row { grid-template-columns: minmax(0, 1fr) minmax(360px, auto); column-gap: calc(var(--space24) * 2); align-items: start; }
  .row .words { position: sticky; top: var(--space24); }
  .demo { justify-content: flex-end; }
}

/* ---- the footer (B) */
.foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space8) var(--space24); padding-block: var(--space24) calc(var(--space24) * 2); border-top: 1px solid var(--ghostOutline); color: var(--onSurfaceLow); font-size: 15px; }
.foot a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-underline-offset: 3px; }
.foot .lang-menu { color: var(--ink); }

/* the hero's equation takes the states' html (SITE5-5): its digits and operator wear the page's ink */
.eq .nn-digit, .eq .nn-op { color: inherit; padding: 0; }
.eq .nn-rel { color: inherit; }
