/* Tarsier app styles. Loaded by index.html as /app.css?v=<content hash>;
   server.js injects the hash so the file can be cached for a year. */

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

:root {
  --bg: #0c0f1e;
  --bg-deep: #080a18;
  --surface-1: #16182e;
  --surface-2: #1c1f37;
  --border: rgba(255, 220, 170, 0.08);
  --amber: #e4a853;
  --amber-soft: #f3c479;
  --amber-dim: rgba(228, 168, 83, 0.12);
  --amber-glow: rgba(228, 168, 83, 0.18);
  --coral: #f4a682;
  --cream: #f0ece4;
  --text-1: #f4efe5;
  --text-2: #8c8aa1;
  --text-3: #5a5a78;
  --success: #6cc995;
  --danger: #e07a7a;
  --btn-primary-text: #1a0f00;
  --r-card: 24px;
  --r-button: 999px;
}

html, body, main {
  height: 100%;
  background: var(--bg);
  color: var(--text-1);
  font-family: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  font-feature-settings: 'ss01' on, 'ss02' on;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  letter-spacing: -0.005em;
}

/* Warm ambient gradient: dark room lit by a single amber lamp */
body {
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(228,168,83,0.06) 0%, transparent 55%),
    radial-gradient(ellipse 80% 70% at 80% 110%, rgba(244,166,130,0.04) 0%, transparent 60%),
    var(--bg-deep);
  background-attachment: fixed;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  contain: style;
  position: relative;
}
#screen-home {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; }

/* Eyes pair */
.eyes-pair {
  display: flex;
  gap: 16px;
  align-items: center;
}

/* Eye mark */
.eye-mark {
  width: 74px;
  height: 84px;
  border-radius: 50%;
  border: 2px solid var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  -webkit-transform: translateZ(0);
  background: radial-gradient(circle at 35% 30%, #8a5e1c 0%, #5a3f15 100%);
  box-shadow: 0 0 24px -6px rgba(228, 168, 83, 0.25);
}
.eyes-pair .eye-mark:first-child { transform: rotate(-6deg); }
.eyes-pair .eye-mark:last-child { transform: rotate(6deg); }
.eye-mark-lg {
  width: 100px;
  height: 114px;
  border-width: 2px;
}
.eye-mark-pupil {
  width: 30px;
  height: 34px;
  border-radius: 50%;
  background: var(--amber);
  transition: transform 0.15s ease-out, width 1s cubic-bezier(0.25, 0.1, 0.25, 1), height 1s cubic-bezier(0.25, 0.1, 0.25, 1);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.eye-mark-inner {
  width: 8px;
  height: 9px;
  background: #1a0e00;
  border-radius: 50%;
  transition: transform 0.12s ease-out, width 1.2s cubic-bezier(0.25, 0.1, 0.25, 1), height 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  position: absolute;
}
.eye-mark-pupil.dilated {
  width: 58px;
  height: 66px;
}
.eye-mark-pupil.dilated .eye-mark-inner {
  width: 48px;
  height: 54px;
}
.eye-mark-pupil::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 7px;
  background: rgba(255,255,255,0.5);
  border-radius: 50%;
  top: 5px;
  right: 5px;
}
.eye-mark-lg .eye-mark-pupil {
  width: 40px;
  height: 48px;
}
.eye-mark-lg .eye-mark-inner {
  width: 10px;
  height: 12px;
}
.eye-mark-lg .eye-mark-pupil.dilated {
  width: 82px;
  height: 94px;
}
.eye-mark-lg .eye-mark-pupil.dilated .eye-mark-inner {
  width: 68px;
  height: 78px;
}
.eye-mark-lg .eye-mark-pupil::after {
  width: 8px;
  height: 9px;
  top: 7px;
  right: 7px;
}
@keyframes watch-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.94); }
}
.eye-mark.watching,
.eyes-pair.watching {
  animation: watch-pulse 3s ease-in-out infinite;
}

