/* Internet Data — engine/styles.base.css
 * Base typography, chrome, gate, overlay, and standalone-about page styles.
 * Shared by every piece in the series; per-piece styles.css adds the
 * data-field colours and any local overrides on top.
 * © 2026 Joshua Borsman. All rights reserved.
 */

:root {
  --ink: #f4f1ea;
  --ink-soft: rgba(244, 241, 234, 0.82);
  --ink-faint: rgba(244, 241, 234, 0.56);
  --void: #04070d;
  --rule: rgba(244, 241, 234, 0.14);
  --serif: "EB Garamond", "Iowan Old Style", "Apple Garamond", Garamond, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --pad: clamp(1.25rem, 2.4vw, 2rem);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--void);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  position: fixed;
  inset: 0;
  touch-action: manipulation;       /* kill ~300 ms double-tap zoom delay on iOS */
}

::selection { background: rgba(244, 241, 234, 0.18); color: var(--ink); }

a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  touch-action: manipulation;       /* kill ~300 ms double-tap zoom delay on iOS */
  transition: color 220ms ease, border-color 220ms ease;
}
a:hover, a:focus-visible { color: var(--ink); border-bottom-color: var(--ink-faint); outline: none; }

/* Keyboard focus ring that doesn't fire on mouse clicks. */
:focus-visible { outline: 2px solid var(--ink-soft); outline-offset: 3px; }
button:focus-visible { outline-offset: 3px; }

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  /* Full-bleed canvases own the gesture surface — don't let the browser
     scroll/zoom the page when the visitor touches the visual.  Pieces
     that need a draggable canvas (Ephemeris) can add `cursor: grab` in
     their own css/styles.css shim. */
  touch-action: none;
}

/* Chrome ----------------------------------------------------------------- */

.chrome {
  position: fixed;
  z-index: 10;
  user-select: none;
  pointer-events: none;
  /* Fast return when the visitor moves; slow fade when idle. */
  transition: opacity 480ms ease;
}
.chrome a, .chrome button { pointer-events: auto; }

body.is-idle .chrome {
  opacity: 0;
  transition: opacity 1400ms ease;
}

/* Safe-area-aware insets so the chrome clears the notch and the home
   indicator on iOS without affecting any desktop layout (env() resolves
   to 0 outside iOS / Android display cutouts).  calc(pad + env()) adds
   spacing on top of the pad rather than taking max — gives a touch of
   breathing room past the cutout rather than landing right against it. */
