/* ============================================================
   @databolsa/theme — BASE + UTILITÁRIOS
   Camada base (body/seleção/foco), superfícies, tipografia de marca
   (.h-disp/.eyebrow/.stmt), chips, cards, disclosure e animações.
   Depende dos tokens (tokens.css) e do Tailwind v4 (@layer).
   ============================================================ */

@layer base {
  * {
    border-color: var(--line);
  }
  body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
  }
  ::selection {
    background: var(--accent);
    color: var(--accent-ink);
  }
  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

/* malha técnica de fundo — superfície opcional (tinta neutra, funciona no dark) */
.surface-mesh {
  background-color: var(--paper);
  background-image: linear-gradient(color-mix(in srgb, var(--ink) 4%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--ink) 4%, transparent) 1px, transparent 1px);
  background-size: 28px 28px;
}

@layer components {
  /* ---------- tipografia ---------- */
  .h-disp {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.04;
  }
  .eyebrow {
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-soft);
  }
  .eyebrow--ticks::before {
    content: "┤ ";
    opacity: 0.45;
  }
  .eyebrow--ticks::after {
    content: " ├";
    opacity: 0.45;
  }
  .tabnum {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
  }
  .rule-head {
    border-top: 1px solid var(--line-strong);
    padding-top: 8px;
  }

  /* grandes afirmações — a tela responde com UMA frase.
     .stmt-num é o único elemento que pode receber cor de acento. */
  .stmt {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(28px, 3.2vw, 44px);
    line-height: 1.06;
    letter-spacing: -0.02em;
    text-wrap: balance;
  }
  .stmt-xl {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(40px, 5vw, 64px);
    line-height: 1.03;
    letter-spacing: -0.025em;
    text-wrap: balance;
  }
  .stmt-num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
  }

  /* ---------- chips ---------- */
  .chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    font-size: 13.5px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: var(--r-chip);
    border: var(--bw) solid var(--line);
    background: var(--card-bg);
    color: var(--ink);
    white-space: nowrap;
  }
  .chip--accent {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
  }
  .chip--warn {
    border-color: var(--warn);
    color: var(--warn);
    background: var(--warn-soft);
  }
  .chip--sel {
    border-color: var(--line-strong);
    background: var(--fill);
    font-weight: 600;
  }
  .chip--dashed {
    border-style: dashed;
    color: var(--ink-soft);
    background: transparent;
  }
  .chip--tag {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 3px 9px;
    color: var(--ink-soft);
    background: var(--fill);
    border-color: transparent;
  }
  /* tons do chip--tag (mantêm o tamanho pequeno; só trocam a cor) */
  .chip--tag-warn {
    color: var(--warn);
    background: var(--warn-soft);
  }
  .chip--tag-accent {
    color: var(--accent);
    background: var(--accent-soft);
  }

  /* ---------- cards ---------- */
  .card-tech {
    background: var(--card-bg);
    border: var(--bw) solid var(--line);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.25s var(--ease-out), transform 0.25s var(--ease-out),
      border-color 0.25s var(--ease-out);
  }
  .card--ink {
    border-color: var(--line-strong);
    box-shadow: 0 2px 4px rgba(20, 20, 22, 0.04), 0 14px 32px -16px rgba(20, 20, 22, 0.1);
  }
  .card--lift {
    cursor: pointer;
  }
  .card--lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-up);
    border-color: var(--ink-faint);
  }
  /* assinatura: marcas de corte em verde — OPT-IN, reservadas ao destaque #1 */
  .card--crop {
    position: relative;
  }
  .card--crop::before,
  .card--crop::after {
    content: "";
    position: absolute;
    width: 11px;
    height: 11px;
    pointer-events: none;
  }
  .card--crop::before {
    top: -5px;
    left: -5px;
    border-top: 1.5px solid var(--accent);
    border-left: 1.5px solid var(--accent);
  }
  .card--crop::after {
    bottom: -5px;
    right: -5px;
    border-bottom: 1.5px solid var(--accent);
    border-right: 1.5px solid var(--accent);
  }

  /* ---------- disclosure — a casa das notas de metodologia/linhagem ---------- */
  .disclosure {
    border-top: var(--bw) solid var(--line);
  }
  .disclosure > summary {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 11px 2px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: color 0.2s var(--ease-out);
  }
  .disclosure > summary::-webkit-details-marker {
    display: none;
  }
  .disclosure > summary:hover {
    color: var(--ink);
  }
  .disclosure__chevron {
    display: inline-block;
    transition: transform 0.2s var(--ease-out);
  }
  .disclosure[open] .disclosure__chevron {
    transform: rotate(90deg);
  }
  .disclosure__body {
    padding: 4px 2px 16px 18px;
    max-width: 640px;
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--ink-soft);
  }
  .disclosure__body a {
    text-decoration: underline;
  }

  /* ---------- misc ---------- */
  .hairline {
    border: 0;
    border-top: var(--bw) solid var(--line);
  }
  .shimmer {
    display: block;
    height: 11px;
    background: linear-gradient(90deg, var(--fill) 25%, var(--board) 50%, var(--fill) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite linear;
  }
  .faint {
    color: var(--ink-faint);
  }
  .muted {
    color: var(--ink-soft);
  }
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}
@keyframes fadeup-el {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.fadeup {
  animation: fadeup-el 0.55s var(--ease-out) both;
}
.stagger > * {
  animation: fadeup-el 0.55s var(--ease-out) both;
}
.stagger > *:nth-child(1) { animation-delay: 0.03s; }
.stagger > *:nth-child(2) { animation-delay: 0.09s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.21s; }
.stagger > *:nth-child(5) { animation-delay: 0.27s; }
.stagger > *:nth-child(6) { animation-delay: 0.33s; }
.stagger > *:nth-child(n + 7) { animation-delay: 0.39s; }

/* Faixa de mercado rolando (estilo painel de pregão). O track tem 2 cópias do
   conteúdo; translateX(-50%) avança exatamente uma cópia → loop sem emenda. */
@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.ticker-track {
  animation: ticker 32s linear infinite;
}
.ticker-track:hover {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .fadeup,
  .stagger > *,
  .ticker-track {
    animation: none;
  }
  .card-tech {
    transition: none;
  }
}

@media print {
  .surface-mesh {
    background-image: none;
  }
  .card-tech {
    box-shadow: none;
  }
}