/* Friendly wink on load — left eye blinks ~1.6s after entry */
@keyframes wink-left {
  0%, 14%, 100% { transform: rotate(-6deg) scaleY(1); }
  6%, 9% { transform: rotate(-6deg) scaleY(0.08); }
}
.eyes-pair.greet .eye-mark:first-child {
  animation: wink-left 2.4s ease-in-out 1.6s 1 both;
  transform-origin: center;
}
@media (prefers-reduced-motion: reduce) {
  .eyes-pair.greet .eye-mark:first-child { animation: none; transform: rotate(-6deg); }
}

/* Typography — Bricolage Grotesque variable */
.display-text {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: -0.015em;
}
.display-text-sm {
  font-size: 22px;
  font-weight: 500;
}
.mono-text {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 400;
}

/* === Friendly display scale === */
.display-xl {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: clamp(52px, 14vw, 92px);
  line-height: 0.92;
  letter-spacing: -0.035em;
  color: var(--text-1);
  font-variation-settings: 'wdth' 100;
}
.display-lg {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: clamp(38px, 10vw, 64px);
  line-height: 0.96;
  letter-spacing: -0.028em;
  color: var(--text-1);
}
.display-md {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600;
  font-size: clamp(24px, 6vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.018em;
  color: var(--text-1);
}
.display-xl em, .display-lg em, .display-md em {
  font-style: normal;
  color: var(--amber);
}
.display-xl .wink, .display-lg .wink {
  display: inline-block;
  color: var(--amber);
}

/* Kicker — small mono label, friendlier */
.kicker {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.kicker::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--amber);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--amber-glow);
}

