/* Fuera de Serie — gameshow look, no images.
 * Palette pulled from the logo (sunburst orange, navy banner, coral stroke).
 * Optimized for low bandwidth: fonts are the only network asset (~65 KB total).
 */

@import url('https://fonts.googleapis.com/css2?family=Bagel+Fat+One&family=Inter:wght@400;600;800&display=swap');

:root {
  --fds-orange: #F5A623;
  --fds-orange-deep: #D87410;
  --fds-red: #D93B2C;
  --fds-red-dark: #8E1F14;
  --fds-navy: #1A2A5E;
  --fds-navy-deep: #0E1838;
  --fds-cream: #FFF7E8;
  --fds-yellow: #FFD93D;
  --fds-pink: #FF6B9D;
  --fds-teal: #4FD1C5;
  --fds-black: #0a0a14;
  --fds-stroke: 4px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--fds-cream);
  min-height: 100vh;
  background: radial-gradient(ellipse at center,
    var(--fds-orange) 0%,
    var(--fds-orange-deep) 38%,
    var(--fds-navy) 92%);
  overflow-x: hidden;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

/* Sunburst rays — pure CSS, 0 KB asset cost */
body::before {
  content: '';
  position: fixed;
  inset: -50vmax;
  background: repeating-conic-gradient(from 0deg,
    rgba(255, 217, 61, 0.32) 0deg 6deg,
    transparent 6deg 14deg);
  animation: sunburst 80s linear infinite;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
}
@keyframes sunburst { to { transform: rotate(360deg); } }

/* Confetti — JS injects 25 spans on load */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}
.confetti span {
  position: absolute;
  top: -5vh;
  width: 10px; height: 14px;
  border-radius: 2px;
  animation: confetti-fall linear infinite;
}
@keyframes confetti-fall {
  0%   { transform: translate3d(0, -10vh, 0) rotate(0); opacity: 1; }
  100% { transform: translate3d(var(--dx, 0), 110vh, 0) rotate(720deg); opacity: 0.85; }
}
.confetti span:nth-child(5n+1) { background: var(--fds-yellow); }
.confetti span:nth-child(5n+2) { background: var(--fds-red); }
.confetti span:nth-child(5n+3) { background: var(--fds-pink); }
.confetti span:nth-child(5n+4) { background: var(--fds-teal); }
.confetti span:nth-child(5n+5) { background: var(--fds-cream); }
@media (prefers-reduced-motion: reduce) {
  .confetti, body::before { animation: none; }
}

/* Main stage (landing/waiting/call) */
main {
  position: relative;
  z-index: 2;
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 3rem);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: clamp(1rem, 3vw, 2rem);
}

/* The "FUERA DE SERIE" wordmark, pure typography */
.fds-title {
  margin: 0;
  font-family: 'Bagel Fat One', system-ui, cursive;
  color: var(--fds-cream);
  -webkit-text-stroke: var(--fds-stroke) var(--fds-red);
  text-shadow:
    0 4px 0 var(--fds-red),
    0 8px 0 var(--fds-red-dark),
    0 12px 0 var(--fds-red-dark),
    0 18px 28px rgba(0, 0, 0, 0.55);
  letter-spacing: 0.02em;
  font-weight: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.88;
  filter: drop-shadow(0 0 28px rgba(255, 217, 61, 0.45));
}
.fds-title .line {
  font-size: clamp(3rem, 13vw, 7.5rem);
  transform: rotate(-1.5deg);
}
.fds-title .line--small {
  font-size: clamp(2rem, 8vw, 4.5rem);
  margin: 0.1em 0;
  transform: rotate(2deg);
}

/* Subtitle banner ("RISAS · CONOCIMIENTOS · ALEGRÍA") */
.fds-banner {
  display: inline-block;
  background: var(--fds-navy);
  color: var(--fds-cream);
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  letter-spacing: 0.15em;
  padding: 0.75rem 1.5rem;
  transform: rotate(-1.5deg);
  box-shadow: 4px 4px 0 var(--fds-red), 8px 8px 0 var(--fds-red-dark);
  font-size: clamp(0.85rem, 2.5vw, 1.15rem);
  border: 3px solid var(--fds-cream);
  border-radius: 6px;
  text-transform: uppercase;
}

