@font-face {
  font-family: 'Baloo 2';
  src: url('../fonts/baloo2.woff2') format('woff2');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Space Mono';
  src: url('../fonts/spacemono-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Space Mono';
  src: url('../fonts/spacemono-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------------- tokens ---------------- */

:root {
  /* the board the patches are pinned to */
  --board:        #f2e4c8;
  --board-deep:   #e6d3ae;
  --ink:          #2b1c08;
  --ink-soft:     #7c6746;
  --rule:         rgba(43, 28, 8, .14);

  /* felt swatches — physical colours, identical in both themes */
  --felt-mustard: #e8a83a;
  --felt-cream:   #f6f0e0;
  --felt-cream-lo:#ddd0ab;
  --navy:         #22233d;
  --navy-deep:    #0e0e1c;
  --navy-soft:    rgba(34, 35, 61, .42);
  --orange:       #f0854a;
  --pink:         #d8477e;
  --thread:       #faf4e4;
  --thread-ink:   rgba(34, 35, 61, .4);

  /* one shared macro photo of real felt, used as a grain map on every patch */
  --fiber: url('../img/felt-grain.png');
  --fiber-size: 240px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --board:      #1b1610;
    --board-deep: #110d08;
    --ink:        #f0e7d5;
    --ink-soft:   #ac9d80;
    --rule:       rgba(240, 231, 213, .14);
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--board);
  background-image: var(--fiber);
  background-repeat: repeat;
  background-size: var(--fiber-size) var(--fiber-size);
  color: var(--ink);
  font-family: 'Baloo 2', ui-rounded, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* the board gets a soft vignette so patches read as lit from above */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse 1200px 700px at 50% -8%, var(--board-deep), transparent 70%);
}

img { max-width: 100%; }

/* ---------------- shared felt patch ---------------- */

.felt {
  position: relative;
  background-color: var(--card-bg, var(--felt-cream));
  background-image: var(--fiber);
  background-repeat: repeat;
  background-size: var(--fiber-size) var(--fiber-size);
  border-radius: 20px;
  transform: var(--tilt, none);
  box-shadow:
    0 8px 16px -6px rgba(0, 0, 0, .3),
    0 3px 5px rgba(0, 0, 0, .15),
    inset 0 1px 0 rgba(255, 255, 255, .5);
}

/* topstitch, always set well inside the edge — never hugging it */
.felt::after {
  content: '';
  position: absolute;
  inset: 11px;
  border-radius: 10px;
  border: 2px dashed var(--card-border, var(--felt-cream-lo));
  pointer-events: none;
  z-index: 1;
}

/* ---------------- top bar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(14px, 4vw, 40px);
  background-color: var(--navy);
  background-image: var(--fiber);
  background-repeat: repeat;
  background-size: var(--fiber-size) var(--fiber-size);
  box-shadow: 0 4px 14px -4px rgba(0, 0, 0, .5);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--thread);
  font-size: 1.15rem;
  font-variation-settings: 'wght' 800;
  text-decoration: none;
  letter-spacing: .01em;
}

.topnav { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.topnav a {
  padding: 6px 13px;
  border-radius: 999px;
  color: var(--thread);
  font-size: .82rem;
  font-variation-settings: 'wght' 700;
  text-decoration: none;
  border: 1.5px dashed rgba(250, 244, 228, .3);
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
.topnav a:hover,
.topnav a:focus-visible {
  background-color: var(--felt-mustard);
  border-color: var(--felt-mustard);
  color: var(--navy);
}

.cube-link {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
  transition: transform .18s ease;
}
.cube-link img { width: 30px; height: 30px; display: block; }
.cube-link:hover { transform: rotate(12deg) scale(1.08); }

/* ---------------- page shell ---------------- */

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 clamp(14px, 4vw, 32px) 70px;
}

.section { padding-top: 62px; }

.section-title {
  margin: 0 0 8px;
  text-align: center;
  font-size: clamp(1.5rem, 3.4vw, 2rem);
  font-variation-settings: 'wght' 800;
  color: var(--ink);
  text-wrap: balance;
}
.section-lead {
  margin: 0 auto 30px;
  max-width: 56ch;
  text-align: center;
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: .82rem;
  line-height: 1.6;
  color: var(--ink-soft);
  text-wrap: balance;
}

/* ---------------- hero / about ---------------- */

.hero {
  --card-bg: var(--felt-mustard);
  --card-border: #c78d23;
  margin-top: 46px;
  padding: 34px clamp(20px, 4vw, 38px);
  border-radius: 28px;
}
.hero::after { inset: 13px; border-radius: 17px; }

.hero-inner {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}
@media (min-width: 760px) {
  .hero-inner { grid-template-columns: 210px minmax(0, 1fr); gap: 34px; align-items: center; }
}

