/* ============================================================
   Dot-matrix greyscale design system — used by _layouts/dot-home.html
   Tokens: paper/ink greys only, no hue. Dark theme = negative print.
   ============================================================ */
:root {
  --paper:    #E9E8E4;
  --paper-2:  #F0EFEB;
  --ink:      #17171B;
  --ink-2:    #4E4E54;
  --ink-3:    #8E8E92;
  --ink-4:    #C9C8C3;
  --line:     #B9B8B3;
  --grid-dot: #D8D7D2;
  --scheme: light;
}
/* Dark = negative print, reachable only via the Invert toggle.
   Paper-light is the site's face regardless of OS preference.
   Raised surfaces go LIGHTER than the page in dark mode so cards
   and panels come forward instead of sinking into the void. */
/* native UI follows the chosen theme; an explicit light choice opts out of forced darkening */
:root[data-theme="light"] { color-scheme: only light; }
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="dark"] {
  --paper:    #121214;
  --paper-2:  #1A1A1E;
  --ink:      #E7E6E1;
  --ink-2:    #ABAAA6;
  --ink-3:    #77777C;
  --ink-4:    #3E3E44;
  --line:     #47474D;
  --grid-dot: #2B2B30;
  --scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1.2px);
  background-size: 26px 26px;
  color: var(--ink);
  font-family: ui-monospace, "JetBrains Mono", "IBM Plex Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--ink); color: var(--paper); }

a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--ink-3); }
a:hover { border-bottom-color: var(--ink); }
:focus-visible { outline: 2px dotted var(--ink); outline-offset: 3px; }

.wrap { max-width: 1060px; margin: 0 auto; padding: 0 22px; }
.muted { color: var(--ink-3); }
.dim   { color: var(--ink-2); }
.num   { font-variant-numeric: tabular-nums; }

/* ── Topnav ── */
.topnav {
  position: sticky; top: 0; z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.topnav .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; gap: 16px;
}
.brand { font-weight: 700; letter-spacing: 0.08em; border-bottom: none; font-size: 15px; }
.brand .sq { display: inline-block; width: 9px; height: 9px; background:
  radial-gradient(var(--ink) 34%, transparent 36%); background-size: 4.5px 4.5px; margin-right: 7px; }
.navlinks { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.navlinks a {
  border-bottom: none; padding: 5px 10px; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-2);
}
.navlinks a:hover { background: var(--ink); color: var(--paper); }

/* ── Buttons ── */
.btn {
  display: inline-block;
  border: 1px solid var(--ink);
  padding: 9px 16px; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  background: transparent; color: var(--ink); cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: transparent; color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: 10px; }

/* ── Hero ── */
.hero { padding: 56px 0 8px; }
.hero-grid { display: grid; grid-template-columns: 1fr 240px; gap: 48px; align-items: center; }
@media (max-width: 820px) { .hero-grid { grid-template-columns: 1fr; } .hero-grid > .card { max-width: 240px; } }

.name-row { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 18px; }
.name-canvas canvas { display: block; max-width: 100%; height: auto !important; }
.cursor {
  display: inline-block; width: 34px; height: 48px; flex: none; margin-bottom: 3px;
  background-image: radial-gradient(var(--ink) 34%, transparent 36%);
  background-size: 6.86px 6.86px;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cursor { animation: none; } }

.role { margin: 0 0 10px; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); }
.role a { color: var(--ink); border-bottom: 1px solid var(--ink-2); }
.role a:hover { border-bottom-color: var(--ink); }
.role a.role-btn { margin-left: 16px; vertical-align: 1px; border: 1px solid var(--ink); letter-spacing: 0.16em; }
.role a.role-btn:hover { background: transparent; color: var(--ink); }
.role a:not(.role-btn) { white-space: nowrap; }
@media (max-width: 560px) { .role a.role-btn { display: table; margin: 12px 0 0; } }
.thesis { margin: 0 0 24px; max-width: 52ch; font-size: 16.5px; line-height: 1.75; color: var(--ink); }

