/* Public site styles. All colours are tokens on :root; dark mode only redefines the tokens.
   Dark applies when the visitor's system prefers it (unless they picked light with the toggle),
   or when they picked dark with the toggle. */
:root {
  --bg: #fafaf9;
  --bg-soft: #f2f1ef;
  --surface: #ffffff;
  --text: #18181b;
  --muted: #62626b;
  --border: #e6e4e1;
  --accent: #4f46e5;
  --accent-2: #0891b2;
  --accent-soft: #eef0ff;
  --on-accent: #ffffff;
  --glow: rgba(79, 70, 229, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b10; --bg-soft: #111118; --surface: #15151d; --text: #ececf1; --muted: #9a9aa8;
    --border: #262631; --accent: #8b85ff; --accent-2: #22d3ee; --accent-soft: #1d1b3a;
    --on-accent: #0b0b10; --glow: rgba(139, 133, 255, .18);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
  :root:not([data-theme="light"]) .when-light { display: none; }
}
:root[data-theme="dark"] {
  --bg: #0b0b10; --bg-soft: #111118; --surface: #15151d; --text: #ececf1; --muted: #9a9aa8;
  --border: #262631; --accent: #8b85ff; --accent-2: #22d3ee; --accent-soft: #1d1b3a;
  --on-accent: #0b0b10; --glow: rgba(139, 133, 255, .18);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}
:root[data-theme="dark"] .when-light { display: none; }
.when-dark { display: none; }
:root[data-theme="dark"] .when-dark { display: inline-flex; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .when-dark { display: inline-flex; } }

/* ---- base ---- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.7 var(--font);
  -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.015em; }
p { margin: 0 0 .8em; }
ul, ol { margin: 0; padding: 0; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 760px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.icon { width: 1.1em; height: 1.1em; flex-shrink: 0; vertical-align: -.17em; }

.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 14px; border-radius: 8px; }
.skip:focus { left: 8px; }

/* ---- nav ---- */
.nav { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid transparent;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(10px);
  transition: border-color .2s; }
.nav.is-scrolled { border-bottom-color: var(--border); }
.nav-inner { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; font-size: .8rem;
  letter-spacing: .04em; color: var(--on-accent); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.nav nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav nav a { color: var(--muted); font-size: .92rem; font-weight: 500; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.nav nav a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.nav nav a.is-active { color: var(--accent); background: var(--accent-soft); }
.theme-toggle { display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0; cursor: pointer;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 1rem; }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---- buttons, chips, badges ---- */
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 550;
  transition: transform .15s, border-color .15s, box-shadow .15s; }
.btn:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 6px 20px var(--glow); }
.btn-primary:hover { box-shadow: 0 8px 28px var(--glow); }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { font-size: .88rem; padding: 4px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); }
.chips-sm li { font-size: .78rem; padding: 2px 10px; background: var(--bg-soft); }
.badge { display: inline-block; font-size: .7rem; font-weight: 650; padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); vertical-align: middle; letter-spacing: .02em; }

.socials { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; }
.socials a { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 1.1rem;
  transition: color .15s, border-color .15s, transform .15s; }
.socials a:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }

/* ---- hero ---- */
/* The glow may extend below the hero and fade over the next section; clip only sideways. */
.hero { position: relative; overflow-x: clip; }
.hero::before { content: ""; position: absolute; top: -260px; right: -180px; width: 720px; height: 720px; max-width: 100vw;
  background: radial-gradient(closest-side, var(--glow), transparent); pointer-events: none; }
.hero-inner { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 48px;
  padding-top: 96px; padding-bottom: 72px; }
.eyebrow { color: var(--accent); font-weight: 600; margin: 0 0 4px; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 3.8rem); font-weight: 750; letter-spacing: -.03em;
  background: linear-gradient(120deg, var(--text) 30%, var(--accent) 75%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent; padding-bottom: 4px; }
.headline { font-size: clamp(1.1rem, 2.4vw, 1.35rem); color: var(--muted); margin: 8px 0 6px; }
.location { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.avatar { width: 220px; height: 220px; border-radius: 28px; object-fit: cover; display: block;
  box-shadow: 0 0 0 6px var(--surface), 0 0 0 7px var(--border), 0 24px 60px var(--glow); }
.avatar-initials { display: grid; place-items: center; font-size: 4rem; font-weight: 750; color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

/* ---- sections ---- */
.section { padding: 56px 0 24px; }
.section-title { display: flex; align-items: center; gap: 14px; font-size: 1.6rem; margin-bottom: 28px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.prose { max-width: 70ch; font-size: 1.04rem; }
.small-heading { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 12px; font-weight: 650; }

/* timeline */
.timeline { list-style: none; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline-item { position: relative; padding: 0 0 32px 28px; }
.timeline-item:last-child { padding-bottom: 8px; }
.timeline-item::before { content: ""; position: absolute; left: -8px; top: 6px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--accent); }
.timeline-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px 16px; }
.timeline-head h3 { font-size: 1.12rem; }
.at { color: var(--accent); font-weight: 550; }
.timeline-item > .at { margin: 2px 0 6px; }
.dates { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.bullets { padding-left: 20px; margin-top: 10px; }
.bullets li { margin-bottom: 5px; }
.bullets li::marker { color: var(--accent); }

/* projects */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.card { position: relative; display: flex; flex-direction: column; overflow: hidden; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); transition: transform .2s, border-color .2s, box-shadow .2s; }
.card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); box-shadow: var(--shadow); }
.card-featured { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.card-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; border-bottom: 1px solid var(--border); }
.card-img-placeholder { display: grid; place-items: center; font-size: 2.4rem; color: var(--accent);
  background: radial-gradient(circle at 30% 20%, var(--glow), transparent 60%), linear-gradient(135deg, var(--accent-soft), var(--bg-soft)); }
