/* ==========================================================================
   Kalcfy — Design System
   Calcule tudo. Decida melhor.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --brand: #635BFF;
  --brand-dark: #4B44D6;
  --brand-soft: #EEEDFF;
  --ink: #111827;
  --ink-soft: #1F2937;
  --success: #10B981;
  --success-soft: #E7F8F1;
  --danger: #EF4444;
  --danger-soft: #FDECEC;
  --warning: #B45309;
  --warning-soft: #FEF6E7;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --text: #0F172A;
  --muted: #475569;
  --line: #E2E8F0;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 4px 16px rgba(15, 23, 42, .07);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, .10);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --container: 1140px;
  --header-h: 64px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --brand: #8B85FF;
  --brand-dark: #6E66F5;
  --brand-soft: #241F52;
  --success: #34D399;
  --success-soft: #12312A;
  --danger: #F87171;
  --danger-soft: #3A1D1D;
  --warning: #FBBF24;
  --warning-soft: #372B12;
  --bg: #0B1120;
  --surface: #111827;
  --surface-2: #1B2436;
  --text: #E8EDF6;
  --muted: #9AA7BC;
  --line: #26324A;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 4px 16px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, .55);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--space-3); color: var(--text); font-weight: 700; letter-spacing: -.015em; }
h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.5rem); }
h2 { font-size: clamp(1.35rem, 1.1rem + 1.1vw, 1.8rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 var(--space-4); }
ul, ol { margin: 0 0 var(--space-4); padding-left: 1.25rem; }
li { margin-bottom: var(--space-2); }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 1000;
  background: var(--brand); color: #fff; padding: 12px 18px; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

.visually-hidden {
  position: absolute !important; 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: var(--container); margin: 0 auto; padding: 0 var(--space-4); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; gap: var(--space-4);
  min-height: var(--header-h);
}
.brand { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; flex: 0 0 32px; }
.brand-name { font-weight: 800; font-size: 1.25rem; letter-spacing: -.03em; color: var(--text); }
.brand-name span { color: var(--brand); }

.header-search { flex: 1 1 auto; max-width: 420px; position: relative; }
.header-nav { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }
.header-nav a { color: var(--muted); font-weight: 600; font-size: .93rem; padding: 8px 10px; border-radius: var(--radius-sm); }
.header-nav a:hover { color: var(--brand); background: var(--surface-2); text-decoration: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  cursor: pointer; transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.icon-btn svg { width: 20px; height: 20px; }

.menu-toggle { display: none; }

/* Dropdown de categorias */
.has-dropdown { position: relative; }
.dropdown-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: 0; font: inherit; font-weight: 600; font-size: .93rem;
  color: var(--muted); cursor: pointer; padding: 8px 10px; border-radius: var(--radius-sm);
}
.dropdown-toggle:hover { color: var(--brand); background: var(--surface-2); }
.dropdown-toggle svg { width: 14px; height: 14px; transition: transform .2s ease; }
.dropdown-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.dropdown-panel {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 240px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: var(--space-2); display: none;
}
.dropdown-panel.is-open { display: block; }
.dropdown-panel a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--radius-sm); color: var(--text); font-weight: 500; font-size: .95rem;
}
.dropdown-panel a:hover { background: var(--surface-2); text-decoration: none; color: var(--brand); }

/* ---------- Busca ---------- */
.search-field { position: relative; display: block; }
.search-field svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--muted); pointer-events: none;
}
.search-input {
  width: 100%; font: inherit; font-size: .95rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 10px 16px 10px 40px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus {
  background: var(--surface); border-color: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);
  outline: none;
}
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 70;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-height: 60vh; overflow-y: auto; padding: var(--space-2);
  display: none;
}
.search-results.is-open { display: block; }
.search-results li { margin: 0; list-style: none; }
.search-results ul { margin: 0; padding: 0; }
.search-item {
  display: block; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text);
}
.search-item:hover, .search-item:focus, .search-item.is-active { background: var(--surface-2); text-decoration: none; }
.search-item strong { display: block; font-size: .95rem; font-weight: 600; }
.search-item mark { background: color-mix(in srgb, var(--brand) 25%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.search-item small { color: var(--muted); font-size: .82rem; }
.search-empty { padding: 16px 12px; color: var(--muted); font-size: .92rem; text-align: center; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .97rem; line-height: 1;
  padding: 13px 22px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; text-align: center;
  transition: transform .14s ease, background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--brand); color: var(--brand); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--brand); border-color: var(--brand); }
