/* Neural Floorplan demo — page-specific styles.

   Design tokens (color, type scale, spacing, radius, motion) come from
   /shared/site.css and are deliberately NOT redefined here. Only two kinds of
   value are local:
     - --font-mono, which the shared sheet does not define
     - the classified-geometry colors, which are copied from the pipeline's
       final_vector.svg and must keep matching what the drawing draws. */

:root {
  --font-mono: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;

  /* Panel surface for the instrument. The shared sheet flattens --bg and
     --bg-elev to #ffffff on .subpage pages, so a panel that must read as
     raised needs its own surface. This is the site's own grey ground. */
  --demo-panel: #f4f5f6;

  /* Largest the drawing is ever painted. The stage rasters are 512px native,
     so this allows a ~1.6x upscale - soft enough to stay unobtrusive on line
     art, and far better than stranding a small image in a wide field. The
     vector stage is capped to the same number so stepping through the stages
     does not change the drawing's size. */
  --sheet-max: 820px;

  /* classified geometry, identical to final_vector.svg */
  --wall: #1a1a1a;
  --window: #3a78dc;
  --door-origin: #a046b4;
  --door-leaf: #eb8c50;
  --door-arc: #dc5a5a;
}

/* Base element styles, links, focus rings, .eyebrow and the header/footer
   come from /shared/site.css. Everything below is specific to the demo
   instrument. */

/* The instrument is a tool, not prose: it wants width, and it should fit a
   normal display without scrolling. .subpage caps at 1080px for readability,
   which is the wrong constraint here. */
.demo-main {
  max-width: min(1720px, 100%);
  padding-top: var(--space-3);
}

.demo-hero { margin-bottom: var(--space-3); padding-bottom: var(--space-2); }
.demo-hero .proj-hero__title { font-size: var(--fs-h3); margin-bottom: 0; }
.demo-hero__summary {
  margin: var(--space-1) 0 0;
  max-width: 92ch;
  font-size: var(--fs-small);
  line-height: 1.5;
  color: var(--ink-3);
}
.demo-hero__summary em { color: var(--ink); font-style: italic; }

/* ------------------------------------------------------------ instrument */

.instrument {
  display: grid;
  grid-template-columns: minmax(215px, 250px) minmax(0, 1fr) minmax(250px, 310px);
  grid-template-rows: minmax(0, 1fr);
  height: clamp(440px, calc(100vh - 262px), 900px);
  align-items: stretch;
  border-radius: var(--radius);
}

/* Nothing here may grow the panel; each column scrolls inside it instead. */
.rail, .stack, .readout { min-height: 0; }
.readout { overflow-y: auto; }
.rail { overflow: hidden; }

/* ------------------------------------------------------------------ rail */

.rail {
  display: flex;
  flex-direction: column;
  background: var(--demo-panel);
  border: 1px solid var(--line);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
}

.rail__block { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); flex: none; }

/* Only the stage list gives way when the panel is short, so the plan picker
   and the Run button stay put no matter how little height there is. */
.rail__block--grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.rail__block--grow .ledger { flex: 1; min-height: 0; overflow-y: auto; }

.rail__foot { flex: none; }

