/* ---------- Tokens ---------- */
:root {
  --bg: #141118;
  --bg-alt: #1a161f;
  --surface: #1f1a25;
  --surface-2: #28212f;
  --border: #3a3143;
  --text: #ede7f0;
  --muted: #b2a7ba;
  --accent: #c8a2d8;
  --accent-strong: #e2c6ee;
  --gold: #d6b26a;
  --on-accent: #1a1220;
  --star: rgba(237, 231, 240, 0.35);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03), 0 18px 40px -24px rgba(0, 0, 0, 0.8);

  --font-sans: "Josefin Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --radius: 14px;
  --wrap: 1120px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f1ea;
  --bg-alt: #efe8df;
  --surface: #fffcf7;
  --surface-2: #f4ede4;
  --border: #ddd1c4;
  --text: #231c27;
  --muted: #5d5262;
  --accent: #6b3a7d;
  --accent-strong: #4c2259;
  --gold: #8a6420;
  --on-accent: #fffcf7;
  --star: rgba(107, 58, 125, 0.18);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.6), 0 18px 40px -26px rgba(60, 30, 70, 0.35);
  color-scheme: light;
}

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

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

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

h1, h2, h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 0.6em;
}
h1 { font-size: clamp(2.25rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h3 { font-size: 1.25rem; }
h1 em, h2 em { font-family: var(--font-serif); font-style: italic; font-weight: 400; color: var(--accent); }

/* Editorial serif: hero line, project names, education headings */
.hero h1, .project-card h3, .project > h1, .education h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
}

p { margin: 0 0 1em; }

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

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 1rem; }
@media (min-width: 640px) { .wrap { padding: 0 2rem; } }

/* Read by screen readers, hidden on screen */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 1rem; top: -3rem; z-index: 20;
  background: var(--accent); color: var(--on-accent);
  padding: 0.5rem 0.9rem; border-radius: 8px;
}
.skip-link:focus { top: 1rem; }

.eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.9rem;
}

.lede { font-size: 1.2rem; color: var(--muted); max-width: 40rem; }

/* ---------- Buttons ---------- */
.actions, .contact-links { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.75rem 0 0; padding: 0; list-style: none; }

.button {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 500;
  font-size: 0.98rem;
  text-decoration: none;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.button:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.button.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.button.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4rem; }

.brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  color: var(--text); text-decoration: none;
  font-family: var(--font-sans); font-weight: 600; font-size: 1.1rem; letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand:hover { color: var(--text); }

.main-nav { display: flex; align-items: center; gap: 0.5rem; }
.main-nav ul { display: flex; gap: 0.25rem; margin: 0; padding: 0; list-style: none; }
.main-nav a {
  display: block; padding: 0.4rem 0.6rem; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 0.95rem;
}
.main-nav a:hover { color: var(--text); }

.theme-toggle {
  display: grid; place-items: center;
  width: 2.25rem; height: 2.25rem; margin-left: 0.25rem;
  border: 1px solid var(--border); border-radius: 50%;
  background: transparent; color: var(--gold); cursor: pointer;
}
.theme-toggle:hover { border-color: var(--gold); }
.theme-toggle svg { width: 1.05rem; height: 1.05rem; }

@media (max-width: 520px) {
  .brand { font-size: 1rem; }
  .main-nav a { padding: 0.4rem 0.4rem; font-size: 0.9rem; }
}

/* ---------- Hero ---------- */
.hero {
  padding: clamp(4rem, 12vw, 8rem) 0 clamp(3rem, 8vw, 5rem);
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, var(--star) 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 68%, var(--star) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 46% 14%, var(--star) 50%, transparent 51%),
    radial-gradient(1px 1px at 63% 82%, var(--star) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 78% 34%, var(--star) 50%, transparent 51%),
    radial-gradient(1px 1px at 91% 60%, var(--star) 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 86%, var(--star) 50%, transparent 51%);
}
.hero h1 { max-width: 19ch; font-size: clamp(2.75rem, 6.5vw, 4.5rem); line-height: 1.05; }

