/* ==========================================================================
   AUTHENTIC CRT TV FRAME & CHANNEL STATIC SWITCH FOR STATIC INQUIRIES
   ========================================================================== */

/* 1. CRT BEZEL FRAME */
.tv-bezel-frame {
  position: fixed;
  inset: 0;
  z-index: 9950;
  pointer-events: none;
  background: #080706;
  visibility: hidden;
}

.tv-bezel-frame.is-visible {
  visibility: visible;
}

/* 2. CRT GLASS BEVEL */
.tv-glass-bevel {
  position: fixed;
  inset: 0;
  z-index: 9945;
  pointer-events: none;
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.55),
    inset 0 0 18px rgba(0, 0, 0, 0.42);
  visibility: hidden;
}

.tv-glass-bevel.is-visible {
  visibility: visible;
}

/* 3. CRT PHOSPHOR INNER RIM SVG */
.tv-stroke-svg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 9948;
  pointer-events: none;
}

/* 4. CRT OVERLAYS (Scanlines, Ambient Grain, Sweeping Beams, Glow, Vignette) */
.tv-scanlines {
  position: fixed;
  inset: 0;
  z-index: 9940;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.025) 3px,
    rgba(0, 0, 0, 0.025) 4px
  );
  pointer-events: none;
}

/* Ambient animated grain canvas */
.tv-grain-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 9940;
  opacity: 0.04;
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* Sweeping CRT scanner lines */
.tv-scanner-lines {
  position: fixed;
  inset: 0;
  z-index: 9941;
  overflow: hidden;
  pointer-events: none;
}

.tv-scanner-beam {
  position: absolute;
  left: 0;
  right: 0;
  top: -4px;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  mix-blend-mode: multiply;
  box-shadow:
    0 5px 0 rgba(255, 255, 255, 0.06),
    0 0 10px rgba(255, 255, 255, 0.08);
  will-change: transform;
  animation: pageScanDown 11s linear infinite;
}

.tv-scanner-beam:nth-child(2) {
  height: 2px;
  animation-duration: 15s;
  animation-delay: -5s;
  opacity: 0.08;
}

.tv-scanner-beam:nth-child(3) {
  height: 4px;
  animation-duration: 19s;
  animation-delay: -10s;
  opacity: 0.05;
}

@keyframes pageScanDown {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  3% {
    opacity: 0.7;
  }
  59% {
    transform: translateY(calc(100vh + 8px));
    opacity: 0.5;
  }
  62% {
    transform: translateY(calc(100vh + 8px));
    opacity: 0;
  }
  100% {
    transform: translateY(calc(100vh + 8px));
    opacity: 0;
  }
}

.tv-vignette {
  position: fixed;
  inset: 0;
  z-index: 9942;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 68%,
    rgba(0, 0, 0, 0.20) 100%
  );
}

.tv-inner-glow {
  position: fixed;
  inset: 0;
  z-index: 9943;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.04) 0%, transparent 15%),
    linear-gradient(to top,    rgba(255, 255, 255, 0.03) 0%, transparent 12%),
    linear-gradient(to right,  rgba(255, 255, 255, 0.03) 0%, transparent 12%),
    linear-gradient(to left,   rgba(255, 255, 255, 0.03) 0%, transparent 12%);
}

/* 5. CHANNEL STATIC TRANSITION SCREEN (Fine Analog TV Static + Authentic Station Search OSD) */
.channel-static-screen {
  position: fixed;
  inset: 0;
  z-index: 9948; /* Under tv-bezel-frame (9950), covers ambient scanner lines (9941) */
  background: #000000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: auto;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.channel-static-screen.is-arriving {
  opacity: 0;
  pointer-events: none;
}

.channel-static-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.90;
  pointer-events: none;
}

