/* ==========================================================================
   Portfolio stylesheet
   Sections: tokens, base, header, hero + manifest, sections, experience,
   projects, stack, contact, footer, responsive, reduced motion
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-code: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --gutter: clamp(1.25rem, 4vw, 2.5rem);

  /* Light theme (default) */
  --bg: #F2F5F8;
  --surface: #FFFFFF;
  --ink: #142033;
  --muted: #52627A;
  --line: #D5DDE7;
  --line-strong: #B4C0CF;
  --accent: #2B47F5;
  --accent-hover: #1F36C9;
  --accent-ink: #FFFFFF;

  /* Manifest panel */
  --panel-bg: #14213A;
  --panel-line: #26385A;
  --panel-ink: #D9E4F5;
  --panel-key: #92B0FF;
  --panel-val: #9FE3C0;
  --panel-punct: #7B8FAF;
  --pending: #E9B24F;
  --synced: #43D39B;
}

[data-theme="dark"] {
  --bg: #0F1B31;
  --surface: #172845;
  --ink: #E6ECF7;
  --muted: #9BAAC2;
  --line: #26385A;
  --line-strong: #3A5180;
  --accent: #8EA2FF;
  --accent-hover: #B0BEFF;
  --accent-ink: #0F1B31;

  --panel-bg: #0A1426;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-wrap: balance;
}

p { margin: 0; }

a { color: inherit; }

ul, ol { margin: 0; padding: 0; list-style: none; }

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.container {
  width: min(100% - 2 * var(--gutter), 72rem);
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 0.75rem; }

.link {
  color: var(--accent);
  font-weight: 600;
  text-decoration-line: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.25em;
}
.link:hover { color: var(--accent-hover); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.4rem;
  border: 1.5px solid transparent;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 0.975rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost { border-color: var(--line-strong); color: var(--ink); }
.btn--ghost:hover { border-color: var(--ink); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
}

.site-header__right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.nav__list { display: flex; gap: 0.25rem; }

.nav__link {
  display: block;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s, background-color 0.15s;
}
.nav__link:hover { color: var(--ink); }
.nav__link[aria-current="true"] {
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.header-actions { display: flex; gap: 0.5rem; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s;
}
.icon-btn:hover { border-color: var(--line-strong); }

.theme-toggle__sun { display: none; }
[data-theme="dark"] .theme-toggle__sun { display: block; }
[data-theme="dark"] .theme-toggle__moon { display: none; }

.nav-toggle { display: none; }
.nav-toggle__close { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle__open { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle__close { display: block; }

/* ---------- Hero ---------- */
.hero {
  padding-block: clamp(3.5rem, 9vw, 7rem) clamp(3.5rem, 8vw, 6rem);
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: clamp(2.5rem, 6vw, 4.5rem);
  align-items: center;
}

.hero__title {
  font-size: clamp(2.5rem, 5.4vw, 4.4rem);
  letter-spacing: -0.035em;
  line-height: 1.03;
}

.hero__lead {
  max-width: 34rem;
  margin: 1.75rem 0 2.25rem;
  color: var(--muted);
  font-size: clamp(1.1rem, 1.6vw, 1.3rem);
  line-height: 1.55;
}

.hero__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* Manifest panel. The one animated moment on the page:
   every line starts "pending" (amber) and turns "synced" (green) in order. */
.manifest {
  --end: calc(var(--n) * 110ms + 700ms);
  margin: 0;
  overflow: hidden;
  background: var(--panel-bg);
  color: var(--panel-ink);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  box-shadow: 0 28px 50px -28px rgba(20, 33, 58, 0.55);
}

.manifest__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.1rem;
  border-bottom: 1px solid var(--panel-line);
  font-family: var(--font-code);
  font-size: 0.8rem;
}

.manifest__file { color: var(--panel-ink); }

.manifest__lines {
  padding: 1.1rem 0;
  overflow-x: auto;
  font-family: var(--font-code);
  font-size: 0.875rem;
  line-height: 1.8;
}

.ln {
  display: grid;
  grid-template-columns: 2.25rem 1fr;
  align-items: baseline;
  padding-right: 1rem;
  animation: line-in 0.35s ease-out both;
  animation-delay: calc(var(--i) * 110ms + 600ms);
}

.ln__dot {
  align-self: center;
  justify-self: center;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--synced);
  animation: dot-sync 0.45s ease-out both;
  animation-delay: calc(var(--i) * 110ms + 600ms);
}

.ln__text { white-space: pre; }

.k { color: var(--panel-key); }
.v { color: var(--panel-val); }
.p { color: var(--panel-punct); }

.manifest__foot {
  padding: 0.8rem 1.1rem;
  border-top: 1px solid var(--panel-line);
  color: var(--panel-punct);
  font-family: var(--font-code);
  font-size: 0.78rem;
}

/* Two stacked texts: the first fades out, the second fades in when the last line syncs. */
.swap { display: grid; }
.swap__a,
.swap__b { grid-area: 1 / 1; }
.swap__a { animation: fade-out 0.2s both; animation-delay: var(--end); }
.swap__b { animation: fade-in 0.3s both; animation-delay: var(--end); }

.status { font-size: 0.78rem; }
.status__state {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  justify-content: flex-end;
}
.status__state::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}
.status__state--pending { color: var(--pending); }
.status__state--ok { color: var(--synced); }

@keyframes line-in {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

@keyframes dot-sync {
  from { background: var(--pending); transform: scale(0.8); }
  60% { transform: scale(1.6); }
  to { background: var(--synced); transform: scale(1); }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Sections ---------- */
.section {
  padding-block: clamp(4rem, 9vw, 7rem);
  border-top: 1px solid var(--line);
}

.section__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
  gap: 2rem clamp(2rem, 6vw, 5rem);
}

.section__title {
  position: sticky;
  top: 6rem;
  align-self: start;
  font-size: clamp(1.75rem, 3vw, 2.4rem);
}

.prose { max-width: 38rem; }
.prose p + p { margin-top: 1.25rem; }

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.75rem 2rem;
  max-width: 38rem;
  margin: 2.25rem 0 0;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* ---------- Experience ---------- */
.timeline { max-width: 40rem; }

.job {
  position: relative;
  margin-left: 0.4rem;
  padding: 0 0 3rem 2rem;
  border-left: 2px solid var(--line);
}
.job:last-child { padding-bottom: 0; border-left-color: transparent; }

.job::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 0.45rem;
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--bg);
}
.job--current::before { background: var(--accent); }

