/* ==========================================================================
   Sandesh Adhikari — portfolio
   Two visual tracks: dark "computational" (default) and light "paper" (civil).
   ========================================================================== */

:root {
  --font-display: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;

  /* computational track (dark) */
  --bg: #0a0d12;
  --surface: #10141b;
  --surface-2: #171c26;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #eef1f5;
  --text-2: #b4bcc8;
  --muted: #8a93a1;
  --accent: #6da7ec;
  --accent-ink: #0a0d12;

  /* chart roles */
  --series-1: #3987e5; /* flood / model */
  --series-2: #d95926; /* earthquake / damage */
  --series-3: #199e70; /* optimized / rehabilitated */
  --grid: #212734;
  --axis: #343c4b;

  --wrap: 1180px;
  --gutter: clamp(20px, 4vw, 44px);
  --radius: 14px;
  --radius-sm: 8px;
}

.theme-paper {
  --bg: #f3f0e8;
  --surface: #fbfaf6;
  --surface-2: #e9e5da;
  --line: rgba(22, 32, 44, 0.13);
  --line-strong: rgba(22, 32, 44, 0.28);
  --text: #16202c;
  --text-2: #46515f;
  --muted: #677180;
  --accent: #1c5cab;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #e0dcd0;
  --axis: #bdb8aa;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 76px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
canvas,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 500;
  line-height: 1.12;
}

p {
  margin: 0 0 1em;
}

.wrap {
  width: min(var(--wrap), 100% - 2 * var(--gutter));
  margin-inline: auto;
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
}

.skip:focus {
  top: 12px;
}

.mono {
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   Navigation
   -------------------------------------------------------------------------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 13, 18, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 62px;
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.nav__mark {
  width: 26px;
  height: 26px;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav__links a {
  display: block;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--text-2);
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
}

.nav__links a:hover {
  color: var(--text);
}

.nav__links a[aria-current="true"] {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.nav__links .nav__cta a {
  margin-left: 8px;
  border: 1px solid var(--line-strong);
  color: var(--text);
}

.nav__toggle {
  display: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.nav__toggle span,
.nav__toggle span::before,
.nav__toggle span::after {
  display: block;
  width: 18px;
  height: 1.5px;
  margin: 0 auto;
  background: currentColor;
  content: "";
}

.nav__toggle span::before {
  transform: translateY(-6px);
}

.nav__toggle span::after {
  transform: translateY(4.5px);
}

@media (max-width: 1000px) {
  .nav__toggle {
    display: block;
  }

  .nav__links {
    position: absolute;
    left: 0;
    right: 0;
    top: 62px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px var(--gutter) 18px;
    background: #0a0d12;
    border-bottom: 1px solid var(--line);
  }

  .nav__links.is-open {
    display: flex;
  }

  .nav__links a {
    padding: 12px 12px;
    font-size: 1rem;
  }

  .nav__links .nav__cta a {
    margin: 8px 0 0;
    text-align: center;
  }
}

/* --------------------------------------------------------------------------
   Shared section furniture
   -------------------------------------------------------------------------- */

.section {
  padding: clamp(64px, 9vw, 120px) 0;
  background: var(--bg);
  color: var(--text);
}

.section--ruled {
  border-top: 1px solid var(--line);
}

.kicker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.kicker::before {
  width: 28px;
  height: 1px;
  background: currentColor;
  content: "";
}

.h-display {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4.6vw, 3.5rem);
  font-weight: 400;
  letter-spacing: -0.018em;
}

.section__intro {
  max-width: 62ch;
  margin: 20px 0 0;
  color: var(--text-2);
  font-size: 1.12rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.96rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
}

.btn:hover {
  border-color: var(--text-2);
  transform: translateY(-1px);
}

.btn--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.btn--primary:hover {
  border-color: var(--text);
  background: var(--text);
}

.btn--quiet {
  padding: 8px 14px;
  color: var(--text-2);
  font-size: 0.85rem;
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tags li {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
}

.badge--review::before {
  background: #fab219;
}

.badge--published::before {
  background: #0ca30c;
}

/* reveal on scroll (only when JS is running) */
.js .reveal {
  opacity: 0;
  transform: translateY(16px);
}

.js .reveal.is-in {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .js .reveal,
  .js .reveal.is-in {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(48px, 7vw, 96px) 0 0;
  background: var(--bg);
  isolation: isolate;
}

.hero__net {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  opacity: 0.9;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.25) 34%, #000 72%);
  mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.25) 34%, #000 72%);
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(0, 0.58fr);
  align-items: end;
  gap: clamp(28px, 5vw, 72px);
}

.hero__who {
  margin: 0 0 22px;
  color: var(--text-2);
  font-size: 1rem;
}

.hero__who strong {
  color: var(--text);
  font-weight: 600;
}

.hero__question {
  max-width: 15ch;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6.2vw, 4.9rem);
  font-weight: 400;
  letter-spacing: -0.028em;
  line-height: 1.02;
}

.hero__lede {
  max-width: 34ch;
  margin: 28px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.2vw, 1.7rem);
  line-height: 1.3;
  letter-spacing: -0.005em;
}