.chrome--top-left {
  top:  calc(var(--pad) + env(safe-area-inset-top));
  left: calc(var(--pad) + env(safe-area-inset-left));
}
.chrome--top-right {
  top:   calc(var(--pad) + env(safe-area-inset-top));
  right: calc(var(--pad) + env(safe-area-inset-right));
}
.chrome--bottom {
  bottom: calc(var(--pad) + env(safe-area-inset-bottom));
  left:   calc(var(--pad) + env(safe-area-inset-left));
  right:  calc(var(--pad) + env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.4rem, 2.2vw, 1.85rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0;
  line-height: 1;
}

.byline {
  margin: 0.55rem 0 0;
  font-family: var(--sans);
  font-weight: 300;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.readout {
  margin: 0;
  display: flex;
  gap: clamp(0.9rem, 1.6vw, 1.6rem);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-align: right;
}
.readout > div { display: flex; flex-direction: column; align-items: flex-end; }
.readout dt {
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 300;
}
.readout dd {
  margin: 0.18rem 0 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.meta {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 300;
  letter-spacing: 0.06em;
}
.meta .dot { color: var(--ink-faint); }
.meta .source { color: var(--ink-faint); }
.meta .source a { color: var(--ink-soft); }

.copyright {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

/* Entry gate ------------------------------------------------------------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  /* Semi-transparent veil with a soft blur so the piece's visual
     reads as a quiet texture behind the panel.  The center is a
     touch denser than the edges to keep the title and Begin button
     readable against bright motes.  The blur is what really sells
     it — sharp text on a softly-defocused field of light. */
  background: radial-gradient(120% 80% at 50% 50%, rgba(8, 12, 22, 0.68), rgba(4, 7, 13, 0.50));
  backdrop-filter: blur(12px) saturate(118%);
  -webkit-backdrop-filter: blur(12px) saturate(118%);
  display: grid;
  place-items: center;
  /* Safe-area-aware padding so the panel never sits under the notch or
     home indicator on iOS.  Overflow-y allows the panel to scroll on
     short viewports (landscape phones) rather than clipping. */
  padding: max(var(--pad), env(safe-area-inset-top))
           max(var(--pad), env(safe-area-inset-right))
           max(var(--pad), env(safe-area-inset-bottom))
           max(var(--pad), env(safe-area-inset-left));
  overflow-y: auto;
  overscroll-behavior: contain;
  transition: opacity 900ms ease, visibility 0s linear 900ms;
}
.gate.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.gate__panel {
  text-align: center;
  max-width: 32rem;
  animation: rise 1200ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.gate__title {
  margin: 0 0 1.2rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.gate__body {
  margin: 0 0 2.2rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.02rem, 1.4vw, 1.18rem);
  line-height: 1.55;
  color: var(--ink-soft);
}

.gate__enter {
  appearance: none;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink-faint);
  padding: 0.85rem 2.4rem;
  min-height: 44px;                  /* iOS HIG tap-target floor */
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;        /* kill ~300 ms double-tap zoom delay */
  transition: background 280ms ease, border-color 280ms ease;
}
.gate__enter:hover, .gate__enter:focus-visible {
  background: rgba(244, 241, 234, 0.06);
  border-color: var(--ink-soft);
  outline: none;
}

.gate__hint {
  margin: 1.8rem 0 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}
.gate__hint kbd {
  font-family: var(--mono);
  font-size: 0.7rem;
  border: 1px solid var(--ink-faint);
  border-radius: 3px;
  padding: 0.05rem 0.4rem;
  margin: 0 0.15rem;
  color: var(--ink-soft);
}
.gate__hint a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--ink-faint);
  padding-bottom: 1px;
  transition: color 220ms ease, border-color 220ms ease;
}
.gate__hint a:hover, .gate__hint a:focus-visible {
  color: var(--ink);
  border-color: var(--ink-soft);
  outline: none;
}
.gate__hint + .gate__hint { margin-top: 0.5rem; }

/* Mode toast (D-toggle confirmation) ------------------------------------- */

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(max(var(--pad), env(safe-area-inset-bottom)) + 3.4rem);
  transform: translate(-50%, 8px);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: rgba(8, 12, 22, 0.68);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--rule);
  padding: 0.6rem 1.1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 360ms ease, transform 360ms ease;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* About overlay (in-app reader; music keeps playing behind it) ----------- */

.about-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  visibility: hidden;
  opacity: 0;
  transition: opacity 520ms ease, visibility 0s linear 520ms;
}
.about-overlay.is-open {
  visibility: visible;
  opacity: 1;
  transition: opacity 520ms ease;
  /* Lifted above the gate (z-index: 100) so that when a visitor
     opens "About this piece" from the start panel, the overlay
     reads over the gate rather than behind it.  Mid-experience
     opens (gate already hidden) are unaffected — anything below
     this z-index is dimmed by the scrim either way. */
  z-index: 110;
}

.about-overlay__scrim {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 13, 0.62);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
}

.about-overlay__panel {
  position: relative;
  width: 100%;
  max-width: 46rem;
  height: 100%;
  margin: 0 auto;
  /* Safe-area-aware so the title clears the notch and the closing rule
     clears the home indicator; horizontal insets matter on landscape
     iPhone where the notch is on the side. */
  padding:
    max(clamp(2.4rem, 6vw, 4.8rem), env(safe-area-inset-top))
    max(clamp(1.4rem, 4vw, 3rem),  env(safe-area-inset-right))
    max(clamp(2.4rem, 6vw, 4.8rem), env(safe-area-inset-bottom))
    max(clamp(1.4rem, 4vw, 3rem),  env(safe-area-inset-left));
  overflow-y: auto;
  overscroll-behavior: contain;
  font-family: var(--serif);
  font-size: clamp(1.16rem, 1.4vw, 1.30rem);
  line-height: 1.78;
  color: var(--ink);
  scrollbar-width: thin;
  scrollbar-color: var(--ink-faint) transparent;
  -webkit-overflow-scrolling: touch;
}
.about-overlay__panel::-webkit-scrollbar { width: 6px; }
.about-overlay__panel::-webkit-scrollbar-thumb { background: var(--ink-faint); border-radius: 3px; }
.about-overlay__panel::-webkit-scrollbar-track { background: transparent; }

