/* =====================================================
AGUA FRAMEWORK - base.agua.css - v2.5
O esqueleto completo que todo projeto Agua herda.
Tokens estruturais - Preflight - Elementos - Formularios -
Primitivas - Utilitarios - Ambiente
NAO CONTEM: componentes (.btn, .card, .badge) →
components.agua.css - identidade visual → theme.agua.css
temas/regras de pagina → agua-manifesto.css (ou customizado)
===================================================== */

/* -----------------------------------------------------
TOKENS ESTRUTURAIS
(--shadow-* definidos só como vocabulário p/ components;
o base NÃO aplica nenhuma sombra;
identidade visual vive exclusivamente em theme.agua.css)
----------------------------------------------------- */
:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "Fira Code", monospace;
  /* Tipografia fluida - Lei 03 */
  --text-xs: clamp(0.75rem, 0.7rem + 0.2vw, 0.8125rem);
  --text-sm: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  --text-base: clamp(0.9375rem, 0.9rem + 0.15vw, 1rem);
  --text-lg: clamp(1.0625rem, 1rem + 0.3vw, 1.125rem);
  --text-xl: clamp(1.25rem, 1.1rem + 0.6vw, 1.375rem);
  --text-2xl: clamp(1.5rem, 1.3rem + 0.8vw, 1.75rem);
  --text-3xl: clamp(1.875rem, 1.5rem + 1.5vw, 2.5rem);
  --text-4xl: clamp(2.25rem, 1.8rem + 2vw, 3.25rem);
  --text-5xl: clamp(2.75rem, 2rem + 3vw, 4.5rem);
  /* Espaçamento */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: clamp(3rem, 2rem + 5vw, 5rem);
  --space-20: clamp(4rem, 3rem + 5vw, 7rem);
  /* Formas (sem elevação) */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-full: 999px;
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08);
  --shadow-md: 0 4px 14px -2px rgb(0 0 0 / 0.12);
  --shadow-lg: 0 12px 28px -4px rgb(0 0 0 / 0.16);
  /* Medidas e camadas */
  --measure: 68ch;
  --header-height: 3.5rem;
  --z-nav: 100;
  --z-overlay: 900;
  --z-modal: 1000;
  --z-toast: 1100;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 250ms;
  --control-h: 3rem;
}

/* Contrato: este arquivo consome --color-* definidos por theme.agua.css.
   O base nao fornece fallback de identidade visual. */

/* -----------------------------------------------------
2. PREFLIGHT - reset moderno
----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  scroll-padding-top: calc(var(--header-height) + 1rem);
  -webkit-text-size-adjust: 100%;
}
body {
  min-height: 100svh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg, video, canvas, picture, iframe { display: block; max-width: 100%; }
img, video { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
[hidden] { display: none !important; }
::selection { background: var(--color-accent); color: var(--color-bg); }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* -----------------------------------------------------
3. ELEMENTOS - defaults flat (separação por tom, não por linha)
----------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-text);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.1em; }
p { color: var(--color-text-2); line-height: 1.7; text-wrap: pretty; }
strong, b { font-weight: 600; color: var(--color-text); }
em { font-style: italic; }
small { font-size: var(--text-sm); }
del { text-decoration: line-through; color: var(--color-text-3); }
ins { text-decoration: underline; color: var(--color-accent-2); }
mark { background: var(--color-accent-dim); color: var(--color-accent-2); padding: 0 0.25em; border-radius: 2px; }
sub, sup { font-size: 0.75em; line-height: 0; position: relative; vertical-align: baseline; }
sup { top: -0.5em; }
sub { bottom: -0.25em; }
abbr[title] { text-decoration: underline dotted; cursor: help; }
address { font-style: normal; color: var(--color-text-2); }
/* Links - sem transição, cor direta */
a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-2); text-decoration: none; }
/* Listas */
ul, ol { padding-left: 1.25rem; }
li::marker { color: var(--color-accent); }
dl { display: grid; gap: var(--space-2); }
dt { font-weight: 600; color: var(--color-text); }
dd { color: var(--color-text-2); margin: 0 0 var(--space-3) 0; }
/* Citação - bloco por tom, sem borda */
blockquote {
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-lg);
  color: var(--color-text);
  line-height: 1.4;
  text-wrap: balance;
}
blockquote p { color: inherit; }
blockquote cite, blockquote footer {
  display: block; margin-top: var(--space-3);
  font-style: normal; font-size: var(--text-sm); color: var(--color-text-3);
}
figure { margin: 0; }
figcaption { margin-top: var(--space-2); font-size: var(--text-sm); color: var(--color-text-3); }
/* Separador - 1px de fundo, única "linha" estrutural */
hr { border: 0; height: 1px; background: var(--color-border); margin: var(--space-8) 0; }
/* Código - fundo, sem borda */
code, kbd, pre { font-family: var(--font-mono); font-size: 0.875em; }
code, kbd { background: var(--color-surface-2); padding: 0.125rem 0.5rem; border-radius: var(--radius-sm); color: var(--color-accent-2); }
pre { background: var(--color-surface); border-radius: var(--radius-md); padding: var(--space-4); overflow-x: auto; }
pre code { background: none; padding: 0; color: var(--color-text-2); }
/* Tabelas - zero borda, zebras por tom */
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
caption { text-align: left; font-size: var(--text-sm); color: var(--color-text-3); padding-bottom: var(--space-2); }
th, td { padding: var(--space-3) var(--space-4); text-align: left; vertical-align: top; }
tbody tr:nth-child(even) { background: var(--color-surface-2); }
th { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-3); }
/* Mídia e interativos nativos - sem blur, sem borda */
progress, meter { accent-color: var(--color-accent); height: 0.5rem; }
summary { cursor: pointer; font-weight: 500; }
dialog {
  background: var(--color-surface); color: var(--color-text);
  border: 0; border-radius: var(--radius-lg);
  padding: var(--space-6); max-width: 32rem; width: calc(100% - 2rem);
}
dialog::backdrop { background: var(--color-overlay); }

