/* Resenha 2.6 · temas.
   Seis temas (app/themes.js). Resenha e Vidro mudam material e cor sobre a mesma tela (salas · call · chat);
   Sintonia, Apê, Caderno e Mergulho redesenham a sala inteira (app/skins/). O movimento é um só (motion.js). */

/* ---------- Variáveis comuns ---------- */
/* --hl: destaque · --speak: quem fala · --soft: hover · --disp: fonte dos títulos */
html[data-tk] { --hl: var(--accent); --speak: var(--green); --soft: color-mix(in srgb, var(--text) 5%, transparent); --disp: Figtree, sans-serif; }
html[data-tk="vidro"] { --hl: #ff8a3d; }

/* Movimento: um padrão só para todos os temas (motion.js: --ease-out e --dur-*). Os temas mudam material e arranjo, não o tempo. */

/* ================= Peças comuns (todos os temas) ================= */
html.glass {
  /* Interruptor "gota": a bolinha estica enquanto corre (uma ponta sai antes da outra) e acende na cor do tema */
  & label.check input[type="checkbox"], & .sw-drop { -webkit-appearance: none; appearance: none; position: relative; flex: none; width: 40px !important; height: 24px !important; min-height: 24px; max-height: 24px; align-self: center; margin: 0; padding: 0; border-radius: 999px; cursor: pointer;
    background: color-mix(in srgb, var(--text) 9%, transparent); box-shadow: inset 0 0 0 1px var(--g-edge, var(--line)); transition: background .3s; }
  & label.check input[type="checkbox"]::before { content: ''; position: absolute; top: 4px; left: 4px; right: 20px; height: 16px; border-radius: 999px; box-shadow: inset 0 0 0 2px var(--muted);
    transition: left .2s var(--ease-out) .04s, right .2s var(--ease-out), background .2s, box-shadow .2s; }
  & label.check input[type="checkbox"]:checked { background: color-mix(in srgb, var(--hl) 16%, transparent); }
  & label.check input[type="checkbox"]:checked::before { left: 20px; right: 4px; background: var(--hl); box-shadow: 0 0 10px color-mix(in srgb, var(--hl) 45%, transparent);
    transition: left .2s var(--ease-out), right .2s var(--ease-out) .04s, background .2s, box-shadow .2s; }
  & label.check input[type="checkbox"]:disabled { opacity: .45; cursor: default; }
  & label.check input[type="checkbox"]:focus-visible { outline: 2px solid color-mix(in srgb, var(--hl) 60%, transparent) !important; outline-offset: 2px; }

  /* Abas: só texto e um traço fino que desliza (motion.js) — sem caixas em volta */
  & .tabs, & #chat .right-nav { background: transparent !important; box-shadow: none !important; }
  & .m-slider-tabs, & #chat .right-nav .m-slider-tabs { border-radius: 2px !important; background: var(--hl) !important; box-shadow: none !important; }
  & .tabs .tab, & #chat .right-nav button:not(.right-close) { background: transparent !important; box-shadow: none !important; color: var(--muted) !important; font-weight: 600; transition: color .2s; }
  & .tabs .tab:hover, & #chat .right-nav button:not(.right-close):hover { color: var(--text) !important; }
  & .tabs .tab.active, & #chat .right-nav button[aria-pressed="true"] { color: var(--text-hi) !important; }
  & #chat .right-nav { border-bottom: 1px solid var(--g-edge, var(--line)) !important; border-radius: 0 !important; }

  /* Campos de texto: sem brilho neon; ao focar, o fundo clareia e surge um traço fino embaixo */
  & :is(input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]), textarea, select):focus,
  & :is(input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]), textarea, select):focus-visible {
    outline: none !important; box-shadow: inset 0 -1.5px 0 var(--hl) !important; background-color: color-mix(in srgb, var(--text) 8%, transparent) !important; transition: box-shadow .25s, background-color .25s; }
  & #composer #input:focus, & #composer #input:focus-visible { box-shadow: none !important; background-color: transparent !important; }
}


