/* ---------- Tokens ---------- */
:root {
  color-scheme: light dark;
  --bg: #f6f7f4;
  --bg-alt: #eef1ec;
  --surface: #ffffff;
  --surface-2: #f1f4f0;
  --ink: #0f1f1b;
  --muted: #5a6a63;
  --line: rgba(15, 31, 27, .09);
  --line-strong: rgba(15, 31, 27, .16);
  --accent: #0f766e;
  --accent-2: #14b8a6;
  --accent-ink: #ffffff;
  --gold: #c08a35;
  --glow: rgba(20, 184, 166, .18);
  --shadow: 0 1px 2px rgba(15, 31, 27, .04), 0 8px 24px -12px rgba(15, 31, 27, .12);
  --shadow-lg: 0 2px 4px rgba(15, 31, 27, .04), 0 24px 48px -20px rgba(15, 31, 27, .25);
  --header-bg: rgba(246, 247, 244, .72);
  --radius: 16px;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --c-quimica: #0f766e;
  --c-ciencia: #7c3aed;
  --c-apps: #2563eb;
  --c-linux: #c2410c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1210;
    --bg-alt: #0e1714;
    --surface: #121c19;
    --surface-2: #17231f;
    --ink: #e7efeb;
    --muted: #93a49c;
    --line: rgba(231, 239, 235, .08);
    --line-strong: rgba(231, 239, 235, .16);
    --accent: #2dd4bf;
    --accent-2: #5eead4;
    --accent-ink: #04211d;
    --gold: #e0b062;
    --glow: rgba(45, 212, 191, .16);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .5);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 24px 48px -20px rgba(0, 0, 0, .7);
    --header-bg: rgba(11, 18, 16, .7);

    --c-quimica: #2dd4bf;
    --c-ciencia: #a78bfa;
    --c-apps: #60a5fa;
    --c-linux: #fb923c;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box }
html { scroll-behavior: smooth; scroll-padding-top: 90px }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none }
button { font: inherit }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px }
::selection { background: var(--accent); color: var(--accent-ink) }
main { overflow-x: clip }
.wrap { width: min(1160px, calc(100% - 64px)); margin-inline: auto }

/* ---------- Header ---------- */
.header {
  position: sticky; top: 0; z-index: 10;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 68px }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.02em }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink); border-radius: 10px;
  font-family: var(--serif); font-size: 22px; font-weight: 700;
  box-shadow: 0 6px 16px -6px var(--accent);
}
nav { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500 }
nav a { padding: 8px 14px; border-radius: 999px; color: var(--muted); transition: color .2s, background .2s }
nav a:hover { color: var(--ink); background: var(--surface-2) }
.nav-github { color: var(--ink) !important; border: 1px solid var(--line-strong); margin-left: 6px }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  display: grid; grid-template-columns: 1.15fr 1fr; align-items: center; gap: 64px;
  padding-block: 96px 88px;
}
.hero::before {
  content: ""; position: absolute; inset: -40px -10vw auto; height: 560px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 50% at 15% 30%, var(--glow), transparent 70%),
    radial-gradient(35% 45% at 85% 40%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 70%);
  filter: blur(10px);
}
.badge {
  display: inline-flex; align-items: center; gap: 10px; margin: 0 0 28px;
  padding: 6px 14px 6px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-strong);
  font-size: 13px; font-weight: 500; color: var(--muted); box-shadow: var(--shadow);
}
.badge > span {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2);
  box-shadow: 0 0 0 4px var(--glow);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent } }
