/* ========================================
   1. CSS Variables & Design Tokens
   ======================================== */

:root {
  --bg0: #05040a;
  --bg1: #050b16;
  --accent: #f7c06f;
  --text: #f4f6ff;
  --muted: rgba(244,246,255,.65);
  --font-display: 'Fraunces', serif;
  --font-body: 'Space Grotesk', system-ui, sans-serif;
  --page-padding-y: clamp(0.8rem, 2vw, 2rem);
  --page-padding-x: clamp(0.75rem, 2.2vw, 2.4rem);
  --page-footer-padding: 2rem;
  --story-gap: clamp(0.9rem, 1.8vw, 1.4rem);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-viewport-h: calc(100dvh - var(--safe-top) - var(--safe-bottom));
  --monitor-radius: 3rem;
  --monitor-border: rgba(89, 255, 131, 0.95);
  --screen-border: rgba(255, 255, 255, 0.08);
  --screen-inner: rgba(57, 255, 20, 0.25);
}

/* ========================================
   2. Reset & Base Styles
   ======================================== */

* { 
  box-sizing: border-box; 
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  background: linear-gradient(180deg, var(--bg0), var(--bg1));
  color: var(--text);
  overflow-x: hidden;
}

/* ========================================
   3. Typography
   ======================================== */

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1.1;
}

h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(22px, 2.2vw, 34px);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(244,246,255,.7);
}

p {
  margin: 0;
  font-size: clamp(16px, 1.2vw, 18px);
  color: var(--muted);
}

.hero-lead {
  color: rgba(244,246,255,0.85);
  font-size: clamp(18px, 1.4vw, 20px);
  line-height: 1.7;
  letter-spacing: 0.02em;
}

.hero-welcome {
  margin: 0;
  font-size: clamp(18px, 1.45vw, 20px);
  line-height: 1.7;
  color: rgba(244,246,255,0.95);
  text-align: center;
  max-width: 880px;
}

.hero-welcome-detail {
  margin: 0;
  margin-top: 0.7rem;
  font-size: clamp(15px, 1.2vw, 17px);
  line-height: 1.7;
  letter-spacing: 0.05em;
  color: rgba(244,246,255,0.75);
  text-align: center;
  max-width: 1080px;
}

.subtext {
  font-size: 12px;
  letter-spacing: .4em;
  text-transform: uppercase;
  color: rgba(244,246,255,.5);
}

.terminal-text {
  flex: 1;
  font-family: 'Space Mono', 'Fira Code', monospace;
  font-size: clamp(0.9rem, 1vw, 1rem);
  line-height: 1.5;
  color: rgba(57,255,20,0.95);
  white-space: pre-wrap;
  min-height: 0;
  position: relative;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.4s ease;
  margin: 0;
  padding: 0.55rem 0.75rem 0;
  text-shadow: 0 0 8px rgba(0,0,0,0.8), 0 0 2px rgba(57,255,20,0.6);
}

/* ========================================
   4. Layout Components
   ======================================== */

.page {
  position: relative;
  min-height: 100dvh;
  min-height: calc(var(--safe-viewport-h) - var(--page-padding-y) - var(--page-footer-padding));
  max-height: calc(var(--safe-viewport-h) - var(--page-padding-y) - var(--page-footer-padding));
  display: grid;
  grid-template-rows: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: var(--story-gap);
  justify-items: stretch;
  align-items: stretch;
  padding:
    calc(var(--page-padding-y) + var(--safe-top))
    var(--page-padding-x)
    calc(var(--page-footer-padding) + var(--safe-bottom));
  overflow: hidden;
  z-index: 3;
}

/* ========================================
   5. Hero Section
   ======================================== */

.hero-shell {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  text-align: center;
  overflow: hidden;
  background: none;
  width: 100%;
}

.hero-content {
  max-width: 1200px;
  width: 100%;
  position: relative;
  z-index: 2;
  display: grid;
  gap: 1.5rem;
  justify-items: center;
  height: 100%;
  min-height: 0;
}

.hero-heading {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  align-items: center;
  text-align: center;
}

.hero-logos-container {
  display: flex;
  flex-direction: row;
  gap: clamp(1.5rem, 3vw, 3rem);
  align-items: center;
  justify-content: center;
  margin-top: 0.7rem;
  flex-wrap: wrap;
}

.hero-logo-wrapper {
  width: clamp(140px, 18vw, 240px);
  display: flex;
  justify-content: center;
}

.hero-logo {
  width: 100%;
  height: auto;
  display: block;
}

.hero-name-highlight {
  display: inline-flex;
  position: relative;
  justify-content: center;
}

.hero-name-highlight::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -0.1em;
  width: 135%;
  height: 0.4rem;
  border-radius: 999px;
  background: radial-gradient(circle at top, rgba(247,192,111,0.9), transparent 70%);
  transform: translateX(-50%) scaleX(0.25);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.5s ease;
  filter: blur(2px);
}

body.hero-focus .hero-name-highlight::after {
  transform: translateX(-50%) scaleX(1);
  opacity: 0.85;
}

