/* ---------- tokens ---------- */
:root {
  --bg: #f2f8f5;
  --bg-2: #e5f0ea;
  --fg: #22303b;
  --muted: #64787f;
  --line: #d3e4db;
  --accent: #6e7ff3;       /* periwinkle, on a mint base */
  --accent-2: #bfe9d4;
  --dot: rgba(34, 48, 59, 0.10);
  --radius: 14px;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #171226;
  --bg-2: #201936;
  --fg: #ece7f9;
  --muted: #9a91bd;
  --line: #2f2750;
  --accent: #f4df8d;       /* butter yellow on deep purple */
  --accent-2: #4c4120;
  --dot: rgba(236, 231, 249, 0.10);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171226;
    --bg-2: #201936;
    --fg: #ece7f9;
    --muted: #9a91bd;
    --line: #2f2750;
    --accent: #f4df8d;
    --accent-2: #4c4120;
    --dot: rgba(236, 231, 249, 0.10);
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  transition: background .4s ease, color .4s ease;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.1; margin: 0; }
em { font-style: italic; }
.todo { color: var(--muted); opacity: .7; }
.todo::after { content: ' (todo)'; font-size: .8em; }

#bg {
  position: fixed; inset: 0; z-index: -1;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* ---------- theme toggle (fixed, top-right) ---------- */
.theme-toggle {
  position: fixed; top: 18px; right: 18px; z-index: 10;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--fg);
  cursor: pointer; font-size: 1.05rem; overflow: hidden; display: grid; place-items: center;
}
.theme-toggle span { grid-area: 1/1; transition: transform .45s cubic-bezier(.34,1.56,.64,1), opacity .3s; }
.theme-toggle .moon { transform: translateY(140%) rotate(-40deg); opacity: 0; }
:root[data-theme="dark"] .theme-toggle .sun { transform: translateY(-140%) rotate(40deg); opacity: 0; }
:root[data-theme="dark"] .theme-toggle .moon { transform: none; opacity: 1; }

/* ---------- layout: sticky sidebar + scrolling content ---------- */
.layout {
  max-width: 1400px; margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: clamp(32px, 5vw, 88px);
  padding: 0 clamp(16px, 5vw, 48px);
}
.sidebar {
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  padding: clamp(48px, 12vh, 100px) 0 clamp(28px, 5vh, 48px);
}
main { padding: clamp(48px, 12vh, 100px) 0 80px; }

/* ---------- sidebar: intro ---------- */
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: .95rem; }
.sidebar h1 { font-size: clamp(2.6rem, 4.5vw, 3.6rem); letter-spacing: -.02em; }
.wobble span { display: inline-block; transition: transform .35s cubic-bezier(.34,1.56,.64,1), color .3s; cursor: default; }
.wobble span.space { width: .25em; }
.wobble span:hover { transform: translateY(-.12em) rotate(-6deg); color: var(--accent); }
.wobble span:nth-child(even):hover { transform: translateY(-.1em) rotate(6deg); }
.wobble .dot { color: var(--accent); }
.lede { font-size: 1.05rem; max-width: 36ch; margin: 18px 0 0; color: var(--muted); }
.lede em { font-family: var(--serif); font-size: 1.08em; color: var(--fg); }

/* ---------- sidebar: nav ---------- */
.side-nav { display: flex; flex-direction: column; gap: 16px; margin-top: clamp(32px, 6vh, 56px); }
.side-nav a {
  display: flex; align-items: center; gap: 12px;
  font-size: .92rem; color: var(--muted);
  width: max-content; transition: color .2s;
}
.side-nav a::before {
  content: ''; width: 24px; height: 1px; background: var(--line);
  transition: width .3s cubic-bezier(.34,1.56,.64,1), background .2s;
}
.side-nav .num { font-size: .75rem; letter-spacing: .08em; color: var(--accent); }
.side-nav a:hover, .side-nav a.active { color: var(--fg); }
.side-nav a:hover::before, .side-nav a.active::before { width: 48px; background: var(--accent); }

/* ---------- sidebar: contact ---------- */
.side-contact { margin-top: auto; padding-top: 32px; }
.big { font-family: var(--serif); font-size: clamp(1.15rem, 1.8vw, 1.4rem); margin: 0 0 12px; }
.big a { background: linear-gradient(transparent 62%, var(--accent-2) 62%); }
.big a:hover { color: var(--accent); }
.contact-links { display: flex; gap: 16px; flex-wrap: wrap; margin: 0 0 16px; font-size: .9rem; }
.contact-links a {
  border-bottom: 1px solid var(--line); padding-bottom: 2px;
  transition: border-color .2s, color .2s;
}
.contact-links a:hover { border-color: var(--accent); color: var(--accent); }
.meta { display: flex; gap: 14px; margin: 0; font-size: .82rem; color: var(--muted); }

