/* Geography
   A 1970s textbook plate: one flat ink field, the globe drawn in white line,
   type in Helvetica reversed out of the field. The second ink (gold) marks
   the projects and their figure numbers, and nothing else. */

:root {
  --field: #2b666b;
  --ink: #fff;
  --ink-soft: rgba(255, 255, 255, 0.76);
  --ink-faint: rgba(255, 255, 255, 0.5);
  --spot: #f2b134;
  --veil: rgba(43, 102, 107, 0.92);
  --helvetica: Helvetica, "Helvetica Neue", "Nimbus Sans", "TeX Gyre Heros", Arial, sans-serif;
  --gutter: clamp(16px, 2.4vw, 36px);
  /* the map's share of the window, at the top of the page, which scrolls:
     most of it, the page below showing only a strip (where the article
     begins) until the reader scrolls */
  --map-h: 84vh;
  color-scheme: dark;
}
@supports (height: 1svh) {
  :root { --map-h: 84svh; }
}

/* The theme clock (js/clock.js) sets --field, --veil and --spot on the root
   as the sun moves at Greenwich; without scripts, the system's preference. */
@media (prefers-color-scheme: dark) {
  :root {
    --field: #0f2426;
    --veil: rgba(15, 36, 38, 0.93);
    --spot: #e9a62c;
  }
}

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

[hidden] { display: none !important; }

/* the scrollbar's room kept, so a long article never narrows the map */
html { overscroll-behavior-y: none; scrollbar-gutter: stable; }
html, body {
  margin: 0;
  background: var(--field);
  color: var(--ink);
  font-family: var(--helvetica);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.5s ease;
}

button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }

/* A tap, double tap or long press on the map and its furniture should not
   select type or raise the phone's copy menu; the card's and the panels' text
   stays selectable, to copy a title or a line. */
.stage, .title, .tools, .contents, .readout, .points, .player, .attribution {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }

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

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

/* The plate: the map zone, at the top of the page and scrolling away with
   it; its lower edge is the plate's white rule */

.mapzone {
  position: relative;
  z-index: 2;
  height: var(--map-h);
  overflow: hidden;
  background: var(--field);
  border-bottom: 2px solid var(--ink);
  transition: background-color 0.5s ease;
}

.stage {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: default;
}
/* over the earth the cursor is a magnifying glass; its crosshair is the point
   the readout reports, and a click zooms in on it */
.stage.is-over-earth { cursor: url("../img/magnifier.svg") 12 12, zoom-in; }
/* holding Alt (Option) turns the glass to zoom out */
.alt-held .stage.is-over-earth,
.is-close .stage.is-over-earth { cursor: url("../img/magnifier-out.svg") 12 12, zoom-out; }
.stage.is-dragging { cursor: grabbing; }

#globe { display: block; width: 100%; height: 100%; }

.points { position: absolute; inset: 0; pointer-events: none; }

.point {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
}
.point::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--spot);
  box-shadow: 0 0 0 2px var(--field);
}
.point.is-current::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
}
.point-number {
  position: absolute;
  left: 18px;
  top: -6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--spot);
  /* a halo in the field colour lifts the number off the coastlines */
  text-shadow: 0 0 2px var(--field), 0 0 2px var(--field), 0 0 3px var(--field);
  pointer-events: none;
}
.point-label {
  position: absolute;
  left: 18px;
  top: 8px;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.2;
  padding: 1px 4px 2px;
  background: var(--veil);
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
}
.point:hover .point-label, .point.is-hot .point-label, .point.is-current .point-label { opacity: 1; }

/* Type reversed out of the field: the title over the map, sized to the map
   zone's height as well as its width */

.masthead {
  position: absolute;
  top: calc(var(--gutter) * 0.4);
  left: var(--gutter);
  right: var(--gutter);
  z-index: 3;
  pointer-events: none;
}

.title {
  margin: 0 0 0 -0.05em;
  font-size: max(3.4rem, min(13.2vw, calc(var(--map-h) * 0.27), 13.5rem));
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.045em;
  color: var(--ink);
  pointer-events: none;
  white-space: nowrap;
  position: relative;
}
/* The title behind the map (occlude.js, an experiment in the Preview panel):
   under the canvas, which paints the field over the letters it hides */
