*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #050607;
  --ink: #e8e6e0;
  --chrome: #c8c4bc;
  --muted: rgba(200, 196, 188, 0.42);
  --dim: rgba(180, 176, 168, 0.55);
  --move: cubic-bezier(0.25, 0.85, 0.3, 1);
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  /* Typo-Skala: 11 / 13 / 21 / 34 */
  --t-11: 11px;
  --t-13: 13px;
  --t-21: 21px;
  --t-34: 34px;
  --werk: #3bdab6;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--chrome);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: fixed;
  inset: 0;
}

#viewport {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  cursor: pointer;
  touch-action: none;
}

body[data-phase="room"] #viewport,
body[data-phase="open"] #viewport,
body[data-phase="archiv"] #viewport {
  cursor: default;
}

.poster-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  display: block;
  background: var(--bg);
}

.poster-fallback[hidden] {
  display: none;
}

.fail-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 12;
  max-width: min(36rem, 88vw);
  padding: 1.4rem 1.6rem;
  background: rgba(8, 9, 10, 0.92);
  border: 1px solid rgba(200, 196, 188, 0.22);
  color: var(--ink);
  text-align: center;
  font-size: var(--t-13);
  letter-spacing: 0.04em;
  line-height: 1.55;
}

.fail-banner[hidden] {
  display: none;
}

.fail-banner strong {
  display: block;
  font-size: var(--t-21);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 0.55rem;
}