.hero__sub {
  max-width: 58ch;
  margin: 20px 0 0;
  color: var(--text-2);
  font-size: 1.06rem;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.portrait {
  margin: 0;
}

.portrait__frame {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  aspect-ratio: 4 / 5;
}

.portrait__frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 18%;
}

.portrait figcaption {
  margin-top: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
}

@media (max-width: 900px) {
  .hero__grid {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .portrait {
    order: -1;
    width: min(210px, 52vw);
  }

  .hero__net {
    opacity: 0.5;
  }
}

/* two-track entry cards */
.tracks {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: clamp(44px, 6vw, 76px);
  padding: 0 0 clamp(56px, 7vw, 88px);
}

.trackcard {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 168px;
  padding: 24px 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}

.trackcard:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.trackcard__no {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.trackcard__title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  letter-spacing: -0.01em;
}

.trackcard__text {
  max-width: 52ch;
  margin: 0;
  color: var(--text-2);
  font-size: 0.96rem;
}

.trackcard__go {
  margin-top: auto;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
}

.trackcard.theme-paper {
  border-color: transparent;
}

@media (max-width: 760px) {
  .tracks {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   Profile
   -------------------------------------------------------------------------- */

.profile {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: clamp(32px, 6vw, 88px);
  margin-top: 40px;
}

.profile__body p {
  color: var(--text-2);
  font-size: 1.1rem;
}

.profile__body p:first-child {
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.1vw, 1.6rem);
  line-height: 1.38;
}

.profile__body p.profile__aside {
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.96rem;
}

.facts {
  margin: 0;
  border-top: 1px solid var(--line);
}

.facts div {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.facts dt {
  padding-top: 3px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.facts dd {
  margin: 0;
  color: var(--text);
  font-size: 0.98rem;
}

@media (max-width: 860px) {
  .profile {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   Abilities
   -------------------------------------------------------------------------- */

.abilities {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.ability {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.ability__glyph {
  width: 72px;
  height: 45px;
  margin-bottom: 4px;
  overflow: visible;
}

.ability__glyph path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ability__glyph path.is-band {
  fill: var(--series-1);
  stroke: none;
  opacity: 0.18;
}

.ability__glyph path.is-axis {
  stroke: var(--axis);
}

.ability__glyph circle {
  fill: var(--text);
}

/* glyphs draw themselves as the card scrolls in */
.js .ability path[pathLength] {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.js .ability.is-in path[pathLength] {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1.5s ease 0.25s;
}

.ability h4 {
  font-family: var(--font-display);
  font-size: 1.42rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.ability p {
  margin: 0;
  color: var(--text-2);
  font-size: 0.95rem;
}

.ability p.ability__also {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 0.88rem;
}

.ability__also span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

@media (max-width: 980px) {
  .abilities {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .abilities {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .js .ability path[pathLength] {
    stroke-dasharray: none;
    stroke-dashoffset: 0;
  }
}

/* --------------------------------------------------------------------------
   The problem: playable network
   -------------------------------------------------------------------------- */

.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 0 28px;
  margin-top: 44px;
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.game__board {
  position: relative;
  height: 460px;
}

.game__board canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
}

.game__panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-left: 28px;
  border-left: 1px solid var(--line);
}

.game__budget {
  margin: 0;
  color: var(--text-2);
  font-size: 0.95rem;
}

.game__budget span {
  margin-right: 4px;
  color: var(--text);
  font-size: 2.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}

.game__status {
  min-height: 3.1em;
  margin: 10px 0 14px;
  color: var(--text-2);
  font-size: 0.9rem;
  line-height: 1.5;
}

.game__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.game__actions .btn--primary {
  width: 100%;
  justify-content: center;
}

.scores {
  width: 100%;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.scores__title {
  margin: 0 0 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.score {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 0.86rem;
}

.score__label {
  color: var(--text-2);
}

.score__track {
  display: block;
  height: 12px;
  border-left: 1px solid var(--axis);
}

.score__fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: var(--muted);
  transition: width 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.score--you .score__fill {
  background: var(--series-1);
}

.score--opt .score__fill {
  background: var(--series-3);
}

.score__value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
}

.game__verdict {
  min-height: 4.2em;
  margin: 16px 0 12px;
  font-family: var(--font-display);
  font-size: 1.16rem;
  line-height: 1.35;
}

.game__legend {
  grid-column: 1 / -1;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

@media (max-width: 900px) {
  .game {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .game__board {
    height: 360px;
  }

  .game__panel {
    padding: 18px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .game__actions .btn--primary {
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .score__fill {
    transition: none;
  }
}

.hard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(20px, 3vw, 44px);
  margin-top: 28px;
}

.hard__item {
  padding-top: 20px;
  border-top: 1px solid var(--line-strong);
}

.hard__no,
.moves__no {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
}

.hard__item h4 {
  margin: 10px 0 10px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.hard__item p {
  margin: 0;
  color: var(--text-2);
  font-size: 0.98rem;
}

.hard__item strong {
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .hard {
    grid-template-columns: 1fr;
  }
}

.subhead + .section__intro {
  margin-top: 14px;
}

.note {
  max-width: 68ch;
  margin: 32px 0 0;
  padding-left: 18px;
  border-left: 2px solid var(--line-strong);
  color: var(--text-2);
  font-size: 0.98rem;
}

/* --------------------------------------------------------------------------
   Approach: three moves
   -------------------------------------------------------------------------- */

.moves {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 44px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: move;
}

.moves li {
  position: relative;
  padding: 22px 28px 4px 0;
  border-top: 1px solid var(--line-strong);
  counter-increment: move;
}

.moves li::before {
  position: absolute;
  top: -5px;
  left: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 0 0 1.5px var(--text-2) inset;
  content: "";
}

/* a pulse hands off from one move to the next */
.moves li::after {
  position: absolute;
  top: -1.5px;
  left: 0;
  width: 44px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent));
  content: "";
  opacity: 0;
  animation: move-flow 4.5s linear infinite;
  animation-delay: calc(var(--i) * 1.5s);
}

@keyframes move-flow {
  0% {
    left: 0;
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  31% {
    left: calc(100% - 44px);
    opacity: 1;
  }
  33%,
  100% {
    left: calc(100% - 44px);
    opacity: 0;
  }
}

.moves__no::before {
  content: counter(move, decimal-leading-zero);
}

.moves h3 {
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.moves p {
  max-width: 34ch;
  margin: 8px 0 0;
  color: var(--text-2);
  font-size: 0.98rem;
}

@media (max-width: 820px) {
  .moves {
    grid-template-columns: 1fr;
  }

  .moves li {
    padding: 0 0 24px 26px;
    border-top: 0;
    border-left: 1px solid var(--line-strong);
  }

  .moves li::before {
    top: 4px;
    left: -5px;
  }

  .moves li::after {
    display: none;
  }

  .moves h3 {
    margin-top: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .moves li::after {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Live demos
   -------------------------------------------------------------------------- */

.demos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 40px;
}

@media (max-width: 980px) {
  .demos {
    grid-template-columns: 1fr;
  }
}

.demo {
  margin: 0;
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.demo__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.demo__tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.demo__tag::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--series-3);
  content: "";
  animation: live-dot 2s ease-in-out infinite;
}

@keyframes live-dot {
  50% {
    opacity: 0.25;
  }
}

.demo__title {
  margin-top: 4px;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
}

.demo__controls {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}

.demo__controls button {
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
}

.demo__controls button:hover {
  border-color: var(--text-2);
  color: var(--text);
}

.demo__stage {
  position: relative;
  height: 340px;
}

.demo__stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.demo__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 12px 0 0;
  padding: 0;
  color: var(--text-2);
  font-size: 0.8rem;
  list-style: none;
}

.demo__legend li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.key {
  display: inline-block;
  flex-shrink: 0;
}

.key--line {
  width: 16px;
  height: 2px;
  border-radius: 1px;
  background: var(--k, var(--series-1));
}

.key--thin {
  height: 1px;
}

.key--thick {
  height: 5px;
  border-radius: 3px;
}

.key--dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--k, var(--series-1));
}

.key--ring {
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--k, var(--muted));
  border-radius: 50%;
}

.key--band {
  width: 16px;
  height: 9px;
  border-radius: 2px;
  background: var(--k, var(--series-1));
  opacity: 0.28;
}

.key--square {
  width: 9px;
  height: 9px;
  background: var(--k, var(--text));
}

.key--valve {
  width: 12px;
  height: 9px;
  background: var(--k, var(--series-3));
  clip-path: polygon(0 0, 50% 50%, 0 100%, 100% 100%, 50% 50%, 100% 0);
}

.key--cross {
  position: relative;
  width: 10px;
  height: 10px;
}

.key--cross::before,
.key--cross::after {
  position: absolute;
  top: 4px;
  left: -1px;
  width: 12px;
  height: 2px;
  background: var(--k, var(--series-2));
  content: "";
  transform: rotate(45deg);
}

.key--cross::after {
  transform: rotate(-45deg);
}

.demo__readout {
  min-height: 2.9em;
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.55;
}

.demo__readout b {
  color: var(--text);
  font-weight: 500;
}

.demo figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

@media (max-width: 620px) {
  .demo__stage {
    height: 300px;
  }
}

/* --------------------------------------------------------------------------
   Further work, methods, publications
   -------------------------------------------------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 32px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card .badge {
  align-self: flex-start;
  margin-bottom: 4px;
}

.cards--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card--post {
  padding: 26px;
}

.card--post h4 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.card--post p {
  font-size: 0.98rem;
}

.card__when {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card__link {
  margin-top: auto;
  padding-top: 12px;
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
}

.card__link:hover {
  text-decoration: underline;
}

/* the whole card is the link target */
.card--post {
  position: relative;
  transition: border-color 0.15s, transform 0.15s;
}

.card--post:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.card__link::after {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  content: "";
}

.card h4 {
  font-size: 1.06rem;
  font-weight: 600;
  line-height: 1.32;
}

.card p {
  margin: 0;
  color: var(--text-2);
  font-size: 0.92rem;
}

.card__meta {
  margin-top: auto;
  padding-top: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.5;
}

@media (max-width: 900px) {
  .cards {
    grid-template-columns: 1fr;
  }
}

.subhead {
  margin-top: clamp(56px, 7vw, 88px);
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  font-weight: 400;
  letter-spacing: -0.01em;
}

.stack {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  margin: 48px 0 0;
  padding-top: 28px;
  border-top: 1px solid var(--line-strong);
}

.stack h3 {
  margin-bottom: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

@media (max-width: 900px) {
  .stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .stack {
    grid-template-columns: 1fr;
  }
}

.pubs {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.pubgroup {
  margin-top: 44px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pub {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 24px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.pub__status {
  padding-top: 2px;
}

.pub__title {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.35;
}

.pub__authors {
  margin: 6px 0 0;
  color: var(--text-2);
  font-size: 0.94rem;
}

.pub__authors b {
  color: var(--text);
  font-weight: 600;
}

.pub__venue {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.pub__venue em {
  color: var(--text-2);
}

@media (max-width: 680px) {
  .pub {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

/* --------------------------------------------------------------------------
   Civil engineering track (light "paper")
   -------------------------------------------------------------------------- */

.civil {
  position: relative;
  background-color: var(--bg);
  background-image: linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: center top;
}

.civil::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--bg) 0, rgba(243, 240, 232, 0.72) 180px, rgba(243, 240, 232, 0.72) 100%);
  content: "";
  pointer-events: none;
}

.civil > .wrap {
  position: relative;
}

.civil__grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: clamp(28px, 5vw, 72px);
  margin-top: 48px;
  align-items: start;
}

.frame {
  position: sticky;
  top: 88px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.frame__stage {
  position: relative;
  height: 470px;
}

.frame__stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.frame figcaption {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--text-2);
  font-size: 0.86rem;
  line-height: 1.5;
}

.frame__readout {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.block + .block {
  margin-top: 48px;
}

.block__title {
  margin-bottom: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.entry {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 20px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.entry__when {
  padding-top: 3px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

.entry h4 {
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.32;
}

.entry__where {
  margin: 3px 0 0;
  color: var(--text-2);
  font-size: 0.94rem;
}

.entry__text {
  margin: 8px 0 0;
  color: var(--text-2);
  font-size: 0.95rem;
}

.entry .tags {
  margin-top: 12px;
}

.theme-paper .tags li {
  background: var(--surface);
}

@media (max-width: 980px) {
  .civil__grid {
    grid-template-columns: 1fr;
  }

  .frame {
    position: static;
  }

  .frame__stage {
    height: 380px;
  }
}

@media (max-width: 560px) {
  .entry {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* --------------------------------------------------------------------------
   Contact + footer
   -------------------------------------------------------------------------- */

.contact {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: clamp(32px, 6vw, 88px);
  align-items: end;
}

.contact__title {
  max-width: 16ch;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5.4vw, 4.2rem);
  font-weight: 400;
  letter-spacing: -0.022em;
  line-height: 1.04;
}

.contact__text {
  max-width: 48ch;
  margin: 22px 0 28px;
  color: var(--text-2);
  font-size: 1.1rem;
}

.links {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.links a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
}

.links a:hover span:first-child {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.links span:last-child {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-align: right;
}

@media (max-width: 860px) {
  .contact {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

.footer {
  padding: 28px 0 40px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.84rem;
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
}
