/* Iris — Portfolio & C++20 relativistic engine UI. */

@font-face {
  font-family: "Jost";
  src: url("assets/fonts/jost-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("assets/fonts/geist-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("assets/fonts/geist-mono-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:root {
  --grotesk: "Geist", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --futura: "Jost", Futura, "Century Gothic", sans-serif;

  --night: #03050a;
  --light: #f3f7ff;
  --soft: rgba(243, 247, 255, 0.56);
  --blue: #8fd0ff;

  /* Normal-composited editorial tokens for the side-stage chapters */
  --ink: #f2f6ff;
  --prose: rgba(236, 243, 255, 0.80);
  --muted: rgba(235, 242, 255, 0.66);
  --faint: rgba(225, 235, 255, 0.42);
  --rule: rgba(243, 247, 255, 0.13);
  --head-rule: rgba(243, 247, 255, 0.26);
  --accent: #8fd0ff;
  --veil-solid: rgba(3, 5, 10, 0.92);
  --veil-mid: rgba(3, 5, 10, 0.74);
  --code-bg: rgba(243, 247, 255, 0.05);

  --edge: clamp(18px, 2.6vw, 44px);
  --low: calc(var(--edge) * 0.8);
}

html[data-mode="light"] {
  --night: #e2e3e5;
  --blue: #ce931d;

  --ink: #111318;
  --prose: rgba(17, 19, 24, 0.82);
  --muted: rgba(17, 19, 24, 0.68);
  --faint: rgba(17, 19, 24, 0.46);
  --rule: rgba(17, 19, 24, 0.14);
  --head-rule: rgba(17, 19, 24, 0.26);
  --accent: #1548b8;
  --veil-solid: rgba(226, 227, 229, 0.94);
  --veil-mid: rgba(226, 227, 229, 0.80);
  --code-bg: rgba(17, 19, 24, 0.055);

  color-scheme: light;
}
html { color-scheme: dark; }

html, body { background: var(--night); color: var(--light); }

.page { position: fixed; inset: 0; overflow: hidden; contain: strict; }

#gl, #hud { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#hud { pointer-events: none; mix-blend-mode: difference; }
#hud[hidden] { display: none; }

.top, .foot, .note dl {
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.top, .foot {
  position: absolute;
  left: var(--edge);
  right: var(--edge);
  display: flex;
  align-items: center;
  gap: 1.8em;
  mix-blend-mode: difference;
  z-index: 30;
}
.top { top: var(--low); justify-content: flex-end; align-items: baseline; pointer-events: none; }
.top a, .top button { pointer-events: auto; }
.foot { bottom: var(--low); justify-content: flex-end; color: var(--soft); pointer-events: none; }
a { color: inherit; text-decoration: none; border-bottom: 1px solid currentColor; padding-bottom: 2px; transition: color 0.3s; }
a:hover, a:focus-visible { color: var(--blue); outline: none; }

/* Top-right chapter navigation */
.chapters {
  display: flex;
  align-items: baseline;
  gap: clamp(1em, 1.8vw, 2.1em);
  pointer-events: auto;
}
.chapters button {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--soft);
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 0 0 4px;
  margin-right: -0.14em;
  cursor: pointer;
  transition: color 0.35s, border-color 0.35s;
}
.chapters button[aria-pressed="true"] {
  color: var(--light);
  border-bottom-color: currentColor;
}
.chapters button:hover, .chapters button:focus-visible {
  color: var(--blue);
  outline: none;
}

.mode { display: flex; align-items: center; gap: 0.95em; }
.mode button, .card button {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  transition: color 0.4s;
}
.mode button[data-mode], .card span, .card button { margin-right: -0.14em; }
.mode button[aria-pressed="true"], .card button[aria-pressed="true"] { color: var(--light); }
.mode button:hover, .mode button:focus-visible, .card button:hover, .card button:focus-visible { color: var(--blue); outline: none; }
.mode .hole {
  position: relative;
  width: 11px;
  height: 11px;
  border: 1px solid var(--light);
  border-radius: 50%;
  color: var(--light);
}
.mode .hole::before { content: ""; position: absolute; inset: -9px -6px; }
.mode .hole::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  background: currentColor;
  transform: scale(0);
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
html[data-mode="light"] .mode .hole::after { transform: scale(1); }
.mode .hole:hover, .mode .hole:focus-visible { border-color: var(--blue); }

.card { display: flex; align-items: baseline; gap: 0.95em; color: var(--soft); }
.card[hidden] { display: none; }

.name {
  position: absolute;
  left: var(--edge);
  top: calc(var(--low) + 9px - 1.172em);
  margin: 0;
  font: 500 clamp(13px, 0.8vw, 17px)/1.75 var(--futura);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  mix-blend-mode: difference;
  opacity: 0;
  transition: opacity 1.6s;
  z-index: 30;
}
.name.in { opacity: 1; }
.name .brand {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.name .brand:focus-visible { color: var(--blue); outline: none; }
.name span { font-weight: 400; color: var(--soft); }

/* --- Side-Stage Editorial Column (Direction B) ----------------------------- */

.stage-veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, var(--veil-solid) 0%, var(--veil-mid) 40%, transparent 66%);
  opacity: 0;
  transition: opacity 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 10;
}
html[data-stage-open="true"] .stage-veil { opacity: 1; }

.stage {
  position: absolute;
  left: var(--edge);
  top: calc(var(--low) + 64px);
  bottom: calc(var(--low) + 38px);
  --bar: 20px;                               /* room kept at the right for the scrollbar, */
  --grip: 11px;                              /* of which this much is the scrollbar itself */
  width: calc(min(50ch, 45vw) + var(--bar));
  padding-right: calc(var(--bar) - var(--grip));
  scrollbar-gutter: stable;                  /* kept whether or not there is anything to scroll, so the text never moves */
  color: var(--ink);
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.38s cubic-bezier(0.2, 0.8, 0.2, 1),
              transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1),
              width 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
/* The scrollbar: a line 3px wide at the right of its room, with the whole
   room to take hold of it by. It is there only when the chapter is longer
   than its place. */
.stage::-webkit-scrollbar { width: var(--grip); }
.stage::-webkit-scrollbar-track { background: transparent; }
.stage::-webkit-scrollbar-thumb {
  background: var(--faint);
  background-clip: padding-box;
  border-left: calc(var(--grip) - 3px) solid transparent;
}
.stage::-webkit-scrollbar-thumb:hover, .stage::-webkit-scrollbar-thumb:active { background-color: var(--ink); }
@supports not selector(::-webkit-scrollbar) {
  .stage { scrollbar-width: thin; scrollbar-color: var(--faint) transparent; }
}
/* A chapter stands in the middle of its place where it fits, and starts from
   the top where it has to be scrolled (centred by the place itself, its top
   would be cut off out of reach). */
.panel { margin-block: auto; }
.stage[data-reading="true"] .panel { margin-block: 0; }
.stage[hidden] { display: none; }
.stage.in { opacity: 1; transform: translateY(0); }
.stage[data-reading="true"] {
  width: calc(min(58ch, 48vw) + var(--bar));
  padding-top: 4px;
}

.panel[hidden], .reader[hidden] { display: none; }

.panel {
  animation: panelFade 0.36s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes panelFade {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1em;
  margin: 0 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--head-rule);
}
.section-head::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 34px;
  height: 2px;
  background: var(--accent);
}
.section-title {
  margin: 0;
  font: 300 clamp(25px, 1.9vw, 30px)/1 var(--futura);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink);
}
.section-tag {
  font: 500 10px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
}

