/* ==========================================================================
   TV — Design system "Liquid Glass"
   Tokens, reset, tipografia, material de vidro e componentes básicos.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Tipografia */
  --font: -apple-system, "SF Pro Display", "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-hero: clamp(2.6rem, 5.2vw, 4.6rem);
  --fs-xl: clamp(1.9rem, 3.4vw, 2.8rem);
  --fs-lg: clamp(1.35rem, 2.1vw, 1.75rem);
  --fs-md: 1.0625rem;
  --fs-sm: 0.9375rem;
  --fs-xs: 0.8125rem;

  /* Cores (texto sempre com contraste >= 4.5:1 sobre o vidro escurecido) */
  --bg: #000;
  --bg-elev: #141418;
  --bg-elev-2: #1d1d23;
  --text: #f5f5f7;
  --text-2: rgba(235, 235, 245, 0.72);
  --text-3: rgba(235, 235, 245, 0.56);
  --accent: #4da3ff;
  --accent-2: #7cc0ff;
  --danger: #ff5a5f;
  --warning: #ffcc4d;
  --success: #3ddc84;
  --focus: #7cc0ff;

  /* Vidro */
  --glass-bg: rgba(255, 255, 255, 0.10);
  --glass-bg-hover: rgba(255, 255, 255, 0.14);
  --glass-tint: rgba(18, 18, 24, 0.38);         /* escurece o fundo sob texto */
  --glass-tint-thick: rgba(16, 16, 22, 0.62);
  --glass-blur: 28px;
  --glass-blur-thick: 40px;
  --glass-sat: 180%;
  --glass-edge-top: rgba(255, 255, 255, 0.55);
  --glass-edge-mid: rgba(255, 255, 255, 0.08);
  --glass-edge-bottom: rgba(255, 255, 255, 0.20);
  --glass-shadow: 0 10px 40px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.25);
  --glass-inset: inset 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 -1px 0 rgba(255, 255, 255, 0.06),
                 inset 0 0 24px rgba(255, 255, 255, 0.04);

  /* Raios concêntricos: raio interno = externo - padding */
  --r-xl: 32px;
  --r-lg: 24px;
  --r-md: 16px;
  --r-sm: 12px;
  --r-pill: 999px;

  /* Espaços */
  --gutter: clamp(16px, 3.6vw, 50px);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 72px;

  /* Movimento (springs) */
  --ease-spring: cubic-bezier(0.2, 0.9, 0.25, 1.12);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-1: 160ms;
  --dur-2: 280ms;
  --dur-3: 480ms;

  --nav-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    /* spring real (amortecida) quando o navegador suporta linear() */
    --ease-spring: linear(0, 0.006, 0.025 2.8%, 0.101 6.1%, 0.539 18.9%, 0.721 25.3%, 0.849 31.5%,
      0.937 38.1%, 0.968 41.8%, 0.991 45.7%, 1.006 50.1%, 1.015 55%, 1.017 63.9%, 1.001 85.9%, 1);
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 8px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 1000; padding: 10px 16px; border-radius: var(--r-pill);
  background: var(--text); color: #000; font-weight: 600; transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* ---------- Tipografia ---------- */
.t-hero { font-size: var(--fs-hero); font-weight: 800; letter-spacing: -0.03em; line-height: 1.02; }
.t-xl { font-size: var(--fs-xl); font-weight: 750; letter-spacing: -0.025em; line-height: 1.08; }
.t-lg { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.015em; line-height: 1.15; }
.t-sm { font-size: var(--fs-sm); }
.t-xs { font-size: var(--fs-xs); }
.t-2 { color: var(--text-2); }
.t-3 { color: var(--text-3); }
.t-caps { text-transform: uppercase; letter-spacing: 0.04em; font-size: var(--fs-xs); font-weight: 600; }
.t-strong { font-weight: 600; }
.clamp-2, .clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }
.shadow-text { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55), 0 0 18px rgba(0, 0, 0, 0.35); }

/* ==========================================================================
   Material Liquid Glass
   ========================================================================== */
.glass {
  --r: var(--r-lg);
  --mx: 50%;
  --my: 0%;
  position: relative;
  isolation: isolate;
  border-radius: var(--r);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.02) 55%, rgba(255, 255, 255, 0.05)),
    var(--glass-tint);
  background-color: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  box-shadow: var(--glass-inset), var(--glass-shadow);
}
/* Borda de 1px com gradiente de luz (reflexo especular no topo) */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, var(--glass-edge-top), var(--glass-edge-mid) 38%, var(--glass-edge-mid) 62%, var(--glass-edge-bottom));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}
/* Brilho que acompanha o ponteiro/toque (variáveis --mx/--my atualizadas via JS) */
.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  background: radial-gradient(120px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.20), rgba(255, 255, 255, 0.05) 45%, transparent 70%);
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease-out);
  pointer-events: none;
  mix-blend-mode: plus-lighter;
}
.glass.is-lit::after { opacity: 1; }
.glass > * { position: relative; z-index: 2; }

