/* ===== Theme tokens ===== */
:root,
[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #fafafa;
  --text: #111114;
  --muted: #5c5c66;
  --border: #e7e7ea;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.10);
  --card: #ffffff;
  --nav-bg: rgba(255, 255, 255, 0.72);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0c0c0f;
  --bg-elev: #131316;
  --text: #ececf1;
  --muted: #9a9aa5;
  --border: #232327;
  --accent: #6b9bff;
  --accent-soft: rgba(107, 155, 255, 0.14);
  --card: #131316;
  --nav-bg: rgba(12, 12, 15, 0.72);
  color-scheme: dark;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  font-size: clamp(16px, 1vw + 13px, 18px);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.skip {
  position: absolute; left: -9999px;
  background: var(--bg-elev); padding: .5rem .75rem; border: 1px solid var(--border);
}
.skip:focus { left: 1rem; top: 1rem; z-index: 100; }

/* ===== Preloader ===== */
.loader {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.1rem;
  background: var(--bg);
  transition: opacity .5s ease, visibility .5s ease;
}
.loader__brand {
  font-weight: 720; font-size: clamp(1.6rem, 4vw, 2.2rem); letter-spacing: -0.03em;
  color: var(--text);
  animation: pulse 1.4s ease-in-out infinite;
}
.loader__bar {
  width: 140px; height: 2px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.loader__bar-fill {
  display: block; height: 100%; width: 0; background: var(--accent);
  animation: loadbar 2.6s cubic-bezier(.4, 0, .2, 1) forwards;
}
body.is-loaded .loader { opacity: 0; visibility: hidden; pointer-events: none; }

@keyframes pulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
@keyframes loadbar { 0% { width: 0; } 45% { width: 60%; } 82% { width: 92%; } 100% { width: 100%; } }

/* ===== Nav ===== */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav__inner {
  max-width: 1080px; margin: 0 auto; padding: 0 1.5rem;
  height: 60px; display: flex; align-items: center; gap: 1rem;
}
.brand { font-weight: 650; font-size: 1.05rem; letter-spacing: -0.02em; }

/* ===== Tabs ===== */
.tabs {
  position: relative;
  display: flex; align-items: center; gap: .25rem;
  margin-left: auto; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; z-index: 1;
  background: transparent; border: 0; cursor: pointer;
  color: var(--muted); font: inherit; font-size: .9rem; font-weight: 500;
  padding: .5rem .85rem; border-radius: 8px; white-space: nowrap;
  transition: color .18s ease, background-color .18s ease;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); }
.tabs__indicator {
  position: absolute; z-index: 0; top: 50%; left: 0; height: 34px;
  transform: translateY(-50%);
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px;
  transition: transform .26s cubic-bezier(.4, 0, .2, 1), width .26s cubic-bezier(.4, 0, .2, 1);
}

/* ===== Sections / panels ===== */
.section { max-width: 720px; margin: 0 auto; padding: 4.5rem 1.5rem 4rem; }
.section__title {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .14em;
  color: var(--muted); margin-bottom: 1.5rem; font-weight: 600;
}

.panel { display: none; }
.panel.is-active { display: block; animation: panelIn .45s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes panelIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* staggered reveal of active panel's direct children */
.panel.is-active > * { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
.panel.is-active > *:nth-child(1) { animation-delay: .05s; }
.panel.is-active > *:nth-child(2) { animation-delay: .11s; }
.panel.is-active > *:nth-child(3) { animation-delay: .17s; }
.panel.is-active > *:nth-child(4) { animation-delay: .23s; }
.panel.is-active > *:nth-child(5) { animation-delay: .29s; }
.panel.is-active > *:nth-child(n+6) { animation-delay: .35s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ===== Hero ===== */
.hero__status {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: .82rem; color: var(--muted); margin: 0 0 1rem;
  display: inline-flex; align-items: center; gap: .5rem;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15);
}
.hero__title { font-size: clamp(2.6rem, 7vw, 4.5rem); font-weight: 720; letter-spacing: -0.03em; }
.hero__tag { font-size: clamp(1.1rem, 2.4vw, 1.4rem); color: var(--muted); margin-top: .75rem; max-width: 32ch; }
.hero__cta { display: flex; gap: .75rem; margin-top: 2rem; flex-wrap: wrap; }

.hero__intro { color: var(--muted); max-width: 52ch; margin-top: 1.1rem; font-size: 1rem; }
.hero__now {
  margin-top: 2.75rem; font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: .85rem; color: var(--muted);
}
.hero__now-label { color: var(--accent); margin-right: .45rem; }
.hero__featured { margin-top: 2.5rem; }
.hero__stack { margin-top: 2.5rem; }
.hero__mini-title {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted);
  font-weight: 600; margin: 0 0 1rem;
}
.hero__list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.hero__list li { border-bottom: 1px solid var(--border); }
.hero__list a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding: .9rem 0; transition: padding-left .18s ease, color .18s ease;
}
.hero__list a:hover { padding-left: .5rem; color: var(--accent); }
.hero__list a > span:first-child { font-weight: 550; }
.hero__list .muted { color: var(--muted); font-size: .8rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .6rem 1.1rem; border-radius: 9px; font-size: .92rem; font-weight: 550;
  border: 1px solid var(--border); color: var(--text); cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.btn:hover { background: var(--bg-elev); transform: translateY(-1px); }
.btn--primary { background: var(--text); color: var(--bg); border-color: transparent; }
.btn--primary:hover { background: var(--text); opacity: .88; }

/* ===== Grid / cards ===== */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.section:has(.grid) { max-width: 1080px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.4rem; transition: border-color .15s ease, transform .15s ease;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card__title { font-size: 1.15rem; font-weight: 620; }
.card__desc { color: var(--muted); font-size: .95rem; margin: .5rem 0 1rem; }
.card__links { display: flex; gap: 1rem; margin-top: 1rem; font-size: .9rem; }
.card__links a { color: var(--accent); }

/* ===== Tags ===== */
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; margin: 0; }
.tags li {
  font-size: .78rem; padding: .2rem .55rem; border-radius: 6px;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ===== About / Contact prose ===== */
.prose p { margin: .5rem 0; color: var(--text); }
.prose p + p { color: var(--muted); }
.prose p:first-child { font-size: 1.12rem; color: var(--text); }
.link-email { color: var(--accent); font-size: 1.1rem; font-weight: 550; }

.about__facts {
  list-style: none; margin: 2.5rem 0 0; padding: 1.4rem 0 0; border-top: 1px solid var(--border);
  display: grid; gap: .7rem;
}
.about__facts li { display: flex; gap: 1.25rem; align-items: baseline; flex-wrap: wrap; }
.about__facts .label {
  color: var(--muted); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .12em;
  min-width: 6.5rem; flex-shrink: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ===== Skills ===== */
.skills { display: grid; gap: 1.5rem; }
.skill-group h3 { font-size: .9rem; color: var(--muted); margin-bottom: .6rem; font-weight: 600; }

/* ===== Contact socials ===== */
.socials { list-style: none; display: flex; gap: 1.25rem; padding: 1rem 0 0; margin: 0; }
.socials a { color: var(--muted); font-size: .92rem; }
.socials a:hover { color: var(--text); }

/* ===== Footer ===== */
.footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 1.5rem; text-align: center;
  color: var(--muted); font-size: .85rem;
}
.footer p { margin: 0; }

/* ===== Responsive ===== */
@media (max-width: 720px) { .grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .nav__inner { flex-wrap: wrap; height: auto; padding: .55rem 1rem; gap: .4rem; }
  .brand { padding: .35rem 0; }
  .tabs { margin-left: 0; width: 100%; padding-bottom: .2rem; }
}

/* ===== Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}