/* Authentic CRT TV Station Search OSD */
.channel-osd {
  position: absolute;
  top: clamp(28px, 4.5vh, 60px);
  left: clamp(28px, 4.5vw, 64px);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: 'VT323', monospace;
  color: #00ff66;
  text-shadow: 0 0 10px rgba(0, 255, 102, 0.75), 0 0 20px rgba(0, 255, 102, 0.35);
  letter-spacing: 0.06em;
  pointer-events: none;
  user-select: none;
}

.channel-osd-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: clamp(22px, 3.2vw, 38px);
  line-height: 1;
}

.channel-osd-ch {
  color: #00ff66;
  font-weight: 700;
}

.channel-osd-status {
  color: #ffd060;
  text-shadow: 0 0 8px rgba(255, 208, 96, 0.7);
  font-size: clamp(16px, 2.2vw, 26px);
  transition: color 0.15s ease, text-shadow 0.15s ease;
}

.channel-osd-status.is-locked {
  color: #00ff66;
  text-shadow: 0 0 10px rgba(0, 255, 102, 0.8), 0 0 20px rgba(0, 255, 102, 0.4);
}

.channel-osd-freq {
  color: #ffd060;
  text-shadow: 0 0 8px rgba(255, 208, 96, 0.6);
  font-size: clamp(14px, 1.8vw, 22px);
  letter-spacing: 0.08em;
  transition: color 0.15s ease, text-shadow 0.15s ease;
}

.channel-osd-freq.is-locked {
  color: #00ff66;
  text-shadow: 0 0 8px rgba(0, 255, 102, 0.6);
}

.channel-osd-searching {
  color: #ffffff;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
  font-size: clamp(12px, 1.5vw, 18px);
  letter-spacing: 0.12em;
  opacity: 0.88;
  animation: osdPulse 1s ease-in-out infinite;
  transition: color 0.15s ease, text-shadow 0.15s ease;
}

.channel-osd-searching.is-locked {
  color: #00ff66;
  text-shadow: 0 0 8px rgba(0, 255, 102, 0.6);
  animation: none;
  opacity: 1;
}

@keyframes osdPulse {
  0%, 100% { opacity: 0.88; }
  50% { opacity: 0.45; }
}

@media (max-width: 768px) {
  .channel-osd {
    top: 22px;
    left: 20px;
    right: 20px;
    gap: 4px;
  }
  .channel-osd-header {
    font-size: 20px;
    gap: 8px;
  }
  .channel-osd-ch {
    font-size: 20px;
  }
  .channel-osd-status {
    font-size: 15px;
  }
  .channel-osd-freq {
    font-size: 13px;
    letter-spacing: 0.05em;
  }
  .channel-osd-searching {
    font-size: 12px;
    letter-spacing: 0.06em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .channel-static-screen { display: none !important; }
}

/* 5. INDEX SIDEBAR DRAWER - RESTRICTED STRICTLY INSIDE THE CRT SCREEN */
dialog#chapter-index,
dialog#index,
dialog.index,
dialog[class*="index"] {
  top: clamp(14px, 2.2vh, 32px) !important;
  bottom: clamp(14px, 2.2vh, 32px) !important;
  right: clamp(16px, 2.2vw, 36px) !important;
  left: auto !important;
  height: calc(100dvh - 2 * clamp(14px, 2.2vh, 32px)) !important;
  max-height: calc(100dvh - 2 * clamp(14px, 2.2vh, 32px)) !important;
  border-radius: clamp(18px, 2.2vw, 32px) !important;
  box-shadow: -15px 0 45px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.25) !important;
  overflow-y: auto !important;
}

@media (max-width: 768px) {
  dialog#chapter-index,
  dialog#index,
  dialog.index,
  dialog[class*="index"] {
    top: 12px !important;
    bottom: 12px !important;
    right: 10px !important;
    left: 10px !important;
    width: calc(100vw - 20px) !important;
    max-width: calc(100vw - 20px) !important;
    height: calc(100dvh - 24px) !important;
    max-height: calc(100dvh - 24px) !important;
    border-radius: 16px !important;
  }
}