/* Card panel (forms, status messages) */
.fds-card {
  background: var(--fds-cream);
  color: var(--fds-navy);
  padding: clamp(1rem, 3vw, 2rem);
  border: 4px solid var(--fds-navy);
  border-radius: 1.25rem;
  box-shadow: 8px 8px 0 var(--fds-red);
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.fds-card p { margin: 0; font-size: 1.05rem; line-height: 1.4; }
.fds-card h2 {
  margin: 0;
  font-family: 'Bagel Fat One', cursive;
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: var(--fds-red);
  -webkit-text-stroke: 1px var(--fds-navy);
}

.fds-input {
  font-family: inherit;
  font-size: 1.05rem;
  padding: 0.85rem 1rem;
  border: 3px solid var(--fds-navy);
  border-radius: 0.75rem;
  background: #fff;
  color: var(--fds-navy);
  outline: none;
  transition: box-shadow 0.15s;
  width: 100%;
}
.fds-input:focus { box-shadow: 0 0 0 3px var(--fds-yellow); }

/* Big chunky buttons */
.fds-btn {
  font-family: 'Bagel Fat One', cursive;
  font-size: clamp(1.1rem, 2.5vw, 1.55rem);
  background: var(--fds-yellow);
  color: var(--fds-navy);
  border: 4px solid var(--fds-black);
  padding: 0.85rem 2rem;
  border-radius: 1rem;
  cursor: pointer;
  box-shadow: 6px 6px 0 var(--fds-black);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  user-select: none;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}
.fds-btn:hover:not(:disabled),
.fds-btn:focus-visible {
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0 var(--fds-black);
  outline: none;
}
.fds-btn:active:not(:disabled) {
  transform: translate(3px, 3px);
  box-shadow: 3px 3px 0 var(--fds-black);
}
.fds-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.5);
}
.fds-btn--danger { background: var(--fds-red); color: var(--fds-cream); }
.fds-btn--ghost  { background: var(--fds-cream); color: var(--fds-navy); }
.fds-btn--small  {
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  padding: 0.55rem 1.2rem;
  box-shadow: 4px 4px 0 var(--fds-black);
}
.fds-btn--small:hover:not(:disabled),
.fds-btn--small:focus-visible {
  box-shadow: 6px 6px 0 var(--fds-black);
}
.fds-btn--block { width: 100%; }

/* View switcher (landing/waiting/call). The `:not(.active) + !important`
 * keeps inactive views hidden even when they also carry `.stack` or other
 * helper classes that set `display: flex`. */
[data-view] { display: none; }
[data-view].active { display: flex; }
[data-view]:not(.active) { display: none !important; }

/* Waiting view */
.waiting-pip {
  width: clamp(160px, 30vw, 220px);
  aspect-ratio: 4 / 3;
  background: #000;
  border: 4px solid var(--fds-navy);
  border-radius: 0.75rem;
  object-fit: cover;
  display: block;
  margin: 0 auto;
  transform: scaleX(-1);
}
.waiting-info {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 1.1rem;
  color: var(--fds-navy);
}
.waiting-info strong {
  color: var(--fds-red);
  font-size: 1.6rem;
  font-family: 'Bagel Fat One', cursive;
}

/* Call layout — modeled on TortillaTV solo-mode:
 * Desktop: two cameras side-by-side at 50/50, fullscreen
 * Mobile : remote fills the viewport, local is a corner PiP
 *
 * .fds-call-stage--fullscreen → user-facing call (covers the page)
 * .fds-call-stage--contained  → admin call (sits inside .call-panel,
 *                                next to the queue on desktop) */
.fds-call-stage {
  display: flex;
  flex-direction: row;
  gap: 4px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  width: 100%;
}
.fds-call-stage--fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* Reserve room at the bottom for the controls bar so video tiles end up
   * casi-square (~0.95 aspect on a 16:10 viewport), matching how Tortilla
   * lays out its solo-mode (topbar + video-area + controls bar). */
  bottom: 96px;
  z-index: 20;
  border-radius: 0;
  padding: 0;
}
.fds-call-stage--contained {
  aspect-ratio: 16 / 9;
  border: 4px solid var(--fds-black);
  box-shadow: 8px 8px 0 var(--fds-navy-deep);
}
.fds-call-stage video {
  flex: 1 1 0;
  width: 50%;
  height: 100%;
  object-fit: cover;
  background: #111;
  display: block;
}
.fds-call-stage .video-local {
  transform: scaleX(-1);
}

/* Floating controls bar (Tortilla-style) — pinned bottom-center,
 * circular icon buttons in FDS palette */
.fds-controls-bar {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(26, 42, 94, 0.88);
  border: 3px solid var(--fds-cream);
  border-radius: 999px;
  z-index: 30;
  box-shadow: 4px 4px 0 var(--fds-red);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.fds-btn-icon {
  width: 48px; height: 48px;
  font-size: 1.35rem;
  background: var(--fds-yellow);
  color: var(--fds-navy);
  border: 3px solid var(--fds-black);
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 3px 3px 0 var(--fds-black);
  font-family: inherit;
  line-height: 1;
}
.fds-btn-icon:hover:not(:disabled),
.fds-btn-icon:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--fds-black);
  outline: none;
}
.fds-btn-icon:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--fds-black);
}
.fds-btn-icon--off,
.fds-btn-icon--danger {
  background: var(--fds-red);
  color: var(--fds-cream);
}

