/* Scene 0 — A U-Net, end to end. (Ronneberger-style architecture overview.)

   All classes prefixed s0-. Layout:
     hero
     controls (sample picker + play forward)
     .s0-arch  (positioned ancestor)
        .s0-svg-host  (the SVG diagram + bookends absolutely positioned over it)
        .s0-legend    (top-right corner)
        .s0-sidebar   (right rail; hover popover)
     caption + step controls
*/

.s0-root .s0-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.s0-hero h1 { font-size: 28px; }
.s0-hero .lede em { font-style: italic; color: var(--ink); }

/* ---------------------------------------------------------------------------
   Sample / play controls (top of arch)
   --------------------------------------------------------------------------- */

.s0-controls-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  /* Hidden until step >= 1 (when bookends fade in). The bare schematic
     at step 0 stands alone with no controls except the step nav. */
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms ease-out;
}
.s0-wrap.s0-show-picker .s0-controls-top {
  opacity: 1;
  visibility: visible;
}
.s0-sample-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.s0-control-label {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}
.s0-sample-btn {
  position: relative;
  background: var(--card-bg);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 3px;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}
.s0-sample-btn:hover { border-color: var(--ink-secondary); }
.s0-sample-btn.active {
  border-color: var(--cnn-pos);
  box-shadow: 0 0 0 1px var(--cnn-pos);
}
.s0-sample-thumb {
  width: 28px;
  height: 28px;
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
}
.s0-sample-thumb canvas {
  display: block;
  image-rendering: pixelated;
  width: 100%;
  height: 100%;
}
.s0-sample-num {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-secondary);
  padding-right: 4px;
}
.s0-sample-btn.active .s0-sample-num { color: var(--ink); }
.s0-play-btn {
  margin-left: auto;
  background: var(--cnn-pos);
  color: white;
  border: 1px solid var(--cnn-pos);
  border-radius: 3px;
  padding: 4px 12px;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}
.s0-play-btn:hover { filter: brightness(1.06); }

/* ---------------------------------------------------------------------------
   The architecture container
   --------------------------------------------------------------------------- */

.s0-arch {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 14px;
  align-items: start;
  padding: 14px;
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
}

.s0-svg-host {
  position: relative;
  overflow-x: auto;
  overflow-y: visible;
  /* Smooth scrollbar look. */
  scrollbar-color: var(--rule) transparent;
}

.s0-svg {
  display: block;
}

/* ---------------------------------------------------------------------------
   Bars
   --------------------------------------------------------------------------- */

/* Activations: medium blue. */
.s0-bar-act {
  fill: var(--cnn-pos);
  fill-opacity: 0.78;
}
/* Input bar: lighter, a hint of warmth. */
.s0-bar-input {
  fill: var(--cnn-pos);
  fill-opacity: 0.5;
}
/* Output (argmax): the accent color so it reads as "the answer". */
.s0-bar-output {
  fill: var(--cnn-accent);
  fill-opacity: 0.92;
}

/* Concat halves: the upsample side keeps the activation blue, the skip side
   takes the amber accent so the concat bookkeeping reads at a glance. */
.s0-bar-up {
  fill: var(--cnn-pos);
  fill-opacity: 0.78;
}
.s0-bar-skip {
  fill: var(--cnn-accent);
  fill-opacity: 0.78;
}

.s0-bar-outline {
  fill: none;
  stroke: var(--ink);
  stroke-opacity: 0.55;
  stroke-width: 1;
}

/* Hover state: a clear lift via stronger outline. */
.s0-bar-group.s0-bar-hover .s0-bar-outline {
  stroke: var(--ink);
  stroke-opacity: 1;
  stroke-width: 2;
}
.s0-bar-group.s0-bar-hover .s0-bar,
.s0-bar-group.s0-bar-hover .s0-bar-up,
.s0-bar-group.s0-bar-hover .s0-bar-skip { fill-opacity: 1; }