.title-under .stage { z-index: 1; }
.title-under .masthead { z-index: 0; }
/* the word changes with the place clicked (title.js); a long one is drawn
   smaller, measured against "Geography" in the hidden sizer */
.title-word { display: inline-block; transform-origin: 0 78%; transition: opacity 0.18s ease; }
.title-word.is-out { opacity: 0; }
.title-sizer { position: absolute; left: 0; top: 0; visibility: hidden; }

.tools {
  position: absolute;
  top: var(--gutter);
  right: var(--gutter);
  z-index: 4;
  display: flex;
  gap: 1.2rem;
}
.tools button {
  border: 0;
  padding: 0.2rem 0;
  background: none;
  font-size: 0.95rem;
  cursor: pointer;
  text-underline-offset: 0.25em;
}
.tools button:hover, .tools button[aria-expanded="true"] { text-decoration: underline; }

/* The page below the map: what geography is, then the chosen article (or, at
   the whole earth, the issue and its contents beside the phrase). Its top
   shows beneath the map, the phrase and the start of what follows; the rest
   is below the fold, and the map scrolls away above it. */

.zone {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - var(--map-h));
  padding: 1.5rem var(--gutter) 5rem;
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.5fr);
  column-gap: clamp(2rem, 5vw, 5rem);
  align-items: start;
}
/* with an article open it takes the page, and the contents follow it */
.has-card .zone { grid-template-columns: minmax(0, 1fr); }

.side { min-width: 0; }
.side > * { scroll-margin-top: 1rem; }

.phrase {
  position: relative;
  margin: 0 0 1.1rem;
  padding-right: 4.5rem; /* clear of Close */
  font-size: clamp(2rem, 3.6vw, 3.6rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.025em;
}
.phrase-line {
  display: block;
  opacity: 0;
  transition: opacity 2.2s ease;
}
/* the line on its way out lies over the one coming in, out of the flow */
.phrase-line:not(.is-shown) { position: absolute; top: 0; left: 0; right: 0; }
.phrase-line.is-shown { opacity: 1; }
.phrase.is-quick .phrase-line { transition-duration: 0.5s; }

.caption, .about { outline: none; }
.about { position: relative; max-width: 38rem; }
/* the article: its text in a reading column, its image mounted beside it */
.caption {
  display: grid;
  grid-template-columns: minmax(0, 38rem) minmax(12rem, 28rem);
  column-gap: clamp(2rem, 5vw, 5rem);
  align-items: start;
}
.caption > * { grid-column: 1; }
.caption > .caption-image { grid-column: 2; grid-row: 1 / span 30; }

.fig {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--spot);
}

.caption h2, .about h2 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.6rem, 2.4vw, 2.4rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.makers { margin: 0; font-size: 1.02rem; line-height: 1.35; color: var(--ink-soft); }
.meta { margin: 0.1rem 0 0; font-size: 1.02rem; color: var(--ink-soft); }

.caption .text, .about p {
  margin: 1rem 0 0;
  font-size: 1.06rem;
  line-height: 1.55;
  max-width: 36em;
}
.about p:first-of-type { margin-top: 0.5rem; }
.about .credits { font-size: 0.9rem; color: var(--ink-soft); }

