/* ==========================================================================
   coisaútil.tech — sistema visual no estilo shadcn/ui
   Use em todas as páginas:  <link rel="stylesheet" href="/assets/ui.css">
   ========================================================================== */

@font-face { font-family: "Matter"; src: url("/fonts/matter-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Matter"; src: url("/fonts/matter-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Matter"; src: url("/fonts/matter-medium.woff2") format("woff2"); font-weight: 500 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Matter"; src: url("/fonts/matter-bold.woff2") format("woff2"); font-weight: 700 800; font-style: normal; font-display: swap; }

/* ---------- Tokens (paleta zinc + vermelho da marca como primary) ---------- */
:root {
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --popover: #ffffff;
  --popover-foreground: #09090b;
  --primary: #fe0030;
  --primary-hover: #e0002a;
  --primary-foreground: #ffffff;
  --secondary: #f4f4f5;
  --secondary-foreground: #18181b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --accent: #f4f4f5;
  --accent-foreground: #18181b;
  --destructive: #ef4444;
  --destructive-foreground: #ffffff;
  --success: #16a34a;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --ring: #fe0030;
  --radius: 0.5rem;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --font-sans: "Matter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #09090b;
    --foreground: #fafafa;
    --card: #09090b;
    --card-foreground: #fafafa;
    --popover: #09090b;
    --popover-foreground: #fafafa;
    --primary-hover: #ff2a50;
    --secondary: #27272a;
    --secondary-foreground: #fafafa;
    --muted: #27272a;
    --muted-foreground: #a1a1aa;
    --accent: #27272a;
    --accent-foreground: #fafafa;
    --destructive: #dc2626;
    --border: #27272a;
    --input: #27272a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --background: #09090b; --foreground: #fafafa; --card: #09090b; --card-foreground: #fafafa;
  --popover: #09090b; --popover-foreground: #fafafa; --primary-hover: #ff2a50;
  --secondary: #27272a; --secondary-foreground: #fafafa; --muted: #27272a; --muted-foreground: #a1a1aa;
  --accent: #27272a; --accent-foreground: #fafafa; --destructive: #dc2626; --border: #27272a; --input: #27272a;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; border: 0 solid var(--border); }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
}
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--primary) 20%, transparent); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: calc(var(--radius) - 2px); }

[hidden] { display: none !important; }
.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; }
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
@media (min-width: 640px) { .container { padding-left: 24px; padding-right: 24px; } }
.text-muted { color: var(--muted-foreground); }
.link { text-decoration: underline; text-underline-offset: 4px; }
.link:hover { color: var(--primary); }

/* ---------- Tipografia ---------- */
.h1 { font-size: clamp(2.25rem, 7vw, 3.75rem); font-weight: 700; letter-spacing: -0.035em; line-height: 1.05; }
.h2 { font-size: clamp(1.5rem, 4vw, 1.875rem); font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; }
.h3 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; }
.lead { font-size: clamp(1rem, 2.6vw, 1.25rem); color: var(--muted-foreground); line-height: 1.6; }
.small { font-size: .875rem; }
.xs { font-size: .75rem; }