/* Wavy underline rule — friendly motif */
.wave-rule {
  display: inline-block;
  width: 64px;
  height: 10px;
  color: var(--amber);
  opacity: 0.75;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 10' fill='none' stroke='%23e4a853' stroke-width='2' stroke-linecap='round'><path d='M2 5 Q 10 1 18 5 T 34 5 T 50 5 T 62 5'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
.wave-rule-center { margin-left: auto; margin-right: auto; display: block; }
.wave-rule-coral {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 10' fill='none' stroke='%23f4a682' stroke-width='2' stroke-linecap='round'><path d='M2 5 Q 10 1 18 5 T 34 5 T 50 5 T 62 5'/></svg>");
}
.wave-rule-danger {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 10' fill='none' stroke='%23e07a7a' stroke-width='2' stroke-linecap='round'><path d='M2 5 Q 10 1 18 5 T 34 5 T 50 5 T 62 5'/></svg>");
}

/* Keep .hairline as legacy alias so any unswapped instance still renders */
.hairline {
  display: inline-block;
  width: 64px;
  height: 10px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 10' fill='none' stroke='%23e4a853' stroke-width='2' stroke-linecap='round'><path d='M2 5 Q 10 1 18 5 T 34 5 T 50 5 T 62 5'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.75;
}
.hairline-center { margin-left: auto; margin-right: auto; display: block; }

/* Hero mark halo — warm amber atmosphere behind the eyes */
.hero-halo {
  position: relative;
  display: inline-flex;
  isolation: isolate;
}
.hero-halo::before {
  content: '';
  position: absolute;
  inset: -130%;
  background:
    radial-gradient(circle at 38% 42%,
      rgba(228, 168, 83, 0.22) 0%,
      rgba(228, 168, 83, 0.07) 22%,
      transparent 52%),
    radial-gradient(circle at 70% 65%,
      rgba(244, 166, 130, 0.10) 0%,
      transparent 38%);
  z-index: -1;
  pointer-events: none;
  animation: halo-breathe 6s ease-in-out infinite;
  border-radius: 50%;
  filter: blur(2px);
}
@keyframes halo-breathe {
  0%, 100% { opacity: 0.7; transform: scale(0.94); }
  50% { opacity: 1; transform: scale(1.08); }
}

/* Friendly pill primary — Show button */
.btn-pill-primary {
  background: var(--amber);
  background-image: linear-gradient(180deg, var(--amber-soft) 0%, var(--amber) 100%);
  color: var(--btn-primary-text);
  border-radius: var(--r-button);
  padding: 18px 36px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: none;
  cursor: pointer;
  width: 100%;
  max-width: 340px;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s, filter 0.2s;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 0 0 0 rgba(228, 168, 83, 0),
    0 20px 50px -18px rgba(228, 168, 83, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-pill-primary:hover {
  box-shadow:
    0 0 0 6px rgba(228, 168, 83, 0.08),
    0 24px 60px -16px rgba(228, 168, 83, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  filter: brightness(1.04);
}
.btn-pill-primary:active { transform: scale(0.97); }

/* Friendly pill ghost — Watch button */
.btn-pill-ghost {
  background: var(--surface-1);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: var(--r-button);
  padding: 17px 36px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  width: 100%;
  max-width: 340px;
  transition: border-color 0.3s, background 0.3s, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
}
.btn-pill-ghost:hover { border-color: rgba(228, 168, 83, 0.4); background: var(--surface-2); }
.btn-pill-ghost:active { transform: scale(0.97); background: var(--surface-2); }

/* Editorial layout column — narrow, breathing, can be left-aligned or centered */
.editorial-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

/* Atmospheric body grain — Halide-tactile, very subtle */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 240 240' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.9 0 0 0 0 0.85 0 0 0 0 0.7 0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* Soft organic blob ornament — sits behind hero content */
.screen.hero-screen::before {
  content: '';
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translate(-50%, 0);
  width: min(560px, 110vw);
  aspect-ratio: 1.1;
  background:
    radial-gradient(circle at 35% 38%,
      rgba(228, 168, 83, 0.10) 0%,
      rgba(228, 168, 83, 0.04) 30%,
      transparent 62%),
    radial-gradient(circle at 70% 70%,
      rgba(244, 166, 130, 0.06) 0%,
      transparent 50%);
  filter: blur(36px);
  pointer-events: none;
  z-index: 0;
  border-radius: 47% 53% 56% 44% / 51% 48% 52% 49%;
  animation: blob-drift 18s ease-in-out infinite;
}
@keyframes blob-drift {
  0%, 100% { transform: translate(-50%, 0) rotate(0deg) scale(1); }
  33% { transform: translate(-46%, -2%) rotate(-3deg) scale(1.04); }
  66% { transform: translate(-54%, 1%) rotate(2deg) scale(0.98); }
}
.screen.hero-screen > * { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) {
  .screen.hero-screen::before { animation: none; }
}

/* Entrance choreography for hero compositions */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.screen.active .stagger > * {
  opacity: 0;
  animation: rise-in 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.screen.active .stagger > *:nth-child(1) { animation-delay: 0.05s; }
.screen.active .stagger > *:nth-child(2) { animation-delay: 0.18s; }
.screen.active .stagger > *:nth-child(3) { animation-delay: 0.30s; }
.screen.active .stagger > *:nth-child(4) { animation-delay: 0.42s; }
.screen.active .stagger > *:nth-child(5) { animation-delay: 0.54s; }
.screen.active .stagger > *:nth-child(6) { animation-delay: 0.64s; }
.screen.active .stagger > *:nth-child(7) { animation-delay: 0.72s; }
.screen.active .stagger > *:nth-child(8) { animation-delay: 0.80s; }
@media (prefers-reduced-motion: reduce) {
  .screen.active .stagger > * { animation: none; opacity: 1; }
  .hero-halo::before { animation: none; }
}

/* Buttons */
.btn-primary {
  background: var(--amber);
  color: var(--btn-primary-text);
  border-radius: var(--r-button);
  padding: 14px 28px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: none;
  cursor: pointer;
  width: 100%;
  max-width: 320px;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), filter 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { transform: scale(0.97); filter: brightness(0.95); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r-button);
  padding: 14px 28px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  max-width: 320px;
  transition: border-color 0.2s, color 0.2s, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
}
.btn-ghost:active { border-color: rgba(228, 168, 83, 0.3); color: var(--text-1); transform: scale(0.97); }

.btn-role {
  background: var(--surface-1);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 20px 24px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  max-width: 320px;
  text-align: left;
  transition: border-color 0.2s, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
}
.btn-role:active { border-color: rgba(228, 168, 83, 0.3); transform: scale(0.99); }
.btn-role .btn-sub {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-2);
  margin-top: 4px;
}

.back-link {
  color: var(--text-3);
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  background: none;
  border: none;
  padding: 10px 14px;
  border-radius: 999px;
  transition: color 0.2s, background 0.2s;
}
.back-link:hover { color: var(--text-1); background: var(--surface-1); }
.back-link:active { color: var(--amber); }

/* Video */
.video-container {
  position: relative;
  width: 100%;
  max-width: 480px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface-1);
}
.video-container video {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: #000;
}
.video-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.3) 100%);
  pointer-events: none;
  border-radius: 16px;
}

