/* The context address bar and the Spatial Spine screen.
 *
 * Kept in its own stylesheet because it is the one surface that is not the handoff's layout: the
 * handoff has no spatial screen, so nothing here has a token to inherit from except the palette.
 */

/* ============================================================== the context address
 * Fixed at the bottom, OUTSIDE #smooth-wrapper, mirroring #depth's geometry.
 *
 * It is deliberately NOT a second sticky band at the top. `.hero` already owns that slot and its
 * compression is scrubbed against a tuned start:0 end:150, so a band above it would compress at
 * the wrong scroll offset. `.mast` is not sticky at all, so mounting it there would have meant
 * "never unmounts" without meaning "always visible". The competitor idiom (XYZ Platform) also
 * runs its persistent context strip along the bottom.
 */
#address {
  position: fixed; inset-inline: var(--rail-w) 0; bottom: 0; z-index: 48;
  pointer-events: none;
}
#address .abar {
  pointer-events: auto;
  display: flex; align-items: center; gap: 6px;
  padding: 8px calc(var(--pad) + 4px);
  background: var(--canvas);
  border-top: 1px solid var(--hairline);
  box-shadow: 0 -2px 14px oklch(0.227 0.004 286 / .05);
}
#address .aicon svg {
  width: 16px; height: 16px; display: block;
  fill: none; stroke: var(--stone-text); stroke-width: 1.7;
}
#address .aseg {
  display: flex; align-items: baseline; gap: 7px;
  padding: 5px 11px; border-radius: var(--r-pill);
  border: 1px solid var(--hairline); background: var(--canvas);
  font: inherit; cursor: default;
}
#address .aseg.act { cursor: pointer; }
#address .aseg.act:hover { border-color: var(--ink); }
#address .aseg.on { border-color: var(--ink); }
#address .ak {
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--stone-text);
}
#address .av { font-size: 13px; font-weight: 600; color: var(--ink); unicode-bidi: isolate; }
#address .asep { color: var(--stone-text); font-style: normal; display: inline-block; }
/* the chevron points INTO the narrowing, so it has to turn around in RTL */
:dir(rtl) #address .asep { transform: scaleX(-1); }
#address .agrow { flex: 1; }

#address .awbs {
  font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--stone-text);
}
/* the bar is fixed, so the scroll column has to end above it */
/* only the screens that actually show the bar pay for it */
body:has(#address .abar) #smooth-content { padding-bottom: 76px; }

/* ===================================================================== spine */
.spine > .panel, .spine .roompan { padding: 16px 18px; }
.spine {
  display: grid; grid-template-columns: 272px minmax(0, 1fr) 300px;
  gap: var(--pad); align-items: start;
}
@media (max-width: 1180px) { .spine { grid-template-columns: 1fr; } }
.spine .ph { font-size: 13px; font-weight: 700; letter-spacing: .02em; margin: 0 0 10px; }
.spine .hint { font-size: 11.5px; color: var(--stone-text); margin: 12px 0 0; line-height: 1.45; }
.spine .foot { font-size: 11.5px; color: var(--stone-text); margin: 12px 0 0; line-height: 1.5; }

/* ---- hero band ---- */
.sband { display: flex; gap: 10px; flex-wrap: wrap; }
.sfig {
  flex: 1 1 170px; background: var(--card); border: 1px solid var(--hairline);
  border-radius: var(--r-md); padding: 14px 16px;
}
.sfig .sv {
  font-size: 26px; font-weight: 700; color: var(--ink); line-height: 1.1;
  unicode-bidi: isolate; direction: ltr;
}
.sfig .sk { font-size: 12.5px; font-weight: 600; color: var(--ink); margin-top: 3px; }
.sfig .ss { font-size: 11.5px; color: var(--stone-text); margin-top: 2px; }
.sclaim {
  font-size: 12.5px; color: var(--slate); line-height: 1.55; margin: 12px 0 0; max-width: 78ch;
}

/* ---- the stack: storeys by elevation, T levels as sub-bands of their own slab ---- */
.stack { display: flex; flex-direction: column; gap: 3px; }
.band {
  display: grid; grid-template-columns: 30px 42px minmax(0, 1fr) auto; align-items: center; gap: 7px;
  padding: 7px 8px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: none; font: inherit; cursor: pointer; text-align: start;
}
.band:hover { background: var(--surface); }
.band.sel { border-color: var(--ink); background: var(--surface); }
.band.tier-sub { margin-inline-start: 16px; padding-block: 4px; }
.band.tier-sub .blab { font-size: 11px; }
.band .blab { font-size: 12.5px; font-weight: 700; color: var(--ink); unicode-bidi: isolate; }
.band .belev {
  font-size: 11px; color: var(--stone-text); unicode-bidi: isolate; direction: ltr;
  font-variant-numeric: tabular-nums;
}
.band .bnum {
  font-size: 11px; color: var(--stone-text); unicode-bidi: isolate; white-space: nowrap;
}
.band.empty .bnum { font-style: italic; }
.sbar {
  display: flex; height: 7px; min-width: 0; border-radius: var(--r-pill);
  overflow: hidden; background: var(--hairline);
}
.sbar i { display: block; height: 100%; }
.sbar.none i { width: 100%; background: var(--hairline-soft); }

/* ---- the plate ----
 * Rooms are DIVS clipped to their real IfcSpace outline, never SVG paths: audit() resolves a
 * foreground against getComputedStyle().backgroundColor walked up the tree, and an SVG fill is
 * invisible to it, so a label on a dark tint would be audited against the panel behind it and
 * would pass while being unreadable.
 */
.plate {
  position: relative; width: 100%; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--r-sm); overflow: hidden;
}
.room {
  position: absolute; border: 0; padding: 0; margin: 0; font: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  outline: none; transition: filter .12s ease;
}
.room:hover { filter: brightness(.95); }
.room.sel { filter: none; box-shadow: inset 0 0 0 2px var(--ink); z-index: 2; }
.room:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.rlab {
  font-size: 11px; font-weight: 600; color: var(--ink); line-height: 1.1;
  padding: 0 3px; text-align: center; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 100%; unicode-bidi: isolate; direction: ltr;
}