/* ---------- sections ---------- */
.section { padding: 0 0 72px; scroll-margin-top: 48px; }
.section h2 { font-size: clamp(1.6rem, 3vw, 2rem); margin-bottom: 28px; display: flex; align-items: baseline; gap: 14px; }
.num { font-family: var(--sans); font-size: .8rem; font-weight: 500; color: var(--accent); letter-spacing: .08em; }
.section-lede { margin: -18px 0 28px; color: var(--muted); font-style: italic; font-family: var(--serif); }

/* ---------- projects ---------- */
.pgroup { margin-bottom: 44px; }
.pgroup:last-child { margin-bottom: 0; }
.group-title {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 16px;
  font-family: var(--sans); font-size: .78rem; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.group-title::after { content: ''; flex: 1; height: 1px; background: var(--line); order: 1; }
.row-nav { display: flex; gap: 6px; order: 2; }
.row-nav button {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 1rem; line-height: 1; cursor: pointer;
  display: grid; place-items: center; padding: 0 0 2px;
  transition: color .2s, border-color .2s, background .2s;
}
.row-nav button:hover { color: var(--accent); border-color: var(--accent); background: var(--bg-2); }
.carousel {
  list-style: none; margin: 0; padding: 2px;
  display: flex; gap: 16px;
  overflow-x: auto; overscroll-behavior-x: contain;
  cursor: grab;
  scrollbar-width: none;             /* loop has no meaningful scrollbar */
}
.carousel::-webkit-scrollbar { display: none; }
.carousel:active { cursor: grabbing; }
.pcard {
  flex: 0 0 min(380px, 85%);
  border-radius: var(--radius); overflow: hidden;
  background: var(--bg-2); border: 1px solid var(--line);
  transition: transform .25s, border-color .25s;
}
.pcard:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.carousel:not(.in) .pcard { opacity: 0; }
.carousel.in .pcard {
  animation: cardrise .55s ease backwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes cardrise {
  from { opacity: 0; transform: translateY(14px); }
}
.pcard-top {
  aspect-ratio: 16/10; overflow: hidden; position: relative;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 70%, var(--bg)) 0%, color-mix(in srgb, var(--accent) 25%, var(--bg)) 100%);
}
.pcard-top::after {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(var(--bg) 1px, transparent 1px);
  background-size: 8px 8px; opacity: .35;
  transition: opacity .3s;
}
.pcard:hover .pcard-top::after { opacity: .15; }
.pcard-top video, .pcard-top img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  position: relative; z-index: 1;
  -webkit-user-drag: none; user-select: none;
}
.pcard-top.contain img { object-fit: contain; padding: 18px; }
.pcard-top .hint {
  position: absolute; right: 8px; bottom: 8px; z-index: 2;
  padding: 3px 9px; border-radius: 999px;
  font-size: .68rem; letter-spacing: .04em;
  color: #fff; background: rgba(0, 0, 0, .45); backdrop-filter: blur(3px);
  pointer-events: none; transition: opacity .25s;
}
.pcard:hover .hint { opacity: 0; }
@media (hover: none) {
  .hint { display: none; } /* touch screens autoplay the gif instead */
}
.pcard-body { padding: 14px 16px 16px; }
.context { margin: 0 0 4px; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.pcard-body h4 { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; margin: 0 0 8px; }
.pcard-body p { margin: 0 0 10px; }
.pdesc { font-size: .88rem; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tags span { font-size: .75rem; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.links { display: flex; gap: 14px; font-size: .9rem; }
.links a { color: var(--accent); }
.links a:hover { text-decoration: underline; }
.note { color: var(--muted); font-size: .85rem !important; font-style: italic; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); display: grid; gap: 26px; }
.timeline li { position: relative; display: grid; grid-template-columns: 130px 1fr; gap: 16px; }
.timeline li::before {
  content: ''; position: absolute; left: -25px; top: .45em;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
  transition: background .2s, transform .2s;
}
.timeline li:hover::before { background: var(--accent); transform: scale(1.3); }
.when { font-size: .85rem; color: var(--muted); padding-top: .15em; }
.timeline strong { display: block; font-family: var(--serif); font-size: 1.1rem; font-weight: 600; }
.timeline div span { display: block; font-size: .95rem; color: var(--muted); }

/* ---------- off-screen ---------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.card {
  padding: 22px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.card:hover { transform: rotate(-.6deg) translateY(-2px); }
.card:nth-child(even):hover { transform: rotate(.6deg) translateY(-2px); }
.card h3 { font-size: 1.35rem; margin-bottom: 8px; }
.card p { font-size: .95rem; margin: 0 0 14px; }
.mini-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.mini-list li { display: grid; grid-template-columns: 105px 1fr; gap: 10px; font-size: .88rem; }
.mini-list .when { padding-top: 0; }
.mini-list strong { font-weight: 600; }
.card .links { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gallery img { aspect-ratio: 1; border-radius: 8px; object-fit: cover; width: 100%; display: block; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar {
    position: static; height: auto;
    padding: clamp(48px, 10vh, 80px) 0 0;
  }
  .side-nav { display: none; }
  .side-contact { margin-top: 28px; padding-top: 0; }
  .meta { display: none; }
  main { padding-top: 56px; }
  .cards { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
  .carousel:not(.in) .pcard { opacity: 1; }
}