.welcome-console {
  width: 100%;
  aspect-ratio: auto;
  min-height: 0;
  max-height: none;
  height: 100%;
  padding: clamp(0.9rem, 1.5vw, 1.2rem);
  margin-inline: auto;
  justify-content: center;
  min-width: 0;
  overflow: auto;
}

.welcome-console .hero-heading {
  margin-top: 0.1rem;
}

.welcome-console .hero-logos-container {
  margin-top: 0.35rem;
}

.top-console {
  display: grid;
  width: 100%;
  gap: 0.6rem;
}

.top-console-view {
  width: 100%;
}

.top-console-output {
  margin: 0;
  min-height: 11rem;
  border: 1px solid rgba(125, 251, 167, 0.36);
  border-radius: 0.75rem;
  padding: 0.85rem;
  background: rgba(0, 0, 0, 0.72);
  color: rgba(190, 255, 212, 0.96);
  font: 500 0.86rem/1.5 "Space Mono", "Fira Mono", monospace;
  white-space: pre-wrap;
}

.top-console-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.top-console-actions .btn {
  min-width: 11.5rem;
}

.top-console-web {
  margin-top: 0.6rem;
}

.top-console-web iframe {
  width: 100%;
  min-height: 18rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(133, 250, 166, 0.36);
  background: #030704;
}

/* ========================================
   6. Terminal Components
   ======================================== */

.terminal-window {
  background: radial-gradient(circle at 20% 20%, rgba(247,192,111,0.15), rgba(3,4,6,0.95) 65%);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--monitor-radius) var(--monitor-radius) calc(var(--monitor-radius) * 0.8) calc(var(--monitor-radius) * 0.8);
  padding: clamp(0.9rem, 1.4vw, 1.35rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: default;
  min-height: 0;
  aspect-ratio: 16 / 10;
  width: 100%;
  max-width: 100%;
  outline: none;
  opacity: 0;
  transform: none;
  filter: brightness(0.4) saturate(0.45) contrast(0.9);
  transition: filter 0.5s ease, opacity 0.6s ease, box-shadow 0.5s ease, border-color 0.5s ease;
  position: relative;
  overflow: hidden;
}

.terminal-window::before,
.terminal-window::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
}

.terminal-window::before {
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,0.12), transparent 45%);
  mix-blend-mode: screen;
  opacity: 0.9;
}

.terminal-window::after {
  border: 1px solid rgba(255,255,255,0.04);
  box-shadow: inset 0 -20px 40px rgba(0,0,0,0.8);
  filter: drop-shadow(0 8px 30px rgba(0, 0, 0, 0.6));
}

.terminal-window.frame-visible {
  opacity: 1;
  transform: none;
}

.terminal-window.active {
  border-color: rgba(57,255,20,0.8);
  box-shadow: 0 0 40px rgba(57,255,20,.35), inset 0 0 20px rgba(57,255,20,0.1);
}

.terminal-window.monitor-off {
  opacity: 0.72;
  transform: none;
  filter: brightness(0.45) saturate(0.35) contrast(0.92);
  border-color: rgba(255,255,255,0.08);
  box-shadow: inset 0 0 60px rgba(0,0,0,0.6);
}

.terminal-window.powering {
  opacity: 1;
  filter: brightness(1) saturate(1) contrast(1.02);
  animation: monitorGlow 1.2s ease, crtWarmup 1.8s ease;
}

/* CRT Warmup flicker effect - Enhanced */
@keyframes crtWarmup {
  0% {
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.95);
    filter: brightness(0.1) contrast(0.8);
  }
  3% {
    box-shadow: 0 0 8px rgba(57, 255, 120, 0.08), inset 0 0 55px rgba(0, 0, 0, 0.9);
    filter: brightness(0.3) contrast(0.9);
  }
  5% {
    box-shadow: 0 0 18px rgba(57, 255, 120, 0.18), inset 0 0 55px rgba(0, 0, 0, 0.85);
    filter: brightness(1.8) contrast(1.2);
  }
  8% {
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.9);
    filter: brightness(0.2) contrast(0.85);
  }
  12% {
    box-shadow: 0 0 22px rgba(57, 255, 120, 0.22), inset 0 0 50px rgba(0, 0, 0, 0.8);
    filter: brightness(2.2) contrast(1.3);
  }
  15% {
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.9);
    filter: brightness(0.3) contrast(0.9);
  }
  20% {
    box-shadow: 0 0 28px rgba(57, 255, 120, 0.28), inset 0 0 45px rgba(0, 0, 0, 0.75);
    filter: brightness(1.5) contrast(1.15);
  }
  30% {
    box-shadow: 0 0 32px rgba(57, 255, 120, 0.3), inset 0 0 42px rgba(57, 255, 20, 0.05);
    filter: brightness(1.2) contrast(1.1);
  }
  50% {
    box-shadow: 0 15px 55px rgba(57, 255, 120, 0.2), inset 0 0 40px rgba(57, 255, 20, 0.06);
    filter: brightness(1.1) contrast(1.08);
  }
  70% {
    box-shadow: 0 20px 60px rgba(57, 255, 120, 0.22), inset 0 0 42px rgba(57, 255, 20, 0.07);
    filter: brightness(1.05) contrast(1.05);
  }
  100% {
    box-shadow: 0 25px 75px rgba(57, 255, 120, 0.25), inset 0 0 48px rgba(57, 255, 20, 0.08);
    filter: brightness(1) contrast(1);
  }
}

