/* ---------- Tokens ---------- */
/* Primitivos: nomeados pelo valor, nunca usados direto num componente. */
:root {
  --navy-900: #011936;
  --navy-800: #0b2442;
  --navy-700: #24364c;
  --navy-600: #14304f;
  --slate-600: #465362;
  --slate-400: #647b82;
  --sage-300: #82a3a1;
  --sage-200: #9dbfbc;
  --sage-100: #e4ecea;
  --paper: #f5f6f4;
  --white: #ffffff;
  --ice-100: #e9eff0;
  --ice-300: #a9b9bd;
  --grey-200: #d9dfdf;
}

/* Semânticos: nomeados pelo papel. É a única camada que os componentes usam.
   O valor de cada papel aparece uma vez só: o tema claro abaixo, o escuro em
   --d-*. Os dois seletores de tema fazem só o remapeamento, sem repetir cor.
   (light-dark() seria mais curto, mas o Chrome não reinvalida as cores quando o
   botão de tema troca color-scheme em tempo de execução, e o tema fica misturado.) */
:root {
  color-scheme: light dark;

  --bg:          var(--paper);
  --surface:     var(--white);
  --text:        var(--navy-900);
  --muted:       var(--slate-600);
  --line:        var(--grey-200);
  --accent:      var(--navy-700);
  --accent-soft: var(--sage-100);
  --image-outline: rgb(0 0 0 / .1);

  --d-bg:          var(--navy-900);
  --d-surface:     var(--navy-800);
  --d-text:        var(--ice-100);
  --d-muted:       var(--ice-300);
  --d-line:        var(--navy-700);
  --d-accent:      var(--sage-200);
  --d-accent-soft: var(--navy-600);
  --d-image-outline: rgb(255 255 255 / .1);

  /* Linha de contorno de um controle: precisa de 3:1 contra o fundo (WCAG 1.4.11).
     --line é separador decorativo e fica em 1,24:1, então não serve aqui.
     --slate-400 mede 4,12:1 no claro e 3,94:1 no escuro. */
  --control-border: var(--slate-400);
  --marker-border:  var(--slate-400);

  /* Painel de marca do projeto em destaque: escuro nos dois temas, de propósito. */
  --panel-bg:    var(--navy-900);
  --panel-bg-to: var(--navy-700);
  --panel-ink:   var(--ice-100);
  --panel-muted: var(--sage-300);

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --maxw: 1080px;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: var(--d-bg); --surface: var(--d-surface); --text: var(--d-text);
    --muted: var(--d-muted); --line: var(--d-line); --accent: var(--d-accent);
    --accent-soft: var(--d-accent-soft); --image-outline: var(--d-image-outline);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--d-bg); --surface: var(--d-surface); --text: var(--d-text);
  --muted: var(--d-muted); --line: var(--d-line); --accent: var(--d-accent);
  --accent-soft: var(--d-accent-soft); --image-outline: var(--d-image-outline);
}
:root[data-theme="light"] { color-scheme: light; }

