:root {
  --bg: #17120f;
  --node: #0f0b09;
  --node-border: #4a3a30;
  --line: #33271f;
  --text: #d8cbb8;
  --muted: #8c7e70;
  --head: #f5ead6;
  --addr: #c2553a;
  --label: #e0a45c;
  --blue: #8aa0b4;
  --green: #c9b26b;
  --red: #b8423a;
  --yellow: #d9b46a;
  --purple: #a58bb0;
  --bar: #0b0807;
  --code-bg: #0a0705;

  --hover: var(--label);   /* box outline on mouse-over: old gold in theme 1 */
  --font-mono: "JetBrains Mono", "Fira Code", "Consolas", ui-monospace, monospace;

  --gap: 2.75rem;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
}

/* ---------- e33: Belle Epoque midnight, gold leaf, falling red petals ---------- */
:root[data-theme="e33"] {
  --bg: #07080d;
  --node: #0d0f16;
  --node-border: #b8964f;
  --line: #1f2230;
  --text: #d9d3c3;
  --muted: #8b8b95;
  --head: #f3e6bf;
  --addr: #c9a85c;
  --label: #e8d08a;
  --blue: #8a9db8;
  --green: #e0a458;
  --red: #d9453f;
  --yellow: #e8d08a;
  --purple: #b79ad8;
  --bar: #050609;
  --code-bg: #090a10;
  --font-mono: "EB Garamond", "Cormorant Garamond", Georgia, serif;
  --hover: var(--red);
}
:root[data-theme="e33"] { font-size: 118%; }
:root[data-theme="e33"] pre,
:root[data-theme="e33"] code,
:root[data-theme="e33"] .post-body code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.86rem;
}
:root[data-theme="e33"] body {
  background:
    radial-gradient(ellipse 80% 40% at 50% 100%, rgba(217, 69, 63, 0.16), transparent 70%),
    radial-gradient(ellipse 60% 30% at 50% 0%, rgba(184, 150, 79, 0.10), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
/* One clean border that sits flush against the box (the earlier double frame left a visible gap). */
:root[data-theme="e33"] .block { box-shadow: none; }
:root[data-theme="e33"] .block:hover { border-color: var(--red); box-shadow: none; }
:root[data-theme="e33"] .hero-name,
:root[data-theme="e33"] .timeline-body h3,
:root[data-theme="e33"] .block-body h3 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  letter-spacing: 0.02em;
}
:root[data-theme="e33"] .hero-name { font-size: 3rem; color: var(--head); text-shadow: 0 0 24px rgba(232, 208, 138, 0.35); }
:root[data-theme="e33"] .block-head { border-bottom-color: rgba(184, 150, 79, 0.45); }
:root[data-theme="e33"] .sym::before { content: "\2726  "; color: var(--red); }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.75;
  overflow-wrap: break-word;
  word-break: break-word;
  padding-bottom: 3rem;
}

[id] { scroll-margin-top: 4rem; }

h1, h2, h3, h4 {
  color: var(--head);
  font-family: var(--font-mono);
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 var(--space-2);
}
h1 { font-size: 1.7rem; }
h3 { font-size: 0.98rem; }
h4 { font-size: 0.94rem; }

p { margin: 0 0 var(--space-2); }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.accent { color: var(--green); }
.alert-text { color: var(--red); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: stretch;
  background: var(--bar);
  border-bottom: 1px solid var(--node-border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
.tabbar-brand {
  display: flex;
  align-items: center;
  padding: 0 1.1rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--label);
  white-space: nowrap;
  border-right: 1px solid var(--line);
}
.tabs { display: flex; }
.tab {
  display: flex;
  align-items: center;
  padding: 0.7rem 1rem;
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
  border-right: 1px solid var(--line);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--head); text-decoration: none; }
.tab.active { color: var(--head); background: var(--node); border-bottom-color: var(--label); }

.theme-toggle, .cursor-toggle, .motion-toggle {
  margin-left: auto;
  padding: 0 1rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
  background: transparent;
  border: none;
  border-left: 1px solid var(--line);
  cursor: pointer;
  white-space: nowrap;
}
.theme-toggle:hover, .cursor-toggle:hover, .motion-toggle:hover { color: var(--head); }
.theme-toggle { margin-left: 0; }

