/* ambient.css — the full-screen player's own skin.
 *
 * Self-contained, like quiz.css: this page shares no layout with the reader
 * (no topbar, no sidebar, no card grid), so it defines its own world rather
 * than overriding kb.css. Two constraints drive every choice here:
 *
 *   1. It is read from a DISTANCE — type scales with the viewport (vw units),
 *      so the same page is legible on a laptop and on a wall-mounted screen.
 *   2. It runs UNATTENDED — dark by default (a bright rectangle in a room at
 *      night is a lamp), and every control fades away until someone reaches
 *      for it.
 */

body.amb-body {
    margin: 0;
    padding: 0;
    background: #0b1020;
    color: #e9eefc;
    font-family: 'DM Sans', system-ui, -apple-system, Arial, sans-serif;
    overflow: hidden;                 /* the stage owns the viewport */
}

.amb-stage {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: clamp(20px, 3.4vw, 64px);
    /* A very soft off-centre glow keeps a large dark screen from reading as a
       dead panel, without competing with the text. */
    background:
        radial-gradient(1200px 620px at 22% 12%, rgba(47,128,237,.14), transparent 62%),
        radial-gradient(900px 520px at 82% 88%, rgba(124,58,237,.12), transparent 60%);
}

/* ── Progress: the only always-visible motion, so a passer-by can tell the
      display is live and roughly when it will turn over. ─────────────────── */