/* ---------- Sections ---------- */
.section { padding: clamp(3.5rem, 8vw, 6rem) 0; }
.section.alt { background: var(--bg-alt); border-block: 1px solid var(--border); }
.section-head { max-width: 44rem; margin-bottom: 2.5rem; }
.section-head p:not(.eyebrow) { color: var(--muted); }

/* ---------- Project cards ---------- */
.project-grid {
  display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  margin: 0; padding: 0; list-style: none;
}
.project-card {
  position: relative;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.25s, transform 0.25s;
}
.project-card:not(.is-placeholder):hover { border-color: var(--accent); transform: translateY(-2px); }
.project-card:not(.is-placeholder):focus-within { border-color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .project-card:hover { transform: none; } }

.project-shot {
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.project-shot img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top left; transition: transform 0.4s; }
.project-card:not(.is-placeholder):hover .project-shot img { transform: scale(1.03); }
@media (prefers-reduced-motion: reduce) { .project-card:hover .project-shot img { transform: none; } }
.project-card.is-placeholder .project-shot { background: transparent; border-bottom-style: dashed; }
.project-body-card { display: flex; flex-direction: column; flex: 1; padding: 1.4rem 1.5rem 1.4rem; }
.project-card h3 { margin-bottom: 0.4rem; font-size: 1.7rem; }
.project-card h3 a { color: var(--text); text-decoration: none; }
.project-card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.project-card p { color: var(--muted); }
.project-num { font-family: var(--font-serif); font-style: italic; color: var(--gold); font-size: 1.1rem; margin-bottom: 0.6rem; }
.project-type { font-size: 0.85rem; margin-top: auto; margin-bottom: 0.8rem; }

.paper-trail { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0; padding: 0; list-style: none; }
.paper-trail li {
  font-size: 0.75rem; padding: 0.15rem 0.55rem;
  border: 1px solid var(--border); border-radius: 999px; color: var(--muted);
}

.project-card.is-placeholder {
  background: transparent; border-style: dashed; box-shadow: none;
}
.project-card.is-placeholder h3 { color: var(--muted); }

/* ---------- Pillars ---------- */
.pillars {
  display: grid; gap: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  margin: 0; padding: 0; list-style: none; counter-reset: pillar;
}
.pillars li { counter-increment: pillar; padding-top: 1.2rem; border-top: 1px solid var(--gold); }
.pillars li::before {
  content: "0" counter(pillar);
  display: block; font-family: var(--font-serif); font-style: italic; color: var(--gold); margin-bottom: 0.4rem;
}
.pillars p { color: var(--muted); }

/* ---------- About ---------- */
.about { display: grid; gap: 3rem; }
@media (min-width: 900px) { .about { grid-template-columns: 1.4fr 1fr; align-items: start; } }
.about-copy p:not(.eyebrow) { color: var(--muted); }
.about-copy h2 + p { color: var(--text); font-size: 1.15rem; }

