﻿@font-face {
  font-family: 'MirrorFont';
  src: url('/media/assets/fonts/font.otf') format('opentype');
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #f0eee8;
  --muted: #9a9488;
  --line: rgba(240, 238, 232, 0.14);
  --panel: #171714;
  --paper: #e8e0cf;
  --paper-ink: #25231f;
  --accent: #b6a36f;
  --accent-2: #9bb3a1;
  --danger: #b86c5f;
  --bg: #0d0d0b;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "MirrorFont", "Aptos", "Segoe UI", "Microsoft YaHei", sans-serif;
  overflow: hidden;
}

button, input { font: inherit; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, calc(100vh * 9 / 16)) minmax(380px, 1fr);
  background: var(--bg);
}

.stage {
  height: 100vh;
  padding: clamp(14px, 2vw, 26px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  border-right: 1px solid var(--line);
}

.stage-frame {
  position: relative;
  height: 100%;
  aspect-ratio: 9 / 16;
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  background: #050504;
  border: 1px solid rgba(232, 224, 207, 0.18);
}

.stage-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,0.28), transparent 28%, transparent 64%, rgba(0,0,0,0.55));
}

.stage-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 520ms cubic-bezier(.22, 1, .36, 1);
  background: #050504;
}

.stage-video.is-active { opacity: 1; }

.stage-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(240,238,232,.72);
  background:
    linear-gradient(135deg, rgba(182,163,111,.1), transparent 42%),
    #0b0b09;
  letter-spacing: .16em;
  font-size: 12px;
}

.stage-fallback.is-hidden { display: none; }

