/* ==========================================================================
   Crisma Fran — css/base.css
   Fundação do design system: reset, tokens, tipografia, fundo, layout,
   animação base e estados globais. Nada de componente aqui.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. RESET
   -------------------------------------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -moz-tab-size: 2;
  tab-size: 2;
  background: var(--bg);
}

/* Rolagem suave só para quem não pediu menos movimento. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: transparent;
  color: var(--txt);
  font-family: var(--f-texto);
  font-size: var(--t-base);
  line-height: 1.65;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg, video, canvas, picture, iframe {
  display: block;
  max-width: 100%;
}
img, video { height: auto; }

input, button, textarea, select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
button { background: none; border: none; }
button, [role="button"], summary { cursor: pointer; }
textarea { resize: vertical; }

/* Alvo de toque confortável em qualquer controle. */
button, a, input, select, summary, [role="button"], [role="tab"] {
  touch-action: manipulation;
}

ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

table { border-collapse: collapse; border-spacing: 0; }

/* Só quem navega por teclado vê o anel. */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
  border-radius: var(--r-1);
}

::selection {
  background: var(--brand);
  color: var(--txt-inv);
}

/* Barra de rolagem discreta (padrão + WebKit). */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--border-forte) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-forte);
  border: 2px solid transparent;
  background-clip: content-box;
  border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover { background-color: var(--brand); }

/* --------------------------------------------------------------------------
   2. TOKENS — :root é o tema CLARO
   -------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  /* Superfícies — papel quente, levemente creme */
  --bg: #fdf8ef;
  --bg-2: #f6eee0;
  --surface: #fffdf9;
  --surface-2: #f8f1e5;
  --surface-3: #f0e6d5;
  --border: #e7dcc8;
  --border-forte: #8f7f63;

  /* Texto (AA verificado sobre --bg, --surface, --surface-2 e --surface-3) */
  --txt: #23162f;
  --txt-2: #544566;
  --txt-3: #6b5c7e;
  --txt-inv: #fffdf9;

  /* Marca — acentos do vitral rebaixados em luminância para o fundo claro */
  --violeta: #6d28c4;
  --violeta-2: #5a1fa8;
  --ouro: #8a5a00;
  --ouro-2: #6f4700;
  --rosa: #bf1f6e;
  --rosa-2: #a01059;
  --ciano: #0b6b73;
  --ciano-2: #08555c;
  --brand: #6d28c4;
  --brand-2: #bf1f6e;
  --accent: #8a5a00;

  /* Semânticas */
  --ok: #166a45;
  --aviso: #8a5a00;
  --erro: #c02626;
  --info: #1560ac;

  /* Paleta por parte */
  --p-violeta: #6d28c4;
  --p-ouro: #8a5a00;
  --p-rosa: #bf1f6e;
  --p-ciano: #0b6b73;

  /* Gradientes */
  /* No claro o ouro é escuro (#8a5a00, para dar contraste com texto branco) e deixava
     o fim do gradiente cor de barro. Aqui ele fica na família violeta/magenta. */
  --grad-marca: linear-gradient(135deg, var(--violeta) 0%, #9b1f86 52%, var(--rosa) 100%);
  --grad-ouro: linear-gradient(135deg, var(--ouro-2) 0%, var(--ouro) 100%);
  --grad-vitral: linear-gradient(135deg, var(--violeta) 0%, var(--ciano) 32%, var(--rosa) 66%, var(--ouro) 100%);
  --grad-texto: linear-gradient(100deg, var(--violeta-2) 0%, var(--rosa-2) 52%, var(--ouro-2) 100%);

  /* Raios */
  --r-1: 8px;
  --r-2: 12px;
  --r-3: 18px;
  --r-4: 26px;
  --r-5: 36px;
  --r-full: 999px;

  /* Sombras */
  --sh-1: 0 1px 2px rgba(35, 22, 47, .06), 0 2px 8px rgba(35, 22, 47, .05);
  --sh-2: 0 2px 6px rgba(35, 22, 47, .07), 0 10px 24px -8px rgba(35, 22, 47, .12);
  --sh-3: 0 6px 16px rgba(35, 22, 47, .09), 0 28px 60px -20px rgba(35, 22, 47, .22);
  --sh-brand: 0 10px 34px -12px rgba(109, 40, 196, .45);

  /* Espaço */
  --e-1: 4px;
  --e-2: 8px;
  --e-3: 12px;
  --e-4: 16px;
  --e-5: 24px;
  --e-6: 32px;
  --e-7: 48px;
  --e-8: 64px;
  --e-9: 96px;

  /* Tipografia */
  --f-display: "Outfit", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --f-texto: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --f-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Tamanhos fluidos (multiplicados pela escala escolhida pelo usuário) */
  --t-xs: calc(clamp(0.72rem, 0.69rem + 0.16vw, 0.81rem) * var(--escala));
  --t-sm: calc(clamp(0.83rem, 0.79rem + 0.2vw, 0.93rem) * var(--escala));
  --t-base: calc(clamp(1rem, 0.96rem + 0.22vw, 1.08rem) * var(--escala));
  --t-lg: calc(clamp(1.12rem, 1.05rem + 0.33vw, 1.28rem) * var(--escala));
  --t-xl: calc(clamp(1.3rem, 1.2rem + 0.5vw, 1.5rem) * var(--escala));
  --t-2xl: calc(clamp(1.55rem, 1.4rem + 0.78vw, 1.95rem) * var(--escala));
  --t-3xl: calc(clamp(1.9rem, 1.62rem + 1.35vw, 2.6rem) * var(--escala));
  --t-4xl: calc(clamp(2.3rem, 1.82rem + 2.3vw, 3.5rem) * var(--escala));
  --t-5xl: calc(clamp(2.8rem, 2rem + 3.9vw, 4.8rem) * var(--escala));

  /* Layout */
  --max: 1200px;
  --max-txt: 68ch;
  --header-h: 64px;
  --nav-h: 64px;

  /* Movimento */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --dur-1: 150ms;
  --dur-2: 250ms;
  --dur-3: 400ms;

  /* Foco */
  --ring: #6d28c4;
}

