/* Dark, linear theme. Opt in with <body class="theme-dark">.
   Structure comes from 1px hairlines; no fills or shadows. */

@font-face {
  font-family: "JetBrains Mono";
  font-display: swap;
  src: url(assets/fonts/jetbrains-mono.woff2) format("woff2");
}

.theme-dark {
  --paper: #08090a;
  --ink: #f7f8f8;
  --muted: #8a8f98;
  --faint: #7d828a;
  --line: rgb(255 255 255 / 0.08);
  --accent: #f7f8f8;
  --wash: #0f1011;
  --draw: rgb(255 255 255 / 0.6);
  --card: rgb(255 255 255 / 0.015);
  --panel: rgb(255 255 255 / 0.04);
  --pill: rgb(255 255 255 / 0.4);
  --body-text: rgb(247 248 248 / 0.72);
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --serif: var(--sans);
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

/* Light variant: same layout and glows, inverted neutrals. Small text is at
   least 4.5:1 and the button outline at least 3:1 against --paper.
   Switched by the .theme-toggle button (theme.js) via a class on <html>. */
.light .theme-dark {
  --paper: #f7f8f8;
  --ink: #08090a;
  --muted: #4e535a;
  --faint: #686d75;
  --line: rgb(0 0 0 / 0.18);
  --accent: #08090a;
  --wash: #eef0f1;
  --draw: rgb(0 0 0 / 0.55);
  --card: rgb(0 0 0 / 0.015);
  --panel: rgb(0 0 0 / 0.04);
  --pill: rgb(0 0 0 / 0.45);
  --body-text: rgb(8 9 10 / 0.82);
}

/* Type: one sans family, medium weight for headings, mono for labels. */
.theme-dark h1,
.theme-dark h2 {
  font-weight: 500;
  letter-spacing: -0.03em;
}
.theme-dark .eyebrow,
.theme-dark .case-meta dt,
.theme-dark .flow-explainer span,
.theme-dark .zoom-label,
.theme-dark .evidence figcaption {
  font-family: var(--mono);
  font-weight: 400;
}
.theme-dark .eyebrow,
.theme-dark .case-meta dt {
  color: var(--faint);
}

/* Header: no divider, quiet links. */
.theme-dark .site-header {
  border-bottom: 0;
}
.theme-dark .site-header nav a {
  color: var(--muted);
  transition: color 0.2s ease;
}
.theme-dark .site-header nav a:hover {
  color: var(--ink);
  text-decoration: none;
}
.theme-dark .pill {
  color: var(--ink);
}
.theme-dark .pill:hover {
  color: var(--paper);
}
.theme-dark .wordmark span {
  color: var(--faint);
}

/* Light/dark switch: an outlined circle at the end of the header. */
.theme-dark .site-header nav {
  margin-left: auto;
}
.theme-toggle {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: 24px;
  padding: 0;
  border: 1px solid var(--pill);
  border-radius: 50%;
  background: none;
  color: var(--ink);
  transition: border-color 0.2s ease;
}
.theme-toggle:hover {
  border-color: var(--ink);
}
.theme-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.5s var(--ease-out);
}
.theme-toggle:hover svg {
  transform: rotate(20deg);
}
.theme-toggle .moon,
.light .theme-toggle .sun {
  display: none;
}
.light .theme-toggle .moon {
  display: block;
}
@media (max-width: 760px) {
  .theme-toggle {
    width: 32px;
    height: 32px;
    margin-left: 12px;
  }
}

/* Images: outlined frames instead of filled panels. */
.theme-dark .image-button,
.theme-dark .case-cover .image-button {
  background: var(--wash);
  border: 1px solid var(--line);
}
.theme-dark .zoom-label {
  border-color: var(--pill);
}

/* Hover outline that draws itself: four 1px lines grow from the corners. */
.theme-dark .image-button::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  --l: linear-gradient(var(--draw), var(--draw));
  background:
    var(--l) left top / 0 1px no-repeat,
    var(--l) right top / 1px 0 no-repeat,
    var(--l) right bottom / 0 1px no-repeat,
    var(--l) left bottom / 1px 0 no-repeat;
  transition: background-size 0.55s var(--ease-out);
}
.theme-dark .image-button:is(:hover, :focus-visible)::after {
  background-size:
    100% 1px,
    1px 100%,
    100% 1px,
    1px 100%;
}

.theme-dark footer {
  border-top-color: var(--line);
}
.theme-dark dialog::backdrop {
  background: rgb(0 0 0 / 0.8);
}

/* Floating back-to-top link, bottom right. */
.to-top {
  position: fixed;
  right: clamp(16px, 3vw, 40px);
  bottom: clamp(16px, 3vw, 40px);
  z-index: 20;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--pill);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition:
    opacity 0.3s var(--ease-out),
    transform 0.3s var(--ease-out),
    visibility 0s linear 0.3s,
    border-color 0.2s ease;
}
.to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity 0.3s var(--ease-out),
    transform 0.3s var(--ease-out),
    border-color 0.2s ease;
}
.to-top:hover {
  border-color: var(--ink);
}
.to-top svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s var(--ease-out);
}
.to-top:hover svg {
  transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
  .theme-dark .image-button::after {
    transition: none;
  }
}