.terminal-window.powered {
  opacity: 1;
  filter: brightness(1.05) saturate(1.15) contrast(1.05);
  border-color: rgba(57,255,20,0.5);
  box-shadow: 0 25px 75px rgba(57,255,120,0.25), inset 0 0 48px rgba(57,255,20,0.08);
}

.terminal-window.boot-line .terminal-boot-core { 
  animation: bootLine 0.55s ease forwards; 
}

.terminal-window.boot-open .terminal-boot-core {
  width: 92%;
  height: 92%;
  border-radius: 2px;
  animation: bootOpen 0.7s ease forwards;
}

.terminal-window.no-signal .terminal-boot {
  background: radial-gradient(circle at 50% 50%, rgba(167,255,177,.25), rgba(12,12,12,.95)),
    repeating-radial-gradient(circle at 50% 50%, rgba(215,215,215,.16) 0 1px, transparent 1px 3px);
}

.terminal-window.active .terminal-boot {
  opacity: 0;
  pointer-events: none;
}

/* Outer Limits-style console effects */
.terminal-window.outer-limits-power-on {
  animation: outerLimitsPowerOn 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
  position: relative;
  overflow: hidden;
}

.terminal-window.outer-limits-power-on::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(247, 192, 111, 0.15) 48%,
    rgba(247, 192, 111, 0.25) 50%,
    rgba(247, 192, 111, 0.15) 52%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 10;
}

.terminal-window.outer-limits-power-off {
  animation: outerLimitsPowerOff 0.9s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.terminal-window.outer-limits-active {
  animation: none;
  filter: brightness(1.15) contrast(1.15) saturate(1.1) drop-shadow(0 0 30px rgba(247, 192, 111, 0.8));
}

.terminal-window.outer-limits-active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.15) 0px,
      transparent 1px,
      transparent 2px,
      rgba(0, 0, 0, 0.15) 3px
    ),
    radial-gradient(circle at 50% 50%, transparent 0%, rgba(247, 192, 111, 0.05) 100%);
  pointer-events: none;
  z-index: 5;
}

.terminal-window.channel-switching {
  animation: channelSwitch 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.terminal-window.channel-switching::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.1) 0px,
    transparent 2px,
    transparent 4px,
    rgba(255, 255, 255, 0.1) 6px
  );
  pointer-events: none;
  z-index: 15;
}

.terminal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: var(--story-gap);
  width: min(1320px, 100%);
  margin-inline: auto;
  justify-items: stretch;
  align-items: center;
  padding-bottom: 0;
  height: 100%;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  font-size: 0.82rem;
  margin-bottom: 0.85rem;
  padding: 0.45rem 0.7rem;
  color: rgba(250, 225, 167, 0.94);
  border: 1px solid rgba(109, 75, 35, 0.8);
  border-radius: 0.4rem;
  background:
    linear-gradient(180deg, rgba(186, 129, 64, 0.5), rgba(93, 62, 27, 0.7)),
    linear-gradient(90deg, rgba(246, 212, 152, 0.12), rgba(57, 39, 18, 0.2));
  box-shadow:
    inset 0 1px 0 rgba(255, 232, 184, 0.24),
    inset 0 -2px 5px rgba(31, 20, 8, 0.65),
    0 2px 8px rgba(0, 0, 0, 0.35);
}

.terminal-body {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  position: relative;
  z-index: 2;
  min-height: 0;
}

.terminal-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: clamp(260px, 24vw, 360px);
  min-height: 120px;
  transform: translate(-50%, 0) scale(0.9) rotate(-1deg);
  padding: 16px 20px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(247, 192, 111, 0.7);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8), inset 0 0 12px rgba(255, 255, 255, 0.05);
  font-family: "Space Mono", "Fira Mono", "Courier New", monospace;
  font-size: clamp(12px, 1vw, 15px);
  letter-spacing: 0.18em;
  color: #caff99;
  opacity: 0;
  pointer-events: none;
  z-index: 25;
  transition: opacity 0.6s ease, transform 0.5s ease, filter 0.5s ease;
  border-top: 3px solid rgba(247, 192, 111, 0.9);
  filter: drop-shadow(0 20px 45px rgba(0, 200, 120, 0.35));
}

.terminal-panel.visible {
  opacity: 1;
}

.terminal-panel.incoming {
  transform: translate(-50%, -20px) scale(0.95) rotate(-2deg);
  filter: drop-shadow(0 25px 55px rgba(0, 210, 150, 0.45));
}

.terminal-panel.fixed {
  transform: translate(-50%, 0) scale(1) rotate(0deg);
  filter: drop-shadow(0 25px 45px rgba(0, 200, 120, 0.45));
}

.terminal-panel.atomized {
  opacity: 0;
  transform: translate(-50%, 40px) scale(1.2) skewX(7deg);
  filter: drop-shadow(0 40px 80px rgba(0, 0, 0, 0.8)) blur(2px);
}

.terminal-title {
  font-size: 10px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(247, 192, 111, 0.9);
  margin-bottom: 8px;
}