/* ---------- Graph canvas ---------- */
.graph {
  max-width: 1060px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-3) 0;
}
/* Writeups get a wider canvas; the body keeps a readable line length. */
.graph.graph-wide { max-width: min(1500px, 100vw - 260px); }
@media (max-width: 1320px) { .graph.graph-wide { max-width: 100%; } }

.block {
  background: var(--node);
  border: 1px solid var(--node-border);
  height: 100%;
  transition: border-color 160ms ease;
}
.block:hover { border-color: var(--hover); }

.block-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;   /* the middle name is centred, whatever the sides contain */
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px dashed var(--line);
  font-size: 0.72rem;
}
.block-head > * { white-space: nowrap; }
.block-head > :nth-child(3) { justify-self: end; }
/* Two-part headers (just an address and a name): the name stays on the right. */
.block-head > :nth-child(2):last-child { grid-column: 3; justify-self: end; }
@media (max-width: 640px) {
  .block-head { display: flex; flex-wrap: wrap; justify-content: space-between; }
}
.block-head .addr { color: var(--addr); }
.block-head .sym { color: var(--label); font-weight: 700; }
.block-head .sym::after { content: ":"; }
.block-head .flag { color: var(--muted); }
.block-body { padding: 1.4rem 1.5rem; }

.comment {
  font-size: 0.76rem;
  color: var(--green);
  margin: var(--space-3) 0 0.5rem;
}
.block-body > .comment:first-child { margin-top: 0; }

.reveal { opacity: 0; transform: translateY(14px); }
.reveal.revealed {
  opacity: 1;
  transform: none;
  transition: opacity 600ms ease, transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Edges ---------- */
@keyframes flow-y { to { background-position: 0 12px; } }
@keyframes flow-x { to { background-position: 12px 0; } }

.edge {
  --c: var(--blue);
  position: relative;
  width: 2px;
  height: 54px;
  margin: 0 auto;
  background-image: repeating-linear-gradient(to bottom, var(--c) 0 6px, transparent 6px 12px);
  background-size: 2px 12px;
  animation: flow-y 0.9s linear infinite;
}
.edge::after {
  content: "";
  position: absolute;
  left: -5px;
  bottom: -2px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 10px solid var(--c);
}
.edge.short { height: 30px; }
.edge.no-arrow::after { display: none; }

.fork-split, .fork-merge {
  display: flex;
  width: calc(50% + var(--gap) / 2);
  margin: 0 auto;
}
.fs-half { position: relative; flex: 1; height: 30px; }
.fs-half::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background-image: repeating-linear-gradient(to right, var(--c) 0 6px, transparent 6px 12px);
  background-size: 12px 2px;
  animation: flow-x 0.9s linear infinite;
}
.fork-split .fs-half::before { top: 0; }
.fork-merge .fs-half::before { bottom: 0; }
.fs-left { --c: var(--green); }
.fs-right { --c: var(--red); }
.fs-half .drop {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background-image: repeating-linear-gradient(to bottom, var(--c) 0 6px, transparent 6px 12px);
  background-size: 2px 12px;
  animation: flow-y 0.9s linear infinite;
}
.fs-left .drop { left: 0; }
.fs-right .drop { right: 0; }
.fork-split .drop::after {
  content: "";
  position: absolute;
  left: -5px;
  bottom: -2px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 10px solid var(--c);
}

.fork {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  align-items: stretch;
}

/* ---------- Hero ---------- */
.block-hero { max-width: 1000px; margin: 0 auto; }
.block-hero .block-body { padding: 2rem; }
.hero-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 2.5rem;
  align-items: stretch;
}
.hero-side { display: flex; flex-direction: column; gap: 0.75rem; }
.portrait {
  width: 100%;
  flex: 1;
  min-height: 340px;
  border: 1px solid var(--node-border);
  padding: 5px;
}
.portrait img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; display: block; }

.hero-main { display: flex; flex-direction: column; justify-content: flex-start; gap: 1.75rem; min-width: 0; }   /* the bio sits a fixed distance under the title, whatever height the photo column ends up with */
.hero-kicker { color: var(--muted); font-size: 1.15rem; margin: 0 0 0.6rem; letter-spacing: 0.02em; }
.hero-handle { color: var(--label); font-weight: 700; }
.hero-name {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0 0 0.6rem;
}
.hero-role {
  color: var(--label);
  font-size: 0.92rem;
  margin: 0;
}
.hero-tagline {
  max-width: 56ch;
  margin: 0;
  padding-left: 1rem;
  border-left: 2px solid var(--line);
}
.hero-ranks .chip-list { margin: 0; }