.defs { display: grid; grid-template-columns: repeat(3, auto); gap: 8px 36px; margin: 0 0 22px; width: fit-content; }
@media (max-width: 560px) { .defs { grid-template-columns: 1fr; } }
.defs dt { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 3px; }
.defs dd { margin: 0; font-size: 13px; }
.blinker { display: inline-block; width: 7px; height: 7px; background: var(--ink);
  margin-right: 7px; animation: blink 1.6s steps(1) infinite; }
@media (prefers-reduced-motion: reduce) { .blinker { animation: none; } }

.latest {
  margin: 0 0 26px; font-size: 11px; letter-spacing: 0.1em; color: var(--ink-3);
  text-transform: uppercase;
}
.latest b { color: var(--ink-2); font-weight: 600; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* portrait card */
.card { border: 1px solid var(--line); background: var(--paper-2); }
.card-head, .card-foot {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 12px; font-size: 10px; letter-spacing: 0.14em; color: var(--ink-3);
  text-transform: uppercase;
}
.card-head { border-bottom: 1px solid var(--line); }
.card-foot { border-top: 1px solid var(--line); }
.card-foot > div { display: flex; flex-direction: column; gap: 2px; }
.card-foot .v { color: var(--ink); font-size: 11px; letter-spacing: 0.04em; }
.portrait img { display: block; width: 100%; filter: grayscale(1); }

/* ── NOW strip ── */
.now {
  border: 1px solid var(--ink); background: var(--paper-2);
  padding: 14px 18px; margin: 0 0 8px;
}
.now h4 { margin: 0 0 6px; font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; }
.now p { margin: 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.7; max-width: 88ch; }

/* ── Sections ── */
.section { padding-top: 64px; padding-bottom: 10px; }
#work { padding-top: 40px; }
.sec-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding-bottom: 10px; margin-bottom: 28px;
  background-image: radial-gradient(var(--ink-3) 1.1px, transparent 1.3px);
  background-size: 7px 3px; background-position: 0 100%; background-repeat: repeat-x;
}
.sec-left { display: flex; align-items: center; gap: 12px; }
.sec-label { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-2); }
.sec-aside { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); text-align: right; }
.sec-title { font-size: 21px; font-weight: 700; margin: 0 0 14px; letter-spacing: 0.01em; }
.sec-title .prompt { color: var(--ink-3); margin-right: 8px; }
.lead { max-width: 68ch; color: var(--ink-2); margin: 0 0 28px; font-size: 13.5px; line-height: 1.8; }

/* ── Filter chips ── */
.chips { display: flex; gap: 0; flex-wrap: wrap; margin: 0 0 20px; }
.chips button {
  font-family: inherit; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  background: transparent; color: var(--ink-2); border: 1px solid var(--line);
  margin-right: -1px; padding: 6px 12px; cursor: pointer;
}
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ── Research layers: numbered stages joined by one dotted rule ── */
.stages { display: flex; gap: 14px; align-items: stretch; }
.stage { flex: var(--n, 1) 1 0; min-width: 0; display: flex; flex-direction: column; }
.stage-head {
  position: relative; padding-bottom: 12px; margin-bottom: 14px;
  background-image: radial-gradient(var(--ink-3) 1.1px, transparent 1.3px);
  background-size: 7px 3px; background-position: 0 100%; background-repeat: repeat-x;
}
.stage:not(:last-child) .stage-head::after {
  content: '\203A'; position: absolute; right: -11px; bottom: -8px; color: var(--ink-2); font-size: 14px;
}
.stage-num { font-size: 10px; letter-spacing: 0.2em; color: var(--ink-3); margin-right: 10px; }
.stage-title { font-size: 12px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }
.stage-line { margin: 6px 0 0; font-size: 11.5px; color: var(--ink-2); line-height: 1.6; min-height: 3.2em; }
.cards.stage-cards { grid-template-columns: repeat(var(--n, 1), 1fr); flex: 1; }
@media (max-width: 980px) {
  .stages { flex-direction: column; }
  .cards.stage-cards { grid-template-columns: repeat(2, 1fr); }
  .stage-line { min-height: 0; }
  .stage:not(:last-child) .stage-head::after { content: none; }
}
@media (max-width: 520px) { .cards.stage-cards { grid-template-columns: 1fr; } }