/* Status dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.amber { background: var(--amber); }
.status-dot.green { background: var(--success); }
@keyframes pulse-slow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes pulse-fast {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.status-dot.pulsing { animation: pulse-slow 2s ease-in-out infinite; }
.status-dot.pulsing-fast { animation: pulse-fast 0.8s ease-in-out infinite; }

/* Controls */
.controls-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin-top: 16px;
}
.ctrl-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.ctrl-btn.active {
  color: var(--amber);
  border-color: rgba(228, 168, 83, 0.35);
  background: var(--amber-dim);
}
.ctrl-btn svg { width: 20px; height: 20px; }

.ctrl-btn-lg {
  width: 60px;
  height: 60px;
  border-radius: 20px;
}
.ctrl-btn-lg.active {
  box-shadow:
    0 0 0 1px rgba(228, 168, 83, 0.18),
    0 14px 40px -10px rgba(228, 168, 83, 0.35);
}
.ctrl-btn-lg svg { width: 24px; height: 24px; }

/* URL display */
.url-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  max-width: 480px;
  width: 100%;
}
.url-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  color: var(--text-1);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
}
.url-copy-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.url-copy-btn svg { width: 18px; height: 18px; }
.url-copy-btn.copied { color: var(--success); }

/* Audio visualiser */
.audio-viz {
  height: 32px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  justify-content: center;
}
.audio-viz canvas {
  border-radius: 4px;
}

/* Viewer badge */
.viewer-badge {
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Info text */
.info-text {
  font-size: 15px;
  color: var(--text-2);
  text-align: center;
  line-height: 1.5;
}
.info-text-sm {
  font-size: 13px;
  color: var(--text-2);
  text-align: center;
  line-height: 1.6;
}

/* Wake lock indicator */
.wake-indicator {
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
}
.wake-indicator.active { color: var(--text-2); }
.wake-indicator svg { width: 14px; height: 14px; }

/* Dim overlay */
#dim-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s, background-color 0.4s ease;
  z-index: 100;
}
#dim-overlay.active { pointer-events: auto; }
#dim-overlay.level-1 { background-color: #000;            opacity: 0.94; } /* full dim */
#dim-overlay.level-2 { background-color: rgb(38, 18, 0);  opacity: 0.96; } /* night low */
#dim-overlay.level-3 { background-color: rgb(118, 64, 18); opacity: 0.92; } /* night med */
#dim-overlay.level-4 { background-color: rgb(200, 124, 50); opacity: 0.88; } /* night high */

/* Viewer live overlay */
.viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 24, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  gap: 16px;
  padding: 24px;
}

/* Viewer controls */
.viewer-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  z-index: 10;
  flex-shrink: 0;
}
.viewer-status-text {
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
  min-height: 16px;
  transition: opacity 0.3s;
}

/* In-room tip */
.in-room-tip {
  background: var(--surface-1);
  border: 1px solid rgba(244, 166, 130, 0.18);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  z-index: 20;
  white-space: nowrap;
  transition: opacity 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.in-room-tip::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--coral);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(244,166,130,0.5);
}

/* Fullscreen styles */
#remote-video-wrapper:-webkit-full-screen,
#remote-video-wrapper:fullscreen {
  width: 100vw;
  height: 100vh;
  background: #000;
}
#remote-video:-webkit-full-screen,
#remote-video:fullscreen {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
}

/* Night mode */

/* Enhance mode */
.enhance video { filter: brightness(1.6) contrast(1.3) saturate(0.9); }

/* Monitor status bar */
.monitor-status {
  position: absolute;
  top: 12px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
  pointer-events: none;
}

/* Trial prompt */
.trial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 24, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  gap: 16px;
  padding: 24px;
}

