/* pallete */
body.vhs {
  --v-blue-deep: #0000c8;
  --v-blue-mid:  #0019ff;
  --v-blue-pop:  #4d6dff;
  --v-red:       #ff0010;
  --v-red-deep:  #aa0008;
  --v-yellow:    #ffe200;
  --v-yellow-soft: #fff04a;
  --v-cream:     #f5f0d8;
  --v-white:     #ffffff;
  --v-black:     #000000;
  --chart-grid:  var(--v-yellow);
  --chart-axis:  var(--v-white);
  --chart-text:  var(--v-cream);

  background: var(--v-blue-deep);
  color: var(--v-white);
  font-family: 'Helvetica Neue', 'Arial Black', Impact, sans-serif;
  overflow-x: hidden;
}

body.vhs img { image-rendering: auto; }

/* chromatic aberration via shared SVG filter */
body.vhs .slide,
body.vhs .vhs-ticker-track,
body.vhs .vhs-channel,
body.vhs .vhs-subtitle-text {
  filter: url(#vhs-chroma);
}

/* ---- hide modern layout ---- */
body.vhs #about,
body.vhs #featured,
body.vhs #research,
body.vhs #talks,
body.vhs #software,
body.vhs #topnav,
body.vhs .hero { display: none !important; }

/* ---- CRT overlay ---- */
body.vhs::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9999;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.22) 0px,
      rgba(0, 0, 0, 0.22) 1px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0) 4px
    ),
    radial-gradient(
      ellipse at center,
      transparent 55%,
      rgba(0, 0, 0, 0.55) 100%
    );
  mix-blend-mode: overlay;
}

body.vhs::after {
  content: '';
  position: fixed; left: 0; right: 0;
  height: 48px;
  top: 0;
  pointer-events: none;
  z-index: 9998;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(255, 255, 255, 0.10) 30%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.10) 70%,
    transparent
  );
  mix-blend-mode: screen;
  animation: vhs-tracking-roll 6s linear infinite;
}

body.vhs .vhs-tracking-bar {
  position: fixed; left: 0; right: 0;
  height: 18px;
  pointer-events: none;
  z-index: 9997;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.05), transparent);
  mix-blend-mode: screen;
  animation: vhs-tracking-roll 9.3s linear infinite reverse;
  animation-delay: -2s;
}

body.vhs main { animation: vhs-flicker 0.22s steps(2) infinite; }

/* ---- top ticker ---- */
body.vhs .vhs-ticker {
  position: relative;
  background: var(--v-red);
  color: var(--v-white);
  overflow: hidden;
  border-top: 3px solid var(--v-yellow);
  border-bottom: 3px solid var(--v-yellow);
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
  text-transform: uppercase;
  z-index: 5;
}

body.vhs .vhs-ticker-track {
  display: inline-block;
  padding: 6px 0;
  animation: vhs-marquee 50s linear infinite;
  white-space: nowrap;
}

/* ---- broadcast screen ---- */
body.vhs #vhs-broadcast {
  margin: 0;
  max-width: none;
  width: 100%;
  /* floor so short slides still fill the viewport; tall slides extend past it */
  min-height: calc(100vh - 40px);
  background: linear-gradient(180deg, var(--v-blue-mid) 0%, var(--v-blue-deep) 100%);
  border-top: 6px solid var(--v-yellow);
  border-bottom: 6px solid var(--v-yellow);
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.55);
  position: relative;
  overflow: hidden;
  color: var(--v-white);
  display: flex;
  flex-direction: column;
}

/* ---- slide layout: image|info / payments / email ---- */
body.vhs .slide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  grid-template-areas:
    "image info"
    "payments payments"
    "email email";
  grid-template-rows: 1fr auto auto;
  gap: 12px 24px;
  padding: 18px 24px;
  /* stretch to broadcast floor; expand past it when content is taller */
  flex: 1 1 auto;
  min-height: 0;
  animation: vhs-zoom-in 0.4s ease-out;
  cursor: pointer;
}

