/* ───────────────────────────────────────────────────────────────────────────
   asmade platform shell
   Tiers 1–2 are "paper" (client surface, carried from construction-overview).
   Tier 3 inverts to the "instrument" shell — the change of ground is the signal
   that you have moved from managing the job to inspecting it.

   Status colour is a traffic light driven by one threshold table in app.js:
     ok   >= -2   green     warn  -3..-9  orange     late <= -10  red
   LIVE yellow is kept out of the gauge so the two meanings never collide.
   ─────────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600&display=swap');

:root {
  --paper: #f4f4f1;
  --panel: #ffffff;
  --ink: #17201d;
  --muted: #6b7269;
  --faint: #9aa096;
  --line: #e4e4df;
  --live: #e8b84a;

  --ok: #2f7d53;
  --warn: #dd7a1b;
  --late: #d5432f;

  --instrument: #0a1a1a;
  --ink-dark: #e6efe9;
  --muted-dark: #7e938e;

  --head-h: 52px;
  --gauge-w: 232px;
  --sans: 'Archivo', -apple-system, 'Segoe UI', system-ui, Roboto, Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

.is-ok { --st: var(--ok); }
.is-warn { --st: var(--warn); }
.is-late { --st: var(--late); }

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}

button, input { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
a { color: inherit; }
*:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 3px; }
body.tier-3 *:focus-visible { outline-color: var(--ink-dark); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── chrome: one line, the breadcrumb is the whole navigation model ───────── */

#chrome {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--head-h);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
  transition: background .35s var(--ease), border-color .35s var(--ease), color .35s var(--ease);
}

body.tier-3 #chrome {
  background: color-mix(in srgb, var(--instrument) 82%, transparent);
  border-bottom-color: #22312f;
  color: var(--ink-dark);
}

#mark { font-weight: 600; letter-spacing: -.02em; flex: none; }
#mark .dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--live);
  margin-right: 7px;
  vertical-align: 1px;
}

#crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1; }
#crumbs .sep { color: var(--faint); flex: none; }
body.tier-3 #crumbs .sep { color: var(--muted-dark); }

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.crumb:hover { background: rgba(23, 32, 29, .06); color: var(--ink); }
.crumb[aria-current] { color: var(--ink); font-weight: 500; cursor: default; }
.crumb[aria-current]:hover { background: none; }
.crumb .caret { font-size: 10px; color: var(--faint); }
body.tier-3 .crumb { color: var(--muted-dark); }
body.tier-3 .crumb:hover { background: rgba(230, 239, 233, .09); color: var(--ink-dark); }
body.tier-3 .crumb[aria-current] { color: var(--ink-dark); }

#chrome-meta {
  flex: none;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
}
body.tier-3 #chrome-meta { color: var(--muted-dark); }

.pill {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--st);
  background: color-mix(in srgb, var(--st) 13%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--st) 26%, transparent) inset;
}
body.tier-3 .pill { background: color-mix(in srgb, var(--st) 22%, transparent); color: #fff; }

.live-tag { display: inline-flex; align-items: center; gap: 6px; }
.live-tag i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 2.6s var(--ease) infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }

/* site switcher */
.menu {
  position: fixed;
  z-index: 60;
  min-width: 290px;
  padding: 5px;
  border-radius: 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 14px 44px rgba(23, 32, 29, .2);
}
.menu .item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 7px;
  border-radius: 8px;
  text-align: left;
  transition: background .12s linear;
}
.menu .item:hover { background: rgba(23, 32, 29, .05); }
.menu .item[aria-current] { background: rgba(23, 32, 29, .07); }
.menu .item img { width: 50px; height: 34px; border-radius: 4px; object-fit: cover; flex: none; }
.menu .item .col { flex: 1; min-width: 0; }
.menu .item .nm { display: block; font-size: 14px; font-weight: 500; }
.menu .item .mt { display: block; font-size: 12px; color: var(--muted); }
.menu .item .pc { font-weight: 500; color: var(--st); }

/* ── stage ────────────────────────────────────────────────────────────────── */

#stage { position: fixed; inset: var(--head-h) 0 0 0; }

/* ── tier 1: portfolio ────────────────────────────────────────────────────── */

#portfolio { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; }
#portfolio[hidden] { display: none; }

.wrap { max-width: 1060px; margin: 0 auto; padding: 52px 24px 96px; }

