/* Interway — one page, dressed as a fight card: carmine field, wide wordmark,
   product fragments on charcoal so the recordings keep their own colours.

   One type scale, one spacing scale. Every section is built from the same
   steps, so the page reads as one document at every width. Nothing folds
   except the questions, which are native <details> and open on a desktop. */

:root {
  --ground: #9c1220;
  --ground-deep: #8a101c;
  --ground-soft: #a92330;
  --ink: #ffffff;
  --muted: #f4c6c9;
  --accent: #ffd9dc;
  --accent-ink: #9c1220;
  --char: #141111;
  --char-2: #1d1918;
  --char-ink: #f1f3f7;
  --char-muted: #a9a0a0;

  /* type */
  --step-small: clamp(0.875rem, 0.85rem + 0.1vw, 0.9375rem);
  --step-body: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  --step-lead: clamp(1.25rem, 1.15rem + 0.55vw, 1.625rem);
  --step-head: clamp(1.9rem, 1.4rem + 2.6vw, 4rem);
  --step-display: clamp(3rem, 1.6rem + 8.4vw, 8.5rem);

  /* space */
  --s-1: 6px;
  --s-2: 14px;
  --s-3: 22px;
  --s-4: 34px;
  --s-5: 52px;

  --pad: clamp(20px, 4vw, 56px);
  --gap-section: clamp(64px, 9vw, 150px);

  /* Height of the sticky bar, so an anchor never lands under it. */
  --head-h: 62px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "Switzer", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--step-body);
  line-height: 1.5;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
  font-family: "Panchang", "Switzer", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 0.98;
  margin: 0;
}

p { margin: 0; }

a { color: inherit; }

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

::selection { background: var(--accent); color: var(--accent-ink); }

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

/* ---------- top bar ---------- */

/* The whole bar is one floating glass capsule: a translucent carmine fill over
   whatever scrolls beneath it, a hairline border, a light along the top edge.
   The fill is dark enough that white nav text stays legible over a white
   heading as well as over the charcoal figures. */
.top {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin: 8px 8px 0;
  padding: 8px 12px 8px 18px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 30px;
  background: rgba(120, 14, 26, 0.66);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 10px 26px rgba(0, 0, 0, 0.16);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
}

/* No glass: the bar is paper again, same border, same radius. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .top { background: var(--ground); }
}

@media (prefers-reduced-transparency: reduce) {
  .top {
    background: var(--ground-deep);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.mark {
  font-family: "Panchang", sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  font-size: 1rem;
  text-decoration: none;
  white-space: nowrap;
}

.nav { display: flex; gap: var(--s-2); }

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  font-size: 0.8125rem;
  text-decoration: none;
  color: var(--ink);
  opacity: 0.9;
  white-space: nowrap;
}

.nav a:hover {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.lang {
  display: flex;
  gap: 0;
  margin-left: auto;
  font-size: 0.8125rem;
}

.lang a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 5px;
  text-decoration: none;
  opacity: 0.55;
}

.lang a:hover { opacity: 1; }

.lang a[aria-current="true"] {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

.action {
  margin-left: 0;
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  font-weight: 500;
  font-size: var(--step-small);
  padding: 10px 18px;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  white-space: nowrap;
  transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.action:hover { background: var(--ink); }
.action:active { transform: translateY(1px); }

.action.big {
  font-size: var(--step-body);
  padding: 15px 26px;
}

.action.alt {
  background: transparent;
  color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.action.alt:hover { background: var(--accent); color: var(--accent-ink); }

/* The two pills in the bar share one height with the links beside them. */
.top .action {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 0.8125rem;
}

