/* ==========================================================================
   LOS AVETODOS — PORTAL
   A cinematic front door. Dark stage, three glowing rooms, one keystone.
   ========================================================================== */

:root {
  --bg-0: #07070a;
  --bg-1: #0b0b11;
  --bg-2: #12121b;
  --ink: #eceaf2;
  --ink-dim: #a2a0b0;
  --ink-faint: #6d6a7d;
  --line: rgba(255, 255, 255, 0.08);
  --jf: #f5c66b;
  --jf-2: #ff9d4d;
  --retro: #5dff9e;
  --retro-2: #ff5db1;
  --req: #6bb8ff;
  --req-2: #7a5dff;
  --danger: #ff5d5d;
  --ok: #46e08a;
  --rad: 18px;
  --font-display: "Syne", system-ui, sans-serif;
  --font-body: "Space Grotesk", system-ui, sans-serif;
  --font-pixel: "VT323", monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(64, 66, 110, 0.20), transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(245, 198, 107, 0.35); color: #fff; }

/* ------------------------------- layers -------------------------------- */

#bg-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  opacity: 0.9;
}
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(90% 70% at 50% 42%, transparent 40%, rgba(0, 0, 0, 0.55) 100%);
}
.grain {
  position: fixed; inset: -50%; z-index: 2; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  opacity: 0.055;
  animation: grain-shift 900ms steps(3) infinite;
  mix-blend-mode: overlay;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-1.6%, 1.1%); }
  66% { transform: translate(1.2%, -1.4%); }
  100% { transform: translate(0, 0); }
}
.scene-glow {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0; transition: opacity 900ms var(--ease-out);
  background: radial-gradient(70% 55% at 50% 62%, var(--glow, rgba(245,198,107,0.16)), transparent 70%);
}
body[data-scene="jf"] .scene-glow { --glow: rgba(245, 198, 107, 0.17); opacity: 1; }
body[data-scene="retro"] .scene-glow { --glow: rgba(93, 255, 158, 0.14); opacity: 1; }
body[data-scene="req"] .scene-glow { --glow: rgba(107, 184, 255, 0.16); opacity: 1; }

/* ------------------------------- topbar --------------------------------- */

.topbar {
  position: relative; z-index: 5;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 22px 28px 0;
}
.wordmark { line-height: 1.05; }
.wm-main {
  font-family: var(--font-display);
  font-weight: 800; font-size: clamp(18px, 2.2vw, 24px);
  letter-spacing: 0.14em;
  background: linear-gradient(92deg, #fff 20%, #d9d5e6 45%, #fff 70%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.wm-sub {
  display: block; margin-top: 6px;
  font-size: 10px; letter-spacing: 0.42em;
  color: var(--ink-faint);
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.sys-status { display: flex; gap: 7px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 999px; }
.led {
  width: 7px; height: 7px; border-radius: 50%;
  background: #3a3a46;
  box-shadow: 0 0 0 0 transparent;
  transition: background 300ms ease, box-shadow 300ms ease;
}
.led.ok { background: var(--ok); box-shadow: 0 0 8px 1px rgba(70, 224, 138, 0.55); }
.led.bad { background: var(--danger); box-shadow: 0 0 8px 1px rgba(255, 93, 93, 0.5); }
.icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink-dim);
  cursor: pointer;
  transition: color 200ms ease, border-color 200ms ease, transform 200ms var(--ease-spring);
}
.icon-btn:hover { color: var(--ink); border-color: rgba(255,255,255,0.2); transform: translateY(-1px); }
.icon-btn .off { display: none; }
.icon-btn.muted .on { display: none; }
.icon-btn.muted .off { display: block; }

/* -------------------------------- stage --------------------------------- */

.stage {
  position: relative; z-index: 4;
  height: calc(100% - 96px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: clamp(18px, 3.4vh, 34px);
  padding: 0 24px 12px;
}
.stage-intro { text-align: center; }
.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(30px, 5.2vw, 58px);
  letter-spacing: 0.02em;
  line-height: 1.02;
}
.ht-line {
  display: block;
  opacity: 0;
  transform: translateY(26px) skewX(-6deg);
  animation: line-in 900ms var(--ease-out) forwards;
}
.ht-line[data-i="1"] { animation-delay: 140ms; }
@keyframes line-in {
  to { opacity: 1; transform: translateY(0) skewX(0deg); }
}
.hero-tag {
  margin: 12px 0 0;
  font-size: clamp(12px, 1.3vw, 14px);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-faint);
  opacity: 0;
  animation: fade-up 800ms var(--ease-out) 420ms forwards;
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* -------------------------------- doors --------------------------------- */