.lede {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -.028em;
  line-height: 1.15;
  margin: 0 0 8px;
  max-width: 22ch;
}

.sub-lede { color: var(--muted); margin: 0 0 42px; max-width: 60ch; }

.axis-key {
  display: flex;
  align-items: baseline;
  color: var(--faint);
  font-size: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.axis-key .grow { flex: 1; }
.axis-key .g { width: var(--gauge-w); flex: none; }
.axis-key .pc { width: 52px; text-align: right; flex: none; }
.axis-key .vr { width: 52px; text-align: right; flex: none; }

.row {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  text-align: left;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
  transition: background .12s linear;
}
.row:hover { background: rgba(23, 32, 29, .035); }
.row:active { background: rgba(23, 32, 29, .06); }

.row .thumb {
  width: 104px; height: 68px;
  flex: none;
  border-radius: 5px;
  object-fit: cover;
  background: #dcdcd6;
  box-shadow: 0 0 0 1px rgba(23, 32, 29, .09) inset;
}

.row .id { flex: 1; min-width: 0; }
.row .nm {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.012em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row .mt {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row .mt .issues { color: var(--late); }

/* the gauge — one shared x-axis across every row, status in the fill,
   the shortfall drawn as the gap between built and the plan tick */
.gauge { width: var(--gauge-w); flex: none; position: relative; height: 22px; }
.gauge .track { position: absolute; left: 0; right: 0; top: 10px; height: 2px; background: var(--line); }
.gauge .done { position: absolute; left: 0; top: 7px; height: 8px; border-radius: 1px; background: var(--st); }
.gauge .gap {
  position: absolute;
  top: 7px; height: 8px;
  border-radius: 1px;
  background: repeating-linear-gradient(135deg,
    color-mix(in srgb, var(--st) 34%, transparent) 0 3px,
    transparent 3px 6px);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--st) 30%, transparent) inset;
}
.gauge .plan { position: absolute; top: 2px; width: 1px; height: 18px; background: var(--ink); }
.gauge .plan::after {
  content: '';
  position: absolute;
  left: -2px; top: -1px;
  width: 5px; height: 2px;
  background: var(--ink);
}

.row .pc { width: 58px; font-size: 17px; flex: none; text-align: right; font-weight: 500; letter-spacing: -.02em; }
.row .vr { width: 52px; flex: none; text-align: right; font-size: 13px; font-weight: 500; color: var(--st); }

/* ── tiers 2 + 3: the viewport ────────────────────────────────────────────── */

#viewport {
  position: absolute;
  inset: 0;
  background: var(--instrument);
  transform-origin: 50% 46%;
  transition: opacity .34s var(--ease), transform .34s var(--ease);
}
#viewport[hidden] { display: none; }
#viewport.leaving { opacity: 0; transform: scale(1.06); pointer-events: none; }

#portfolio { transition: opacity .34s var(--ease), transform .34s var(--ease); }
#portfolio.entering { opacity: 0; transform: translateY(10px) scale(.994); }

#gl {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  opacity: 0;
  transition: opacity .5s var(--ease);
}
#gl.live { opacity: 1; }
#gl.grabbing { cursor: grabbing; }

/* the still that paints instantly while the splat streams in behind it */
#still {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: opacity .6s var(--ease);
}
#still.gone { opacity: 0; }
#still::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(10, 26, 26, .2), rgba(10, 26, 26, .55));
}

#progress {
  position: absolute;
  left: 0; top: 0;
  height: 2px; width: 0;
  background: var(--live);
  z-index: 12;
  transition: width .2s linear, opacity .4s var(--ease);
}
#progress.gone { opacity: 0; }

/* zone pins */
#pins { position: absolute; inset: 0; pointer-events: none; }
#lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pinline { stroke: rgba(255, 255, 255, .45); stroke-width: 1; stroke-dasharray: 2 3; }
.pindot { fill: rgba(255, 255, 255, .8); }

.pin {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 13px 5px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 3px 14px rgba(0, 0, 0, .3);
  white-space: nowrap;
  transition: box-shadow .16s var(--ease), transform .16s var(--ease);
}
.pin::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 2px var(--st) inset;
  opacity: .55;
  pointer-events: none;
}
.pin:hover { box-shadow: 0 7px 24px rgba(0, 0, 0, .4); }
.pin img { width: 34px; height: 26px; border-radius: 3px; object-fit: cover; flex: none; }
.pin .pt { font-size: 13px; font-weight: 500; letter-spacing: -.01em; }
.pin .pp { font-size: 13px; font-weight: 500; color: var(--st); }