.terminal-content {
  line-height: 1.5;
  text-transform: none;
  letter-spacing: 0.12em;
  font-weight: 500;
  min-height: 48px;
}

.terminal-cursor {
  width: 10px;
  height: 18px;
  border-radius: 3px;
  margin-top: 6px;
  background: rgba(247, 192, 111, 0.8);
  animation: blink 1.2s steps(1) infinite;
}

.terminal-cursor-slot {
  display: inline-flex;
  align-items: flex-start;
  min-height: 1.25em;
}

.terminal-widget-cursor {
  width: 10px;
  height: 1.25em;
  border-radius: 3px;
  margin-left: 0.4rem;
  background: rgba(247, 192, 111, 0.9);
  animation: blink 1.2s steps(1) infinite;
}

.terminal-boot {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(0, 0, 0, 0.95);
  display: grid;
  place-items: center;
  z-index: 3;
  transition: opacity 0.45s ease;
  overflow: hidden;
}

/* Add a subtle glow pulse during boot */
.terminal-window.boot-line .terminal-boot,
.terminal-window.boot-open .terminal-boot {
  background: radial-gradient(
    ellipse at center,
    rgba(57, 255, 20, 0.08) 0%,
    rgba(0, 0, 0, 0.95) 50%
  );
  animation: bootGlowPulse 0.8s ease-in-out;
}

@keyframes bootGlowPulse {
  0%, 100% {
    background: radial-gradient(
      ellipse at center,
      rgba(57, 255, 20, 0.04) 0%,
      rgba(0, 0, 0, 0.95) 50%
    );
  }
  50% {
    background: radial-gradient(
      ellipse at center,
      rgba(57, 255, 20, 0.12) 0%,
      rgba(0, 0, 0, 0.93) 45%
    );
  }
}

.terminal-boot-core {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 1) 0%, rgba(142, 248, 164, 0.95) 100%);
  box-shadow: 0 0 14px rgba(142, 248, 164, 0.9), 0 0 4px rgba(255, 255, 255, 0.8);
}

.screen-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 140px;
  border-radius: 1.6rem;
  overflow: hidden;
  background: #000;
  box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.85);
  margin-bottom: 0.45rem;
  padding: 0.3rem;
}

.screen-wrapper.show-text .terminal-text {
  opacity: 1;
}

.screen-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
  border-radius: 1.5rem;
  background: #000;
  border: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0.85rem 0.65rem 0.6rem;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.95);
  overflow: hidden;
}

/* CRT Scanline effect overlay */
.screen-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15) 0px,
    transparent 1px,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 3px
  );
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.terminal-window.powered .screen-stage::before,
.terminal-window.powering .screen-stage::before {
  opacity: 0.4;
}

/* Subtle phosphor glow effect */
.screen-stage::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 0%,
    transparent 40%,
    rgba(57, 255, 20, 0.03) 70%,
    rgba(57, 255, 20, 0.08) 100%
  );
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.terminal-window.powered .screen-stage::after,
.terminal-window.powering .screen-stage::after {
  opacity: 1;
}

.graphics-layer {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: none;
  z-index: 1;
  filter: brightness(0.86) saturate(0.9);
}

.graphics-layer.active {
  opacity: 1;
  filter: brightness(1) saturate(1.05);
  animation: phosphorFadeIn 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes phosphorFadeIn {
  0% {
    opacity: 0;
    filter: brightness(0.3) saturate(0.3) blur(4px);
  }
  15% {
    opacity: 0.3;
    filter: brightness(1.8) saturate(0.5) blur(3px);
  }
  35% {
    opacity: 0.6;
    filter: brightness(1.5) saturate(0.7) blur(2px);
  }
  60% {
    opacity: 0.85;
    filter: brightness(1.2) saturate(0.9) blur(1px);
  }
  100% {
    opacity: 1;
    filter: brightness(1) saturate(1.05) blur(0px);
  }
}

.graphics-layer.static {
  background-image:
    linear-gradient(0deg, rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 4px 4px;
  animation: tvSnow 0.3s steps(4) infinite;
  mix-blend-mode: screen;
}

/* ========================================
   7. Interactive Elements
   ======================================== */

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: center;
  margin: 0;
  justify-content: center;
}

.btn {
  border-radius: 999px;
  padding: .9rem 1.8rem;
  border: 1px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.08);
  color: var(--text);
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
}

.btn.glow {
  background: linear-gradient(135deg, rgba(247,192,111,.6), rgba(255,255,255,.1));
  border-color: transparent;
}

.btn.soft {
  background: rgba(255,255,255,0.05);
  border-color: rgba(247,192,111,.5);
  letter-spacing: .16em;
  padding: .85rem 1.45rem;
}

.btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,.6);
}

.btn:focus-visible {
  outline: 2px solid rgba(57,255,20,0.8);
  outline-offset: 3px;
}

.channel-player {
  margin-top: 1rem;
  border-radius: 22px;
  border: 1px solid rgba(247,192,111,.35);
  background: rgba(1,1,3,0.88);
  box-shadow: 0 28px 68px rgba(0,0,0,.45), inset 0 0 26px rgba(57,255,20,0.08);
  overflow: hidden;
  position: relative;
}