/* product image */
body.vhs .slide-image {
  position: relative;
  grid-area: image;
  display: flex; align-items: center; justify-content: center;
  background: var(--v-white);
  border: 4px solid var(--v-black);
  overflow: hidden;
  min-height: 0;
}

body.vhs .slide-image img {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: contrast(1.05) saturate(1.1);
  position: relative;
  z-index: 1;
}

/* fallback emoji */
body.vhs .slide-image-fallback {
  font-size: clamp(5rem, 14vw, 10rem);
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.4));
}

/* info column */
body.vhs .slide-info {
  grid-area: info;
  display: flex; flex-direction: column;
  gap: 8px;
  min-width: 0;
}

/* title */
body.vhs .slide-title {
  font-family: Impact, 'Arial Black', sans-serif;
  font-weight: 900;
  font-size: clamp(2.2rem, 5vw, 4rem);
  text-transform: uppercase;
  line-height: 0.95;
  margin: 0;
  color: var(--v-white);
  letter-spacing: 0.02em;
  -webkit-text-stroke: 2px var(--v-black);
  text-shadow:
    2px 2px 0 var(--v-red-deep),
    4px 4px 0 var(--v-red-deep),
    6px 6px 0 var(--v-red-deep),
    8px 8px 12px rgba(0, 0, 0, 0.6);
}

/* author list */
body.vhs .slide-authors {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  color: var(--v-white);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(0.85rem, 1.4vw, 1.1rem);
  line-height: 1.35;
  margin: 4px 0 0;
  text-shadow: 1px 1px 0 var(--v-black);
}

body.vhs .slide-authors .self {
  background: var(--v-yellow);
  color: var(--v-red);
  font-weight: 900;
  font-style: normal;
  padding: 0 4px;
}

/* subtitle */
body.vhs .slide-subtitle {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-style: italic;
  font-weight: 700;
  font-size: clamp(1.1rem, 2vw, 1.7rem);
  color: var(--v-yellow);
  letter-spacing: 0.03em;
  text-shadow: 1px 1px 0 var(--v-black);
}

/* price block */
body.vhs .slide-price-block {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 4px;
}

/* price */
body.vhs .slide-price {
  font-family: Impact, 'Arial Black', sans-serif;
  font-weight: 900;
  color: var(--v-yellow);
  font-size: clamp(3rem, 8vw, 6rem);
  line-height: 0.9;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  -webkit-text-stroke: 2px var(--v-black);
  text-shadow:
    2px 2px 0 var(--v-red-deep),
    4px 4px 0 var(--v-red-deep),
    6px 6px 0 var(--v-red-deep),
    8px 8px 0 var(--v-red-deep),
    10px 10px 14px rgba(0, 0, 0, 0.6);
}

/* price-unit tag */
body.vhs .slide-price-unit {
  font-family: 'Arial Black', sans-serif;
  font-weight: 900;
  font-size: 0.95rem;
  color: var(--v-white);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  align-self: center;
  background: var(--v-black);
  padding: 2px 8px;
  border: 2px solid var(--v-yellow);
}

/* benefit text */
body.vhs .slide-benefit {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  color: var(--v-white);
  font-size: 1rem;
  line-height: 1.4;
  margin-top: 4px;
}

/* ---- payments row ---- */
body.vhs .slide-payments {
  grid-area: payments;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
}

body.vhs .slide-payments-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* "$0.00 FREE!" price */
body.vhs .slide-pay-price {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 6px 8px 0 0;
  font-family: Impact, 'Arial Black', sans-serif;
  font-weight: 900;
  color: var(--v-yellow);
  font-size: clamp(3rem, 7vw, 5.5rem);
  line-height: 0.9;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  -webkit-text-stroke: 2px var(--v-black);
  text-shadow:
    2px 2px 0 var(--v-red-deep),
    4px 4px 0 var(--v-red-deep),
    6px 6px 0 var(--v-red-deep),
    8px 8px 0 var(--v-red-deep);
  white-space: nowrap;
  animation: vhs-bounce 1.1s ease-in-out infinite;
}

