/* Polyvox — shared design system
 * Glass-morphism shell tokens + primitives used by admin, broadcaster, mobile viewer.
 * Single source of truth for colors, radii, motion, type, and component shapes. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: local("Inter"), url("https://rsms.me/inter/font-files/Inter-roman.var.woff2?v=4.1") format("woff2");
}

:root {
  /* Surface palette */
  --bg: #08080c;
  --bg-1: #0c0c12;
  --bg-2: #14141c;

  /* Glass surfaces — paired with backdrop-filter at use site */
  --glass-1-bg: rgba(255, 255, 255, 0.05);
  --glass-1-border: rgba(255, 255, 255, 0.06);
  --glass-1-highlight: rgba(255, 255, 255, 0.08);
  --glass-2-bg: rgba(255, 255, 255, 0.07);
  --glass-2-border: rgba(255, 255, 255, 0.10);
  --glass-2-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.65), 0 1px 0 rgba(255, 255, 255, 0.06) inset;

  /* Accent + semantic */
  --amber: #f5b342;
  --amber-deep: #c98a1f;
  --amber-soft: rgba(245, 179, 66, 0.16);
  --teal: #5ac8c0;
  --teal-soft: rgba(90, 200, 192, 0.16);
  --green: #3ecf8e;
  --green-soft: rgba(62, 207, 142, 0.18);
  --red: #ef5764;
  --red-soft: rgba(239, 87, 100, 0.18);
  --violet: #8a7cf3;

  /* Text */
  --fg: #f0ede8;
  --fg-strong: #ffffff;
  --fg-dim: #a8a4ae;
  --fg-mute: #66626b;

  /* Radii */
  --r-1: 8px;
  --r-2: 12px;
  --r-3: 18px;
  --r-4: 24px;
  --r-pill: 999px;

  /* Motion */
  --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --t-hover: 200ms;
  --t-shift: 320ms;
  --t-modal: 240ms;

  /* Spacing */
  --gap-1: 4px;
  --gap-2: 8px;
  --gap-3: 12px;
  --gap-4: 16px;
  --gap-5: 24px;
  --gap-6: 32px;
  --gap-7: 48px;

  /* Type */
  --font-sans: "Inter", "Inter var", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* Layout */
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 64px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 400 14px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Aurora — three soft radial blobs anchored to give glass something to refract.
 * Fixed-position so they don't move during scroll, low luminance so contrast against text remains AA. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(60vw 60vw at 88% 12%, rgba(245, 179, 66, 0.10), transparent 60%),
    radial-gradient(50vw 50vw at 8% 92%, rgba(138, 124, 243, 0.10), transparent 60%),
    radial-gradient(70vw 70vw at 50% 50%, rgba(90, 200, 192, 0.06), transparent 60%);
  filter: saturate(140%);
  animation: aurora 28s var(--ease-out) infinite alternate;
}
@keyframes aurora {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-2%, 1%, 0) scale(1.04); }
}
@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}
@media (prefers-reduced-transparency: reduce) {
  body::before { display: none; }
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[disabled], button:disabled { opacity: 0.45; cursor: not-allowed; }

::selection { background: var(--amber-soft); color: var(--fg-strong); }

/* Focus ring — accessibility G2.
 * 2px ring at 3:1 against any glass surface (verified). */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: var(--r-1);
}

/* ─── Glass primitives ─────────────────────────────────────────────── */

