/* Dottiworks
   Palette sampled from the original nav render.
   Change --nav-size if higher-resolution nav art becomes available. */

:root {
  --paper:      #ffffff;
  --ink:        #111111;
  --slate:      #4e5f5c;   /* spike mid-tone */
  --slate-pale: #9aa8a4;   /* spike light facet */
  --magenta:    #f0156a;   /* highlight, sampled from nav_16 */
  --rule:       #d8dcda;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
          "Liberation Mono", monospace;

  --nav-size: 250px;       /* native resolution of the source art */
  --measure: 34rem;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: clamp(1.5rem, 6vw, 4rem) 1.25rem 4rem;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  display: flex;
  justify-content: center;
}

.shell {
  width: 100%;
  max-width: var(--measure);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---- wordmark ------------------------------------------------------ */

.wordmark {
  margin: 0 0 clamp(1.25rem, 5vw, 2.25rem);
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--slate);
  align-self: flex-start;
}

/* ---- nav ----------------------------------------------------------- */

.nav {
  position: relative;
  width: var(--nav-size);
  max-width: 100%;
  aspect-ratio: 1;
  line-height: 0;
}

.nav__base,
.nav__highlight,
.nav__map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.nav__base { object-fit: contain; }

/* Sprite sheet: 36 stacked frames, transparent except the lit spike.
   Frame i sits at i/35 of the vertical travel. */
.nav__highlight {
  background-image: url("nav-highlights.webp");
  background-repeat: no-repeat;
  background-size: 100% 3600%;
  background-position: 0 calc(var(--frame, 0) * (100% / 35));
  opacity: 0;
  pointer-events: none;
}

.nav[data-active] .nav__highlight { opacity: 1; }

.nav__map { overflow: visible; }

.nav__map polygon {
  fill: #ffffff;
  fill-opacity: 0;
  stroke: none;
  cursor: pointer;
  pointer-events: all;
}

.nav__map a { outline: none; }

.nav__map a:focus-visible polygon {
  stroke: var(--magenta);
  stroke-width: 2;
  stroke-linejoin: round;
  paint-order: stroke;
}

/* ---- readout ------------------------------------------------------- */

.readout {
  width: var(--nav-size);
  max-width: 100%;
  margin-top: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
  text-align: right;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--slate-pale);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.readout[data-state="live"]     { color: var(--magenta); }
.readout[data-state="reserved"] { color: var(--slate); }

/* ---- text index ---------------------------------------------------- */

.index {
  width: var(--nav-size);
  max-width: 100%;
  margin-top: 2.25rem;
}

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

.index li + li { margin-top: 0.15rem; }

.index a {
  display: flex;
  gap: 0.9rem;
  padding: 0.2rem 0;
  color: var(--ink);
  text-decoration: none;
}

.index a:hover,
.index a:focus-visible { color: var(--magenta); }

.index a:focus-visible {
  outline: 1px solid var(--magenta);
  outline-offset: 2px;
}

.index .num {
  color: var(--slate-pale);
  font-variant-numeric: tabular-nums;
}

.index a:hover .num,
.index a:focus-visible .num { color: var(--magenta); }

/* ---- hint ---------------------------------------------------------- */

.hint {
  width: var(--nav-size);
  max-width: 100%;
  margin: 1.75rem 0 0;
  font-size: 0.6875rem;
  color: var(--slate-pale);
}

/* ---- touch ---------------------------------------------------------
   Coarse pointers get a larger nav. Several spike polygons are under
   30px wide at native size, well below a comfortable tap target. */

@media (hover: none) {
  :root { --nav-size: min(78vw, 340px); }
}

@media (prefers-reduced-motion: no-preference) {
  .nav__highlight { transition: opacity 90ms linear; }
  .index a { transition: color 90ms linear; }
}

/* ==== gallery ======================================================== */

.crumb {
  width: 100%;
  max-width: var(--measure);
  margin: 0 0 clamp(1.25rem, 5vw, 2.25rem);
  font-size: 0.6875rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
}

.crumb a { color: var(--slate-pale); text-decoration: none; }
.crumb a:hover, .crumb a:focus-visible { color: var(--magenta); }
.crumb span { color: var(--slate); }

.sheet { width: 100%; max-width: var(--measure); }

.sheet__title {
  margin: 0 0 0.35rem;
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.sheet__meta {
  margin: 0 0 1.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.6875rem;
  color: var(--slate-pale);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.5rem;
}

.cell {
  display: block;
  position: relative;
  margin: 0;
  padding: 0;
  border: 1px solid var(--rule);
  background: var(--paper);
  aspect-ratio: 1;
  cursor: pointer;
  overflow: hidden;
}

.cell img {
  width: 100%;
  height: 100%;
  /* contain, not cover: cropping an architectural view loses the
     composition, and mixed portrait and landscape would crop hard. */
  object-fit: contain;
  display: block;
}

.cell:hover, .cell:focus-visible { border-color: var(--magenta); outline: none; }
.cell:focus-visible { box-shadow: 0 0 0 2px var(--magenta); }

.cell--video::after {
  content: "";
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  border-style: solid;
  border-width: 0.3rem 0 0.3rem 0.5rem;
  border-color: transparent transparent transparent var(--magenta);
}

/* ---- viewer --------------------------------------------------------- */

.viewer {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--paper);
  color: var(--ink);
}