/* "FREE!" tag beside the price */
body.vhs .slide-pay-price em {
  font-style: normal;
  font-family: 'Arial Black', 'Helvetica Neue', sans-serif;
  font-weight: 900;
  font-size: 0.32em;
  background: var(--v-black);
  color: var(--v-yellow);
  padding: 4px 10px;
  -webkit-text-stroke: 0;
  text-shadow: 2px 2px 0 var(--v-red);
  letter-spacing: 0.1em;
  border: 3px solid var(--v-yellow);
  align-self: center;
}

/* icon badge */
body.vhs .slide-pay-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 38px;
  background: var(--v-white);
  border: 2px solid var(--v-black);
  color: var(--v-black);
  text-decoration: none;
  font-size: 1.4rem;
  font-family: 'Arial Black', sans-serif;
  padding: 0 8px;
  box-shadow: 2px 2px 0 var(--v-black);
  transition: background 0.1s linear;
}

body.vhs .slide-pay-badge:hover { background: var(--v-yellow); }

/* text-form badge for journal short name */
body.vhs .slide-pay-text {
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

/* guarantee line */
body.vhs .slide-guarantee {
  color: var(--v-white);
  font-family: 'Arial Black', sans-serif;
  font-weight: 900;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-shadow: 1px 1px 0 var(--v-black);
}

/* ---- email link ---- */
body.vhs .slide-email {
  grid-area: email;
  text-align: center;
  margin-top: 8px;
}

body.vhs .slide-email-link {
  display: inline-block;
  font-family: Impact, 'Arial Black', sans-serif;
  color: var(--v-yellow);
  font-size: clamp(2.5rem, 7vw, 5rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  -webkit-text-stroke: 2px var(--v-black);
  text-shadow:
    2px 2px 0 var(--v-red-deep),
    4px 4px 0 var(--v-red-deep),
    6px 6px 0 var(--v-red-deep),
    8px 8px 0 var(--v-red-deep),
    10px 10px 14px rgba(0, 0, 0, 0.7);
  animation: vhs-bounce 1.1s ease-in-out infinite;
}

body.vhs .slide-email-link:hover {
  color: var(--v-yellow-soft);
}

/* ---- color-bars test pattern ---- */
body.vhs .vhs-color-bars {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 10005;
  opacity: 0;
  transition: opacity 0.04s linear;

  /* SMPTE 7 stripes: white / yellow / cyan / green / magenta / red / blue */
  background: linear-gradient(
    to right,
    #c0c0c0 0%,    #c0c0c0 14.28%,
    #c0c000 14.28%, #c0c000 28.57%,
    #00c0c0 28.57%, #00c0c0 42.86%,
    #00c000 42.86%, #00c000 57.14%,
    #c000c0 57.14%, #c000c0 71.43%,
    #c00000 71.43%, #c00000 85.71%,
    #0000c0 85.71%, #0000c0 100%
  );
}

body.vhs .vhs-color-bars.is-active { opacity: 1; }

/* scanlines on the color bars */
body.vhs .vhs-color-bars::before {
  content: '';
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.35) 0px,
      rgba(0, 0, 0, 0.35) 1px,
      transparent 2px,
      transparent 4px
    );
  pointer-events: none;
}

/* SMPTE bottom strip */
body.vhs .vhs-color-bars::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 25%;
  background: linear-gradient(
    to right,
    #0000c0 0%, #0000c0 25%,
    #1a1a1a 25%, #1a1a1a 50%,
    #c000c0 50%, #c000c0 75%,
    #000000 75%, #000000 100%
  );
}