/* Unsupported banner */
.compat-banner {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  max-width: 320px;
  text-align: center;
}

/* Permission help */
.permission-help {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  max-width: 320px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}

/* Spacers */
.gap-4 { height: 4px; }
.gap-8 { height: 8px; }
.gap-12 { height: 12px; }
.gap-16 { height: 16px; }
.gap-24 { height: 24px; }
.gap-32 { height: 32px; }

/* Waiting animation */
@keyframes breathe {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}
.breathing { animation: breathe 4s ease-in-out infinite; }

/* WiFi reminder */
.wifi-reminder {
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Stop confirm overlay */
.stop-confirm {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
}
.stop-confirm.active { display: flex; }

/* Bedtime story paragraphs (global reset zeros p margins) */
.story p { margin-bottom: 14px; }
.story p:last-child { margin-bottom: 0; }

/* Room code — large, mono, well-spaced (readable from across a room) */
.room-code {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: clamp(28px, 9vw, 44px);
  letter-spacing: 0.32em;
  color: var(--amber);
  line-height: 1;
  text-align: center;
  padding: 4px 0 4px 0.32em; /* compensate for trailing letter-spacing */
}
/* Room code overlay — sits inline next to the lock icon at bottom-left
   of the video preview. Single line, restrained pill. Animates in/out
   by sliding from the lock + fading in. */
.room-code-overlay {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 7px 0;
  pointer-events: none;
  opacity: 0;
  max-width: 0;
  transform: translateX(-6px);
  white-space: nowrap;
  overflow: hidden;
  transition:
    opacity 220ms ease,
    max-width 280ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 240ms cubic-bezier(0.16, 1, 0.3, 1),
    padding 240ms ease,
    border-color 220ms ease;
}
.room-code-overlay.active {
  opacity: 1;
  max-width: 240px;
  padding: 7px 14px 7px 12px;
  border-color: rgba(228,168,83,0.35);
  transform: translateX(0);
}
@media (prefers-reduced-motion: reduce) {
  .room-code-overlay { transition: opacity 120ms linear; transform: none; }
  .room-code-overlay.active { transform: none; }
}
.room-code-overlay .rco-kicker {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-2);
}
.room-code-overlay .rco-digits {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 17px;
  letter-spacing: 0.32em;
  color: var(--amber);
  line-height: 1;
  padding-left: 0.32em; /* compensate trailing letter-spacing */
}
/* Lock button (video overlay variant) — amber tint when locked */
#btn-lock.active {
  color: var(--amber);
  background: rgba(228, 168, 83, 0.25);
}

/* Toast — bottom-anchored, single column, stacks if multiple at once */
#toast-host {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 400;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast {
  background: var(--surface-1);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  box-shadow: 0 20px 48px -16px rgba(0,0,0,0.5);
  pointer-events: auto;
  animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.toast-danger { color: var(--danger); border-color: rgba(224,122,122,0.35); }
.toast.toast-out { animation: toast-out 0.25s ease-in forwards; }
.toast-action {
  margin-left: 14px;
  background: var(--amber);
  color: var(--btn-primary-text);
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast-action:active { transform: scale(0.96); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px); }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}

/* Wavy-underline link — friendly trigger style */
.link-wavy {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-2);
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 15px;
  font-weight: 500;
  padding: 8px 4px 12px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 6' fill='none' stroke='%23e4a853' stroke-width='1.6' stroke-linecap='round'><path d='M2 3 Q 10 0 18 3 T 34 3 T 50 3 T 66 3 T 78 3'/></svg>");
  background-repeat: no-repeat;
  background-position: bottom center;
  background-size: 96px 5px;
  transition: color 0.2s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
}
.link-wavy:hover { color: var(--text-1); }
.link-wavy:active { transform: scale(0.97); }

/* Plain link — for when wavy rules sit around it instead */
.link-plain {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-1);
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
  padding: 6px 12px;
  transition: color 0.2s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
}
.link-plain:hover { color: var(--amber); }
.link-plain:active { transform: scale(0.97); }