.btn-cv {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.65rem 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--green);
  border: 1px solid var(--green);
}
.btn-cv-hint { color: var(--muted); font-weight: 400; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.btn-cv:hover { background: var(--green); color: var(--node); text-decoration: none; }
.btn-cv:hover .btn-cv-hint { color: var(--node); }

.chip-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0;
  margin: 0;
}
.chip {
  font-size: 0.74rem;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--line);
  color: var(--text);
}
.chip:hover { border-color: var(--hover); color: var(--head); }

.badge-rank {
  display: inline-flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--purple);
}
.badge-rank-name { color: var(--purple); font-weight: 700; }
.badge-rank-result { color: var(--head); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--line); }
.timeline-entry { position: relative; padding: 0 0 var(--space-3) var(--space-3); }
.timeline-entry:last-child { padding-bottom: 0; }
.timeline-marker { position: absolute; left: -4px; top: 0.6em; width: 7px; height: 7px; background: var(--label); }
.timeline-entry:first-child .timeline-marker { animation: blink 1.6s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.timeline-body h3 { margin-bottom: 0.25rem; }
.timeline-role { font-size: 0.78rem; color: var(--yellow); margin-bottom: 0.15rem; }
.timeline-period { font-size: 0.72rem; color: var(--muted); }
.timeline-body ul { padding-left: 1.1rem; margin: var(--space-1) 0 0; }
.timeline-body li::marker { color: var(--label); }

/* ---------- Projects ---------- */
.catalogue { display: flex; flex-direction: column; }
.catalogue-entry { display: flex; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px dashed var(--line); }
.catalogue-entry:first-child { padding-top: 0; }
.catalogue-entry:last-child { border-bottom: none; padding-bottom: 0; }
.catalogue-no { flex-shrink: 0; width: 3rem; color: var(--addr); font-size: 0.78rem; padding-top: 0.15rem; }
.catalogue-body { flex: 1; min-width: 0; }
.catalogue-meta { font-size: 0.72rem; color: var(--muted); margin-bottom: 0.2rem; }
.catalogue-role { font-size: 0.8rem; color: var(--yellow); margin-bottom: 0.4rem; }
.catalogue-body .chip-list { margin-top: var(--space-2); }

.link-more { font-size: 0.78rem; color: var(--blue); }

.post-grid, .post-teaser-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-2);
  align-items: stretch;      /* every box in a row is as tall as the tallest one */
}
.post-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); grid-auto-rows: 1fr; }   /* all boxes share one height; a short last row keeps the same box width */
.post-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  padding: var(--space-2) var(--space-3);
  color: var(--text);
  transition: border-color 160ms ease;
}
.post-card:hover { border-color: var(--hover); color: var(--text); text-decoration: none; }
.post-card h3, .post-card h4 { margin-bottom: 0.35rem; white-space: nowrap; }   /* the name stays on one line; main.js shrinks it to fit */
.post-card > p:not(.post-card-cat):not(.post-card-count) { flex: 1 1 auto; }     /* the writeup count sits at the bottom of every box */
.post-card p { font-size: 0.82rem; color: var(--muted); }
.post-card-cat {
  font-size: 0.7rem;
  color: var(--purple);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;      /* the category always stays on one line */
  overflow: hidden;
  text-overflow: ellipsis;
}
.post-card .post-card-count {
  margin: 0.9rem 0 0;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--line);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--label);        /* the writeup count stands out from the description above it */
  letter-spacing: 0.02em;
}

