/* ============================================================
   BASE — tokens, reset, tipografia, botões, layout e movimento
   As cores principais vêm do painel (Aparência) via applyTheme().
   ============================================================ */
:root {
  --c-primary: #003399;
  --c-secondary: #032154;
  --c-accent: #86abca;
  --c-bg: #f7f8fc;
  --c-text: #171b24;
  --c-surface: #ffffff;

  /* Derivadas — acompanham automaticamente as cores do tema */
  --c-text-soft: color-mix(in srgb, var(--c-text) 70%, var(--c-bg));
  --c-text-faint: color-mix(in srgb, var(--c-text) 50%, var(--c-bg));
  --c-line: color-mix(in srgb, var(--c-secondary) 11%, transparent);
  --c-line-strong: color-mix(in srgb, var(--c-secondary) 20%, transparent);
  --c-tint: color-mix(in srgb, var(--c-primary) 6%, var(--c-surface));
  --c-accent-ink: color-mix(in srgb, var(--c-accent) 42%, var(--c-secondary)); /* texto de destaque legível sobre fundo claro */
  --c-accent-on-dark: color-mix(in srgb, var(--c-accent) 70%, #fff); /* texto pequeno de destaque sobre o azul (contraste ≥ 4,5) */
  --c-deep: color-mix(in srgb, var(--c-secondary) 82%, #000);

  --radius: 18px;
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-lg: calc(var(--radius) + 6px);
  --font-heading: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, sans-serif;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 2px 8px -2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, 0.08), 0 12px 32px -12px rgba(16, 24, 40, 0.16);
  --shadow-lg: 0 10px 24px -8px rgba(16, 24, 40, 0.14), 0 32px 64px -24px rgba(16, 24, 40, 0.28);

  /* Curvas de movimento (ease-out forte para entradas, drawer estilo iOS) */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  --header-h: 68px;
  --gutter: 24px;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img {
  max-width: 100%;
  display: block;
}
a {
  color: inherit;
  text-decoration: none;
}
h1,
h2,
h3,
h4 {
  font-family: var(--font-heading);
  margin: 0;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
p {
  margin: 0;
  color: var(--c-text-soft);
  text-wrap: pretty;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}
button:disabled {
  cursor: not-allowed;
}
input,
textarea,
select {
  font: inherit;
}
::selection {
  background: color-mix(in srgb, var(--c-accent) 45%, transparent);
  color: var(--c-text);
}
:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 3px;
  border-radius: 4px;
}
.ic {
  flex: 0 0 auto;
  display: inline-block;
  vertical-align: middle;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 300;
  background: var(--c-secondary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  transform: translateY(-160%);
  transition: transform 0.2s var(--ease-out);
}
.skip-link:focus {
  transform: none;
}

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.container.narrow {
  max-width: 820px;
}
.center {
  text-align: center;
}
.clamp-2,
.clamp-3,
.clamp-4 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clamp-2 {
  -webkit-line-clamp: 2;
}
.clamp-3 {
  -webkit-line-clamp: 3;
}
.clamp-4 {
  -webkit-line-clamp: 4;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--c-accent-ink);
}

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1;
  white-space: nowrap;
  border: 1.5px solid transparent;
  transition:
    transform 160ms var(--ease-out),
    background-color 200ms ease,
    border-color 200ms ease,
    color 200ms ease,
    box-shadow 200ms ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.5;
}
.btn-sm {
  min-height: 38px;
  padding: 0 16px;
  font-size: 13.5px;
}
.btn-lg {
  min-height: 52px;
  padding: 0 28px;
  font-size: 15.5px;
}
.btn-block {
  width: 100%;
}
.btn-primary {
  background: var(--c-primary);
  color: #fff;
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--c-primary) 70%, transparent);
}
.btn-accent {
  background: var(--c-accent);
  color: var(--c-secondary);
}
.btn-ghost {
  color: var(--c-primary);
  border-color: var(--c-line-strong);
  background: transparent;
}
.btn-outline-light {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.04);
}
.btn-danger {
  color: #b42318;
  border-color: rgba(180, 35, 24, 0.25);
  background: transparent;
}
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    background: color-mix(in srgb, var(--c-primary) 88%, #000);
  }
  .btn-accent:hover {
    background: color-mix(in srgb, var(--c-accent) 86%, #fff);
  }
  .btn-ghost:hover {
    background: var(--c-tint);
    border-color: color-mix(in srgb, var(--c-primary) 35%, transparent);
  }
  .btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.6);
  }
  .btn-danger:hover {
    background: rgba(180, 35, 24, 0.06);
  }
}
.btn.loading {
  color: transparent !important;
  position: relative;
}
.btn.loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: spin 0.6s linear infinite;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-primary);
  padding: 6px 0;
  text-underline-offset: 3px;
}
@media (hover: hover) {
  .link-btn:hover {
    text-decoration: underline;
  }
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--c-tint);
  color: var(--c-secondary);
  transition:
    background-color 0.2s ease,
    transform 160ms var(--ease-out);
}
.icon-btn:active:not(:disabled) {
  transform: scale(0.94);
}
.icon-btn:disabled {
  opacity: 0.35;
}
.icon-btn-lg {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 1000300;
  max-width: calc(100vw - 32px);
  background: var(--c-deep);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translate(-50%, 10px) scale(0.98);
  transition:
    opacity 220ms var(--ease-out),
    transform 260ms var(--ease-out),
    bottom 260ms var(--ease-out);
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast[data-type="error"] {
  background: #912018;
}
body.has-player .toast {
  bottom: calc(108px + env(safe-area-inset-bottom));
}

/* A tela de abertura (vinheta) fica em css/intro.css. */

/* Enquanto a abertura está na tela, as animações de entrada do site
   ficam pausadas — assim elas acontecem quando a pessoa consegue ver. */
html.booting #siteRoot *,
html.booting #siteRoot *::before,
html.booting #siteRoot *::after {
  animation-play-state: paused !important;
}
html.booting body {
  overflow: hidden;
}

/* ============================================================
   MOVIMENTO
   - Conteúdo é visível por padrão; só fica oculto quando o JS
     adiciona .motion no <html> (sem JS, nada some).
   - Entradas usam animation com fill "backwards": ao terminar,
     o elemento volta a obedecer seus estados de hover normais.
   ============================================================ */
.motion [data-reveal]:not(.in),
.motion [data-stagger]:not(.in) > * {
  opacity: 0;
}
.motion [data-reveal].in {
  animation: reveal 700ms var(--ease-out) backwards;
}
.motion [data-stagger].in > * {
  animation: reveal 600ms var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}

main.page-enter {
  animation: pageIn 320ms var(--ease-out);
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
}
@keyframes pageIn {
  from {
    opacity: 0;
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
}
@keyframes fadeOut {
  to {
    opacity: 0;
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes shake {
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-3px);
  }
}

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

@media (max-width: 600px) {
  :root {
    --gutter: 18px;
    --header-h: 62px;
  }
}

/* Alvo do link "Pular para o conteúdo": recebe foco sem mostrar contorno */
main:focus {
  outline: none;
}

/* Faixa "AMBIENTE DE TESTE" (js/config.js): só fora da produção */
.env-banner {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 2147483647;
  transform: translateX(-50%);
  padding: 3px 12px;
  border-radius: 0 0 8px 8px;
  background: #f5b400;
  color: #1c1c1c;
  font: 700 11px/1.4 system-ui, sans-serif;
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.env-banner.is-prod {
  background: #c62828;
  color: #fff;
}