.rail__title {
  margin: 0 0 var(--space-1);
  font-size: var(--fs-meta);
  font-weight: var(--w-bold);
  letter-spacing: 1.56px;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* sample picker */

.samples { display: flex; flex-direction: column; gap: 0.35rem; }

.sample {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  width: 100%;
  padding: 0.45rem 0.7rem;
  font-family: inherit;
  font-size: var(--fs-small);
  font-weight: var(--w-semi);
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.sample:hover { border-color: var(--line-strong); }

.sample[aria-checked="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.sample__meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: var(--w-regular);
  letter-spacing: 0;
  color: var(--ink-2);
}

.sample[aria-checked="true"] .sample__meta { color: var(--accent); }

/* stage ledger */

.ledger { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }

.stage {
  display: grid;
  grid-template-columns: 1.7rem minmax(0, 1fr);
  gap: 0.5rem;
  width: 100%;
  padding: 0.4rem 0.4rem;
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.ledger li:last-child .stage { border-bottom: none; }

.stage:hover { background: #ffffff; color: var(--ink); }

.stage__num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: var(--w-semi);
  color: var(--ink-2);
  padding-top: 0.15rem;
}

.stage__body { min-width: 0; }

.stage__name {
  display: block;
  font-size: var(--fs-small);
  font-weight: var(--w-semi);
  line-height: 1.3;
  color: var(--ink);
}

.stage__desc {
  display: block;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--ink-2);
}

.stage[aria-current="true"] {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.stage[aria-current="true"] .stage__name { color: var(--accent-strong); }
.stage[aria-current="true"] .stage__num { color: var(--accent); }
.stage[aria-current="true"] .stage__desc { color: var(--ink-3); }

.stage--done .stage__num { color: var(--accent); }

/* run control */

.rail__foot { padding: var(--space-2) var(--space-3) var(--space-3); }

.run {
  position: relative;
  display: block;
  width: 100%;
  padding: 0.7rem 1rem;
  font-family: inherit;
  font-size: var(--fs-meta);
  font-weight: var(--w-bold);
  letter-spacing: 1.56px;
  text-transform: uppercase;
  color: #ffffff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow: hidden;
  transition: background var(--dur) var(--ease);
}

.run:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.run[data-running="true"] {
  background: #ffffff;
  color: var(--accent-strong);
  border-color: var(--accent);
  cursor: default;
}

.run__label { position: relative; z-index: 1; }

.run__bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--accent-soft);
  transition: width var(--dur) linear;
}

.rail__hint {
  margin: var(--space-1) 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--ink-2);
}

/* ----------------------------------------------------------------- stack */

.stack {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 0;
  min-width: 0;
}

/* Stage commentary and the title block sit beside the drawing rather than
   under it, so the height they used to occupy goes to the viewer instead. */
.readout {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--demo-panel);
  border: 1px solid var(--line);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.sheet { margin: 0; display: flex; flex-direction: column; flex: 1; min-height: 0; }

.sheet__head {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
}

.sheet__index {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: var(--w-semi);
  letter-spacing: 0.05em;
  color: var(--accent);
  white-space: nowrap;
}

.sheet__name {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: var(--fs-h3);
  font-weight: var(--w-bold);
  letter-spacing: -0.01em;
  color: var(--ink);
}

.sheet__full {
  font-size: var(--fs-meta);
  font-weight: var(--w-medium);
  color: var(--ink-3);
  text-decoration: none;
  white-space: nowrap;
}

.sheet__full:hover { color: var(--accent); }
.sheet__full[hidden] { display: none; }

.sheet__field {
  position: relative;
  /* Fills the height the panel has left over. The stage images are square,
     so this height is what actually governs how large they render. */
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: var(--space-3);
  background: #ffffff;
  transition: opacity var(--dur) var(--ease);
  overflow: hidden;
}

.sheet__field[data-fading="true"] { opacity: 0; }

.sheet__img,
.sheet__vector {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  max-width: var(--sheet-max);
  max-height: var(--sheet-max);
  margin: auto;
}

.sheet__img { object-fit: contain; display: block; }
.sheet__img[hidden] { display: none; }

.sheet__vector { display: grid; place-items: center; width: 100%; height: 100%; }
.sheet__vector[hidden] { display: none; }
.sheet__vector svg { width: 100%; height: 100%; max-width: 100%; max-height: 100%; }

/* layer visibility, driven from app.js */
.sheet__vector.hide-walls #walls,
.sheet__vector.hide-windows #windows,
.sheet__vector.hide-doors #doors { display: none; }

.sheet__note {
  margin: 0;
  padding: var(--space-3);
  font-size: var(--fs-meta);
  line-height: 1.6;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}

.sheet__note strong { color: var(--ink); font-weight: var(--w-semi); }

/* layers + downloads */

.layers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-2) var(--space-3);
  margin-top: auto;
  border-top: 1px solid var(--line);
  background: var(--demo-panel);
}

.layers[hidden] { display: none; }

.layers__title {
  font-size: var(--fs-meta);
  font-weight: var(--w-bold);
  letter-spacing: 1.56px;
  text-transform: uppercase;
  color: var(--ink-3);
}