.post-body :is(h1, h2, h3) { margin-top: var(--space-3); }
/* Nothing in a writeup may ever be wider than its block. */
.post-body { min-width: 0; max-width: 100%; }
.post-body :is(img, video, canvas, svg, iframe, embed, object) { max-width: 100%; height: auto; }
.post-body img { display: block; margin: var(--space-2) 0; }
.post-body table { display: block; max-width: 100%; overflow-x: auto; }
.post-body pre, .post-body .codehilite { max-width: 100%; }
.code-wrap { position: relative; margin: 0 0 var(--space-2); }
.post-body .codehilite { margin: 0; }
.post-body pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  padding: var(--space-2);
  padding-right: 2.75rem;
  margin: 0;
  overflow-x: auto;
  user-select: text;
}
.post-body code { font-family: var(--font-mono); font-size: 0.86em; user-select: text; }
.post-body .codehilite pre { margin: 0; }

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--node);
  border: 1px solid var(--line);
  color: var(--label);
  cursor: pointer;
  opacity: 1;
  transition: opacity 150ms ease, color 150ms ease, border-color 150ms ease;
}
.copy-btn svg { width: 17px; height: 17px; stroke-width: 2.2; }
.copy-btn { border-color: color-mix(in srgb, var(--label) 55%, transparent); background: color-mix(in srgb, var(--label) 12%, var(--node)); }
.copy-btn:hover, .copy-btn:focus-visible, .copy-btn.copied { opacity: 1; color: var(--green); border-color: var(--green); }

/* ---------- Footer block ---------- */
footer.graph { padding-top: 0; }
.block-end { max-width: 520px; margin: 0 auto var(--space-4); }
.block-end .block-body { padding: 0.9rem 1.4rem; font-size: 0.8rem; color: var(--muted); text-align: center; }
.block-end .retn { color: var(--label); font-weight: 700; }

/* ---------- Social rail ---------- */
.social-rail {
  position: fixed;
  left: 1.8rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  z-index: 20;
}
.social-icon { line-height: 0; opacity: 0.9; transition: transform 150ms ease; }
.social-icon:hover { transform: translateY(-3px) scale(1.08); text-decoration: none; }
.social-rail-line { width: 1px; height: 5rem; background: linear-gradient(to bottom, var(--node-border), transparent); margin-top: var(--space-1); }
@media (max-width: 1320px) { .social-rail { display: none; } }

/* ---------- Status bar ---------- */
.statusbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 1.6rem;
  height: 2.1rem;
  padding: 0 1rem;
  background: var(--bar);
  border-top: 1px solid var(--node-border);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}