/* Tema ESCURO explícito */
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #12091f;
  --bg-2: #180d29;
  --surface: #1d1132;
  --surface-2: #271848;
  --surface-3: #33205c;
  --border: #392a5c;
  --border-forte: #816bbd;

  --txt: #f5eefc;
  --txt-2: #cfc0e6;
  --txt-3: #a394c2;
  --txt-inv: #12091f;

  --violeta: #c19bff;
  --violeta-2: #dcc4ff;
  --ouro: #ffc85c;
  --ouro-2: #ffe0a3;
  --rosa: #ff85c0;
  --rosa-2: #ffb3d8;
  --ciano: #5fdfe0;
  --ciano-2: #a2f0f0;
  --brand: #c19bff;
  --brand-2: #ff85c0;
  --accent: #ffc85c;

  --ok: #5fe0a0;
  --aviso: #ffc45c;
  --erro: #ff8a8a;
  --info: #7fc4ff;

  /* no escuro o ouro é claro e vivo, então volta a fechar o gradiente */
  --grad-marca: linear-gradient(135deg, var(--violeta) 0%, var(--rosa) 55%, var(--ouro) 100%);

  --p-violeta: #c19bff;
  --p-ouro: #ffc85c;
  --p-rosa: #ff85c0;
  --p-ciano: #5fdfe0;

  --sh-1: 0 1px 2px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .35);
  --sh-2: 0 2px 6px rgba(0, 0, 0, .5), 0 12px 28px -8px rgba(0, 0, 0, .6);
  --sh-3: 0 8px 20px rgba(0, 0, 0, .5), 0 32px 70px -22px rgba(0, 0, 0, .8);
  --sh-brand: 0 10px 40px -12px rgba(193, 155, 255, .5);

  --ring: #ffc85c;
}

/* Tema ESCURO por preferência do sistema (variáveis repetidas de propósito:
   não dependemos da cascata do atributo [data-theme]). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #12091f;
    --bg-2: #180d29;
    --surface: #1d1132;
    --surface-2: #271848;
    --surface-3: #33205c;
    --border: #392a5c;
    --border-forte: #816bbd;

    --txt: #f5eefc;
    --txt-2: #cfc0e6;
    --txt-3: #a394c2;
    --txt-inv: #12091f;

    --violeta: #c19bff;
    --violeta-2: #dcc4ff;
    --ouro: #ffc85c;
    --ouro-2: #ffe0a3;
    --rosa: #ff85c0;
    --rosa-2: #ffb3d8;
    --ciano: #5fdfe0;
    --ciano-2: #a2f0f0;
    --brand: #c19bff;
    --brand-2: #ff85c0;
    --accent: #ffc85c;

    --ok: #5fe0a0;
    --aviso: #ffc45c;
    --erro: #ff8a8a;
    --info: #7fc4ff;

    /* no escuro o ouro é claro e vivo, então volta a fechar o gradiente */
    --grad-marca: linear-gradient(135deg, var(--violeta) 0%, var(--rosa) 55%, var(--ouro) 100%);

    --p-violeta: #c19bff;
    --p-ouro: #ffc85c;
    --p-rosa: #ff85c0;
    --p-ciano: #5fdfe0;

    --sh-1: 0 1px 2px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .35);
    --sh-2: 0 2px 6px rgba(0, 0, 0, .5), 0 12px 28px -8px rgba(0, 0, 0, .6);
    --sh-3: 0 8px 20px rgba(0, 0, 0, .5), 0 32px 70px -22px rgba(0, 0, 0, .8);
    --sh-brand: 0 10px 40px -12px rgba(193, 155, 255, .5);

    --ring: #ffc85c;
  }
}

