/* Fontes alojadas no site (subconjunto latin do Google Fonts): sem a folha de terceiros a bloquear a renderização */
@font-face {
  font-family: "Archivo"; src: url("assets/fonts/archivo-latin.woff2") format("woff2");
  font-weight: 400 800; font-stretch: 100% 125%; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono"; src: url("assets/fonts/jetbrains-mono-latin.woff2") format("woff2");
  font-weight: 400 500; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  /* Cores do logótipo: tinta preta, azul e branco */
  --bg: #ffffff;
  --bg-alt: #f5f7fa;
  --surface: #ffffff;
  --border: #e2e6ee;
  --border-strong: #cdd4e0;
  --text: #0a0c10;           /* preto do logótipo */
  --muted: #4b5567;          /* 7,5:1 sobre branco */
  --brand: #3c80ec;          /* azul do logótipo: formas e texto grande */
  --brand-deep: #2b6be0;     /* botões: contraste AA com texto branco */
  --brand-ink: #1f5bc8;      /* texto azul pequeno sobre fundo claro (6,2:1) */
  --brand-tint: #eef4fe;
  /* superfícies escuras (terminal e contacto) */
  --ink: #0a0c10;
  --ink-2: #14181f;
  --on-ink: #f3f5f9;
  --on-ink-muted: #a3adc0;
  --on-ink-border: rgba(255, 255, 255, 0.12);
  --slant: 32deg;            /* inclinação da barra azul do logótipo */
  --radius: 14px;
  --font-head: "Archivo", system-ui, sans-serif;
  --font-body: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);       /* entradas e resposta a toque */
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);  /* morph no ecrã */
  --gutter: clamp(16px, 4vw, 32px);
  --header-h: 72px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: var(--header-h); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--brand); color: #fff; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-head); font-stretch: 112.5%; line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
h1, h2 { text-wrap: balance; }
h1, h2, h3 { overflow-wrap: anywhere; } /* só parte uma palavra que não cabe sozinha na linha (letra grande, espaçamento WCAG) */
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--brand-deep); outline-offset: 3px; border-radius: 6px; }

.container { width: 100%; max-width: 75rem; margin-inline: auto; padding-inline: var(--gutter); } /* 1200px; em rem para crescer com a letra do browser (com 1200px fixos o menu saía da caixa a 24px) */