.chrome {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.label {
  position: absolute;
  top: 1.15rem;
  left: 1.25rem;
  font-size: var(--t-11);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(200, 196, 188, 0.48);
}

.label b {
  color: rgba(220, 216, 208, 0.86);
  font-weight: 500;
}

.telemetry {
  position: absolute;
  top: 1.15rem;
  right: 1.25rem;
  font-family: var(--mono);
  font-size: var(--t-11);
  letter-spacing: 0.04em;
  color: rgba(180, 190, 188, 0.42);
}

.telemetry[hidden] {
  display: none;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 7.5vh;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: #4a4844;
  text-align: center;
  line-height: 1.55;
  transition: opacity 140ms steps(2, end);
}

.hint[hidden] {
  opacity: 0;
}

.osd {
  position: absolute;
  top: 16%;
  right: 11%;
  font-family: var(--mono);
  font-size: clamp(13px, 2vw, 21px);
  letter-spacing: 0.14em;
  color: rgba(210, 240, 225, 0.9);
  text-shadow: 0 0 14px rgba(100, 200, 170, 0.22);
  transition: opacity 120ms steps(2, end);
}

.osd[hidden] {
  opacity: 0;
}

.osd.searching {
  opacity: 1;
}

/* EPG — dünne Unterzeile, 2 s nach Zap */
.epg {
  position: absolute;
  left: 50%;
  bottom: 3.2vh;
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  max-width: min(52rem, 92vw);
  padding: 0.45rem 0.9rem;
  background: rgba(6, 7, 8, 0.72);
  border-top: 1px solid rgba(200, 196, 188, 0.12);
  font-family: var(--mono);
  font-size: var(--t-11);
  letter-spacing: 0.08em;
  color: rgba(200, 196, 188, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 160ms steps(2, end);
}

.epg:not([hidden]) {
  opacity: 1;
}

.epg[hidden] {
  display: flex;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.epg-now {
  color: rgba(230, 228, 222, 0.92);
}

.epg-sep {
  color: rgba(200, 196, 188, 0.28);
}

.epg-next {
  color: rgba(180, 176, 168, 0.55);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Detail — clean chrome, §4b */
.detail {
  position: fixed;
  left: clamp(20px, 4vw, 56px);
  bottom: clamp(24px, 5vh, 64px);
  z-index: 6;
  max-width: min(42ch, 52vw);
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 650ms var(--move),
    transform 650ms var(--move);
}

.detail:not([hidden]) {
  opacity: 1;
  transform: translateY(0);
}

.detail[hidden] {
  display: block;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

body[data-phase="open"] .detail:not([hidden]) {
  visibility: visible;
}

.detail::before {
  content: "";
  position: absolute;
  inset: -40% -30% -20% -20%;
  background: radial-gradient(
    ellipse 70% 60% at 20% 80%,
    color-mix(in srgb, var(--werk) 14%, transparent),
    transparent 70%
  );
  pointer-events: none;
  z-index: -1;
}

.detail-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 0.5rem;
}

.detail-title {
  font-size: clamp(var(--t-21), 3.2vw, var(--t-34));
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.15;
  margin-bottom: 0.6rem;
}

.detail-meta {
  font-family: var(--mono);
  font-size: var(--t-11);
  letter-spacing: 0.08em;
  color: rgba(200, 196, 188, 0.62);
  line-height: 1.45;
}

.detail-esc {
  margin-top: 1rem;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

kbd {
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid rgba(200, 196, 188, 0.28);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--chrome);
}

/* Teletext — halbtransparent über Werk */
.teletext {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: transparent;
}

.teletext[hidden] {
  display: none;
}

.tt-inner {
  width: min(42rem, 88vw);
  aspect-ratio: 4 / 3;
  max-height: min(72vh, 32rem);
  background: rgba(18, 14, 10, 0.78);
  border: 1px solid rgba(232, 220, 195, 0.18);
  color: #e8dcc3;
  font-family: var(--mono);
  display: flex;
  flex-direction: column;
  padding: 0.85rem 1rem 0.7rem;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.tt-head {
  display: flex;
  justify-content: space-between;
  font-size: var(--t-11);
  letter-spacing: 0.12em;
  color: #d9a44a;
  border-bottom: 1px solid rgba(232, 220, 195, 0.16);
  padding-bottom: 0.45rem;
  margin-bottom: 0.7rem;
}

.tt-body {
  flex: 1;
  font-size: clamp(11px, 1.35vw, 13px);
  line-height: 1.55;
  letter-spacing: 0.04em;
  white-space: pre-wrap;
  color: #e8dcc3;
  overflow: hidden;
}

.tt-foot {
  margin-top: 0.55rem;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a7f6d;
}

/* Archiv-Portal Overlay */
.archiv-overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
  background:
    radial-gradient(ellipse 55% 40% at 50% 45%, rgba(40, 34, 28, 0.55), transparent 70%),
    rgba(5, 6, 7, 0.28);
  opacity: 0;
  transition: opacity 650ms var(--move);
}

.archiv-overlay:not([hidden]) {
  opacity: 1;
}

.archiv-overlay[hidden] {
  display: grid;
  opacity: 0;
  visibility: hidden;
}

body[data-phase="archiv"] .archiv-overlay:not([hidden]) {
  visibility: visible;
}

.archiv-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.28em;
  color: rgba(200, 196, 188, 0.45);
  margin-bottom: 0.7rem;
}

.archiv-title {
  font-size: clamp(var(--t-21), 4vw, var(--t-34));
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--ink);
  margin-bottom: 0.75rem;
}

.archiv-meta {
  font-family: var(--mono);
  font-size: var(--t-11);
  letter-spacing: 0.12em;
  color: rgba(200, 196, 188, 0.5);
}

.sr-only {
  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-phase="boot"] .label,
body[data-phase="power"] .label {
  opacity: 0.35;
}

body[data-phase="open"] .hint,
body[data-phase="archiv"] .hint {
  opacity: 0;
}

body[data-phase="open"] .label,
body[data-phase="archiv"] .label {
  opacity: 0.28;
}

@media (max-width: 760px) {
  .detail {
    max-width: calc(100vw - 40px);
    bottom: 18px;
  }

  .hint {
    bottom: 9vh;
    font-size: 9px;
    max-width: 88vw;
  }

  .osd {
    right: 6%;
    top: 12%;
  }

  .epg {
    bottom: 2vh;
    font-size: 10px;
  }

  .tt-inner {
    max-height: 64vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .detail,
  .hint,
  .osd,
  .epg,
  .archiv-overlay {
    transition: none;
  }
}