/* floating readout: the site tier wears it large bottom-left; inside a zone it
   moves to the top-left title position the published viewer uses, clear of the
   WASD cluster and the background toggle */
#readout {
  position: absolute;
  left: 22px; bottom: 22px;
  z-index: 14;
  color: #fff;
  text-shadow: 0 1px 16px rgba(0, 0, 0, .75);
  max-width: 46ch;
  transition: none;
}
#readout h1 { font-size: 26px; font-weight: 600; letter-spacing: -.028em; margin: 0 0 2px; }
#readout p { margin: 0; font-size: 14px; opacity: .84; }

body.tier-3 #readout { bottom: auto; top: 18px; }
body.tier-3 #readout h1 { font-size: 17px; }
body.tier-3 #readout p { font-size: 13px; opacity: .78; }


/* tier 3 toolbar */
#tools {
  position: absolute;
  right: 22px; top: 22px;
  z-index: 14;
  display: flex;
  gap: 5px;
  padding: 5px;
  border-radius: 10px;
  background: rgba(10, 26, 26, .62);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(230, 239, 233, .12);
}
#tools[hidden] { display: none; }
#tools button {
  padding: 7px 13px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--muted-dark);
  transition: background .14s linear, color .14s linear;
}
#tools button:hover { background: rgba(230, 239, 233, .08); color: var(--ink-dark); }
#tools button[aria-pressed='true'] { background: var(--ink-dark); color: var(--instrument); font-weight: 500; }

/* compare wipe — the right half is a live restyle of the same canvas, so the
   "planned" view costs one backdrop-filter and no extra asset */
#wipe { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
#wipe[hidden] { display: none; }
#wipe .model {
  position: absolute;
  inset: 0;
  backdrop-filter: grayscale(1) brightness(1.4) contrast(.7);
  background: linear-gradient(160deg, rgba(86, 136, 196, .22), rgba(150, 170, 200, .14));
  clip-path: inset(0 0 0 var(--wipe, 50%));
}
#wipe .bar { position: absolute; top: 0; bottom: 0; left: var(--wipe, 50%); width: 1px; background: rgba(255, 255, 255, .85); }
#wipe .grip {
  position: absolute;
  top: 50%; left: var(--wipe, 50%);
  transform: translate(-50%, -50%);
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .45);
  pointer-events: auto;
  cursor: ew-resize;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 2px;
}
/* the labels ride the divider, so which side is which stays obvious while dragging,
   and they sit below the toolbar rather than under it */
#wipe .tag {
  position: absolute;
  top: 76px;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 12px;
  white-space: nowrap;
  background: rgba(10, 26, 26, .6);
  backdrop-filter: blur(10px);
  color: var(--ink-dark);
}
#wipe .tag.l { right: calc(100% - var(--wipe, 50%) + 12px); }
#wipe .tag.r { left: calc(var(--wipe, 50%) + 12px); }

/* ── view transitions ─────────────────────────────────────────────────────── */

::view-transition-old(root), ::view-transition-new(root) { animation-duration: .24s; }

@media (max-width: 760px) {
  .wrap { padding: 32px 16px 72px; }
  .lede { font-size: 24px; }
  .axis-key .g, .gauge { width: 104px; }
  .row { gap: 12px; }
  .row .thumb { width: 52px; height: 36px; }
  #chrome-meta { display: none; }
  #readout h1 { font-size: 20px; }
  .pin .pt { display: none; }
}

/* ───────────────────────────────────────────────────────────────────────────
   Tier 3 viewer chrome — laid out to match the published /s/ viewer:
   right rail of square tools, round compare button top centre, camera-path
   scrubber bottom centre, WASD hint and background toggle bottom left.
   ─────────────────────────────────────────────────────────────────────────── */

#viewer { position: absolute; inset: 0; z-index: 16; pointer-events: none; }
#viewer[hidden] { display: none; }
#viewer > * { pointer-events: auto; }

