/* =========================
   CRT BLOOM — style.css
   ========================= */

:root{
  --bg:#050508;
  --tube:#07100a;
  --phosphor:#77ff77;
  --phosphor-dim:#3fe35c;
  --red:#ff3b3b;
  --scan:rgba(255,255,255,.06);
  --noise:rgba(255,255,255,.08);

  --tv:#1a1a1f;
  --tv2:#101014;
  --bezel:#0e0f12;

  --shadow: 0 24px 80px rgba(0,0,0,.55);
  --radius: 28px;
  --screen-radius: 22px;

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: radial-gradient(1200px 600px at 50% 40%, #11111a 0%, #050508 55%, #020203 100%);
  color:#d8ffe0;
  font-family: var(--mono);
  overflow:hidden; /* critical: scroll only inside screen */
}

/* ========= Boot overlay ========= */
#boot {
  position:fixed;
  inset:0;
  background:#000;
  z-index:9999;
  display:flex;
  align-items:center;
  justify-content:center;
  pointer-events:none;
}

#boot .dot{
  width:6px;height:6px;border-radius:50%;
  background:#fff;
  opacity:0;
  filter: blur(.5px);
  box-shadow: 0 0 18px rgba(255,255,255,.9);
}

body.booting #app{ opacity:0; transform: scale(.995); }
body.ready   #app{ opacity:1; transform: none; transition: opacity 700ms ease, transform 900ms ease; }

/* ========= TV Frame Layout ========= */
#app{
  height:100%;
  display:grid;
  place-items:center;
}

.tv{
  width:min(1100px, 94vw);
  height:min(720px, 90vh);
  background: linear-gradient(180deg, var(--tv) 0%, var(--tv2) 100%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position:relative;
  padding:22px;
  display:grid;
  grid-template-columns: 1fr 210px; /* screen + side panel */
  gap:18px;
  border: 1px solid rgba(255,255,255,.06);
}

.tv::before{
  content:"";
  position:absolute;
  inset:10px;
  border-radius: calc(var(--radius) - 10px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05),
              inset 0 0 50px rgba(0,0,0,.6);
  pointer-events:none;
}

/* ========= Screen ========= */
.screenWrap{
  position:relative;
  border-radius: var(--screen-radius);
  background: linear-gradient(180deg, #0a0f0b 0%, #050a06 100%);
  overflow:hidden;
  border: 1px solid rgba(255,255,255,.05);
  box-shadow:
    inset 0 0 0 2px rgba(0,0,0,.6),
    inset 0 0 60px rgba(0,0,0,.8),
    inset 0 0 160px rgba(10,255,120,.05);
}

/* beveled inner bezel */
.screenWrap::before{
  content:"";
  position:absolute;
  inset:10px;
  border-radius: calc(var(--screen-radius) - 10px);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.04),
    inset 0 0 35px rgba(0,0,0,.85);
  pointer-events:none;
}

/* CRT curvature illusion */
.screenWrap::after{
  content:"";
  position:absolute;
  inset:-2px;
  border-radius: var(--screen-radius);
  background:
    radial-gradient(120% 90% at 50% 35%,
      rgba(255,255,255,.09) 0%,
      rgba(255,255,255,.04) 20%,
      rgba(255,255,255,.00) 55%),
    radial-gradient(90% 120% at 50% 80%,
      rgba(0,0,0,.00) 0%,
      rgba(0,0,0,.35) 60%,
      rgba(0,0,0,.65) 100%);
  mix-blend-mode: screen;
  pointer-events:none;
  opacity:.55;
}

/* Screen viewport — scrolling happens here */
.screen{
  position:relative;
  height:100%;
  padding:22px 22px 18px 22px;
  overflow:auto;   /* ALL scrolling here */
  scrollbar-width: thin;
  scrollbar-color: rgba(120,255,160,.35) rgba(0,0,0,.25);
}

/* Webkit scrollbars */
.screen::-webkit-scrollbar{ width:10px; }
.screen::-webkit-scrollbar-track{ background: rgba(0,0,0,.28); border-radius:10px; }
.screen::-webkit-scrollbar-thumb{ background: rgba(120,255,160,.25); border-radius:10px; }

/* ========= CRT FX layers ========= */
.fx-scanlines, .fx-noise, .fx-vignette, .fx-wobble {
  position:absolute; inset:0; pointer-events:none; z-index:4;
}

.fx-scanlines{
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0) 0px,
    rgba(255,255,255,0) 2px,
    rgba(255,255,255,.06) 3px
  );
  opacity:.22;
  mix-blend-mode: overlay;
  animation: scan-drift 6s linear infinite;
}

@keyframes scan-drift{
  0%{ transform: translateY(0); }
  100%{ transform: translateY(12px); }
}