.glass {
  /* Layered: dark base for legibility + soft white highlight on top.
   * Without the dark base, bright UI behind (amber CTAs) bleeds through blur. */
  background-color: rgba(14, 14, 22, 0.55);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%);
  border: 1px solid var(--glass-1-border);
  backdrop-filter: blur(22px) saturate(135%);
  -webkit-backdrop-filter: blur(22px) saturate(135%);
  border-radius: var(--r-3);
  box-shadow: 0 1px 0 var(--glass-1-highlight) inset, 0 12px 40px -20px rgba(0, 0, 0, 0.55);
}
.glass-raised {
  /* Higher opacity dark base — modals, drawers, popovers must be readable
   * even over bright content (amber CTAs, status pills). */
  background-color: rgba(14, 14, 22, 0.82);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.09) 0%, rgba(255, 255, 255, 0.03) 100%);
  border: 1px solid var(--glass-2-border);
  backdrop-filter: blur(40px) saturate(140%);
  -webkit-backdrop-filter: blur(40px) saturate(140%);
  border-radius: var(--r-3);
  box-shadow: var(--glass-2-shadow);
}
@supports not (backdrop-filter: blur(1px)) {
  .glass { background-color: rgba(20, 20, 28, 0.94); background-image: none; }
  .glass-raised { background-color: rgba(14, 14, 22, 0.97); background-image: none; }
}

/* ─── Buttons ──────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-2);
  padding: 0 var(--gap-4);
  height: 38px;
  min-width: 38px;
  border: 1px solid var(--glass-2-border);
  background: var(--glass-1-bg);
  color: var(--fg);
  border-radius: var(--r-2);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: background var(--t-hover) var(--ease-out), border-color var(--t-hover) var(--ease-out), transform var(--t-hover) var(--ease-out);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.18); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(180deg, #fbcb6a 0%, var(--amber) 70%, var(--amber-deep) 100%);
  border-color: rgba(0, 0, 0, 0.2);
  color: #1a1208;
  font-weight: 600;
  box-shadow: 0 8px 24px -8px rgba(245, 179, 66, 0.55), 0 1px 0 rgba(255, 255, 255, 0.4) inset;
}
.btn-primary:hover { filter: brightness(1.05); }

.btn-ghost { background: transparent; border-color: var(--glass-2-border); color: var(--fg-dim); }
.btn-ghost:hover { color: var(--fg); }

.btn-danger { background: var(--red-soft); border-color: rgba(239, 87, 100, 0.35); color: #ffd0d4; }
.btn-danger:hover { background: rgba(239, 87, 100, 0.28); }

.btn-icon {
  width: 38px; height: 38px;
  padding: 0;
  border-radius: var(--r-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 15px; border-radius: var(--r-3); }

/* Default icon size — applies regardless of parent class so any button or
 * non-button host gets a visible glyph. Was '.btn .ico' previously, which
 * left icons inside .btn-icon-only hosts at 0×0. */
.ico { width: 18px; height: 18px; flex-shrink: 0; }
.btn-sm .ico { width: 14px; height: 14px; }
.btn-lg .ico { width: 20px; height: 20px; }

/* ─── Chips / Badges ───────────────────────────────────────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--fg-dim);
}
.chip-live {
  background: var(--green-soft);
  border-color: rgba(62, 207, 142, 0.3);
  color: #b6f0d3;
}
.chip-live::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.chip-amber { background: var(--amber-soft); border-color: rgba(245, 179, 66, 0.3); color: #f8d289; }
.chip-warn { background: var(--amber-soft); border-color: rgba(245, 179, 66, 0.3); color: #f8d289; }
.chip-err { background: var(--red-soft); border-color: rgba(239, 87, 100, 0.3); color: #ffb4ba; }
.chip-teal { background: var(--teal-soft); border-color: rgba(90, 200, 192, 0.3); color: #b0e8e3; }

/* ─── Form fields ──────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-dim);
  letter-spacing: 0.01em;
}
.field-help {
  font-size: 12px;
  color: var(--fg-mute);
  line-height: 1.5;
}

.input, .select, .textarea {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-2-border);
  border-radius: var(--r-2);
  color: var(--fg);
  font: inherit;
  transition: border-color var(--t-hover) var(--ease-out), background var(--t-hover) var(--ease-out);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: rgba(245, 179, 66, 0.5);
  background: rgba(0, 0, 0, 0.45);
}
.input::placeholder, .textarea::placeholder { color: var(--fg-mute); }
.textarea { resize: vertical; min-height: 80px; }
.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23a8a4ae' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-inline-end: 36px;
}
[dir="rtl"] .select {
  background-position: left 14px center;
}

.input-mono { font-family: var(--font-mono); font-size: 12px; }

/* Lang chip multi-select for target_langs */
.lang-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.lang-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-1-border);
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-dim);
  cursor: pointer;
  transition: all var(--t-hover) var(--ease-out);
  user-select: none;
}
.lang-chip:hover { background: rgba(255, 255, 255, 0.08); }
.lang-chip[aria-pressed="true"] {
  background: var(--amber-soft);
  border-color: rgba(245, 179, 66, 0.5);
  color: #f8d289;
}