/* Sweep state: muted before the wavefront, fully lit on the wavefront. */
.s0-arch.s0-show-sweep .s0-bar-group .s0-bar,
.s0-arch.s0-show-sweep .s0-bar-group .s0-bar-up,
.s0-arch.s0-show-sweep .s0-bar-group .s0-bar-skip {
  fill-opacity: 0.18;
  transition: fill-opacity 220ms ease-out;
}
.s0-arch.s0-show-sweep .s0-bar-group.s0-bar-sweep .s0-bar,
.s0-arch.s0-show-sweep .s0-bar-group.s0-bar-sweep .s0-bar-up,
.s0-arch.s0-show-sweep .s0-bar-group.s0-bar-sweep .s0-bar-skip {
  fill-opacity: 0.78;
}
.s0-arch.s0-show-sweep .s0-bar-group.s0-bar-sweep-active .s0-bar,
.s0-arch.s0-show-sweep .s0-bar-group.s0-bar-sweep-active .s0-bar-up,
.s0-arch.s0-show-sweep .s0-bar-group.s0-bar-sweep-active .s0-bar-skip {
  fill-opacity: 1;
}
.s0-arch.s0-show-sweep .s0-bar-group.s0-bar-sweep-active .s0-bar-outline {
  stroke-width: 2;
  stroke-opacity: 1;
}

/* Cursor changes only when hover-mode (step 2+) is active. */
.s0-bar-hit { cursor: default; }
.s0-arch.s0-show-hover .s0-bar-hit { cursor: pointer; }

/* ---------------------------------------------------------------------------
   Numeric labels
   --------------------------------------------------------------------------- */

.s0-label-channels {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  fill: var(--ink);
}
.s0-label-spatial {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 10px;
  fill: var(--ink-secondary);
}
.s0-label-annot {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-style: italic;
  font-size: 10.5px;
  fill: var(--ink-secondary);
}

.s0-arrow-label {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-style: italic;
  font-size: 11px;
  fill: var(--ink-secondary);
}

/* ---------------------------------------------------------------------------
   Operation arrows
   --------------------------------------------------------------------------- */