/* ---------- Idioma: conteúdo PT/EN lado a lado, um escondido ---------- */
html[data-lang="pt"] [lang="en"]:not(html),
html[data-lang="en"] [lang="pt"]:not(html) { display: none !important; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* Sem scroll-behavior: smooth. Ele também anima a rolagem que acompanha o foco
   do teclado, e o anel de foco fica fora da tela enquanto a animação não chega. */
html { scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 {
  font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em;
  letter-spacing: -.01em; text-wrap: balance; overflow-wrap: break-word;
}
h4 { overflow-wrap: break-word; }
h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; text-wrap: pretty; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .container { padding: 0 32px; } }

/* clip-path em vez de left: -999px: não sai da viewport, então nenhum checker
   de overflow o conta, e o comportamento é o mesmo. */
.sr-only, .skip-link {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link:focus {
  position: absolute; left: 8px; top: 8px; z-index: 100;
  width: auto; height: auto; margin: 0; padding: 8px 12px;
  overflow: visible; clip-path: none;
  background: var(--surface); color: var(--text);
}

.eyebrow {
  font: 600 .75rem/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin-bottom: 14px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .container { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 600; }
.brand img { width: 32px; height: 32px; }
.brand span { font-family: var(--serif); font-size: 1.05rem; }
.nav { margin-left: auto; display: none; gap: 24px; }
.nav a { color: var(--muted); text-decoration: none; font-size: .95rem; }
@media (min-width: 760px) { .nav { display: flex; } }
.controls { display: flex; gap: 6px; margin-left: auto; }
@media (min-width: 760px) { .controls { margin-left: 16px; } }
.icon-btn {
  min-width: 40px; height: 40px; padding: 0 10px;
  border: 1px solid var(--control-border); border-radius: var(--radius);
  background: transparent; color: var(--text);
  font: 600 .8rem var(--sans); letter-spacing: .05em; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 18px; height: 18px; }
.theme-dark-icon { display: none; }
:root[data-theme="dark"] .theme-dark-icon { display: block; }
:root[data-theme="dark"] .theme-light-icon { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--radius);
  font: 600 .95rem var(--sans); text-decoration: none;
  border: 1px solid var(--text); color: var(--text); background: transparent;
}
.btn-primary { background: var(--text); color: var(--bg); }
.btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.minor-links { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 20px; font-size: .95rem; }
/* 44px de altura dá a folga que a WCAG 2.5.8 pede entre alvos vizinhos no celular. */
.minor-links a { color: var(--muted); display: inline-flex; align-items: center; min-height: 44px; }

/* ---------- Estados ---------- */
/* Hover só em ponteiro de verdade: no toque o :hover trava depois do tap
   e o controle fica parecendo selecionado. */
@media (hover: hover) {
  a:hover { text-decoration-thickness: 2px; }
  .nav a:hover { color: var(--text); }
  .icon-btn:hover,
  .btn:hover { background: var(--accent-soft); }
  .btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--bg); }
}
/* Só `scale` transiciona. Pôr background-color aqui faria a troca de tema
   animar o fundo de todo botão de uma vez, e o swap sai borrado. */
.btn, .icon-btn { transition: scale 150ms ease-out; }
.btn:not([aria-disabled="true"]):active,
.icon-btn:active { scale: .96; }
@media (prefers-reduced-motion: reduce) {
  .btn, .icon-btn { transition: none; }
  .btn:not([aria-disabled="true"]):active,
  .icon-btn:active { scale: 1; background-color: var(--accent-soft); }
}

