/* Theme shared with https://pooya.ai/timeline (assets/css/site.css in the
   portfolio repository), with the green accent replaced by cyan. */
:root {
  --ink: #e8f2f4;
  --ink-muted: #91a7ad;
  --ink-faint: #586f75;
  --accent: #56e8ff;
  --accent-bright: #c3f6ff;
  --accent-dim: #1b93a9;
  --void: #010304;
  --void-soft: #02080a;
  --panel: rgba(0, 5, 7, 0.9);
  --line: rgba(125, 230, 255, 0.2);
  --line-soft: rgba(125, 230, 255, 0.13);
  --line-strong: rgba(125, 230, 255, 0.48);
  --danger: #ffb081;
  --header-height: 88px;
  --toolbar-height: 104px;
  --page-gutter: clamp(1rem, 4vw, 4.5rem);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --scale: 1.5;
}

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

html {
  min-width: 320px;
  background: var(--void);
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--void);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  color: inherit;
  font: inherit;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}

a:hover {
  color: var(--accent-bright);
}

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

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--void);
  background: var(--accent-bright);
  font: 700 0.75rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  transform: translateY(-180%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* Header */

.site-header {
  position: fixed;
  z-index: 30;
  inset: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  height: var(--header-height);
  padding: max(1rem, env(safe-area-inset-top)) var(--page-gutter) 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(1, 3, 4, 0.94);
}

.wordmark {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.wordmark-name {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.035em;
}

.primary-nav {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: clamp(0.85rem, 2.5vw, 2.25rem);
  font: 600 0.68rem/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.primary-nav a {
  position: relative;
  padding-block: 0.6rem;
  color: var(--ink-muted);
  text-decoration: none;
  white-space: nowrap;
}

.primary-nav a::after {
  position: absolute;
  right: 0;
  bottom: 0.15rem;
  left: 0;
  height: 1px;
  background: var(--accent);
  content: "";
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 180ms ease;
}

.primary-nav a:hover::after,
.primary-nav a:focus-visible::after,
.primary-nav a[aria-current="page"]::after {
  transform: scaleX(1);
  transform-origin: left;
}

.primary-nav a[aria-current="page"] {
  color: var(--accent);
}

/* Shared pieces */

.eyebrow {
  margin: 0 0 1rem;
  color: var(--accent);
  font: 700 0.67rem/1.25 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  color: var(--accent-bright);
  background: rgba(86, 232, 255, 0.04);
  font: 700 0.65rem/1 var(--mono);
  letter-spacing: 0.07em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover {
  color: var(--accent-bright);
  background: rgba(86, 232, 255, 0.12);
}

.tag {
  color: var(--tag, var(--accent));
  font: 600 0.75rem/1.4 var(--mono);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 1px solid transparent;
}

.tag:hover {
  color: var(--tag, var(--accent));
  border-bottom-color: currentColor;
}

/* Toolbar: search, view switch, tags */

.toolbar {
  position: fixed;
  z-index: 20;
  inset: var(--header-height) 0 auto;
  height: var(--toolbar-height);
  padding: 0 var(--page-gutter);
  border-bottom: 1px solid var(--line);
  background: rgba(1, 3, 4, 0.88);
}

.search {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 60px;
}

.search-prompt {
  color: var(--accent);
  font: 600 0.82rem/1 var(--mono);
  white-space: nowrap;
}

.search input {
  flex: 1;
  min-width: 0;
  height: 2.2rem;
  padding: 0 0.15rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  color: var(--ink);
  background: transparent;
  font: 400 0.82rem/1 var(--mono);
  appearance: none;
}

.search input:focus {
  border-bottom-color: var(--accent);
}

.search input::placeholder {
  color: var(--ink-faint);
}

.search input::-webkit-search-cancel-button {
  appearance: none;
}

.search-status {
  color: var(--ink-muted);
  font: 400 0.7rem/1 var(--mono);
  white-space: nowrap;
}

.tag-bar {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  height: 44px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tag-bar::-webkit-scrollbar {
  display: none;
}

.tag-bar .tag[aria-pressed="true"] {
  border-bottom-color: currentColor;
  font-weight: 700;
}

.tag-bar.is-filtering .tag:not([aria-pressed="true"]) {
  color: var(--ink-faint);
}

/* 3D scene */

.scene {
  position: fixed;
  z-index: 0;
  inset: 0;
  visibility: hidden;
  background: var(--void);
}

#webgpu-canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
  touch-action: none;
  cursor: grab;
}

.scene.is-dragging #webgpu-canvas {
  cursor: grabbing;
}

.scene.is-hovering #webgpu-canvas {
  cursor: pointer;
}

.scene-scan {
  position: absolute;
  inset: 0;
  opacity: 0.5;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(86, 232, 255, 0.04) 0,
    rgba(86, 232, 255, 0.04) 1px,
    transparent 1px,
    transparent 7px
  );
}

.scene-labels {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.scene-label {
  position: absolute;
  top: 0;
  left: 0;
  padding: 0.2rem 0.45rem;
  border: 0;
  border-left: 2px solid var(--tag, var(--accent));
  border-radius: 0;
  pointer-events: auto;
  cursor: pointer;
  color: var(--ink);
  background: rgba(1, 3, 4, 0.85);
  font: 600 0.69rem/1.4 var(--mono);
  white-space: nowrap;
  will-change: transform;
}

.scene-label::before {
  color: var(--tag, var(--accent));
  content: "> ";
}

.scene-label.is-active,
.scene-label:hover {
  color: #fff;
}

.scene-reticle {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  will-change: transform;
}

.scene-reticle i {
  position: absolute;
  width: 7px;
  height: 7px;
  border: 0 solid var(--accent-bright);
}

.scene-reticle i:nth-child(1) { top: calc(var(--r) * -1); left: calc(var(--r) * -1); border-top-width: 1.5px; border-left-width: 1.5px; }
.scene-reticle i:nth-child(2) { top: calc(var(--r) * -1); right: calc(var(--r) * -1); border-top-width: 1.5px; border-right-width: 1.5px; }
.scene-reticle i:nth-child(3) { bottom: calc(var(--r) * -1); left: calc(var(--r) * -1); border-bottom-width: 1.5px; border-left-width: 1.5px; }
.scene-reticle i:nth-child(4) { bottom: calc(var(--r) * -1); right: calc(var(--r) * -1); border-bottom-width: 1.5px; border-right-width: 1.5px; }

/* Preview panel for the selected note */

.preview {
  position: fixed;
  z-index: 15;
  top: calc(var(--header-height) + var(--toolbar-height) + 1.25rem);
  right: var(--page-gutter);
  width: min(24rem, calc(100vw - 2 * var(--page-gutter)));
  padding: 1.25rem;
  border: 1px solid var(--line);
  background: var(--panel);
}

.preview::before {
  position: absolute;
  top: -1px;
  left: -1px;
  width: 3rem;
  height: 1px;
  background: var(--accent);
  content: "";
}

.preview h2 {
  margin: 0 0 0.6rem;
  font: 600 0.95rem/1.5 var(--mono);
}

.preview h2::before {
  color: var(--accent);
  content: "> ";
}

.preview p:not(.eyebrow) {
  margin: 0 0 0.85rem;
  color: #fff;
  font: 400 0.8rem/1.7 var(--mono);
}

/* Timeline list */

.timeline {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  padding: calc(var(--header-height) + var(--toolbar-height) + 2rem) var(--page-gutter) 5rem;
  background: var(--void-soft);
}

.timeline-inner,
.page-inner {
  max-width: 72rem;
  margin: 0 auto;
}

.list-summary {
  margin: 0;
  color: var(--ink-muted);
  font: 400 0.78rem/1.6 var(--mono);
}

.year-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin: 2.5rem 0 1rem;
  color: var(--accent);
  font: 700 calc(0.7rem * var(--scale))/1 var(--mono);
  letter-spacing: 0.12em;
}

.year-divider::before,
.year-divider::after {
  flex: 1;
  height: 1px;
  background: var(--line-strong);
  content: "";
}

.note-item {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 1rem clamp(1.5rem, 3vw, 3rem);
  padding: 0.95rem 0 1.4rem;
  border-top: 1px solid var(--line-soft);
}

.year-divider + .note-item {
  border-top: 0;
}

.note-item time {
  padding-top: 0.2rem;
  color: var(--accent);
  font: 600 calc(0.72rem * var(--scale))/1.5 var(--mono);
}

.note-item h3 {
  margin: 0 0 0.45rem;
  font: 600 calc(clamp(0.78rem, 1.3vw, 0.9rem) * var(--scale))/1.5 var(--mono);
}

.note-item h3::before {
  color: var(--accent);
  content: "> ";
}

.note-item h3 a {
  text-decoration: none;
}

.note-item p {
  max-width: 54rem;
  margin: 0 0 0.6rem;
  color: #fff;
  font: 400 calc(clamp(0.7rem, 1.15vw, 0.82rem) * var(--scale))/1.7 var(--mono);
}

.note-item mark,
.preview mark {
  color: #fff;
  background: rgba(86, 232, 255, 0.25);
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  margin: 0 0 0.9rem;
  padding: 0;
  list-style: none;
}

.note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.list-more {
  min-height: 2rem;
  padding-top: 1rem;
  color: var(--ink-faint);
  font: 400 0.75rem/1.6 var(--mono);
}

/* View modes. Without JavaScript or WebGPU the page stays in list mode.
   "waiting-for-scene" is set before the first frame when the browser has
   WebGPU, so the page opens on the scene and the list never flashes by. */

body.view-3d,
.waiting-for-scene body {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

body.view-3d .scene,
.waiting-for-scene .scene {
  visibility: visible;
}

body.view-3d .toolbar,
.waiting-for-scene .toolbar {
  background: rgba(1, 3, 4, 0.82);
}

body.view-3d .timeline,
body.view-3d .site-footer,
.waiting-for-scene .timeline,
.waiting-for-scene .site-footer {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.scene-status {
  position: absolute;
  top: 50%;
  left: 50%;
  display: none;
  margin: 0;
  color: var(--ink-muted);
  font: 400 0.78rem/1.6 var(--mono);
  transform: translate(-50%, -50%);
}

.scene-status::before {
  color: var(--accent);
  content: "> ";
}

.waiting-for-scene .scene-status {
  display: block;
}

body:not(.view-3d) .preview {
  display: none;
}

/* Note and tag pages */

.page {
  position: relative;
  padding: calc(var(--header-height) + clamp(2.5rem, 6vw, 5rem)) var(--page-gutter) 5rem;
  background: var(--void-soft);
}

.page-header {
  margin: 0 0 clamp(2rem, 5vw, 3.5rem);
  padding: 0 0 1.5rem;
  border-bottom: 1px solid var(--line);
}

.page-header h1 {
  margin: 0 0 0.85rem;
  color: var(--accent);
  font: 600 calc(clamp(0.95rem, 2vw, 1.2rem) * var(--scale))/1.5 var(--mono);
}

.page-header > p:not(.eyebrow) {
  max-width: 54rem;
  margin: 0 0 1rem;
  color: var(--ink-muted);
  font: 400 calc(clamp(0.72rem, 1.2vw, 0.86rem) * var(--scale))/1.7 var(--mono);
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin: 0;
  padding: 0;
  color: var(--ink-muted);
  list-style: none;
  font: 400 0.75rem/1.6 var(--mono);
}

.page-meta {
  font-size: 0.9rem;
}

.page-meta .tag {
  font-size: inherit;
}

.page-header .eyebrow {
  font-size: 0.8rem;
}

.prose {
  max-width: 54rem;
  color: #fff;
  font: 400 calc(clamp(0.7rem, 1.15vw, 0.82rem) * var(--scale))/1.8 var(--mono);
  overflow-wrap: break-word;
}

.prose > :first-child {
  margin-top: 0;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose pre,
.prose table,
.prose figure {
  margin: 0 0 1.4em;
}

.prose h2,
.prose h3,
.prose h4 {
  margin: 2.2em 0 0.8em;
  color: var(--ink);
  font: 600 1.1em/1.5 var(--mono);
}

.prose h2::before {
  color: var(--accent);
  content: "## ";
}

.prose h3::before {
  color: var(--accent);
  content: "### ";
}

.prose h4::before {
  color: var(--accent);
  content: "#### ";
}

.prose a {
  color: var(--accent-bright);
}

.prose strong {
  color: var(--ink);
  font-weight: 700;
}

.prose ul,
.prose ol {
  padding-left: 1.6em;
}

.prose li::marker {
  color: var(--accent);
}

.prose blockquote {
  padding: 0.2em 0 0.2em 1.2em;
  border-left: 1px solid var(--line-strong);
  color: var(--ink-muted);
}

.prose hr {
  height: 1px;
  margin: 2.5em 0;
  border: 0;
  background: var(--line);
}

.prose img,
.prose video {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
}

.prose code {
  padding: 0.1em 0.35em;
  color: var(--accent-bright);
  background: rgba(86, 232, 255, 0.08);
  font-size: 0.92em;
}

.prose pre {
  padding: 1.1em 1.25em;
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--void);
  font-size: 0.85em;
  line-height: 1.65;
}

.prose pre code {
  padding: 0;
  color: var(--ink);
  background: none;
  font-size: inherit;
}

.prose .table-wrap {
  margin: 0 0 1.4em;
  overflow-x: auto;
}

.prose table {
  margin: 0;
  border-collapse: collapse;
  font-size: 0.9em;
}

.prose th,
.prose td {
  padding: 0.5em 0.9em;
  border: 1px solid var(--line);
  text-align: left;
}

.prose th {
  color: var(--accent);
  font-weight: 600;
}

/* Code highlighting (Pygments token classes) */
.prose .k, .prose .kc, .prose .kd, .prose .kn, .prose .kp, .prose .kr, .prose .kt, .prose .ow { color: var(--accent); }
.prose .s, .prose .s1, .prose .s2, .prose .sb, .prose .sc, .prose .sd, .prose .se, .prose .sh, .prose .si, .prose .sr, .prose .ss, .prose .sx, .prose .dl { color: #dea584; }
.prose .c, .prose .c1, .prose .ch, .prose .cm, .prose .cp, .prose .cpf, .prose .cs { color: var(--ink-faint); }
.prose .m, .prose .mb, .prose .mf, .prose .mh, .prose .mi, .prose .mo, .prose .il { color: #f1e05a; }
.prose .nf, .prose .fm, .prose .nc, .prose .nn, .prose .nd, .prose .ne { color: var(--accent-bright); }
.prose .nb, .prose .bp, .prose .nt, .prose .na { color: #a97bff; }
.prose .o, .prose .p { color: var(--ink-muted); }
.prose .gd { color: var(--danger); }
.prose .gi { color: #89e051; }

/* The block between the rule and the buttons is as tall as the title and the
   tags above the article, so the buttons under the article sit as far from
   their rule as the buttons above it do. */
.note-footer {
  margin: clamp(3rem, 6vw, 4.5rem) 0 0;
  padding: 1.5rem 0 0;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font: 400 0.8rem/1.7 var(--mono);
}

.note-footer .note-history {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
  min-height: calc(clamp(0.95rem, 2vw, 1.2rem) * var(--scale) * 1.5 + 0.85rem + 0.9rem * 1.6);
  margin: 0 0 1rem;
}

.note-history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
}

.note-history-tags:empty {
  display: none;
}

.note-footer .note-history .tag {
  color: var(--tag, var(--accent));
  font-size: 0.9rem;
}

.note-neighbours {
  margin-top: 1.5rem;
}

.note-footer p {
  margin: 0;
}

.note-footer a {
  color: var(--accent-bright);
}

.note-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.page-header .note-bar {
  margin: 0 0 1rem;
}

.note-bar .eyebrow {
  margin: 0;
}

.note-share {
  display: flex;
  gap: 0.6rem;
  margin-left: auto;
}

.note-neighbours {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
}

/* Footer */

.site-footer {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  padding: 1.35rem var(--page-gutter);
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  background: #010405;
  font: 500 0.63rem/1.4 var(--mono);
  letter-spacing: 0.04em;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--accent-bright);
}

/* Responsive */

@media (max-width: 980px) {
  :root {
    --header-height: 104px;
  }

  .site-header {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 0.45rem 1rem;
    padding-bottom: 0.65rem;
  }

  .primary-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    justify-content: flex-start;
    gap: 1.4rem;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .primary-nav::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 620px) {
  :root {
    --header-height: 100px;
    --toolbar-height: 96px;
    --page-gutter: 1rem;
    --scale: 1.3;
  }

  .site-header {
    padding-top: max(0.7rem, env(safe-area-inset-top));
  }

  .wordmark-name {
    font-size: clamp(0.68rem, 3vw, 0.8rem);
  }

  .search {
    height: 54px;
  }

  .search-status {
    display: none;
  }

  .tag-bar {
    height: 42px;
  }

  .note-item {
    grid-template-columns: 3.9rem minmax(0, 1fr);
    gap: 0.75rem 1rem;
  }

  /* Under the article the buttons wrap onto two rows. Share and Feed take
     the first one, so they stay level with the pair above the article. */
  .note-footer .note-share {
    order: -1;
    width: 100%;
    justify-content: flex-end;
  }

  /* The preview becomes a bottom sheet so the scene stays visible above it. */
  .preview {
    top: auto;
    right: 0.75rem;
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    left: 0.75rem;
    width: auto;
    max-height: 46dvh;
    overflow-y: auto;
  }

}

@media (max-height: 690px) and (min-width: 621px) {
  :root {
    --header-height: 72px;
  }

  .site-header {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 1fr;
    gap: 1rem;
    padding-block: 0.65rem;
  }

  .primary-nav {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    width: auto;
  }
}

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

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .scene-scan {
    display: none;
  }

  .preview {
    background: Canvas;
  }
}

@media print {
  .site-header,
  .toolbar,
  .scene,
  .preview,
  .note-actions,
  .note-share {
    display: none !important;
  }

  .page,
  .timeline {
    padding-top: 0;
  }
}
