:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #6b6b6b;
  --accent: #0099ff;        /* farza blue */
  --accent-soft: #bfe2ff;
  --rule: #ececec;
  --card: #f6f6f6;
  --veil: rgba(255,255,255,.75);
  --veil-strong: rgba(252,251,249,.9);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e0e10;
  --fg: #ececea;
  --muted: #9b9b9b;
  --accent: #4db5ff;
  --accent-soft: #1b3a55;
  --rule: #262629;
  --card: #18181b;
  --veil: rgba(14,14,16,.78);
  --veil-strong: rgba(14,14,16,.9);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.68;
  margin: 0;
  padding: 56px 20px 110px;
}
main { max-width: 620px; margin: 0 auto; }

.name {
  font-family: "Manrope", "Inter", sans-serif;
  font-weight: 800;
  font-size: 40px;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.tagline { color: var(--muted); font-size: 18px; margin: 0 0 24px; }

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 14px;
  font-weight: 600;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 8px;
}
nav a { color: var(--muted); text-decoration: none; }
nav a:hover { color: var(--accent); }

p { margin: 0 0 20px; }
em { font-style: italic; }
a { color: var(--accent); text-decoration: none; }
a.link:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .86em; background: var(--card); padding: 1px 5px; border-radius: 4px; }

.section {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 54px 0 16px;
  scroll-margin-top: 24px;
}
.lede { color: var(--muted); font-size: 15px; margin-top: -6px; }

.now { list-style: none; padding: 0; margin: 0 0 12px; }
.now li { padding: 3px 0 3px 18px; position: relative; }
.now li::before { content: "→"; position: absolute; left: 0; color: var(--accent); }
.stamp { font-size: 13px; color: var(--muted); }

.proj { margin: 0 0 26px; }
.proj h2 {
  font-family: "Manrope", "Inter", sans-serif;
  font-weight: 700; font-size: 20px;
  margin: 0 0 2px; letter-spacing: -0.01em;
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
}
.proj .tag { color: var(--muted); font-weight: 400; font-size: 17px; font-family: "Inter", sans-serif; }
.when { color: var(--muted); font-weight: 500; font-size: 13px; font-family: "Inter", sans-serif; white-space: nowrap; }
.proj p { margin: 0; }
.links { font-size: 13px; font-weight: 600; margin-top: 6px !important; }
.links a { margin-right: 14px; }

/* writing list */
.posts { list-style: none; padding: 0; margin: 0; }
.posts li { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 6px 0; }
.posts .ph { color: var(--muted); font-style: italic; }

hr { border: none; border-top: 1px solid var(--rule); margin: 54px 0; }

.draft {
  border-left: 3px solid var(--accent);
  background: var(--card);
  padding: 14px 18px;
  border-radius: 0 8px 8px 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 20px;
}
.draft strong { color: var(--accent); }

/* things i like */
.likes { display: grid; grid-template-columns: 1fr 1fr; gap: 24px 32px; }
.likes h3 { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.likes ul { margin: 0; padding: 0; list-style: none; }
.likes li { padding: 3px 0; }
.likes li span { color: var(--muted); }
.likes .ph { color: var(--muted); font-style: italic; }
@media (max-width: 520px) { .likes { grid-template-columns: 1fr; } }

/* photos */
.photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.photos figure { margin: 0; }
.photos img, .photos .ph-tile {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: 8px; display: block; background: var(--card);
}
.photos .ph-tile {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px; text-align: center; padding: 10px;
  border: 1px dashed #d8d8d8;
}
.photos figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }
@media (max-width: 460px) { .photos { grid-template-columns: 1fr; } }