.layers__set { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.layer {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.65rem;
  font-family: inherit;
  font-size: var(--fs-meta);
  font-weight: var(--w-medium);
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.layer:hover { border-color: var(--line-strong); }
.layer[aria-pressed="false"] { opacity: 0.42; }

.layer__swatch { width: 11px; height: 11px; border-radius: 2px; flex: none; }

.layers__downloads { margin-left: auto; display: flex; gap: 0.35rem; }

.download {
  font-size: var(--fs-meta);
  font-weight: var(--w-medium);
  color: var(--ink-3);
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.download:hover { color: var(--accent); border-color: var(--accent); }

/* ---------------------------------------------------------- title block */

.titleblock { background: var(--demo-panel); margin-top: auto; }

.titleblock__cells {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.cell {
  padding: 0.55rem 0.8rem 0.6rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.cell__label {
  display: block;
  font-size: 0.68rem;
  font-weight: var(--w-semi);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell__value {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: var(--w-medium);
  line-height: 1.3;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.cell__value--muted { color: var(--ink-3); font-size: 0.84rem; }

.titleblock__strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem var(--space-3);
  padding: 0.5rem 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-2);
}

.titleblock__stamp {
  padding: 0.18rem 0.55rem;
  border: 1px solid var(--teal);
  border-radius: var(--radius-sm);
  color: var(--teal-strong);
  background: #eaf4f3;
  font-family: var(--font-sans);
  font-weight: var(--w-semi);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.66rem;
}

/* -------------------------------------------------------------- colophon */

.colophon {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: var(--space-4) var(--space-5);
  margin: var(--space-5) 0 0;
  padding: var(--space-4) 0 0;
  border-top: 1px solid var(--line);
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--ink-2);
}

.colophon__title {
  margin: 0 0 var(--space-1);
  font-size: var(--fs-meta);
  font-weight: var(--w-bold);
  letter-spacing: 1.56px;
  text-transform: uppercase;
  color: var(--ink-3);
}

.colophon p { margin: 0 0 var(--space-2); }
.colophon strong { color: var(--ink); font-weight: var(--w-semi); }

/* ----------------------------------------------------------- embed mode
   Set by app.js from ?embed=1, for iframing the instrument into the project
   page. Header, footer and hero are dropped — the colophon carries the CubiCasa5K
   attribution required by CC BY-NC 4.0 and must stay visible. */

.is-embedded .site-header,
.is-embedded .subpage-footer,
.is-embedded .demo-hero { display: none; }
.is-embedded .subpage { padding-top: var(--space-3); }
.is-embedded .colophon { margin-top: var(--space-4); padding-bottom: var(--space-4); }

/* On short viewports the stage list is the first thing to run out of room.
   Trim its secondary copy rather than let it scroll: the stage names alone
   still say what each step does. */
@media (min-width: 1201px) and (max-height: 940px) {
  .rail__hint { display: none; }
  .stage { padding: 0.35rem 0.4rem; }
}

@media (min-width: 1201px) and (max-height: 820px) {
  .stage__desc { display: none; }
  .sample__meta { display: none; }
}

/* ------------------------------------------------------------ responsive */

/* Below ~1200px the readout drops under the drawing and spans both columns;
   the field stops chasing viewport height once the page has to scroll anyway. */
@media (max-width: 1200px) {
  .instrument {
    grid-template-columns: minmax(205px, 240px) minmax(0, 1fr);
    grid-template-rows: auto auto;
    height: auto;
  }

  .rail, .readout { overflow-y: visible; }
  .sheet__field { height: clamp(320px, calc(100vh - 300px), 620px); flex: none; }

  .stack { border-radius: 0 var(--radius) 0 0; }

  .readout {
    grid-column: 1 / -1;
    border-left: 1px solid var(--line);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
  }

  .rail { border-radius: var(--radius) 0 0 0; }

  .sheet__note { border-bottom: none; border-right: none; }

  .titleblock__cells { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
}

@media (max-width: 900px) {
  .instrument { grid-template-columns: minmax(0, 1fr); }

  .rail {
    border-right: 1px solid var(--line);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .stack { border-radius: 0; border-top: none; }

  .samples { flex-direction: row; flex-wrap: wrap; }
  .sample { width: auto; flex: 1 1 9rem; }

  .sheet__field { height: clamp(280px, 68vw, 520px); flex: none; }
}

@media (max-width: 560px) {
  .sheet__head { flex-wrap: wrap; row-gap: 0.25rem; }
  .sheet__name { flex-basis: 100%; order: 3; }
  .layers__downloads { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