.channel-player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(247,192,111,.2);
  text-transform: uppercase;
  letter-spacing: 0.26em;
  font-size: 0.72rem;
  color: rgba(247,192,111,0.9);
}

.channel-player-screen {
  position: relative;
  min-height: clamp(220px, 38vw, 420px);
  background: radial-gradient(circle at center, rgba(57,255,20,0.15), rgba(0,0,0,0.95));
  display: grid;
  place-items: center;
  isolation: isolate;
}

.channel-player-media {
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
  display: none;
}

.channel-player-media.visible {
  display: block;
}

.channel-player-placeholder {
  padding: 1.5rem;
  color: rgba(244,246,255,.78);
  text-align: center;
  max-width: 680px;
  line-height: 1.7;
  letter-spacing: 0.04em;
}

.channel-player-overlay {
  position: absolute;
  inset: auto 0 0;
  z-index: 2;
  padding: 1rem;
  background: linear-gradient(to top, rgba(0,0,0,.84), rgba(0,0,0,.1));
  display: grid;
  gap: 0.4rem;
}

.channel-player-link {
  justify-self: start;
  margin-top: 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.4);
  padding: 0.45rem 0.95rem;
  color: #fff;
  text-decoration: none;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: rgba(247,192,111,.23);
  display: none;
  min-height: 44px;
  min-width: 44px;
  align-items: center;
  justify-content: center;
}

.channel-player-link.visible {
  display: inline-flex;
}

.channel-player-link:focus-visible {
  outline: 2px solid rgba(57,255,20,0.8);
  outline-offset: 2px;
}

.channel-widget-ad {
  margin-top: auto;
  border-radius: 12px;
  border: 1px solid rgba(247,192,111,.28);
  background: rgba(255,255,255,0.04);
  padding: 0.7rem;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 0.6rem;
  align-items: center;
  cursor: pointer;
  position: relative;
  z-index: 4;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.channel-widget-ad:hover,
.channel-widget-ad:focus-visible {
  border-color: rgba(57,255,20,0.75);
  transform: translateY(-1px);
  outline: none;
}

.channel-widget-ad:focus-visible {
  outline: 2px solid rgba(57,255,20,0.8);
  outline-offset: 2px;
}

.channel-widget-logo {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.18);
}

.channel-widget-text {
  min-width: 0;
  display: grid;
  gap: 0.15rem;
  text-align: left;
}

.channel-widget-name {
  font-size: 0.72rem;
  color: rgba(255,255,255,.92);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-widget-meta {
  font-size: 0.64rem;
  color: rgba(244,246,255,.68);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========================================
   8. Decorative Effects
   ======================================== */

.icon-cloud {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  background: 
    radial-gradient(circle at 25% 20%, rgba(57, 255, 20, 0.12), transparent 35%), 
    radial-gradient(circle at 75% 30%, rgba(247, 192, 111, 0.08), transparent 40%),
    radial-gradient(circle at 50% 80%, rgba(0, 255, 176, 0.14), transparent 45%);
  mix-blend-mode: screen;
  opacity: 0;
  animation: iconCloudFadeIn 1.4s ease-out 0.25s forwards;
}

@keyframes iconCloudFadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 0.78;
  }
}

.icon-cloud-item {
  position: absolute;
  left: 0;
  top: 0;
  width: 90px;
  height: 90px;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  will-change: transform, filter;
  pointer-events: none;
  mix-blend-mode: screen;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.72)) brightness(1.03) saturate(1.05);
  transition: filter 0.4s ease;
}

.icon-cloud-item.pulse {
  filter: drop-shadow(0 15px 36px rgba(0, 0, 0, 0.65)) drop-shadow(0 0 25px rgba(57, 255, 120, 0.85)) brightness(1.3) saturate(1.3);
  animation: iconPulseGlow 1.5s ease-in-out;
}


.icon-cloud-item.spotlight-fade {
  animation: iconSpotlightFade 2.2s ease-out;
}

@keyframes iconSpotlightFade {
  0% { opacity: 1; }
  60% { opacity: 0.25; }
  100% { opacity: 0.75; }
}

@keyframes iconPulseGlow {
  0%, 100% {
    filter: drop-shadow(0 15px 36px rgba(0, 0, 0, 0.65)) drop-shadow(0 0 25px rgba(57, 255, 120, 0.85)) brightness(1.3) saturate(1.3);
  }
  50% {
    filter: drop-shadow(0 20px 45px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 40px rgba(247, 192, 111, 0.95)) brightness(1.5) saturate(1.5);
  }
}

body.hero-focus .icon-cloud {
  background: 
    radial-gradient(circle at 25% 20%, rgba(57, 255, 20, 0.18), transparent 38%), 
    radial-gradient(circle at 75% 30%, rgba(247, 192, 111, 0.14), transparent 42%),
    radial-gradient(circle at 50% 80%, rgba(0, 255, 176, 0.2), transparent 48%);
}

body.hero-focus .icon-cloud-item {
  filter: drop-shadow(0 25px 65px rgba(57, 255, 20, 0.6)) brightness(1.2) saturate(1.25);
}

/* ========================================
   9. Animations & Keyframes
   ======================================== */

