/* Low Capacity OS — The Shrinking Room — structural shrink build.
 * Rooms shrink by asking less: fewer controls, less chrome, more
 * empty space — never by dimming or desaturating the interface.
 *
 * Ported from the Quiet Apartment Console architecture. */

body.os-low-capacity {
  --lc-void: #0a0812;
  --lc-muted: #a89dc4;
  --lc-warn: #c48a7d;
  --lc-soft: #c4b8e8;
}

.app-header {
  justify-content: space-between;
}

.app-header--in-room {
  padding-top: 10px;
  padding-bottom: 10px;
}

.app-header__brand {
  flex: 1;
  min-width: 0;
}

.app-header__context {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  margin: 4px 0 0;
  min-width: 0;
}

.app-header__sep {
  color: var(--whisper);
  opacity: 0.5;
  user-select: none;
}

.app-header__actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.app-header__progress {
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* In-room header: brand row on top, actions below — prevents crowding on narrow screens */
@media (max-width: 640px) {
  .app-header--in-room .app-header__brand {
    flex: 1 1 100%;
  }
  .app-header--in-room .app-header__actions {
    width: 100%;
    justify-content: space-between;
  }
}

body.header-in-room .screen__room.type-meta {
  display: none;
}

.validate-line {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--text-lg);
  max-width: 36ch;
  margin: 0 auto 12px;
  line-height: 1.45;
}

.screen__badge {
  display: inline-block;
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lavender);
  border: 1px solid rgba(124, 157, 170, 0.35);
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 12px;
}

.deck-card--router {
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
}

.deck-card--router .deck-card__felt {
  font-size: clamp(1.15rem, 3.5vw, 1.35rem);
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 6px;
}

.deck-card--router .deck-card__room {
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  opacity: 0.75;
  margin-bottom: 4px;
}

.deck-card__no-ai {
  display: block;
  margin-top: 8px;
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--lc-muted);
  opacity: 0.85;
}

.deck-card__icon {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.deck-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.deck-card__body > * {
  display: block;
}

.deck-card__hint,
.deck-card__route {
  font-size: var(--text-sm);
  opacity: 0.85;
  margin-top: 4px;
  line-height: 1.4;
  font-style: normal;
}

.deck-card__capacity {
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-top: 6px;
}

.deck-card__meters {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.deck-card__meter {
  display: inline-flex;
  gap: 3px;
}

.room-capacity-slot {
  margin: 12px auto 4px;
  max-width: 420px;
}

.room-capacity {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(124, 157, 170, 0.15);
  background: rgba(23, 33, 43, 0.55);
  text-align: left;
}

.room-capacity__no-ai {
  margin: 6px 0 0;
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--lc-muted);
}

.receipt-no-ai {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--whisper);
  margin: 12px 0 0;
  letter-spacing: 0.04em;
}