/* -----------------------------------------------------
4. FORMULÁRIOS - flat: fundo + outline no foco, zero borda
----------------------------------------------------- */
label { display: block; font-size: var(--text-sm); font-weight: 500; margin-bottom: var(--space-2); }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
select, textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--color-surface-2);
  border: 0;
  border-radius: var(--radius-md);
  font-size: 1rem; /* ≥16px: evita zoom automático no iOS */
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
select { height: var(--control-h); }
input::placeholder, textarea::placeholder { color: var(--color-text-3); }
input:disabled, select:disabled, textarea:disabled, button:disabled { opacity: 0.5; cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { width: 1rem; height: 1rem; accent-color: var(--color-accent); margin: 0; }
input[type="search"] { appearance: none; }
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
input[type="file"] { padding: 0.5rem; }
input[type="file"]::file-selector-button {
  background: var(--color-text); color: var(--color-bg); border: 0;
  border-radius: var(--radius-sm); padding: 0.375rem 0.75rem;
  margin-right: 0.75rem; cursor: pointer; font-weight: 600;
}
input[type="date"], input[type="time"], time { font-variant-numeric: tabular-nums; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='gray' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}
textarea { resize: none; min-height: 6rem; }
fieldset { border: 0; padding: 0; }
legend { font-weight: 600; margin-bottom: var(--space-3); }
/* Padrão .field */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label { margin-bottom: 0; }
.field-error { font-size: var(--text-xs); color: var(--color-danger); }
.field-error:empty { display: none; }
.hint { font-size: var(--text-xs); color: var(--color-text-3); }
.check { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-text-2); cursor: pointer; }
.check label { display: inline; margin: 0; font-weight: 400; font-size: inherit; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-4); }
/* D18 - switch estrutural: formulario passa a duas colunas quando os campos cabem */
@media (min-width: 600px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .full { grid-column: 1 / -1; }
}