.top .action.demo {
  padding: 0 14px;
  background: transparent;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.top .action.demo:hover { background: var(--accent); color: var(--accent-ink); }

/* ---------- sections ---------- */

main > section {
  padding: 0 var(--pad);
  margin-top: var(--gap-section);
  scroll-margin-top: calc(var(--head-h) + 16px);
}

main > section:first-child { margin-top: var(--s-2); }

h2 { font-size: var(--step-head); max-width: 20ch; }

.lead {
  font-size: var(--step-lead);
  line-height: 1.4;
  max-width: 34ch;
  margin-top: var(--s-3);
  color: var(--ink);
  opacity: 0.88;
}
.lead code { color: var(--ink); }

/* ---------- hero ---------- */

.hero h1 { font-size: var(--step-display); }

/* English words are wider than the Russian ones at the same size: cap the
   display step so "ANSWERS." fits the content width on a phone. */
html[lang="en"] .hero h1 { font-size: min(var(--step-display), 10.7vw); }

/* Russian hero is two short words: one line on a desktop, stacked below it. */
@media (min-width: 1000px) {
  html[lang="ru"] .hero h1 { white-space: nowrap; }
}
@media (max-width: 999px) {
  html[lang="ru"] .hero h1 span { display: block; }
}

.hero .lead { max-width: 46ch; }

/* ---------- recording ---------- */

.player {
  margin: var(--s-4) 0 0;
  background: var(--char);
}

.player-stage {
  position: relative;
  background: var(--char);
}

.player video {
  display: block;
  width: 100%;
  aspect-ratio: 1180 / 540;
  object-fit: cover;
  background: var(--char);
  cursor: pointer;
}

.player-toggle {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: rgba(20, 17, 17, 0.62);
  color: var(--accent);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.player-toggle:hover { background: rgba(20, 17, 17, 0.88); }

.player-toggle svg { display: block; fill: currentColor; }

.player-toggle[data-state="playing"] .ic-play { display: none; }
.player-toggle[data-state="paused"] .ic-pause { display: none; }

.media-bar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 12px 16px;
  background: var(--char-2);
}

.switch { display: flex; gap: 8px; }

.switch button {
  font: inherit;
  font-size: var(--step-small);
  color: var(--char-ink);
  background: #2a2524;
  border: 0;
  border-radius: 0;
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.switch button:hover { background: #352f2d; }

.switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.clock {
  margin-left: auto;
  font-size: var(--step-small);
  color: var(--char-muted);
  font-variant-numeric: tabular-nums;
}

.player figcaption {
  padding: 12px 16px 14px;
  color: var(--char-muted);
  font-size: var(--step-small);
  line-height: 1.45;
  background: var(--char-2);
}

/* ---------- code figures (the ASCII look) ---------- */

.codefig { margin: var(--s-4) 0 0; }

.codefig pre {
  margin: 0;
  padding: var(--s-3);
  background: var(--char);
  color: var(--char-ink);
  font-size: var(--step-small);
  line-height: 1.6;
  white-space: pre;
  overflow-x: auto;
  max-width: 100%;
}

.codefig figcaption {
  margin-top: var(--s-2);
  font-size: var(--step-small);
  opacity: 0.75;
  max-width: 46ch;
}

.hero-ascii { margin: var(--s-5) 0 0; }

.hero-ascii pre {
  font: 400 clamp(9px, 1.15vw, 17px)/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
  width: max-content;
  letter-spacing: 0;
}

/* ---------- demo ---------- */

.demo-frame {
  position: relative;
  margin-top: var(--s-4);
  background: var(--char);
  min-height: 520px;
}

.demo-frame iframe {
  visibility: hidden;
  display: block;
  width: 100%;
  height: 520px;
  border: 0;
  background: var(--char);
}

.demo-scrim {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-3);
  text-align: center;
  background: var(--char);
  color: var(--char-ink);
  border: 1px solid var(--hair);
}

.demo-scrim.gone { display: none; }
.demo-frame.started iframe { visibility: visible; }

.demo-kicker {
  font-size: var(--step-small);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--char-muted);
}

.demo-scrim h3 {
  font-size: clamp(1.55rem, 1.1rem + 1.9vw, 2.6rem);
  max-width: 16ch;
}

.demo-line {
  max-width: 44ch;
  color: var(--char-ink);
  opacity: 0.92;
}

.demo-scrim .action { margin-left: 0; min-height: 44px; }

.demo-done {
  margin-top: var(--s-3);
  font-size: var(--step-body);
}

.demo-done a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.demo-elsewhere {
  margin-top: var(--s-2);
  font-size: var(--step-small);
  opacity: 0.85;
}

.demo-elsewhere a { color: var(--accent); text-underline-offset: 3px; }

/* ---------- session ---------- */

/* A claim and its one-line proof: one row each, no paragraphs. */
.spec {
  width: 100%;
  margin-top: var(--s-4);
  border-collapse: collapse;
  font-size: var(--step-small);
}

.spec th,
.spec td {
  text-align: left;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  vertical-align: top;
}

.spec th {
  width: 14ch;
  padding-right: var(--s-3);
  font-weight: 500;
  color: var(--ink);
  opacity: 0.62;
  white-space: nowrap;
}

.spec td { opacity: 0.92; }

.spec code { color: var(--ink); background: rgba(0, 0, 0, 0.18); padding: 0 4px; overflow-wrap: anywhere; }

/* ---------- keys ---------- */

.keylist {
  list-style: none;
  margin: var(--s-4) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.keylist li {
  display: grid;
  grid-template-columns: 13ch 22ch 1fr;
  gap: var(--s-2);
  align-items: baseline;
  padding: var(--s-3);
}

.keylist li:nth-child(odd) { background: var(--ground-deep); }

.keylist kbd {
  justify-self: start;
  font-size: var(--step-body);
  padding: 6px 12px;
}

.keylist b {
  font-family: "Panchang", sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  font-size: var(--step-body);
  line-height: 1.1;
}

.keylist span { color: var(--ink); opacity: 0.82; }

kbd {
  font-family: "Switzer", sans-serif;
  font-size: inherit;
  font-weight: 500;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 0;
  padding: 1px 8px;
  white-space: nowrap;
}

/* ---------- legend / mentor: prose beside a terminal strip ---------- */

.legend .lead { max-width: 52ch; }

/* Prose beside a terminal strip. */
.legend-body {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: var(--s-5);
  margin-top: var(--s-4);
  align-items: start;
}

.legend-body { grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); }

.legend-text p { max-width: 46ch; opacity: 0.92; }

.legend-text p + p { margin-top: var(--s-2); }

/* The mentor figure is the whole section now: no prose column beside it. */
.mentor .codefig { margin-top: var(--s-4); }

.legend-text code {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.18);
  padding: 0 4px;
  overflow-wrap: anywhere;
}

