/* =========================================================================
   design.metadax.com.br — folha de estilos principal
   Construído sobre os tokens do METADAX Design System v2 (tokens.css)
   ========================================================================= */

@font-face {
  font-family: 'Geist Sans';
  src: url('https://cdn.metadax.com.br/fonts/geist/GeistVF.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('https://cdn.metadax.com.br/fonts/geist/GeistMonoVF.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Audiowide';
  src: url('https://cdn.metadax.com.br/fonts/audiowide/Audiowide-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-canvas);
  color: var(--text-primary);
  font-family: var(--font-product), 'JetBrains Mono', sans-serif;
  transition: background-color .15s ease, color .15s ease;
}

body { font-size: 16px; line-height: 1.5; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

img, svg { max-width: 100%; display: block; }
a { color: var(--metadax-blue-bright); text-decoration: none; }
[data-theme="light"] a:not(.btn) { color: var(--metadax-blue); }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--metadax-blue); color: #fff; }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--metadax-blue-bright); color: #fff; padding: 10px 16px;
  border-radius: 0 0 var(--radius-button-md) 0;
}
.skip-link:focus { left: 0; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 20px;
  background: color-mix(in srgb, var(--surface-canvas) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-logo); font-size: 16px; letter-spacing: 0.02em; color: var(--text-primary); }
.topbar__logo { display: block; height: 24px; width: auto; }
[data-theme="dark"] .topbar__logo--on-light,
[data-theme="light"] .topbar__logo--on-dark { display: none; }
.topbar__brand-mark {
  width: 28px; height: 28px; border-radius: var(--radius-button-sm);
  background: var(--metadax-gradient-nova);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--font-product); font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.topbar__sub { font-family: var(--font-product); font-size: 12px; font-weight: 500; color: var(--text-tertiary); border-left: 1px solid var(--hairline); padding-left: 10px; margin-left: 2px; }
.topbar__spacer { flex: 1; }
.topbar__nav { display: none; gap: 4px; align-items: center; }
.topbar__nav a {
  font-family: var(--font-product); font-size: 14px; font-weight: 500; color: var(--text-secondary);
  padding: 8px 12px; border-radius: var(--radius-button-md);
}
.topbar__nav a:hover { background: var(--surface-1); color: var(--text-primary); text-decoration: none; }
.topbar__nav a.is-active { color: var(--text-primary); background: var(--surface-1); }
@media (min-width: 1024px) { .topbar__nav { display: flex; } }

.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-button-sm); background: transparent; border: 1px solid transparent; color: var(--text-secondary);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-1); border-color: var(--hairline); color: var(--text-primary); }
.icon-btn svg { width: 18px; height: 18px; }

.menu-btn { display: inline-flex; }
@media (min-width: 1024px) { .menu-btn.js-doc-nav-toggle { display: none; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-product); font-size: 14px; font-weight: 600;
  height: 40px; padding: 0 18px; border-radius: var(--radius-button-md);
  border: 1px solid transparent; cursor: pointer; text-decoration: none !important;
  transition: filter .15s ease, transform .05s ease, background-color .15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--metadax-blue); color: #fff; }
[data-theme="dark"] .btn-primary, :root:not([data-theme="light"]) .btn-primary { background: var(--metadax-blue-bright); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text-primary); border-color: var(--hairline); }
.btn-ghost:hover { background: var(--surface-1); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-button-sm); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: var(--radius-pill); font-family: var(--font-product);
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em;
}
.badge--new { background: var(--metadax-red-soft); color: var(--metadax-red); }
.badge--info { background: var(--color-info-bg); color: var(--color-info); }
.badge--success { background: var(--color-success-bg); color: var(--color-success); }
.badge--neutral { background: var(--surface-1); color: var(--text-secondary); border: 1px solid var(--hairline); }

/* ---------- Layout shell ---------- */
.shell { display: flex; min-height: calc(100vh - 60px); }

.doc-nav {
  width: 272px; flex-shrink: 0; border-right: 1px solid var(--hairline);
  position: sticky; top: 60px; align-self: flex-start;
  height: calc(100vh - 60px); overflow-y: auto; padding: 20px 14px 40px;
  background: var(--surface-canvas);
}
.doc-nav__section { margin-bottom: 22px; }
.doc-nav__label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); padding: 0 10px 8px; }
.doc-nav__list { list-style: none; margin: 0; padding: 0; }
.doc-nav__list a {
  display: block; font-family: var(--font-product); font-size: 13.5px; color: var(--text-secondary);
  padding: 7px 10px; border-radius: var(--radius-button-sm); line-height: 1.35;
  border-left: 2px solid transparent;
}
.doc-nav__list a:hover { background: var(--surface-1); color: var(--text-primary); text-decoration: none; }
.doc-nav__list a.is-active { color: var(--metadax-blue-bright); background: var(--surface-1); border-left-color: var(--metadax-blue-bright); font-weight: 600; }
.doc-nav__list--h3 a { padding-left: 22px; font-size: 13px; color: var(--text-tertiary); }
.doc-nav__doclink { display: flex; align-items: center; gap: 8px; font-family: var(--font-product); font-weight: 600; font-size: 13.5px; color: var(--text-primary); padding: 8px 10px; border-radius: var(--radius-button-sm); margin-bottom: 2px; }
.doc-nav__doclink:hover { background: var(--surface-1); text-decoration: none; }
.doc-nav__doclink.is-active { background: var(--surface-1); color: var(--metadax-blue-bright); }
.doc-nav__doclink .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--metadax-blue-bright); flex-shrink: 0; }