/* ─── Toast ────────────────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  inset-inline-end: var(--gap-5);
  bottom: var(--gap-5);
  display: flex; flex-direction: column;
  gap: var(--gap-2);
  z-index: 200;
  pointer-events: none;
}
.toast {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-2);
  padding: 12px 18px;
  background: var(--glass-2-bg);
  backdrop-filter: blur(40px) saturate(140%);
  -webkit-backdrop-filter: blur(40px) saturate(140%);
  border: 1px solid var(--glass-2-border);
  border-radius: var(--r-2);
  box-shadow: var(--glass-2-shadow);
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  pointer-events: auto;
  animation: toast-in var(--t-modal) var(--ease-spring);
}
.toast.toast-err { border-color: rgba(239, 87, 100, 0.4); color: #ffd0d4; }
.toast.toast-ok { border-color: rgba(62, 207, 142, 0.4); }
@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ─── Dialogs (modal + drawer) ─────────────────────────────────────── */
dialog.dlg, dialog.drawer {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--fg);
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
}
dialog.dlg::backdrop, dialog.drawer::backdrop {
  background: rgba(4, 4, 8, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

dialog.dlg {
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--gap-5);
}
dialog.dlg[open] { display: flex; }
.dlg-card {
  width: min(540px, 100%);
  max-height: calc(100vh - 60px);
  overflow: auto;
  padding: var(--gap-6);
  animation: dlg-in var(--t-modal) var(--ease-spring);
}
@keyframes dlg-in {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

dialog.drawer {
  display: none;
}
dialog.drawer[open] { display: block; }
.drawer-panel {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  width: min(560px, 100vw);
  height: 100vh;
  overflow-y: auto;
  padding: var(--gap-6);
  border-radius: 0;
  border-inline-start: 1px solid var(--glass-2-border);
  animation: drawer-in var(--t-modal) var(--ease-spring);
}
[dir="rtl"] .drawer-panel { animation-name: drawer-in-rtl; }
@keyframes drawer-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes drawer-in-rtl {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .dlg-card, .drawer-panel { animation: none; }
}

.dlg-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--gap-4);
  margin-bottom: var(--gap-4);
}
.dlg-head h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.dlg-head .sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--fg-dim);
  line-height: 1.5;
}
.dlg-foot {
  display: flex;
  gap: var(--gap-2);
  justify-content: flex-end;
  margin-top: var(--gap-5);
}

/* ─── Skeletons ────────────────────────────────────────────────────── */
.skel {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.10) 50%, rgba(255, 255, 255, 0.04) 100%);
  background-size: 200% 100%;
  border-radius: var(--r-2);
  animation: skel 1.4s linear infinite;
}
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* ─── Utility ──────────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: var(--gap-3); flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: var(--gap-3); }
.spacer { flex: 1; min-width: 0; }
.muted { color: var(--fg-dim); }
.faint { color: var(--fg-mute); }
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Container for the icon-button hot zone — keeps min-tap target 44px on mobile */
@media (pointer: coarse) {
  .btn-icon { min-width: 44px; min-height: 44px; }
}

/* ─── Language switcher ─────────────────────────────────────────────
 * Reusable globe-icon button + dropdown. Sits in topbars across admin,
 * broadcaster, and (optionally) viewer surfaces. Shows current UI lang
 * code uppercase next to the globe; click → list of supported locales. */
