:root {
  --paper: #EDF0F3;
  --surface: #F8FAFB;
  --ink: #17283A;
  --muted: #556677;
  --rule: #C7D0D9;
  --pass: #1F7148;
  --term-bg: #17283A;
  --term-ink: #D5DEE7;
  --term-dim: #8498AC;
  --term-pass: #6FD3A0;

  --sans: "Archivo", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --gutter: clamp(16px, 4vw, 48px);
  --max: 1120px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --topbar-h: 0px;
  --topbar-bg: rgba(237, 240, 243, 0.86);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F1924;
    --surface: #15222F;
    --ink: #E2E8EE;
    --muted: #97A7B7;
    --rule: #283848;
    --pass: #6FD3A0;
    --term-bg: #08111A;
    --topbar-bg: rgba(15, 25, 36, 0.86);
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .logo.escurece-claro { filter: none; }
  :root:not([data-theme="light"]) .logo.inverte-escuro { filter: invert(1); }
  :root:not([data-theme="light"]) .logo.clareia-escuro { filter: brightness(1.9); }
}
:root[data-theme="dark"] {
  --paper: #0F1924;
  --surface: #15222F;
  --ink: #E2E8EE;
  --muted: #97A7B7;
  --rule: #283848;
  --pass: #6FD3A0;
  --term-bg: #08111A;
  --topbar-bg: rgba(15, 25, 36, 0.86);
  color-scheme: dark;
}
:root[data-theme="dark"] .logo.escurece-claro { filter: none; }
:root[data-theme="dark"] .logo.inverte-escuro { filter: invert(1); }
:root[data-theme="dark"] .logo.clareia-escuro { filter: brightness(1.9); }

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--pass); color: var(--paper); }

a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--pass); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.15; text-wrap: balance; }
p, li, dd { text-wrap: pretty; }
p { margin: 0; }
ul, ol, dl, dd { margin: 0; padding: 0; }

.skip {
  position: absolute; left: var(--gutter); top: -100px;
  background: var(--ink); color: var(--paper); padding: 0.5rem 1rem; z-index: 30;
  border-radius: 6px;
}
.skip:focus { top: 0.5rem; }

/* Constelação interativa no fundo, fixa na tela; as estrelas ficam mais ralas até o rodapé */
.constelacao {
  position: fixed; inset: 0; z-index: 0;
  display: block;
  width: 100%; height: 100%;
  pointer-events: none;
}
@media print { .constelacao { display: none; } }

/* Top bar: fixa no topo a partir do tablet, com fundo translúcido */
.topbar {
  position: relative;
  padding: 1.25rem max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
  z-index: 20;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
@media (min-width: 641px) {
  :root { --topbar-h: 4.25rem; }
  /* Transparente no topo da página, para a constelação passar por trás */
  .topbar { position: sticky; top: 0; }
  .topbar.is-scrolled {
    background: var(--topbar-bg);
    border-bottom-color: var(--rule);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    backdrop-filter: saturate(1.4) blur(12px);
  }
}
.mark {
  display: inline-grid; place-items: center;
  width: 2.25rem; height: 2.25rem;
  border-radius: 8px;
  background: var(--ink); color: var(--paper);
  font-weight: 800; font-stretch: 125%; text-decoration: none;
  font-size: 0.95rem; letter-spacing: -0.02em;
  transition: transform 0.16s var(--ease-out);
}
.mark:active { transform: scale(0.94); }
.topbar nav { display: flex; gap: clamp(0.75rem, 2.5vw, 1.75rem); flex-wrap: wrap; font-size: 0.95rem; }
.topbar nav a {
  position: relative;
  text-decoration: none; color: var(--muted);
  padding: 0.25rem 0;
  transition: color 0.15s ease;
}
.topbar nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  border-radius: 1px;
  background: var(--pass);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.25s var(--ease-out);
}
.topbar nav a.is-active { color: var(--ink); }
.topbar nav a.is-active::after { transform: scaleX(1); }
@media (hover: hover) and (pointer: fine) {
  .topbar nav a:hover { color: var(--ink); }
}