.stage-overlay {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 2;
  padding: 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.stage-overlay p {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.stage-overlay h1 {
  max-width: 11em;
  margin: 0;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.04;
  font-weight: 500;
  letter-spacing: 0;
}

.stage-meta {
  display: grid;
  gap: 6px;
  justify-items: end;
  flex: none;
}

.stage-meta span {
  border: 1px solid rgba(240,238,232,.22);
  padding: 5px 8px;
  color: rgba(240,238,232,.82);
  font-size: 12px;
  background: rgba(8,8,7,.45);
}

.transport {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.transport button,
.segmented button,
.element-grid button,
.phase-stack button {
  min-height: 42px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.transport button:hover,
.segmented button:hover,
.element-grid button:hover,
.phase-stack button:hover {
  border-color: rgba(240,238,232,.36);
  transform: translateY(-1px);
}

.transport .primary,
button.is-active {
  background: var(--paper);
  color: var(--paper-ink);
  border-color: var(--paper);
}

.volume-control {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.volume-control input { width: 100%; accent-color: var(--accent); }

.panel {
  min-width: 0;
  height: 100vh;
  overflow: auto;
  padding: clamp(24px, 4vw, 54px);
  background:
    linear-gradient(90deg, rgba(182,163,111,.07), transparent 22%),
    var(--panel);
}

.panel-header {
  margin-bottom: clamp(26px, 5vh, 54px);
}

.panel-header p {
  margin: 0 0 12px;
  color: var(--accent);
  letter-spacing: .2em;
  text-transform: uppercase;
  font-size: 12px;
}

.panel-header h2 {
  margin: 0;
  font-size: clamp(34px, 5vw, 72px);
  line-height: .95;
  font-weight: 500;
  letter-spacing: 0;
}

.control-group {
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.control-group.slim { padding-bottom: 28px; }

.group-title {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  color: var(--ink);
  font-size: 15px;
}

.group-title span {
  color: var(--muted);
  font-size: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.segmented.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.element-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.element-grid button {
  min-height: 72px;
  display: grid;
  place-items: center;
}

.element-grid small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

button.is-active small { color: rgba(37,35,31,.62); }

.phase-stack {
  display: grid;
  gap: 8px;
}

.phase-stack button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  text-align: left;
}

.phase-stack span { color: var(--muted); font-size: 12px; }
button.is-active span { color: rgba(37,35,31,.62); }

.slider-row {
  display: grid;
  grid-template-columns: 52px 1fr 42px;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
  color: var(--muted);
}

.slider-row input { width: 100%; accent-color: var(--accent-2); }
.slider-row b { color: var(--ink); font-weight: 500; text-align: right; }

.state-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.state-readout div {
  min-width: 0;
  border: 1px solid var(--line);
  padding: 14px;
  background: rgba(255,255,255,.025);
}

.state-readout span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.state-readout strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--ink);
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .shell { grid-template-columns: 1fr; }
  .stage, .panel { height: auto; min-height: 100vh; }
  .stage-frame { height: min(72vh, 760px); }
  .panel { min-height: auto; }
}

button:disabled {
  cursor: not-allowed;
  color: rgba(240, 238, 232, 0.28);
  border-color: rgba(240, 238, 232, 0.07);
  background: rgba(255, 255, 255, 0.015);
  transform: none;
}

button:disabled small {
  color: rgba(240, 238, 232, 0.2);
}

[hidden] { display: none !important; }

.spaced { margin-top: 10px; }

.wait-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  max-width: 28em;
}

.subtitle-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 820ms cubic-bezier(.22, 1, .36, 1);
  color: rgba(248, 246, 240, .96);
  text-shadow: 0 2px 12px rgba(0,0,0,.55), 0 0 1px rgba(255,255,255,.35);
}

.subtitle-layer.is-visible { opacity: 1; }

.subtitle-layer.is-centered {
  display: grid;
  place-items: center;
  padding: 11%;
  background: rgba(0,0,0,.18);
}

.subtitle-layer.is-centered .subtitle-body {
  display: grid;
  gap: .56em;
  text-align: center;
  font-size: clamp(18px, 2.2vw, 30px);
  line-height: 1.35;
  letter-spacing: .08em;
}

.subtitle-layer.is-guide {
  padding: 11% 9%;
}

.subtitle-layer.is-guide .subtitle-body {
  display: grid;
  gap: .5em;
  max-width: 13em;
  font-size: clamp(17px, 1.8vw, 24px);
  line-height: 1.55;
  letter-spacing: .06em;
}

.subtitle-layer.is-complex .subtitle-title {
  position: absolute;
  top: 8%;
  left: 10%;
  font-size: clamp(88px, 13vw, 176px);
  line-height: .9;
  font-weight: 300;
  letter-spacing: .02em;
  color: rgba(255,255,255,.9);
  filter: drop-shadow(0 0 18px rgba(255,255,255,.16));
}

.subtitle-layer.is-complex .subtitle-title::after {
  content: "";
  position: absolute;
  inset: 13% -8% -6% -10%;
  background-image: radial-gradient(circle, rgba(255,255,255,.55) 0 1px, transparent 1.7px);
  background-size: 17px 17px;
  opacity: .28;
  animation: particle-breathe 4.8s ease-in-out infinite;
}

.subtitle-layer.is-complex .subtitle-body {
  position: absolute;
  right: 8%;
  bottom: 14%;
  display: grid;
  gap: .45em;
  text-align: right;
  font-size: clamp(15px, 1.55vw, 22px);
  line-height: 1.56;
  letter-spacing: .05em;
}

.subtitle-body span {
  display: block;
}

@keyframes particle-breathe {
  0%, 100% { transform: translate3d(0,0,0) scale(1); opacity: .18; }
  50% { transform: translate3d(2px,-3px,0) scale(1.025); opacity: .36; }
}

body.is-running .stage-overlay {
  opacity: .42;
  transition: opacity 360ms ease;
}

body.is-running .stage-overlay h1 {
  font-size: clamp(18px, 1.8vw, 24px);
  max-width: 12em;
}

/* Proportional subtitle scaling: original layout is 1080x1920, so text follows the video frame width. */
.stage-frame { container-type: inline-size; }

.subtitle-layer.is-centered .subtitle-body {
  font-size: clamp(12px, 3.25cqw, 22px);
  gap: .48em;
}

.subtitle-layer.is-guide .subtitle-body {
  font-size: clamp(12px, 3.45cqw, 21px);
}

.subtitle-layer.is-complex .subtitle-title {
  font-size: clamp(52px, 16.7cqw, 120px);
}

.subtitle-layer.is-complex .subtitle-body {
  font-size: clamp(12px, 3.9cqw, 20px);
}

.slider-row input:disabled {
  opacity: .36;
  cursor: not-allowed;
}

/* Keep playback internals off screen; the right panel now only exposes interaction inputs. */
.stage-overlay,
.state-readout {
  display: none;
}

/* All narrative text appears in the video center with the same fade-in/fade-out treatment. */
.subtitle-layer,
.subtitle-layer.is-centered,
.subtitle-layer.is-guide,
.subtitle-layer.is-complex {
  display: grid;
  grid-template-rows: auto auto;
  align-content: center;
  place-items: center;
  row-gap: .46em;
  padding: 12%;
  background: rgba(0, 0, 0, .12);
}

.subtitle-layer .subtitle-title,
.subtitle-layer.is-complex .subtitle-title {
  position: static;
  margin: 0 0 .46em;
  text-align: center;
  font-size: clamp(30px, 8.4cqw, 64px);
  line-height: 1;
  font-weight: 300;
  letter-spacing: 0;
  color: rgba(248, 246, 240, .95);
  filter: none;
}

.subtitle-layer .subtitle-title:empty {
  display: none;
}

.subtitle-layer.is-complex .subtitle-title::after {
  display: none;
}

.subtitle-layer .subtitle-body,
.subtitle-layer.is-centered .subtitle-body,
.subtitle-layer.is-guide .subtitle-body,
.subtitle-layer.is-complex .subtitle-body {
  position: static;
  display: grid;
  gap: .5em;
  width: min(78%, 18em);
  max-width: 18em;
  margin: 0 auto;
  text-align: center;
  font-size: clamp(13px, 3.45cqw, 22px);
  line-height: 1.48;
  letter-spacing: .04em;
}