/* The one line that says what is not for sale yet. */
.note {
  margin-top: var(--s-3);
  font-size: var(--step-small);
  line-height: 1.5;
  color: var(--accent);
  max-width: 46ch;
}

/* ---------- questions ---------- */

/* ---------- download ---------- */

.build {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 64px);
  align-items: start;
}

.build-text .lead { max-width: 30ch; }

.downloads {
  background: var(--char);
  padding: var(--s-3);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-2);
  justify-items: stretch;
  align-content: start;
}

.downloads .action.big {
  margin: 0;
  text-align: center;
}

/* ---------- footer ---------- */

.foot {
  margin-top: var(--gap-section);
  padding: 0 var(--pad) 40px;
}

.foot-mark {
  font-family: "Panchang", sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.03em;
  /* Fit the wordmark to the content width: 9.4em is the measured word length,
     so it spans the page without bleeding past the right edge at any width. */
  font-size: min(10.2vw, calc((100vw - 2 * var(--pad)) / 9.4), 9.5rem);
  line-height: 0.8;
  white-space: nowrap;
}

.foot-note {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-top: var(--s-3);
  font-size: var(--step-small);
  opacity: 0.85;
}

/* ---------- sticky download CTA (phone only, below the recording) ---------- */

.cta-bar { display: none; }

/* ---------- motion ---------- */

[data-reveal] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

[data-reveal].in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  [data-reveal] { opacity: 1; transform: none; transition: none; }
  .action, .switch button, .player-toggle, .cta-bar { transition: none; }
}

/* ---------- tablet ---------- */

/* Seven section links stop fitting before the layout does: the bar keeps the
   wordmark, the language and the download, and drops the index. */
@media (max-width: 999px) {
  .nav { display: none; }
}

/* ---------- phone: one rhythm from 390 to 430 ---------- */

@media (max-width: 820px) {
  :root { --head-h: 60px; }

  /* Phone: the bar is wordmark and language only. The download lives in the
     bottom bar, the demo in the index below, so the first screen stays the
     recording, not two pills. */
  .top {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "mark . lang";
    align-items: center;
    column-gap: var(--s-2);
    padding: 8px 12px;
    background: rgba(156, 18, 32, 0.55);
  }

  .top .action.cta,
  .top .action.demo { display: none; }

  /* Without a backdrop filter the bar is paper again, same hairline. */
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .top { background: var(--ground); }
  }

  @media (prefers-reduced-transparency: reduce) {
    .top { background: var(--ground); }
  }

  .top .mark { grid-area: mark; justify-self: start; }

  .top .lang {
    grid-area: lang;
    justify-self: end;
    align-self: center;
    margin-left: 0;
  }

  .top .lang a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 6px;
    opacity: 0.8;
  }

  .top .lang a[aria-current="true"] { opacity: 1; }

  .lead { max-width: 32ch; }

  /* the recording and the text session run edge to edge */
  .recording { margin-top: var(--s-5); }

  .player { margin-inline: calc(var(--pad) * -1); }

  .hero-ascii { margin-inline: calc(var(--pad) * -1); }

  .hero-ascii pre { width: 100%; padding: 12px; }

  .hero-ascii figcaption { padding: 0 var(--pad); }

  .demo-frame,
  .demo-frame iframe { min-height: 640px; height: 640px; }

  .demo-scrim h3 { max-width: 100%; }

  .keylist li {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-1);
  }

  .legend-body,
  .mentor-body { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }

  .build { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }

  .foot-note { flex-direction: column; gap: var(--s-1); }

  body { padding-bottom: 68px; }

  .cta-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: 10px var(--pad);
    background: var(--ground-deep);
    border-top: 1px solid var(--ground-soft);
    transform: translateY(110%);
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
  }

  .cta-bar.show {
    transform: none;
    visibility: visible;
    transition: transform 0.22s ease;
  }

  .cta-bar .cta-note {
    font-size: var(--step-small);
    color: var(--muted);
  }

  .cta-bar .action { margin-left: auto; }
}

/* 320-380: the capsule keeps its two rows, so the type and the insets step
   down instead of the bar growing. */
@media (max-width: 380px) {
  :root { --head-h: 54px; }

  .top {
    margin: 6px 6px 0;
    padding: 6px 10px;
    column-gap: var(--s-1);
  }

  .mark { font-size: 0.92rem; }
  .lang { font-size: 0.8rem; }
}

/* 4 px of a decorative box used to spill past the column on 320 px screens */
.build-text .cta-note {
  margin-top: var(--s-3);
  font-size: var(--step-small);
  line-height: 1.5;
  color: var(--muted);
  max-width: 62ch;
}

.build-text { min-width: 0; overflow-x: clip; }
.build-text h2 { overflow-x: clip; letter-spacing: -0.028em; }
@media (max-width: 380px) {
  .build-text h2 { letter-spacing: -0.036em; }
}
