:root {
  --bg: #000;
  --fg: #fff;
  --text: #e5e5e5;
  --muted: #a3a3a3;
  --faint: #6b6b6b;
  --line: #1f1f1f;
  --border: #333;
  --underline: #555;
  --pill-bg: #1c1c1c;
  --pill-fg: #d4d4d4;
  --dim: rgba(0, 0, 0, 0.78);
  --emblem: invert(1); /* emblem is dark line art; flip it on the black page */
  --green: #22c55e;
  --glow: #22d3ee; /* dot-field accent */
  --yc: #f26522;
}

:root[data-theme="light"] {
  --bg: #fff;
  --fg: #0a0a0a;
  --text: #262626;
  --muted: #525252;
  --faint: #8a8a8a;
  --line: #e5e5e5;
  --border: #d4d4d4;
  --underline: #b5b5b5;
  --pill-bg: #f0f0f0;
  --pill-fg: #404040;
  --dim: rgba(255, 255, 255, 0.82);
  --emblem: none;
  --green: #16a34a;
  --glow: #0891b2;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 24px 64px;
}

/* ---------- header ---------- */
/* the header plus the gap below it; the dot field fills it behind the text */
.hero { position: relative; padding-bottom: 124px; }
.hero .dot-field { position: absolute; inset: 0; height: 100%; }
.header { position: relative; z-index: 1; pointer-events: none; }
.header > * { pointer-events: auto; }
.header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.header-actions { display: flex; gap: 8px; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  position: relative;
  z-index: 2;
  background: var(--bg); /* solid so the dot field never shows through */
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, background-color .3s ease;
}
.icon-btn:hover { color: var(--fg); border-color: var(--muted); }
.icon-btn:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; }
/* show the icon for the theme you'd switch to */
.theme-toggle .icon-moon, :root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }
.name { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.role { font-size: 19px; color: var(--muted); line-height: 1.3; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(260px, 300px) 1fr;
  gap: 40px;
}

.intro { border-top: 1px solid var(--line); padding-top: 28px; } /* matches .section top padding */

.bio {
  font-size: 20px;
  line-height: 1.4;
  padding: 0 4px;
  min-height: 9.8em; /* reserve space so layout doesn't jump while typing */
  white-space: pre-line;
}

.cursor {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  background: var(--fg);
  vertical-align: -0.15em;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.contact-block { margin-top: 48px; }
.contact-title { display: none; } /* mobile only, where the links move to the bottom */
.contact li {
  border-top: 1px solid var(--line);
  padding: 8px 4px;
  font-size: 12px;
}
.contact li:last-child { border-bottom: 1px solid var(--line); }
.contact a { transition: color .15s; }
.contact a:hover { color: var(--muted); }
.arrow { font-size: 0.85em; }
.underline { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--underline); }

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

.section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 28px 0 32px;
  border-bottom: 1px solid var(--line);
}
.section:last-child { border-bottom: 0; }

.section-head { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.section-head h2 { font-size: 14px; font-weight: 500; }
.view-all { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: 13px; transition: color .15s; }
.view-all:hover { color: var(--fg); }

.writings { display: flex; flex-direction: column; gap: 8px; }
.writings time { color: var(--faint); font-size: 11px; margin-left: 8px; white-space: nowrap; }

.entries { display: flex; flex-direction: column; gap: 22px; }
.title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
}
.entries p { margin-top: 4px; color: var(--text); }
.job-role { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.job-role + p { margin-top: 2px; }
.location { color: var(--faint); }
.location::before { content: "·"; margin: 0 6px; }

/* hover pop */
.item {
  transform-origin: left center;
  transition: transform .2s ease, opacity .2s ease;
}
.item:hover { transform: translateX(4px) scale(1.025); }
.sections ul:hover .item:not(:hover) { opacity: 0.5; }

/* ---------- role details ---------- */
.has-details { cursor: pointer; }
.more {
  position: relative;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s;
}
.more::before, .more::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 8px;
  height: 1px;
  background: currentColor;
  transform: translate(-50%, -50%);
  transition: transform .2s ease;
}
.more::after { transform: translate(-50%, -50%) rotate(90deg); }
.has-details:hover .more, .more:focus-visible { border-color: var(--muted); color: var(--fg); }
.more[aria-expanded="true"]::before { transform: translate(-50%, -50%) rotate(45deg); }
.more[aria-expanded="true"]::after { transform: translate(-50%, -50%) rotate(135deg); }
.more:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; }