.glass--thick {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.01) 50%, rgba(255, 255, 255, 0.03)),
    var(--glass-tint-thick);
  -webkit-backdrop-filter: blur(var(--glass-blur-thick)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur-thick)) saturate(var(--glass-sat));
}
.glass--clear { background-color: rgba(255, 255, 255, 0.06); background-image: none; }
.glass--flat { box-shadow: var(--glass-inset); }

/* Refração/lente: só onde backdrop-filter aceita url() (Chromium). Classe aplicada via JS após detecção. */
.has-refraction .glass--lens {
  -webkit-backdrop-filter: url(#lg-refract) blur(6px) saturate(var(--glass-sat));
  backdrop-filter: url(#lg-refract) blur(6px) saturate(var(--glass-sat));
}

/* Acessibilidade: menos transparência = vidro quase opaco */
@media (prefers-reduced-transparency: reduce) {
  .glass, .glass--thick, .glass--clear {
    background: rgba(34, 34, 40, 0.97) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  .glass::after { display: none; }
}
html.reduce-transparency .glass,
html.reduce-transparency .glass--thick {
  background: rgba(34, 34, 40, 0.97) !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

@media (prefers-contrast: more) {
  :root { --text-2: rgba(245, 245, 250, 0.9); --text-3: rgba(245, 245, 250, 0.75); --glass-tint: rgba(10, 10, 14, 0.7); }
}

/* ==========================================================================
   Botões
   ========================================================================== */
.btn {
  --r: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 26px;
  border-radius: var(--r);
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  transition: transform var(--dur-2) var(--ease-spring), background-color var(--dur-1) ease, opacity var(--dur-1) ease;
}
.btn:active { transform: scale(0.96); }
.btn[disabled], .btn[aria-busy="true"] { opacity: 0.55; pointer-events: none; }
.btn svg { width: 20px; height: 20px; flex: none; }

.btn--primary { background: #f5f5f7; color: #000; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3); }
.btn--primary:hover { background: #fff; }
.btn--glass { color: var(--text); }
.btn--glass:hover { background-color: var(--glass-bg-hover); }
.btn--danger { background: rgba(255, 90, 95, 0.16); color: #ff8a8e; }
.btn--danger:hover { background: rgba(255, 90, 95, 0.26); }
.btn--small { min-height: 36px; padding: 0 16px; font-size: var(--fs-sm); }
.btn--block { width: 100%; }
.btn--link { min-height: auto; padding: 0; color: var(--accent-2); font-weight: 500; }
.btn--link:hover { text-decoration: underline; }

.icon-btn {
  --r: var(--r-pill);
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex: none;
  transition: transform var(--dur-2) var(--ease-spring), background-color var(--dur-1) ease;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn--sm { width: 36px; height: 36px; }
.icon-btn--sm svg { width: 18px; height: 18px; }
.icon-btn.is-on { background: rgba(255, 255, 255, 0.92); color: #000; }

/* ==========================================================================
   Chips, badges e classificação indicativa (ClassInd)
   ========================================================================== */
.chip {
  --r: var(--r-pill);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 14px;
  border-radius: var(--r);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
}
.chip--tag { min-height: 30px; padding: 0 12px; font-weight: 600; font-size: var(--fs-sm); }
button.chip { transition: background-color var(--dur-1), transform var(--dur-2) var(--ease-spring); }
button.chip:active { transform: scale(0.95); }
.chip[aria-pressed="true"], .chip.is-active { background: rgba(255, 255, 255, 0.92); color: #000; }

.meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--text-2); font-size: var(--fs-md); }
.meta-line > .dot::before { content: "·"; margin: 0 -4px; }

/* Ícones da classificação indicativa brasileira (cores oficiais do ClassInd) */
.classind {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 22px;
  padding: 0 4px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.85);
  flex: none;
}
.classind--L { background: #0c9a48; }
.classind--10 { background: #0a8fd0; }
.classind--12 { background: #f7c600; color: #1a1a1a; box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.35); }
.classind--14 { background: #f2771d; }
.classind--16 { background: #e3101b; }
.classind--18 { background: #000; box-shadow: inset 0 0 0 1.5px #fff; }
.classind--lg { min-width: 40px; height: 34px; font-size: 18px; border-radius: 8px; }

.score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: var(--fs-sm);
}
.score img, .score svg { width: 22px; height: 22px; }

/* ==========================================================================
   Formulários
   ========================================================================== */
.field { display: grid; gap: 8px; }
.field > label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.input {
  --r: var(--r-sm);
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border-radius: var(--r);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
  font-size: 17px; /* >= 16px evita zoom automático no Safari iOS */
  transition: border-color var(--dur-1), background-color var(--dur-1);
}
.input::placeholder { color: var(--text-3); }
.input:focus { border-color: var(--accent); background: rgba(255, 255, 255, 0.1); outline: none; box-shadow: 0 0 0 4px rgba(77, 163, 255, 0.25); }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { min-height: 110px; resize: vertical; line-height: 1.5; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23ebebf5' stroke-width='2'%3E%3Cpath d='M3 5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; }
.field-error { color: #ff8a8e; font-size: var(--fs-sm); }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: var(--fs-sm); color: var(--text-2); }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 0; }

.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { appearance: none; -webkit-appearance: none; margin: 0; width: 100%; height: 100%; border-radius: 999px; background: rgba(255, 255, 255, 0.18); transition: background var(--dur-2); }
.switch input:checked { background: var(--success); }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); transition: transform var(--dur-2) var(--ease-spring); }
.switch input:checked::after { transform: translateX(20px); }

/* Segmented control em vidro */
.segmented {
  --r: var(--r-pill);
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: var(--r);
}
.segmented button {
  --r: calc(var(--r-pill));
  min-height: 36px;
  padding: 0 16px;
  border-radius: var(--r);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-1);
}
.segmented button[aria-selected="true"] { background: rgba(255, 255, 255, 0.9); color: #000; }

/* Estrelas / nota */
.stars { display: inline-flex; gap: 4px; }
.stars button { width: 36px; height: 36px; display: grid; place-items: center; color: rgba(255, 255, 255, 0.3); transition: transform var(--dur-2) var(--ease-spring), color var(--dur-1); }
.stars button svg { width: 28px; height: 28px; }
.stars button.is-on { color: #ffd60a; }
.stars button.is-half { color: #ffd60a; }
.stars button:active { transform: scale(0.85); }

/* ==========================================================================
   Toast, sheet, diálogo
   ========================================================================== */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 900;
  display: grid;
  gap: 8px;
  width: min(92vw, 440px);
  pointer-events: none;
}
.toast {
  --r: var(--r-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  font-size: var(--fs-sm);
  font-weight: 500;
  pointer-events: auto;
  animation: toast-in var(--dur-3) var(--ease-spring) both;
}
.toast.is-leaving { animation: toast-out var(--dur-2) var(--ease-out) both; }
.toast button { margin-left: auto; font-weight: 600; color: var(--accent-2); }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.98); } }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(0, 0, 0, 0.45);
  animation: fade-in var(--dur-2) ease both;
}
.scrim.is-leaving { animation: fade-out var(--dur-2) ease both; }
.sheet {
  --r: var(--r-xl);
  position: fixed;
  z-index: 810;
  left: 50%;
  bottom: calc(16px + var(--safe-bottom));
  width: min(640px, calc(100vw - 24px));
  max-height: min(86vh, 900px);
  max-height: min(86dvh, 900px);
  display: flex;
  flex-direction: column;
  transform: translateX(-50%);
  animation: sheet-in var(--dur-3) var(--ease-spring) both;
  overflow: hidden;
}
.sheet.is-leaving { animation: sheet-out var(--dur-2) var(--ease-out) both; }
.sheet__head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 8px 24px; }
.sheet__head h2 { flex: 1; font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.01em; }
.sheet__body { padding: 8px 24px 24px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet__grabber { width: 40px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.35); margin: 8px auto 0; }
@media (min-width: 900px) {
  .sheet { top: 50%; bottom: auto; transform: translate(-50%, -50%); animation-name: dialog-in; }
  .sheet.is-leaving { animation-name: dialog-out; }
  .sheet__grabber { display: none; }
}
.sheet--wide { width: min(980px, calc(100vw - 24px)); }
@keyframes sheet-in { from { opacity: 0; transform: translate(-50%, 40px) scale(0.98); } }
@keyframes sheet-out { to { opacity: 0; transform: translate(-50%, 30px) scale(0.98); } }
@keyframes dialog-in { from { opacity: 0; transform: translate(-50%, -46%) scale(0.94); } }
@keyframes dialog-out { to { opacity: 0; transform: translate(-50%, -48%) scale(0.97); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* Menus (popover) */
.menu {
  --r: var(--r-lg);
  position: absolute;
  z-index: 700;
  min-width: 240px;
  padding: 6px;
  animation: menu-in var(--dur-2) var(--ease-spring) both;
  transform-origin: top right;
}
.menu button, .menu a {
  --r: calc(var(--r-lg) - 6px);
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--r);
  font-size: var(--fs-md);
  text-align: left;
}
.menu button:hover, .menu a:hover, .menu button:focus-visible { background: rgba(255, 255, 255, 0.12); outline: none; }
.menu svg { width: 20px; height: 20px; flex: none; }
.menu hr { border: 0; height: 1px; background: rgba(255, 255, 255, 0.12); margin: 6px 8px; }
@keyframes menu-in { from { opacity: 0; transform: scale(0.92); } }

/* Skeleton / loading */
.skeleton {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.12) 40%, rgba(255, 255, 255, 0.06) 80%);
  background-size: 300% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.2); border-top-color: #fff; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Avatar */
.avatar { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; flex: none; display: grid; place-items: center; background: #222; }
.avatar img, .avatar svg { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 96px; height: 96px; }
.avatar--xl { width: 128px; height: 128px; }

/* Progresso (orçamento IA, episódios) */
.progress { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--text); transition: width var(--dur-3) var(--ease-out); }
.progress.is-warn > span { background: var(--warning); }
.progress.is-full > span { background: var(--danger); }

/* ==========================================================================
   Movimento reduzido
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