.fx-noise{
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
  opacity:.14;
  mix-blend-mode: screen;
  animation: noise-flicker 0.9s steps(2,end) infinite;
}

@keyframes noise-flicker{
  0%,100%{ opacity:.11; }
  50%{ opacity:.17; }
}

.fx-vignette{
  background: radial-gradient(140% 120% at 50% 45%,
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,.28) 55%,
    rgba(0,0,0,.62) 100%);
  opacity:.95;
}

.fx-wobble{
  opacity:1;
}

/* Wobble is applied via class to .screenWrap for better performance */
.screenWrap.wobble{
  animation: wobble 5.8s ease-in-out infinite;
}
@keyframes wobble{
  0%,100%{ transform: translate(0,0) skewX(0deg); }
  25%{ transform: translate(.6px,-.4px) skewX(.08deg); }
  50%{ transform: translate(-.4px,.5px) skewX(-.06deg); }
  75%{ transform: translate(.4px,.2px) skewX(.05deg); }
}

/* Flicker transition */
.screenWrap.flicker{
  animation: flick 240ms steps(2,end) 1;
}
@keyframes flick{
  0%{ filter: brightness(1) contrast(1); }
  40%{ filter: brightness(.65) contrast(1.2); }
  70%{ filter: brightness(1.35) contrast(1.1); }
  100%{ filter: brightness(1) contrast(1); }
}

/* ========= Text bloom (phosphor glow) ========= */
.bloom{
  text-shadow:
    0 0 10px rgba(60,255,120,.35),
    0 0 22px rgba(60,255,120,.18),
    0 0 2px rgba(255,255,255,.10);
}

h1,h2,h3{
  margin:0 0 10px 0;
  letter-spacing:.04em;
}

h1{ font-size: 20px; color: #d9ffdf; }
h2{ font-size: 16px; color: #caffd3; }
h3{ font-size: 14px; color: #b8ffc7; }

p,li{ font-size: 13px; line-height: 1.6; color: #c9ffd4; }
a{ color: #b4ffb8; text-decoration: none; border-bottom: 1px dotted rgba(180,255,184,.45); }
a:hover{ border-bottom-color: rgba(180,255,184,.95); }

hr{
  border:none;
  height:1px;
  background: linear-gradient(90deg, rgba(120,255,160,0), rgba(120,255,160,.35), rgba(120,255,160,0));
  margin: 16px 0;
}

/* ========= Channel number HUD ========= */
.hud{
  position:absolute;
  top:14px;
  right:16px;
  z-index:6;
  font-size: 26px;
  color: var(--phosphor);
  letter-spacing: .08em;
  text-shadow:
    0 0 10px rgba(60,255,120,.45),
    0 0 22px rgba(60,255,120,.22);
  opacity:.95;
  user-select:none;
}

/* ========= Side panel buttons ========= */
.panel{
  border-radius: 20px;
  background: linear-gradient(180deg, #0f0f15 0%, #0b0b10 100%);
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.8);
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:10px;
  position:relative;
  overflow:hidden;
}

.panel .label{
  font-size:12px;
  color: rgba(220,220,230,.85);
  letter-spacing:.12em;
  margin: 2px 0 10px 2px;
  opacity:.85;
}

.chanbtn{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 10px;
  border-radius:14px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.25));
  border: 1px solid rgba(255,255,255,.07);
  color:#e9ffe9;
  cursor:pointer;
  text-decoration:none;
  user-select:none;
}

.chanbtn:hover{
  border-color: rgba(140,255,170,.35);
  box-shadow: 0 0 0 2px rgba(140,255,170,.08);
}

.chanbtn .left{
  display:flex; align-items:center; gap:10px;
}

.badge{
  width:44px;
  padding:4px 0;
  text-align:center;
  border-radius:10px;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.06);
  color: rgba(220,255,220,.95);
  font-weight:700;
}

.small{
  font-size:11px;
  opacity:.9;
}

.panel .foot{
  margin-top:auto;
  font-size:11px;
  opacity:.7;
  color: rgba(220,220,230,.7);
  line-height:1.5;
}

/* ========= Home Broadcast Window ========= */
.broadcast{
  border-radius: 16px;
  padding: 12px 12px;
  border: 1px solid rgba(120,255,160,.22);
  background: rgba(0,0,0,.25);
  box-shadow: inset 0 0 25px rgba(60,255,120,.06);
  margin: 14px 0 10px 0;
}

.broadcast .title{
  font-size:12px;
  letter-spacing:.12em;
  opacity:.85;
  margin-bottom:6px;
}

.broadcast .msg{
  font-size:13px;
  line-height:1.6;
}

/* ========= Terminal posts ========= */
.post{
  padding: 12px 12px;
  border-radius: 14px;
  background: rgba(0,0,0,.20);
  border: 1px solid rgba(120,255,160,.12);
  margin-bottom: 12px;
}
.post .head{
  color: #bfffc9;
  font-weight:700;
  margin-bottom:8px;
}

/* ========= Snapshots gallery ========= */
.gallery{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:10px;
}
.gallery a{
  border-bottom:none;
}
.thumb{
  width:100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.7);
  filter: contrast(1.05) saturate(1.05);
}

/* Lightbox */
#lightbox{
  position:fixed; inset:0;
  background: rgba(0,0,0,.75);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:9998;
}
#lightbox img{
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 20px 90px rgba(0,0,0,.55);
}