.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  background: var(--brand-deep); color: #fff; padding: 10px 16px; border-radius: 8px; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* barra inclinada do logótipo, usada como marca gráfica */
.slash { display: inline-block; flex: none; width: 6px; height: 14px; background: var(--brand); transform: skewX(var(--slant)); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 24px; border-radius: 999px;
  font: 600 0.95rem/1 var(--font-body); text-decoration: none;
  border: 1px solid transparent; transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.btn-primary { background: var(--brand-deep); color: #fff; box-shadow: 0 8px 20px -10px rgba(43, 107, 224, .7); }
.btn-ghost { border-color: var(--border-strong); color: var(--text); background: var(--surface); }
.btn:active { transform: scale(0.97); }
.btn-sm { padding: 10px 18px; font-size: .875rem; white-space: nowrap; } /* só no menu: a 1025px com barra de rolagem faltam 2px e partia em duas linhas */

/* ---------- Cabeçalho ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  background: rgba(255, 255, 255, .78);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color .3s, background-color .3s;
}
.site-header.scrolled { border-bottom-color: var(--border); background: rgba(255, 255, 255, .92); }
.header-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { flex: none; } /* sem isto o logótipo encolhia e deformava quando o menu não cabia */
.brand img { height: 34px; width: auto; }
.nav { display: flex; align-items: center; gap: 32px; margin-left: auto; } /* encosta o menu ao seletor de idioma */
.nav ul { display: flex; gap: 28px; }
/* padding vertical num link inline: área de toque de 40px sem mexer no desenho (tablets na horizontal usam este menu) */
.nav ul a { padding-block: 12px; text-decoration: none; color: var(--muted); font-size: .925rem; font-weight: 500; transition: color 150ms ease; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Seletor de idioma: <details> nativo; o main.js só o fecha ao clicar fora e com Escape */
.lang { position: relative; flex: none; }
.lang summary {
  display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 6px;
  list-style: none; cursor: pointer; border-radius: 8px;
  color: var(--muted); font: 600 .825rem/1 var(--font-body); letter-spacing: .02em;
}
.lang summary::-webkit-details-marker { display: none; }
.flag { width: 18px; height: 12px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(10, 12, 16, .12); }
.chev { width: 10px; height: 6px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.chev { transition: transform 200ms var(--ease-in-out); }
.lang[open] .chev { transform: rotate(180deg); }
.lang ul {
  position: absolute; right: 0; top: 100%; margin-top: 4px; min-width: 168px; padding: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 16px 32px -16px rgba(10, 12, 16, .25);
  transform-origin: top right; /* abre a partir do botão, que está no canto superior direito */
}
/* animação e não @starting-style: dentro do <details> o Firefox e o WebKit ignoram o @starting-style (testado com o Playwright) */
.lang[open] ul { animation: fade-in 200ms var(--ease-out); }
.lang ul a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 6px; text-decoration: none; font-size: .925rem; }
.lang ul a[aria-current] { color: var(--brand-ink); font-weight: 600; }

.nav-toggle { display: none; background: none; border: 0; padding: 11px; cursor: pointer; } /* 44×48 de área de toque */
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--text); margin: 5px 0; border-radius: 2px; transition: transform 250ms var(--ease-in-out), opacity 250ms var(--ease-in-out); }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Breakpoints em em: acompanham a letra que o utilizador escolhe no browser (com 150% o menu completo não cabia nem a 1440px).
   71em = 1136px: com o espaçamento de texto do WCAG 1.4.12 e a barra de rolagem do Windows o menu completo só cabe a partir de 1120px */
@media (max-width: 71em) {
  .header-inner { gap: 8px; } /* a 320px: logótipo 151 + idioma + botão 44 só cabem com 8px entre eles */
  .lang { margin-left: auto; }
  .nav-toggle { display: block; order: 1; } /* fica depois do idioma à vista, mas antes do menu no DOM, para o Tab entrar no menu aberto */
  .nav {
    position: fixed; inset: var(--header-h) 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 16px;
    padding: 16px var(--gutter) 24px;
    background: var(--bg); border-bottom: 1px solid var(--border);
    box-shadow: 0 24px 40px -24px rgba(10, 12, 16, .25);
    display: none;
    /* telemóvel deitado: o menu tem ~430px e é fixo; sem isto o fim fica fora do ecrã e inalcançável */
    max-height: calc(100dvh - var(--header-h)); overflow-y: auto;
  }
  .nav.open { display: flex; transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out); }
  @starting-style { .nav.open { opacity: 0; } }
  .nav ul { flex-direction: column; gap: 0; }
  .nav ul a { display: block; padding: 14px 0; font-size: 1.05rem; color: var(--text); border-bottom: 1px solid var(--border); }
  .nav .btn { justify-content: center; padding-block: 14px; } /* 44px de altura ao toque */
}

/* ---------- Hero ---------- */
.hero { position: relative; padding: clamp(56px, 10vw, 112px) 0 64px; overflow: hidden; isolation: isolate; }

.hero-inner { display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(40px, 6vw, 80px); align-items: center; }
.eyebrow {
  display: inline-flex; align-items: flex-start; gap: 10px;
  color: var(--muted); font: 500 .8rem/1.4 var(--font-mono); letter-spacing: .02em;
}
.eyebrow .slash { margin: 2px 0 0 5px; } /* o skew desloca o topo 4px para a esquerda */
/* min(…, 11vw): abaixo de ~350px o título encolhe; a 38px a linha mais larga (296px) entrava na margem a 320px */
.hero h1 { font-size: clamp(min(2.4rem, 11vw), 5.2vw, 3.4rem); margin: 22px 0 20px; font-weight: 700; }
.nowrap { white-space: nowrap; }
/* até 400px as linhas do título são iguais sem nowrap; com espaçamento WCAG ou letra maior, o nowrap alargava o hero e cortava 26px */
@media (max-width: 25em) { .nowrap { white-space: normal; } }
.accent { color: var(--brand-deep); }
.lead { color: var(--muted); font-size: clamp(1.05rem, 1.6vw, 1.2rem); max-width: 42ch; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 36px; }