.statusbar .st-idle { color: var(--green); }
.statusbar .st-right { margin-left: auto; display: flex; gap: 1.2rem; }
.statusbar .st-addr { color: var(--addr); }
.statusbar .st-sym { color: var(--label); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .fork { grid-template-columns: 1fr; gap: var(--space-3); }
  .fork-split, .fork-merge { display: none; }
  /* Stacked on phones: a dashed line links Experience down to Education, like the other sections. */
  .fork > *:not(:last-child) { position: relative; }
  .fork > *:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 100%;
    width: 2px;
    height: var(--space-3);
    background-image: repeating-linear-gradient(to bottom, var(--blue) 0 6px, transparent 6px 12px);
    background-size: 2px 12px;
    animation: flow-y 0.9s linear infinite;
  }
  /* ...and both connectors end in an arrow, like the others. */
  .edge.no-arrow::after { display: block; }
  .fork > *:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 50%;
    top: calc(100% + var(--space-3) - 8px);
    margin-left: -6px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 10px solid var(--blue);
  }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-side { max-width: 320px; width: 100%; margin: 0 auto; }
  .statusbar .st-hide { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- Page transition ---------- */
/* An instant cut: the new page opens already covered by kindle.js's darkness.
   Nothing gets its own transition layer, or it would draw on top of that darkness. */
@view-transition { navigation: auto; }
::view-transition-group(root),
::view-transition-old(root),
::view-transition-new(root) { animation: none; }
::view-transition-old(root) { display: none; }

/* ---------- Easter egg ---------- */
.egg-glitch { animation: egg-glitch 0.9s steps(1, end); }
@keyframes egg-glitch {
  0%   { transform: translate(0, 0); filter: none; }
  12%  { transform: translate(-8px, 0); filter: hue-rotate(90deg) contrast(1.4); }
  24%  { transform: translate(8px, 4px); filter: invert(1); }
  36%  { transform: translate(-4px, -4px); filter: none; }
  48%  { transform: translate(12px, 0); filter: hue-rotate(200deg); }
  60%  { transform: translate(-8px, 4px); filter: invert(1) contrast(1.6); }
  72%  { transform: translate(4px, 0); filter: none; }
  84%  { transform: translate(-12px, -4px); filter: hue-rotate(300deg); }
  100% { transform: translate(0, 0); filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  .egg-glitch { animation: none; }
}

/* ida_dark: no green anywhere, so code highlighting follows the accent too. */
:root:not([data-theme]) .codehilite :is(.k, .kc, .kd, .kn, .kp, .kr, .kt, .nt, .ow) { color: #c9b26b; }
:root[data-theme="deco"] .codehilite :is(.k, .kc, .kd, .kn, .kp, .kr, .kt, .nt, .ow) { color: #e0b25a; }
:root:not([data-theme]) .codehilite .gi { color: #c9b26b; }
:root[data-theme="deco"] .codehilite .gi { color: #e0b25a; }


/* ---------- Writeups: code must read as clearly apart from the prose ---------- */
.post-body .code-wrap {
  margin: 1.9rem 0;
  border: 1px solid var(--node-border);
  border-left: 4px solid var(--label);
  background: color-mix(in srgb, var(--code-bg) 55%, #000);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}
.post-body .code-wrap::before {
  content: "";
  display: block;
  height: 2.4rem;
  background: color-mix(in srgb, var(--label) 10%, var(--code-bg));
  border-bottom: 1px solid var(--line);
}
.post-body .code-wrap pre { border: 0; background: transparent; margin: 0; }
.post-body .code-wrap .copy-btn { top: 0.35rem; right: 0.6rem; width: 1.7rem; height: 1.7rem; }
.post-body p { margin-top: 1.1rem; margin-bottom: 1.1rem; }

/* e33: no green anywhere, so code highlighting uses amber for its former greens too. */
:root[data-theme="e33"] .codehilite :is(.k, .kc, .kd, .kn, .kp, .kr, .kt, .nt, .ow, .gi) { color: #e0a458; }

/* ---------- Theme 1: Ember & Ash ---------- */
/* Interface: JetBrains Mono (set on :root). Name and headings: Oxanium bold.
   Code and addresses: Bitcount Prop Single (a pixel font whose ^ and symbols stay readable), scaled up 36%. */
:root:not([data-theme]) {
  --code-font: "Bitcount Prop Single", "JetBrains Mono", ui-monospace, monospace;
  --cscale: 1.36;
}
:root:not([data-theme]) :is(h1, h2, h3, h4, .hero-name) {
  font-family: "Oxanium", "JetBrains Mono", system-ui, sans-serif;
  font-weight: 700;
}
:root:not([data-theme]) :is(pre, code, .codehilite, .post-body code) {
  font-family: var(--code-font);
  font-size: calc(0.72rem * var(--cscale));
  font-weight: 400;
}
:root:not([data-theme]) .block-head .addr {
  font-family: var(--code-font);
  font-size: calc(0.63rem * var(--cscale));
}
:root:not([data-theme]) .st-addr {
  font-family: var(--code-font);
  font-size: calc(0.6rem * var(--cscale));
}
:root:not([data-theme]) .catalogue-no {
  font-family: var(--code-font);
  font-size: calc(0.62rem * var(--cscale));
}

/* ---------- Theme 2: Rapture Deco ---------- */
:root[data-theme="deco"] {
  --bg: #0f1c1e;
  --node: #0a1415;
  --node-border: #c6963f;
  --line: #1f3336;
  --text: #d8cdb4;
  --muted: #7f948f;
  --head: #f6e8c8;
  --addr: #c6963f;
  --label: #e0b25a;
  --blue: #6fb0b0;
  --green: #e0b25a;
  --red: #b5502e;
  --yellow: #d9b86a;
  --purple: #9a8fb0;
  --bar: #070f10;
  --code-bg: #091213;
  --font-mono: "Lora", Georgia, "Times New Roman", serif;
  --hover: var(--label);   /* brass on mouse-over; the border itself is already brass */
}
:root[data-theme="deco"] pre,
:root[data-theme="deco"] code,
:root[data-theme="deco"] .codehilite,
:root[data-theme="deco"] .post-body code {
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 400;
}
:root[data-theme="deco"] :is(.block-head .addr, .st-addr, .catalogue-no) {
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  font-size: 0.63rem;
}
/* Name and headings: Oxanium bold, in normal case. */
:root[data-theme="deco"] :is(h1, h2, h3, h4, .hero-name) {
  font-family: "Oxanium", "Lora", system-ui, sans-serif;
  font-weight: 700;
}

/* ---------- Writeups: screenshots get a frame, like the code blocks ---------- */
.post-body img {
  box-sizing: border-box;
  max-width: 100%;
  margin: 1.9rem 0;
  padding: 8px;
  border: 1px solid var(--node-border);
  border-left: 4px solid var(--label);
  background: color-mix(in srgb, var(--code-bg) 55%, #000);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

/* e33: wide serif capitals would be cut off, so the category uses elegant small capitals instead. */
:root[data-theme="e33"] .post-card-cat {
  text-transform: none;
  font-variant-caps: all-small-caps;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
}

/* e33: its serif is wider, so card titles are a little smaller to stay on one line. */
:root[data-theme="e33"] .post-card :is(h3, h4) { font-size: 0.9rem; }

.empty-note { color: var(--muted); font-style: italic; margin: 0.5rem 0 1.5rem; }

/* A CTF with no writeups yet shows "incoming" in place of a count. */
.post-card .post-card-count.is-incoming { font-style: italic; font-weight: 500; color: var(--muted); }

/* Incoming (no writeups yet): a dashed, dimmed box that does not react to the mouse. */
.post-card.is-incoming { border-style: dashed; opacity: 0.7; cursor: default; }
.post-card.is-incoming:hover { border-color: var(--line); color: inherit; }

/* ---------- Phones and small screens ---------- */
/* The tab row fades at an edge when more tabs are off-screen in that direction (main.js toggles the classes). */
.tabs.fade-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 34px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 34px), transparent); }
.tabs.fade-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 34px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 34px), transparent); }
.tabs.fade-left.fade-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 34px, #000 calc(100% - 34px), transparent); mask-image: linear-gradient(to right, transparent, #000 34px, #000 calc(100% - 34px), transparent); }

/* A comfortable tap target: the link text alone was 23px tall, just under the 24px WCAG 2.2 minimum. */
.link-more { display: inline-block; padding: 0.5rem 0; }

@media (max-width: 640px) {
  /* Header labels may wrap instead of forcing the whole page to scroll sideways. */
  .block-head > * { white-space: normal; min-width: 0; }
  .block-head .flag { text-align: right; overflow-wrap: anywhere; }

  /* Two-row nav: brand and theme button on top, the tabs on a row of their own that scrolls sideways. */
  .tabbar { flex-wrap: wrap; }
  .tabbar-brand { flex: 1 1 auto; padding: 0.55rem 1rem; border-right: 0; }
  .theme-toggle { padding: 0.55rem 1rem; }
  /* All tabs stay visible: the row wraps to a second line instead of scrolling and clipping the last tab. */
  .tabs { order: 3; flex: 1 0 100%; flex-wrap: wrap; border-top: 1px solid var(--line); }
  .tab { flex: 1 1 auto; justify-content: center; padding: 0.55rem 0.6rem; font-size: 0.72rem; }
}

/* The side rail needs a wide screen. Below that, the same links appear in the hero and under the footer. */
.hero-social { display: none; }
@media (max-width: 1320px) {
  .hero-social { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; margin-top: 1rem; }
  .hero-social .social-icon {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px;
    background: var(--node); border: 1px solid var(--line);
    transition: border-color 150ms ease, transform 150ms ease;
  }
  .hero-social .social-icon:hover { border-color: var(--hover); }
  .hero-social .social-icon svg { width: 24px; height: 24px; }
}
.social-row { display: none; }
@media (max-width: 1320px) {
  .social-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; margin: 1.4rem 0 2.4rem; }
  .social-row .social-icon {
    display: flex; align-items: center; justify-content: center;
    width: 48px; height: 48px;
    background: var(--node); border: 1px solid var(--line);
    transition: border-color 150ms ease, transform 150ms ease;
  }
  .social-row .social-icon:hover { border-color: var(--hover); }
}

/* The role line: it may wrap between the roles, never inside one ("Mobile Pentester" stays together),
   and it shrinks a little before wrapping so the whole title sits on one line when there is room. */
.hero-main { container-type: inline-size; }
.hero-role .role-part { white-space: nowrap; }
@supports (font-size: 1cqw) {
  .hero-role { font-size: clamp(0.7rem, 3cqw, 0.92rem); }
}

/* Bigger social icons: 26px was smaller than the custom cursor. */
.social-rail { gap: 1.7rem; }
.social-rail .social-icon svg { width: 40px; height: 40px; }
.social-row .social-icon svg { width: 30px; height: 30px; }

/* The line under the social icons: it was 1px and nearly invisible. */
.social-rail-line {
  width: 4px;
  height: 6.5rem;
  margin-top: 0.7rem;
  border-radius: 2px;
  background: linear-gradient(to bottom, var(--label), transparent);
}

/* ---------- Phones: smaller type and tighter padding, so a line holds a readable number of words ---------- */
@media (max-width: 640px) {
  :root, :root[data-theme="e33"] { font-size: 82%; }
  .graph { padding-left: 0.6rem; padding-right: 0.6rem; }
  .block-body { padding: 1rem 0.9rem; }
  .block-hero .block-body { padding: 1.1rem 0.9rem; }
  .hero-name, :root[data-theme="e33"] .hero-name { font-size: clamp(1.7rem, 8.4vw, 2.2rem); white-space: nowrap; letter-spacing: -0.02em; }
  .hero-kicker { font-size: 0.95rem; }
  .hero-tagline { padding-left: 0.7rem; max-width: none; }
}

/* Phones: the brand sits in the true centre of the top row; the theme button stays at the right edge. */
@media (max-width: 640px) {
  .tabbar { display: grid; grid-template-columns: 1fr auto 1fr; }
  .tabbar-brand { grid-column: 2; grid-row: 1; justify-content: center; padding: 0.55rem 0.4rem; }
  .theme-toggle { grid-column: 3; grid-row: 1; justify-self: end; margin-left: 0; }
  .tabs { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- Clickable affordances: what can be clicked should look clickable before the pointer lands on it ---------- */
:root { --aff: var(--label); }

/* Cards that open something: targeting brackets on the corners and a "jmp" tag whose arrow keeps nudging. */
a.post-card { position: relative; }
a.post-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  pointer-events: none;
  --b: color-mix(in srgb, var(--aff) 70%, transparent);
  background:
    linear-gradient(var(--b), var(--b)) 0 0 / 14px 2px no-repeat,
    linear-gradient(var(--b), var(--b)) 0 0 / 2px 14px no-repeat,
    linear-gradient(var(--b), var(--b)) 100% 0 / 14px 2px no-repeat,
    linear-gradient(var(--b), var(--b)) 100% 0 / 2px 14px no-repeat,
    linear-gradient(var(--b), var(--b)) 0 100% / 14px 2px no-repeat,
    linear-gradient(var(--b), var(--b)) 0 100% / 2px 14px no-repeat,
    linear-gradient(var(--b), var(--b)) 100% 100% / 14px 2px no-repeat,
    linear-gradient(var(--b), var(--b)) 100% 100% / 2px 14px no-repeat;
  transition: inset 180ms cubic-bezier(.3, 1.5, .5, 1), opacity 180ms ease;
}
a.post-card:hover::before { inset: -5px; --b: var(--aff); }
a.post-card::after {
  content: "jmp \25B8";
  position: absolute;
  top: -0.62rem;
  right: 0.9rem;
  padding: 0.05rem 0.4rem;
  background: var(--node);
  font-size: 0.64rem;
  letter-spacing: 0.04em;
  color: var(--aff);
  border: 1px dashed color-mix(in srgb, var(--aff) 60%, transparent);
  animation: aff-nudge 1.8s ease-in-out infinite;
}
a.post-card:hover::after { background: var(--aff); color: var(--node); border-style: solid; animation: none; }
@keyframes aff-nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(3px); } }

/* Text links: always underlined (dotted), solid on hover. */
.link-more, .post-body a { text-decoration: underline dotted; text-underline-offset: 4px; text-decoration-thickness: 1.5px; }
.link-more:hover, .post-body a:hover { text-decoration-style: solid; }

/* Inactive tabs and the theme switch read as controls: a faint baseline, a button outline, a glyph. */
.tab:not(.active) { border-bottom-color: color-mix(in srgb, var(--aff) 32%, transparent); }
.theme-toggle { color: var(--aff); }
.theme-toggle::before { content: "\21C4\00A0"; }

/* The social icons send out a soft ring, one after another, so the eye finds them. */
.social-icon { position: relative; }
.social-icon::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1.5px solid currentColor;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  animation: aff-ring 5.5s ease-out infinite;
}
.social-icon:nth-child(2)::after { animation-delay: 0.5s; }
.social-icon:nth-child(3)::after { animation-delay: 1s; }
.social-icon:nth-child(4)::after { animation-delay: 1.5s; }
@keyframes aff-ring { 0% { transform: scale(0.85); opacity: 0.6; } 22%, 100% { transform: scale(1.35); opacity: 0; } }

/* The scan wave: main.js adds .xref-ping to each visible clickable in turn. */
.xref-ping { animation: xref-ping 1s ease-out both; animation-delay: var(--xd, 0ms); }
a.post-card.xref-ping { animation: xref-ping 1s ease-out both; animation-delay: var(--xd, 0ms); }
@keyframes xref-ping {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--aff) 40%, transparent); }
  40% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--aff) 0%, transparent); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