.s0-arrow {
  stroke-width: 1.6;
  stroke-linecap: round;
  fill: none;
}
.s0-arrow-conv     { stroke: #5aa64a; }
.s0-arrow-pool     { stroke: #c95a5a; stroke-width: 1.8; }
.s0-arrow-upconv   { stroke: #9067c2; stroke-width: 1.8; }
.s0-arrow-onexone  { stroke: #3a8fb7; stroke-width: 1.8; }
.s0-arrow-argmax   { stroke: var(--ink-secondary); stroke-width: 1.2; stroke-dasharray: 4 3; }
/* up→concat short arrow: same gray as the skip arc, but solid (not dashed)
   so the viewer sees "two gray inputs feed this concat — one is the
   long-distance skip, the other is the local upsample". */
.s0-arrow-concat {
  stroke: #7d776c;
  stroke-width: 1.6;
  opacity: 0.9;
}
:root[data-theme="dark"] .s0-arrow-concat { stroke: #a09a8d; }
.s0-arrow-skip {
  stroke: var(--ink-secondary);
  stroke-width: 1.6;
  stroke-dasharray: 6 4;
  opacity: 0.85;
}

/* In dark theme, the conv green and pool red can dim the markers a bit; nudge. */
:root[data-theme="dark"] .s0-arrow-conv    { stroke: #7bc070; }
:root[data-theme="dark"] .s0-arrow-pool    { stroke: #e07a7a; }
:root[data-theme="dark"] .s0-arrow-upconv  { stroke: #b08adb; }
:root[data-theme="dark"] .s0-arrow-onexone { stroke: #6fb6d6; }

/* ---------------------------------------------------------------------------
   Bookends (real input image + predicted seg map)
   --------------------------------------------------------------------------- */

.s0-bookend {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 320ms ease-out, transform 320ms ease-out;
}
.s0-arch.s0-show-bookends .s0-bookend {
  opacity: 1;
  transform: translateY(0);
}
.s0-bookend-canvas {
  border: 1px solid var(--ink-secondary);
  border-radius: 3px;
  background: var(--card-bg);
  overflow: hidden;
}
.s0-bookend-canvas canvas {
  display: block;
  image-rendering: pixelated;
}
.s0-bookend-label {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-style: italic;
  font-size: 10.5px;
  color: var(--ink-secondary);
}

/* ---------------------------------------------------------------------------
   Legend (top-right of arch)
   --------------------------------------------------------------------------- */

/* Legend lives inside the scrollable SVG host so it stays anchored to the
   diagram coordinates (not the viewport). JS positions it via inline styles. */
.s0-legend {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 9px;
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  z-index: 3;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.s0-legend-title {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  margin-bottom: 2px;
}
.s0-legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink);
}
.s0-legend-swatch {
  display: inline-block;
  width: 18px;
  height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}
.s0-legend-swatch.lg-conv    { background: #5aa64a; }
.s0-legend-swatch.lg-pool    { background: #c95a5a; }
.s0-legend-swatch.lg-upconv  { background: #9067c2; }
.s0-legend-swatch.lg-skip {
  background: transparent;
  border-top: 2px dashed var(--ink-secondary);
  height: 0;
  margin-top: 2px;
}
.s0-legend-swatch.lg-onexone { background: #3a8fb7; }
.s0-legend-swatch.lg-argmax {
  background: transparent;
  border-top: 2px dashed var(--ink-secondary);
  height: 0;
  margin-top: 2px;
  opacity: 0.7;
}
:root[data-theme="dark"] .s0-legend-swatch.lg-conv    { background: #7bc070; }
:root[data-theme="dark"] .s0-legend-swatch.lg-pool    { background: #e07a7a; }
:root[data-theme="dark"] .s0-legend-swatch.lg-upconv  { background: #b08adb; }
:root[data-theme="dark"] .s0-legend-swatch.lg-onexone { background: #6fb6d6; }

/* ---------------------------------------------------------------------------
   Hover sidebar (right rail)
   --------------------------------------------------------------------------- */

.s0-sidebar {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  min-height: 220px;
  opacity: 0.55;
  transition: opacity 220ms ease-out;
}
.s0-arch.s0-show-hover .s0-sidebar { opacity: 1; }

.s0-sb-head { display: flex; flex-direction: column; gap: 2px; }
.s0-sb-name {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.s0-sb-op {
  font-size: 11.5px;
  color: var(--ink-secondary);
}
.s0-sb-shape {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--ink);
  padding: 4px 6px;
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: 3px;
}
.s0-sb-shape-label {
  color: var(--ink-secondary);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-right: 6px;
}
.s0-sb-preview-wrap {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}
.s0-sb-preview {
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
  background: var(--card-bg);
}
.s0-sb-preview canvas { display: block; image-rendering: pixelated; }
.s0-sb-preview-subtitle {
  text-align: center;
  font-style: italic;
  font-size: 10.5px;
  color: var(--ink-secondary);
}
.s0-sb-hint {
  font-size: 11px;
  color: var(--ink-secondary);
  font-style: italic;
  text-align: center;
}

/* ---------------------------------------------------------------------------
   Caption / step controls
   --------------------------------------------------------------------------- */

.s0-caption {
  margin: 4px 4px 0;
  font-size: 14px;
}

.s0-controls { margin-top: 6px; }

/* ---------------------------------------------------------------------------
   Responsive: collapse the sidebar to a stacked panel on narrow viewports.
   --------------------------------------------------------------------------- */

/* No grid restructure needed at narrow widths since the sidebar/legend are
   absolutely positioned overlays. The SVG host scrolls horizontally if
   the diagram does not fit. */