/* ---------- Header / Footer do site ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) 85%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  padding-top: env(safe-area-inset-top);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-icon { width: 28px; height: 28px; }
.brand-wordmark { height: 18px; width: auto; }
.brand-wordmark .wm1 { fill: var(--primary); }
.brand-wordmark .wm2 { fill: var(--foreground); }
.site-footer { border-top: 1px solid var(--border); padding: 24px 0 max(24px, env(safe-area-inset-bottom)); color: var(--muted-foreground); font-size: .875rem; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }

/* ---------- Botão ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--radius);
  font-size: .875rem; font-weight: 500; line-height: 1; white-space: nowrap;
  cursor: pointer; user-select: none;
  border: 1px solid transparent;
  transition: background-color .15s, color .15s, border-color .15s, box-shadow .15s;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-secondary:hover { background: color-mix(in srgb, var(--secondary) 80%, var(--foreground) 6%); }
.btn-outline { background: var(--background); border-color: var(--input); box-shadow: var(--shadow-sm); }
.btn-outline:hover { background: var(--accent); color: var(--accent-foreground); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--accent); color: var(--accent-foreground); }
.btn-destructive { background: var(--destructive); color: var(--destructive-foreground); }
.btn-sm { height: 36px; padding: 0 12px; }
.btn-lg { height: 44px; padding: 0 24px; font-size: .9375rem; }
.btn-icon { width: 40px; padding: 0; }
.btn-block { width: 100%; }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 9999px; border: 1px solid transparent;
  padding: 2px 10px; font-size: .75rem; font-weight: 500; line-height: 1.4; white-space: nowrap;
}
.badge-primary { background: var(--primary); color: var(--primary-foreground); }
.badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.badge-outline { border-color: var(--border); color: var(--foreground); }
.badge-success { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.badge-dot.pulse { animation: ui-pulse 1.6s ease-in-out infinite; }
@keyframes ui-pulse { 50% { opacity: .3; } }

/* ---------- Card ---------- */
.card { background: var(--card); color: var(--card-foreground); border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); box-shadow: var(--shadow-sm); }
.card-header { padding: 24px 24px 0; display: flex; flex-direction: column; gap: 6px; }
.card-title { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; }
.card-description { font-size: .875rem; color: var(--muted-foreground); }
.card-content { padding: 24px; }
.card-footer { padding: 0 24px 24px; display: flex; align-items: center; gap: 8px; }
a.card { display: block; transition: border-color .15s, box-shadow .15s, transform .15s; }
a.card:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); box-shadow: var(--shadow); }

/* ---------- Formulários ---------- */
.label { display: block; font-size: .875rem; font-weight: 500; line-height: 1; margin-bottom: 8px; }
.input, .select, .textarea {
  display: block; width: 100%;
  height: 40px; padding: 0 12px;
  font-size: 16px; /* evita zoom no iPhone */
  background: var(--background); color: var(--foreground);
  border: 1px solid var(--input); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 80px; padding: 8px 12px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--muted-foreground); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: none; border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 22%, transparent);
}
.help { font-size: .8125rem; color: var(--muted-foreground); margin-top: 6px; }

/* ---------- Diversos ---------- */
.separator { height: 1px; background: var(--border); border: 0; }
.kbd { font-family: var(--font-mono); font-size: .75rem; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--muted); }
.alert { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; font-size: .875rem; }
.alert-destructive { border-color: color-mix(in srgb, var(--destructive) 50%, transparent); color: var(--destructive); }
.icon-box { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius); background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); }
.icon-box svg { width: 20px; height: 20px; }

/* ---------- Acessibilidade (assets/a11y.js) ---------- */
html[data-fonte="1"] body { zoom: 1.15; min-height: calc(100svh / 1.15); }
html[data-fonte="2"] body { zoom: 1.3; min-height: calc(100svh / 1.3); }
.a11y-fim { display: flex; align-items: center; gap: 4px; flex-shrink: 0; min-width: 0; }
.a11y { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; }
.a11y .a11y-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; margin: 0;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--foreground);
  font-family: var(--font-sans); font-size: 1rem; font-weight: 600; line-height: 1; letter-spacing: -.02em;
  cursor: pointer; box-shadow: none; transition: background-color .15s;
}
.a11y .a11y-btn:hover { background: var(--accent); }
.a11y .a11y-btn svg { width: 18px; height: 18px; display: block; }
.a11y .a11y-btn[aria-pressed="true"] { background: var(--accent); }
.a11y-fonte sup { font-size: .65em; margin-left: 1px; vertical-align: .55em; line-height: 0; }
.site-header .brand, .topbar .home { flex-shrink: 0; }
/* No celular, a marca já leva ao início: esconde o "← Todas as ferramentas" */
@media (max-width: 560px) { .a11y-fim .back, .a11y-fim .voltar-site, .a11y-fim > .btn { display: none; } }

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