.btn-sm { padding: 9px 14px; font-size: .88rem; }
.btn-block { width: 100%; }

/* ---------- Cards de ferramentas ---------- */
.tool-grid {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  list-style: none; padding: 0; margin: 0;
}
.tool-card {
  position: relative; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--space-4); box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  margin: 0;
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.tool-card-icon {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); margin-bottom: 6px;
}
.tool-card-icon svg { width: 21px; height: 21px; }
.tool-card h3 { font-size: 1.02rem; margin: 0; }
.tool-card h3 a { color: var(--text); }
.tool-card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.tool-card h3 a:hover { color: var(--brand); text-decoration: none; }
.tool-card p { font-size: .89rem; color: var(--muted); margin: 0; }
.tool-card .tag {
  align-self: flex-start; margin-top: auto; padding-top: 10px;
  font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--brand);
}
.fav-btn {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; transition: color .18s ease, background .18s ease;
}
.fav-btn:hover { color: var(--brand); background: var(--brand-soft); }
.fav-btn svg { width: 19px; height: 19px; }
.fav-btn[aria-pressed="true"] { color: var(--brand); }
.fav-btn[aria-pressed="true"] svg { fill: currentColor; }

/* ---------- Seções ---------- */
.section { padding: var(--space-7) 0; }
.section-head { margin-bottom: var(--space-5); }
.section-head p { color: var(--muted); margin: 0; }
.section-head .eyebrow {
  display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--brand); margin-bottom: 6px;
}
.section-alt { background: var(--surface); border-block: 1px solid var(--line); }

/* ---------- Hero ---------- */
.hero { padding: var(--space-8) 0 var(--space-7); position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -40% 30% auto -10%; height: 520px;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--brand) 20%, transparent), transparent);
  pointer-events: none; z-index: 0;
}
.hero .container { position: relative; z-index: 1; }
.hero h1 { max-width: 15ch; }
.hero-lead { font-size: 1.08rem; color: var(--muted); max-width: 58ch; }
.hero-search { max-width: 560px; margin-bottom: var(--space-4); }
.hero-search .search-input { padding: 15px 18px 15px 44px; font-size: 1rem; box-shadow: var(--shadow); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-5); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 var(--space-5); }
.chip-row li { margin: 0; }
.chip {
  display: inline-block; padding: 7px 14px; border-radius: 999px; font-size: .87rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.chip:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.hero-stats { display: flex; flex-wrap: wrap; gap: var(--space-6); }
.hero-stats div { min-width: 96px; }
.hero-stats strong { display: block; font-size: 1.65rem; font-weight: 800; color: var(--brand); letter-spacing: -.03em; }
.hero-stats span { font-size: .86rem; color: var(--muted); }

/* ---------- Categorias ---------- */
.category-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); list-style: none; padding: 0; margin: 0; }
.category-grid li { margin: 0; }
.category-card {
  display: flex; align-items: center; gap: 12px; padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm);
  transition: border-color .18s ease, transform .18s ease;
}
.category-card:hover { border-color: var(--brand); transform: translateY(-2px); text-decoration: none; color: var(--brand); }
.category-card .tool-card-icon { margin: 0; }
.category-card small { display: block; font-weight: 500; color: var(--muted); font-size: .8rem; }

/* ---------- Benefícios ---------- */
.feature-grid { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.feature h3 { font-size: 1.05rem; }
.feature p { color: var(--muted); font-size: .94rem; margin: 0; }
.feature .tool-card-icon { background: var(--success-soft); color: var(--success); }

/* ---------- FAQ ---------- */
.faq-list { display: grid; gap: var(--space-3); }
.faq-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 4px var(--space-4); box-shadow: var(--shadow-sm);
}
.faq-item summary {
  cursor: pointer; font-weight: 600; padding: 14px 0; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+"; font-size: 1.4rem; font-weight: 400; color: var(--brand); line-height: 1;
}
.faq-item[open] summary::after { content: "−"; }
.faq-item p { color: var(--muted); font-size: .95rem; margin: 0 0 14px; }