main, .contact { position: relative; z-index: 1; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
section[id], footer[id] { scroll-margin-top: var(--topbar-h); }

/* Hero */
.hero { padding: clamp(2.5rem, 7vw, 5rem) 0 clamp(3rem, 8vw, 5.5rem); }

.name {
  font-size: clamp(2.4rem, 8.2vw, 6.25rem);
  font-weight: 800;
  font-stretch: 125%;
  line-height: 0.95;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
  text-wrap: initial;
}

.hero-grid {
  margin-top: clamp(2rem, 5vw, 3.5rem);
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.intro { max-width: 38rem; }
.intro .role {
  font-size: 1.3rem; font-weight: 600; font-stretch: 110%;
  line-height: 1.3; margin-bottom: 1rem;
}
.intro p + p { color: var(--muted); }

.links { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.75rem; }
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--rule);
  font-size: 0.9rem; font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: transform 0.16s var(--ease-out), background-color 0.15s ease, border-color 0.15s ease;
}
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn .arrow { font-weight: 500; transition: transform 0.2s var(--ease-out); }
.btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { border-color: var(--ink); }
  .btn:not(.btn-primary):hover { background: var(--surface); }
  .btn:hover .arrow { transform: translate(2px, -2px); }
}

/* Terminal: o elemento de destaque */
.term {
  margin: 0;
  background: var(--term-bg);
  color: var(--term-ink);
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 2px 4px -2px rgba(10, 25, 40, 0.25),
    0 28px 56px -30px rgba(10, 25, 40, 0.6);
}
.term-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.025);
}
.term-bar span { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.16); }
.term-title {
  flex: 1; text-align: center; margin-right: 42px;
  font: 400 0.75rem/1 var(--mono); color: var(--term-dim);
}
.term pre {
  margin: 0;
  padding: 1.1rem 1.25rem 1.3rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: clamp(0.72rem, 1.35vw, 0.84rem);
  line-height: 1.75;
}
.term .ln { color: var(--term-dim); }
.term .ln i { font-style: normal; }
.term .ln b { font-weight: 500; color: var(--term-ink); }
.term .ln em { font-style: normal; font-weight: 500; color: var(--term-pass); }
.term .prompt { color: var(--term-ink); }
.term .summary { color: var(--term-pass); font-weight: 500; }
.term .cursor {
  display: inline-block; width: 0.55em; height: 1.1em;
  vertical-align: -0.2em;
  background: var(--term-ink); opacity: 0.8;
}

@media (prefers-reduced-motion: no-preference) {
  .term .ln {
    opacity: 0;
    animation: line-in 0.01s linear forwards;
    animation-delay: calc(0.35s + var(--i) * 0.16s);
  }
  .term .ln em {
    opacity: 0;
    animation: line-in 0.2s ease-out forwards;
    animation-delay: calc(0.45s + var(--i) * 0.16s);
  }
  .term .summary { animation-delay: calc(0.6s + var(--i) * 0.16s); }
  .term .cursor { animation: blink 1.1s steps(1) 2.4s infinite; }
}
@keyframes line-in { to { opacity: 1; } }
@keyframes blink { 50% { opacity: 0; } }

