/* Windhorse v2: one screen. The mountain is the app; every explanation opens as a small terminal window where you asked for it. */
@import url("./tokens.css");
@import url("./base.css");


:root {
  --bar-h: 56px; --dock-h: 92px;
  --text-hero: clamp(2.25rem, 3.4vw + 0.6rem, 4.25rem);
}

html:not(.js) .js-only, html:not(.js) .sky canvas { display: none; }
html, body { height: 100%; overflow: hidden; }
body { background: var(--sky-top); overscroll-behavior: none; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 var(--space-lg); border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--color-ink); font: 500 var(--text-md)/1 var(--font-body); text-transform: lowercase; white-space: nowrap; text-decoration: none; cursor: pointer; transition: background-color var(--dur-short) var(--ease-out), transform var(--dur-micro) var(--ease-out); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--color-accent); color: var(--color-accent-ink); }
.btn--primary:hover { background: var(--color-accent-hover); }
.btn--quiet { box-shadow: inset 0 0 0 var(--rule-hair) var(--color-rule-2); }
.btn--quiet:hover { background: var(--color-paper-2); }
.btn--s { min-height: 36px; padding: 0 var(--space-md); font: 400 var(--text-xs)/1 var(--font-outlier); }
.link, .more, .key, .win__x { border: 0; background: none; color: inherit; font: 400 var(--text-xs)/1 var(--font-outlier); cursor: pointer; }
.link { min-height: 40px; padding: 0 var(--space-xs); color: var(--color-ink-2); text-transform: lowercase; }
.link:hover, .link:popover-open { color: var(--color-ink); text-decoration: underline; text-decoration-color: var(--color-accent); text-underline-offset: 0.3em; }
/* 24px: the smallest tap target that is still easy to hit */
.more { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 24px; padding: 2px 6px; border-radius: 3px; color: var(--color-accent-text); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--color-accent-text) 45%, transparent); vertical-align: 0.1em; }
.more:hover { background: color-mix(in oklab, var(--color-accent-text) 16%, transparent); }
.key { min-width: 36px; min-height: 36px; border-radius: 4px; color: var(--color-ink-2); font-size: var(--text-md); box-shadow: inset 0 0 0 1px var(--color-rule-2); }
.key:hover { color: var(--color-ink); background: var(--color-paper-2); }

/* the panels: a terminal window look shared by the intro, the dock and every popup */
.panel, .win { background: var(--panel); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border: 1px solid var(--color-rule-2); border-radius: 6px; color: var(--color-ink); box-shadow: var(--shadow-card); }
.win__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); min-height: 36px; padding: 0 var(--space-2xs) 0 var(--space-sm); border-bottom: 1px solid var(--color-rule); font: 400 var(--text-xs)/1 var(--font-outlier); color: var(--color-muted); }
.win__x { min-width: 32px; min-height: 32px; border-radius: 4px; color: var(--color-muted); font-size: var(--text-md); }
.win__x:hover { color: var(--color-ink); background: var(--color-paper-2); }

/* top bar */
.bar { position: fixed; inset: 0 0 auto; z-index: var(--z-sticky-nav); height: var(--bar-h); display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); padding-inline: var(--gutter); pointer-events: none; }
.bar > * { pointer-events: auto; }
.wordmark { font-family: var(--font-display); font-size: var(--text-2xl); line-height: 1; letter-spacing: var(--tracking-display); color: var(--color-ink); text-decoration: none; text-shadow: 0 0 12px var(--sky-top); }
.bar__links { display: flex; align-items: center; gap: var(--space-2xs); padding: 0 var(--space-2xs); border-radius: 6px; background: var(--panel); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }

/* the mountain */
.app { position: fixed; inset: 0; }
.sky { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
.sky.is-dragging { cursor: grabbing; }
.sky.is-over { cursor: pointer; }
.sky:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -3px; }
.sky canvas { position: absolute; left: 0; top: 0; image-rendering: pixelated; will-change: transform; }
.tip { position: fixed; z-index: var(--z-tooltip); padding: 4px 8px; border-radius: 3px; background: var(--color-ink); color: var(--color-paper); font: 400 var(--text-xs)/1.4 var(--font-outlier); white-space: nowrap; pointer-events: none; }