@media (max-width: 1023px) {
  .doc-nav {
    position: fixed; inset: 60px 0 0 0; z-index: 90; width: 100%;
    transform: translateX(-100%); transition: transform .2s ease;
    border-right: none; height: calc(100vh - 60px);
  }
  .doc-nav.is-open { transform: translateX(0); }
}

.doc-main { flex: 1; min-width: 0; }
.doc-layout { display: flex; gap: 40px; max-width: 1680px; margin: 0 auto; padding: 40px 32px 100px; }
.doc-content { flex: 1; min-width: 0; max-width: 760px; }
.doc-aside {
  width: 220px; flex-shrink: 0; display: none;
  position: sticky; top: 84px; align-self: flex-start; max-height: calc(100vh - 100px); overflow-y: auto;
}
@media (min-width: 1280px) { .doc-aside { display: block; } }
.doc-aside__label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 10px; }
.doc-aside__list { list-style: none; margin: 0 0 24px; padding: 0; border-left: 1px solid var(--hairline); }
.doc-aside__list a { display: block; font-size: 12.5px; color: var(--text-tertiary); padding: 4px 0 4px 14px; border-left: 2px solid transparent; margin-left: -1px; }
.doc-aside__list a:hover, .doc-aside__list a.is-active { color: var(--metadax-blue-bright); border-left-color: var(--metadax-blue-bright); text-decoration: none; }
.doc-aside__list--h3 a { padding-left: 26px; }

/* ---------- Sync / meta panel ---------- */
.sync-card {
  border: 1px solid var(--hairline); border-radius: var(--radius-button-md);
  background: var(--surface-1); padding: 14px; font-family: var(--font-product); font-size: 12.5px;
}
.sync-card__row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sync-card__row:last-child { margin-bottom: 0; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--text-tertiary); }
.sync-dot--live { background: var(--color-success); box-shadow: 0 0 0 3px var(--color-success-bg); }
.sync-dot--cache { background: var(--color-warning); box-shadow: 0 0 0 3px var(--color-warning-bg); }
.sync-dot--error { background: var(--color-error); box-shadow: 0 0 0 3px var(--color-error-bg); }
.sync-card__label { color: var(--text-secondary); }
.sync-card a { font-size: 12.5px; }

/* ---------- Prose (rendered markdown) ---------- */
.prose { font-family: var(--font-institutional); color: var(--text-primary); }
.prose > *:first-child { margin-top: 0; }
.prose h1 { font-family: var(--font-product); font-size: clamp(28px, 4vw, 40px); font-weight: 600; line-height: 1.12; letter-spacing: -0.02em; margin: 0 0 8px; }
.prose h2 {
  font-family: var(--font-product); font-size: clamp(21px, 2.6vw, 26px); font-weight: 600; line-height: 1.25;
  margin: 52px 0 16px; padding-top: 16px; border-top: 1px solid var(--hairline); scroll-margin-top: 84px;
}
.prose > h2:first-of-type { border-top: none; padding-top: 0; margin-top: 28px; }
.prose h3 { font-family: var(--font-product); font-size: 18px; font-weight: 600; margin: 32px 0 12px; scroll-margin-top: 84px; }
.prose h4 { font-family: var(--font-product); font-size: 15px; font-weight: 600; margin: 24px 0 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; }
.prose p { font-size: 16px; line-height: 1.65; color: var(--text-secondary); margin: 0 0 16px; }
.prose strong { color: var(--text-primary); font-weight: 600; }
.prose ul, .prose ol { color: var(--text-secondary); line-height: 1.7; padding-left: 22px; margin: 0 0 16px; }
.prose li { margin-bottom: 6px; }
.prose li > ul, .prose li > ol { margin-top: 6px; }
.prose hr { border: none; border-top: 1px solid var(--hairline); margin: 40px 0; }
.prose blockquote {
  margin: 20px 0; padding: 14px 18px; border-left: 3px solid var(--metadax-blue-bright);
  background: var(--surface-1); border-radius: 0 var(--radius-button-md) var(--radius-button-md) 0;
  color: var(--text-secondary); font-size: 15px;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose blockquote strong { color: var(--text-primary); }

.prose code:not(pre code) {
  font-family: var(--font-financial); font-size: 0.86em; background: var(--surface-1);
  border: 1px solid var(--hairline); padding: 1px 6px; border-radius: 5px; color: var(--price-up);
}

.prose a { font-weight: 500; }

/* Tables */
.prose .table-wrap { overflow-x: auto; margin: 0 0 24px; border: 1px solid var(--hairline); border-radius: var(--radius-button-md); }
.prose table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.prose th, .prose td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.prose thead th {
  font-family: var(--font-product); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-tertiary); background: var(--surface-1); white-space: nowrap;
}
.prose tbody tr:last-child td { border-bottom: none; }
.prose tbody tr:hover { background: var(--surface-1); }
.prose td code, .prose th code { font-family: var(--font-financial); font-size: 0.86em; color: var(--price-up); background: var(--surface-2); border: 1px solid var(--hairline); padding: 1px 6px; border-radius: 5px; white-space: nowrap; }