.places {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.85rem 0 0;
  padding: 0;
}
.places button {
  border: 1px solid var(--ink-faint);
  background: none;
  padding: 0.2rem 0.45rem 0.25rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.places button:hover { border-color: var(--ink); }
.place-letter { margin-right: 0.35em; font-weight: 700; color: var(--spot); }
.places button[aria-current="true"] .place-letter { color: var(--field); }
.places button[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: var(--field); }

.caption .link {
  display: inline-block;
  margin-top: 1.1rem;
  font-weight: 700;
  font-size: 1.02rem;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.22em;
}
.caption .link:hover { text-decoration-color: var(--spot); }

/* Close, at the top right of the page below the map */
.close {
  position: absolute;
  top: 1.5rem;
  right: var(--gutter);
  z-index: 1;
  border: 0;
  padding: 0.15rem 0;
  background: none;
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.about .close { top: 0; right: 0; }
.close:hover { color: var(--ink); }

/* The chosen project's image heads its card, mounted like a print: a white
   mat and a keyline, with the credit beneath */

.caption-image { margin: 0.4rem 0 1.05rem; }
.caption-image .frame {
  display: inline-block;
  max-width: calc(100% - 10px);
  margin: 5px;
  padding: 6px;
  background: #fff;
  outline: 1px solid rgba(255, 255, 255, 0.7);
  outline-offset: 4px;
}
.caption-image img {
  display: block;
  max-width: 100%;
  /* beside the headline, below the fold */
  max-height: min(72vh, 44rem);
  width: auto;
  height: auto;
}
.caption-image figcaption {
  margin-top: 0.75rem;
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--ink-soft);
}

/* Where the cursor is, and what time it is at Greenwich */

.readout {
  position: absolute;
  right: var(--gutter);
  bottom: 1.35rem;
  z-index: 3;
  margin: 0;
  text-align: right;
  font-size: 0.8rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  pointer-events: none;
}
.readout span { display: block; white-space: pre; }
.readout-coords.is-centre { color: var(--ink-soft); }
.readout-time { color: var(--ink-soft); }

/* The note that an ordinary scroll moves the page, and how to zoom: shown
   for a moment, the first time a scroll passes over the map */
.hint {
  position: absolute;
  left: 50%;
  bottom: 1.35rem;
  z-index: 4;
  margin: 0;
  padding: 0.45rem 0.8rem 0.5rem;
  transform: translateX(-50%);
  background: var(--veil);
  border: 1px solid var(--ink-faint);
  font-size: 0.85rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.hint.is-shown { opacity: 1; }

/* The leader: a hairline from the card's frame to the chosen point */
.leader {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.leader line { stroke: #fff; stroke-width: 1; opacity: 0; transition: opacity 0.45s ease; }
.leader.is-shown line { opacity: 0.85; }

/* Type set straight on the map keeps a halo in the field colour, so it reads
   over the finer line work */
.readout, .tools button, .attribution, .player {
  text-shadow: 0 0 2px var(--field), 0 0 3px var(--field), 0 0 5px var(--field);
}

/* The Preview panel (preview.js), for ?preview only */

.preview-panel {
  position: fixed;
  left: var(--gutter);
  top: calc(var(--gutter) * 3);
  bottom: var(--gutter);
  z-index: 5;
  width: min(24rem, 34vw);
  overflow-y: auto;
  padding: 0.8rem 0.95rem 1rem;
  background: var(--field);
  border-top: 2px solid var(--spot);
  box-shadow: 0 0 0 1px var(--ink-faint);
  font-size: 0.78rem;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.preview-panel h2 { margin: 0; font-size: 1rem; }
.preview-panel h3 { margin: 1rem 0 0.3rem; font-size: 0.85rem; color: var(--spot); }
.preview-panel p { margin: 0.2rem 0; }
.pv-head { display: flex; align-items: baseline; gap: 0.6rem; }
.pv-head h2 { flex: 1; }
.pv-note { color: var(--ink-soft); }
.pv-row { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.pv-layers { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
.preview-panel button {
  border: 1px solid var(--ink-faint);
  padding: 0.12rem 0.45rem;
  background: none;
  font-size: 0.75rem;
  cursor: pointer;
}
.preview-panel button:hover { border-color: var(--ink); }
.preview-panel button:disabled { opacity: 0.4; cursor: default; }
.preview-panel input { accent-color: var(--spot); font: inherit; }
.preview-panel input[type="datetime-local"] { background: none; color: inherit; border: 1px solid var(--ink-faint); padding: 0.05rem 0.25rem; color-scheme: dark; }
.pv-list { list-style: none; margin: 0.3rem 0 0; padding: 0; }
.pv-list li { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: baseline; padding: 0.25rem 0; border-top: 1px solid var(--ink-faint); }
.pv-list li span { flex: 1 1 12rem; }
.preview-toggle { color: var(--spot) !important; }
.readout-time.is-set { color: var(--spot); }

/* The compass rose, close up on the Dymaxion, placed beside the scale bar by
   compass.js: it points to north as the map lies; pressed, north is up and
   its north point is gold */

.compass {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  width: 50px; /* SIZE in compass.js */
  height: 50px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.compass[hidden] { display: none; }
.compass svg { display: block; width: 100%; height: 100%; overflow: visible; }
.compass .rose-disc { fill: var(--field); fill-opacity: 0.9; stroke: currentColor; stroke-width: 0.9; }
.compass .rose-n { fill: currentColor; }
.compass .rose-s, .compass .rose-ew { fill: none; stroke: currentColor; stroke-width: 0.9; stroke-linejoin: round; }
.compass .rose-letter { fill: currentColor; font: 700 7px var(--helvetica); }
.compass[aria-pressed="true"] .rose-n, .compass[aria-pressed="true"] .rose-letter { fill: var(--spot); }
.compass:hover .rose-disc { fill-opacity: 1; }
.compass:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; border-radius: 50%; }

/* The credit for the finer map, while it shows */

.attribution {
  position: absolute;
  right: var(--gutter);
  bottom: 0.35rem;
  z-index: 3;
  margin: 0;
  font-size: 0.66rem;
  color: var(--ink-soft);
}
.attribution a { color: inherit; }

/* Sound: the card's listen button, and the player that keeps playing */

.sound { margin-top: 0.95rem; }
.listen {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 0;
  padding: 0;
  background: none;
  font-weight: 700;
  font-size: 0.98rem;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.22em;
  cursor: pointer;
}
.listen::before {
  /* the gold play sign; a square once it plays */
  content: "";
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0.36em 0 0.36em 0.6em;
  border-color: transparent transparent transparent var(--spot);
}
.listen.is-on::before { width: 0.6em; height: 0.6em; border: 0; background: var(--spot); }
.listen:hover { text-decoration-color: var(--spot); }
.sound-credit { margin: 0.3rem 0 0; font-size: 0.8rem; color: var(--ink-soft); }

.player {
  position: absolute;
  right: var(--gutter);
  top: calc(var(--gutter) + 2.4rem);
  z-index: 4;
  max-width: 20rem;
  padding: 0.55rem 0.7rem 0.5rem;
  background: var(--veil);
  text-align: right;
  font-size: 0.8rem;
  line-height: 1.4;
}
.player p { margin: 0; }
.player-title { font-weight: 700; }
.player-credit { color: var(--ink-soft); }
.player-frame iframe { display: block; width: 18rem; max-width: 100%; height: 30px; margin: 0.4rem 0 0 auto; border: 0; }
.player-foot { margin-top: 0.15rem !important; }
.player-state { color: var(--spot); font-variant-numeric: tabular-nums; }
.player-stop {
  border: 0;
  padding: 0;
  margin-left: 0.5rem;
  background: none;
  font-size: 0.8rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

/* Issues: the list of them, and the dateline over the contents */

.issues-list { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.issues-list button {
  display: grid;
  grid-template-columns: 5.2rem 1fr;
  gap: 0.1rem 0.6rem;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--ink-faint);
  padding: 0.6rem 0 0.65rem;
  background: none;
  text-align: left;
  cursor: pointer;
}
.issues-list li:last-child button { border-bottom: 1px solid var(--ink-faint); }
.issues-list .n { font-weight: 700; color: var(--spot); }
.issues-list .t { font-weight: 700; }
.issues-list .d { grid-column: 2; color: var(--ink-soft); font-size: 0.9rem; }
.issues-list button:hover .t, .issues-list button[aria-current="true"] .t { text-decoration: underline; text-underline-offset: 0.22em; }

.issue-intro { margin-top: 0.9rem; color: var(--ink-soft); font-size: 0.9rem; }
.issue-intro p { margin: 0 0 0.6em; }

.issue-line { margin: 0 0 0.55rem; font-size: 0.8rem; color: var(--ink-soft); }
.issue-line strong { color: var(--ink); font-weight: 700; }

.caption .text p { margin: 0 0 0.7em; }
.caption .text p:last-child { margin-bottom: 0; }

/* Contents, set like the list of plates in the front of the book: beside the
   phrase at the whole earth, after the article when one is open */

.contents { min-width: 0; padding-top: 0.6rem; }
.has-card .contents { margin-top: 3rem; padding-top: 1.2rem; border-top: 1px solid var(--ink-faint); max-width: 60rem; }
.contents-list { list-style: none; margin: 0; padding: 0; columns: 2 16rem; column-gap: 2.5rem; }
.contents-list li { break-inside: avoid; }
.contents-list button {
  display: grid;
  grid-template-columns: 1.8rem 1fr;
  align-items: baseline;
  width: 100%;
  border: 0;
  padding: 0.3rem 0;
  background: none;
  text-align: left;
  font-size: 1rem;
  line-height: 1.25;
  color: var(--ink-soft);
  cursor: pointer;
}
.contents-list .n { font-weight: 700; font-size: 0.8rem; color: var(--spot); }
.contents-list .region-head { margin: 0.7rem 0 0.15rem; font-size: 0.8rem; color: var(--ink-soft); }
.contents-list button:hover, .contents-list button[aria-current="true"] { color: var(--ink); }
.contents-list button[aria-current="true"] .t { text-decoration: underline; text-underline-offset: 0.22em; }

.noscript {
  position: fixed;
  left: var(--gutter);
  bottom: var(--gutter);
  margin: 0;
  font-size: 1.1rem;
}

/* Phones: the map on top (four fifths of the screen, tall enough that the
   Dymaxion stands upright), the title under the tools, and the page below in
   one column, headline before image. The strip of page beneath the map is
   where a finger scrolls it; on the map a finger moves the map. */

@media (max-width: 720px) {
  :root { --map-h: 80vh; }
  @supports (height: 1svh) {
    :root { --map-h: 80svh; }
  }
  .masthead { top: calc(var(--gutter) + 1.6rem); }
  .title { font-size: max(2.8rem, min(19vw, calc(var(--map-h) * 0.2), 6rem)); }
  .tools { gap: 1rem; }
  .tools button { font-size: 0.88rem; }

  .zone { grid-template-columns: minmax(0, 1fr); padding-top: 1.1rem; }
  .phrase { font-size: clamp(1.6rem, 7.4vw, 2.2rem); margin-bottom: 0.8rem; }
  /* number, headline and makers, then the image, then the text */
  .caption { grid-template-columns: minmax(0, 1fr); }
  .caption > .caption-image { grid-column: 1; grid-row: auto; order: 1; margin-top: 0.9rem; }
  .caption > .text, .caption > .places, .caption > .sound, .caption > .link { order: 2; }
  .caption-image img { max-height: 60vh; }
  .caption .text, .about p { font-size: 1rem; }
  .close { top: 1.1rem; }
  .contents { padding-top: 0; margin-top: 1.4rem; }

  .readout {
    right: auto;
    bottom: auto;
    left: var(--gutter);
    top: calc(var(--gutter) + 1.6rem + max(2.8rem, min(19vw, calc(var(--map-h) * 0.2), 6rem)) * 0.95);
    text-align: left;
    font-size: 0.72rem;
  }
  .player {
    right: auto;
    left: var(--gutter);
    top: calc(var(--gutter) + 1.6rem + max(2.8rem, min(19vw, calc(var(--map-h) * 0.2), 6rem)) * 0.95 + 2.2rem);
    max-width: calc(100vw - 2 * var(--gutter));
    text-align: left;
  }
  .player-frame iframe { margin-left: 0; }
  .preview-panel { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 62vh; }
  .attribution { right: var(--gutter); font-size: 0.56rem; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .phrase-line, .phrase.is-quick .phrase-line { transition: none; }
  .leader line { transition: none; }
  .title-word { transition: none; }
  html, body { transition: none; }
}