/* the intro: a folded terminal window, bottom left */
.intro { position: absolute; left: var(--gutter); bottom: calc(var(--dock-h) + var(--space-lg)); z-index: var(--z-raised); width: min(500px, calc(100% - 2 * var(--gutter))); }
.intro__body { display: grid; justify-items: start; gap: var(--space-md); padding: var(--space-lg); }
.intro h1 { max-width: 13ch; font-size: var(--text-hero); line-height: 0.95; text-transform: lowercase; }
.intro .lead { max-width: 36ch; color: var(--color-ink-2); }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-top: var(--space-2xs); }
.intro.is-folded .intro__body { display: none; }
.intro.is-folded .win__bar { border-bottom: 0; }
.verb { display: inline-block; color: var(--color-accent-2); }
.verb::after { content: ""; display: block; height: 0.03em; background: currentColor; transform-origin: left; animation: draw var(--dur-long) var(--ease-out) both; }
@keyframes draw { from { transform: scaleX(0); } }

/* the dock: live readouts and the map of the whole range */
.dock { position: absolute; left: var(--space-sm); right: var(--space-sm); bottom: var(--space-sm); z-index: var(--z-raised); display: grid; gap: var(--space-xs); padding: var(--space-xs) var(--space-sm); font: 400 var(--text-xs)/1.4 var(--font-outlier); }
.dock__row { display: flex; align-items: center; gap: var(--space-sm); min-width: 0; }
.tail { flex: 1; min-width: 0; overflow: hidden; color: var(--color-ink-2); white-space: nowrap; text-overflow: ellipsis; }
.tail::after { content: "_"; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.hud { display: flex; align-items: center; gap: var(--space-md); margin: 0; }
.hud div { display: flex; gap: 6px; }
.hud dt { color: var(--color-muted); }
.hud dd { margin: 0; font-variant-numeric: tabular-nums; }
.map { flex: 1; min-width: 0; height: 30px; image-rendering: pixelated; border-radius: 3px; cursor: pointer; touch-action: none; }

/* windows: native popovers, placed next to whatever opened them */
.win { width: min(400px, calc(100vw - 24px)); max-height: min(78svh, 720px); padding: 0; overflow: auto; overscroll-behavior: contain; background: var(--color-paper); }
.win .win__bar { position: sticky; top: 0; z-index: 1; background: var(--color-paper); }
.win--wide { width: min(460px, calc(100vw - 24px)); }
.js .win:popover-open:not(.is-placed) { visibility: hidden; }
.win.is-placed { inset: auto; margin: 0; }
.win:popover-open { animation: pop var(--dur-short) var(--ease-out); }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }
.win__body { display: grid; gap: var(--space-md); padding: var(--space-lg); }
.win h2 { font-size: var(--text-2xl); line-height: 1.02; text-transform: lowercase; }
.win h3 { display: flex; gap: var(--space-sm); align-items: baseline; font-size: var(--text-xl); text-transform: lowercase; }
.win p { color: var(--color-ink-2); }
.win canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; border-radius: 3px; background: var(--color-paper-2); }
.n { font: 400 var(--text-xs)/1 var(--font-outlier); color: var(--color-accent-text); }
.step { display: grid; gap: var(--space-sm); }
.step canvas { width: min(100%, 260px); }
.preview canvas { width: min(100%, 150px); }
.step + .step { padding-top: var(--space-md); border-top: 1px solid var(--color-rule); }
.figure { margin: 0; display: grid; gap: var(--space-2xs); }
.colours { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; font: 400 var(--text-xs)/1.4 var(--font-outlier); text-align: center; color: var(--color-muted); }
.range { display: grid; gap: var(--space-2xs); }
.range label { display: flex; justify-content: space-between; font: 400 var(--text-xs)/1.6 var(--font-outlier); color: var(--color-muted); }
.range output { color: var(--color-ink); }
.range input { width: 100%; min-height: 36px; margin: 0; accent-color: var(--color-accent); cursor: pointer; }
.log { width: 100%; border-collapse: collapse; font: 400 var(--text-xs)/1.5 var(--font-outlier); font-variant-numeric: tabular-nums; }
.log th { padding: 0 0 var(--space-2xs); font-weight: 400; color: var(--color-muted); text-align: left; }
.log td { padding: var(--space-2xs) var(--space-sm) var(--space-2xs) 0; border-top: 1px solid var(--color-rule); color: var(--color-ink-2); }
.log tr.is-yours td { color: var(--color-accent-text); }
.rows { margin: 0; }
.rows div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2xs) var(--space-md); padding-block: var(--space-sm); border-top: 1px solid var(--color-rule); }
.rows dt { grid-column: 1 / -1; font: 400 var(--text-lg)/1.15 var(--font-display); text-transform: lowercase; }
.rows dd { margin: 0; color: var(--color-ink-2); }
.rows .val { font: 400 var(--text-xs)/1.6 var(--font-outlier); color: var(--color-muted); }
.win__body--flag { grid-template-columns: 112px minmax(0, 1fr); align-items: start; }
.kv, .kv div { margin: 0; }
.kv { display: grid; gap: var(--space-2xs); font: 400 var(--text-xs)/1.5 var(--font-outlier); }
.kv div { display: grid; grid-template-columns: 11ch minmax(0, 1fr); gap: var(--space-xs); }
.kv dt { color: var(--color-muted); }
.kv dd { margin: 0; }

