/* Page layout. The colors are defined in theme.css. */
:root {
  /* Rem bounds respect the browser's text size. Viewport terms add modest growth. */
  font-size: clamp(1rem, calc(.875rem + .25vw + .15svh), 1.5rem);
  --network-width: 44rem;
  --frame-height: 6.25rem;
  --page-gutter: clamp(1rem, 5vw, 6rem);
}
* {
  box-sizing: border-box;
}

a {
  color: inherit;
  text-decoration: none;
}

html, body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--page);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

::selection {
  background: var(--selection);
}

:focus-visible {
  outline: 0.125rem solid var(--accent);
  outline-offset: 0.25rem;
}

.skip-link {
  position: fixed;
  top: -6.25rem;
  left: 1.25rem;
  z-index: 10;
  padding: 0.75rem;
  background: var(--page);
}

.skip-link:focus {
  top: 0.75rem;
}

header {
  position: relative;
  min-height: var(--frame-height);
  padding: .75rem var(--page-gutter);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  z-index: 2;
}

.wordmark {
  min-width: 0;
  overflow-wrap: anywhere;
  flex-wrap: wrap;
  justify-self: start;
  gap: .2em;
  font-size: 1.34375rem;
  font-weight: 700;
  letter-spacing: -.0.4375rem;
}

.wordmark span {
  font-weight: 400;
  color: var(--muted);
}

.brand {
  justify-self: center;
  display: flex;
  align-items: center;
}

.brand svg {
  width: 3.49375rem;
  height: 3.225rem;
  overflow: visible;
}

.logo-edges {
  stroke: var(--text);
  stroke-width: 5;
  stroke-linecap: round;
}

/* Nodes inherit the animated color instead of starting a second fill transition. */
.logo-nodes {
  color: var(--text);
}

.logo-nodes circle {
  fill: currentColor;
}

.brand:hover .logo-nodes, .brand:focus-visible .logo-nodes {
  color: var(--accent);
}

.header-tools {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mono {
  font: .75rem 'Courier New', monospace;
  letter-spacing: 0.08125rem;
}

.header-note {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--label);
}

main {
  min-height: 0;
  display: grid;
  place-content: center;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  padding: 0 1.5rem;
}

.site-intro {
  position: relative;
  top: var(--intro-offset, 0rem);
  margin: 0 0 1rem;
  max-width: 42rem;
  text-align: center;
  font-size: .9375rem;
  line-height: 1.6;
  color: var(--muted);
}

.network {
  width: min(var(--network-width), 100%);
  height: auto;
  aspect-ratio: 898 / 560;
  overflow: visible;
}

footer {
  position: relative;
  min-min-height: var(--frame-height);
  padding: .75rem var(--page-gutter);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1.25rem;
  align-items: center;
  color: var(--label);
  font: .75rem 'Courier New', monospace;
  letter-spacing: 0.0625rem;
}

.contact-link {
  font-size: .75rem;
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  display: grid;
  place-items: center;
  min-height: max(44px, 2.75rem);
  padding: 0 0.75rem;
  transition: color .25s;
}

footer > span:first-child { justify-self: start; grid-column: 1; grid-row: 1; }
footer > span:last-child { justify-self: end; grid-column: 3; grid-row: 1; }
.contact-link:hover, .contact-link:focus-visible { color: var(--accent); }

.status {
  position: absolute;
  bottom: calc(100% + 0.25rem);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  min-height: 0.75rem;
  color: var(--accent);
}

/* The network is a navigation map, not a trained model. */
.network .edge {
  stroke: var(--line);
  stroke-width: 1.1;
  opacity: .8;
  transition: opacity .4s;
}

.network .point {
  cursor: pointer;
  outline: none;
}

.layer-heading {
  font: 18.75px 'Courier New', monospace;
  letter-spacing: 2px;
  fill: var(--label);
}

.network .neuron-body {
  fill: var(--node);
  stroke: var(--node-border);
  stroke-width: 1.3;
  transition: fill .25s, stroke .25s;
}

.network .neuron text {
  font: 16.5px 'Courier New', monospace;
  letter-spacing: .4px;
  fill: var(--muted);
  pointer-events: none;
}

.network .neuron:hover .neuron-body, .network .neuron:focus-visible .neuron-body {
  fill: var(--hover);
  stroke: var(--accent);
}

.network .neuron:focus-visible .neuron-body {
  stroke-width: 2;
}

.network.is-active .edge {
  opacity: .18;
}

/* Animated color lives on a separate dashed layer, never on the solid path. */
.network .signal-edge {
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-dasharray: 4 5;
  fill: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s;
  animation: signal 2s linear infinite;
  animation-play-state: paused;
}

.network .signal-edge.lit {
  opacity: 1;
}

.network .signal-edge.lit, .network .signal-edge.fading {
  animation-play-state: running;
}


.network .hint {
  font: 15.625px 'Courier New', monospace;
  letter-spacing: 1.3px;
  fill: var(--label);
}

@keyframes signal {
  to {
    stroke-dashoffset: -40;
  }

}

.mobile-network {
  display: none;
}

/* Collection panels keep their controls visible while the content scrolls. */
.zoom-layer {
  position: fixed;
  inset: var(--frame-height) var(--page-gutter) 1rem;
  z-index: 5;
  display: grid;
  place-items: center;
  pointer-events: none;
  visibility: hidden;
  min-height: 0;
}