.held-not-solved {
  text-align: center;
  font-family: var(--font-serif);
  font-size: clamp(1.25rem, 4vw, 1.5rem);
  font-style: italic;
  line-height: 1.45;
  margin: 0 auto 20px;
  max-width: 24ch;
  animation: fade-up 0.7s ease both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.mode-switch {
  display: flex;
  gap: 8px;
  justify-content: center;
  max-width: 360px;
  margin: 0 auto 20px;
  padding: 4px;
  background: rgba(23, 33, 43, 0.5);
  border-radius: 999px;
  border: 1px solid rgba(245, 239, 230, 0.08);
}

.mode-switch__btn {
  flex: 1;
  padding: 11px 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.mode-switch__btn.is-active {
  background: rgba(124, 157, 170, 0.2);
  color: var(--cream);
  outline: 1px solid rgba(124, 157, 170, 0.35);
}

.deck-grid--rides .deck-card--router {
  background: linear-gradient(160deg, #3a4f5c 0%, #2f3d48 45%, #283540 100%);
}

.load-card--bright {
  box-shadow: 0 0 16px var(--lavender-glow);
  border: 1px solid rgba(196, 163, 90, 0.35);
}

.load-card--dimmed {
  opacity: 0.4;
  filter: saturate(0.45);
}

body[data-metaphor="access-ring"] .container-zone[data-drop="real"] {
  box-shadow: 0 0 24px var(--lavender-glow);
}

body[data-metaphor="access-ring"] .container-zone[data-drop="not-tonight"] .load-card {
  opacity: 0.45;
  filter: saturate(0.5);
}

.receipt-card {
  max-width: 480px;
  margin: 0 auto 20px;
  padding: 24px 22px;
  background: linear-gradient(165deg, var(--cream) 0%, #ebe3d4 100%);
  color: #1f252b;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: receipt-in 0.7s ease both;
}

@keyframes receipt-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.receipt-card__label {
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 8px;
}

.receipt-card__moved {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-style: italic;
  line-height: 1.35;
  margin: 0 0 20px;
}

.receipt-section {
  padding-top: 14px;
  border-top: 1px solid rgba(31, 37, 43, 0.12);
  margin-top: 14px;
}

.receipt-section__label {
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 6px;
}

.receipt-section__text {
  font-size: var(--text-lg);
  line-height: 1.45;
  margin: 0;
}

.receipt-section__text--held {
  opacity: 0.85;
  font-size: var(--text-sm);
}

.receipt-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.card-output {
  max-width: 480px;
  margin: 0 auto 20px;
  padding: 18px 20px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--cream);
  background: rgba(23, 33, 43, 0.65);
  border: 1px solid rgba(124, 157, 170, 0.25);
  border-radius: var(--radius);
}

.ride-bridge {
  max-width: 440px;
  margin: 0 auto;
  text-align: center;
}

.ride-bridge__moved {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--lavender);
  margin: 16px 0;
}

.install-card {
  max-width: 420px;
  margin: 0 auto 24px;
  padding: 20px;
  background: rgba(23, 33, 43, 0.5);
  border: 1px solid rgba(124, 157, 170, 0.25);
  border-radius: var(--radius);
  text-align: center;
}

.install-card__title {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  margin: 0 0 8px;
}

.install-card__body {
  font-size: 0.8125rem;
  color: var(--muted);
  margin: 0 0 16px;
  line-height: 1.5;
}

.install-card__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-footer__alt {
  margin-top: 8px;
  font-size: 0.6875rem;
}

.app-footer__alt a {
  color: var(--whisper);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.visual-stage {
  margin: 16px auto 20px;
  max-width: 420px;
  min-height: 72px;
  border-radius: var(--radius);
  border: 1px solid rgba(124, 157, 170, 0.15);
  background: rgba(23, 33, 43, 0.4);
  position: relative;
  overflow: hidden;
}

.step-phase-label {
  text-align: center;
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 auto 10px;
  max-width: 420px;
}

/* Noise mixer */
.noise-mixer-visual {
  min-height: 96px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  padding: 16px;
}

.noise-bar {
  width: 14px;
  border-radius: 4px 4px 0 0;
  background: rgba(201, 135, 120, 0.55);
  transition: height 0.4s ease, opacity 0.4s ease, background 0.4s ease;
}

.noise-mixer--lowering .noise-bar.is-target {
  background: var(--lc-soft);
  box-shadow: 0 0 12px rgba(168, 191, 166, 0.35);
}

.noise-mixer--lowering .noise-bar:not(.is-target) {
  opacity: 0.35;
}

/* Ping gate */
.ping-gate-visual {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ping-gate-visual::before {
  content: "";
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid rgba(201, 135, 120, 0.55);
  animation: ping-pulse 1.4s ease infinite;
}

.ping-gate--gated::before {
  animation: none;
  border-color: var(--lavender-deep);
  box-shadow: 0 0 20px var(--lavender-glow);
  transform: scale(0.85);
  opacity: 0.5;
}

@keyframes ping-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.7; }
}

/* Loop break */
.loop-break-visual {
  min-height: 88px;
}

.loop-break-visual::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: 50%;
  height: 3px;
  background: rgba(201, 135, 120, 0.45);
  border-radius: 2px;
}

.loop-break--seam::after {
  background: linear-gradient(90deg, rgba(201, 135, 120, 0.3), var(--lc-soft), rgba(201, 135, 120, 0.3));
  box-shadow: 0 0 16px rgba(168, 191, 166, 0.25);
}

/* Zone dim */
.zone-dim-visual {
  min-height: 88px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px;
}

.zone-tile {
  border-radius: var(--radius-sm);
  background: rgba(201, 135, 120, 0.25);
  min-height: 40px;
  transition: opacity 0.6s ease, box-shadow 0.6s ease;
}

.zone-dim--soft .zone-tile.is-target {
  box-shadow: 0 0 16px rgba(168, 191, 166, 0.35);
  background: rgba(168, 191, 166, 0.35);
}

.zone-dim--soft .zone-tile:not(.is-target) {
  opacity: 0.35;
}

/* Default lock */
.default-lock-visual {
  min-height: 88px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
  align-items: center;
  justify-content: center;
}

.default-switch {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: rgba(245, 239, 230, 0.12);
  opacity: 0.4;
  transition: opacity 0.4s ease, background 0.4s ease;
}

.default-lock--locked .default-switch.is-active {
  opacity: 1;
  background: var(--lc-soft);
  box-shadow: 0 0 12px rgba(168, 191, 166, 0.35);
}

/* Access ring */
.access-ring-visual {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.access-ring-visual::before {
  content: "";
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid rgba(124, 157, 170, 0.35);
  transition: border-color 0.6s ease, box-shadow 0.6s ease;
}

.access-ring--forming::before {
  border-color: var(--lavender-deep);
  box-shadow: 0 0 24px var(--lavender-glow);
}

/* Night door */
.night-door-visual {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.night-door-visual::before {
  content: "";
  width: 56px;
  height: 72px;
  border: 3px solid rgba(168, 160, 181, 0.45);
  border-radius: 4px 4px 0 0;
  transition: transform 0.8s ease, opacity 0.6s ease;
  transform-origin: left center;
}

.night-door--closed::before {
  transform: perspective(200px) rotateY(-28deg);
  border-color: var(--lc-soft);
  box-shadow: -8px 0 20px rgba(0, 0, 0, 0.25);
}

/* Replacement wheel */
.replacement-wheel-visual {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.replacement-wheel-visual::before {
  content: "";
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px dashed rgba(201, 135, 120, 0.45);
  transition: transform 0.8s ease, border-color 0.6s ease;
}

.replacement-wheel--revealed::before {
  transform: rotate(90deg);
  border-color: var(--lc-soft);
  border-style: solid;
}

/* Volume bridge */
.volume-bridge-visual {
  min-height: 88px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}

.volume-bridge-visual::before,
.volume-bridge-visual::after {
  content: "";
  width: 48px;
  height: 8px;
  border-radius: 4px;
  background: rgba(201, 135, 120, 0.35);
}

.volume-bridge-visual::after {
  width: 64px;
  background: rgba(168, 191, 166, 0.45);
  opacity: 0;
  transition: opacity 0.6s ease;
}

.volume-bridge--built::after {
  opacity: 1;
  box-shadow: 0 0 12px rgba(168, 191, 166, 0.3);
}

/* Reentry tunnel */
.reentry-tunnel-visual {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
}

.reentry-door {
  flex: 1;
  height: 48px;
  border-radius: var(--radius-sm);
  background: rgba(245, 239, 230, 0.08);
  opacity: 0.35;
  transition: opacity 0.5s ease, box-shadow 0.5s ease;
}

.reentry-tunnel--open .reentry-door.is-open {
  opacity: 1;
  background: rgba(196, 163, 90, 0.25);
  box-shadow: 0 0 16px var(--lavender-glow);
}

/* Debris sweep */
.debris-sweep-visual {
  min-height: 88px;
}

.debris-sweep-visual::after {
  content: "Not useful for repair";
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lc-warn);
  opacity: 0;
  transition: opacity 0.6s ease;
}

.debris-sweep--swept::after {
  opacity: 1;
}

/* Shame peel */
.shame-peel-visual {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shame-peel-visual::before {
  content: "label";
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 10px 18px;
  border: 1px solid rgba(201, 135, 120, 0.45);
  border-radius: var(--radius-sm);
  color: var(--lc-warn);
  transition: transform 0.8s ease, opacity 0.6s ease;
}

.shame-peel--peeled::before {
  transform: translateY(24px) rotate(8deg);
  opacity: 0.25;
}

/* Quiet seal */
.quiet-seal-visual {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quiet-seal-visual::before {
  content: "THE DIGITAL DEMAND IS HELD";
  font-size: var(--text-2xs);
  letter-spacing: 0.12em;
  padding: 10px 14px;
  border: 2px solid rgba(124, 157, 170, 0.35);
  border-radius: 999px;
  color: var(--lavender);
  opacity: 0.5;
  transition: opacity 0.6s ease, border-color 0.6s ease;
}

.quiet-seal--sealed::before {
  opacity: 1;
  border-color: var(--lc-soft);
  box-shadow: 0 0 20px rgba(168, 191, 166, 0.2);
}

/* Return door */
.return-door-visual {
  min-height: 88px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px;
}

.return-door-visual::before,
.return-door-visual::after {
  content: "";
  border-radius: var(--radius-sm);
  background: rgba(245, 239, 230, 0.08);
  opacity: 0.35;
}

.return-door--opening {
  box-shadow: inset 0 0 40px rgba(124, 157, 170, 0.15);
}

.return-door--opening::before {
  opacity: 1;
  background: rgba(124, 157, 170, 0.2);
}

.airlock-build,
.airlock-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto 16px;
}

.airlock-field__label {
  font-size: var(--text-sm);
  color: var(--muted);
}

.mark-sentence {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 500;
  font-style: italic;
  color: var(--lavender);
  margin: 0 0 16px;
  line-height: 1.35;
}

.transform-count--revealing {
  animation: transform-count-in 0.85s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes transform-count-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.receipt-card--revealing {
  animation: receipt-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes receipt-rise {
  from { opacity: 0; transform: translateY(16px); filter: brightness(0.7); }
  to { opacity: 1; transform: translateY(0); filter: brightness(1); }
}

.close-hero--ceremony .close-hero__icon {
  animation: close-moon-rise 1.2s ease both;
}

@keyframes close-moon-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.container-zone--pulse {
  animation: container-pulse 0.9s ease both;
}

@keyframes container-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(124, 157, 170, 0); }
  50% { box-shadow: 0 0 24px rgba(124, 157, 170, 0.25); }
}

.card-birth-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  pointer-events: none;
  overflow: hidden;
}

.card-birth__flyer {
  position: absolute;
  left: var(--ox);
  top: var(--oy);
  transform: translate(-50%, -50%);
  animation: card-leave-head 1s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i) * 70ms);
}

@keyframes card-leave-head {
  to {
    transform: translate(calc(-50% + var(--dx, 40px)), calc(-50% + var(--dy, -120px)));
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ping-gate-visual::before,
  .card-birth__flyer {
    animation: none !important;
  }
}

/* Arrive card readability cleanup */
.screen--arrive .deck-card__capacity,
.screen--arrive .capacity-meters,
.screen--arrive .capacity-meter {
  display: none !important;
}

.screen--arrive .deck-grid--rides .deck-card__body {
  gap: 0.5rem;
}

.screen--arrive .deck-grid--rides .deck-card__route {
  line-height: 1.5;
  display: block;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ---- The Shrinking Room: structural shrink ----
 * data-shrink is the step index in the current room flow. Higher means
 * the interface has shed secondary elements — controls, hints, folds —
 * while primary text and actions stay readable and reachable. */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

body[data-shrink="1"] .screen__signature,
body[data-shrink="2"] .screen__signature,
body[data-shrink="2"] .screen__hint.step-truth,
body[data-shrink="2"] #dump-capacity,
body[data-shrink="2"] #dump-presets,
body[data-shrink="3"] .screen__hint,
body[data-shrink="3"] .screen__signature,
body[data-shrink="3"] .optional-fold,
body[data-shrink="3"] #dump-capacity,
body[data-shrink="4"] .screen__hint,
body[data-shrink="4"] .screen__tagline,
body[data-shrink="4"] .screen__signature,
body[data-shrink="4"] .optional-fold,
body[data-shrink="4"] .step-truth {
  display: none !important;
}

body[data-shrink="3"] .screen__hero,
body[data-shrink="4"] .screen__hero {
  padding-bottom: 0.25rem;
  margin-bottom: 0.5rem;
}

/* Functional text floor — low-capacity UI never drops required
 * controls or body text below a readable size. */
body.os-low-capacity .guided-chip,
body.os-low-capacity .door-card__label,
body.os-low-capacity .btn-primary,
body.os-low-capacity .btn-secondary,
body.os-low-capacity .btn-ghost,
body.os-low-capacity .dump-input,
body.os-low-capacity .add-card-input,
body.os-low-capacity .quiet-card p,
body.os-low-capacity .screen__hint {
  font-size: max(14px, 1em);
}

/* hidden must win over display rules — density folds rely on it. */
body.os-low-capacity [hidden] {
  display: none !important;
}