.lang-switch { position: relative; }
.lang-switch-btn {
  display: inline-flex; align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 38px;
  width: auto;
  background: var(--glass-1-bg);
  border: 1px solid var(--glass-1-border);
  color: var(--fg-dim);
  border-radius: var(--r-2);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-hover) var(--ease-out), color var(--t-hover) var(--ease-out), border-color var(--t-hover) var(--ease-out);
}
.lang-switch-btn:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}
.lang-switch-btn .ico { width: 16px; height: 16px; }
.lang-switch-pop {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 200px;
  padding: 6px;
  z-index: 50;
  /* Stack children vertically. Using flex-column instead of plain block
   * so an item with default inline-block <button> behaviour can never
   * accidentally lay out side by side. */
  display: none;
  flex-direction: column;
}
.lang-switch-pop.open {
  display: flex;
  animation: dlg-in var(--t-modal) var(--ease-spring);
}
.lang-switch-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  border-radius: var(--r-1);
  cursor: pointer;
  text-align: start;
  transition: background var(--t-hover) var(--ease-out);
}
.lang-switch-item:hover { background: rgba(255, 255, 255, 0.06); }
.lang-switch-item[aria-current="true"] {
  background: var(--amber-soft);
  color: var(--amber);
}
.lang-switch-item .lang-code-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-mute);
  letter-spacing: 0.1em;
  margin-inline-start: auto;
}
.lang-switch-item[aria-current="true"] .lang-code-tag { color: var(--amber); }

/* ─────────────────────────────────────────────────────────────────
 * Landing + login screen — shared between index.html and admin.html
 * ───────────────────────────────────────────────────────────────── */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(440px, 38vw);
  gap: var(--gap-7);
  padding: var(--gap-7);
  align-items: center;
  max-width: 1320px;
  margin: 0 auto;
  position: relative; z-index: 1;
}
.landing-pitch { max-width: 680px; }
.landing-hero h2 {
  font-size: clamp(28px, 3.6vw, 42px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.08;
  margin-bottom: var(--gap-4);
}
.landing-hero h2 .accent {
  background: linear-gradient(135deg, var(--amber), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.landing-hero p {
  font-size: 16px;
  color: var(--fg-dim);
  line-height: 1.55;
  margin-bottom: var(--gap-6);
  max-width: 56ch;
}
.landing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-3);
}
.landing-card {
  padding: var(--gap-4);
  display: flex;
  flex-direction: column;
  gap: var(--gap-2);
}
.landing-card .ico-tile {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: rgba(245, 179, 66, 0.10);
  border: 1px solid rgba(245, 179, 66, 0.22);
  color: var(--amber);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.landing-card .ico-tile svg { width: 20px; height: 20px; }
.landing-card h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.landing-card p {
  font-size: 13px;
  color: var(--fg-dim);
  line-height: 1.5;
  margin: 0;
}
.landing-aside {
  display: flex;
  justify-content: center;
  align-items: center;
}
.login-card {
  width: 100%;
  max-width: 440px;
  padding: var(--gap-7);
  text-align: center;
}
.login-mark {
  width: 56px; height: 56px;
  margin: 0 auto var(--gap-4);
  border-radius: 14px;
  background: linear-gradient(135deg, var(--amber), var(--violet));
  box-shadow: 0 0 32px rgba(245, 179, 66, 0.45);
  position: relative;
}
.login-mark::after {
  content: ""; position: absolute; inset: 12px;
  border-radius: 6px; background: var(--bg);
}
.login-card h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 8px; }
.login-card > p { color: var(--fg-dim); font-size: 14px; margin-bottom: var(--gap-5); }

@media (max-width: 1024px) {
  .login {
    grid-template-columns: 1fr;
    padding: var(--gap-5);
    gap: var(--gap-5);
  }
  .landing-pitch { order: 2; max-width: 100%; }
  .landing-aside { order: 1; }
  .landing-hero h2 { font-size: clamp(24px, 7vw, 32px); }
}
@media (max-width: 560px) {
  .landing-grid { grid-template-columns: 1fr; }
}
