/* ============================================================
   New Sharing — base (reset, tipografia, formulários, foco, rolagem)
   Seletores de baixa especificidade (:where) para que componentes
   e páginas sempre consigam sobrescrever sem !important.
   ============================================================ */

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

/* atributo hidden é o único mecanismo de mostrar/ocultar do JS */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  accent-color: var(--accent);
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image: var(--theme-wallpaper,
    repeating-linear-gradient(90deg, var(--bg-rain-a) 0 2px, transparent 2px 5.5rem),
    repeating-linear-gradient(90deg, var(--bg-rain-b) 0 2px, transparent 2px 3.3rem),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 62%));
  background-attachment: fixed;
  color: var(--fg);
  font: var(--text-base) / var(--leading-base) var(--font-ui);
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
  text-rendering: auto;
}

:where(img, video, canvas, svg) { max-width: 100%; }
:where(img, video) { display: block; }
:where(p, h1, h2, h3, h4, ul, ol, figure) { margin: 0; }
:where(ul, ol) { padding: 0; list-style: none; }

/* ---------- tipografia ---------- */
::where(h1, h2, h3, h4) {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  text-wrap: balance;
}
:where(h1) { font-size: var(--text-2xl); }
:where(h2) { font-size: var(--text-lg); }
:where(h3) { font-size: var(--text-md); letter-spacing: -0.01em; }
:where(h4) { font-size: var(--text-base); letter-spacing: 0; }
:where(p) { text-wrap: pretty; }
:where(b, strong) { font-weight: 650; }
:where(small) { font-size: var(--text-xs); }
:where(code, kbd, samp) { font-family: var(--font-mono); font-size: 0.92em; }

:where(a) {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 0.18em;
  border-radius: var(--r-xs);
}
:where(a:hover) { color: var(--accent-hover); text-decoration: underline; }

::selection { background: var(--accent); color: var(--on-accent); }

.muted    { color: var(--fg-2); }
.subtle   { color: var(--fg-3); }
.mono     { font-family: var(--font-mono); letter-spacing: 0; }
.eyebrow  {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--fg-3);
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- foco: um único anel, sempre visível no teclado ---------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus { outline: none; }
::where(a, button, summary, [tabindex], [role="button"], [role="tab"], [role="menuitem"]):focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--shadow-ink);
}

/* ---------- formulários ---------- */
:where(input, select, textarea) {
  font: inherit;
  font-size: var(--text-base);
  color: var(--fg);
  width: 100%;
  min-width: 0;
  height: var(--control-h);
  padding: 0 var(--sp-3);
  background: var(--surface-sunk);
  border: 2px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: inset 2px 2px 0 var(--shadow-inset);
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
:where(textarea) { height: auto; min-height: 5rem; padding: var(--sp-2) var(--sp-3); resize: vertical; }
:where(select) {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b909b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 1rem;
}
:where(input, select, textarea)::placeholder { color: var(--placeholder); opacity: 1; }
:where(input, select, textarea):hover { border-color: var(--line-strong); }
::where(input, select, textarea):focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 1px;
  border-color: var(--accent);
  box-shadow: inset 2px 2px 0 var(--shadow-inset);
}
:where(input, select, textarea)[aria-invalid="true"] { border-color: var(--danger); }
:where(input, select, textarea):disabled { opacity: 0.5; cursor: not-allowed; }

:where(input[type="checkbox"], input[type="radio"]) {
  width: 1.125rem;
  height: 1.125rem;
  padding: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

/* iOS dá zoom em inputs < 16px; sem isso o site precisaria bloquear o zoom da página */
@media (pointer: coarse) {
  :where(input, select, textarea) { font-size: max(16px, 1rem); }
}

/* range (volume etc.) */
:where(input[type="range"]) {
  appearance: none;
  -webkit-appearance: none;
  height: 1.25rem;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  cursor: pointer;
}
::where(input[type="range"])::-webkit-slider-runnable-track { height: 4px; border-radius: var(--r-xs); background: var(--line-strong); }
::where(input[type="range"])::-moz-range-track { height: 4px; border-radius: var(--r-xs); background: var(--line-strong); }
::where(input[type="range"])::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 0.875rem; height: 0.875rem; margin-top: -5px;
  border-radius: var(--r-xs); background: var(--accent); border: 2px solid var(--shadow-ink);
}
::where(input[type="range"])::-moz-range-thumb { width: 0.875rem; height: 0.875rem; border-radius: var(--r-xs); background: var(--accent); border: 2px solid var(--shadow-ink); }
:where(input[type="range"]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: none; }

:where(button) { font: inherit; color: inherit; }

/* ---------- rolagem discreta ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) var(--surface-sunk); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--surface-sunk); }
::-webkit-scrollbar-thumb { background: var(--line-strong); border: 2px solid var(--surface-sunk); }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---------- utilitários mínimos (evitam style="" inline) ---------- */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip-link {
  position: fixed;
  top: var(--sp-2); left: var(--sp-2);
  z-index: calc(var(--z-toast) + 1);
  padding: var(--sp-2) var(--sp-4);
  background: var(--fg); color: var(--fg-inverse);
  border-radius: var(--r-md);
  font-weight: 600;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; text-decoration: none; color: var(--fg-inverse); }

.stack   { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack-2 { display: flex; flex-direction: column; gap: var(--sp-2); }
.stack-4 { display: flex; flex-direction: column; gap: var(--sp-4); }
.row     { display: flex; align-items: center; gap: var(--sp-2); }
.row-3   { display: flex; align-items: center; gap: var(--sp-3); }
.row-wrap { flex-wrap: wrap; }
.grow    { flex: 1 1 0; min-width: 0; }
.center  { text-align: center; }
.right   { margin-left: auto; }

@media print { body { background: var(--paper); color: var(--ink); } }