@keyframes blink {
  0%, 30% { opacity: 1; }
  50% { opacity: 0; }
  80% { opacity: 1; }
}

@keyframes monitorGlow {
  0% { 
    transform: translateY(4px) scale(0.99); 
    filter: brightness(0.4) saturate(0.4);
  }
  15% {
    transform: translateY(2px) scale(0.995);
    filter: brightness(2.5) saturate(0.6);
  }
  35% {
    transform: translateY(0) scale(1.005);
    filter: brightness(1.8) saturate(0.8);
  }
  60% {
    transform: translateY(0) scale(1.01);
    filter: brightness(1.3) saturate(0.95);
  }
  100% { 
    transform: translateY(2px) scale(1); 
    filter: brightness(1) saturate(1);
  }
}

@keyframes tvSnow {
  0% { transform: translateY(0); opacity: 0.45; }
  50% { transform: translateY(4px); opacity: 0.6; }
  100% { transform: translateY(-4px); opacity: 0.45; }
}

@keyframes bootLine {
  0% { 
    width: 7px; 
    box-shadow: 0 0 14px rgba(142, 248, 164, 0.9);
  }
  50% { 
    width: 48%; 
    box-shadow: 0 0 24px rgba(142, 248, 164, 1), 0 0 8px rgba(255, 255, 255, 0.8);
  }
  100% { 
    width: 92%; 
    box-shadow: 0 0 18px rgba(142, 248, 164, 0.95);
  }
}

@keyframes bootOpen {
  0% { 
    clip-path: inset(49% 0 49% 0);
    opacity: 1;
    filter: brightness(3) saturate(0.3);
  }
  20% {
    clip-path: inset(40% 0 40% 0);
    filter: brightness(2.5) saturate(0.5);
  }
  50% {
    clip-path: inset(25% 0 25% 0);
    filter: brightness(1.8) saturate(0.7);
  }
  80% {
    clip-path: inset(8% 0 8% 0);
    filter: brightness(1.2) saturate(0.9);
  }
  100% { 
    clip-path: inset(4% 0 4% 0);
    opacity: 1;
    filter: brightness(1) saturate(1);
  }
}

/* Outer Limits-style console animations */
@keyframes outerLimitsPowerOn {
  0% { 
    transform: scale(0.01, 1) translateY(0);
    filter: brightness(3) contrast(0.5);
    opacity: 0;
  }
  15% {
    transform: scale(1, 0.02) translateY(0);
    filter: brightness(5) contrast(0.3);
    opacity: 0.7;
  }
  30% {
    transform: scale(1.05, 1.08) translateY(-2px);
    filter: brightness(2) contrast(1.2) saturate(0.5);
    opacity: 0.9;
  }
  45% {
    transform: scale(0.98, 0.96) translateY(1px);
    filter: brightness(1.5) contrast(1.5) saturate(0.8);
  }
  60% {
    transform: scale(1.02, 1.03) translateY(-1px);
    filter: brightness(1.3) contrast(1.3);
  }
  80% {
    transform: scale(1, 1) translateY(0);
    filter: brightness(1.15) contrast(1.15) saturate(1.1);
  }
  100% {
    transform: scale(1, 1) translateY(0);
    filter: brightness(1.15) contrast(1.15) saturate(1.1) drop-shadow(0 0 30px rgba(247, 192, 111, 0.8));
    opacity: 1;
  }
}

@keyframes outerLimitsPowerOff {
  0% {
    transform: scale(1, 1) translateY(0);
    filter: brightness(1.15) contrast(1.15) saturate(1.1) drop-shadow(0 0 30px rgba(247, 192, 111, 0.8));
    opacity: 1;
  }
  20% {
    transform: scale(1.02, 1) translateY(0);
    filter: brightness(1.5) contrast(1.3) saturate(0.8);
  }
  40% {
    transform: scale(0.98, 1.05) translateY(-1px);
    filter: brightness(2) contrast(0.7) saturate(0.5);
  }
  60% {
    transform: scale(1, 0.02) translateY(0);
    filter: brightness(3) contrast(0.3);
    opacity: 0.6;
  }
  80% {
    transform: scale(0.01, 0.5) translateY(0);
    filter: brightness(5) contrast(0.1);
    opacity: 0.2;
  }
  100% {
    transform: scale(0, 1) translateY(0);
    filter: brightness(0) contrast(0);
    opacity: 0;
  }
}

@keyframes scanLineFlicker {
  0%, 100% { 
    transform: translateY(0) scaleY(1);
    opacity: 0.15;
  }
  25% {
    transform: translateY(-100%) scaleY(1.5);
    opacity: 0.25;
  }
  50% {
    transform: translateY(-50%) scaleY(2);
    opacity: 0.35;
  }
  75% {
    transform: translateY(-150%) scaleY(1.2);
    opacity: 0.2;
  }
}

@keyframes horizontalDistortion {
  0%, 100% { transform: translateX(0) scaleX(1); }
  25% { transform: translateX(-2px) scaleX(1.01); }
  50% { transform: translateX(3px) scaleX(0.99); }
  75% { transform: translateX(-1px) scaleX(1.005); }
}