.about-aside {
  padding: 1.75rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.skills { margin: 0; padding: 0; list-style: none; }
.skills li { padding: 0.55rem 0 0.55rem 1.6rem; position: relative; border-bottom: 1px solid var(--border); }
.skills li:last-child { border-bottom: 0; }
.skills li::before { content: "✦"; position: absolute; left: 0; color: var(--gold); font-size: 0.8rem; top: 0.75rem; }

/* ---------- Education ---------- */
.education {
  display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  margin: 0; padding: 0; list-style: none;
}
.education li { padding: 1.4rem; border: 1px solid var(--border); border-radius: var(--radius); }
.education h3 { font-size: 1.3rem; margin-bottom: 0.3rem; }
.education p { color: var(--muted); margin: 0; font-size: 0.95rem; }
.edu-label {
  font-size: 0.85rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 1rem;
}
.education + .edu-label { margin-top: 2.5rem; }
/* Keep rows even: three in a row or stacked, never 2 + 1 */
.edu-3, .edu-2 { grid-template-columns: 1fr; }
@media (min-width: 520px) { .edu-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 680px) { .edu-3 { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Contact ---------- */
.contact { text-align: center; }
.contact .lede { margin: 0 auto; }
.contact .contact-links { justify-content: center; }

/* ---------- Project + doc pages ---------- */
.project, .doc { padding-top: 3rem; padding-bottom: 5rem; }
.breadcrumb { font-size: 0.9rem; color: var(--muted); margin-bottom: 2rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }

.project-nav { margin: 2.5rem 0; overflow-x: auto; overflow-y: hidden; }
.project-nav ul { display: flex; gap: 0.25rem; margin: 0; padding: 0; list-style: none; box-shadow: inset 0 -1px var(--border); min-width: max-content; }
.project-nav a, .project-nav .soon {
  display: block; white-space: nowrap;
  padding: 0.65rem 0.9rem; border-bottom: 2px solid transparent;
  font-size: 0.95rem; text-decoration: none; color: var(--muted);
}
.project-nav a:hover { color: var(--text); }
.project-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--gold); }
.project-nav .soon { opacity: 0.5; cursor: default; }

.project-body { display: grid; gap: 2.5rem; }
@media (min-width: 900px) { .project-body { grid-template-columns: 1.6fr 1fr; align-items: start; } }

.facts { padding: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.facts h2 { font-size: 1.4rem; }
.facts dl { margin: 0; }
.facts dt { font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); margin-top: 1rem; }
.facts dd { margin: 0.25rem 0 0; }
.facts dd ul { margin: 0; padding-left: 1.1rem; }

.trail-heading { margin-top: 4rem; }
.doc-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  margin: 0; padding: 0; list-style: none;
}
.doc-card {
  position: relative; padding: 1.3rem 1.3rem 1.1rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  transition: border-color 0.2s;
}
.doc-card:not(.is-soon):hover { border-color: var(--accent); }
.doc-card h3 { font-size: 1.35rem; margin-bottom: 0.3rem; }
.doc-card h3 a { color: var(--text); text-decoration: none; }
.doc-card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.doc-card p { color: var(--muted); font-size: 0.95rem; margin: 0; }
.doc-card.is-soon { background: transparent; border-style: dashed; }
.doc-card .soon-label { margin-top: 0.75rem; font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }

.draft-note {
  padding: 0.8rem 1rem; border: 1px dashed var(--gold); border-radius: 10px;
  color: var(--muted); font-size: 0.92rem;
}

/* ---------- Long-form prose (docs) ---------- */
.prose { max-width: 44rem; }
.prose h2 { font-size: 1.9rem; margin-top: 2.2em; }
.prose h3 { margin-top: 1.8em; }
.prose > :first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3rem; margin: 0 0 1.2em; }
.prose li { margin-bottom: 0.35em; }
.prose li::marker { color: var(--gold); }
.prose blockquote {
  margin: 1.5em 0; padding: 0.2em 0 0.2em 1.2em;
  border-left: 2px solid var(--accent);
  font-family: var(--font-serif); font-style: italic; font-size: 1.35rem; color: var(--text);
}
.prose code {
  font-size: 0.88em; padding: 0.1em 0.35em; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.prose table { width: 100%; border-collapse: collapse; margin: 1.5em 0; font-size: 0.95rem; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); }
.prose th { color: var(--gold); font-weight: 600; }
.prose img { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--border); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.5em 0; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 2.5rem 0; }
.footer-inner { color: var(--muted); font-size: 0.9rem; }
.footer-inner p { margin: 0; }

/* ---------- 404 ---------- */
.not-found { text-align: center; }
.not-found .lede { margin: 0 auto 1.5rem; }