.rows { display: flex; flex-direction: column; }

.row, .note-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}
.rows > :first-child { border-top: 0; padding-top: 2px; }

.row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1em;
  margin-bottom: 5px;
  font: 500 10px/1.2 var(--mono);
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.row-meta { color: var(--faint); }
.row-tag  { color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }

.row-title {
  display: block;
  margin: 0 0 5px;
  font: 600 clamp(15px, 1.05vw, 16.5px)/1.28 var(--grotesk);
  letter-spacing: -0.015em;
  color: var(--ink);
}

.row-body {
  display: block;
  margin: 0;
  font: 400 13.2px/1.55 var(--grotesk);
  color: var(--muted);
}

.row-points {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.row-points li {
  position: relative;
  padding-left: 13px;
  font: 400 12.8px/1.52 var(--grotesk);
  color: var(--muted);
}
.row-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 5px;
  height: 1px;
  background: var(--accent);
}

.row-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.3em;
  margin-top: 9px;
  font: 500 10.5px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.row-links a, .reader-foot a, .text-btn, .back-btn, .copy-btn {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--ink);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 0 0 2px;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s;
}
.row-links a:hover, .reader-foot a:hover, .text-btn:hover, .back-btn:hover, .copy-btn:hover,
.row-links a:focus-visible, .reader-foot a:focus-visible, .text-btn:focus-visible, .back-btn:focus-visible, .copy-btn:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  outline: none;
}