/* Code blocks */
.prose pre {
  background: var(--code-bg); color: var(--code-text); font-family: var(--font-financial);
  font-size: 13.5px; line-height: 1.65; border-radius: var(--radius-button-lg);
  padding: 18px 20px; border: 1px solid var(--hairline); overflow-x: auto; margin: 0 0 24px;
  position: relative;
}
.prose pre code { font-family: inherit; background: none; border: none; padding: 0; color: inherit; }
.tok-comment  { color: var(--code-comment); font-style: italic; }
.tok-keyword  { color: var(--code-keyword); font-weight: 600; }
.tok-string   { color: var(--code-string); }
.tok-number   { color: var(--code-number); }
.tok-function { color: var(--code-function); }
.tok-tag      { color: var(--code-tag); }
.tok-property { color: var(--metadax-blue-bright); }
.tok-punct    { color: var(--text-tertiary); }

.code-copy {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  font-family: var(--font-product); font-size: 11px; font-weight: 600;
  color: var(--text-tertiary); background: var(--surface-2); border: 1px solid var(--hairline);
  border-radius: var(--radius-button-sm); padding: 5px 9px; cursor: pointer;
  opacity: 0; transition: opacity .12s ease;
}
.prose pre:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy.is-copied { color: var(--color-success); border-color: var(--color-success); }

/* Color swatches auto-injected next to hex tokens in tables */
.swatch { display: inline-block; width: 13px; height: 13px; border-radius: 4px; border: 1px solid var(--hairline); margin-right: 6px; vertical-align: -2px; flex-shrink: 0; }

/* Heading anchor links */
.prose h2, .prose h3 { position: relative; }
.heading-anchor {
  position: absolute; left: -22px; top: 0.15em; opacity: 0; color: var(--text-tertiary);
  font-size: 0.85em; text-decoration: none;
}
.prose h2:hover .heading-anchor, .prose h3:hover .heading-anchor, .heading-anchor:focus-visible { opacity: 1; }

/* ---------- Doc header ---------- */
.doc-header { margin-bottom: 8px; }
.doc-kicker { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.doc-summary { font-size: 17px; color: var(--text-secondary); line-height: 1.55; margin: 14px 0 0; max-width: 62ch; }
.doc-meta-row { display: flex; align-items: center; gap: 14px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--hairline); flex-wrap: wrap; }

.mobile-sync { margin: 20px 0 32px; }
@media (min-width: 1280px) { .mobile-sync { display: none; } }