.hero-photo {
  position: relative;
  width: 178px;
  justify-self: center;
  transform: rotate(-3.2deg);
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, .35));
}
.hero-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 50%;
  border: 5px solid var(--felt-cream);
}
.hero-photo::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px dashed rgba(250, 244, 228, .7);
  pointer-events: none;
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  font-variation-settings: 'wght' 800;
  color: var(--navy);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .3);
}
.hero p {
  margin: 0 0 12px;
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: .85rem;
  line-height: 1.62;
  color: var(--navy);
}
.hero p:last-of-type { margin-bottom: 0; }
/* scoped to prose links only — must not out-rank .btn on the contact row */
.hero p a { color: var(--navy); text-underline-offset: 3px; }

/* little felt nametags used for labelled rows */
.label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  padding: 5px 11px;
  border-radius: 9px;
  background-color: var(--felt-cream);
  background-image: var(--fiber);
  background-repeat: repeat;
  background-size: var(--fiber-size) var(--fiber-size);
  border: 1.5px dashed var(--felt-cream-lo);
  box-shadow: 0 3px 6px -2px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .5);
  font-size: .7rem;
  font-variation-settings: 'wght' 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--navy);
}

.hero-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

/* ---------------- felt buttons ---------------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 18px;
  border: 0;
  border-radius: 14px;
  background-color: var(--navy);
  background-image: var(--fiber);
  background-repeat: repeat;
  background-size: var(--fiber-size) var(--fiber-size);
  color: var(--orange);
  font-family: 'Baloo 2', sans-serif;
  font-size: .86rem;
  font-variation-settings: 'wght' 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--navy-deep), 0 7px 12px -5px rgba(0, 0, 0, .45);
  transition: transform .1s ease, box-shadow .1s ease;
}
.btn::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 8px;
  border: 1.5px dashed rgba(250, 244, 228, .32);
  pointer-events: none;
}
.btn > * { position: relative; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--navy-deep), 0 10px 15px -5px rgba(0, 0, 0, .45); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--navy-deep); }

.btn-light {
  background-color: var(--felt-cream);
  color: var(--navy);
  box-shadow: 0 4px 0 var(--felt-cream-lo), 0 7px 12px -5px rgba(0, 0, 0, .35);
}
.btn-light::before { border-color: var(--thread-ink); }
.btn-light:hover { box-shadow: 0 6px 0 var(--felt-cream-lo), 0 10px 15px -5px rgba(0, 0, 0, .35); }
.btn-light:active { box-shadow: 0 2px 0 var(--felt-cream-lo); }

.btn-sm { padding: 8px 14px; font-size: .78rem; border-radius: 12px; }
.btn-sm::before { inset: 5px; border-radius: 7px; }

/* ---------------- felt tags ---------------- */

.tag-row { position: relative; z-index: 2; display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  background-color: rgba(255, 255, 255, .5);
  background-image: var(--fiber);
  background-repeat: repeat;
  background-size: var(--fiber-size) var(--fiber-size);
  border: 1.5px dashed var(--navy-soft);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .14);
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: .64rem;
  font-weight: 700;
  color: var(--navy);
}

/* ---------------- research interests ---------------- */

.interests-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 30px 26px;
}

.interest-card { padding: 24px 22px; }
.interest-card > * { position: relative; z-index: 2; }
.interest-card h3 {
  margin: 0 0 9px;
  font-size: 1.12rem;
  font-variation-settings: 'wght' 700;
  color: var(--navy);
}
.interest-card p {
  margin: 0 0 14px;
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: .78rem;
  line-height: 1.6;
  color: var(--navy);
}
.interest-card .btn { margin-top: 16px; }

/* ---------------- projects ---------------- */

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 32px 26px;
}

.project-card { overflow: hidden; border-radius: 18px; }
.project-card::after { inset: 9px; border-radius: 11px; }

.project-thumb {
  display: block;
  width: 100%;
  height: 158px;
  object-fit: cover;
  object-position: center;
  background: #ebebe7;
  border-bottom: 2px dashed var(--card-border, var(--felt-cream-lo));
}

.project-body { position: relative; z-index: 2; padding: 16px 18px 18px; }
.project-body h3 {
  margin: 0 0 7px;
  font-size: 1rem;
  font-variation-settings: 'wght' 700;
  color: var(--navy);
}
.project-body p {
  margin: 0 0 12px;
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: .75rem;
  line-height: 1.55;
  color: var(--navy);
}
.project-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ---------------- CV ---------------- */

.cv-stack { display: grid; gap: 26px; }

.cv-card { padding: 24px 22px; }
.cv-card > * { position: relative; z-index: 2; }
.cv-card h3 {
  margin: 10px 0 2px;
  font-size: 1.05rem;
  font-variation-settings: 'wght' 700;
  color: var(--navy);
}
.cv-org {
  display: inline-block;
  margin-bottom: 10px;
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: .78rem;
  font-weight: 700;
  color: var(--navy);
  text-underline-offset: 3px;
}
.cv-card ul { margin: 0; padding-left: 18px; }
.cv-card li {
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: .76rem;
  line-height: 1.6;
  color: var(--navy);
  margin-bottom: 5px;
}
.cv-card p {
  margin: 0 0 10px;
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: .76rem;
  line-height: 1.6;
  color: var(--navy);
}
.cv-card a { color: var(--navy); }
.cv-group { margin-bottom: 12px; }
.cv-group:last-child { margin-bottom: 0; }