.eyebrow {
  font: 600 12px/1.5 var(--mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 14px;
}
h1 {
  font-size: clamp(44px, 6vw, 76px); font-weight: 800; line-height: 1.02;
  letter-spacing: -.045em; margin: 0 0 24px;
}
h1 em {
  font-family: var(--serif); font-style: italic; font-weight: 500; letter-spacing: -.02em;
  background: linear-gradient(100deg, var(--accent) 10%, var(--accent-2) 55%, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  padding-right: .08em;
}
.intro { color: var(--muted); font-size: 18px; line-height: 1.7; margin: 0; max-width: 34em }
.hero-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 36px; font-size: 15px; font-weight: 600 }
.button {
  display: inline-flex; align-items: center; gap: 12px;
  background: var(--ink); color: var(--bg);
  padding: 14px 22px; border-radius: 999px;
  box-shadow: var(--shadow-lg); transition: transform .2s, box-shadow .2s;
}
.button:hover { transform: translateY(-2px) }
.hero-actions .text-link { padding: 14px 20px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface) }
.hero-actions .text-link:hover { border-color: var(--accent); color: var(--accent) }
.text-link { font-weight: 600; transition: color .2s, border-color .2s }
.text-link:hover { color: var(--accent) }
.topics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 40px }
.topics span {
  font: 500 11px var(--mono); letter-spacing: .1em; color: var(--muted);
  padding: 6px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line);
}

/* Lab card */
.lab {
  position: relative;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line-strong); border-radius: 24px; padding: 22px;
  box-shadow: var(--shadow-lg);
  animation: float 8s ease-in-out infinite;
}
.lab::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none; padding: 1px;
  background: linear-gradient(135deg, var(--accent-2), transparent 40%, transparent 60%, var(--gold));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; opacity: .6;
}
@keyframes float { 50% { transform: translateY(-8px) } }
.lab-top, .lab-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; font: 500 11px var(--mono); letter-spacing: .08em; color: var(--muted) }
.lab-top { padding-bottom: 16px; border-bottom: 1px dashed var(--line-strong) }
.lab svg { display: block; width: 100%; height: auto; margin-block: 12px }
.lab .grid-dot { fill: var(--line-strong) }
.lab .mol { color: var(--accent) }
.lab .trail { color: var(--gold) }
.lab-bottom { padding-top: 16px; border-top: 1px dashed var(--line-strong); letter-spacing: 0 }
.lab-seal { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 11px }

/* ---------- Projects ---------- */
.projects-section { background: var(--bg-alt); border-block: 1px solid var(--line); padding: 96px 0 }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px }
h2 { font-size: clamp(32px, 4vw, 46px); font-weight: 800; letter-spacing: -.035em; line-height: 1.1; margin: 0 }
h2 > span { color: var(--accent) }
.section-heading > p { font-size: 15px; line-height: 1.7; color: var(--muted); margin: 0; text-align: right }

.filters {
  display: inline-flex; flex-wrap: wrap; gap: 4px; margin-top: 40px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
}
.filters[hidden] { display: none }
.filters button {
  border: 0; background: transparent; border-radius: 999px; padding: 9px 18px;
  font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; transition: background .2s, color .2s;
}
.filters button:hover { color: var(--ink) }
.filters button[aria-pressed=true] { background: var(--ink); color: var(--bg) }
.result-count { font: 500 12px var(--mono); color: var(--muted); margin: 24px 0 16px }

.project-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px }
.project {
  --c: var(--accent);
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column; min-height: 232px; padding: 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), border-color .25s, box-shadow .25s;
}
.project::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity .3s;
  background: radial-gradient(120% 80% at 100% 0%, color-mix(in srgb, var(--c) 14%, transparent), transparent 60%);
}
.project:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--c) 45%, transparent); box-shadow: var(--shadow-lg) }
.project:hover::before { opacity: 1 }
.project[hidden] { display: none }
.project[data-category="Química"] { --c: var(--c-quimica) }
.project[data-category="Ciência e código"] { --c: var(--c-ciencia) }
.project[data-category="Aplicações"] { --c: var(--c-apps) }
.project[data-category="Linux"] { --c: var(--c-linux) }

