/* Three-region geometry (2026-07-22 rebuild): left context rail, center
   stage, right summary rail, straight from the calm-studio reference,
   rendered on the dark mission-control material. The rails are shell-owned
   slots (#pw-rail-context, #pw-rail-summary) that screens fill; a rail with
   no content collapses so non-investigation screens get the full stage. */

.pw-body {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) auto;
  flex: 1;
  min-height: 0;
}
/* Unauthenticated views (login, setup): no rails, the stage takes the row. */
.pw-body.no-rails { grid-template-columns: minmax(0, 1fr) auto; }
.pw-body.no-rails #pw-content { grid-column: 1; }

/* Left rail: nav on top, contextual content (history, similarity) below. */
.pw-rail-left {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--bar-border);
}
.pw-rail-left .pw-nav { width: auto; border-right: none; flex: none; }
.pw-rail-context {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 10px 12px;
  border-top: 1px solid var(--bar-border);
}
.pw-rail-context:empty { border-top: none; padding: 0; }
.pw-rail-title {
  font-family: var(--font-heading);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--console-head);
  margin: 10px 4px 8px;
}

/* Center stage. */
#pw-content { grid-column: 2; overflow-y: auto; padding: 20px 24px; min-width: 0; }

/* Right rail: summary and lenses. Zero width until a screen fills it. */
.pw-rail-right {
  grid-column: 3;
  width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--bar-border);
}
.pw-rail-right.filled { width: var(--rail-r-w); overflow: visible; }

/* Floating card: the rebuild's shared surface. */
.pw-card {
  background: var(--raised);
  border: 1px solid var(--copy-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
}

/* Narrow viewports: the stage wins. Rails stack under the stage; the left
   rail keeps only its nav (icon mode comes from shell.css). */
@media (max-width: 960px) {
  .pw-body { grid-template-columns: 52px minmax(0, 1fr); }
  .pw-rail-context { display: none; }
  .pw-rail-right { grid-column: 2; grid-row: 2; width: auto; border-left: none; border-top: 1px solid var(--bar-border); }
  .pw-rail-right.filled { width: auto; max-height: 40vh; }
}

/* ── Motion pass (2026-07-22 rebuild) ── */
/* Rows stream in; results reveal staggered. High-impact moments only. */
@media (prefers-reduced-motion: no-preference) {
  .pw-probe, .pw-term-line, .pw-reason-entry {
    animation: pw-row-in 0.25s ease both;
  }
  .pw-result-hero { animation: pw-card-in 0.4s ease both; }
  .pw-verdict { animation: pw-card-in 0.4s ease 0.08s both; }
  .pw-untested-card, .pw-verify-line { animation: pw-card-in 0.4s ease 0.16s both; }
  .pw-theory { animation: pw-card-in 0.3s ease both; }
}
@keyframes pw-row-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
@keyframes pw-card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Focus is always visible; status is never color alone (glyphs + words ride
   every colored element). */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

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