/* Craig Kapp @ NYU — site styles */

:root {
  --bg: #ffffff;
  --surface: #f6f4f8;
  --surface-strong: #ece8f1;
  --text: #1f1c24;
  --muted: #5d5868;
  --border: #e2dde9;
  --accent: #57068c;
  --accent-hover: #7a2bb3;
  --code-bg: #f3f0f6;
  --code-text: #4a0a74;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --wrap: 72rem;
  --measure: 46rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  --radius: 8px;
  --header-h: 4.75rem;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141217;
    --surface: #1c1a21;
    --surface-strong: #26232c;
    --text: #ebe8f0;
    --muted: #a8a2b3;
    --border: #322e3a;
    --accent: #c9a2f2;
    --accent-hover: #ddc2fa;
    --code-bg: #221f28;
    --code-text: #dcc4f7;
  }
}

/* Base */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 2em 0 0.6em;
}

h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  letter-spacing: -0.025em;
  margin-top: 0;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

p,
ul,
ol,
pre,
table {
  margin: 0 0 1.1em;
}

p {
  text-wrap: pretty;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

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

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

img {
  max-width: 100%;
  height: auto;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  overflow-x: auto;
  line-height: 1.5;
  tab-size: 4;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
}

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

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.prose {
  max-width: var(--measure);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  background: var(--bg);
  padding: 0.5rem 1rem;
  z-index: 20;
}

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

.skip-link:focus {
  left: 0.5rem;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.brand {
  display: flex;
  flex-direction: column;
  color: var(--text);
  text-decoration: none;
  line-height: 1.3;
}

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

.brand-name {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.brand-role {
  color: var(--muted);
  font-size: 0.85rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0 -0.6rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
}

.site-nav a:hover {
  color: var(--text);
  background: var(--surface);
}

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

@media (max-width: 30rem) {
  .site-header .wrap {
    padding-top: 0.75rem;
    padding-bottom: 0.5rem;
    gap: 0.25rem;
  }

  .brand-role {
    display: none;
  }

  .site-nav {
    gap: 0;
    margin: 0 -0.4rem;
  }

  .site-nav a {
    font-size: 0.875rem;
    padding: 0.35rem 0.4rem;
  }
}

/* Home */

.bg-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.bg-canvas canvas {
  display: block;
}

/* one centered panel per page, framed on both sides by the animation */
.stage {
  padding: clamp(2rem, 8vh, 5rem) var(--gutter) clamp(3rem, 10vh, 6rem);
}

.stage > .panel {
  max-width: 40rem;
  margin: 0 auto;
}

.stage-home {
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100svh - var(--header-h));
  display: grid;
  align-items: center;
}

.stage-home > .panel {
  width: 100%;
}

.stage-wide > .panel {
  max-width: 58rem;
}

/* opaque enough that text contrast holds wherever the animated shapes overlap */
.panel {
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: clamp(1.25rem, 5vw, 2.75rem);
}

.panel > :last-child {
  margin-bottom: 0;
}

/* corner control for the background animation */
.motion-toggle {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 5;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.motion-toggle:hover {
  color: var(--accent);
}

.motion-toggle svg {
  width: 0.9rem;
  height: 0.9rem;
  fill: currentColor;
}

.panel h1 {
  margin-bottom: 0.5em;
}

.intro p {
  font-size: 1.15rem;
}

.intro + .timeline {
  margin-top: 2rem;
}

/* Documentation pages */

.doc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  padding-top: clamp(2rem, 6vw, 3.5rem);
}

.doc-content {
  min-width: 0;
  padding-bottom: 4rem;
  max-width: 52rem;
}

.doc-content > h2:first-of-type {
  margin-top: 1.5em;
}

.doc-content h3 {
  font-size: 1.35rem;
  margin-top: 0;
}

.toc {
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.75rem 1rem;
}

.toc summary {
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0;
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc > ul {
  margin-top: 0.5rem;
}

.toc ul ul {
  padding-left: 0.85rem;
  border-left: 1px solid var(--border);
  margin: 0.2rem 0 0.4rem 0.1rem;
}

.toc a {
  display: block;
  padding: 0.15rem 0;
  color: var(--muted);
  text-decoration: none;
}

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

@media (min-width: 64rem) {
  .doc-layout {
    grid-template-columns: 15rem minmax(0, 1fr);
    gap: 3rem;
  }

  .toc {
    position: sticky;
    top: calc(var(--header-h) + 1.5rem);
    align-self: start;
    max-height: calc(100vh - var(--header-h) - 3rem);
    overflow-y: auto;
    background: none;
    border: 0;
    padding: 0;
  }

  .toc summary {
    list-style: none;
    pointer-events: none;
    color: var(--text);
    font-size: 0.85rem;
  }

  .toc summary::-webkit-details-marker {
    display: none;
  }
}

/* CDN link with copy button */

.cdn {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  margin: 0.4rem 0 1.25rem;
}

.cdn input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
}

button {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

/* Collapsible API sections */

details.api {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 0.6rem;
  background: var(--bg);
}

details.api > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.65rem 1rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

details.api > summary::-webkit-details-marker {
  display: none;
}

details.api > summary::before {
  content: "";
  width: 0.45em;
  height: 0.45em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  color: var(--muted);
  flex: none;
}

details.api[open] > summary::before {
  transform: rotate(45deg);
}

details.api > summary:hover {
  background: var(--surface);
}

details.api[open] > summary {
  border-bottom: 1px solid var(--border);
}

details.api > div {
  padding: 1rem;
}

details.api > div > :last-child {
  margin-bottom: 0;
}

.api-controls {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1.5rem;
}

/* Tables */

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

.table-wrap table {
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  border-bottom-width: 2px;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: var(--surface);
}

/* keep identifiers whole so narrow columns grow instead of splitting names */
td code {
  overflow-wrap: break-word;
}

td pre {
  margin: 0.5rem 0;
  font-size: 0.8rem;
}

/* Classes timeline */

.timeline {
  font-size: 1rem;
}

.timeline tbody th {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  border-bottom-width: 1px;
  white-space: nowrap;
  width: 7rem;
  font-variant-numeric: tabular-nums;
}

.timeline td {
  width: 50%;
}

.timeline tbody tr:nth-child(even) {
  background: none;
}

.timeline tbody th,
.timeline td {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.timeline ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline li + li {
  margin-top: 0.3rem;
}

.timeline .note,
.timeline .none {
  color: var(--muted);
}

@media (max-width: 40rem) {
  .timeline thead {
    display: none;
  }

  .timeline,
  .timeline tbody,
  .timeline tr,
  .timeline th,
  .timeline td {
    display: block;
    width: auto;
  }

  .timeline tr {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
  }

  .timeline tbody th,
  .timeline td {
    padding: 0;
    border: 0;
  }

  .timeline tbody th {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
  }

  .timeline td + td {
    margin-top: 0.75rem;
  }

  .timeline td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.2rem;
  }

  .timeline td.none {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