/* inline expand; animates height via grid rows */
.details {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .3s ease;
}
.details-inner { overflow: hidden; visibility: hidden; transition: visibility 0s .3s; }
.item.open .details { grid-template-rows: 1fr; }
.item.open .details-inner { visibility: visible; transition-delay: 0s; }
.item.open .details-inner > :first-child { margin-top: 16px; }

.detail-group + .detail-group { margin-top: 18px; }
.details-inner { max-width: 560px; }
.detail-group h3 { font-size: 13px; font-weight: 600; }
.dur { margin-left: 6px; color: var(--faint); font-weight: 400; }
.detail-group h4 { margin-top: 10px; color: var(--muted); font-size: 12px; font-weight: 500; }
.detail-group ul { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.detail-group li {
  position: relative;
  padding-left: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.detail-group li::before { content: "→"; position: absolute; left: 0; color: var(--faint); }
.detail-group li li::before { content: "·"; left: 4px; }
.detail-group li ul { margin-top: 4px; gap: 3px; }
.detail-group b { color: var(--fg); font-weight: 500; }
.name-tag { color: var(--text); font-weight: 500; }
.detail-link { display: inline-block; margin-top: 16px; font-size: 13px; transition: color .15s; }
.detail-link:hover { color: var(--muted); }

/* lights down: dims the rest of the page while a role is expanded */
.dimmer {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--dim);
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s ease, visibility 0s .35s;
}
.lights-down .dimmer { opacity: 1; visibility: visible; transition-delay: 0s; }
.item.open { position: relative; z-index: 11; }

/* badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--pill-bg);
  color: var(--pill-fg);
  font-size: 11px;
  font-weight: 400;
}
.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; box-shadow: none; }
}

.yc {
  display: inline-grid;
  place-items: center;
  width: 13px;
  height: 13px;
  background: var(--yc);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
}
.meta { color: var(--muted); font-size: 11px; font-weight: 400; margin-left: -3px; }
.rainmatter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 500;
  color: var(--text);
}

.logo { border-radius: 3px; }
.school {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}
.school img { filter: var(--emblem); }

/* ---------- footer ---------- */
.footer { margin-top: 96px; border-top: 1px solid var(--line); }
.dot-field { display: block; width: 100%; height: 260px; cursor: crosshair; }
/* allow scrolling and pinch, but not double-tap zoom, so fast taps just make ripples */
.hero, .hero *, .footer, .footer * { touch-action: manipulation; }
.footer-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  color: var(--faint);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  top: 20px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 10px 18px 10px 14px;
  border: 1px solid color-mix(in srgb, var(--glow) 55%, transparent);
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--fg);
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--glow) 12%, transparent), 0 10px 30px rgba(0, 0, 0, .35);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -16px);
  transition: opacity .25s ease, transform .35s cubic-bezier(.22, .61, .36, 1), visibility 0s .35s;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
.toast-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 10px var(--glow);
  animation: pulse 1.4s ease-in-out infinite;
}

/* ---------- tablet ---------- */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr 1fr; gap: 40px; }
  .hero { padding-bottom: 110px; }
  .section { grid-template-columns: 1fr; gap: 20px; }
  .section-head { flex-direction: row; align-items: baseline; gap: 12px; }
}

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .page { padding: 20px 16px 48px; }
  .name { font-size: 22px; }
  .role { font-size: 17px; }
  .layout { grid-template-columns: 1fr; gap: 48px; }
  .hero { padding-bottom: 64px; }
  /* unwrap the intro so the contact links can drop below the last section */
  .intro { display: contents; }
  .bio { font-size: 17px; min-height: 0; border-top: 1px solid var(--line); padding-top: 28px; }
  .contact-block { order: 1; margin-top: -48px; padding-top: 28px; border-top: 1px solid var(--line); }
  .contact-title { display: block; margin-bottom: 20px; font-size: 14px; font-weight: 500; }
  .footer { margin-top: 64px; }
  .toast { gap: 8px; padding: 8px 12px 8px 10px; font-size: 12px; }
  .toast-dot { width: 7px; height: 7px; }
  .dot-field { height: 200px; }
  .dates { display: block; }
  .dates::before { content: none; }
  .item:hover { transform: none; }
  .sections ul:hover .item:not(:hover) { opacity: 1; }
}