/* ---------- Home page ---------- */
.hero { padding: 84px 32px 56px; max-width: 980px; margin: 0 auto; text-align: left; }
.hero__badge { margin-bottom: 22px; }
.hero h1 { font-family: var(--font-product); font-size: clamp(32px, 5.4vw, 52px); font-weight: 600; line-height: 1.08; letter-spacing: -0.02em; margin: 0 0 20px; }
.hero h1 em { font-style: normal; background: var(--metadax-gradient-nova); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { font-size: 18px; line-height: 1.6; color: var(--text-secondary); max-width: 62ch; margin: 0 0 32px; }
.hero__ctas { display: flex; gap: 12px; flex-wrap: wrap; }

.section { max-width: 1160px; margin: 0 auto; padding: 20px 32px 64px; }
.section__head { max-width: 640px; margin-bottom: 32px; }
.section__eyebrow { font-family: var(--font-product); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--metadax-blue-bright); margin-bottom: 10px; }
.section h2 { font-family: var(--font-product); font-size: clamp(22px, 3vw, 30px); font-weight: 600; margin: 0 0 10px; }
.section p { color: var(--text-secondary); font-size: 16px; line-height: 1.6; margin: 0; }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.doc-card {
  display: block; border: 1px solid var(--hairline); border-radius: var(--radius-card);
  background: var(--surface-1); padding: 22px; text-decoration: none !important; color: inherit;
  transition: border-color .15s ease, transform .1s ease;
}
.doc-card:hover { border-color: var(--metadax-blue-bright); transform: translateY(-2px); }
.doc-card__icon {
  width: 40px; height: 40px; border-radius: var(--radius-button-md); display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); margin-bottom: 16px; color: var(--metadax-blue-bright);
}
.doc-card__icon svg { width: 20px; height: 20px; }
.doc-card h3 { font-family: var(--font-product); font-size: 17px; font-weight: 600; margin: 0 0 8px; color: var(--text-primary); }
.doc-card p { font-family: var(--font-product); font-size: 13.5px; color: var(--text-tertiary); line-height: 1.55; margin: 0 0 14px; }
.doc-card__meta { display: flex; align-items: center; justify-content: space-between; font-family: var(--font-financial); font-size: 11.5px; color: var(--text-tertiary); }
.doc-card__go { color: var(--metadax-blue-bright); font-family: var(--font-product); font-weight: 600; font-size: 13px; }

.token-strip { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.token-chip {
  display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-financial); font-size: 12px;
  background: var(--surface-1); border: 1px solid var(--hairline); border-radius: var(--radius-pill); padding: 6px 12px 6px 8px;
  color: var(--text-secondary);
}

.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 4px; }
@media (min-width: 640px) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.stat { border: 1px solid var(--hairline); border-radius: var(--radius-button-lg); padding: 18px; background: var(--surface-1); }
.stat b { display: block; font-family: var(--font-financial); font-size: 26px; font-weight: 600; margin-bottom: 4px; }
.stat span { font-family: var(--font-product); font-size: 12.5px; color: var(--text-tertiary); }

/* ---------- AI Timeline component (used on home as living example) ---------- */
.ai-timeline { display: flex; flex-direction: column; gap: 10px; list-style: none; padding: 0; margin: 0; font-family: var(--font-product); }
.ai-step { display: flex; align-items: center; gap: 10px; }
.ai-step p { margin: 0; font-size: 13px; color: var(--text-secondary); }
.ai-pill { flex-shrink: 0; min-width: 76px; text-align: center; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; }
.ai-step--thinking .ai-pill { color: var(--ai-stage-thinking-fg); background: var(--ai-stage-thinking-bg); }
.ai-step--grep .ai-pill     { color: var(--ai-stage-grep-fg);     background: var(--ai-stage-grep-bg); }
.ai-step--read .ai-pill     { color: var(--ai-stage-read-fg);     background: var(--ai-stage-read-bg); }
.ai-step--edit .ai-pill     { color: var(--ai-stage-edit-fg);     background: var(--ai-stage-edit-bg); }
.ai-step--done .ai-pill     { color: var(--ai-stage-done-fg);     background: var(--ai-stage-done-bg); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--hairline); padding: 40px 32px; }
.site-footer__inner { max-width: 1160px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 20px; align-items: center; justify-content: space-between; }
.site-footer p { margin: 0; font-family: var(--font-institutional); font-size: 12px; color: var(--text-tertiary); line-height: 1.6; }
.site-footer a { font-size: 12px; color: var(--text-tertiary); }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Usage / snippets page ---------- */
.snippet-section { margin-bottom: 36px; }
.snippet-section__title { font-family: var(--font-product); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--metadax-blue-bright); margin-bottom: 14px; }
.snippet-links { list-style: none; padding: 0; margin: 0 0 4px; display: flex; flex-direction: column; gap: 8px; }
.snippet-links li { display: flex; align-items: center; gap: 10px; border: 1px solid var(--hairline); background: var(--surface-1); border-radius: var(--radius-button-md); padding: 10px 12px; }
.snippet-links .k { font-family: var(--font-product); font-weight: 600; font-size: 12.5px; color: var(--text-tertiary); min-width: 150px; flex-shrink: 0; text-transform: uppercase; letter-spacing: .03em; }
.snippet-links code { font-family: var(--font-financial); font-size: 12.5px; color: var(--price-up); word-break: break-all; }

/* ---------- Utility ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.center-note { text-align: center; color: var(--text-tertiary); font-family: var(--font-product); font-size: 13px; padding: 60px 20px; }
.overlay-backdrop {
  position: fixed; inset: 60px 0 0 0; background: rgba(0,0,0,0.5); z-index: 80; opacity: 0; pointer-events: none; transition: opacity .15s ease;
}
.overlay-backdrop.is-open { opacity: 1; pointer-events: auto; }
@media (min-width: 1024px) { .overlay-backdrop { display: none; } }