/* ================= RESENHA: sóbrio e denso; a cor 10 só no que pede ação ================= */
html[data-tk="resenha"] {
  & .btn.primary { background: var(--accent) !important; color: var(--on-accent) !important; border-color: transparent !important; box-shadow: none !important; }
  & .btn.primary:hover { background: var(--blurple-h) !important; }
  & #composer .send-btn { background: var(--accent) !important; color: var(--on-accent) !important; box-shadow: none !important; }
  & #chat .msg.mine .text { background: var(--accent-soft) !important; color: var(--text-hi) !important; box-shadow: none !important; }
  & #chat .msg.mine .text a { color: var(--link) !important; }
  & :is(.dd-item, .ctx-item):hover { background: var(--hover) !important; }
  & #call #call-controls .cc-btn.on::after { background: var(--accent) !important; }
  & #update-bar .up-progress i, & .up-progress i { background: var(--accent); }
  & ::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
  & ::-webkit-scrollbar-thumb { background: var(--scroll) !important; border-radius: 99px; }
  & #main, & #home { background: var(--bg-main) !important; }
  & #main #chat { background: var(--bg-side) !important; }
}

/* Sem movimento quando o sistema ou o Resenha pedem menos animação */
@media (prefers-reduced-motion: reduce) { :is(#main, #home)::before, #main::after, #call::before, #call .tile::before, #call #call-controls::after, #call .tile { animation: none !important; } }
html.reduce-motion :is(#main, #home)::before, html.reduce-motion #main::after, html.reduce-motion #call::before, html.reduce-motion #call .tile::before, html.reduce-motion #call #call-controls::after, html.reduce-motion #call .tile { animation: none !important; }


/* Os controles da call ancoram as próprias camadas (vidro do Líquido, feixe do Neon) */
html.glass #call #call-controls { position: relative; }

/* Em jogo, não deixe nem animações finitas esperando no primeiro quadro. */
html.game-mode *, html.game-mode *::before, html.game-mode *::after { animation: none !important; transition: none !important; }

/* Janela escondida (html.bg-paused): fundos, brilhos e feixes param no lugar e voltam iguais ao reabrir */
html.bg-paused :is(#main, #home)::before, html.bg-paused :is(#main, #call)::after, html.bg-paused #call::before, html.bg-paused #call .tile, html.bg-paused #call .tile::before, html.bg-paused #call #call-controls::after,
html.bg-paused :is(#sidebar .channel.active > svg, .m-slider-tabs, label.check input),
html.bg-paused :is(label.check input[type="checkbox"]:checked)::after, html.bg-paused label.check input[type="checkbox"]:checked::before { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) { #call .tile.speaking::before { animation: none !important; } }


@property --ai-a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes ai-spin { to { --ai-a: 360deg; } }
@keyframes ai-halo { 0% { opacity: 0; transform: scale(1); } 18% { opacity: .55; } 100% { opacity: 0; transform: scale(var(--s, 1.05)); } }
/* 2.2: halo ao passar o mouse (no Holofoil, nos botões da call).
   Cada tema usa a própria cor de destaque; o Holofoil usa o anel holográfico (--ai-ring). */
.ai-halo { position: fixed; z-index: 9000; pointer-events: none; padding: 1.5px; box-sizing: border-box;
  background: var(--ai-ring, conic-gradient(from var(--ai-a), var(--hl, #fff), color-mix(in srgb, var(--hl, #fff) 35%, #fff) 30%, var(--hl, #fff) 55%, color-mix(in srgb, var(--hl, #fff) 55%, transparent) 80%, var(--hl, #fff)));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: ai-halo .95s var(--ease-out) forwards, ai-spin 2.4s linear; }


/* ===== LÍQUIDO 2.6 · vidro claro sobre o "fundo vivo" (referência: visionOS — HIG Materials, Ornaments e Windows) =====
   Vidro escuro separa seções (painéis); vidro claro marca o que é interativo ou selecionado (nunca claro sobre claro).
   Atrás de tudo: grafite com luz de cima e, por cima dele, a luz que vem da call (app/ambient.js). Sem blur ao vivo nos painéis. */
html[data-tk="vidro"] {
  --lg-panel: rgba(60,60,64,.34); --lg-tile: rgba(128,128,128,.26); --lg-thin: rgba(255,255,255,.16); --lg-thin-h: rgba(255,255,255,.24);
  --lg-sel: rgba(255,255,255,.24); --lg-top: rgba(255,255,255,.22); --lg-edge: rgba(255,255,255,.07);
  & #main { isolation: isolate; background: radial-gradient(120% 90% at 50% -20%, #54545b 0%, #2a2a2f 45%, #141416 100%) !important; }
  & #main::before, & #main::after { background: none !important; animation: none !important; }
  & #ambient { display: block; }
  /* janelas: vidro escuro translúcido, filete de luz no topo e sombra que mostra a distância */
  & #main #sidebar, & #main #chat { background: var(--lg-panel) !important; -webkit-backdrop-filter: none; backdrop-filter: none; border: 0 !important; border-radius: 28px !important;
    box-shadow: inset 0 1px 0 var(--lg-top), inset 0 0 0 1px var(--lg-edge), 0 24px 60px rgba(0,0,0,.35) !important; }
  & #call .tile:not(.is-screen) { background: var(--lg-tile) !important; -webkit-backdrop-filter: none; backdrop-filter: none; border: 0 !important; border-radius: 24px !important;
    box-shadow: inset 0 1px 0 var(--lg-top), inset 0 0 0 1px var(--lg-edge), 0 18px 44px rgba(0,0,0,.30) !important; }
  & #call .tile.is-screen { border-radius: 24px !important; box-shadow: 0 18px 44px rgba(0,0,0,.35) !important; }
  & #call .tile:not(.is-screen, .is-voice) { --speaking-ring: inset 0 0 0 2px rgba(255,255,255,.9); }
  & #call .tile .tile-body .avatar { border-radius: 50% !important; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
  & #call .tile .label { background: var(--lg-thin) !important; -webkit-backdrop-filter: none; backdrop-filter: none; border-radius: 999px !important; padding: 4px 12px !important; font-weight: 600; color: #fff !important; }
  /* texto em três níveis, como a vibração do visionOS (principal, secundário, inativo) */
  & #main { --text: #fff; --text-hi: #fff; --muted: rgba(255,255,255,.62); --muted2: rgba(255,255,255,.42); }
  & #sidebar .nsb-sec { color: rgba(255,255,255,.42) !important; }
  /* vidro claro só no que é interativo ou selecionado */
  & #sidebar .channel:hover { background: var(--lg-thin) !important; }
  & #sidebar .channel.active, & #sidebar .channel.voice.connected { background: var(--lg-sel) !important; color: #fff !important; box-shadow: none !important; }
  & #sidebar .channel.active *, & #sidebar .channel.voice.connected * { color: #fff !important; }
  & #chat .msg .text, & #chat .msg.mine .text, & #composer .composer-row {
    background: var(--lg-thin) !important; box-shadow: none !important; border: 0 !important; color: #fff !important; }
  & #composer #input::placeholder { color: rgba(255,255,255,.62); }
  /* ação principal em branco, como os botões de destaque do visionOS */
  & #composer .send-btn { background: rgba(255,255,255,.92) !important; color: #111 !important; box-shadow: none !important; }
  & #call #call-title { font-size: 22px; letter-spacing: -.02em; }
  /* barra da call como ornamento: cápsula de vidro com botões redondos sem borda; o único blur ao vivo fica aqui (e some na live, glass.css) */
  & #call #call-controls { background: var(--lg-tile) !important; -webkit-backdrop-filter: blur(24px) saturate(140%); backdrop-filter: blur(24px) saturate(140%); border: 0 !important; border-radius: 999px !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.24), inset 0 0 0 1px var(--lg-edge), 0 18px 44px rgba(0,0,0,.35) !important; padding: 8px !important; gap: 6px !important; }
  & #call #call-controls .cc-sep { display: none !important; }
  & #call #call-controls .cc-btn:not(#cc-leave) { width: 48px !important; min-width: 48px !important; height: 48px !important; padding: 0 !important; border-radius: 50% !important; background: transparent !important; color: #fff !important; }
  & #call #call-controls .cc-btn:hover { background: var(--lg-thin-h) !important; }
  & #call #call-controls #cc-leave { background: #b92f28; color: #fff; border-radius: 24px; }
  & #call #call-controls #cc-leave:hover { background: #a92923; }
  & #call #call-controls #cc-leave svg { color: #fff !important; }
}
/* fundo vivo: canvas de 16x9 ampliado (o próprio aumento já suaviza; sem blur ao vivo) */
#ambient { display: none; position: absolute; inset: -4%; width: 108%; height: 108%; z-index: -1; pointer-events: none;
  opacity: 0; filter: saturate(1.3) brightness(.62); transition: opacity 1.2s var(--ease-out); }
#ambient.lit { opacity: 1; }
html.reduce-motion #ambient { transition: none; }