@media (max-width: 370px) {
  .toast { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor, .dot, .toast-dot { animation: none; }
  .item, .details, .details-inner, .dimmer, .toast, .more::before, .more::after { transition: none; }
  .item:hover { transform: none; }
}

.print-only { display: none; }

/* ---------- print / PDF resume ----------
   light theme, A4, all role details expanded, decoration stripped */
@media print {
  @page { size: A4; margin: 14mm 15mm 16mm; }
  :root, :root[data-theme="light"] {
    --bg: #fff;
    --fg: #0a0a0a;
    --text: #262626;
    --muted: #4a4a4a;
    --faint: #6b6b6b;
    --line: #e2e2e2;
    --pill-bg: #f0f0f0;
    --pill-fg: #404040;
    --underline: #9a9a9a;
    --emblem: none;
    --green: #16a34a;
  }
  html, body { background: #fff; }
  body { font-size: 9.5pt; line-height: 1.45; transition: none; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .page { max-width: none; padding: 0; }
  .screen-only { display: none !important; }
  .print-only { display: inline; }
  li.print-only { display: list-item; }
  .dot-field, .header-actions, .more, .dimmer, .toast, .cursor, .footer, .contact-title { display: none !important; }

  .hero { padding-bottom: 0; }
  .header { display: block; }
  .name { font-size: 20pt; }
  .role { font-size: 11pt; }

  .layout { display: block; margin-top: 4mm; }
  .intro { display: block; border-top: 0; padding-top: 0; }
  .bio { font-size: 10pt; line-height: 1.45; min-height: 0; padding: 0; border: 0; color: var(--text); }
  .contact-block { margin-top: 3mm; padding: 0; border: 0; }
  .contact { display: flex; flex-wrap: wrap; gap: 2mm 6mm; }
  .contact li, .contact li:last-child { border: 0; padding: 0; font-size: 9.5pt; }
  .contact a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--underline); }

  .sections { margin-top: 5mm; }
  .section { grid-template-columns: 24mm 1fr; gap: 4mm; padding: 4mm 0; }
  .section-head { flex-direction: column; gap: 1mm; }
  .section-head h2 { font-size: 10pt; font-weight: 600; }
  .view-all { font-size: 8.5pt; }
  .entries { gap: 3.5mm; }
  .title { font-size: 10.5pt; gap: 5px; }
  .job-role { font-size: 9pt; }
  .entries p { font-size: 9.5pt; margin-top: 1mm; }
  .writings { gap: 1.5mm; }
  .writings time { font-size: 8pt; }
  .pill { font-size: 7.5pt; padding: 1px 5px; }
  .dot { animation: none; box-shadow: none; }

  /* every role's details, open */
  .details { grid-template-rows: 1fr !important; }
  .details-inner { visibility: visible !important; max-width: none; }
  .details-inner > :first-child { margin-top: 2.5mm; }
  .detail-group + .detail-group { margin-top: 2.5mm; }
  .detail-group h3 { font-size: 9.5pt; }
  .detail-group ul { gap: 1mm; margin-top: 1mm; }
  .detail-group li { font-size: 9pt; color: var(--text); }
  .detail-link { margin-top: 2mm; font-size: 9pt; }

  .item { transform: none !important; opacity: 1 !important; break-inside: avoid; }
  .item.has-details { break-inside: auto; }
  .detail-group li, .item > .title, .job-role { break-inside: avoid; }
  .title, .section-head { break-after: avoid; }
}