/* Ferramentas: faixa de logos abaixo do topo. Parada sem JS ou com "reduzir movimento" */
.tools {
  margin: clamp(3rem, 7vw, 4.5rem) 0 0;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
  display: grid;
  gap: 1.75rem;
}
.tools-row { display: grid; gap: 0.85rem; }
.tools dt {
  color: var(--muted);
  font: 500 0.78rem/1.4 var(--mono);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.tools ul {
  list-style: none;
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 1.25rem 2.75rem;
}
.tools li {
  display: inline-flex; align-items: center; gap: 0.75rem;
  font-size: clamp(1.05rem, 1.6vw, 1.3rem); font-weight: 500;
  color: var(--muted); white-space: nowrap;
}
.logo { width: 2.25rem; height: 2.25rem; object-fit: contain; flex: none; }
.logo.mono {
  display: inline-grid; place-items: center;
  border-radius: 7px;
  background: var(--ink); color: var(--paper);
  font: 800 0.8rem/1 var(--sans); font-stretch: 110%; letter-spacing: -0.02em;
}
/* Logos que somem no fundo: o C é claro; o Bash, o GitHub e o MySQL são escuros */
.logo.escurece-claro { filter: brightness(0.7); }

.marquee.is-moving {
  display: flex;
  overflow: hidden;
  -webkit-mask: linear-gradient(90deg, transparent, #000 3rem, #000 calc(100% - 3rem), transparent);
  mask: linear-gradient(90deg, transparent, #000 3rem, #000 calc(100% - 3rem), transparent);
}
.marquee.is-moving .track {
  flex: none;
  flex-wrap: nowrap;
  padding-right: 2.75rem;
  animation: marquee var(--dur, 40s) linear infinite;
}
.tools-row + .tools-row .marquee.is-moving .track { animation-direction: reverse; }
.marquee.is-moving:hover .track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) {
  .marquee.is-moving .track { animation: none; }
}

/* Seções, numeradas como num relatório */
main { counter-reset: secao; }
.block { padding: clamp(3rem, 7vw, 5rem) 0; border-top: 1px solid var(--rule); }
.block > h2, .contact > h2 {
  font-size: clamp(1.6rem, 3.4vw, 2.25rem);
  font-weight: 800; font-stretch: 125%;
  letter-spacing: -0.02em;
  margin-bottom: clamp(1.75rem, 4vw, 2.75rem);
}
.block > h2::before, .contact > h2::before {
  counter-increment: secao;
  content: counter(secao, decimal-leading-zero);
  display: block;
  margin-bottom: 0.7rem;
  font: 500 0.8rem/1 var(--mono);
  letter-spacing: 0.08em;
  color: var(--pass);
}
.contact > h2::before { content: "04"; }

/* Experiência: linha do tempo com trilho e marcadores */
.timeline { list-style: none; }
.job {
  --rail: calc(12rem + 1.25rem);
  position: relative;
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  gap: 1rem 2.5rem;
  padding: 0 0 2.5rem;
}
.job:last-child { padding-bottom: 0; }
.job::before {
  content: ""; position: absolute;
  left: var(--rail); top: 0.6rem; bottom: -0.6rem; width: 1px;
  background: var(--rule);
}
.job:last-child::before { bottom: auto; height: 0.6rem; }
.job > div { position: relative; }
.job > div::before {
  content: ""; position: absolute;
  left: calc(var(--rail) - 12rem - 2.5rem + 0.5px); top: 0.42rem;
  width: 11px; height: 11px; border-radius: 50%;
  transform: translateX(-50%);
  background: var(--paper);
  border: 2px solid var(--rule);
}
.job:has(.live) > div::before { border-color: var(--pass); background: var(--pass); box-shadow: 0 0 0 4px color-mix(in srgb, var(--pass) 18%, transparent); }
.when { color: var(--muted); font-size: 0.95rem; line-height: 1.5; padding-top: 0.15rem; }
.live {
  display: flex; align-items: center; gap: 0.45rem;
  margin-top: 0.35rem; color: var(--pass); font-size: 0.85rem; font-weight: 600;
}
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
@media (prefers-reduced-motion: no-preference) {
  .live::before { animation: pulse 2.4s ease-out infinite; }
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); }
  70%, 100% { box-shadow: 0 0 0 6px transparent; }
}
.job h3 { font-size: 1.3rem; font-stretch: 110%; }
.org { color: var(--muted); margin: 0.2rem 0 0.9rem; }
.lead { max-width: 46rem; margin-bottom: 0.75rem; }
.job ul { padding-left: 1.1rem; max-width: 46rem; }
.job li + li { margin-top: 0.35rem; }
.job li::marker { color: var(--muted); }

/* Competências */
.skills {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}
.skills div {
  padding: 1.1rem 1.15rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--ink);
  border-radius: 4px 4px 10px 10px;
  transition: border-color 0.2s ease, transform 0.2s var(--ease-out);
}
.skills dt { font-weight: 700; font-stretch: 110%; margin-bottom: 0.4rem; }
.skills dd { color: var(--muted); font-size: 0.97rem; }
@media (hover: hover) and (pointer: fine) {
  .skills div:hover { border-top-color: var(--pass); transform: translateY(-2px); }
}

/* Formação */
.edu {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 2rem 3rem;
}
.edu h3 { font-size: 1.3rem; font-stretch: 110%; margin-bottom: 0.4rem; }
.muted { color: var(--muted); }
.langs h3 { font-size: 1.05rem; }
.langs p { color: var(--muted); }

.progress {
  margin-top: 1rem;
  max-width: 26rem;
  height: 8px;
  border-radius: 4px;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), var(--paper) calc(10% - 2px) 10%),
    var(--rule);
  position: relative;
  overflow: hidden;
}
.progress span {
  position: absolute; inset: 0 auto 0 0;
  width: calc(var(--n) * 10%);
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(100% / var(--n) - 2px), var(--paper) calc(100% / var(--n) - 2px) calc(100% / var(--n))),
    var(--pass);
}

.courses-title { margin: clamp(2.5rem, 6vw, 3.5rem) 0 0.4rem; font-size: 1.3rem; font-stretch: 110%; }
/* Colunas em vez de grade: os grupos têm tamanhos diferentes e não sobram buracos */
.courses { columns: 3 16rem; column-gap: 2.5rem; }
.courses > div { break-inside: avoid; padding-bottom: 2rem; }
.courses h4 {
  font-size: 0.95rem; font-weight: 700;
  margin-bottom: 0.75rem; padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}