/* Mobile: remote fullscreen, local PiP on top, controls compact */
@media (max-width: 640px) {
  .fds-call-stage--fullscreen {
    flex-direction: column;
    gap: 0;
    /* On phones we go edge-to-edge — remote fills the whole viewport,
     * controls bar floats on top of it (Tortilla mobile pattern). */
    bottom: 0;
  }
  .fds-call-stage--fullscreen .video-remote {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }
  .fds-call-stage--fullscreen .video-local {
    position: fixed;
    bottom: 92px;
    right: 12px;
    width: 110px;
    height: 150px;
    flex: none;
    border-radius: 12px;
    border: 2px solid var(--fds-cream);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
    z-index: 25;
  }
  .fds-controls-bar { bottom: 14px; padding: 8px 10px; gap: 8px; }
  .fds-btn-icon { width: 44px; height: 44px; font-size: 1.2rem; }
}

/* Admin layout when in-call:
 * The call-stage takes over the screen (same as user-side fullscreen)
 * and the queue floats as a translucent overlay on top of the video.
 * Yannier can still see who's waiting and pick anyone without leaving
 * the call view. */
.admin-shell.in-call .admin-header { display: none; }
.admin-shell.in-call .admin-grid {
  display: block;
  gap: 0;
}
.admin-shell.in-call .call-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  background: transparent;
}
.admin-shell.in-call .call-panel > h2,
.admin-shell.in-call .call-panel > p {
  display: none;
}
.admin-shell.in-call .queue-panel {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 26;
  width: 280px;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  background: rgba(255, 247, 232, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  /* slimmer than the side panel — keeps overlay compact */
  padding: 0.65rem;
}
.admin-shell.in-call .queue-panel h2 { font-size: 1.1rem; }
.admin-shell.in-call .queue-panel .queue-item {
  padding: 0.5rem;
  font-size: 0.9rem;
}
.admin-shell.in-call .queue-panel .queue-item .pos { font-size: 1.05rem; min-width: 1.6rem; }
.admin-shell.in-call .queue-panel > p { display: none; }

@media (max-width: 640px) {
  .admin-shell.in-call .queue-panel {
    top: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 35vh;
  }
}

/* Status pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  background: var(--fds-yellow);
  color: var(--fds-navy);
  border: 2px solid var(--fds-navy);
}
.pill--ok   { background: var(--fds-teal); color: #fff; border-color: #fff; }
.pill--err  { background: var(--fds-red); color: #fff; border-color: #fff; }
.pill--idle { background: #d8d8d8; color: #333; }
.pill::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* Admin layout */
.admin-shell {
  position: relative;
  z-index: 2;
  max-width: 1300px;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.admin-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: space-between;
}
.admin-header .fds-title {
  align-items: flex-start;
  text-align: left;
  flex-direction: row;
  gap: 0.5rem;
  filter: drop-shadow(0 0 18px rgba(255, 217, 61, 0.35));
}
.admin-header .fds-title .line {
  font-size: clamp(1.6rem, 5vw, 2.8rem);
  transform: rotate(-1deg);
}
.admin-header .fds-title .line--small {
  font-size: clamp(1.1rem, 3.5vw, 1.8rem);
  margin: 0;
}

.admin-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .admin-grid { grid-template-columns: 360px 1fr; align-items: start; }
}

.queue-panel,
.call-panel,
.admin-card {
  background: var(--fds-cream);
  color: var(--fds-navy);
  padding: 1rem;
  border: 4px solid var(--fds-navy);
  border-radius: 1rem;
  box-shadow: 6px 6px 0 var(--fds-red);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.queue-panel h2,
.call-panel h2,
.admin-card h2 {
  font-family: 'Bagel Fat One', cursive;
  margin: 0;
  font-size: 1.5rem;
  color: var(--fds-red);
  -webkit-text-stroke: 1px var(--fds-navy);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 60vh;
  overflow-y: auto;
}
.queue-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 3px solid var(--fds-navy);
  border-radius: 0.75rem;
  background: #fff;
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  font-family: inherit;
  width: 100%;
  text-align: left;
}
.queue-item:hover,
.queue-item:focus-visible {
  background: var(--fds-yellow);
  transform: translateX(4px);
  outline: none;
}
.queue-item:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.queue-item .pos {
  font-family: 'Bagel Fat One', cursive;
  font-size: 1.4rem;
  color: var(--fds-red);
  min-width: 2rem;
  -webkit-text-stroke: 1px var(--fds-navy);
}
.queue-item .name { flex: 1; font-weight: 700; font-size: 1.05rem; }
.queue-item .wait { font-size: 0.85rem; color: var(--fds-red-dark); }

.queue-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--fds-navy-deep);
  opacity: 0.7;
  font-style: italic;
}


.muted { opacity: 0.7; }
.hidden { display: none !important; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.spacer { flex: 1; }

/* Generic mobile adjustments (non-call) */
@media (max-width: 600px) {
  .fds-card { box-shadow: 4px 4px 0 var(--fds-red); }
  .fds-banner { box-shadow: 3px 3px 0 var(--fds-red), 6px 6px 0 var(--fds-red-dark); }
  .admin-header .fds-title { flex-direction: column; align-items: flex-start; gap: 0.1rem; }
}

/* Small admin login card centering */
.admin-login {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