/* PLAY and SP indicators */
body.vhs .vhs-cb-play,
body.vhs .vhs-cb-sp {
  position: absolute;
  top: 14px;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  font-size: 1.6rem;
  color: var(--v-white);
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 10px;
  letter-spacing: 0.08em;
  z-index: 2;
}

body.vhs .vhs-cb-play { left: 14px; }
body.vhs .vhs-cb-sp   { right: 14px; }

/* ---- footer ---- */
body.vhs .site-footer {
  background: var(--v-blue-deep);
  color: var(--v-cream);
  border-top: 4px ridge var(--v-yellow);
  padding: 16px;
  margin-top: 16px;
}

body.vhs .site-footer a { color: var(--v-yellow); }

/* viewmode toggle sits below the CRT overlay so scanlines apply to it */
body.vhs #viewmode-toggle {
  z-index: 9990;
  background: var(--v-red);
  color: var(--v-yellow);
  border: 3px outset var(--v-yellow);
  font-family: 'Arial Black', sans-serif;
}

/* ---- scrollbar ---- */
body.vhs::-webkit-scrollbar { width: 14px; height: 14px; }
body.vhs::-webkit-scrollbar-track { background: var(--v-blue-deep); }
body.vhs::-webkit-scrollbar-thumb {
  background: var(--v-red);
  border: 2px outset var(--v-yellow);
}
body.vhs::-webkit-scrollbar-thumb:hover { background: var(--v-yellow); }

/* ---- keyframes ---- */
@keyframes vhs-flicker {
  0%   { opacity: 1; }
  50%  { opacity: 0.94; }
  100% { opacity: 1; }
}

@keyframes vhs-tracking-roll {
  from { transform: translateY(-60px); }
  to   { transform: translateY(100vh); }
}

@keyframes vhs-marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

@keyframes vhs-bounce {
  0%, 100% { transform: rotate(-1deg) translateY(0); }
  50%      { transform: rotate(1deg) translateY(-4px); }
}

@keyframes vhs-zoom-in {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ---- bonus-talks callout ---- */
body.vhs .slide-bonus {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 16px 12px;
  background: var(--v-yellow);
  border: 3px solid var(--v-red);
  outline: 2px solid var(--v-black);
  box-shadow: 5px 5px 0 var(--v-black);
  transform: rotate(-1.5deg);
  color: var(--v-black);
}

/* bonus header */
body.vhs .slide-bonus-header {
  font-family: Impact, 'Arial Black', sans-serif;
  font-weight: 900;
  font-size: clamp(1.6rem, 3.4vw, 2.8rem);
  color: var(--v-red);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 0.95;
  -webkit-text-stroke: 1.5px var(--v-black);
  text-shadow:
    2px 2px 0 var(--v-black),
    3px 3px 0 var(--v-red-deep),
    5px 5px 0 var(--v-red-deep),
    7px 7px 12px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  animation: vhs-bounce 1.1s ease-in-out infinite;
}

body.vhs .slide-bonus-pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

body.vhs .slide-bonus-pill {
  display: inline-block;
  padding: 1px 7px;
  background: var(--v-black);
  color: var(--v-yellow);
  text-decoration: none;
  font-family: 'Arial Black', sans-serif;
  font-weight: 900;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  border: 1px solid var(--v-yellow);
  white-space: nowrap;
}

body.vhs .slide-bonus-pill:hover {
  background: var(--v-yellow);
  color: var(--v-red);
  border-color: var(--v-red);
}

/* ---- mobile ---- */
@media (max-width: 700px) {
  body.vhs::before {
    background:
      repeating-linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.14) 0px,
        rgba(0, 0, 0, 0.14) 1px,
        rgba(0, 0, 0, 0) 4px,
        rgba(0, 0, 0, 0) 8px
      ),
      radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.5) 100%);
  }
  body.vhs #vhs-broadcast { min-height: auto; }
  body.vhs .slide {
    grid-template-columns: 1fr;
    grid-template-areas:
      "image"
      "info"
      "payments"
      "email";
    gap: 12px;
    padding: 14px;
  }
  body.vhs .slide-image { max-height: 36vh; }
  body.vhs .slide-image img { max-height: 36vh; }
  body.vhs .slide-payments { flex-direction: column; align-items: flex-start; }
  body.vhs .slide-guarantee { font-size: 0.85rem; }
  body.vhs .vhs-subtitle { bottom: 8px; max-width: calc(100% - 16px); }
  body.vhs .vhs-subtitle-text { font-size: 0.9rem; padding: 3px 8px; }
  body.vhs .vhs-channel { top: 8px; right: 8px; font-size: 0.95rem; padding: 2px 6px; }
  body.vhs .vhs-static-lines { bottom: 56px; height: 28px; }
  body.vhs .slide-bonus { transform: none; }
}