/* Escala tipográfica do usuário. Fica fora do bloco :root para manter a lista
   de tokens da seção 5.2 intacta. */
html { --escala: 1; }
html[data-fonte="m"] { --escala: 1; }
html[data-fonte="g"] { --escala: 1.12; }
html[data-fonte="gg"] { --escala: 1.25; }

/* Cor local por parte: qualquer elemento com [data-cor] se pinta sozinho. */
html { --parte: var(--brand); --parte-2: var(--brand-2); }
[data-cor="violeta"] { --parte: var(--p-violeta); --parte-2: var(--p-rosa); }
[data-cor="ouro"]    { --parte: var(--p-ouro);    --parte-2: var(--p-rosa); }
[data-cor="rosa"]    { --parte: var(--p-rosa);    --parte-2: var(--p-violeta); }
[data-cor="ciano"]   { --parte: var(--p-ciano);   --parte-2: var(--p-violeta); }

/* --------------------------------------------------------------------------
   3. TIPOGRAFIA
   -------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--f-display);
  color: var(--txt);
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h1 { font-size: var(--t-4xl); font-weight: 900; letter-spacing: -0.035em; }
h2 { font-size: var(--t-3xl); font-weight: 800; letter-spacing: -0.03em; }
h3 { font-size: var(--t-2xl); font-weight: 700; }
h4 { font-size: var(--t-xl); font-weight: 700; letter-spacing: -0.015em; }
h5 { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.01em; }
h6 {
  font-size: var(--t-sm);
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--txt-2);
}

p, li, dd, figcaption {
  text-wrap: pretty;
}

p { max-width: var(--max-txt); }

p + p { margin-top: var(--e-4); }

ul, ol {
  padding-left: 1.35em;
  max-width: var(--max-txt);
}
li + li { margin-top: var(--e-2); }
li::marker { color: var(--parte, var(--brand)); }

strong, b { font-weight: 700; color: var(--txt); }
em, i { font-style: italic; }
small { font-size: var(--t-sm); color: var(--txt-2); }

blockquote {
  max-width: var(--max-txt);
  padding: var(--e-3) var(--e-5);
  border-left: 3px solid var(--parte, var(--brand));
  background: var(--surface-2);
  border-radius: 0 var(--r-2) var(--r-2) 0;
  color: var(--txt-2);
  font-style: italic;
}
blockquote cite {
  display: block;
  margin-top: var(--e-2);
  font-style: normal;
  font-size: var(--t-sm);
  color: var(--txt-3);
}

code, kbd, samp, pre {
  font-family: var(--f-mono);
  font-size: .92em;
}
code {
  padding: .15em .4em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-1);
  color: var(--txt);
}
pre {
  overflow-x: auto;
  padding: var(--e-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
}
pre code { padding: 0; background: none; border: none; }

hr, .divisor {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: var(--e-6) 0;
}

a {
  color: var(--brand);
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  text-underline-offset: .18em;
  text-decoration-thickness: .08em;
  transition: color var(--dur-1) var(--ease), text-decoration-color var(--dur-1) var(--ease);
}
a:hover { color: var(--brand-2); text-decoration-color: currentColor; }

abbr[title] { text-decoration: underline dotted; cursor: help; }

/* --------------------------------------------------------------------------
   4. FUNDO — malha de luz de vitral, fixa e sutil
   -------------------------------------------------------------------------- */

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: var(--bg);
  background-image:
    radial-gradient(58vw 46vw at 12% -6%, rgba(109, 40, 196, .12), transparent 70%),
    radial-gradient(46vw 40vw at 92% 4%, rgba(191, 31, 110, .10), transparent 72%),
    radial-gradient(52vw 44vw at 78% 88%, rgba(11, 107, 115, .10), transparent 72%),
    radial-gradient(40vw 36vw at 22% 96%, rgba(138, 90, 0, .09), transparent 74%);
}