.zoom-panel {
  width: min(47.5rem, 100%);
  height: min(37.5rem, 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--page);
  border: 0.0625rem solid var(--border);
  opacity: 0;
  transform: translate(var(--zoom-x, 0rem), var(--zoom-y, 0rem)) scale(.12);
  transform-origin: center;
  transition: transform 650ms cubic-bezier(.22, .8, .2, 1), opacity 350ms ease;
  box-shadow: 0 0.75rem 3.125rem var(--shadow);
}

.zoom-layer.open {
  visibility: visible;
  pointer-events: auto;
}

.zoom-layer.open .zoom-panel {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

.zoom-layer.closing {
  visibility: visible;
}

.zoom-panel-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.375rem;
  flex-shrink: 0;
  background: var(--page);
  border-bottom: 0.0625rem solid var(--border);
}

.zoom-controls {
  display: flex;
  gap: 0.5625rem;
}

.zoom-back {
  padding: 0.625rem 0.75rem;
  min-height: max(44px, 2.75rem);
  background: transparent;
  border: 0.0625rem solid var(--node-border);
  color: var(--muted);
  font: 0.75rem Arial, sans-serif;
  cursor: pointer;
}

.zoom-back:hover {
  background: var(--surface);
}

.zoom-section {
  margin-left: auto;
  font: .75rem 'Courier New', monospace;
  letter-spacing: 0.0625rem;
  color: var(--label);
}

.zoom-content {
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  padding: 1.625rem 1.875rem 2.1875rem;
  scrollbar-color: var(--border) var(--page);
  scrollbar-width: thin;
}

.zoom-content h1 {
  font: 2.625rem Georgia, serif;
  font-weight: normal;
  letter-spacing: -0.0625rem;
  margin: 0 0 0.9375rem;
}

.zoom-content h2 {
  font: 1.5625rem Georgia, serif;
  font-weight: normal;
  margin: 1.875rem 0 0.75rem;
}

.zoom-content h3 {
  font: 1.25rem Georgia, serif;
  font-weight: normal;
  margin: 0 0 0.5625rem;
}

.zoom-content p {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--muted);
}

.collection-label {
  font: .75rem 'Courier New', monospace;
  color: var(--accent);
  letter-spacing: 0.0625rem;
  margin-bottom: 0.9375rem;
}

.content-card {
  display: block;
  border-top: 0.0625rem solid var(--border);
  padding: 1.375rem 0;
}

.content-card:hover h3 {
  color: var(--accent);
}

.content-meta {
  font: .75rem 'Courier New', monospace;
  color: var(--label);
  line-height: 1.6;
}

.content-card p {
  margin: 0 0 0.75rem;
}

.contact-placeholder {
  padding: 1rem 0;
  border-top: 0.0625rem solid var(--border);
}

main {
  transition: opacity 400ms ease, transform 650ms cubic-bezier(.22, .8, .2, 1);
}

body.zoomed main {
  opacity: 0;
  transform: scale(1.12);
  pointer-events: none;
}

body.zoomed footer {
  visibility: hidden;
}

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

  .zoom-panel, main {
    transform: none !important;
  }

}

/* Reflow the navigation before the SVG labels or targets become cramped. */
@media (max-width: 52rem) {
  :root { --frame-height: 5.5rem; }
  .network { display: none; }
  main { padding: 1rem var(--page-gutter); gap: 2rem; }
  .site-intro { max-width: 32rem; margin-bottom: 0; }
  .mobile-network {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr);
    gap: .625rem;
    width: min(100%, 36rem);
  }
  .mobile-layer { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
  .mobile-layer-heading {
    text-align: center;
    overflow-wrap: anywhere;
    color: var(--label);
    font: .75rem 'Courier New', monospace;
    letter-spacing: .06em;
    text-transform: uppercase;
  }
  .mobile-layer-buttons {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: .75rem;
    flex: 1;
  }
  .mobile-layer button {
    min-height: max(44px, 2.75rem);
    padding: .5rem .25rem;
    border: 1px solid var(--node-border);
    border-radius: .4375rem;
    background: var(--node);
    color: var(--muted);
    font: .875rem/1.5 'Courier New', monospace;
    overflow-wrap: anywhere;
    cursor: pointer;
  }
  .mobile-layer button:hover { border-color: var(--accent); background: var(--hover); }
  .status { display: none; }
}

@media (max-width: 36rem) {
  .header-note { display: none; }
  .header-tools { gap: 0; }
  .wordmark { font-size: 1.125rem; }
  .brand svg { width: 3rem; height: 2.75rem; }
  footer { gap: .5rem; font-size: .75rem; letter-spacing: .02em; }
}

.theme-fading .contact-link { transition: none; }
footer > span { min-width: 0; overflow-wrap: anywhere; }
footer > span:last-child { text-align: right; }
.header-tools { min-width: 0; }
.wordmark, .brand { min-height: 44px; display: flex; align-items: center; }
.network .neuron:focus-visible .neuron-body { stroke: var(--accent); stroke-width: 3; }

/* System color palettes still distinguish controls and keyboard focus. */
@media (forced-colors: active) {
  .network .neuron-body { fill: Canvas; stroke: ButtonText; }
  .network .neuron text, .layer-heading, .network .hint { fill: CanvasText; }
  .network .neuron:focus-visible .neuron-body { stroke: Highlight; }
  .logo-nodes circle { fill: CanvasText; }
  .logo-edges { stroke: CanvasText; }
}