/* forms (used by the private section) */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lock input {
  font-family: inherit; font-size: 15px;
  background: var(--card); color: var(--fg);
  border: 1px solid var(--rule); border-radius: 8px;
  padding: 10px 12px; width: 100%;
}
.btn {
  font-family: inherit; font-size: 14px; font-weight: 600;
  background: var(--fg); color: var(--bg);
  border: none; border-radius: 8px; padding: 10px 18px; cursor: pointer;
}
.btn:hover { background: var(--accent); color: #fff; }

/* private */
.lock { background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: 20px; }
.lock-row { display: flex; gap: 8px; }
.lock input { background: var(--bg); flex: 1; }
.lock .hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
#lock-err { color: #c0392b; font-size: 13px; margin-top: 8px; min-height: 1em; }
#private-content { display: none; }

footer { color: var(--muted); font-size: 15px; }
::selection { background: var(--accent); color: #fff; }

/* essay pages */
.back { font-size: 14px; font-weight: 600; display: inline-block; margin-bottom: 36px; }
.essay h1 {
  font-family: "Manrope", "Inter", sans-serif;
  font-weight: 800; font-size: 32px; line-height: 1.15;
  letter-spacing: -0.02em; margin: 0 0 8px;
}
.essay .byline { color: var(--muted); font-size: 14px; margin: 0 0 36px; }
.essay h2 {
  font-family: "Manrope", "Inter", sans-serif;
  font-weight: 700; font-size: 21px; margin: 40px 0 10px;
}
.essay ul { padding-left: 20px; margin: 0 0 20px; }
.essay li { margin: 0 0 8px; }
.table-wrap { overflow-x: auto; margin: 0 0 24px; }
.essay table { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 1.5; }
.essay th, .essay td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.essay th { font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.essay td code { white-space: nowrap; }

/* photo at the end of a piece */
.inline-fig { margin: 8px 0 28px; width: 240px; max-width: 100%; }
.inline-fig img { width: 100%; height: auto; border-radius: 8px; display: block; }
.inline-fig figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* photo stickers (scatter.js) */
a.burst {
  text-decoration: underline wavy var(--accent);
  text-decoration-thickness: 1.5px; text-underline-offset: 4px;
  cursor: pointer;
}
a.burst:hover { text-decoration-color: var(--fg); }
a.burst--done { cursor: default; }
a.burst--done:hover { text-decoration-color: var(--accent); }

.sticker-layer { position: absolute; top: 0; left: 0; width: 100%; height: 0; z-index: 40; pointer-events: none; }
.print {
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  position: absolute; margin: 0;
  transform: translate(-50%, -50%) rotate(var(--tilt));
  pointer-events: auto; cursor: grab; touch-action: none; user-select: none;
  animation: stickerIn 620ms var(--spring) both;
}
.print__photo { display: block; height: auto; pointer-events: none; }
.print[data-dragging] {
  cursor: grabbing; animation: none;
  transform: translate(-50%, -50%) rotate(var(--tilt)) scale(1.04);
}

.print--polaroid {
  padding: 12px 12px 0;
  background: linear-gradient(180deg, #fbf8f1 0%, #f2ece2 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.72) inset, 0 1px 2px rgba(46,38,28,.1), 0 16px 32px rgba(46,38,28,.22);
}
.print--polaroid .print__photo { box-shadow: inset 0 0 0 1px rgba(40,32,24,.08); }
/* captions flow under the photo, as wide as it, and the frame grows to fit them */
.print figcaption {
  display: block; box-sizing: border-box; text-align: center;
  font-size: 11.5px; line-height: 15px; color: #4a4339;
  padding: 9px 4px 8px; overflow-wrap: break-word;
}
.print--polaroid figcaption { min-height: 38px; }
.print--tape { padding: 7px 7px 0; background: #fffaf3; box-shadow: 0 12px 26px rgba(46,38,28,.2); }
.print--tape::before, .print--tape::after {
  content: ""; position: absolute; width: 46px; height: 18px; pointer-events: none; mix-blend-mode: multiply;
}
.print--tape::before { top: -7px; left: 14px; transform: rotate(-18deg); background: rgba(255, 214, 102, .6); }
.print--tape::after { top: -5px; right: 16px; transform: rotate(12deg); background: rgba(0, 153, 255, .28); }
.print--torn {
  padding: 9px 9px 0; background: #f7f1e6;
  clip-path: polygon(1.5% 2.8%, 8% .4%, 19% 2.2%, 31% .6%, 44% 2.4%, 58% .3%, 71% 2.1%, 84% .5%, 94% 2.6%, 99% 1.2%,
    98.4% 14%, 100% 28%, 98.2% 42%, 100% 57%, 98.6% 71%, 99.4% 86%, 97.8% 99%, 86% 97.6%, 72% 99.4%, 58% 97.2%,
    44% 99.5%, 31% 97.4%, 18% 99.2%, 6% 97.8%, .6% 99%, 0% 84%, 1.8% 68%, 0% 52%, 1.6% 36%, .2% 21%, 1.2% 8%);
  filter: drop-shadow(0 14px 18px rgba(46,38,28,.22));
}
.print--ink {
  padding: 9px 9px 0; background: #f4efe4;
  border: 2px solid #1c1710; border-radius: 3px 9px 4px 8px / 7px 3px 9px 4px;
  box-shadow: 3px 4px 0 #1c1710, 0 14px 24px rgba(28,22,16,.16);
}

@keyframes stickerIn {
  from { opacity: 0; transform: translate(-50%, -50%) rotate(0deg) scale(.6); }
  60% { opacity: 1; }
  to { opacity: 1; transform: translate(-50%, -50%) rotate(var(--tilt)) scale(1); }
}

@media (prefers-reduced-motion: reduce) { .print { animation: none !important; } }

/* research charts (research/*.html, built by tools/build_research.py) */
.chart { width: 100%; height: auto; display: block; margin: 0 0 6px; overflow: visible; }
.chart text { font-family: "Inter", system-ui, sans-serif; }
.chart [data-tip] { cursor: default; }
.chart circle[data-tip]:hover, .chart circle[data-tip]:focus { stroke: var(--fg); stroke-width: 2.5; outline: none; }
.chart rect[data-tip]:hover, .chart rect[data-tip]:focus { fill: rgba(10,132,224,.05); outline: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.data { margin: 0 0 32px; }
.data summary { font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; padding: 4px 0; }
.data summary:hover { color: var(--accent); }
.data .table-wrap { max-height: 340px; overflow: auto; margin-top: 8px; }
.data table { font-size: 13px; }
.data th { position: sticky; top: 0; background: var(--bg); }
.tip {
  position: fixed; z-index: 2000; max-width: 300px; pointer-events: none;
  background: var(--fg); color: var(--bg); font-size: 13px; line-height: 1.45;
  padding: 8px 11px; border-radius: 7px; opacity: 0; transition: opacity .12s ease;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.tip.on { opacity: 1; }

/* project screenshot */
.shot { margin: 12px 0 0; }
.shot img { width: 100%; height: auto; display: block; border: 1px solid var(--rule); border-radius: 8px; }
.shot figcaption { font-size: 13px; color: var(--muted); margin-top: 7px; }
.hint-click { color: var(--muted); font-weight: 400; font-size: 13px; }
.proj h2 a.burst { color: var(--fg); }
.proj h2 a.burst:hover { color: var(--accent); }

/* tap a print to see it big */
.print-shade {
  position: fixed; inset: 0; z-index: 45; background: rgba(255,255,255,0);
  backdrop-filter: blur(0px); transition: background .25s ease, backdrop-filter .25s ease;
}
.print-shade.on { background: var(--veil); backdrop-filter: blur(5px); }
.print[data-zoomed] {
  /* stickerIn runs with fill-mode:both, and an animation outranks inline styles,
     so it has to be switched off or the tilt sticks while zoomed. */
  animation: none !important;
  position: fixed; z-index: 60; cursor: zoom-out;
  transform: translate(-50%, -50%) rotate(0deg);
  box-shadow: 0 30px 70px rgba(0,0,0,.3);
  max-height: 92vh; overflow: auto;
}
.print[data-zoomed] figcaption { white-space: normal; }

/* deck mode: project screenshots take over the screen, scroll to dismiss */
.deck {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(255,255,255,0); backdrop-filter: blur(0);
  transition: background .3s ease, backdrop-filter .3s ease, opacity .35s ease;
}
.deck.on { background: var(--veil-strong); backdrop-filter: blur(7px); }
.deck.out { opacity: 0; pointer-events: none; }
.deck .deck-card { position: absolute; }
.deck-hint {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 52;
  font-size: 13px; color: var(--muted); background: var(--bg);
  border: 1px solid var(--rule); border-radius: 999px; padding: 6px 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.07); pointer-events: none;
}

/* project pages */
.essay.wide { max-width: 760px; }
.try { margin: 28px 0 40px; }
.try iframe {
  width: 100%; height: 620px; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--card); display: block;
}
.essay pre {
  background: var(--card); border: 1px solid var(--rule); border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; font-size: 13.5px; line-height: 1.6; margin: 0 0 20px;
}
.essay pre code { background: none; padding: 0; font-size: inherit; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 24px; }
.steps li {
  counter-increment: step; position: relative; padding: 0 0 0 38px; margin: 0 0 18px;
}
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 1px;
  width: 24px; height: 24px; border-radius: 50%; background: var(--fg); color: var(--bg);
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.callout {
  border-left: 3px solid var(--accent); background: var(--card);
  padding: 14px 18px; border-radius: 0 8px 8px 0; margin: 0 0 24px; font-size: 15px;
}
.req { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; padding: 0; list-style: none; }
.req li {
  font-size: 13px; font-weight: 600; background: var(--card);
  border: 1px solid var(--rule); border-radius: 999px; padding: 5px 13px;
}

/* clear loose photos */
.clear-photos {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 44;
  font: 600 13px "Inter", sans-serif; color: var(--fg);
  background: var(--bg); border: 1px solid var(--rule); border-radius: 999px;
  padding: 8px 17px; cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.1);
}
.clear-photos:hover { color: var(--accent); border-color: var(--accent); }
.print[data-leaving] { animation: stickerOut 440ms cubic-bezier(.4,0,.85,.4) var(--stagger,0ms) both; }
@keyframes stickerOut {
  from { opacity: 1; transform: translate(-50%,-50%) rotate(var(--tilt)) scale(1); }
  to { opacity: 0; transform: translate(-50%, calc(-50% + 52px)) rotate(calc(var(--tilt) + 14deg)) scale(.7); }
}

/* collapsible section */
details.more { margin: 10px 0 0; }
details.more > summary {
  cursor: pointer; list-style: none;
  font-size: 15px; font-weight: 600; color: var(--accent);
  padding: 8px 0; display: inline-block;
}
details.more > summary::-webkit-details-marker,
details.more > summary::marker { display: none; content: ""; }
details.more > summary:hover { text-decoration: underline; }
details.more .when-open { display: none; color: var(--muted); font-weight: 500; }
details.more[open] .when-open { display: inline; }
details.more[open] .when-closed { display: none; }
details.more > .more-body { margin-top: 6px; }
/* centred variant: the toggle sits in the middle of the column, like a page break */
details.more.center > summary { display: block; width: fit-content; margin: 4px auto 0;
  padding: 7px 18px; border: 1px solid var(--rule); border-radius: 999px; font-size: 14px; }
details.more.center > summary:hover { text-decoration: none; border-color: var(--accent); }
details.more.center[open] > summary { margin-top: 18px; }
details.more.center[open] { display: flex; flex-direction: column-reverse; }


/* a book marked favourite */
.likes li em { font-style: normal; color: var(--accent); font-size: 12px; letter-spacing: .05em; margin-left: 4px; }

/* books: a short list, the rest behind "+ n more" */
details.more-books > summary {
  cursor: pointer; list-style: none; display: inline-block;
  font-size: 13px; font-weight: 600; color: var(--accent); padding: 4px 0;
}
details.more-books > summary::-webkit-details-marker,
details.more-books > summary::marker { display: none; content: ""; }
details.more-books > summary:hover { text-decoration: underline; }
details.more-books .when-open { display: none; color: var(--muted); }
details.more-books[open] .when-open { display: inline; }
details.more-books[open] .when-closed { display: none; }
details.more-books[open] { display: flex; flex-direction: column-reverse; align-items: flex-start; }
details.more-books ul { margin-top: 2px; }

/* socials under the name */
.tagline { margin-bottom: 14px; }
.socials { display: flex; gap: 16px; align-items: center; margin: 0 0 26px; }
.socials a { color: var(--muted); display: inline-flex; transition: color .15s ease, transform .15s ease; }
.socials a:hover { color: var(--fg); transform: translateY(-1px); }
.socials svg { width: 20px; height: 20px; fill: currentColor; }
.socials svg[fill="none"] { fill: none; }




/* research charts: the SVG colours are baked in for light; remap the neutral ones in dark */
:root[data-theme="dark"] .chart [fill="#0a0a0a"] { fill: var(--fg); }
:root[data-theme="dark"] .chart [stroke="#0a0a0a"] { stroke: var(--fg); }
:root[data-theme="dark"] .chart [fill="#6b6b6b"] { fill: var(--muted); }
:root[data-theme="dark"] .chart [stroke="#6b6b6b"] { stroke: var(--muted); }
:root[data-theme="dark"] .chart [stroke="#ececec"] { stroke: var(--rule); }
:root[data-theme="dark"] .chart [stroke="#fff"] { stroke: var(--bg); }

/* theme toggle */
.theme-toggle {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--muted); display: inline-flex; transition: color .15s ease, transform .15s ease;
}
.theme-toggle:hover { color: var(--fg); transform: translateY(-1px); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .moon { display: inline; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: inline; }
.theme-toggle.floating {
  position: fixed; top: 16px; right: 16px; z-index: 30;
  width: 38px; height: 38px; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--rule); border-radius: 50%;
}
.socials .sep { width: 1px; height: 16px; background: var(--rule); }

/* photos with no caption: tape/torn/ink frames go back to an even edge */
.print--polaroid.nocap { padding-bottom: 38px; }
.print--tape.nocap { padding-bottom: 7px; }
.print--torn.nocap { padding-bottom: 9px; }
.print--ink.nocap { padding-bottom: 9px; }
.private-note p { white-space: pre-line; }
.lock .btn:disabled { opacity: .6; cursor: default; }