.project-top { display: flex; justify-content: space-between; align-items: center }
.project-top > span:first-child {
  font: 600 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--c);
  padding: 5px 10px; border-radius: 999px; background: color-mix(in srgb, var(--c) 12%, transparent);
}
.project-top > span:last-child {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line-strong); font-size: 15px; color: var(--muted);
  transition: transform .25s, background .25s, color .25s, border-color .25s;
}
.project:hover .project-top > span:last-child { background: var(--c); border-color: var(--c); color: var(--surface); transform: rotate(45deg) }
.project h3 { font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin: 22px 0 8px }
.project p { font-size: 14.5px; line-height: 1.65; color: var(--muted); margin: 0 0 24px }
.project-bottom {
  display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 16px;
  border-top: 1px solid var(--line); font: 500 12px var(--mono);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c) }
.repo { margin-left: auto; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.all-repos {
  display: flex; width: fit-content; margin: 40px auto 0; gap: 12px;
  font-size: 15px; font-weight: 600; padding: 13px 22px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); transition: border-color .2s, color .2s;
}
.all-repos:hover { border-color: var(--accent); color: var(--accent) }

/* ---------- About ---------- */
.about { display: grid; grid-template-columns: 1fr 1.2fr; gap: 96px; padding-block: 104px }
.about p:not(.eyebrow) { font-size: 17px; color: var(--muted); line-height: 1.8; margin: 0 0 18px }
.about .text-link { font-size: 15px }
.stats { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 0; margin: 32px 0 }
.stats li { padding: 18px 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow) }
.stats strong {
  display: block; font-size: 30px; font-weight: 800; letter-spacing: -.04em; line-height: 1.1;
  background: linear-gradient(100deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stats span { font-size: 13px; color: var(--muted) }

/* ---------- Footer ---------- */
footer { border-top: 1px solid var(--line); padding-block: 32px; display: flex; justify-content: space-between; align-items: center; gap: 20px }
footer p, footer > a:last-child { font-size: 13px; color: var(--muted); margin: 0 }
footer > a:last-child:hover { color: var(--accent) }
footer .brand { font-size: 15px }
footer .brand-mark { width: 28px; height: 28px; font-size: 18px; border-radius: 8px }

.skip { position: absolute; left: 10px; top: -80px; padding: 12px 16px; background: var(--surface); color: var(--ink); border-radius: 8px; z-index: 20 }
.skip:focus { top: 10px }

/* ---------- Responsive ---------- */
@media (max-width: 950px) {
  .hero { gap: 40px; padding-block: 72px }
  .project-grid { grid-template-columns: repeat(2, 1fr) }
  .about { gap: 48px }
}
@media (max-width: 650px) {
  .wrap { width: calc(100% - 32px) }
  .header-inner { height: 60px }
  .brand { font-size: 15px }
  nav { font-size: 13px; gap: 2px }
  nav a { padding: 7px 10px }
  nav a[href="#sobre"] { display: none }
  .hero { grid-template-columns: 1fr; padding-block: 48px 56px; gap: 44px }
  h1 { font-size: 46px }
  .intro { font-size: 16px }
  .hero-actions > * { flex: 1 1 auto; justify-content: center; text-align: center }
  .lab { padding: 16px; border-radius: 20px }
  .projects-section { padding-block: 64px }
  .section-heading { display: block }
  .section-heading > p { margin-top: 14px; text-align: left }
  .filters { display: flex; border-radius: 18px; margin-top: 28px }
  .filters[hidden] { display: none }
  .filters button { padding: 8px 12px; font-size: 13px }
  .project-grid { grid-template-columns: 1fr }
  .project { min-height: 0 }
  .about { grid-template-columns: 1fr; gap: 24px; padding-block: 64px }
  .stats strong { font-size: 24px }
  .stats li { padding: 14px }
  footer { flex-wrap: wrap; gap: 12px }
  footer p { width: 100%; order: 3 }
  .desktop { display: none }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto }
  *, *::before, *::after { transition: none !important; animation: none !important }
}