/* ---------- Sections ---------- */
section { padding: 72px 0; }
@media (min-width: 720px) { section { padding: 104px 0; } }
.section-head { max-width: 640px; margin-bottom: 40px; }
.section-head p { color: var(--muted); }
.rule { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* Hero */
.hero { padding-top: 64px; }
@media (min-width: 720px) { .hero { padding-top: 120px; padding-bottom: 152px; } }
.hero .role { font: 500 1.15rem var(--sans); color: var(--muted); margin-bottom: 24px; }
/* 500 é o peso mais leve de Source Serif 4 que o site carrega; em 400 o navegador
   cairia no 500 de qualquer jeito, mas a fonte de fallback renderizaria 400 de verdade. */
.hero .lede { font-family: var(--serif); font-weight: 500; font-size: clamp(1.25rem, 2.6vw, 1.6rem); line-height: 1.45; max-width: 34ch; margin-bottom: 20px; }
.hero .meta { color: var(--muted); font-size: .95rem; margin-bottom: 32px; }

/* Featured */
.featured {
  display: grid; gap: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
/* minmax(0, …): sem isso uma palavra longa no título estica a coluna além da sua fatia. */
@media (min-width: 860px) { .featured { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
.featured-body { padding: 28px; }
.featured-visual { padding: 28px; }
@media (min-width: 720px) { .featured-body, .featured-visual { padding: 40px; } }
.featured-visual {
  background: var(--panel-bg); color: var(--panel-ink);
  display: flex; flex-direction: column; justify-content: flex-end; min-height: 220px;
  background-image: linear-gradient(135deg, var(--panel-bg), var(--panel-bg-to));
}
.featured-visual .big { font-family: var(--serif); font-weight: 500; font-size: 2.6rem; line-height: 1; margin-bottom: 8px; }
.featured-visual p { color: var(--panel-muted); margin: 0; font-size: .95rem; }

/* A caixa da pill fica na margem comum da seção. Puxá-la -11px para alinhar o
   texto interno resolvia a ótica e quebrava o alinhamento de todo o resto do
   bloco (o checker passou a acusar `stagger`), então a caixa é que manda. */
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 24px; padding: 0; list-style: none; }
.tags li { font-size: .8rem; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.card-links { display: flex; flex-wrap: wrap; gap: 18px; font-size: .95rem; font-weight: 500; }
/* Mesma altura de alvo dos links secundários: são a ação principal de cada card. */
.card-links a { display: inline-flex; align-items: center; min-height: 44px; }

/* Project grid */
.grid { display: grid; gap: 20px; margin-top: 20px; }
@media (min-width: 720px) { .grid { grid-template-columns: 1fr 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
}
.card-img {
  aspect-ratio: 16/9; object-fit: cover; object-position: top; width: 100%;
  background: var(--accent-soft);
  outline: 1px solid var(--image-outline); outline-offset: -1px;
}
.card-body { padding: 24px; display: flex; flex-direction: column; flex: 1; }
.card-body p { color: var(--muted); }
.card .card-links { margin-top: auto; }
.kind { font-size: .8rem; color: var(--muted); margin-bottom: 6px; }

/* About */
.about { display: grid; gap: 40px; }
@media (min-width: 860px) { .about { grid-template-columns: 260px 1fr; gap: 64px; } }
.about-photo { width: 100%; max-width: 260px; aspect-ratio: 4/5; object-fit: cover; border-radius: var(--radius); filter: grayscale(.15); }
.facts { display: grid; gap: 48px; margin-top: 32px; }
.facts h3 { font: 600 .8rem var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 10px; }
.facts ul { list-style: none; padding: 0; margin: 0; }
.facts > div > ul > li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .97rem; }
.facts li small { color: var(--muted); display: block; font-size: .85rem; }
.stack-group { margin-bottom: 14px; }
.stack-group strong { display: block; font-size: .85rem; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.stack-group .tags { margin: 0; }
.lang-note { font-size: .9rem; color: var(--muted); margin-top: 12px; }

/* Contact */
.contact { text-align: left; }
.contact h2 { max-width: 20ch; }
.contact p { color: var(--muted); max-width: 52ch; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0; color: var(--muted); font-size: .88rem; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; }

/* ---------- Case study ---------- */
.case-hero { padding: 56px 0 40px; }
@media (min-width: 720px) { .case-hero { padding: 88px 0 56px; } }
.back { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 20px; color: var(--muted); font-size: .95rem; }
.case-hero .lede { font-family: var(--serif); font-weight: 500; font-size: clamp(1.15rem, 2.3vw, 1.4rem); max-width: 44ch; color: var(--muted); }
.case-layout { display: grid; gap: 48px; padding-bottom: 96px; }
@media (min-width: 900px) { .case-layout { grid-template-columns: 1fr 280px; gap: 72px; } }
.case-main section { padding: 0 0 48px; }
.case-main h2 { font-size: 1.55rem; }
.case-main p, .case-main li { max-width: 68ch; }
.case-main ul { padding-left: 1.2em; }
.case-main figure { margin: 24px 0; }
.case-main figure img {
  border-radius: var(--radius);
  outline: 1px solid var(--image-outline); outline-offset: -1px;
}
.case-main figcaption { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.case-main code, .metrics code { font-size: .9em; background: var(--accent-soft); padding: 1px 5px; border-radius: 3px; }
.case-main video { width: 100%; max-width: 420px; border: 1px solid var(--line); border-radius: var(--radius); }
.metrics { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: .95rem; }
.metrics th, .metrics td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.metrics th { font-weight: 500; color: var(--muted); }
.aside {
  align-self: start; position: sticky; top: 88px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
}
.aside dl { margin: 0; }
.aside dt { font: 600 .75rem var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-top: 16px; }
.aside dt:first-child { margin-top: 0; }
.aside dd { margin: 4px 0 0; }
.aside .actions { margin-top: 24px; flex-direction: column; }
.aside .btn { justify-content: center; }
@media (max-width: 899px) { .aside { position: static; } }

.rastria-logo { display: flex; align-items: center; gap: 8px; margin-bottom: auto; padding-bottom: 32px; }
.rastria-logo span { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; color: var(--panel-ink); }

/* ---------- Ajustes mobile ---------- */
@media (max-width: 759px) {
  /* Em rem para acompanhar o zoom de texto: o header também cresce com ele. */
  html { scroll-padding-top: 7.25rem; }
  .site-header .container { flex-wrap: wrap; height: auto; padding-top: 12px; column-gap: 16px; row-gap: 0; }
  .nav {
    display: flex; order: 3; width: 100%; margin: 0;
    gap: 4px; border-top: 1px solid var(--line); margin-top: 12px;
  }
  .nav a { flex: 1; text-align: center; padding: 12px 0; min-height: 44px; }
}
/* Sem `order` aqui: no celular a ficha técnica vinha desenhada antes do conteúdo,
   mas depois dele no HTML, então teclado e leitor de tela liam na ordem inversa. */
@media (max-width: 899px) {
  .case-layout { gap: 40px; }
}
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; }
.site-footer .container { align-items: center; }

/* ---------- Case: números, código e rodapé de navegação ---------- */
.case-stats {
  display: grid; gap: 1px; margin-top: 32px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; max-width: 760px;
}
.case-stats div { background: var(--surface); padding: 16px 18px; }
.case-stats dt { font: 500 .8rem/1.3 var(--sans); color: var(--muted); margin: 0 0 6px; }
.case-stats dd { margin: 0; font-family: var(--serif); font-size: 1.5rem; line-height: 1.1; font-weight: 600; }
.case-stats dd small { display: block; font: 400 .8rem var(--sans); color: var(--muted); margin-top: 4px; }

.case-main pre {
  margin: 24px 0; padding: 18px 20px; overflow-x: auto; overscroll-behavior-x: contain;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: .85rem; line-height: 1.6; tab-size: 2;
}
.case-main pre code { background: none; padding: 0; font-size: inherit; }
.case-main pre + figcaption,
.code-note { font-size: .85rem; color: var(--muted); margin-top: -12px; }

.case-foot { border-top: 1px solid var(--line); padding: 40px 0 88px; }
.case-foot .container { display: grid; gap: 32px; }
@media (min-width: 720px) { .case-foot .container { grid-template-columns: 1fr 1fr; gap: 48px; } }
.case-foot h2 { font-size: 1.25rem; margin-bottom: 8px; }
.case-foot p { color: var(--muted); font-size: .95rem; margin: 0 0 16px; max-width: 46ch; }
.case-foot .next-label { font: 600 .75rem var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 10px; }

/* ---------- Linha do tempo ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative; padding: 0 0 28px 24px;
  border-left: 1px solid var(--line);
}
.timeline li:last-child { padding-bottom: 0; border-left-color: transparent; }
.timeline li::before {
  content: ""; position: absolute; left: -5px; top: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--marker-border);
}
.timeline li:last-child::before { box-shadow: -1px 0 0 0 var(--line); }
.timeline .is-current::before,
.timeline li.is-current::before { background: var(--text); border-color: var(--text); }
.timeline .tl-when {
  font: 600 .75rem var(--sans); text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin-bottom: 4px;
}
.timeline h4 { font: 600 1.0625rem/1.35 var(--sans); margin: 0; }
.timeline .tl-what p { color: var(--muted); font-size: .9rem; margin: 4px 0 0; max-width: 56ch; }
@media (min-width: 720px) {
  .timeline li { display: grid; grid-template-columns: 150px 1fr; gap: 24px; padding-bottom: 32px; }
  .timeline .tl-when { margin-bottom: 0; padding-top: 2px; }
}