.job:last-child::before { left: -7px; }

.job__dates { color: var(--muted); font-size: 0.95rem; }
.job__role { margin-top: 0.35rem; font-size: 1.45rem; }
.job__org { margin-top: 0.15rem; color: var(--muted); font-weight: 500; }

.job__points { margin-top: 1rem; }
.job__points li { position: relative; padding-left: 1.1rem; }
.job__points li + li { margin-top: 0.5rem; }
.job__points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.78em;
  width: 0.4rem;
  height: 2px;
  background: var(--line-strong);
}

/* ---------- Projects ---------- */
.ledger { border-top: 1px solid var(--line); }

.ledger__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 0.75rem 2.5rem;
  padding: 2rem 0.75rem;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.2s;
}
.ledger__row:hover { background: var(--surface); }

.ledger__title { font-size: clamp(1.35rem, 2.2vw, 1.75rem); }
.ledger__tags { margin-top: 0.5rem; color: var(--muted); font-size: 0.95rem; }
.ledger__desc { max-width: 38rem; }

/* ---------- Stack ---------- */
.section__intro { max-width: 38rem; margin-bottom: 2rem; }
.stack__practices { margin-top: 1.5rem; color: var(--muted); }

.layers { display: grid; gap: 0.5rem; }

.layer {
  display: grid;
  grid-template-columns: minmax(8rem, 11rem) 1fr;
  gap: 0.5rem 1.25rem;
  align-items: baseline;
  padding: 1.1rem 1.4rem;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) calc(var(--depth) * 5% + 4%), var(--surface));
}

.layer--apps {
  background: transparent;
  border: 1.5px dashed var(--line-strong);
  color: var(--muted);
}

.layer__name { font-size: 1.15rem; }
.layer__note { font-weight: 500; }

.layer__items { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; }
.layer__items li { font-weight: 500; }

/* ---------- Education and certifications ---------- */
.records { border-top: 1px solid var(--line); }

.record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.25rem 2rem;
  align-items: baseline;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--line);
}

.record__title { font-weight: 600; }
.record__sub { color: var(--muted); }
.record__date { color: var(--muted); font-size: 0.95rem; text-align: right; }

.subhead { margin: 3rem 0 1.25rem; font-size: 1.35rem; }

/* ---------- Contact ---------- */
.contact__lead {
  max-width: 22ch;
  margin-bottom: 1.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.2vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.contact__mail {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.6vw, 1.9rem);
  font-weight: 600;
  text-decoration-line: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 3px;
  text-underline-offset: 0.3em;
  word-break: break-word;
}
.contact__mail:hover { color: var(--accent); }

.contact__links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; margin-top: 2rem; }

/* ---------- Footer ---------- */
.site-footer {
  padding-block: 2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer__bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
}

/* ---------- 404 page ---------- */
.not-found { padding-block: clamp(4rem, 12vw, 9rem); }
.not-found__title { font-size: clamp(2.2rem, 5vw, 3.6rem); letter-spacing: -0.03em; }
.not-found__text { max-width: 32rem; margin: 1.25rem 0 2rem; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero__grid { grid-template-columns: minmax(0, 1fr); }
  .section__grid { grid-template-columns: minmax(0, 1fr); }
  .section__title { position: static; }
  .ledger__row { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .nav-toggle { display: grid; }

  .nav__list {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem var(--gutter) 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .nav[data-open="true"] .nav__list { display: flex; }
  .nav__link { padding: 0.8rem 0.25rem; font-size: 1.05rem; }
}

@media (max-width: 560px) {
  .manifest__lines { font-size: 0.75rem; }
  .ln { grid-template-columns: 1.75rem 1fr; padding-right: 0.75rem; }
  .layer { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 0.15rem; }
  .facts dd { margin-bottom: 0.9rem; }
  .record { grid-template-columns: minmax(0, 1fr); }
  .record__date { text-align: left; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .swap__a { display: none; }
}