.doors {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(14px, 2vw, 26px);
  width: min(1240px, 100%);
  perspective: 1400px;
}
.door {
  position: relative;
  height: clamp(340px, 56vh, 470px);
  border-radius: var(--rad);
  outline: none;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 480ms var(--ease-spring), filter 480ms ease;
  opacity: 0;
  animation: door-in 1000ms var(--ease-out) forwards;
}
.door:nth-child(1) { animation-delay: 300ms; }
.door:nth-child(2) { animation-delay: 430ms; }
.door:nth-child(3) { animation-delay: 560ms; }
@keyframes door-in {
  from { opacity: 0; transform: translateY(46px) rotateX(9deg) scale(0.96); }
  to { opacity: 1; transform: translateY(0) rotateX(0) scale(1); }
}
.door:focus-visible .door-frame { border-color: rgba(255,255,255,0.5); }

.door-inner {
  position: relative;
  height: 100%;
  border-radius: var(--rad);
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(140% 100% at 50% 0%, rgba(255, 255, 255, 0.045), transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,0.035), rgba(0,0,0,0.28)),
    var(--bg-2);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
  transition: transform 420ms var(--ease-spring), box-shadow 420ms ease, border-color 300ms ease;
}
.door-frame { position: relative; height: 100%; display: flex; flex-direction: column; }

.marquee-tag {
  position: absolute; top: 16px; left: 16px; z-index: 6;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(8, 8, 12, 0.55);
  backdrop-filter: blur(8px);
  font-size: 10px; letter-spacing: 0.34em;
  color: var(--ink-dim);
}
.marquee-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2.2s ease-in-out infinite;
}
.door-jf .marquee-dot { background: var(--jf); color: var(--jf); }
.door-retro .marquee-dot { background: var(--retro); color: var(--retro); }
.door-req .marquee-dot { background: var(--req); color: var(--req); }
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  50% { box-shadow: 0 0 0 5px transparent; opacity: 0.65; }
}

/* door visuals */
.door-visual {
  position: relative;
  flex: 1;
  margin: 44px 16px 0;
  border-radius: 12px;
  overflow: hidden;
  background: radial-gradient(90% 90% at 50% 20%, rgba(255,255,255,0.05), transparent 70%);
  min-height: 120px;
}
.door-visual > img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 900ms ease, transform 1200ms var(--ease-out);
}
.door-visual > img.loaded { opacity: 1; }
.door-visual > img.b { z-index: -1; }
.door-fallback {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: rgba(255, 255, 255, 0.18);
  font-size: 44px;
}

.door-caption {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 14px;
  padding: 13px 18px 14px;
}
.door-caption-text { min-width: 0; }
.door-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(20px, 2.1vw, 26px);
  letter-spacing: 0.08em;
}
.door-sub { margin-top: 5px; font-size: 12.5px; color: var(--ink-dim); letter-spacing: 0.02em; min-height: 1.2em; }

.door-cue {
  position: static; z-index: 7; flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(8, 8, 12, 0.5);
  font-size: 11px; letter-spacing: 0.3em;
  color: var(--ink-faint);
  opacity: 0.7;
  white-space: nowrap;
  transition: opacity 250ms ease, transform 250ms var(--ease-spring), color 250ms ease, border-color 250ms ease;
}
.door:hover .door-cue, .door:focus-visible .door-cue {
  opacity: 1; transform: translateX(4px); color: var(--ink);
}
.door-jf:hover .door-cue { color: var(--jf); }
.door-retro:hover .door-cue { color: var(--retro); }
.door-req:hover .door-cue { color: var(--req); }

.door-shine {
  position: absolute; inset: 0; z-index: 6; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.09) 46%, transparent 60%);
  transform: translateX(-130%);
  transition: transform 900ms var(--ease-out);
}
.door:hover .door-shine { transform: translateX(130%); }

/* per-room accents on hover */
.door-jf:hover .door-inner {
  border-color: rgba(245, 198, 107, 0.45);
  box-shadow: 0 40px 90px -34px rgba(245, 157, 77, 0.4);
}
.door-retro:hover .door-inner {
  border-color: rgba(93, 255, 158, 0.5);
  box-shadow: 0 40px 90px -34px rgba(93, 255, 158, 0.35), 0 0 0 1px rgba(93,255,158,0.12) inset;
}
.door-req:hover .door-inner {
  border-color: rgba(107, 184, 255, 0.5);
  box-shadow: 0 40px 90px -34px rgba(122, 93, 255, 0.4);
}