/* How-it-works modal */
.story-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 24, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 250;
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
  justify-content: center;
  animation: overlay-fade 0.3s ease-out;
}
.story-overlay[style*="flex"] { display: flex !important; }
.story-card {
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, rgba(228,168,83,0.05) 0%, transparent 70%),
    var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 40px 28px 32px;
  max-width: 460px;
  width: 100%;
  position: relative;
  margin: auto 0;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.6);
  animation: card-rise 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.story-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, color 0.2s;
}
.story-close:hover { background: var(--surface-2); color: var(--text-1); }
.story-close:active { transform: scale(0.94); }
@keyframes overlay-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes card-rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .story-overlay, .story-card { animation: none; }
}

/* gap-20 utility */
.gap-20 { height: 20px; }

/* Focus styles */
*:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* Prevent double-tap zoom on interactive video elements */
video, .ctrl-btn, button { touch-action: manipulation; }

.video-overlay-btn {
  position: absolute;
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.4);
  color: var(--text-1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
}
.video-overlay-btn:active { background: rgba(0,0,0,0.6); }
.video-overlay-btn svg { width: 18px; height: 18px; }
.video-overlay-btn.active { color: var(--amber); }
#btn-dim.active { background: rgba(228,168,83,0.25); color: var(--amber); }
.video-overlay-btn.top-btn { top: max(12px, env(safe-area-inset-top, 12px)); }

/* Hide all screens until the first session probe completes so we can jump
   straight into the watch view if a stream is already on the network. */
body.booting .screen { visibility: hidden; }

/* Monitor HUD layer — fades to nothing after 10s of inactivity */
.monitor-hud-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 350ms ease;
  opacity: 1;
}
.monitor-hud-layer > * { pointer-events: auto; }
.monitor-hud-layer.hud-hidden { opacity: 0; pointer-events: none; }
.monitor-hud-layer.hud-hidden > * { pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .monitor-hud-layer { transition: opacity 120ms linear; }
}

/* === Home: the hero fills the first screen; a short document sits below ===
   #screen-home scrolls. The hero carries the centring so the first viewport
   looks exactly as it did; a centred flex column that overflows would clip
   its top instead. */
#screen-home { justify-content: flex-start; }
#screen-home > * { flex-shrink: 0; }
.home-hero {
  width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.home-more {
  --text-body: #b8b6c8;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 56px;
  padding: 88px 0 40px;
  text-align: left;
}
.home-h2 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.018em;
  color: var(--text-1);
  margin-bottom: 20px;
}
.home-section p,
.home-section li,
.home-section dd {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-body);
}
.home-steps {
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.home-steps li {
  counter-increment: step;
  position: relative;
  padding-left: 28px;
}
.home-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.15em;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-2);
}
.home-steps strong { color: var(--text-1); font-weight: 500; }
.home-note { margin-top: 20px; }
.home-facts {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px 16px;
  margin: 0;
}
.home-facts > div { display: contents; }
.home-facts dt {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: var(--text-2);
  padding-top: 4px;
}
.home-facts dd { margin: 0; }
.home-faq details { border-top: 1px solid var(--border); }
.home-faq details:last-child { border-bottom: 1px solid var(--border); }
.home-faq summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-1);
  -webkit-tap-highlight-color: transparent;
}
.home-faq summary::-webkit-details-marker { display: none; }
.home-faq summary::after {
  content: '+';
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  line-height: 1;
  color: var(--text-2);
  flex-shrink: 0;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s;
}
.home-faq details[open] summary::after { transform: rotate(45deg); color: var(--amber); }
.home-faq summary:hover { color: var(--text-1); }
.home-faq summary:focus-visible { outline: 2px solid var(--amber); outline-offset: 4px; border-radius: 4px; }
.home-faq details p { padding: 0 32px 18px 0; }
.home-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 12px;
  padding: 16px 0 max(24px, env(safe-area-inset-bottom, 24px));
  font-size: 13px;
  color: var(--text-2);
}
.home-footer a { color: var(--text-2); text-decoration: none; transition: color 0.2s; }
.home-footer a:hover,
.home-footer a:focus-visible { color: var(--text-1); }
@media (prefers-reduced-motion: reduce) {
  .home-faq summary::after { transition: none; }
}