.pv-sq, .pv-round {
  display: grid;
  place-items: center;
  color: var(--ink-dark);
  background: rgba(14, 22, 21, .52);
  backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(230, 239, 233, .14);
  transition: background .14s linear, color .14s linear, border-color .14s linear;
}
.pv-sq { width: 44px; height: 44px; border-radius: 11px; }
.pv-round { width: 63px; height: 63px; border-radius: 50%; }
.pv-sq:hover, .pv-round:hover { background: rgba(14, 22, 21, .74); border-color: rgba(230, 239, 233, .26); }
.pv-sq[aria-pressed='true'], .pv-round[aria-pressed='true'] {
  background: var(--ink-dark);
  color: #0e1615;
  border-color: transparent;
}
.pv-sq svg, .pv-round svg {
  width: 21px; height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.pv-round svg { width: 26px; height: 26px; }
.pv-text { font-size: 13px; font-weight: 600; letter-spacing: .04em; }

#compare { position: absolute; left: 50%; top: 26px; transform: translateX(-50%); }

#rail {
  position: absolute;
  right: 22px; top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 13px;
}

/* camera path */
#timeline {
  position: absolute;
  left: 50%; bottom: 30px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(620px, 72vw);
  padding: 9px 16px 9px 10px;
  border-radius: 999px;
  background: rgba(14, 22, 21, .5);
  backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(230, 239, 233, .13);
  color: var(--ink-dark);
}
#play { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 50%; }
#play:hover { background: rgba(230, 239, 233, .12); }
#play svg { width: 19px; height: 19px; fill: currentColor; stroke: none; }
#play .ico-pause { display: none; }
#viewer.playing #play .ico-play { display: none; }
#viewer.playing #play .ico-pause { display: block; }

#track { position: relative; flex: 1; height: 16px; cursor: pointer; }
#track::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 7px;
  height: 2px;
  border-radius: 2px;
  background: rgba(230, 239, 233, .26);
}
#track-fill {
  position: absolute;
  left: 0; top: 7px;
  height: 2px;
  width: 0;
  border-radius: 2px;
  background: var(--live);
}
#track-thumb {
  position: absolute;
  top: 3px; left: 0;
  width: 10px; height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 1px 6px rgba(0, 0, 0, .5);
}
#clock { flex: none; font-size: 12px; opacity: .78; }

/* bottom-left hud */
#hud { position: absolute; left: 22px; bottom: 26px; display: flex; flex-direction: column; gap: 14px; }
#keys {
  display: grid;
  grid-template-areas: '. w .' 'a s d';
  gap: 4px;
  width: 104px;
}
#keys .k {
  display: grid;
  place-items: center;
  width: 32px; height: 26px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-dark);
  background: rgba(14, 22, 21, .42);
  border: 1px solid rgba(230, 239, 233, .16);
}
#keys .w { grid-area: w; }
#keys .a { grid-area: a; }
#keys .s { grid-area: s; }
#keys .d { grid-area: d; }

#open-scan {
  position: absolute;
  right: 22px; bottom: 26px;
  padding: 9px 15px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .95);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .38);
  transition: transform .14s var(--ease);
}
#open-scan:hover { transform: translateY(-1px); }
#open-scan[hidden] { display: none; }

#toast {
  position: absolute;
  left: 50%; bottom: 92px;
  transform: translateX(-50%);
  padding: 8px 15px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--ink-dark);
  background: rgba(14, 22, 21, .76);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(230, 239, 233, .14);
}
#toast[hidden] { display: none; }

/* annotation pins */
#notes { position: absolute; inset: 0; pointer-events: none; }
.note {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: #16201e;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .5), 0 0 0 2px rgba(255, 255, 255, .78);
  transition: transform .14s var(--ease);
}
.note:hover { transform: translate(-50%, -50%) scale(1.12); }
.note.open { background: var(--late); }

.note-card {
  position: absolute;
  z-index: 4;
  width: 232px;
  padding: 11px 13px;
  border-radius: 11px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 16px 44px rgba(0, 0, 0, .42);
  pointer-events: auto;
}
.note-card .t { font-size: 14px; font-weight: 500; line-height: 1.35; }
.note-card .m { margin-top: 3px; font-size: 12px; color: var(--muted); }

/* light background: the scan reads differently against white, so the viewer
   offers it the way the published viewer does */
#viewport.light #still::after { background: linear-gradient(to bottom, rgba(244, 244, 241, .3), rgba(244, 244, 241, .55)); }

@media (max-width: 760px) {
  #rail { right: 12px; gap: 9px; }
  .pv-sq { width: 38px; height: 38px; border-radius: 9px; }
  #timeline { width: 86vw; bottom: 18px; }
  #hud { display: none; }
  #open-scan { bottom: 76px; right: 12px; }
}