/* ========= Tape Deck ========= */
.tapeWrap{
  display:grid;
  place-items:center;
  margin: 18px 0 10px;
}

.tape{
  width:min(520px, 92%);
  height: 300px;
  border-radius: 22px;
  position:relative;
  transform: perspective(900px) rotateX(8deg);
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(0,0,0,.25)),
    radial-gradient(120% 120% at 20% 20%, rgba(255,0,200,.18), rgba(0,0,0,0) 55%),
    radial-gradient(120% 120% at 80% 70%, rgba(0,200,255,.16), rgba(0,0,0,0) 55%),
    rgba(0,0,0,.30);
  border: 1px solid rgba(255,255,255,.10);
  box-shadow:
    0 18px 50px rgba(0,0,0,.45),
    inset 0 0 0 2px rgba(0,0,0,.55),
    inset 0 0 60px rgba(255,0,200,.08);
}

.tape:before{
  content:"";
  position:absolute;
  inset:16px;
  border-radius: 16px;
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: inset 0 0 40px rgba(0,0,0,.6);
}

.tapeLabel{
  position:absolute;
  left:28px;
  right:28px;
  top:28px;
  height: 78px;
  border-radius: 14px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  display:flex;
  align-items:center;
  padding: 10px 12px;
  z-index:2;
}

.tapeLabel .hand{
  width:100%;
  font-family: "Comic Sans MS", "Bradley Hand", "Segoe Print", cursive;
  font-size: 20px;
  color: rgba(255,255,255,.92);
  text-shadow: 0 0 12px rgba(255,0,200,.25);
  outline:none;
  border:none;
  background: transparent;
}

.reels{
  position:absolute;
  inset: 120px 28px 70px 28px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:20px;
  z-index:2;
  align-items:center;
}

.reel{
  width: 130px; height: 130px;
  border-radius: 50%;
  margin: auto;
  background:
    radial-gradient(circle at 50% 50%, rgba(0,0,0,.75) 0 18px, rgba(255,255,255,.08) 19px 52px, rgba(0,0,0,.30) 53px 100%);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: inset 0 0 25px rgba(0,0,0,.6);
  position:relative;
}
.reel:after{
  content:"";
  position:absolute;
  inset: 54px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  box-shadow: 0 0 12px rgba(0,0,0,.5);
}

.transport{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:center;
  margin: 14px 0 4px;
}

.btn{
  border:none;
  padding:10px 12px;
  border-radius: 14px;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.08);
  color:#eaffea;
  cursor:pointer;
  font-family: var(--mono);
  font-size:12px;
}
.btn:hover{
  border-color: rgba(140,255,170,.35);
}

.signalLine{
  margin-top:10px;
  font-size:12px;
  opacity:.9;
}

/* ========= Juiceboard static vibe ========= */
.staticPane{
  position:relative;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.22);
  padding: 14px 14px;
  overflow:hidden;
}
.staticPane:before{
  content:"";
  position:absolute; inset:0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0) 0px,
    rgba(255,255,255,0) 1px,
    rgba(255,255,255,.09) 2px
  );
  opacity:.18;
  mix-blend-mode: overlay;
  animation: scan-drift 5s linear infinite;
  pointer-events:none;
}
.staticPane:after{
  content:"";
  position:absolute; inset:0;
  background: radial-gradient(100% 120% at 50% 50%, rgba(255,255,255,.06), rgba(0,0,0,0) 60%);
  opacity:.35;
  pointer-events:none;
}
.staticPane > *{ position:relative; z-index:1; }

.lists{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.lists ul{ margin:8px 0 0 18px; padding:0; }
.lists li{ margin: 6px 0; }

/* ========= Responsive ========= */
@media (max-width: 900px){
  .tv{ grid-template-columns: 1fr; height: 92vh; }
  .panel{ flex-direction:row; flex-wrap:wrap; gap:8px; }
  .panel .label, .panel .foot{ display:none; }
  .chanbtn{ flex: 1 1 48%; }
  .gallery{ grid-template-columns: repeat(2, 1fr); }
}