.viewer::backdrop { background: rgba(255, 255, 255, 0.97); }

.viewer__inner {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: clamp(1rem, 4vw, 2.5rem);
  gap: 1rem;
}

.viewer__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.viewer__stage img,
.viewer__stage video {
  max-height: 100%;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--rule);
}

.viewer__bar {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.75rem;
}

.viewer__caption { flex: 1; color: var(--ink); }
.viewer__count { color: var(--slate-pale); font-variant-numeric: tabular-nums; }

.viewer__nav, .viewer__close {
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--slate);
  font: inherit;
  cursor: pointer;
}

.viewer__nav:hover, .viewer__close:hover,
.viewer__nav:focus-visible, .viewer__close:focus-visible {
  border-color: var(--magenta);
  color: var(--magenta);
  outline: none;
}

@media (prefers-reduced-motion: no-preference) {
  .cell, .viewer__nav, .viewer__close { transition: border-color 90ms linear, color 90ms linear; }
}

/* ==== prose ========================================================== */

.prose {
  width: 100%;
  max-width: var(--measure);
  font-size: 0.8125rem;
  line-height: 1.75;
}

/* The thesis text is lowercase throughout in the 2003 original. That is
   authorial, not an error, so nothing here capitalises it. */

.prose__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.prose__sub { margin: 0.15rem 0 0; color: var(--slate); }

.prose__by {
  margin: 0.15rem 0 1.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.6875rem;
  color: var(--slate-pale);
}

.prose p { margin: 0 0 1.25rem; }

.prose__figure { margin: 0 0 1.75rem; }

.prose__figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
}

/* Image4 is 180px wide. Stretching it to the column would only blur it. */
.prose__figure--small img { width: auto; max-width: 100%; }

.prose__def {
  margin: 0 0 1.75rem;
  padding: 0.9rem 1.1rem;
  border-left: 2px solid var(--magenta);
  background: #fafbfb;
}

.prose__def dt {
  margin-bottom: 0.2rem;
  color: var(--magenta);
  letter-spacing: 0.04em;
}

.prose__def dd { margin: 0; color: var(--slate); }

.prose__pdf {
  display: flex;
  gap: 0.9rem;
  align-items: baseline;
  margin-top: 2.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--rule);
}

.prose__pdf a { color: var(--ink); text-decoration: none; }
.prose__pdf a:hover, .prose__pdf a:focus-visible { color: var(--magenta); }
.prose__pdf span { color: var(--slate-pale); font-size: 0.6875rem; }

/* ==== nz: trip log ==================================================== */

.log {
  display: grid;
  grid-template-columns: 500px 1fr;
  gap: 1.5rem;
  margin: 0 0 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.log__map img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
}

.log__text { font-size: 0.8125rem; line-height: 1.75; }
.log__text p { margin: 0 0 1rem; }
.log__text p:last-child { margin-bottom: 0; }

@media (max-width: 860px) {
  .log { grid-template-columns: 1fr; }
}

.sheet__hint { color: var(--slate-pale); }
@media (max-width: 699px), (pointer: coarse) { .sheet__hint { display: none; } }

/* Panoramas are roughly 800x150. In a square cell they would be a sliver, so
   they take a whole row and keep their proportions. */
.cell--pano { grid-column: 1 / -1; aspect-ratio: auto; }
.cell--pano img { width: 100%; height: auto; object-fit: contain; }

/* ==== nz: draggable panel ============================================= */

.panel {
  position: fixed;
  z-index: 50;
  width: min(var(--pw, 500px), calc(100vw - 2rem));
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.28);
}

.panel[hidden] { display: none; }

/* Below the drag breakpoint the panel is a plain centred viewer. Dragging a
   window around a phone screen is not useful. */
@media (max-width: 699px), (pointer: coarse) {
  .panel {
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%);
    width: calc(100vw - 1.5rem);
  }
}

.panel__grip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.5rem 0.35rem 0.7rem;
  background: var(--slate);
  color: #fff;
  font-size: 0.6875rem;
  letter-spacing: 0.03em;
}

@media (min-width: 700px) and (pointer: fine) {
  .panel__grip { cursor: grab; }
  .panel.is-dragging .panel__grip { cursor: grabbing; }
  /* Stops the caption being text-selected instead of dragged. */
  .panel.is-dragging { user-select: none; }
}

.panel__grip:focus-visible { outline: 2px solid var(--magenta); outline-offset: -2px; }

.panel__title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.panel__close {
  flex: none;
  width: 1.5rem; height: 1.5rem;
  padding: 0;
  background: none; border: 0;
  color: #fff; font-size: 1rem; line-height: 1;
  cursor: pointer;
}
.panel__close:hover, .panel__close:focus-visible { color: var(--magenta); }

.panel__stage { background: #000; }

.panel__stage img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 9rem);
  object-fit: contain;
  margin: 0 auto;
}

.panel__bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.3rem 0.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.6875rem;
}

.panel__nav {
  padding: 0.1rem 0.5rem;
  background: none; border: 1px solid var(--rule);
  color: var(--ink); font: inherit; cursor: pointer;
}
.panel__nav:hover, .panel__nav:focus-visible { border-color: var(--magenta); color: var(--magenta); }

.panel__count { color: var(--slate-pale); font-variant-numeric: tabular-nums; }
