/* The demo's 3D view of the desk diff. Palette from ../demo.css; the diff colours are the tints
   pipeline/diff.py bakes into diff.ply (as in ../../style.css), so the legend matches the splats. */

:root {
  color-scheme: dark;
  --bg: #141211;
  --panel: #1c1816;
  --well: #0a0808;
  --line: #3c302c;
  --soft: #c5b5ad;
  --faint: #8d7d76;
  --text: #fff6ed;
  --ember: #ff936f;
  --ember-soft: #392821;
  --ember-line: #775146;
  --removed: #ff1f33;
  --added: #1aff4d;
  --unfilmed: #8c8c8c;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --glass: #1c1816e6;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  background: var(--bg);
  font: 15px/1.55 var(--sans);
}

[hidden] { display: none !important; }
a { color: inherit; text-underline-offset: 4px; }
a:hover { color: var(--ember); }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; }
code { font: 13px var(--mono); }
kbd {
  display: inline-block;
  min-width: 1.6em;
  margin: 0 1px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  font: 11px/1.6 var(--mono);
  text-align: center;
  color: var(--text);
  background: var(--bg);
}

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

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 0 clamp(16px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.bar a { text-decoration: none; }
.wordmark { display: inline-flex; align-items: center; gap: 4px; font-size: 19px; font-weight: 750; letter-spacing: -.04em; }
.mark { display: block; flex: none; width: 26px; height: 26px; }
.back { color: var(--soft); font-size: 14px; }

/* --- layout -------------------------------------------------------------------------------- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(320px, 28vw, 390px);
  min-height: 0;
}
@media (min-width: 821px) {
  body { height: 100vh; height: 100dvh; overflow: hidden; }
}

/* --- stage --------------------------------------------------------------------------------- */

.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--well); }
.canvas-host, .canvas-host > div { position: absolute; inset: 0; }
.canvas-host canvas { display: block; touch-action: none; }

.modes {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 3;
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--glass);
  backdrop-filter: blur(6px);
}
.modes button {
  min-width: 74px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--soft);
  background: none;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.modes button:hover { color: var(--text); }
.modes button[aria-pressed="true"] { color: var(--text); background: var(--ember-soft); border-color: var(--ember-line); font-weight: 650; }
.modes button:disabled { cursor: default; opacity: .5; }

.caption {
  position: absolute;
  top: 62px;
  left: 14px;
  z-index: 2;
  max-width: calc(100% - 28px);
  margin: 0;
  padding: 4px 9px;
  border-radius: 5px;
  font: 12px/1.4 var(--mono);
  color: var(--soft);
  background: #1c1816b3;
}

.status, .notice {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: min(360px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--glass);
  backdrop-filter: blur(6px);
}
.status p, .notice p { margin: 0; }
.status p { font-size: 14px; color: var(--soft); font-variant-numeric: tabular-nums; }
.progress { position: relative; height: 4px; margin-top: 12px; overflow: hidden; border-radius: 2px; background: var(--line); }
.progress span { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--ember); transition: width .2s ease-out; }
.progress.busy span { width: 35%; animation: busy 1.1s ease-in-out infinite; }
@keyframes busy { from { left: -35%; } to { left: 100%; } }
.status.done { opacity: 0; visibility: hidden; transition: opacity .35s, visibility 0s .35s; }

.notice { border-color: #775146; }
.notice p { line-height: 1.5; }
.notice-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.notice-actions:empty { display: none; }
.notice-actions a, .notice-actions button {
  padding: 6px 12px;
  border: 1px solid var(--ember-line);
  border-radius: 6px;
  color: var(--text);
  background: var(--ember-soft);
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 2;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--soft);
  background: #1c1816b3;
  text-align: center;
  pointer-events: none;
}
.hint-touch { display: none; }
@media (pointer: coarse) {
  .hint-fine { display: none; }
  .hint-touch { display: inline; }
}

/* --- panel --------------------------------------------------------------------------------- */