@keyframes verticalHold {
  0%, 100% { transform: translateY(0) scaleY(1); }
  33% { transform: translateY(2px) scaleY(1.01); }
  66% { transform: translateY(-2px) scaleY(0.99); }
}

@keyframes channelSwitch {
  0% {
    transform: scale(1, 1);
    filter: brightness(1) contrast(1);
    opacity: 1;
  }
  8% {
    transform: scale(1.15, 0.03);
    filter: brightness(6) contrast(0.2) saturate(0);
    opacity: 0.85;
  }
  15% {
    transform: scale(0.08, 1.3);
    filter: brightness(4) contrast(0.4) hue-rotate(45deg) saturate(0.3);
    opacity: 0.4;
  }
  22% {
    transform: scale(1.4, 0.06);
    filter: brightness(5) contrast(0.15) saturate(0);
    opacity: 0.6;
  }
  30% {
    transform: scale(0.04, 1.5);
    filter: brightness(7) contrast(0.08) hue-rotate(-30deg);
    opacity: 0.25;
  }
  38% {
    transform: scale(1.2, 0.1);
    filter: brightness(5) contrast(0.2) saturate(0.2);
    opacity: 0.5;
  }
  46% {
    transform: scale(0.12, 1.2);
    filter: brightness(4) contrast(0.5) saturate(0.4);
    opacity: 0.55;
  }
  54% {
    transform: scale(1.1, 0.15);
    filter: brightness(3.5) contrast(0.6);
    opacity: 0.65;
  }
  62% {
    transform: scale(0.85, 1.15);
    filter: brightness(2.5) contrast(0.9) saturate(0.7);
    opacity: 0.75;
  }
  72% {
    transform: scale(1.08, 0.92);
    filter: brightness(1.8) contrast(1.1) saturate(0.85);
    opacity: 0.85;
  }
  82% {
    transform: scale(0.94, 1.05);
    filter: brightness(1.4) contrast(1.15);
    opacity: 0.92;
  }
  92% {
    transform: scale(1.02, 0.98);
    filter: brightness(1.15) contrast(1.08);
    opacity: 0.97;
  }
  100% {
    transform: scale(1, 1);
    filter: brightness(1) contrast(1);
    opacity: 1;
  }
}

/* CRT Power-off animation - Enhanced classic collapse to center line */
@keyframes crtPowerOff {
  0% {
    transform: scale(1, 1) translateY(0);
    filter: brightness(1.15) contrast(1.15) saturate(1.1);
    opacity: 1;
  }
  10% {
    transform: scale(1.03, 0.92) translateY(0);
    filter: brightness(1.4) contrast(1.25) saturate(0.95);
    opacity: 1;
  }
  18% {
    transform: scale(1.02, 0.75) translateY(0);
    filter: brightness(1.8) contrast(1.35) saturate(0.75);
    opacity: 0.98;
  }
  28% {
    transform: scale(1, 0.45) translateY(0);
    filter: brightness(2.5) contrast(0.85) saturate(0.5);
    opacity: 0.92;
  }
  38% {
    transform: scale(0.99, 0.22) translateY(0);
    filter: brightness(3.2) contrast(0.55) saturate(0.3);
    opacity: 0.82;
  }
  48% {
    transform: scale(0.98, 0.1) translateY(0);
    filter: brightness(4) contrast(0.35) saturate(0.15);
    opacity: 0.68;
  }
  58% {
    transform: scale(0.95, 0.04) translateY(0);
    filter: brightness(5.5) contrast(0.2) saturate(0.05);
    opacity: 0.5;
  }
  68% {
    transform: scale(0.85, 0.02) translateY(0);
    filter: brightness(7) contrast(0.12) saturate(0);
    opacity: 0.35;
  }
  78% {
    transform: scale(0.6, 0.015) translateY(0);
    filter: brightness(9) contrast(0.08) saturate(0);
    opacity: 0.22;
  }
  88% {
    transform: scale(0.25, 0.01) translateY(0);
    filter: brightness(12) contrast(0.04) saturate(0);
    opacity: 0.1;
  }
  95% {
    transform: scale(0.05, 0.008) translateY(0);
    filter: brightness(15) contrast(0.02) saturate(0);
    opacity: 0.03;
  }
  100% {
    transform: scale(0, 0) translateY(0);
    filter: brightness(0) contrast(0) saturate(0);
    opacity: 0;
  }
}

.terminal-window.monitor-off-animation {
  animation: crtPowerOff 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

/* Channel watermark styling */
.channel-watermark {
  position: absolute;
  bottom: 0.55rem;
  right: 0.55rem;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-family: 'Space Mono', 'Fira Code', monospace;
  font-size: clamp(0.6rem, 0.8vw, 0.9rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: rgba(57, 255, 20, 0.55);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8), 0 0 2px rgba(57, 255, 20, 0.4);
  opacity: 0;
  transition: opacity 0.6s ease, color 0.3s ease;
  z-index: 4;
  pointer-events: none;
  padding: 0.22rem 0.35rem;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 4px;
  border: 1px solid rgba(57, 255, 20, 0.15);
}

.channel-watermark-icon {
  width: 0.9rem;
  height: 0.9rem;
  opacity: 0.5;
  filter: grayscale(1) brightness(1.4) hue-rotate(52deg) saturate(3);
}

.terminal-window.powered .channel-watermark,
.terminal-window.powering .channel-watermark {
  opacity: 1;
}

.terminal-window.outer-limits-active .channel-watermark {
  color: rgba(247, 192, 111, 0.65);
  text-shadow: 0 0 6px rgba(247, 192, 111, 0.8), 0 0 3px rgba(247, 192, 111, 0.6);
  border-color: rgba(247, 192, 111, 0.3);
  animation: watermarkPulse 2s ease-in-out infinite;
}

@keyframes watermarkPulse {
  0%, 100% {
    opacity: 0.85;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.03);
  }
}