.talks { list-style: none; padding: 0; margin: 0; display: grid; gap: 11px; }
.talks li {
  margin: 0;
  padding-left: 15px;
  border-left: 2px dashed var(--navy-soft);
}
.talks .talk-when { font-weight: 700; display: block; }

/* ---------------- personal / collapsible ---------------- */

.more { margin-top: 62px; }

.more > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
  padding: 15px 22px;
  border-radius: 16px;
  background-color: var(--felt-mustard);
  background-image: var(--fiber);
  background-repeat: repeat;
  background-size: var(--fiber-size) var(--fiber-size);
  color: var(--navy);
  font-size: 1rem;
  font-variation-settings: 'wght' 700;
  text-align: center;
  box-shadow: 0 5px 0 #c78d23, 0 9px 16px -6px rgba(0, 0, 0, .4);
  transform: rotate(-.8deg);
  transition: transform .12s ease;
}
.more > summary::-webkit-details-marker { display: none; }
.more > summary:hover { transform: rotate(-.8deg) translateY(-2px); }
.more > summary::after {
  content: '▾';
  font-size: .9rem;
  transition: transform .2s ease;
}
.more[open] > summary::after { transform: rotate(180deg); }

.more-body { padding-top: 12px; }

/* ---------------- media grids (albums / movies / games) ---------------- */

.media-grid {
  display: grid;
  gap: 26px 20px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.media-grid.is-wide { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }

.media-card {
  overflow: hidden;
  border-radius: 16px;
  padding: 0;
  border: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  display: block;
}
.media-card::after { inset: 8px; border-radius: 9px; }
button.media-card { cursor: pointer; }

.media-card img {
  display: block;
  width: 100%;
  object-fit: cover;
  border-bottom: 2px dashed var(--card-border, var(--felt-cream-lo));
}
.media-card.ratio-square img { aspect-ratio: 1 / 1; }
.media-card.ratio-poster img { aspect-ratio: 1000 / 1482; }
.media-card.ratio-cover img  { aspect-ratio: 100 / 120; }

.media-meta { position: relative; z-index: 2; display: block; padding: 11px 13px 14px; }
.media-title {
  display: block;
  margin: 0 0 5px;
  font-family: 'Baloo 2', sans-serif;
  font-size: .86rem;
  font-variation-settings: 'wght' 700;
  color: var(--navy);
  overflow-wrap: break-word;
}
.media-sub {
  display: block;
  margin: 0;
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: .66rem;
  line-height: 1.55;
  color: var(--navy);
}
.media-sub strong { font-weight: 700; }

/* ---------------- dialogs ---------------- */

dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}
dialog::backdrop { background: rgba(20, 12, 2, .62); }

.dialog-felt {
  --card-bg: var(--felt-cream);
  --card-border: var(--felt-cream-lo);
  padding: 24px 22px;
  border-radius: 20px;
}
.dialog-felt > * { position: relative; z-index: 2; }
.dialog-felt h3 {
  margin: 0 0 14px;
  padding-right: 40px;
  font-size: 1.12rem;
  font-variation-settings: 'wght' 800;
  color: var(--navy);
}
.dialog-felt h4 {
  margin: 0 0 4px;
  font-size: .95rem;
  font-variation-settings: 'wght' 700;
  color: var(--navy);
}
.dialog-felt p {
  margin: 0;
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: .78rem;
  line-height: 1.6;
  color: var(--navy);
}
.dialog-tip { margin-bottom: 18px; }
.dialog-tip:last-child { margin-bottom: 0; }

.dialog-close {
  position: absolute;
  z-index: 3;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--navy);
  color: var(--thread);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 6px -2px rgba(0, 0, 0, .5);
}
.dialog-close:hover { background: var(--pink); }

.dialog-felt iframe {
  display: block;
  width: 100%;
  height: 380px;
  border: 0;
  border-radius: 12px;
}

/* ---------------- footer ---------------- */

.site-footer {
  margin-top: 74px;
  padding: 26px clamp(14px, 4vw, 32px) 34px;
  background-color: var(--navy);
  background-image: var(--fiber);
  background-repeat: repeat;
  background-size: var(--fiber-size) var(--fiber-size);
  text-align: center;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.footer-note {
  margin: 20px 0 0;
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: .7rem;
  color: rgba(250, 244, 228, .58);
}

/* ---------------- focus + motion ---------------- */

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px dashed var(--pink);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; justify-content: center; }
  .topnav { justify-content: center; order: 3; width: 100%; }
  .section { padding-top: 48px; }
}
