/* ═══════════════════════════════════════════════════════════════════════
   RETRO CRT WORKSTATION — bottom-right, scrolls with the page
   Plays a slideshow of every photo in mark/docs/jpg/ (see tv.js)
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Wrapper (right-aligned machine + robots, in normal flow → scrolls with page) ── */
.tv-zone {
  position: relative;
  max-width: 68em;
  margin: 2em auto 0;
  padding: 0 1em;
}

/* ── Scene ── */
.tv-scene {
  position: relative;
  margin-left: auto;
  width: 340px;
  max-width: 100%;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

/* ── Ambient glow behind the monitor ── */
.tv-glow {
  position: absolute;
  inset: -8% -6%;
  background: radial-gradient(ellipse at center, rgba(176, 140, 255, 0.20), transparent 65%);
  filter: blur(18px);
  z-index: -1;
  pointer-events: none;
  animation: tvGlowPulse 4s ease-in-out infinite;
}

/* ── Monitor body ── */
.tv-monitor {
  position: relative;
  background:
    linear-gradient(160deg, #2c2c34 0%, #1b1b21 48%, #131318 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 22px;
  padding: 16px 16px 13px;
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -6px 14px rgba(0, 0, 0, 0.45);
}

/* ── Bezel (dark frame around the tube) ── */
.tv-bezel {
  padding: 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, #0c0c10, #050507);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.8);
}

/* ── CRT screen ── */
.tv-screen {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: #030304;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03), inset 0 0 34px rgba(0, 0, 0, 0.9);
}

/* Inline SVG filter definition (CRT glass warp) */
.tv-filter-svg {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Photo layer (also receives the CRT warp filter) */
.tv-crt-content {
  position: absolute;
  inset: 0;
  filter: url(#tv-crt-filter);
}
.tv-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.tv-slide.active { opacity: 1; }

/* ── CRT overlay layers ── */
.tv-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0) 0 2px,
    rgba(0, 0, 0, 0.20) 2px 4px
  );
  mix-blend-mode: multiply;
}
.tv-rgb {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.06) 0 1px,
    rgba(0, 255, 0, 0.06) 1px 2px,
    rgba(0, 0, 255, 0.06) 2px 3px
  );
  mix-blend-mode: screen;
}
.tv-glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    rgba(255, 255, 255, 0.09) 0%,
    rgba(255, 255, 255, 0.02) 26%,
    transparent 42%,
    transparent 60%,
    rgba(255, 255, 255, 0.04) 100%
  );
}
.tv-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 54%, rgba(0, 0, 0, 0.55) 100%);
}

/* Rolling refresh band */
.tv-roll {
  position: absolute;
  left: 0;
  right: 0;
  height: 54px;
  top: -60px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(176, 140, 255, 0.07), transparent);
  animation: tvRoll 5.5s linear infinite;
}

/* Screen flicker */
.tv-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(150, 200, 255, 0.035);
  animation: tvFlicker 4s infinite;
}

/* ── Power-off static ── */
.tv-poweroff {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  background-color: #050507;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
  animation: tvNoise 0.4s steps(3) infinite;
}
.tv-scene.is-power-off .tv-poweroff { opacity: 1; }
.tv-scene.is-power-off .tv-crt-content { opacity: 0; }
.tv-scene.is-power-off .tv-screen::after { animation: none; }

/* ── Controls bar ── */
.tv-controls {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 4px 0;
}
.tv-mark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono, monospace);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted, #6e6e88);
  white-space: nowrap;
}
.tv-mark i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b08cff;
  box-shadow: 0 0 8px 1px rgba(176, 140, 255, 0.7);
}
.tv-knob {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  flex-shrink: 0;
  background: radial-gradient(circle at 32% 30%, #3c3c46, #16161b 70%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.12), inset 0 -1px 2px rgba(0, 0, 0, 0.6);
}
.tv-power {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--text-secondary, #9898b8);
  font-family: var(--font-mono, monospace);
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition-fast, 150ms);
}
.tv-power:hover {
  border-color: rgba(176, 140, 255, 0.55);
  color: var(--text-primary, #e8e8f2);
  box-shadow: 0 0 14px rgba(176, 140, 255, 0.18);
}
.tv-led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px 1px rgba(74, 222, 128, 0.7);
  transition: all var(--transition-fast, 150ms);
}
.tv-scene.is-power-off .tv-led {
  background: #3a3a40;
  box-shadow: none;
}

/* ── Animations ── */
@keyframes tvRoll {
  0%   { top: -60px; }
  100% { top: 110%; }
}
@keyframes tvFlicker {
  0%, 100% { opacity: 0.6; }
  92%      { opacity: 0.6; }
  93%      { opacity: 0.15; }
  94%      { opacity: 0.5; }
  96%      { opacity: 0.7; }
  98%      { opacity: 0.4; }
}
@keyframes tvNoise {
  0%   { background-position: 0 0; }
  33%  { background-position: -40px 30px; }
  66%  { background-position: 30px -25px; }
  100% { background-position: 0 0; }
}
@keyframes tvGlowPulse {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .tv-scene { width: 280px; }
  .tv-monitor { padding: 13px 13px 10px; border-radius: 18px; }
  .tv-bezel    { padding: 8px; border-radius: 13px; }
}
@media (max-width: 480px) {
  .tv-zone  { padding: 0 0.7em; }
  .tv-scene { width: 220px; }
  .tv-mark span, .tv-power span:last-child { display: none; }
  .tv-power { padding: 3px 8px; }
}

/* ── Robots (1–2 little droids beside the machine) ── */
.tv-robot {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35));
}
.tv-robot svg { display: block; width: 100%; height: auto; }
.tv-robot--main {
  left: -58px;
  bottom: 30px;
  width: 80px;
  animation: tvRobotBob 3.6s ease-in-out infinite;
}
.tv-robot--side {
  right: -6px;
  top: -26px;
  width: 42px;
  animation: tvRobotBob 4.4s ease-in-out 1.3s infinite;
}
.tv-robot--f1 { left: 0; bottom: 12px; width: 58px; animation: tvRobotBob 3.8s ease-in-out infinite; }
.tv-robot--f2 { left: 150px; bottom: 34px; width: 44px; animation: tvRobotBob 4.2s ease-in-out 0.7s infinite; }
.tv-robot--f3 { left: 300px; bottom: 8px; width: 66px; animation: tvRobotBob 3.4s ease-in-out 1.4s infinite; }
.tv-robot--f4 { left: 470px; bottom: 28px; width: 40px; animation: tvRobotBob 4.6s ease-in-out 2s infinite; }
.tv-robot--flip svg { transform: scaleX(-1); }
.tv-robot__speech {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 9px;
  background: #ffffff;
  color: #16161b;
  font-family: var(--font-sans, sans-serif);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.25;
  padding: 6px 10px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}
.tv-robot__speech::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #ffffff;
}
.tv-robot__glow { animation: tvRobotGlow 1.8s ease-in-out infinite; }

@keyframes tvRobotBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}
@keyframes tvRobotGlow {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

@media (max-width: 1000px) {
  .tv-robot--f2, .tv-robot--f3, .tv-robot--f4 { display: none; }
}
@media (max-width: 900px) {
  .tv-robot--side { display: none; }
}
@media (max-width: 768px) {
  .tv-robot--main { left: -30px; bottom: 20px; width: 62px; }
}
@media (max-width: 480px) {
  .tv-robot--main { left: -14px; bottom: 16px; width: 50px; }
}