[data-theme="dark"] body::before {
  background-image:
    radial-gradient(60vw 48vw at 10% -8%, rgba(150, 88, 255, .26), transparent 70%),
    radial-gradient(48vw 42vw at 94% 2%, rgba(255, 74, 160, .16), transparent 72%),
    radial-gradient(54vw 46vw at 82% 90%, rgba(46, 190, 200, .14), transparent 72%),
    radial-gradient(42vw 38vw at 18% 98%, rgba(255, 176, 60, .10), transparent 74%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body::before {
    background-image:
      radial-gradient(60vw 48vw at 10% -8%, rgba(150, 88, 255, .26), transparent 70%),
      radial-gradient(48vw 42vw at 94% 2%, rgba(255, 74, 160, .16), transparent 72%),
      radial-gradient(54vw 46vw at 82% 90%, rgba(46, 190, 200, .14), transparent 72%),
      radial-gradient(42vw 38vw at 18% 98%, rgba(255, 176, 60, .10), transparent 74%);
  }
}

/* --------------------------------------------------------------------------
   5. LAYOUT E UTILIDADES ESTRUTURAIS
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: max(var(--e-4), env(safe-area-inset-left, 0px)) max(var(--e-4), env(safe-area-inset-right, 0px));
}
@media (min-width: 700px) {
  .container { padding-inline: var(--e-6); }
}

.container--estreito { max-width: 780px; }

.secao {
  padding-block: var(--e-8);
}
@media (min-width: 700px) {
  .secao { padding-block: var(--e-9); }
}

.secao__cabeca {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: var(--e-4);
  margin-bottom: var(--e-6);
}
.secao__cabeca > :first-child { min-width: 0; }
.secao__cabeca p { color: var(--txt-2); margin-top: var(--e-2); }

/* auto-fit + minmax: nunca estoura no mobile, nem precisa de media query */
.grade { display: grid; gap: var(--e-5); }
.grade--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.grade--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.grade--4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); }

.flex {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--e-3);
}

.empilha {
  display: flex;
  flex-direction: column;
  gap: var(--e-3);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* "Pular para o conteúdo": aparece ao receber foco. */
.sr-only--focus:focus,
.sr-only--focus:focus-visible {
  position: fixed;
  top: var(--e-3);
  left: var(--e-3);
  z-index: 999;
  width: auto;
  height: auto;
  margin: 0;
  padding: var(--e-3) var(--e-5);
  overflow: visible;
  clip: auto;
  clip-path: none;
  background: var(--surface);
  color: var(--txt);
  border: 1px solid var(--border-forte);
  border-radius: var(--r-2);
  box-shadow: var(--sh-3);
  font-weight: 700;
  text-decoration: none;
}

.truncar {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vidro {
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  border: 1px solid var(--border);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
}

.brilho {
  box-shadow: var(--sh-brand);
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.9em;
  padding: .15em .5em;
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  line-height: 1.5;
  color: var(--txt-2);
  background: var(--surface-2);
  border: 1px solid var(--border-forte);
  border-bottom-width: 2px;
  border-radius: var(--r-1);
  white-space: nowrap;
}

.marca-texto {
  background: var(--grad-texto);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

/* --------------------------------------------------------------------------
   6. ANIMAÇÃO BASE
   -------------------------------------------------------------------------- */

/* Só esconde quando o JavaScript está de pé (a classe "js" vem do script do <head>).
   Sem JS, ou se algum script quebrar antes do observer subir, o conteúdo aparece igual. */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity var(--dur-3) var(--ease),
    transform var(--dur-3) var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
.js [data-reveal].is-in {
  opacity: 1;
  transform: none;
  will-change: auto;
}

@keyframes subir {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
@keyframes aparecer {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pulsar {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes brilhar {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.28); }
}
@keyframes flutuar {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes girar {
  to { transform: rotate(360deg); }
}
@keyframes tremer {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

/* --------------------------------------------------------------------------
   7. ESTADOS GLOBAIS
   -------------------------------------------------------------------------- */

[hidden] { display: none !important; }
.is-oculto { display: none !important; }

[inert], [aria-disabled="true"], :disabled {
  cursor: not-allowed;
}

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::marker { content: ""; }

/* A tabbar fica fixa no mobile: reserva espaço + área segura do aparelho. */
@media (max-width: 860px) {
  body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); }
}

/* --------------------------------------------------------------------------
   8. MENOS MOVIMENTO — desliga tudo no site inteiro
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
  html { scroll-behavior: auto; }
  .js [data-reveal] { opacity: 1; transform: none; }
}

/* O header é fixo: qualquer alvo de âncora ou scrollIntoView precisa de folga
   por cima, senão o título fica escondido embaixo dele. */
:target,
[id],
.secao,
section {
  scroll-margin-top: calc(var(--header-h) + var(--e-5));
}
