/* CAD & MDT page only. Shared components are in assets/site.css. */

/* ---------- MDT-style terminal (the real Priors MDT's light theme, the same in both site themes) ---------- */
.term {
  --m-bg: #f6f4ee; --m-panel: #ffffff; --m-line: #d4d6cc; --m-head: #e9ece4; --m-fg: #17231c; --m-muted: #5d6b61;
  --m-green: #1b6b43; --m-green-ink: #155a37; --m-clay: #a8401c; --m-red: #b3261e;
  background: var(--m-bg); color: var(--m-fg);
  border: 1px solid var(--m-line); border-radius: 6px;
  font-family: var(--font-mono); font-size: .84rem; line-height: 1.5;
  box-shadow: 0 30px 60px -30px rgba(0,0,0,.45), 0 0 0 6px color-mix(in srgb, var(--m-line) 55%, transparent);
  overflow: hidden; min-width: 0;
}
:root[data-theme="dark"] .term { box-shadow: 0 30px 60px -30px rgba(0,0,0,.8), 0 0 0 6px #22302a; }
.term-bar { display: flex; align-items: stretch; min-height: 32px; background: var(--m-panel); border-bottom: 1px solid var(--m-line); font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; overflow: hidden; }
.term-bar > span { display: flex; align-items: center; padding: 0 .7rem; border-right: 1px solid var(--m-line); white-space: nowrap; color: var(--m-green-ink); }
.term-bar .term-brand { background: var(--m-green); color: #fff; letter-spacing: .12em; border-right: 0; }
.term-bar .term-sp { flex: 1; border-right: 0; padding: 0; }
.term-bar > span:last-child { border-right: 0; }
@media (max-width: 560px) { .term-bar .term-hide, .loop-term .term-bar > span:nth-child(2) { display: none; } }
.term-btn {
  font: 700 .74rem var(--font-mono); letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
  background: var(--m-panel); color: var(--m-fg); border: 1px solid var(--m-line); border-radius: 2px; padding: .55rem .8rem; min-height: 40px;
}
.term-btn:hover { background: #f1efe8; border-color: #b9bdb2; }
.term-btn.solid { background: var(--m-clay); border-color: var(--m-clay); color: #fff; }
.term-btn.solid:hover { background: #923716; }
.term :focus-visible { outline: 2px solid var(--m-green); outline-offset: 2px; }

/* ---------- How it fits: the flow map ---------- */
.flowmap { display: grid; grid-template-columns: minmax(0, 1fr) 8rem minmax(0, 1.25fr) 8rem minmax(0, 1fr); align-items: center; gap: .5rem; }
.fm-node { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.1rem 1.2rem; display: grid; gap: .55rem; align-content: start; min-width: 0; }
.fm-node h3 { font-size: 1.35rem; }
.fm-node p { color: var(--muted); font-size: .9rem; }
.fm-node .status { justify-self: start; }
.fm-game { border-style: dashed; }
.fm-core { border: 2px solid var(--sign); box-shadow: 0 18px 40px -28px rgba(0,0,0,.5); }
.fm-seats { display: grid; gap: .75rem; min-width: 0; }
.fm-api { list-style: none; margin: .2rem 0 0; padding: .6rem .7rem; display: grid; gap: .2rem; background: var(--term-bg); border-radius: 4px; }
.fm-api code { font: .74rem/1.45 var(--font-mono); color: #d6e2d8; overflow-wrap: anywhere; }
.fm-link { display: grid; justify-items: center; gap: .3rem; text-align: center; color: var(--muted); min-width: 0; }
.fm-link svg { width: 100%; max-width: 7rem; height: auto; fill: none; stroke: var(--clay); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.fm-link span { font: 600 .68rem/1.35 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }
.fm-note { margin-top: 1.25rem; max-width: 70ch; }
@media (max-width: 1000px) {
  .flowmap { grid-template-columns: minmax(0, 1fr); gap: .25rem; }
  .fm-link { grid-template-columns: auto auto; justify-content: center; align-items: center; gap: .6rem; padding: .35rem 0; }
  .fm-link svg { width: 2.4rem; transform: rotate(90deg); }
  .fm-seats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
}

/* ---------- The priors loop ---------- */
.loop { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr); gap: clamp(1.25rem, 3vw, 2.5rem); align-items: start; }
.loop-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; position: relative; }
.loop-steps::before { content: ""; position: absolute; left: 1.05rem; top: 1.4rem; bottom: 1.4rem; width: 2px; background: var(--line); }
.loop-steps button {
  position: relative; width: 100%; text-align: left; cursor: pointer; display: grid; grid-template-columns: 2.1rem minmax(0, 1fr); column-gap: .9rem; row-gap: .15rem;
  background: transparent; border: 1px solid transparent; border-radius: 8px; padding: .75rem .9rem .75rem 0; color: var(--fg); font: inherit;
}
.loop-steps button::before {
  content: ""; grid-row: 1 / span 3; justify-self: center; margin-top: .3rem; width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg-2, var(--bg)); border: 2px solid var(--muted); position: relative; z-index: 1;
}
.loop-steps button:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.loop-steps button[aria-selected="true"] { background: var(--surface); border-color: var(--line); box-shadow: 0 12px 30px -24px rgba(0,0,0,.5); }
.loop-steps button[aria-selected="true"]::before { background: var(--clay); border-color: var(--clay); }
.loop-steps button.past::before { background: var(--muted); }
.loop-steps .d { font: 600 .74rem var(--font-mono); color: var(--clay); letter-spacing: .08em; }
.loop-steps b { font: 800 1.2rem/1.1 var(--font-display); text-transform: uppercase; letter-spacing: .01em; }
.loop-steps .s { color: var(--muted); font-size: .88rem; }
.loop-term { position: sticky; top: calc(var(--header-h) + 1rem); }
.term-body { padding: .85rem; display: grid; min-height: 24rem; align-content: start; }
.term-body [role="tabpanel"] { display: grid; gap: .7rem; }
.term-body [role="tabpanel"] + [role="tabpanel"] { margin-top: 1rem; }
.js .term-body [role="tabpanel"] + [role="tabpanel"] { margin-top: 0; }
.term-body [role="tabpanel"]:focus-visible { outline: 2px solid var(--m-green); outline-offset: 3px; }
.ret { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 600 .78rem/1.5 var(--font-mono); color: var(--m-green-ink); background: var(--m-panel); border: 1px solid var(--m-line); padding: .6rem .75rem; }
.ret mark { background: #fbf1d8; color: inherit; padding: .05rem .2rem; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.ret.hit { border-color: var(--m-red); }
.ret mark.top { background: #fdecea; color: var(--m-red); }
.loop-cap { margin: 0; font: 500 .82rem/1.5 var(--font-body); color: var(--m-fg); }
.term-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: 0 .85rem .85rem; flex-wrap: wrap; }
.loop-note { margin-top: 1.2rem; max-width: 75ch; }
@media (max-width: 900px) {
  .loop { grid-template-columns: minmax(0, 1fr); }
  .loop-term { position: static; }
  .term-body { min-height: 0; }
}
@media (max-width: 900px) {
  /* steps become a compact row of numbered chips on small screens */
  .js .loop-steps { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: .3rem; }
  .js .loop-steps::before { left: 1rem; right: 1rem; top: 1.15rem; bottom: auto; width: auto; height: 2px; }
  .js .loop-steps button { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; padding: .5rem .2rem; row-gap: .3rem; }
  .js .loop-steps button::before { grid-row: auto; margin-top: 0; }
  .js .loop-steps b, .js .loop-steps .s { display: none; }
  .js .loop-steps .d { font-size: .7rem; }
  .js .loop-term .term-bar > span:nth-child(2) { display: none; }
}
.loop-now { display: none; }
@media (max-width: 900px) {
  .js .loop-now { display: grid; gap: .2rem; margin-top: .9rem; }
  .loop-now b { font: 800 1.25rem/1.1 var(--font-display); text-transform: uppercase; }
  .loop-now span { color: var(--muted); font-size: .9rem; }
}

.priors-card { margin-top: clamp(2.5rem, 6vw, 4rem); display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 2rem; align-items: center; }
@media (max-width: 900px) { .priors-card { grid-template-columns: minmax(0, 1fr); } }
.priors-copy { display: grid; gap: 1rem; min-width: 0; }
.priors-copy p { color: var(--muted); }

/* ---------- Console ---------- */
.wide-shot { margin-bottom: 2rem; }
.wide-shot figcaption { max-width: 80ch; }
.console-cards .card h3 { font-size: 1.25rem; }
.console-cards .ticks { font-size: .9rem; }
.keys-row { margin-top: 1.5rem; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 1.5rem; align-items: start; }
@media (max-width: 860px) { .keys-row { grid-template-columns: minmax(0, 1fr); } }
.keys { display: grid; gap: .6rem; min-width: 0; }
.keymap { margin: 0; display: grid; gap: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); overflow: hidden; }
.keymap > div { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: .8rem; align-items: center; padding: .5rem .8rem; border-top: 1px solid var(--line); }
.keymap > div:first-child { border-top: 0; }
.keymap dt { white-space: nowrap; }
.keymap dd { margin: 0; font-size: .92rem; }
.cmdline { background: var(--term-bg); color: #d6e2d8; border-radius: 6px; padding: .8rem 1rem; font: .8rem/1.75 var(--font-mono); overflow-x: auto; margin: 0; white-space: pre; border: 1px solid var(--line); max-width: 100%; }
.cmdline .k { color: #ffcf7a; } .cmdline .c { color: #8fa496; }
.cmdline:focus-visible { outline: 2px solid var(--clay); outline-offset: 2px; }

/* ---------- MDT screens explorer ---------- */
.screens { margin-bottom: 1.5rem; }
.screens-grid { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); }
.status-keys { list-style: none; margin: 0; padding: .6rem; display: grid; gap: .4rem; align-content: start; border-right: 1px solid var(--m-line); background: var(--m-bg); }
.status-keys li { background: var(--m-panel); border: 1px solid var(--m-line); border-radius: 3px; padding: .35rem .55rem; font-weight: 700; font-size: .74rem; letter-spacing: .05em; text-transform: uppercase; display: grid; }
.status-keys kbd { font: 600 .68rem var(--font-mono); color: var(--m-green-ink); background: none; border: 0; padding: 0; box-shadow: none; }
.status-keys small { font-weight: 500; color: var(--m-muted); text-transform: none; letter-spacing: 0; }
.screens-main { display: grid; grid-template-rows: auto 1fr; min-width: 0; }
.screen-tabs { display: flex; flex-wrap: wrap; background: var(--m-head); border-bottom: 1px solid var(--m-line); }
.screen-tabs button {
  font: 700 .72rem var(--font-mono); letter-spacing: .06em; text-transform: uppercase; cursor: pointer; white-space: nowrap;
  background: transparent; color: var(--m-muted); border: 0; border-right: 1px solid var(--m-line); border-bottom: 1px solid var(--m-line); margin-bottom: -1px;
  padding: .6rem .75rem; min-height: 40px;
}
.screen-tabs button:hover { color: var(--m-fg); background: #f1efe8; }
.screen-tabs button[aria-selected="true"] { background: var(--m-bg); color: var(--m-green-ink); box-shadow: inset 0 3px 0 var(--m-green); border-bottom-color: var(--m-bg); }
.screen-tabs button:focus-visible { outline: 2px solid var(--m-green); outline-offset: -3px; }
.screen { padding: 1.1rem 1.2rem 1.3rem; display: grid; gap: .5rem; align-content: start; }
.screen + .screen { border-top: 1px dashed var(--m-line); }
.js .screen + .screen { border-top: 0; }
.screen h3 { font: 800 1.5rem/1.1 var(--font-display); text-transform: uppercase; color: var(--m-fg); }
.screen p { font: 400 .95rem/1.55 var(--font-body); color: var(--m-fg); max-width: 62ch; }
.screen a { color: var(--m-clay); font-weight: 600; }
.screen:focus-visible { outline: 2px solid var(--m-green); outline-offset: -4px; }
@media (max-width: 640px) {
  .screens-grid { grid-template-columns: minmax(0, 1fr); }
  .status-keys { grid-template-columns: repeat(3, minmax(0, 1fr)); border-right: 0; border-bottom: 1px solid var(--m-line); }
  .status-keys small { display: none; }
  .screen-tabs button { flex: 1 1 auto; }
}
.mdt-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); gap: clamp(1.25rem, 3vw, 2rem); align-items: start; }
@media (max-width: 960px) { .mdt-row { grid-template-columns: minmax(0, 1fr); } }
.safety { display: grid; gap: .9rem; min-width: 0; }
@media (max-width: 960px) and (min-width: 700px) { .safety { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.safety .card { padding: 1.1rem 1.2rem; gap: .5rem; }
.safety .card h3 { font-size: 1.3rem; }
.safety .card p { font-size: .9rem; }
.pill-key { font: 600 .68rem/1 var(--font-mono); letter-spacing: .08em; padding: .35rem .5rem; border-radius: 3px; background: var(--term-bg); color: #ffcf7a; white-space: nowrap; }

/* ---------- Citations ---------- */
.tour-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 3rem); align-items: start; }
@media (max-width: 900px) { .tour-row { grid-template-columns: minmax(0, 1fr); } }
.tour-copy { display: grid; gap: 1rem; align-content: start; min-width: 0; }
.tour-copy > p { color: var(--muted); }
.tour-copy h2 { font-size: clamp(2rem, 4.5vw, 3rem); }
.ticket-shot { max-width: 460px; justify-self: center; width: 100%; }
.ticket-or-arrest { margin-top: clamp(2.5rem, 6vw, 3.5rem); display: grid; gap: 1rem; }
.ticket-or-arrest h3 { font-size: 1.6rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); max-width: 100%; }
.table-wrap:focus-visible { outline: 2px solid var(--clay); outline-offset: 2px; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table-wrap th, .table-wrap td { text-align: left; vertical-align: top; padding: .8rem 1rem; border-top: 1px solid var(--line); }
.table-wrap thead th { border-top: 0; font: 600 .72rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); background: color-mix(in srgb, var(--line) 30%, transparent); }
.table-wrap tbody th { font-weight: 600; }
.toa { min-width: 640px; }
.toa tbody th { white-space: nowrap; }
.cls { display: inline-block; font: 700 .68rem/1 var(--font-mono); letter-spacing: .06em; padding: .3rem .4rem; border-radius: 3px; margin-right: .45rem; vertical-align: .1em; }
.cls.inf { background: color-mix(in srgb, var(--sign) 14%, transparent); color: var(--st-working); }
.cls.misd { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.cls.fel { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }
.yes, .no { font-weight: 700; }
.yes { color: var(--ok); } .no { color: var(--bad); }

/* ---------- Records ---------- */
.cards.records { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1000px) { .cards.records { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .cards.records { grid-template-columns: minmax(0, 1fr); } }
.records .card { border-top: 4px solid var(--sign); }
.recno { font: 600 .78rem var(--font-mono); letter-spacing: .06em; color: var(--fg); background: color-mix(in srgb, var(--line) 45%, transparent); padding: .3rem .5rem; border-radius: 3px; }
.records .card h3 { font-size: 1.3rem; }

/* ---------- Into the game ---------- */
.compare { min-width: 680px; }
.compare tbody th { width: 11rem; }
.compare td:nth-child(2) { color: var(--muted); width: 38%; }
.compare td .status { margin-left: .35rem; vertical-align: .05em; white-space: nowrap; }
.milestones { margin-top: 2rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 900px) { .milestones { grid-template-columns: minmax(0, 1fr); } }
.ms { display: grid; gap: .55rem; align-content: start; padding: 1.2rem 1.3rem; border-left: 3px solid var(--sign); background: var(--surface); border-radius: 0 8px 8px 0; min-width: 0; }
.ms h3 { font-size: 1.35rem; }
.ms p:not(.sub-label) { color: var(--muted); font-size: .93rem; }
.ms-q { border-left-color: var(--clay); background: color-mix(in srgb, var(--clay) 7%, var(--surface)); }

/* Tables stack into labelled rows on phones */
@media (max-width: 680px) {
  .table-wrap { overflow: visible; }
  .toa, .compare { min-width: 0; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap th, .table-wrap td { display: block; width: auto !important; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .table-wrap tr { padding: .9rem 1rem; border-top: 1px solid var(--line); }
  .table-wrap tbody tr:first-child { border-top: 0; }
  .table-wrap th, .table-wrap td { border: 0; padding: .15rem 0; }
  .table-wrap tbody th { white-space: normal; font-size: 1rem; margin-bottom: .3rem; }
  .table-wrap td[data-label]::before { content: attr(data-label) ": "; font: 600 .7rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .compare td:nth-child(2) { color: var(--muted); }
  .compare td .status { margin: .3rem 0 0; display: inline-flex; }
}

/* Card labels in "The CAD is one part of Priors" */
@media (max-width: 480px) { .ret { font-size: .68rem; padding: .55rem .6rem; } .term-body { padding: .6rem; } }

/* "Try it in the playground" card in Beyond the badge */
.cad-play { border-top: 3px solid var(--st-working); background: color-mix(in srgb, var(--st-working) 6%, var(--bg)) !important; }