/* 🔴 IGNORANCE IS THE INK.
 * Drawn the obvious way round -- colour where we found something, white where we did not -- the
 * plan says exactly what every competitor's plan says, and a client reads the blanks as "not built"
 * because that is how every plan they have ever seen works. So it is inverted: the two states that
 * mean WE DID NOT LOOK are the heaviest marks on the plate, and verified work recedes to a pale
 * wash. The result is a building-shaped picture of what we do not know.
 *
 * Each state sets background-color explicitly as well as any gradient: audit() reads
 * backgroundColor, and a background-image alone computes as transparent, which would walk the
 * contrast check straight past the tint to the panel behind it.
 */
.is-verified { background-color: oklch(0.967 0.021 182); }
.is-mixed    { background-color: oklch(0.969 0.026 78); }
.is-poor     { background-color: oklch(0.957 0.032 24); }
/* never assessed: the densest mark on the plan */
.is-unseen {
  background-color: oklch(0.469 0.027 272);
  background-image: repeating-linear-gradient(45deg,
    oklch(0.227 0.004 286) 0 5px, oklch(0.469 0.027 272) 5px 10px);
}
/* looked at, and still cannot tell: a texture, not the deviation hue */
.is-unclear {
  background-color: oklch(0.800 0.012 275);
  background-image: repeating-linear-gradient(-45deg,
    oklch(0.800 0.012 275) 0 4px, oklch(0.700 0.016 275) 4px 8px);
}
/* no record at all: solid, mid-weight, unmistakably filled */
.is-none { background-color: oklch(0.741 0.018 275); }

.room.is-unseen .rlab { color: var(--on-nav-strong); }
.room.is-verified, .room.is-mixed, .room.is-poor {
  box-shadow: inset 0 0 0 1px oklch(0.227 0.004 286 / .10);
}
.room.is-none, .room.is-unseen, .room.is-unclear { box-shadow: inset 0 0 0 1px oklch(1 0 0 / .35); }

/* ---- legend, which is also the record count per state ---- */
.evlegend { display: flex; flex-wrap: wrap; gap: 7px 16px; margin-top: 14px; }
.evkey { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px;
  color: var(--slate); white-space: nowrap; flex: 0 0 auto; }
.evkey b { font-weight: 600; color: var(--ink); }
.evkey em { font-style: normal; color: var(--stone-text); font-variant-numeric: tabular-nums; }
.sw {
  width: 11px; height: 11px; border-radius: 3px; display: inline-block; flex: none;
  box-shadow: inset 0 0 0 1px oklch(0.227 0.004 286 / .14);
}