/* -----------------------------------------------------
5. PRIMITIVAS - só geometria, sem aparência
----------------------------------------------------- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 clamp(1rem, 5vw, 3rem); }
.container--narrow { max-width: 800px; }
.container--wide { max-width: 1440px; }
.section { padding: var(--space-20) 0; }
.stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--space-4)); }
.stack-sm { --stack-gap: var(--space-2); }
.stack-md { --stack-gap: var(--space-4); }
.stack-lg { --stack-gap: var(--space-8); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--cluster-gap, var(--space-3)); align-items: center; }
.cluster-sm { --cluster-gap: var(--space-2); }
.repel { display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: space-between; align-items: center; }
.switcher { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.switcher > * { flex-grow: 1; flex-basis: calc((var(--switch-at, 40rem) - 100%) * 999); }
.grid {
  display: grid;
  gap: var(--grid-gap, var(--space-5));
  grid-template-columns: repeat(var(--grid-columns, auto-fit), minmax(min(100%, var(--grid-min, 300px)), 1fr));
}
.grid--xs { --grid-min: 140px; }
.grid--sm { --grid-min: 200px; }
.grid--lg { --grid-min: 380px; }
.split { display: grid; grid-template-columns: 1fr; gap: var(--space-6); align-items: start; }
/* D18 - switch estrutural: split vira duas colunas quando leitura lateral fica confortavel */
@media (min-width: 768px) { .split { grid-template-columns: 1fr 1.5fr; gap: var(--space-10); } }
.sidebar { display: grid; grid-template-columns: 1fr; gap: var(--space-6); }
/* D18 - switch estrutural: sidebar vira coluna lateral quando ha largura util */
@media (min-width: 900px) {
  .sidebar { grid-template-columns: minmax(11rem, 16rem) 1fr; }
  .sidebar--right { grid-template-columns: 1fr minmax(11rem, 16rem); }
}
.center { display: grid; place-content: center; }
.bleed { width: 100vw; margin-inline: calc(50% - 50vw); }
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); background: var(--color-surface); }
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: var(--space-4); }
.prose h2 { margin-top: var(--space-10); }
.prose h3 { margin-top: var(--space-8); }
.prose ul, .prose ol { display: grid; gap: var(--space-2); }
.prose blockquote { margin: var(--space-8) 0; }

/* -----------------------------------------------------
6. UTILITÁRIOS
----------------------------------------------------- */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }
.text-4xl { font-size: var(--text-4xl); }
.text-5xl { font-size: var(--text-5xl); }
.text-1 { color: var(--color-text); }
.text-2 { color: var(--color-text-2); }
.text-3 { color: var(--color-text-3); }
.text-center { text-align: center; }
.tabular { font-variant-numeric: tabular-nums; }
.heading { font-weight: 600; line-height: 1; letter-spacing: -0.03em; text-wrap: balance; }
.kicker {
  display: block; font-size: var(--text-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.2em;
  color: var(--color-accent); margin-bottom: var(--space-3);
}
.list-none { list-style: none; padding: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2, .clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { -webkit-line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; }
.aspect-video { aspect-ratio: 16 / 9; }
.aspect-photo { aspect-ratio: 4 / 3; }
.aspect-square { aspect-ratio: 1 / 1; }
.divider { height: 1px; background: var(--color-border); border: 0; margin: var(--space-8) 0; }

/* -----------------------------------------------------
7. AMBIENTE - acessibilidade e movimento
----------------------------------------------------- */
.skip-link {
  position: fixed; top: var(--space-2); left: var(--space-2);
  z-index: var(--z-toast);
  background: var(--color-accent); color: var(--color-bg);
  padding: 0.5rem 1rem; border-radius: var(--radius-md); font-weight: 600;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.no-scroll { overflow: hidden; }
/* Preferencia do usuario: reduz movimento conforme configuracao do sistema */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Cobertura de elementos ~99% (flat) */
audio { display: block; max-width: 100%; }
input[type="range"] { accent-color: var(--color-accent); height: auto; padding: 0; border: 0; background: none; }
input[type="color"] { accent-color: var(--color-accent); width: 3rem; height: var(--control-h); padding: 0.25rem; }
details { background: var(--color-surface-2); border-radius: var(--radius-md); padding: var(--space-3) var(--space-5); }
details + details { margin-top: var(--space-2); }
summary::marker { color: var(--color-accent); }
q { quotes: "\201C" "\201D"; }
q::before, q::after { color: var(--color-accent); }
samp { font-family: var(--font-mono); font-size: 0.875em; }
var { color: var(--color-accent-2); }
dfn { font-style: italic; color: var(--color-text); }
tfoot th, tfoot td { background: var(--color-surface-2); }
output { font-size: var(--text-sm); color: var(--color-text-2); }