/* Terminal preto com a barra azul a passar por trás: o "A\" do logótipo */
/* min-width: 0: sem isto a linha mais longa do terminal alarga a coluna e corta o hero a 320px */
.hero-visual { position: relative; isolation: isolate; min-width: 0; }
.hero-visual::before {
  content: ""; position: absolute; z-index: -1;
  top: -44px; bottom: -44px; right: 16%; width: clamp(40px, 5vw, 64px);
  background: var(--brand); transform: skewX(var(--slant));
}
.terminal {
  border-radius: var(--radius); overflow: hidden;
  background: var(--ink); color: var(--on-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 28px 60px -28px rgba(10, 12, 16, .55);
}
.terminal-bar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--on-ink-border); }
.terminal-bar i { width: 11px; height: 11px; border-radius: 50%; background: #2a303c; }
.terminal-bar span { margin-left: 8px; color: var(--on-ink-muted); font: 500 .75rem var(--font-mono); }
.terminal pre { margin: 0; padding: clamp(14px, 4vw, 22px); overflow-x: auto; font: 400 clamp(.75rem, 1.1vw, .85rem)/1.9 var(--font-mono); color: var(--on-ink); } /* mínimo 12px, como o resto do código */
.t-prompt { color: var(--brand); }
.t-ok { color: var(--brand); }
.t-live { color: #fff; }
.t-dim { color: var(--on-ink-muted); }
.t-accent { color: #fff; font-weight: 500; }
.caret { display: inline-block; width: 8px; height: 1em; margin-left: 4px; vertical-align: -2px; background: var(--brand); }
/* entrada do terminal, uma vez por visita: só opacidade aqui, o movimento entra com prefers-reduced-motion: no-preference.
   O texto do hero não anima: o Chrome só conta o LCP no fim do fade (medido: 284 → 832 ms no desktop, 256 → 864 ms no telemóvel) */
.terminal { animation: fade-in 450ms var(--ease-out) backwards; }
.terminal .t-line { animation: fade-in .4s var(--ease-out) both; }
/* nth-of-type conta também o span do prompt: as linhas são 2..7 */
.terminal .t-line:nth-of-type(2) { animation-delay: .5s; }
.terminal .t-line:nth-of-type(3) { animation-delay: .8s; }
.terminal .t-line:nth-of-type(4) { animation-delay: 1.1s; }
.terminal .t-line:nth-of-type(5) { animation-delay: 1.4s; }
.terminal .t-line:nth-of-type(6) { animation-delay: 1.7s; }
.terminal .t-line:nth-of-type(7) { animation-delay: 2.1s; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
/* a barra inclinada desenha-se de baixo para cima; clip-path precisa do "to" explícito (inset → none não interpola) */
@keyframes draw { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.95); } }

.stats {
  margin-top: clamp(64px, 8vw, 104px);
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-block: 1px solid var(--border);
}
.stats li { padding: 28px 24px 26px; display: flex; flex-direction: column; gap: 8px; }
.stats li:first-child { padding-left: 0; }
.stats li + li { border-left: 1px solid var(--border); }
.stats strong { font: 700 clamp(1.7rem, 3vw, 2.4rem)/1 var(--font-head); font-stretch: 112.5%; letter-spacing: -0.02em; color: var(--text); }
.stats span { color: var(--muted); font-size: .9rem; line-height: 1.45; }

@media (max-width: 56.25em) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-visual { margin-top: 12px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats li:nth-child(3) { border-left: 0; }
  /* 16px de cada lado do divisor: "IGRP 3.0" (124px) cabe numa linha até 320px */
  .stats li:nth-child(odd) { padding-inline: 0 16px; }
  .stats li:nth-child(even) { padding-inline: 16px 0; }
  .stats li:nth-child(n+3) { border-top: 1px solid var(--border); }
}
/* uma coluna só com letra grande: 19,5em = 312px com letra normal (nunca acontece), 624px a 200% */
@media (max-width: 19.5em) {
  .stats { grid-template-columns: 1fr; }
  .stats li:nth-child(n) { padding-inline: 0; border-left: 0; }
  .stats li + li { border-top: 1px solid var(--border); }
}

/* ---------- Secções ---------- */
.section { padding: clamp(72px, 10vw, 128px) 0; position: relative; }
.section-alt { background: var(--bg-alt); border-block: 1px solid var(--border); }
.section-head { max-width: 47.5rem; margin-bottom: clamp(36px, 5vw, 56px); }
.section-head::before, .contact-panel h2::before {
  content: ""; display: block; width: 8px; height: 26px; margin: 0 0 22px 6px;
  background: var(--brand); transform: skewX(var(--slant));
}
.section-head :is(h1, h2) { font-size: clamp(1.8rem, 4vw, 2.75rem); font-weight: 700; }
.section-head p { max-width: 65ch; color: var(--muted); font-size: 1.075rem; margin-top: 16px; }

.cards { display: grid; gap: 20px; }
.cards-4 { grid-template-columns: repeat(4, 1fr); }
.cards-2 { grid-template-columns: repeat(2, 1fr); }
/* 2 colunas até ao mesmo ponto do hambúrguer: a 1040px, em 4 colunas, o texto dos serviços ficava com ~165px de largura */
@media (max-width: 71em) { .cards-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 40em) { .cards-4, .cards-2 { grid-template-columns: 1fr; } }

.card {
  position: relative; padding: 28px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: 0 1px 2px rgba(10, 12, 16, .04);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
/* conteúdo sem caixa: só um separador no topo (caixas ficam para os serviços) */
.cards:has(> .item) { gap: 32px 40px; }
.item { padding-top: 20px; border-top: 1px solid var(--border-strong); }
.card h3, .item h3 { font-size: 1.15rem; font-weight: 600; margin-bottom: 10px; }
.card p, .item p { color: var(--muted); font-size: .95rem; }
.icon {
  width: 44px; height: 44px; padding: 10px; margin-bottom: 22px; border-radius: 12px;
  fill: none; stroke: var(--brand-ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  background: var(--brand-tint);
}
.feature .num { display: block; font: 500 .85rem var(--font-mono); color: var(--brand-ink); margin-bottom: 16px; }
.feature h3 { font-size: 1.35rem; }

/* ---------- Demonstração: percurso de um pedido (bloco preto, secção mais baixa que as outras) ---------- */
/* 6 passos numa linha; abaixo de 56.25em, numa coluna. Entre dois ícones há um troço apagado (::before)
   e o azul por cima (::after), que é o que a animação desenha */
.section-compact { padding-block: clamp(56px, 7vw, 88px); }
.flow { padding: clamp(20px, 4vw, 36px); border-radius: 24px; background: var(--ink); color: var(--on-ink); }
.flow-steps { display: grid; grid-template-columns: repeat(6, 1fr); text-align: center; }
.flow-steps li { --d: 0s; position: relative; padding-inline: 6px; } /* --d: momento em que o pedido chega a este passo */
.flow-steps li:not(:last-child)::before, .flow-steps li:not(:last-child)::after {
  content: ""; position: absolute; top: 23px; left: calc(50% + 26px); width: calc(100% - 52px); height: 2px;
  background: var(--on-ink-border);
}
.flow-steps li:not(:last-child)::after { background: var(--brand); }
/* ícone solto sobre a linha, sem caixa: o impeccable assinala a caixa arredondada por cima de um título (icon-tile-stack) */
.flow-icon { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 10px; color: var(--brand); }
.flow-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.flow-steps h3 { font-size: .95rem; font-weight: 600; font-stretch: 100%; letter-spacing: 0; text-wrap: balance; } /* sem a letra expandida dos títulos: "Microsserviços" não cabia na coluna perto dos 900px */
.flow-tag { display: block; margin-top: 4px; text-wrap: balance; color: var(--on-ink-muted); font: 500 .75rem/1.5 var(--font-mono); }
.flow-steps li:nth-child(2) { --d: .6s; }
.flow-steps li:nth-child(3) { --d: 1.2s; }
.flow-steps li:nth-child(4) { --d: 1.8s; }
.flow-steps li:nth-child(5) { --d: 2.4s; }
.flow-steps li:nth-child(6) { --d: 3s; }
@media (max-width: 56.25em) {
  .flow-steps { grid-template-columns: 1fr; row-gap: 32px; text-align: left; }
  .flow-steps li { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; padding: 0; }
  .flow-icon { grid-row: span 2; width: 44px; height: 44px; margin: 0; }
  .flow-steps h3 { align-self: end; }
  .flow-tag { align-self: start; margin-top: 2px; }
  .flow-steps li:not(:last-child)::before, .flow-steps li:not(:last-child)::after { top: 44px; bottom: -32px; left: 21px; width: 2px; height: auto; }
}
/* ciclo enquanto o painel está no ecrã (main.js): .playing acende os ícones à vez e desenha a linha; ~2 s depois,
   .armed apaga-os em 400 ms e o ciclo recomeça a partir desse estado. Com movimento reduzido não anima e o diagrama
   fica completo. O texto nunca apaga (a 30% dava contraste 1,8:1 e o Lighthouse descontava-o) */
@media (prefers-reduced-motion: no-preference) {
  .flow.armed .flow-steps .flow-icon, .flow.armed .flow-steps li::after { transition: opacity 400ms var(--ease-out); }
  .flow.armed .flow-steps .flow-icon { opacity: .3; }
  .flow.armed .flow-steps li::after { opacity: 0; }
  .flow.playing .flow-steps .flow-icon { animation: tile-on 300ms var(--ease-out) var(--d) backwards; }
  /* ease-in-out: o pedido arranca e trava em cada passo */
  .flow.playing .flow-steps li::after { animation: draw-x 600ms var(--ease-in-out) var(--d) backwards; }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 56.25em) {
  .flow.playing .flow-steps li::after { animation-name: draw-y; }
}
@keyframes draw-x { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
@keyframes draw-y { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0); } }
@keyframes tile-on { from { opacity: .3; transform: scale(.9); } }

/* ---------- Tecnologias: stack de blocos ---------- */
/* uma camada por linha, de cima (automação) para baixo (infraestrutura), assente na barra inclinada do logótipo.
   Os blocos crescem até encher a linha, como tijolos */
.stack { position: relative; display: grid; gap: 8px; max-width: 46rem; margin: clamp(48px, 7vw, 80px) auto 0; padding-bottom: 14px; }
.stack::after { content: ""; position: absolute; inset: auto 0 0; height: 6px; background: var(--brand); transform: skewX(var(--slant)); }
.tech-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tech-list li {
  --i: 0; flex: 1 1 auto; padding: 9px 16px; border: 1px solid var(--border); border-radius: 6px; text-align: center;
  overflow-wrap: anywhere; /* sem nowrap: só parte se o bloco não couber sozinho na linha (a 320px com letra a 200%) */
  font: 500 .85rem var(--font-mono); color: var(--muted); background: var(--surface);
}
/* as peças caem e encaixam uma vez, de baixo para cima, quando a camada de baixo aparece inteira (main.js): primeiro
   desenha-se a base, depois cada camada, com 40 ms entre peças, da última para a primeira (numa camada partida em duas
   linhas, a de baixo assenta primeiro). Queda com mola (duração 0,5 s, bounce 0,3; o linear() vem da equação da mola):
   assenta aos 262 ms e desce 4,6% da queda abaixo do lugar, menos que os 8px entre camadas. O contorno vem azul e
   apaga depois de assentar. Até lá as peças esperam invisíveis; sem JS, com movimento reduzido ou a imprimir, completa */
.stack > li:nth-last-child(1) { --r: .15s; }
.stack > li:nth-last-child(2) { --r: .45s; }
.stack > li:nth-last-child(3) { --r: .7s; }
.stack > li:nth-last-child(4) { --r: 1.1s; }
.stack > li:nth-last-child(5) { --r: 1.4s; }
.tech-list li:nth-last-child(2) { --i: 1; }
.tech-list li:nth-last-child(3) { --i: 2; }
.tech-list li:nth-last-child(4) { --i: 3; }
.tech-list li:nth-last-child(5) { --i: 4; }
.tech-list li:nth-last-child(6) { --i: 5; }
@media screen and (prefers-reduced-motion: no-preference) {
  .stack.armed::after { clip-path: inset(0 100% 0 0); }
  .stack.armed .tech-list li { opacity: 0; }
  .stack.playing::after { animation: draw-x 500ms var(--ease-out) backwards; }
  .stack.playing .tech-list li {
    --t: calc(var(--r) + var(--i) * 40ms);
    animation: drop 600ms var(--ease-out) var(--t) backwards, fade-in 100ms var(--ease-out) var(--t) backwards, settle 700ms ease var(--t) backwards;
    /* em separado: um browser sem linear() ignora só esta linha e fica com o --ease-out */
    animation-timing-function: linear(0, 0.043, 0.146, 0.28, 0.423, 0.561, 0.685, 0.79, 0.874, 0.938, 0.984, 1.015, 1.034, 1.043, 1.046, 1.044, 1.039, 1.033, 1.027, 1.02, 1.014, 1.01, 1.006, 1.003, 1), var(--ease-out), ease;
  }
}
@keyframes drop { from { transform: translateY(-300%); } }
@keyframes settle { 0%, 40% { border-color: var(--brand); } }

/* ---------- Timeline ---------- */
.timeline { position: relative; display: grid; gap: 16px; }
/* coluna do ano em rem (90px): com 90px fixos e letra a 200% o ano passava por cima da linha */
.timeline::before { content: ""; position: absolute; left: 5.625rem; top: 8px; bottom: 8px; width: 1px; background: var(--border-strong); }
.timeline li { display: grid; grid-template-columns: 5.625rem 1fr; gap: 40px; position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: calc(5.625rem - 3px); top: 27px; width: 7px; height: 16px;
  background: var(--brand); transform: skewX(var(--slant)); box-shadow: 0 0 0 4px var(--bg);
}
.year { font: 700 1.35rem var(--font-head); font-stretch: 112.5%; color: var(--text); padding-top: 20px; }
.tl-body {
  padding: 22px 26px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  box-shadow: 0 1px 2px rgba(10, 12, 16, .04); transition: border-color 150ms ease, box-shadow 150ms ease;
  overflow-wrap: anywhere; /* a 320px com letra a 200% uma palavra longa alargava a coluna */
}
.tl-body h3 { font-size: 1.15rem; font-weight: 600; }
/* inline-block já desce inteiro para a linha seguinte; sem nowrap, só parte se o código não couber numa linha sozinho */
.tl-body small { display: inline-block; font: 500 .75rem var(--font-mono); color: var(--muted); letter-spacing: 0; vertical-align: 2px; }
.tl-body .org { color: var(--brand-ink); font-size: .9rem; font-weight: 500; margin: 6px 0 10px; }
.tl-body p { max-width: 75ch; } /* a 1440px o texto chegava a ~130 caracteres por linha */
.tl-body p:last-child { color: var(--muted); font-size: .95rem; }
@media (max-width: 40em) {
  .timeline::before { left: 4px; }
  .timeline li { grid-template-columns: 1fr; gap: 8px; padding-left: 28px; }
  .timeline li::before { left: 1px; top: 4px; }
  .year { padding-top: 0; font-size: 1.1rem; }
  .tl-body { padding: 20px; }
}

/* ---------- Parceiros ---------- */
.partners { display: flex; flex-wrap: wrap; gap: 10px; }
.partners li {
  padding: 12px 20px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  font-family: var(--font-head); font-weight: 500; font-size: .95rem; color: var(--text);
}

/* ---------- Contacto (bloco preto, como o "TA" do logótipo) ---------- */
.contact-panel {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: clamp(32px, 5vw, 64px); align-items: center;
  padding: clamp(24px, 6vw, 64px); border-radius: 24px; /* 24px no telemóvel: com 32px o título partia em 4 linhas a 390px */
  background: var(--ink); color: var(--on-ink);
}
.contact-panel h2 { font-size: clamp(min(1.8rem, 8vw), 4vw, 2.6rem); font-weight: 700; } /* abaixo de 360px encolhe: a 320px partia em 5 linhas */
.contact-panel h2 + p { color: var(--on-ink-muted); margin: 16px 0 28px; font-size: 1.075rem; }
.contact-list { display: grid; gap: 12px; }
.contact-list li { display: flex; flex-direction: column; gap: 2px; padding: 18px 20px; border: 1px solid var(--on-ink-border); border-radius: 14px; background: var(--ink-2); }
.contact-list .label { font: 500 .75rem var(--font-mono); text-transform: uppercase; letter-spacing: .12em; color: var(--on-ink-muted); margin-bottom: 4px; }
.contact-list a { text-decoration: none; font-weight: 500; transition: color 150ms ease; overflow-wrap: anywhere; } /* o email não cabia a 320px com letra a 200% */
.contact-list a + a { margin-top: 10px; } /* os dois telefones estavam a 2px: toque no número errado */
@media (max-width: 56.25em) { .contact-panel { grid-template-columns: 1fr; } }

/* ---------- Rodapé ---------- */
.site-footer { padding: 40px 0; color: var(--muted); font-size: .9rem; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px; }
.footer-logo { height: 28px; width: auto; margin-bottom: 10px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 24px; }
.site-footer nav a { padding-block: 10px; margin-block: -10px; text-decoration: none; transition: color 150ms ease; } /* área de toque de 44px, mesmo desenho */
.copy { width: 100%; padding-top: 24px; border-top: 1px solid var(--border); }

/* ---------- Hover (só com rato: no toque o hover fica preso) ---------- */
@media (hover: hover) and (pointer: fine) {
  .nav ul a:hover, .site-footer nav a:hover, .lang summary:hover { color: var(--text); }
  .lang ul a:hover { background: var(--bg-alt); }
  .btn-primary:hover { background: var(--brand-ink); }
  .btn-ghost:hover { border-color: var(--text); }
  .card:hover, .tl-body:hover { border-color: rgba(60, 128, 236, .55); box-shadow: 0 10px 28px -16px rgba(10, 12, 16, .22); }
  .contact-list a:hover { color: var(--brand); }
}

@media (prefers-reduced-motion: no-preference) {
  @media (max-width: 71em) { @starting-style { .nav.open { transform: translateY(-8px); } } }
  .lang[open] ul { animation-name: pop; }
  .terminal { animation-name: rise; }
  /* só depois de o terminal acabar de entrar (450 ms): enquanto está semitransparente a barra via-se através dele */
  .hero-visual::before { animation: draw 600ms var(--ease-out) 450ms backwards; }
  /* pisca 3 vezes depois da última linha do terminal (2,1 s + 0,4 s) e fica fixo: nada de animação infinita */
  .caret { animation: blink 1s steps(1) 2.5s 3; }
  /* ao saltar pelo menu, a barra do título desenha-se e mostra onde se chegou */
  .section:target :is(.section-head, .contact-panel h2)::before { animation: draw 300ms var(--ease-out); }
  /* ao chegar a cada secção a barra dá uma volta e encaixa (main.js põe .girou, uma vez por visita). Parte de -1turn,
     que à vista é igual a 0: sem JS, a imprimir ou se o observador não disparar, fica como sempre esteve. rotate e não
     transform, para não perder o skewX. Mola da stack (bounce 0,3): volta inteira em ~370 ms, passa ~17° e assenta.
     O segundo transition não tem var(): num browser sem linear() cai no parse e fica o primeiro */
  :is(.section-head, .contact-panel h2)::before { rotate: -1turn; }
  :is(.section-head, .contact-panel h2).girou::before {
    rotate: 0turn;
    transition: rotate 840ms var(--ease-out);
    transition: rotate 840ms linear(0, 0.043, 0.146, 0.28, 0.423, 0.561, 0.685, 0.79, 0.874, 0.938, 0.984, 1.015, 1.034, 1.043, 1.046, 1.044, 1.039, 1.033, 1.027, 1.02, 1.014, 1.01, 1.006, 1.003, 1);
  }
}
@media (prefers-reduced-motion: reduce) {
  .nav-toggle span, .chev { transition: none; }
}