.platehead { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.platehead .ph { margin: 0; }
.metricsw {
  margin-inline-start: auto; display: flex; gap: 2px;
  background: var(--surface); border-radius: var(--r-pill); padding: 2px;
}
.metricsw button {
  font: inherit; font-size: 12px; font-weight: 600; border: 0; cursor: pointer;
  padding: 5px 12px; border-radius: var(--r-pill); background: none; color: var(--stone-text);
}
.metricsw button.on { background: var(--ink); color: var(--on-nav-strong); }

/* ---- the room panel ---- */
.roompan header { margin-bottom: 12px; }
.roompan h2 { font-size: 15px; margin: 0; color: var(--ink); unicode-bidi: isolate; }
.roompan .rmeta {
  font-size: 11.5px; color: var(--stone-text); margin: 3px 0 0;
  unicode-bidi: isolate; direction: ltr;
}
.evrows { display: flex; flex-direction: column; gap: 7px; }
.evrow {
  display: grid; grid-template-columns: 11px 1fr auto; align-items: center; gap: 8px;
  font-size: 12px; color: var(--slate);
}
.evrow b { color: var(--ink); font-variant-numeric: tabular-nums; }
.evrow .evtrack {
  grid-column: 2 / -1; height: 4px; background: var(--bar-track);
  border-radius: var(--r-pill); overflow: hidden;
}
.evrow .evtrack i { display: block; height: 100%; background: var(--stone-text); }
.rseen { font-size: 11.5px; color: var(--stone-text); margin: 12px 0 0;
  unicode-bidi: isolate; direction: ltr; }
.noev { font-size: 12.5px; color: var(--slate); line-height: 1.55; margin: 0; }
.syschips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.syschips .chip {
  font: inherit; font-size: 11px; cursor: pointer; border: 1px solid var(--hairline);
  background: var(--canvas); color: var(--slate); border-radius: var(--r-pill); padding: 3px 9px;
}
.syschips .chip.on { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.syschips .chip em { font-style: normal; color: var(--stone-text); margin-inline-start: 3px; }
.muted { font-size: 12.5px; color: var(--stone-text); }

.platecount { margin-inline-start: auto; font-size: 11.5px; color: var(--stone-text); }

/* ---------------------------------------------------------------- answer highlight
 * Set by plate({ highlight }). A matched room keeps its state tint; everything else fades to a
 * wash so the answer reads as a shape on the plan. Opacity only, so every tint stays the colour
 * the legend promises and audit() keeps measuring the same values. */
.plate .room.dim { opacity: .18; }
.plate .room.dim .rlab { opacity: 0; }
.plate .room.hit { opacity: 1; outline: 2px solid var(--ink); outline-offset: -1px; z-index: 2; }
@media (prefers-reduced-motion: no-preference) {
  .plate .room { transition: opacity .28s ease-out; }
}

/* ------------------------------------------------------------------ ask box
 * Variant A: an inline query bar whose answer redraws the plate. Mounted only when a model is
 * reachable, so on the public URL with no Ollama the screen is exactly as it was. */
.askbox { margin-bottom: 14px; padding: 14px 16px; }
.asklabel { display: block; font: 600 10px/1 var(--font); letter-spacing: .09em;
  text-transform: uppercase; color: var(--stone-text); margin-bottom: 8px; }
.askrow { display: flex; gap: 8px; }
.askrow input { flex: 1; height: 44px; padding: 0 13px; font: 400 14px/1 var(--font);
  color: var(--ink); background: var(--canvas); border: 1px solid var(--hairline); border-radius: 10px; }
.askrow input:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; border-color: transparent; }
.askrow button { height: 44px; padding: 0 17px; border: 0; border-radius: 10px;
  background: var(--ink); color: var(--on-nav-strong); font: 650 13px/1 var(--font); cursor: pointer; }
.askrow button[disabled] { opacity: .45; cursor: default; }
.asksugg { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.asksugg .askchip { min-height: 32px; padding: 7px 11px; font: 400 12px/1 var(--font);
  color: var(--slate); background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 999px; cursor: pointer; }
.asksugg .askchip:hover { border-color: var(--stone-text); }

.askfilter { margin-top: 14px; border: 1px solid var(--hairline); border-radius: 11px; overflow: hidden; }
.askfilter header { display: flex; padding: 8px 12px; background: var(--surface);
  border-bottom: 1px solid var(--hairline-soft); font: 600 10px/1 var(--font);
  letter-spacing: .09em; text-transform: uppercase; color: var(--stone-text); }
.askfilter header span { margin-inline-start: auto; text-transform: none; letter-spacing: 0;
  font-weight: 400; font-size: 11px; }
.askchips { display: flex; gap: 7px; flex-wrap: wrap; padding: 11px 12px; }
.askchip-on { display: inline-flex; align-items: center; gap: 7px; min-height: 32px;
  padding: 6px 7px 6px 11px; font-size: 12.5px; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: 999px; }
.askchip-on i { font-style: normal; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--stone-text); }
.askchip-on b { font-weight: 650; }
.askchip-on button { width: 20px; height: 20px; display: grid; place-items: center; border: 0;
  border-radius: 50%; background: var(--hairline-soft); color: var(--slate); font-size: 13px;
  line-height: 1; cursor: pointer; }
.askchip-on button:hover { background: var(--ink); color: var(--on-nav-strong); }

.askanswer { margin-top: 12px; padding: 14px 16px; border-radius: 11px;
  background: var(--ink); color: var(--on-nav-strong); }
.asksentence { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; line-height: 1.4; }
.askprov { margin: 9px 0 0; font-size: 11.5px; color: oklch(1 0 0 / .68); }
.askhits { display: flex; flex-direction: column; gap: 6px; margin-top: 11px; }
.askhits a, .askhits > span { display: flex; align-items: center; gap: 10px; min-height: 40px;
  padding: 9px 11px; border-radius: 9px; background: var(--canvas); color: var(--ink);
  font-size: 12.5px; text-decoration: none; }
.askhits i { font-style: normal; flex: none; width: 94px; font: 600 9.5px/1 var(--font);
  letter-spacing: .09em; text-transform: uppercase; color: var(--stone-text); }
.askhits b { font-weight: 650; }
.askhits span > span, .askhits a > span { margin-inline-start: auto; color: var(--stone-text); }
.askhits em { font-style: normal; font-weight: 650; color: var(--late); margin-inline-start: 10px; }
.askhits a:hover { outline: 2px solid var(--brand-yellow); outline-offset: 1px; }

.askempty, .askerr { margin: 13px 0 0; padding: 13px 15px; border-radius: 11px; font-size: 13px;
  border: 1px dashed var(--hairline); color: var(--slate); }
.askerr { border-style: solid; border-color: var(--late); color: var(--late); }
.askskel { margin-top: 13px; height: 74px; border-radius: 11px; background: var(--hairline-soft); }
@media (prefers-reduced-motion: no-preference) {
  .askskel { background: linear-gradient(90deg, var(--hairline-soft) 25%, var(--surface) 37%,
    var(--hairline-soft) 63%); background-size: 400% 100%; animation: askshimmer 1.3s linear infinite; }
  @keyframes askshimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
}

/* 🔴 The ask box is a BAND, not a column. Dropped into `.spine` as a plain child it became a
   fourth grid track and squeezed the plate to a third of its width, which inverts the whole point:
   the plan is the answer. Span every column and sit above them. */
.spine > .askhost { grid-column: 1 / -1; }

/* --------------------------------------------------- the agent working
 * Three dots that breathe, plus a stage word that names what is really happening. Under reduced
 * motion the dots hold still and the stage text still advances, so the information survives and
 * only the movement goes. */
.askwork { display: flex; align-items: center; gap: 10px; margin-top: 13px; padding: 14px 16px;
  border-radius: 11px; background: var(--surface); border: 1px solid var(--hairline);
  font-size: 13.5px; color: var(--slate); }
.askspin { display: inline-flex; gap: 4px; }
.askspin i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); opacity: .25; }
.askstage { font-weight: 650; color: var(--ink); }
.askdots::after { content: '...'; }
@media (prefers-reduced-motion: no-preference) {
  .askspin i { animation: askpulse 1.05s ease-in-out infinite; }
  .askspin i:nth-child(2) { animation-delay: .14s; }
  .askspin i:nth-child(3) { animation-delay: .28s; }
  @keyframes askpulse { 0%, 100% { opacity: .22; transform: translateY(0); }
                        40%      { opacity: 1;   transform: translateY(-3px); } }
  .askdots { display: inline-block; width: 1.1em; text-align: start; }
  .askdots::after { animation: askdots 1.2s steps(4, end) infinite; }
  @keyframes askdots { 0% { content: ''; } 25% { content: '.'; }
                       50% { content: '..'; } 75%, 100% { content: '...'; } }
}

/* ------------------------------------------------------- scan thumbnails
 * The visual payoff: an answer about captures is a wall of rooms, each opening the real 3D viewer.
 * `aspect-ratio` reserves the box so a lazy image cannot shift the layout under the client. */
.askcaps { display: grid; grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 9px; margin-top: 12px; }
.askcap { display: block; padding: 7px; border-radius: 10px; background: var(--canvas);
  color: var(--ink); text-decoration: none; }
.askcap img, .askcap .nothumb { display: block; width: 100%; aspect-ratio: 4 / 3;
  object-fit: cover; border-radius: 7px; background: var(--hairline-soft); }
.askcap b { display: block; margin-top: 7px; font-size: 12.5px; font-weight: 650;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.askcap span { display: block; font-size: 11.5px; color: var(--stone-text); }
.askcap:hover img { outline: 2px solid var(--brand-yellow); outline-offset: 2px; }
.askcap:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