.about-overlay__panel h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.2rem, 4.2vw, 3.2rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 0.6rem;
  line-height: 1.05;
}
.about-overlay__panel h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.05rem, 1.3vw, 1.2rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 2.6rem 0 1.1rem;
}
.about-overlay__panel p { margin: 0 0 1.1em; }
.about-overlay__panel .lede {
  font-style: italic;
  color: var(--ink-soft);
  margin: 0 0 2.4rem;
  font-size: clamp(1.22rem, 1.6vw, 1.42rem);
  line-height: 1.5;
}
.about-overlay__panel dl.spec {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 0.65rem 1.4rem;
  font-family: var(--mono);
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  margin: 0 0 2.2rem;
}
.about-overlay__panel dl.spec dt { color: var(--ink-faint); text-transform: uppercase; }
.about-overlay__panel dl.spec dd { margin: 0; color: var(--ink); }
.about-overlay__panel .rule {
  border: 0; height: 1px; background: var(--rule); margin: 2.4rem 0;
}
.about-overlay__panel .copyright-line {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.about-overlay__close {
  position: sticky;
  /* env() so the button never sits under the iPhone notch when the
     panel is scrolled.  Falls back to 0 on platforms with no cutout. */
  top: env(safe-area-inset-top, 0px);
  float: right;
  appearance: none;
  background: rgba(4, 7, 13, 0.45);
  border: 1px solid var(--ink-faint);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  transition: color 220ms ease, border-color 220ms ease, background 220ms ease;
  z-index: 2;
}
.about-overlay__close:hover,
.about-overlay__close:focus-visible {
  color: var(--ink);
  border-color: var(--ink-soft);
  background: rgba(4, 7, 13, 0.7);
  outline: none;
}

@media (max-width: 640px) {
  .about-overlay__panel dl.spec { grid-template-columns: 1fr; gap: 0.1rem 0; }
  .about-overlay__panel dl.spec dt { margin-top: 0.6rem; }
}

/* Standalone /about.html ------------------------------------------------- */

body.page {
  position: static;
  overflow-y: auto;
  height: auto;
  min-height: 100%;
}
body.page #stage { display: none; }

.page-wrap {
  max-width: 46rem;
  margin: 0 auto;
  /* Safe-area-aware so the standalone /about page title clears the
     notch and the back-link clears the home indicator on iOS. */
  padding:
    max(clamp(3rem, 8vw, 6rem), env(safe-area-inset-top))
    max(var(--pad),              env(safe-area-inset-right))
    max(clamp(3rem, 6vw, 5rem),  env(safe-area-inset-bottom))
    max(var(--pad),              env(safe-area-inset-left));
  font-family: var(--serif);
  font-size: clamp(1.16rem, 1.4vw, 1.30rem);
  line-height: 1.78;
  color: var(--ink);
}
.page-wrap p { margin: 0 0 1.1em; color: var(--ink); }
.page-wrap p + p { margin-top: 0; }
.page-wrap h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.15rem, 1.35vw, 1.25rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 3rem 0 1.2rem;
}
.page-wrap h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.4rem, 4.4vw, 3.4rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 0.6rem;
  line-height: 1.05;
}
.page-wrap .lede {
  font-style: italic;
  color: var(--ink-soft);
  margin: 0 0 3rem;
  font-size: clamp(1.22rem, 1.6vw, 1.42rem);
  line-height: 1.5;
}
.page-wrap dl.spec {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 0.65rem 1.4rem;
  font-family: var(--mono);
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  margin: 0 0 2.6rem;
}
.page-wrap dl.spec dt {
  color: var(--ink-faint);
  text-transform: uppercase;
}
.page-wrap dl.spec dd { margin: 0; color: var(--ink); }
.page-wrap .back {
  display: inline-block;
  margin-top: 2.6rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.page-wrap .rule {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin: 2.6rem 0;
}

/* Mobile compactions ----------------------------------------------------- */

@media (max-width: 640px) {
  .readout { gap: 0.7rem; font-size: 0.66rem; }
  .meta { font-size: 0.78rem; gap: 0.8rem; }
  .meta .source { width: 100%; order: 10; margin-top: 0.35rem; }
  .page-wrap dl.spec { grid-template-columns: 1fr; gap: 0.1rem 0; }
  .page-wrap dl.spec dt { margin-top: 0.6rem; }

  /* The wordmark gets a tighter byline on phones — the artist line is
     part of the museum-card; hiding it on mobile diverges from the
     series spec, so keep it but tighten the typography slightly. */
  .chrome--top-left .byline {
    margin-top: 0.4rem;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
  }

  /* Copyright stays visible on phones — it's a series-mandated phrase
     and the bottom row reads bare without it.  Stack it below the meta
     row in the available width with a hair smaller type so it never
     fights the About / Artist links for space. */
  .copyright {
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    flex: 1 0 100%;
    text-align: right;
    margin-top: 0.2rem;
  }

  /* iOS Human Interface Guidelines call for ≥44pt touch targets.
     The visible type stays small (museum-card scale), but we widen
     each anchor's hit-rectangle invisibly with padding + negative
     margin so phones land their taps and desktop layout is identical. */
  .meta a {
    display: inline-block;
    padding: 0.6rem 0.4rem;
    margin: -0.6rem -0.4rem;
  }
  .gate__enter {
    /* A taller, slightly looser button on phones so it lands a fingertip
       reliably (≥44pt) without ever looking enlarged on desktop. */
    padding: 1.05rem 2.6rem;
    font-size: 0.86rem;
  }
  .about-overlay__close {
    padding: 0.75rem 1.05rem;
    font-size: 0.74rem;
  }
}

/* Touch-only refinements ------------------------------------------------- */
/* hover:none + pointer:coarse identifies a touch-primary device (iPhone,
   Android, iPad).  Desktop with a trackpad or mouse is unaffected. */

/* Mobile-only Stop button injected by engine/mobile-controls.js.  Hidden
   by default; only the touch-primary block below makes it visible.  This
   way the chrome remains canonical (wordmark + byline · About · Artist
   · ©) on every desktop/laptop, and gains the discreet Stop control on
   phones where the lockscreen pause may not be the obvious affordance. */
.meta-stop,
.meta-stop__dot { display: none; }

@media (hover: none) and (pointer: coarse) {
  /* The Press-F-for-fullscreen hint is meaningless on a phone — touch
     devices reach fullscreen from the share sheet or browser UI, not a
     keyboard.  Hide the keystroke hint; the About link below it stays. */
  .gate__hint:has(kbd) { display: none; }

  .meta-stop__dot { display: inline; }
  .meta-stop {
    appearance: none;
    background: transparent;
    border: none;
    color: var(--ink-soft);
    /* Sized + spaced so the tap rectangle meets HIG (≥44pt) while the
       visible glyph reads at the same x-height as the adjacent text
       links — sits in the museum-card type, not as a UI bolt-on. */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 0.4rem;
    margin: -0.6rem -0.4rem;
    cursor: pointer;
    transition: color 220ms ease;
    -webkit-tap-highlight-color: transparent;
  }
  .meta-stop svg {
    width: 11px;
    height: 11px;
    display: block;
  }
  .meta-stop:hover,
  .meta-stop:focus-visible {
    color: var(--ink);
    outline: none;
  }
  .meta-stop:active { color: var(--ink); }
}

/* Short viewports (landscape phones) ------------------------------------- */
/* When the visitor turns a phone to landscape, the gate's title + body +
   button + hints exceed the available height.  Tighten the vertical
   rhythm and let the gate scroll inside its own scrim. */
@media (max-height: 520px) {
  .gate__title { font-size: clamp(1.6rem, 4vw, 2.2rem); margin-bottom: 0.7rem; }
  .gate__body  { font-size: clamp(0.95rem, 1.3vw, 1.05rem); line-height: 1.45; margin-bottom: 1.3rem; }
  .gate__hint  { margin-top: 1rem; }
  .gate__panel { padding: 0.4rem 0; }
}

@media (prefers-reduced-motion: reduce) {
  .gate__panel { animation: none; }
  .chrome { transition: none; }
}

/* Printable patch sheet -------------------------------------------------- */

body.patch-sheet {
  position: static;
  overflow-y: auto;
  height: auto;
  min-height: 100%;
  background: #faf7ee;
  color: #131820;
}
body.patch-sheet #stage { display: none; }
.patch-wrap {
  max-width: 56rem;
  margin: 0 auto;
  padding: clamp(2rem, 4vw, 3.4rem) clamp(1.4rem, 4vw, 3rem) 5rem;
  font-family: var(--sans);
  color: #131820;
}
.patch-wrap h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.2rem, 4vw, 3rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 0.4rem;
}
.patch-wrap .patch-lede {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.18rem;
  color: #2e3744;
  margin: 0 0 2.2rem;
}
.patch-wrap h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.1rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 2.4rem 0 1rem;
  color: #131820;
}
.patch-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.86rem;
  margin: 0 0 1.6rem;
}
.patch-wrap table th, .patch-wrap table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid rgba(19, 24, 32, 0.18);
  vertical-align: top;
}
.patch-wrap table th {
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #515f76;
  font-size: 0.74rem;
}
.patch-wrap table td.ch { width: 3rem; color: #515f76; }
.patch-wrap p { line-height: 1.6; margin: 0 0 1rem; }
.patch-wrap .patch-foot {
  margin-top: 3rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: #515f76;
  letter-spacing: 0.06em;
}
@media print {
  body.patch-sheet { background: #fff; }
  .patch-wrap { padding: 0.4in; }
  .patch-wrap a { color: inherit; text-decoration: none; }
}