/* ---- channel indicator ---- */
body.vhs .vhs-channel {
  position: fixed;
  top: 14px; right: 14px;
  z-index: 9990;
  background: var(--v-black);
  color: #00ff66;
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-weight: bold;
  font-size: 1.25rem;
  padding: 4px 12px;
  border: 1px solid #00ff66;
  letter-spacing: 0.1em;
  text-shadow: 0 0 8px rgba(0, 255, 102, 0.7);
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.35);
}

/* ---- subtitle band ---- */
body.vhs .vhs-subtitle {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9990;
  max-width: 80vw;
  pointer-events: none;
  text-align: center;
}

body.vhs .vhs-subtitle-text {
  display: inline-block;
  background: rgba(0, 0, 0, 0.92);
  color: var(--v-white);
  font-family: 'Arial Narrow', 'Helvetica Neue', 'Helvetica', Arial, sans-serif;
  font-weight: 700;
  font-size: clamp(1.6rem, 2.8vw, 2.4rem);
  padding: 6px 22px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  -webkit-text-stroke: 0.5px var(--v-black);
  min-height: 1.4em;
  line-height: 1.25;
  white-space: pre-wrap;
}

/* ---- static-lines overlay ---- */
body.vhs .vhs-static-lines {
  position: fixed;
  left: 0; right: 0;
  bottom: 70px;
  height: 90px;
  z-index: 9995;
  pointer-events: none;
  background:
    /* sparse top band */
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.22) 0px,
      rgba(255, 255, 255, 0.22) 1px,
      transparent 2px,
      transparent 3px
    ),
    /* dense main band */
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.40) 0px,
      rgba(255, 255, 255, 0.40) 1px,
      rgba(0, 0, 0, 0.30) 2px,
      transparent 3px,
      rgba(255, 255, 255, 0.18) 4px,
      transparent 5px,
      transparent 7px,
      rgba(255, 255, 255, 0.32) 8px,
      transparent 9px,
      transparent 11px
    );
  mix-blend-mode: screen;
  animation: vhs-static-roll 0.18s steps(6) infinite;
  opacity: 1;
}

@keyframes vhs-static-roll {
  0%   { transform: translateY(0); }
  100% { transform: translateY(11px); }
}

/* ---- CRT warping ---- */
body.vhs #vhs-broadcast {
  border-radius: 18px / 22px;
  box-shadow:
    inset 0 0 180px rgba(0, 0, 0, 0.8),
    inset 0 0 60px rgba(0, 0, 0, 0.5);
}

body.vhs .slide {
  transform: perspective(2400px) rotateX(0.5deg);
  transform-origin: center top;
}

/* ---- prefers-reduced-motion ---- */
@media (prefers-reduced-motion: reduce) {
  body.vhs main,
  body.vhs::after,
  body.vhs .vhs-tracking-bar,
  body.vhs .vhs-ticker-track,
  body.vhs .slide,
  body.vhs .slide-email-link,
  body.vhs .vhs-static-lines {
    animation: none !important;
  }
}