/* jellyfin strip */
.door-strip {
  position: relative; z-index: 5;
  display: flex; gap: 8px; padding: 6px 18px 16px;
  overflow: hidden;
  height: 104px;
  align-items: center;
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.door-strip img {
  height: 74px; width: 50px; flex: 0 0 auto;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.1);
  filter: saturate(0.9) brightness(0.92);
  transition: transform 300ms var(--ease-spring), filter 300ms ease;
}
.door-strip:hover img { transform: translateY(-3px); }
.door-strip .track { display: flex; gap: 8px; animation: strip-scroll 46s linear infinite; }
.door-strip:hover .track { animation-play-state: paused; }
@keyframes strip-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* retro */
.retro-visual { image-rendering: pixelated; }
.retro-visual > img { object-fit: contain; background: rgba(6, 10, 8, 0.6); }
.retro-title { color: var(--retro); text-shadow: 0 0 22px rgba(93, 255, 158, 0.35); }
.crt-lines {
  position: absolute; inset: 0; z-index: 7; pointer-events: none;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,0.028) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
  opacity: 0.7;
}
.door-retro .door-cue span { font-family: var(--font-pixel); font-size: 15px; letter-spacing: 0.18em; }

/* requests stack */
.req-visual { display: flex; align-items: center; justify-content: center; }
.req-stack {
  position: relative;
  width: 132px; height: 100%;
  display: grid; place-items: center;
}
.req-stack .card {
  position: absolute;
  width: 96px; height: 132px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 20px 40px -18px rgba(0, 0, 0, 0.8);
  background: linear-gradient(160deg, #1a1c26, #101119);
  transition: transform 700ms var(--ease-spring), opacity 700ms ease;
}
.req-stack .card img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 700ms ease; }
.req-stack .card img.loaded { opacity: 1; }
.req-stack .card .ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 26px; color: rgba(255,255,255,0.14);
}
/* initial fan-out pose */
.req-stack .card:nth-child(1) { transform: translateX(-26px) rotate(-9deg) scale(0.94); z-index: 3; }
.req-stack .card:nth-child(2) { transform: translateX(26px) rotate(9deg) scale(0.94); z-index: 3; }
.req-stack .card:nth-child(3) { transform: translateY(10px) scale(0.88); z-index: 2; }
.door-req:hover .req-stack .card:nth-child(1) { transform: translateX(-44px) rotate(-14deg) scale(0.96); }
.door-req:hover .req-stack .card:nth-child(2) { transform: translateX(44px) rotate(14deg) scale(0.96); }
.door-req:hover .req-stack .card:nth-child(3) { transform: translateY(16px) scale(0.9); }
.req-title { color: var(--req); text-shadow: 0 0 22px rgba(107, 184, 255, 0.35); }

.scanbeam {
  position: absolute; left: 10%; right: 10%; top: -20%; z-index: 8; pointer-events: none;
  height: 34%;
  background: linear-gradient(180deg, transparent, rgba(107, 184, 255, 0.10) 60%, rgba(107, 184, 255, 0.32) 98%, transparent);
  opacity: 0;
  transition: opacity 600ms ease;
}
.door-req:hover .scanbeam { opacity: 1; animation: beam 2.4s ease-in-out infinite; }
@keyframes beam {
  0% { top: -28%; }
  55% { top: 108%; }
  100% { top: -28%; }
}

/* ------------------------------ stage foot ------------------------------ */

.stage-foot { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.keystone {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  color: var(--ink-faint);
  font-family: var(--font-body);
  font-size: 11px; letter-spacing: 0.3em;
  cursor: pointer;
  transition: all 250ms var(--ease-spring);
  opacity: 0;
  animation: fade-up 900ms var(--ease-out) 900ms forwards;
}
.keystone:hover {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -14px rgba(0, 0, 0, 0.9);
}
.version-note {
  font-size: 10px; letter-spacing: 0.26em; color: rgba(255, 255, 255, 0.16);
}

/* ------------------------------ transition ------------------------------- */

.transition {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: var(--bg-0);
  opacity: 0; pointer-events: none;
  transition: opacity 420ms ease;
}
.transition.active { opacity: 1; pointer-events: auto; }
.transition-core {
  width: min(420px, 70vw);
  text-align: center;
  transform: translateY(14px);
  transition: transform 500ms var(--ease-out);
}
.transition.active .transition-core { transform: translateY(0); }
.t-title {
  font-family: var(--font-display);
  font-weight: 800; font-size: 17px; letter-spacing: 0.42em;
  color: var(--ink);
}
.t-bar {
  margin: 18px auto 12px;
  height: 3px; width: 100%;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.t-bar span {
  display: block; height: 100%; width: 8%;
  background: linear-gradient(90deg, var(--trans, var(--jf)), #fff);
  border-radius: 99px;
  transition: width 2200ms var(--ease-out);
}
.transition.active .t-bar span { width: 82%; }
.t-sub { font-size: 11px; letter-spacing: 0.24em; color: var(--ink-faint); text-transform: uppercase; }

/* ------------------------------- responsive ------------------------------ */

@media (max-width: 980px) {
  body { overflow: auto; }
  .doors { grid-template-columns: 1fr; width: min(560px, 100%); }
  .door { height: 340px; animation: none; opacity: 1; }
  .hero-title { margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .ht-line, .hero-tag, .keystone, .door { opacity: 1 !important; transform: none !important; }
}