/* X-ray view (press X, or tap the status bar hint): every clickable gets an outline and a label. */
html.xref-view :is(a[href], button, summary, [role="button"], .copy-btn, [data-theme-toggle]) {
  outline: 1.5px dashed var(--aff);
  outline-offset: 3px;
}
#xref-layer { position: fixed; inset: 0; z-index: 2147482000; pointer-events: none; }
.xref-tag {
  position: absolute;
  padding: 0.05rem 0.35rem;
  font: 700 0.62rem/1.3 var(--font-mono);
  color: var(--node);
  background: var(--aff);
  white-space: nowrap;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
[data-xref-toggle] { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  a.post-card::after, .social-icon::after, .xref-ping { animation: none; }
}

/* Cursor switch: sits beside the theme button; it does nothing on touch screens, so it is hidden there. */
.cursor-toggle { color: var(--aff); }
.cursor-toggle::before { content: "\25CE\00A0"; }
.cursor-toggle[aria-pressed="false"] { color: var(--muted); }
@media (hover: none), (pointer: coarse) { .cursor-toggle { display: none; } }
@media (max-width: 640px) { .nav-prefs { grid-column: 1; grid-row: 1; justify-self: start; } .cursor-toggle, .motion-toggle { padding: 0.55rem 0.8rem; } }

/* Motion switch (next to the cursor switch): a toggle row, and the rules that silence everything when it is off. */
.nav-prefs { display: flex; margin-left: auto; }
.nav-prefs > button { margin-left: 0; }
.motion-toggle { color: var(--aff); }
.motion-toggle::before { content: "\224B\00A0"; }
.motion-toggle[aria-pressed="false"] { color: var(--muted); }

html.no-motion { scroll-behavior: auto; }
html.no-motion *, html.no-motion *::before, html.no-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
html.no-motion .reveal { opacity: 1; transform: none; }

/* Phones, final layout: brand on the left; the motion (and cursor) switch sits right beside the theme button. */
@media (max-width: 640px) {
  .tabbar { grid-template-columns: 1fr auto auto; }
  .tabbar-brand { grid-column: 1; grid-row: 1; justify-content: flex-start; padding: 0.55rem 1rem; }
  .nav-prefs { grid-column: 2; grid-row: 1; justify-self: end; }
  .theme-toggle { grid-column: 3; grid-row: 1; }
  .nav-prefs > button { padding: 0.55rem 0.7rem; border-left: 1px solid var(--line); }
}

/* Switching to another browser tab freezes every animation; they carry on from the same point when you come back. */
html.tab-hidden *, html.tab-hidden *::before, html.tab-hidden *::after { animation-play-state: paused !important; }

/* The cover that fades in the moment a link is tapped (nav.js); it is the same dark as the next page's transition. */
#tx-pre {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  background: var(--node);
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms ease-out;
}
#tx-pre.on { opacity: 1; }

main:focus { outline: none; }   /* nav.js moves focus here after a page change */

/* Long writeups: the browser skips layout and painting for blocks that are far off screen (it keeps a remembered size
   for each). Swapping a 260 KB writeup in drops from about 300 ms to about 20 ms, and so does a normal page load. */
.post-body > * {
  content-visibility: auto;
  contain-intrinsic-size: auto 160px;
}