/* ── Collapsed section: earlier projects and tutorials ── */
.older { margin-top: 34px; }
.older > summary {
  list-style: none; cursor: pointer; display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px;
  font-size: 14px; font-weight: 700; color: var(--ink-2); padding: 10px 0;
  border-top: 1px dotted var(--line);
}
.older > summary::-webkit-details-marker { display: none; }
.older > summary:hover { color: var(--ink); }
.older > summary .caret { color: var(--ink-3); display: inline-block; transition: transform 0.15s; }
.older[open] > summary .caret { transform: rotate(90deg); }
.older > summary .count {
  font-weight: 400; font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3);
}
.older .cards { margin-top: 14px; }

/* ── Project cards ── */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 980px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .cards { grid-template-columns: 1fr; } }
.pcard { border: 1px solid var(--line); background: var(--paper-2); display: flex; flex-direction: column; }
.pcard:hover { border-color: var(--ink); }
.pcard[hidden] { display: none; }
.pcard .thumb {
  border-bottom: 1px solid var(--line); aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
a.thumb { cursor: pointer; }
.thumb-wrap { position: relative; }
.p-details { display: flex; flex-direction: column; gap: 8px; }
.p-detail { border-bottom: none; font-size: 10px; line-height: 1.4; color: var(--ink); }
.p-detail:hover { text-decoration: underline; }
.p-detail-kind {
  display: block; font-size: 8.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3);
}
.p-details-over {
  position: absolute; inset: 0; z-index: 2; overflow-y: auto;
  padding: 12px 14px; background: var(--paper-2); border-bottom: 1px solid var(--line);
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
.pcard.show-details .p-details-over { opacity: 1; pointer-events: auto; }
@media (hover: hover) {
  .pcard:hover .p-details-over, .pcard:focus-within .p-details-over { opacity: 1; pointer-events: auto; }
}
/* centred when the list fits, scrollable from the top when it does not */
.p-details-over > :first-child { margin-top: auto; }
.p-details-over > :last-child { margin-bottom: auto; }
.p-details-inline { display: none; }   /* kept for readers without CSS; touch screens tap the thumbnail instead */
.pcard .thumb { position: relative; }
.journal-badge {
  position: absolute; top: 10px; left: 10px; z-index: 1;
  font-size: 9px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink); background: var(--paper-2); border: 1px solid var(--ink); padding: 3px 7px;
}
a.thumb:hover { background: var(--paper); }
.pcard .thumb canvas { max-width: 100%; height: auto !important; display: block; }
.pcard .p-body { padding: 12px 13px 13px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.pcard .p-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pcard .p-title { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; }
.pcard .p-tag {
  font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3);
  border: 1px solid var(--line); padding: 2px 6px; white-space: nowrap;
}
.pcard .p-desc { font-size: 11px; color: var(--ink-2); line-height: 1.6; }
.pcard .p-meta { font-size: 10px; color: var(--ink-3); line-height: 1.5; letter-spacing: 0.03em; }
.pcard .p-links { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.pcard .p-links a {
  border: 1px solid var(--line); font-size: 9px; letter-spacing: 0.14em;
  padding: 3px 8px; color: var(--ink-2); text-transform: uppercase;
}
.pcard .p-links a:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pcard .p-links .nolink { font-size: 9px; letter-spacing: 0.14em; color: var(--ink-3); text-transform: uppercase; padding: 3px 0; }

/* ── Footer ── */
.footer { margin-top: 64px; border-top: 1px solid var(--line); }
.footer .foot-links { display: flex; gap: 8px; flex-wrap: wrap; }
.footer .wrap { align-items: center; }
.footer .wrap {
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding-top: 22px; padding-bottom: 34px;
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3);
}
