/* ============================================================
   Street-Block Urbanity Prediction.
   Header, hero, footer, and base typography come from the shared
   subpage system (shared/site.css). This file keeps the project's
   rich content layouts (metric grids, city grid, formulas, GNN
   figures) and the click-to-zoom lightbox, rebased on tokens.
   ============================================================ */

.subpage section, /* not used, but future-proof */
.abstract, .terms, .overview,
.linearregression, .logisticregression, .graphneuralnetwork, .conclusion {
  margin-bottom: clamp(3.5rem, 2rem + 5vw, 7.5rem);
}

.sb-heading {
  font-size: var(--fs-h2);
  font-weight: var(--w-bold);
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: clamp(2.5rem, 1.5rem + 2.5vw, 4rem) 0 var(--space-3);
}
.graphneuralnetwork .sb-heading + .sb-heading,
.sb-heading + .sb-heading { margin-top: var(--space-4); }

.sb-body {
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0 0 var(--space-3);
}
.sb-body b { color: var(--ink); }
.sb-body a { color: var(--accent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }

.gh-link { color: var(--accent); }

/* Small reference tables (CRS, coefficients) */
.crs-table {
  font-size: var(--fs-small);
  border-collapse: collapse;
  width: 100%;
  margin: var(--space-3) 0;
  color: var(--ink-2);
  line-height: 1.5;
}
.crs-table td { padding: 0.3rem 1.25rem 0.3rem 0; vertical-align: top; border-bottom: 1px solid var(--line); }
.crs-note { margin-top: var(--space-2); color: var(--ink-3); font-size: var(--fs-small); }

/* Formulas */
.formula {
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: var(--fs-small);
  background: var(--bg-elev);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-3) 0;
  display: block;
  overflow-x: auto;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--ink);
  line-height: 2.1;
}
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.2; margin: 0 4px; }
.frac .num { border-bottom: 1px solid currentColor; padding: 0 4px 2px; }
.frac .den { padding: 2px 4px 0; }

/* Definitions grid */
.terms-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); margin: var(--space-4) 0; }
.term-card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-4); }
.term-card .sb-heading { font-size: var(--fs-h3); margin-top: 0; }
.term-card .sb-body { font-size: var(--fs-small); }
.terms-full-img { width: 100%; object-fit: contain; display: block; margin-top: var(--space-3); }
@media (max-width: 700px) { .terms-grid { grid-template-columns: 1fr; } }

/* City population-density grid */
.popden-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: var(--space-3) 0 var(--space-5); }
.city-card { display: flex; flex-direction: column; }
.city-img-box { width: 100%; aspect-ratio: 1 / 1; overflow: hidden; }
.city-img-box img { width: 100%; height: 100%; object-fit: contain; display: block; cursor: pointer; }
.city-label { font-size: var(--fs-meta); margin: 0.4rem 0 0; line-height: 1.5; color: var(--ink-2); }
.city-label b { color: var(--ink); }
@media (max-width: 760px) { .popden-grid { grid-template-columns: repeat(2, 1fr); } }

/* Colorbars */
.colorbar-bar { height: 10px; width: 100%; display: block; border-radius: 2px; }
.colorbar-labels { position: relative; height: 2em; font-size: var(--fs-meta); color: var(--ink-3); margin-top: 3px; line-height: 1.3; }
.colorbar-labels span:first-child { position: absolute; left: 0; transform: translateX(-50%); white-space: nowrap; }
.colorbar-labels span:last-child { position: absolute; right: 0; transform: translateX(50%); white-space: nowrap; }
.colorbar-full { max-width: 40%; margin: var(--space-3) auto var(--space-5); }
@media (max-width: 700px) { .colorbar-full { max-width: 80%; } }

/* Metrics matrix (city x metric image grid) */
.metrics-table {
  display: grid;
  grid-template-columns: max-content repeat(4, minmax(0, 1fr));
  row-gap: 6px;
  column-gap: clamp(10px, 3vw, 30px);
  margin: var(--space-4) auto;
  align-items: center;
}
.metrics-col-header { font-size: var(--fs-meta); font-weight: var(--w-bold); text-align: center; color: var(--ink); padding-bottom: 6px; }
.metrics-row-header { font-size: var(--fs-meta); font-weight: var(--w-bold); color: var(--ink); padding-right: 10px; white-space: nowrap; }
.metrics-table img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; display: block; cursor: pointer; }
.metrics-table .colorbar { width: 70%; margin: 0 auto; }

/* Sample street blocks */
.sb-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: var(--space-4) 0 0.5rem; }
.sb-grid-3 img { width: 100%; display: block; aspect-ratio: 4 / 3; object-fit: cover; cursor: pointer; }

/* Linear-regression feature grid */
.lr-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); margin: var(--space-4) 0; }
.lr-item img { width: 100%; display: block; cursor: pointer; }
.img-stats { font-size: var(--fs-meta); color: var(--ink-3); margin: 0.4rem 0 0; text-align: center; line-height: 1.5; }

/* Two-column image blocks */
.image-2col { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); margin: var(--space-4) 0; align-items: start; }
.image-2col img { width: 100%; display: block; cursor: pointer; }
.image-2col-equal { display: grid; grid-template-columns: 1fr 2fr; gap: var(--space-4); margin: var(--space-4) 0; align-items: start; }
.image-2col-equal .img-frame { overflow: hidden; }
.image-2col-equal > :nth-child(1) .img-frame { aspect-ratio: 4 / 5; }
.image-2col-equal > :nth-child(2) .img-frame { aspect-ratio: 8 / 5; }
.image-2col-equal .img-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.image-2col-sm img { max-height: clamp(140px, 18vw, 320px); width: 100%; object-fit: contain; display: block; }
.image-2col-lg { grid-template-columns: 1fr; }
.image-2col-lg .img-caption { text-align: left; }
.image-2col-lg img { aspect-ratio: 5 / 2; width: 100%; object-fit: contain; display: block; }
@media (max-width: 640px) { .image-2col, .image-2col-equal { grid-template-columns: 1fr; } }

.img-caption { font-size: var(--fs-meta); color: var(--ink-3); margin: 0.5rem 0 0; text-align: center; line-height: 1.5; }
.img-full { width: 100%; display: block; margin: var(--space-3) 0; }

/* Click-to-zoom lightbox */
main img:not(.no-lightbox) { cursor: pointer; transition: filter 0.2s var(--ease); }
@media (hover: hover) { main img:not(.no-lightbox):hover { filter: brightness(0.9); } }
main img.no-lightbox { cursor: default; }
#lightbox {
  display: none; position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.88); z-index: 2000; cursor: pointer;
  justify-content: center; align-items: center;
}
#lightbox.active { display: flex; }
#lightbox img { max-width: 92vw; max-height: 92vh; object-fit: contain; display: block; cursor: default; }