/* the hang form */
.hang { gap: var(--space-sm); }
/* the preview sits beside who and what, so the button stays near the fold */
@media (min-width: 40.0625rem) {
  .hang { grid-template-columns: 150px minmax(0, 1fr); column-gap: var(--space-md); }
  .hang > * { grid-column: 1 / -1; }
  .hang > .preview { grid-column: 1; grid-row: 1 / span 3; align-self: start; }
  .hang > .field, .hang > .check { grid-column: 2; }
}
.summary .nw { white-space: nowrap; }
.preview { margin: 0; display: grid; gap: var(--space-2xs); }
.preview figcaption, .help, .summary { font: 400 var(--text-xs)/1.5 var(--font-outlier); color: var(--color-muted); }
.field { display: grid; gap: var(--space-2xs); }
.field label, .seg legend, .check label { font: 400 var(--text-xs)/1.4 var(--font-outlier); color: var(--color-ink-2); text-transform: lowercase; }
.input { width: 100%; min-height: 44px; padding: var(--space-xs) var(--space-sm); border: 1px solid var(--color-rule-2); border-radius: 4px; background: var(--color-paper); color: var(--color-ink); outline: 2px solid transparent; outline-offset: -3px; }
.input:focus-visible { outline-color: var(--color-focus); }
.input[aria-invalid="true"] { border-color: var(--color-error); }
.input:disabled { opacity: 0.55; cursor: not-allowed; }
textarea.input { min-height: 64px; line-height: 1.5; resize: vertical; }
.help:empty { display: none; }
.check { display: flex; align-items: center; gap: var(--space-sm); min-height: 36px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--color-accent); cursor: pointer; }
.seg { margin: 0; padding: 0; border: 0; }
.seg legend { margin-bottom: var(--space-2xs); padding: 0; }
.seg__opts { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
.seg input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.seg label { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--space-sm); border-radius: 4px; box-shadow: inset 0 0 0 1px var(--color-rule-2); font: 400 var(--text-xs)/1 var(--font-outlier); text-transform: lowercase; white-space: nowrap; cursor: pointer; }
.seg label:hover { background: var(--color-paper-2); }
.seg input:checked + label { background: var(--color-ink); color: var(--color-paper); }
.seg input:focus-visible + label { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.seg:disabled label, .seg input:disabled + label { opacity: 0.4; cursor: not-allowed; }
.seg--swatch label::before { content: ""; width: 10px; height: 10px; background: var(--c); box-shadow: 0 0 0 1px var(--color-rule-2); }
/* summary and button stay in view at the bottom of the window while the fields scroll */
.hang__foot { position: sticky; bottom: 0; display: grid; gap: var(--space-xs); margin-bottom: calc(-1 * var(--space-lg)); padding-block: var(--space-sm) var(--space-lg); border-top: 1px solid var(--color-rule); background: var(--color-paper); }
.hang .btn--primary { justify-self: start; }
.check--consent { align-items: flex-start; }
.check--consent input { margin-top: 2px; flex: none; }
.check--consent label { line-height: 1.5; }
.legal-link { color: var(--color-muted); }
.win__body--flag [data-takedown] { grid-column: 1 / -1; justify-self: start; }
.status { min-height: 1lh; font-size: var(--text-sm); }

@media (max-width: 60rem) {
  .hud .hide-m { display: none; }
}
@media (max-width: 40rem) {
  :root { --dock-h: 104px; }
  .bar { padding-inline: var(--space-sm); }
  .wordmark { font-size: var(--text-xl); }
  .link { padding: 0 4px; }
  .bar__links { gap: 0; }
  .intro { left: var(--space-sm); width: calc(100% - 2 * var(--space-sm)); bottom: calc(var(--dock-h) + var(--space-sm)); }
  .intro__body { padding: var(--space-md); gap: var(--space-sm); }
  .dock__row:first-child { flex-wrap: wrap; row-gap: 2px; }
  .tail { flex-basis: 100%; }
  .hud { gap: var(--space-sm); }
  .hud .hide-s { display: none; }
  .dock__nav .btn--s { padding: 0 var(--space-sm); }
  .dock .key { display: none; }
  .win, .win.is-placed, .win--wide { left: 8px !important; right: 8px !important; top: auto !important; bottom: 8px !important; width: auto; margin: 0; max-height: 76svh; }
}
@media (prefers-reduced-motion: reduce) {
  .verb::after, .tail::after, .win:popover-open { animation: none; }
}