.panel {
  min-width: 0;
  overflow-y: auto;
  padding: 22px clamp(18px, 2vw, 26px) 30px;
  border-left: 1px solid var(--line);
  background: var(--panel);
}
.panel section { padding: 18px 0; border-top: 1px solid var(--line); }
.panel h2 { margin: 0 0 10px; font-size: 15px; font-weight: 650; }
.note { margin: 8px 0 0; font-size: 13px; color: var(--faint); }
.note code { font-size: 12px; }

.intro { padding-bottom: 18px; }
.eyebrow { margin: 0 0 6px; font: 12px/1.4 var(--mono); color: var(--ember); text-transform: uppercase; letter-spacing: .06em; }
.intro h1 { margin: 0; font-size: clamp(26px, 2.4vw, 32px); line-height: 1.1; letter-spacing: -.035em; font-weight: 740; }
.lede { margin: 10px 0 0; color: var(--soft); }
.runline { margin: 10px 0 0; color: var(--soft); }

.sw { flex: none; display: inline-block; width: 14px; height: 14px; border-radius: 3px; }
.sw.removed { background: var(--removed); }
.sw.added { background: var(--added); }
.sw.unfilmed { background: var(--unfilmed); }
.sw.rest { background: linear-gradient(135deg, #6f4b3a, #c9a27e 55%, #3d5d7a); }
.sw.missed-sw { border: 1px dashed var(--soft); background: none; }

.legend { display: grid; gap: 10px; margin: 0; }
.legend div { display: grid; grid-template-columns: 14px minmax(0, 1fr); column-gap: 10px; }
.legend dt { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; font-weight: 650; }
.legend dd { grid-column: 2; margin: 0; color: var(--soft); font-size: 14px; }

.regions { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.regions button {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  row-gap: 2px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--bg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.regions button:hover { border-color: var(--ember-line); }
.regions button[aria-current="true"] { border-color: var(--ember); background: var(--ember-soft); }
.region-name { font-weight: 650; }
.region-kind { font: 11px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .05em; }
.region-kind.removed { color: #ff8b93; }
.region-kind.added { color: #7be897; }
.region-meta { grid-column: 2 / -1; font-size: 13px; color: var(--soft); }
.missed { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0 0; padding: 9px 11px; border: 1px dashed var(--line); border-radius: 8px; font-size: 14px; color: var(--soft); }
.missed .sw { margin-top: 4px; }

.viewpoints { display: flex; flex-wrap: wrap; gap: 6px; }
.viewpoints button {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--soft);
  background: var(--bg);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.viewpoints button:hover { color: var(--text); border-color: var(--ember-line); }

.caveats { margin: 0; padding-left: 18px; color: var(--soft); font-size: 14px; }
.caveats li + li { margin-top: 6px; }

.provenance { display: grid; gap: 4px; margin: 0; font-size: 14px; }
.provenance div { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 8px; }
.provenance dt { color: var(--faint); }
.provenance dd { margin: 0; color: var(--soft); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.keys { display: grid; gap: 6px; margin: 0; font-size: 14px; }
.keys div { display: grid; grid-template-columns: minmax(7.5em, auto) minmax(0, 1fr); gap: 10px; align-items: baseline; }
.keys dt { color: var(--soft); }
.keys dd { margin: 0; color: var(--faint); }

.back-foot { margin: 6px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; color: var(--soft); }
.noscript { margin: 16px; color: var(--soft); }

/* --- narrow screens: the view on top, the panel below it ---------------------------------- */

@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .stage { height: min(68svh, 600px); min-height: 320px; }
  .panel { overflow: visible; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 465px) {
  .back { font-size: 13px; }
  .modes { top: 10px; left: 10px; right: 10px; }
  .modes button { flex: 1; min-width: 0; }
  .caption { top: 58px; left: 10px; }
  .hint { font-size: 12px; }
  .keys-section { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .progress.busy span { animation: none; width: 100%; opacity: .5; }
  .status.done { transition: none; }
}