/* ---------- Anúncios ---------- */
.ad-slot {
  min-height: 100px; margin: var(--space-5) 0; display: grid; place-items: center;
  background: var(--surface-2); border: 1px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase;
}
.ad-slot-lg { min-height: 250px; }

/* ---------- Rodapé ---------- */
.site-footer {
  background: var(--surface); border-top: 1px solid var(--line);
  padding: var(--space-7) 0 var(--space-5); margin-top: var(--space-7);
}
.footer-grid { display: grid; gap: var(--space-5); grid-template-columns: 1.4fr repeat(3, 1fr); }
.footer-grid h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 8px; }
.footer-grid a { color: var(--text); font-size: .93rem; }
.footer-grid a:hover { color: var(--brand); }
.footer-about p { color: var(--muted); font-size: .92rem; max-width: 34ch; }
.footer-bottom {
  margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: space-between;
  color: var(--muted); font-size: .86rem;
}
.footer-bottom button {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: .86rem;
  cursor: pointer; text-decoration: underline; padding: 0;
}
.footer-bottom button:hover { color: var(--brand); }

/* ---------- Banner de cookies ---------- */
.consent {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(720px, calc(100% - 32px)); z-index: 90;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: var(--space-5);
}
.consent[hidden] { display: none; }
.consent h2 { font-size: 1.05rem; }
.consent p { font-size: .9rem; color: var(--muted); margin-bottom: var(--space-4); }
.consent-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.consent-options { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3); margin-bottom: var(--space-4); }
.consent-options label { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; margin-bottom: 10px; }
.consent-options label:last-child { margin-bottom: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: .9rem; font-weight: 600; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .22s ease, transform .22s ease; z-index: 120;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
[data-theme="dark"] .toast { background: var(--brand); }

/* ---------- Menu mobile ---------- */
.mobile-nav {
  display: none; border-top: 1px solid var(--line); background: var(--surface);
  padding: var(--space-4) 0;
}
.mobile-nav.is-open { display: block; }
.mobile-nav ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.mobile-nav a { display: block; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text); font-weight: 600; }
.mobile-nav a:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- Conteúdo institucional ---------- */
.prose { max-width: 72ch; }
.prose h2 { margin-top: var(--space-6); }
.prose h3 { margin-top: var(--space-5); }
.page-header { padding: var(--space-6) 0 0; }

/* ---------- Movimento reduzido ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ---------- Impressão ---------- */
@media print {
  .site-header, .site-footer, .ad-slot, .consent, .result-actions,
  .mobile-nav, .toast, .related, .fav-btn, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .result-box { border: 1px solid #ccc; box-shadow: none; }
  a[href]::after { content: ""; }
}

/* ---------- Complementos de layout ---------- */
.calc-main { min-width: 0; }
.calc-tools { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.calc-card { margin-bottom: var(--space-5); }
.section-desc { color: var(--muted); margin: 0 0 var(--space-4); }
.page-narrow { max-width: 74ch; margin: 0 auto; padding-bottom: var(--space-6); }
.page-header .meta { font-size: .85rem; color: var(--muted); }
.contact-email { font-size: 1.02rem; }

.steps { display: grid; gap: var(--space-2); padding-left: 1.25rem; margin: 0 0 var(--space-5); }
.steps li { color: var(--muted); }

.filter-box { position: relative; max-width: 520px; margin-top: var(--space-4); }
.filter-box input[type="search"] {
  width: 100%; padding: 13px 16px; font-size: 1rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
}
.filter-box input[type="search"]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.error-page { text-align: center; padding: var(--space-8) 0; }
.error-page .search-box, .error-page .hero-actions { justify-content: center; margin-inline: auto; }

.link-button {
  border: 0; background: none; padding: 0; font: inherit; color: var(--brand);
  text-decoration: underline; cursor: pointer;
}
.link-button:hover { color: var(--brand-dark); }

/* Impede que ícones SVG sem dimensão explícita ocupem a largura toda. */
.category-card svg, .feature svg, .cat-icon svg { width: 21px; height: 21px; }
.category-card > span { min-width: 0; }
.eyebrow {
  display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--brand); margin-bottom: 6px;
}

/* Nenhum elemento de mídia deve estourar a largura do contêiner. */
img, svg, canvas, video { max-width: 100%; }