.card-body { display: flex; flex-direction: column; flex: 1; padding: 20px; }
.card-body h3 { font-size: 1.12rem; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-body p { color: var(--muted); font-size: .95rem; }
.card-body .chips { margin-bottom: 4px; }
.card-title-link { color: var(--text); }
.card-title-link::after { content: ""; position: absolute; inset: 0; } /* whole card is clickable */
.card-title-link:hover { text-decoration: none; }
.card-links { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 18px; margin-top: auto; padding-top: 14px; font-weight: 550; font-size: .93rem; }
.card-links a { display: inline-flex; align-items: center; gap: 6px; }

.skill-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.skill-group { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

/* contact */
.contact-card { text-align: center; padding: 48px 24px; border-radius: 22px; border: 1px solid var(--border);
  background: radial-gradient(ellipse at top, var(--glow), transparent 70%), var(--surface); }
.contact-card h2 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin-bottom: 10px; }
.contact-card p { color: var(--muted); max-width: 52ch; margin: 0 auto; }
.contact-card .actions { justify-content: center; margin-bottom: 0; }

.footer { margin-top: 64px; border-top: 1px solid var(--border); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding-top: 24px; padding-bottom: 32px; }
.footer p { margin: 0; }
.footer .socials a { width: 36px; height: 36px; border-radius: 10px; }

/* ---- project detail page ---- */
.project-page { padding-top: 40px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; }
.back-link:hover { color: var(--accent); text-decoration: none; }
.project-header { padding: 28px 0 8px; }
.project-header h1 { font-size: clamp(2rem, 5vw, 2.8rem); font-weight: 750; margin-bottom: 12px; }
.lead { font-size: 1.2rem; color: var(--muted); }
.project-header .chips { margin-top: 16px; }
.project-cover { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); margin: 12px 0 28px; display: block; }

.markdown { max-width: none; }
.markdown h2 { font-size: 1.45rem; margin: 2em 0 .6em; }
.markdown h3 { font-size: 1.15rem; margin: 1.6em 0 .5em; }
.markdown ul, .markdown ol { padding-left: 1.4em; margin: 0 0 1em; }
.markdown li { margin-bottom: .35em; }
.markdown li::marker { color: var(--accent); }
.markdown img { display: block; margin: 1.5em auto; border-radius: 10px; border: 1px solid var(--border); }
.markdown blockquote { margin: 1.2em 0; padding: .4em 1.2em; border-left: 3px solid var(--accent); color: var(--muted); background: var(--bg-soft); border-radius: 0 8px 8px 0; }
.markdown code { font-family: var(--mono); font-size: .88em; padding: .15em .4em; border-radius: 6px; background: var(--bg-soft); border: 1px solid var(--border); }
.markdown pre { overflow-x: auto; padding: 16px 18px; border-radius: 12px; background: var(--bg-soft); border: 1px solid var(--border); line-height: 1.55; }
.markdown pre code { padding: 0; border: 0; background: none; font-size: .86rem; }
.markdown table { width: 100%; border-collapse: collapse; margin: 1.2em 0; font-size: .95rem; display: block; overflow-x: auto; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.markdown th { background: var(--bg-soft); }
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }

.notfound { padding: 120px 0; }
.notfound h1 { font-size: clamp(2rem, 5vw, 2.6rem); margin-bottom: 10px; }

/* ---- scroll reveal (only when JS is running; see base.html) ---- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.js .reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .card, .btn, .socials a { transition: none; }
}

/* ---- small screens ---- */
@media (max-width: 720px) {
  .hero-inner { grid-template-columns: 1fr; gap: 28px; padding-top: 48px; padding-bottom: 40px; }
  .hero-photo { order: -1; }
  .avatar { width: 120px; height: 120px; border-radius: 22px; }
  .avatar-initials { font-size: 2.4rem; }
  .brand-name { display: none; }
  .nav-inner { gap: 10px; }
  .section { padding-top: 44px; }
}