.courses ul { list-style: none; font-size: 0.95rem; line-height: 1.45; }
.courses li + li { margin-top: 0.65rem; }
.courses-note { color: var(--muted); font-size: 0.95rem; margin-bottom: 1.75rem; }
.courses a { text-decoration-color: var(--rule); transition: text-decoration-color 0.15s ease; }
.courses a:hover { text-decoration-color: currentColor; }
.courses li span { display: block; color: var(--muted); font-size: 0.85rem; }

/* Contato */
.contact {
  padding-top: clamp(3rem, 7vw, 5rem);
  padding-bottom: 3rem;
  background: linear-gradient(var(--rule), var(--rule)) var(--gutter) 0 / calc(100% - 2 * var(--gutter)) 1px no-repeat;
}
.contact > h2 { margin-bottom: 0.75rem; }
.contact > p { color: var(--muted); }
.big-mail {
  display: inline-block;
  margin-top: 1.25rem;
  font-size: clamp(1.35rem, 5vw, 2.75rem);
  font-weight: 700; font-stretch: 115%;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  text-decoration: none;
  padding-bottom: 0.1em;
  background:
    linear-gradient(var(--pass), var(--pass)) 0 100% / 0% 2px no-repeat,
    linear-gradient(var(--rule), var(--rule)) 0 100% / 100% 2px no-repeat;
  transition: background-size 0.35s var(--ease-out);
}
.big-mail:hover { background-size: 100% 2px, 100% 2px; }
.social {
  list-style: none; display: flex; gap: 0.75rem;
  /* recua a área de clique para o ícone alinhar com o texto acima */
  margin: 1.75rem 0 0 -0.625rem;
}
.social a {
  display: grid; place-items: center;
  width: 3rem; height: 3rem;
  border-radius: 10px;
  color: var(--muted);
  transition: color 0.15s, background-color 0.15s, transform 0.16s var(--ease-out);
}
.social a:hover { color: var(--ink); background: var(--surface); }
.social a:active { transform: scale(0.94); }
.social svg { width: 1.75rem; height: 1.75rem; fill: currentColor; }
.contact .fine {
  margin-top: 3rem; padding-top: 1.25rem;
  border-top: 1px dashed var(--rule);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1rem;
  font-size: 0.85rem; color: var(--muted);
}
.contact .fine a { text-decoration: none; }
.contact .fine a:hover { color: var(--ink); text-decoration: underline; }

/* Entrada suave das seções ao rolar (só com JS e sem "reduzir movimento") */
/* Anima os filhos, não a seção: assim a âncora do menu cai no lugar certo */
.reveal-on .block > *,
.reveal-on .contact > * {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.reveal-on .is-visible > * { opacity: 1; transform: none; }
.reveal-on .is-visible > :nth-child(2) { transition-delay: 60ms; }
.reveal-on .is-visible > :nth-child(n+3) { transition-delay: 120ms; }
@media print {
  .reveal-on .block > *, .reveal-on .contact > * { opacity: 1; transform: none; }
  .topbar { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  .social a, .btn, .btn .arrow, .mark, .skills div, .topbar, .topbar nav a::after, .big-mail { transition: none; }
}

/* Responsivo */
@media (max-width: 920px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); }
  .skills { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .job {
    --rail: 5px;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem;
    padding-left: 1.6rem;
  }
  .job::before { top: 0.5rem; }
  .job > div::before, .when::before { display: none; }
  .when { position: relative; padding-top: 0; }
  .when::after {
    content: ""; position: absolute;
    left: calc(-1.6rem + 5.5px); top: 0.4rem;
    width: 11px; height: 11px; border-radius: 50%;
    transform: translateX(-50%);
    background: var(--paper);
    border: 2px solid var(--rule);
  }
  .job:has(.live) .when::after { border-color: var(--pass); background: var(--pass); }
  .live { display: inline-flex; margin: 0 0 0 0.6rem; }
  .term pre { white-space: pre-wrap; overflow-wrap: anywhere; padding: 1rem; }
  .term .ln i { display: none; }
  .term-title { display: none; }
  .skills, .edu { grid-template-columns: minmax(0, 1fr); }
  .logo { width: 1.9rem; height: 1.9rem; }
}
@media (max-width: 380px) {
  .term pre { font-size: 0.66rem; padding: 0.9rem 0.85rem; }
}