.amb-progress {
    position: absolute; top: 0; left: 0; right: 0;
    height: 3px; background: rgba(255,255,255,.07);
}
.amb-progress-bar {
    height: 100%; width: 0;
    background: linear-gradient(90deg, #2f80ed, #7c3aed);
}

/* ── Scope label: which slice of the KB is playing. ────────────────────────── */
.amb-scope { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.amb-scope-kind {
    font-size: clamp(10px, .78vw, 14px); font-weight: 700;
    letter-spacing: .14em; text-transform: uppercase;
    color: #7f93c4; border: 1px solid rgba(127,147,196,.34);
    padding: 2px 9px; border-radius: 999px;
}
.amb-scope-name {
    font-size: clamp(13px, 1.05vw, 20px); font-weight: 600; color: #b9c8ea;
}

/* ── The card ─────────────────────────────────────────────────────────────── */
.amb-card {
    flex: 1 1 auto;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    text-align: center;
    gap: clamp(12px, 1.6vw, 28px);
    min-height: 0;                    /* lets .amb-desc scroll instead of overflowing */
    transition: opacity .42s ease, transform .42s ease;
}
.amb-card.amb-fading { opacity: 0; transform: translateY(14px); }

.amb-term {
    margin: 0;
    font-size: clamp(30px, 5vw, 92px);
    font-weight: 700; line-height: 1.08; letter-spacing: -.012em;
    max-width: 22ch;
    background: linear-gradient(92deg, #ffffff 30%, #9fc2ff);
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
}

/* Justified, not centred: the explanation is a paragraph, and centred prose makes
   every line start at a different place — which is exactly the wrong thing to ask
   of an eye reading a few lines in passing from across a room. Hyphenation keeps
   justification from opening rivers between words at these large sizes. */
.amb-desc {
    /* --amb-scale is set by ambient.js's fit pass: 1 normally, stepped down when a
       long description would otherwise run off the bottom of the screen. */
    font-size: calc(clamp(16px, 1.85vw, 38px) * var(--amb-scale, 1));
    line-height: 1.55; color: #cdd8f2;
    /* Wide enough that a Layman or Short description lands whole on screen — the
       46ch reading column was right for a page and too narrow for a wall, where
       the cost of an extra line is a line nobody gets to read. */
    max-width: 64ch;
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto; -webkit-hyphens: auto;
    overflow-y: auto;                 /* a stray long one scrolls rather than clipping */
    scrollbar-width: none;
}
/* A justified block needs a fixed left edge to read as a column, so it takes the
   full width it is allowed rather than shrinking to its content. */
.amb-card > .amb-desc { width: 100%; }
.amb-desc::-webkit-scrollbar { display: none; }
.amb-desc p       { margin: 0 0 .6em; }
.amb-desc p:last-child { margin-bottom: 0; }
.amb-desc ul, .amb-desc ol { text-align: left; margin: .4em 0; padding-left: 1.4em; }
.amb-desc li      { margin: .18em 0; }
.amb-desc b, .amb-desc strong { color: #ffffff; font-weight: 600; }
.amb-desc i, .amb-desc em     { color: #e5ecff; }
.amb-desc a       { color: #8fb6ff; text-decoration: none; }
.amb-desc code    { font-size: .86em; background: rgba(255,255,255,.08); padding: .1em .35em; border-radius: 4px; }

/* Provenance: which topic this card came from — small, and a real link, so the
   display doubles as a pointer to the page when someone walks up to it. */
.amb-where { font-size: clamp(11px, .95vw, 17px); }
.amb-where a { color: #7f93c4; text-decoration: none; border-bottom: 1px solid rgba(127,147,196,.3); }
.amb-where a:hover { color: #b9c8ea; }

/* The register this card is playing — sits beside the provenance line, quiet
   enough to ignore from across a room, there when you look for it. */
.amb-reg {
    margin-left: 10px; padding: 1px 8px; border-radius: 999px;
    font-size: .82em; color: #8fa4d4;
    background: rgba(143,164,212,.12); border: 1px solid rgba(143,164,212,.22);
}
.amb-reg:empty { display: none; }

/* ── Viewer settings: which register, how fast, in what order. ─────────────── */
.amb-settings {
    display: flex; align-items: center; justify-content: center;
    gap: clamp(10px, 1.6vw, 28px); flex-wrap: wrap;
    margin-bottom: clamp(10px, 1.2vw, 20px);
    transition: opacity .45s ease;
}
/* Each setting is its own labelled cluster, so three rows of chips don't read as
   one long undifferentiated strip. */
.amb-set {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.amb-set-lbl {
    font-size: clamp(10px, .78vw, 14px); font-weight: 600;
    letter-spacing: .1em; text-transform: uppercase; color: #5f719c;
    margin-right: 2px;
}
.amb-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: clamp(3px, .35vw, 7px) clamp(10px, .9vw, 16px);
    font-size: clamp(11px, .95vw, 18px); line-height: 1.2;
    color: #b9c8ea; text-decoration: none;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.13); border-radius: 999px;
    transition: background .15s, border-color .15s, color .15s;
}
.amb-chip:hover  { background: rgba(255,255,255,.13); border-color: rgba(255,255,255,.28); color: #fff; }
.amb-chip.active { background: rgba(47,128,237,.24); border-color: #4f8fe8; color: #eaf2ff; }
.amb-chip-n { font-size: .8em; color: #7f93c4; }
.amb-chip.active .amb-chip-n { color: #b9d0f5; }
/* Not a control — where the sequence has got to. */
.amb-chip-page { background: none; border-style: dashed; color: #7f93c4; cursor: default; }

/* ── Controls: present when wanted, invisible when not. ────────────────────── */
.amb-controls {
    display: flex; align-items: center; justify-content: center; gap: clamp(8px, .9vw, 16px);
    transition: opacity .45s ease;
}
.amb-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: clamp(38px, 3.1vw, 58px); height: clamp(38px, 3.1vw, 58px);
    padding: 0 clamp(10px, .8vw, 16px);
    font-size: clamp(14px, 1.15vw, 22px); line-height: 1;
    color: #cdd8f2; text-decoration: none;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.14); border-radius: 999px;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, transform .12s;
}
.amb-btn:hover  { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); color: #fff; }
.amb-btn:active { transform: scale(.94); }
.amb-btn-exit   { font-size: clamp(12px, .95vw, 18px); font-weight: 600; letter-spacing: .02em; }

.amb-hint {
    display: flex; justify-content: center; gap: 18px; flex-wrap: wrap;
    margin-top: 10px; font-size: clamp(10px, .78vw, 14px); color: #5f719c;
    transition: opacity .45s ease;
}

/* Idle = nobody has moved the mouse or pressed a key for a few seconds. The
   card is all that remains — which is the point of the mode. */
.amb-idle .amb-controls,
.amb-idle .amb-hint,
.amb-idle .amb-settings,
.amb-idle .amb-scope { opacity: 0; pointer-events: none; }
.amb-idle { cursor: none; }

@media (max-width: 640px) {
    .amb-term { max-width: 100%; }
    .amb-desc { max-width: 100%; }
    .amb-hint { display: none; }      /* no keyboard to hint at */
}

/* Motion is the feature, so cards still advance — but the fade and the glide
   are decoration, and those go. */
@media (prefers-reduced-motion: reduce) {
    .amb-card { transition: none; }
    .amb-card.amb-fading { opacity: 1; transform: none; }
}
