/* Credential flow. Dark card, white text, indigo and cyan accents, rose only for "not stated" and "not established",
   amber only for "not reconciled". Two designs on one DOM: tall (the fixed 1060px frame used below 900px) is the base,
   wide (aspect ratio 5:4, a 2 by 2 grid in reading order) overrides it near the foot of this file. */
:root {
  --bg: #0b1726; --panel: #102039; --panel2: #16294a; --line: #2f4668; --line2: #4a6590;
  --mute: #b9c7dc;
  --indigo: #635bff; --indigo-t: #b3afff; --cyan: #06b6d4; --cyan-t: #3fd9f0; --rose: #fb7185; --amber: #fbbf24;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; font-size: 16px; }
body { margin: 0; background: var(--bg); color: #fff; font-family: var(--font); line-height: 1.35; min-height: 100vh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }
.lw { display: none; }
.lt { display: inline; }
.af { display: inline; }
.as { display: none; }

.stage { position: relative; display: flex; flex-direction: column; height: 100vh; padding: 0.6rem 0.7rem 0.5rem; gap: 0.4rem; max-width: 46rem; margin: 0 auto; }
.top { display: flex; flex-direction: column; gap: 0.4rem; }
h1 { margin: 0; font-size: 1.1rem; line-height: 1.2; font-weight: 700; }
.ctl { display: flex; gap: 0.5rem; }
.btn { min-height: 2.5rem; min-width: 5.5rem; padding: 0 1rem; border: 1px solid #5b7399; background: var(--panel2); border-radius: 0.5rem; font-size: 0.875rem; font-weight: 600; }
.btn:hover:not(:disabled) { border-color: #fff; }
.btn:disabled { color: #a8b6cc; border-color: var(--line); background: transparent; cursor: default; }
.btn[hidden] { display: none; }

/* ---------- step slider ---------- */
.scrub { display: grid; grid-template-columns: auto 1fr; column-gap: 0.7rem; align-items: center; flex: none; }
.scrub-l { font-size: 0.875rem; color: var(--mute); white-space: nowrap; }
.scrub input[type="range"] { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 2.2rem; margin: 0; background: transparent; cursor: pointer; }
.scrub input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: #3a5278; }
.scrub input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: #3a5278; }
.scrub input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%; background: #fff; border: 5px solid var(--indigo); }
.scrub input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 5px solid var(--indigo); }
.when { grid-column: 1 / span 2; margin: 0; font-size: 0.875rem; color: var(--mute); min-height: 1.35em; }

/* ---------- the flow: stages, arrows, the token ---------- */
.flow { flex: none; }
.grid { position: relative; display: flex; flex-direction: column; --g: 5.2rem; }
.lines { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.ln { position: absolute; display: none; border-radius: 2px; }
.ln.base { background: var(--line2); }
.ln.lit { background: var(--cyan); box-shadow: 0 0 8px rgba(6, 182, 212, 0.85); }
.ah { position: absolute; width: 0; height: 0; border: 0 solid transparent; }
.ah[data-dir="r"] { border-width: 7px 0 7px 7px; border-left-color: var(--line2); }
.ah[data-dir="l"] { border-width: 7px 7px 7px 0; border-right-color: var(--line2); }
.ah[data-dir="d"] { border-width: 7px 7px 0 7px; border-top-color: var(--line2); }
.ah[data-dir="u"] { border-width: 0 7px 7px 7px; border-bottom-color: var(--line2); }
.ah.lit { display: none; }
.ah.lit[data-dir="r"] { border-left-color: var(--cyan); }
.ah.lit[data-dir="l"] { border-right-color: var(--cyan); }
.ah.lit[data-dir="d"] { border-top-color: var(--cyan); }
.ah.lit[data-dir="u"] { border-bottom-color: var(--cyan); }
.token { position: absolute; left: 0; top: 0; z-index: 1; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.55), 0 0 14px 6px rgba(6, 182, 212, 0.8); opacity: 0; pointer-events: none; transition: opacity 0.3s; will-change: transform; }
.token.on { opacity: 1; }
.token.hop { transition: opacity 0.3s, transform 0.26s ease-in-out; }

.card { position: relative; z-index: 2; isolation: isolate; display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; padding: 0.45rem 0.6rem 0.5rem; border: 1px dashed var(--line2); border-radius: 0.6rem; background: #0d1a2d; transition: border-color 0.4s, box-shadow 0.4s; }
.card::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 0.6rem; background: var(--panel2); clip-path: inset(0 0 100% 0 round 0.6rem); transition: clip-path 0.55s cubic-bezier(0.3, 0.7, 0.2, 1); }
.card.lit { border-style: solid; border-color: var(--cyan); }
.card.lit::before { clip-path: inset(0 0 0 0 round 0.6rem); }
.card.now { box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.55), 0 0 18px rgba(6, 182, 212, 0.35); }
.stbtn { display: block; width: 100%; padding: 0; margin: 0; text-align: left; background: none; border: 0; color: inherit; border-radius: 0.4rem; }
.stbtn:hover .ttl, .stbtn.pin .ttl { text-decoration: underline; }
.hd { display: flex; align-items: center; gap: 0.5rem; }
.num { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 2px solid var(--line2); background: transparent; font-weight: 800; font-size: 0.9rem; color: var(--mute); transition: background-color 0.4s, border-color 0.4s, color 0.4s; }
.card.lit .num { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.ttl { font-weight: 700; font-size: 0.95rem; line-height: 1.2; color: var(--mute); transition: color 0.4s; }
.card.lit .ttl { color: #fff; }
.lead { display: block; margin-top: 0.3rem; font-size: 0.875rem; line-height: 1.3; color: #fff; }
.more { display: block; font-size: 0.875rem; line-height: 1.3; color: var(--mute); }
.card:not(.lit) .lead { display: none; }
.rv { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.4s ease; }
.rin { overflow: hidden; min-height: 0; visibility: hidden; transition: visibility 0s 0.4s; }
.card.open .rv { grid-template-rows: 1fr; }
.card.open .rin { visibility: visible; transition-delay: 0s; }
.notes { display: flex; flex-direction: column; gap: 0.3rem; }
.card:not(.lit) .notes { display: none; }
.notes .rv .rin { display: flex; flex-direction: column; gap: 0.3rem; }
.card.open .notes .rv .rin { padding-top: 0.1rem; }

.nt { display: block; width: 100%; text-align: left; padding: 0.3rem 0.5rem; border: 1px solid var(--line2); border-radius: 0.4rem; background: rgba(255, 255, 255, 0.04); font-size: 0.875rem; line-height: 1.3; color: #fff; }
.nt:hover, .nt.pin { box-shadow: 0 0 0 2px #fff; }
.nt .tg { font-weight: 700; }
.nt.stated { border-color: #1b8aa0; background: rgba(6, 182, 212, 0.1); }
.nt.stated .tg { color: var(--cyan-t); }
.nt.ns { --pc: rgba(251, 113, 133, 0.75); border-color: var(--rose); background: rgba(251, 113, 133, 0.1); }
.nt.ns .tg { color: var(--rose); }
.nt.rc { --pc: rgba(251, 191, 36, 0.75); border-color: var(--amber); border-style: dashed; background: rgba(251, 191, 36, 0.1); }
.nt.rc .tg { color: var(--amber); }
.nt.flag { display: none; }
.nt.flag.on { display: block; }
.nt.pulse { animation: pulse 1.1s ease-out 2; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--pc); } 75% { box-shadow: 0 0 0 0.7rem rgba(0, 0, 0, 0); } 100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); } }

.arw { position: relative; z-index: 3; display: block; width: 100%; padding: 0.2rem 0.4rem 0.2rem 3rem; min-height: 2.4rem; text-align: left; background: none; border: 0; color: var(--cyan-t); font-size: 0.875rem; line-height: 1.25; border-radius: 0.4rem; }
.arw:hover .al, .arw.pin .al { text-decoration: underline; color: #fff; }
.arw .al { display: block; }
.arw .as { display: none; }
.rccell, .rcline { display: none; }

/* ---------- tooltip: a sheet over the free edge of the frame in the tall design, floating in the wide one ---------- */
.dock { flex: none; }
.hint { margin: 0; padding: 0.4rem 0.7rem; font-size: 0.875rem; color: var(--mute); border: 1px dashed var(--line); border-radius: 0.5rem; }
.hint, .hint[hidden] { display: none; }
.tip { position: absolute; left: 0.5rem; right: 0.5rem; bottom: 0.5rem; z-index: 30; max-height: 58%; overflow: auto; padding: 0.5rem 0.8rem 0.6rem; background: #09111f; border: 1px solid #5b7399; border-left-width: 5px; border-radius: 0.5rem; font-size: 0.875rem; box-shadow: 0 0.6rem 1.6rem rgba(0, 0, 0, 0.6); pointer-events: none; }
.tip.pinned { pointer-events: auto; }
.tip[hidden] { display: none; }
.tip p { margin: 0; }
.tip[data-tone="stage"] { border-left-color: var(--indigo); }
.tip[data-tone="link"] { border-left-color: var(--cyan); }
.tip[data-tone="stated"], .tip[data-tone="plain"] { border-left-color: var(--cyan); }
.tip[data-tone="ns"] { border-left-color: var(--rose); }
.tip[data-tone="rc"] { border-left-color: var(--amber); }
.tk-kick { color: var(--mute); }
.tk-title { font-weight: 700; font-size: 1rem; margin-top: 0.1rem !important; }
.tk-plain { margin-top: 0.25rem !important; }
.vb { margin-top: 0.4rem; }
.vh { color: var(--cyan-t); font-weight: 700; }
.q { margin: 0.1rem 0 0; padding: 0 0 0 0.6rem; border-left: 2px solid #5b7399; font-style: italic; }
.vn { color: var(--mute); margin-top: 0.15rem !important; }
.tk-der { margin-top: 0.4rem !important; color: var(--cyan-t); font-weight: 600; }
.tk-mid { margin-top: 0.4rem !important; }
.tk-ns { margin-top: 0.4rem !important; color: var(--rose); font-weight: 600; }
.tk-close { display: none; margin-top: 0.5rem; min-height: 2.6rem; padding: 0 1.2rem; background: var(--panel2); border: 1px solid #5b7399; border-radius: 0.4rem; font-weight: 600; font-size: 0.875rem; pointer-events: auto; }
.tip.pinned .tk-close { display: inline-block; }
.src { margin: 0; flex: none; font-size: 0.875rem; color: var(--mute); }
.tipping .src { display: none; }

/* ---------- wide design: a 2 by 2 grid in reading order, 5:4 ---------- */
@media (min-aspect-ratio: 21/20) {
  .lw { display: inline; }
  .lt { display: none; }
  html { font-size: min(calc(100vw / 53), calc(100vh / 42.4)); }
  body { overflow: hidden; }
  .stage { max-width: calc(100vh * 1.25); padding: 0.5rem 1rem 0.35rem; gap: 0.3rem; }
  .top { flex-direction: row; align-items: center; justify-content: space-between; gap: 1rem; }
  h1 { font-size: 1.2rem; }
  .btn { min-height: 1.9rem; min-width: 4.6rem; padding: 0 0.8rem; font-size: 0.8rem; }
  .scrub { grid-template-columns: auto minmax(0, 20rem) 1fr; column-gap: 0.7rem; }
  .scrub-l { font-size: 0.8rem; }
  .scrub input[type="range"] { height: 1.6rem; }
  .scrub input[type="range"]::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -7px; border-width: 4px; }
  .when { grid-column: auto; font-size: 0.8rem; }

  .grid { display: grid; grid-template-columns: 1fr var(--g) 1fr; grid-template-rows: auto 2.2rem auto auto; grid-template-areas: "s1 a1 s2" "a2 a2 a2" "s3 a3 s4" "s3 rcl rc"; }
  .card { padding: 0.38rem 0.6rem 0.45rem; gap: 0.25rem; }
  .lead { margin-top: 0.2rem; }
  .nt { padding: 0.22rem 0.45rem; line-height: 1.28; }
  .notes, .notes .rv .rin { gap: 0.25rem; }
  .ttl { font-size: 0.92rem; }
  .lead, .more, .nt { font-size: 0.8rem; }
  .num { width: 1.5rem; height: 1.5rem; font-size: 0.85rem; }
  .card:not(.lit) .lead { display: block; visibility: hidden; }
  .rv { grid-template-rows: 1fr; transition: none; }
  .rin { visibility: visible; transition: none; }
  .card:not(.lit) .rv, .card:not(.lit) .notes { visibility: hidden; }
  .card:not(.lit) .notes { display: flex; }
  .lead, .rv, .notes { transition: opacity 0.45s 0.25s; }
  .card:not(.lit) .lead, .card:not(.lit) .rv, .card:not(.lit) .notes { opacity: 0; }
  .nt.flag { display: block; visibility: hidden; opacity: 0; transition: opacity 0.4s; }
  .nt.flag.on { visibility: visible; opacity: 1; }
  .arw { padding: 0; min-height: 0; text-align: center; font-size: 0.78rem; border-radius: 0.3rem; }
  .arw.gutter { align-self: stretch; height: auto; }
  .arw.gutter .al { position: absolute; left: 0.15rem; right: 0.15rem; top: 1.75rem; }
  .arw.gutter .af { display: none; }
  .arw.gutter .as { display: block; }
  .arw.wrap { margin: 0 calc((100% - var(--g)) / 4); width: auto; display: flex; align-items: center; justify-content: center; }
  .arw.wrap .al { padding: 0.05rem 0.6rem; background: var(--bg); position: relative; z-index: 4; }
  .arw.wrap .as { display: none; }
  .rccell { display: block; grid-area: rc; margin-top: 0.5rem; align-self: start; }
  .rcline { display: block; grid-area: rcl; align-self: start; margin-top: 1.5rem; border-top: 2px dashed var(--amber); opacity: 0; transition: opacity 0.4s; }
  .grid.rc-on .rcline { opacity: 1; }
  .rccell .nt.rc { padding: 0.4rem 0.55rem; }

  .dock { position: static; height: 0; }
  .hint { display: none; }
  .tip { right: auto; bottom: auto; width: 24rem; max-width: calc(100% - 1rem); max-height: calc(100% - 1rem); font-size: 0.8rem; padding: 0.5rem 0.7rem; }
  .tip.xl { width: 28rem; }
  .tk-title { font-size: 0.9rem; }
  .tk-close { margin-top: 0.4rem; min-height: 1.9rem; font-size: 0.8rem; }
  .src, .tipping .src { display: block; font-size: 0.76rem; }
}


/* Phones (a 375px phone shows this frame about 341px wide): a little less air between and inside the cards, so the tallest stage fits
   the 1060px frame. Text sizes stay as they are. */
@media (max-width: 420px) {
  .stage { gap: 0.3rem; padding-top: 0.5rem; padding-bottom: 0.4rem; }
  .card { gap: 0.2rem; padding: 0.4rem 0.55rem 0.42rem; }
  .arw { min-height: 2rem; padding-top: 0.1rem; padding-bottom: 0.1rem; }
  .notes, .notes .rv .rin { gap: 0.22rem; }
  .nt { padding: 0.24rem 0.45rem; line-height: 1.26; }
  .hint { padding: 0.3rem 0.6rem; }
}

/* Very narrow screens (320px): the title and the step readout move out of sight, still read aloud, so the four stages fit the 1060px frame. */
@media (max-width: 359px) {
  h1, .when { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .stage { padding: 0.45rem 0.6rem 0.4rem; gap: 0.3rem; }
  .card { padding: 0.4rem 0.5rem 0.45rem; }
  .arw { padding: 0.1rem 0.3rem 0.1rem 2.7rem; min-height: 2.1rem; }
}

/* Narrower still (a 320px phone shows this frame about 286px wide): the arrows carry their short labels, the full ones stay in the tooltips. */
@media (max-width: 300px) {
  .arw .af { display: none; }
  .arw .as { display: block; }
  .stage { padding-left: 0.5rem; padding-right: 0.5rem; }
}

/* Without script the plain ordered list shows as text, in order. A module script runs a moment after first paint, so the list
   waits 1.4 seconds before it shows: a reader with script never sees it flash, a reader without script still gets it. */
html:not(.js) .flow { opacity: 0; animation: nojs 0.01s 1.4s forwards; }
@keyframes nojs { to { opacity: 1; } }
html:not(.js) body { overflow: auto; }
html:not(.js) .stage { height: auto; min-height: 100vh; }
html:not(.js) .stages { list-style: decimal; padding-left: 1.3rem; margin: 0.6rem 0; font-size: 0.95rem; }
html:not(.js) .stages li { margin: 0 0 0.7rem; }
html:not(.js) .stages ul { list-style: disc; padding-left: 1.1rem; margin: 0.3rem 0 0; }
html:not(.js) .stages ul li { margin: 0 0 0.3rem; }
html:not(.js) .scrub, html:not(.js) .dock, html:not(.js) .ctl { display: none; }
.notrec { margin: 0.4rem 0; padding: 0.4rem 0.6rem; border: 1px dashed var(--amber); border-radius: 0.4rem; font-size: 0.95rem; }
html.js .notrec { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
.frozen *, .frozen *::before, .frozen *::after { transition: none !important; animation: none !important; }