/* Clickable engineering note cards */
.note-item {
  width: 100%;
  padding: 16px 0;
  text-align: left;
  background: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  cursor: pointer;
  transition: padding-left 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.note-item .row-title {
  font-size: clamp(15.5px, 1.12vw, 18px);
  margin-bottom: 6px;
}
.note-item .row-body {
  font-size: 13.5px;
  line-height: 1.58;
}
.note-item:hover, .note-item:focus-visible {
  padding-left: 6px;
  outline: none;
}
.note-item:hover .row-title, .note-item:focus-visible .row-title {
  color: var(--accent);
}

/* Inline Note / Postmortem Reader */
.reader {
  animation: panelFade 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  padding-bottom: 18px;
}
.reader-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--rule);
  font: 500 10.5px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.reader-title {
  margin: 16px 0 14px;
  font: 600 clamp(19px, 1.42vw, 24px)/1.22 var(--grotesk);
  letter-spacing: -0.022em;
  color: var(--ink);
}
.reader-body {
  font: 400 clamp(13.8px, 0.96vw, 14.8px)/1.68 var(--grotesk);
  color: var(--prose);
}
.reader-body p { margin: 0 0 13px; }
.reader-body > p > a {
  color: var(--ink);
  border-bottom-color: var(--head-rule);
}
.reader-body > p > a:hover, .reader-body > p > a:focus-visible {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.reader-body h3 {
  margin: 22px 0 7px;
  font: 600 clamp(14.5px, 1.02vw, 16px)/1.3 var(--grotesk);
  letter-spacing: -0.012em;
  color: var(--ink);
}
.reader-body code {
  font: 500 12.2px/1 var(--mono);
  color: var(--ink);
  background: var(--code-bg);
  padding: 2px 5px;
}
.reader-body pre {
  margin: 12px 0 15px;
  padding: 12px 14px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
  background: var(--code-bg);
  border: 1px solid var(--rule);
  font: 400 11.6px/1.55 var(--mono);
  color: var(--ink);
}
.reader-body pre::-webkit-scrollbar { height: 3px; }
.reader-body pre::-webkit-scrollbar-track { background: transparent; }
.reader-body pre::-webkit-scrollbar-thumb { background: var(--faint); }
.reader-body pre code {
  padding: 0;
  background: none;
  font: inherit;
}
.reader-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 12px 0 16px;
  padding: 11px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.reader-metrics div span {
  display: block;
  font: 500 9.5px/1.2 var(--mono);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 4px;
}
.reader-metrics div b {
  font: 600 14px/1.2 var(--mono);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.reader-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.2em;
  margin-top: 20px;
  padding-top: 13px;
  border-top: 1px solid var(--rule);
  font: 500 10.5px/1 var(--mono);
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

/* Contact Spec Sheet */
.spec {
  margin: 0;
  border-top: 0;
}
.spec div:first-child {
  padding-top: 2px;
}
.spec div {
  display: flex;
  align-items: baseline;
  gap: 1.4em;
  padding: 11px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  line-height: 1.45;
}
.spec dt {
  flex: 0 0 7.2em;
  font: 500 10.5px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.spec dd {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1em;
  color: var(--ink);
  font-family: var(--grotesk);
}
.spec dd a {
  color: var(--ink);
  border-bottom-color: var(--rule);
}
.spec dd a:hover, .spec dd a:focus-visible {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.copy-btn {
  font: 500 10px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

/* --- Dial & Bottom-Left Telemetry ------------------------------------------ */

.dial {
  --at: -1;
  --pitch: 72px;
  position: absolute;
  left: 50%;
  bottom: var(--low);
  width: 332px;
  margin-left: -166px;
  text-align: center;
  mix-blend-mode: difference;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s, visibility 0s 0.9s, left 0.75s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 25;
}
.dial.in { opacity: 1; visibility: visible; transition: opacity 0.9s, left 0.75s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* When a side-stage chapter opens on wide screens, glide the dial right so it
   stays centered beneath the shifted eye / black hole. */
@media (min-width: 980px) {
  html[data-stage-open="true"] .dial { left: 74.5%; }
}

.dial-name {
  position: relative;
  height: 1em;
  margin: 0 0 1.05em;
  font: 500 12px/1 var(--futura);
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  text-transform: uppercase;
}
.dial-name span { position: absolute; inset: 0; opacity: 0; transition: opacity 0.35s; }
.dial-name span.on { opacity: 1; transition: opacity 0.45s 0.12s; }
.dial-rule { position: relative; height: 31px; }
.dial-rule::after { content: ""; position: absolute; left: 50%; top: 0; width: 1px; height: 15px; margin-left: -0.5px; background: var(--light); }
.dial-fade {
  position: absolute;
  inset: 0 0 auto;
  height: 15px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 24%, #000 76%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 24%, #000 76%, transparent);
}
.dial-ticks, .dial-strip {
  position: absolute;
  left: 50%;
  top: 0;
  width: calc(var(--pitch) * 8 + 1px);
  height: 100%;
  margin-left: calc(var(--pitch) * -4 - 0.5px);
  transform: translateX(calc(var(--at) * var(--pitch) * -1));
  transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.dial-ticks {
  background:
    repeating-linear-gradient(90deg, var(--light) 0 1px, transparent 1px var(--pitch)) 0 3px / 100% 9px no-repeat,
    repeating-linear-gradient(90deg, var(--soft) 0 1px, transparent 1px calc(var(--pitch) / 8)) 0 7px / 100% 5px no-repeat;
}
.dial-strip button {
  position: absolute;
  top: -10px;
  width: var(--pitch);
  margin-left: calc(var(--pitch) / -2);
  padding: 31px 0 7px;
  font: 500 10px/1 var(--mono);
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  color: var(--soft);
  background: none;
  border: 0;
  cursor: pointer;
  transition: color 0.4s;
}
.dial-strip { pointer-events: none; }
.dial-strip button { pointer-events: auto; }
.dial-strip button:nth-child(1) { left: calc(var(--pitch) * 3 + 0.5px); }
.dial-strip button:nth-child(2) { left: calc(var(--pitch) * 4 + 0.5px); }
.dial-strip button:nth-child(3) { left: calc(var(--pitch) * 5 + 0.5px); }
.dial-strip button[aria-pressed="true"] { color: var(--light); }
.dial-strip button:hover, .dial-strip button:focus-visible { color: var(--blue); outline: none; }

.dial-again {
  display: flex;
  align-items: center;
  gap: 0.8em;
  width: max-content;
  margin: calc(1.24em + 1px - 7px) auto -7px;
  padding: 7px 16px;
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft);
  background: none;
  border: 0;
  cursor: pointer;
  transition: color 0.4s;
}
.dial-again span { margin-right: -0.14em; }
.dial-again::before {
  content: "";
  width: 9px;
  height: 9px;
  border: 1px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  transform: rotate(45deg);
  transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.dial-again:hover, .dial-again:focus-visible { color: var(--blue); outline: none; }
.dial-again:hover::before, .dial-again:focus-visible::before { transform: rotate(405deg); }
.dial.held .dial-again { visibility: hidden; }

.note {
  position: absolute;
  left: var(--edge);
  bottom: var(--low);
  width: min(40ch, 62vw);
  mix-blend-mode: difference;
  opacity: 0;
  transition: opacity 0.45s;
}
.note.in { opacity: 1; }
html[data-stage-open="true"] .note {
  opacity: 0;
  pointer-events: none;
}
.note dl { margin: 0; }
.note dl div { display: flex; gap: 1.2em; padding: 0.62em 0; border-top: 1px solid rgba(243, 247, 255, 0.24); }
.note dl div:last-child { padding-bottom: 0; }
.note dt { flex: 0 0 6.4em; color: var(--soft); }
.note dd { margin: 0; font-variant-numeric: tabular-nums; text-transform: none; letter-spacing: 0.05em; white-space: nowrap; }
.note sub { font-size: 0.8em; vertical-align: -0.2em; line-height: 0; }

@media (max-width: 1160px) {
  .note { bottom: calc(var(--low) + 2.6em + 11px * 2.24 + 1px); }
}

/* Mobile & Portrait Layout */
@media (max-width: 820px), (max-aspect-ratio: 21/20) {
  .top {
    top: calc(var(--low) + 42px);
    justify-content: flex-start;
  }
  .chapters { gap: 1.15em; }
  .stage-veil {
    background: linear-gradient(180deg, var(--veil-mid) 0%, transparent 13%, transparent 23%, var(--veil-mid) 36%, var(--veil-solid) 48%);
  }
  .stage, .stage[data-reading="true"] {
    --bar: 5px;
    --grip: 5px;
    left: var(--edge);
    right: calc(var(--edge) - var(--bar));
    width: auto;
    top: 37%;
    bottom: calc(var(--low) + 28px);
  }
  .panel { margin-block: 0; }
  html[data-stage-open="true"] .dial {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  .note { bottom: calc(var(--low) + 2.6em); width: auto; right: var(--edge); }
  .dial { bottom: calc(var(--low) + 140px); }
  .card { display: none; }
  .note dl div:nth-child(3), .note dl div:nth-child(4) { display: none; }
}

#gl { touch-action: none; }

@media (prefers-reduced-motion: reduce) {
  .name, .note, .dial, .dial-name span, .dial-ticks, .dial-strip, .mode .hole::after, .dial-again::before, .stage, .stage-veil, .panel {
    transition: none;
    animation: none;
  }
}