/* Enhanced CRT bezel effect */
.terminal-window::before {
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.14), transparent 45%);
  mix-blend-mode: screen;
  opacity: 0.95;
}

.terminal-window::after {
  border: 2px solid rgba(255, 255, 255, 0.05);
  box-shadow: 
    inset 0 -20px 40px rgba(0, 0, 0, 0.8),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  filter: drop-shadow(0 10px 35px rgba(0, 0, 0, 0.7));
}

.terminal-window.powered::after,
.terminal-window.powering::after {
  box-shadow: 
    inset 0 -20px 40px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px rgba(57, 255, 20, 0.08),
    0 0 30px rgba(57, 255, 20, 0.2);
}

/* ========================================
   10. Responsive Design
   ======================================== */

@media (max-width: 1200px) {
  .story-section {
    min-height: calc(var(--safe-viewport-h) - var(--page-padding-y) - var(--page-footer-padding));
    max-height: calc(var(--safe-viewport-h) - var(--page-padding-y) - var(--page-footer-padding));
    grid-template-rows: minmax(0, 1.32fr) minmax(0, 1fr);
  }

  .terminal-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(0.7rem, 1.2vw, 1rem);
  }

  .welcome-console {
    width: 100%;
  }
}

@media (max-height: 920px) and (min-width: 901px) {
  .page {
    --story-gap: clamp(0.55rem, 1vh, 0.8rem);
    grid-template-rows: minmax(0, 1.2fr) minmax(0, 0.9fr);
  }

  .welcome-console {
    padding: clamp(0.7rem, 1vw, 0.95rem);
  }

  .hero-welcome-detail {
    font-size: clamp(13px, 0.95vw, 15px);
    line-height: 1.45;
  }

  .terminal-grid {
    gap: clamp(0.45rem, 0.9vw, 0.75rem);
  }

  .terminal-window {
    aspect-ratio: 1.62;
    padding: clamp(0.7rem, 0.95vw, 0.95rem);
  }

  .screen-wrapper {
    min-height: 118px;
  }
}

@media (min-width: 901px) and (max-width: 1200px) {
  .terminal-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .page {
    min-height: calc(var(--safe-viewport-h));
    padding:
      calc(var(--page-padding-y) + var(--safe-top))
      var(--page-padding-x)
      calc(var(--page-padding-y) + var(--safe-bottom));
    overflow: auto;
  }

  .story-section {
    min-height: auto;
    max-height: none;
    padding: 0.8rem;
    overflow: visible;
  }

  .terminal-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .welcome-console {
    width: 100%;
    aspect-ratio: auto;
    min-height: auto;
    padding: 1rem;
  }

  .terminal-window {
    aspect-ratio: auto;
    min-height: 280px;
  }

  .hero-welcome-detail {
    max-width: 100%;
  }
  
  /* Reduce icon-cloud visual noise on mobile */
  .icon-cloud {
    background: 
      radial-gradient(circle at 25% 20%, rgba(57, 255, 20, 0.06), transparent 35%), 
      radial-gradient(circle at 75% 30%, rgba(247, 192, 111, 0.04), transparent 40%),
      radial-gradient(circle at 50% 80%, rgba(0, 255, 176, 0.07), transparent 45%);
    opacity: 0.5;
  }
  
  .icon-cloud-item {
    width: 50px !important;
    height: 50px !important;
    opacity: 0.3 !important;
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.5)) brightness(1.0) saturate(1.0);
  }
  
  .icon-cloud-item.pulse {
    filter: drop-shadow(0 10px 25px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 15px rgba(57, 255, 120, 0.65)) brightness(1.15) saturate(1.15);
  }
  
  body.hero-focus .icon-cloud {
    background: 
      radial-gradient(circle at 25% 20%, rgba(57, 255, 20, 0.08), transparent 38%), 
      radial-gradient(circle at 75% 30%, rgba(247, 192, 111, 0.06), transparent 42%),
      radial-gradient(circle at 50% 80%, rgba(0, 255, 176, 0.09), transparent 48%);
  }
  
  body.hero-focus .icon-cloud-item {
    filter: drop-shadow(0 12px 30px rgba(57, 255, 20, 0.4)) brightness(1.1) saturate(1.1);
  }
}

/* ========================================
   11. Accessibility
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .terminal-window {
    transition: none;
    animation: none;
  }
  
  .icon-cloud-item {
    animation: none;
  }
  
  .terminal-cursor,
  .terminal-widget-cursor {
    animation: none;
    opacity: 1;
  }
  
  .hero-name-highlight::after {
    transition: none;
  }
}
