/* The shared page layer (spec 5.2 tokens, 5.3 type, 5.5 bar, 5.6 footer text, 5.7 list).
   Greybox fonts are system fallbacks (10.1): a serif stands in for Imbue, a sans for
   Albert Sans; the final build self-hosts both as woff2 subsets. No monospace anywhere:
   dates and addresses use tabular figures. The museum is a dark room in every theme. */

:root {
  --bg: #121315;
  --surface: #1c1d20;
  --ink: #ece7df;
  --muted: #a9a39a;
  --accent: #c99c8c;
  --accent-ink: #121315;
  --plinth: #b98f80;

  --font-display: ui-serif, Georgia, "Times New Roman", Times, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --step-small: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);
  --step-body: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  --step-lead: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
  --step-head: clamp(2rem, 1.3rem + 3.2vw, 4rem);
  --step-display: clamp(4.5rem, 12vw, 12.5rem);

  --radius: 0;
  --gutter: 32px;
  --target: 44px;
  /* The notch and the rounded corners: the page opts in with viewport-fit=cover, so anything held
     off an edge by the gutter adds these to it. */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --focus: 2px solid var(--accent);
  --focus-offset: 3px;

  color-scheme: dark;
}
@media (max-width: 759px) {
  :root { --gutter: 16px; }
}

*, *::before, *::after { box-sizing: border-box; border-radius: var(--radius); }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-body);
  font-weight: 400;
  line-height: 1.55;
  overflow-x: hidden;
}

h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-optical-sizing: auto;
  font-size: var(--step-display);
  letter-spacing: -0.01em;
  line-height: 0.9;
  white-space: nowrap;
  margin: 0;
}
h2, h3 { font-weight: 500; margin: 0; }
p { margin: 0; }
time, .addr, .tabular { font-variant-numeric: tabular-nums; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
button { font: inherit; color: inherit; }

:focus { outline: none; }
:focus-visible { outline: var(--focus); outline-offset: var(--focus-offset); }

/* ?draft (set by the gate) outlines every draft string from the 5.8 deck. */
html[data-draft] [data-draft] { outline: 1px dashed var(--muted); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- The bar (5.5) ---------- */

.bar {
  position: fixed;
  top: calc(var(--gutter) + var(--safe-t));
  right: calc(var(--gutter) + var(--safe-r));
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0 20px;
  font-size: var(--step-small);
}
.bar a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  color: var(--ink);
  text-decoration: none;
}
.bar a:hover { text-decoration: underline; }
/* Only the mode on offer shows (5.5): "List" in the room, "Gallery" in the list, and
   Gallery never without WebGL2. */
html[data-tier="list"] .bar-mode[data-mode="list"],
html:not([data-tier="list"]) .bar-mode[data-mode="gallery"] { display: none; }
.bar a[aria-current] { color: var(--muted); }
html[data-webgl2="0"] .bar-mode[data-mode="gallery"] { display: none; }
@media (max-width: 759px) {
  .bar .bar-name { display: none; }
}

/* ---------- The list (5.7) ----------
   Applies whenever the gate gives the list, and to a list marked .catalogue (the hall
   shows it below the room in every tier). Elsewhere each structure lays the <ol> out
   as its own scroll track. */

html[data-tier="list"] .works,
.works.catalogue {
  list-style: none;
  margin: 0 auto;
  padding: 0 calc(var(--gutter) + var(--safe-r)) 0 calc(var(--gutter) + var(--safe-l));
  max-width: 1280px;
}
html[data-tier="list"] .works > li,
.works.catalogue > li { margin-top: 26vh; }
html[data-tier="list"] .works > li:nth-child(3n+2),
.works.catalogue > li:nth-child(3n+2) { margin-top: 22vh; }
html[data-tier="list"] .works > li:nth-child(3n),
.works.catalogue > li:nth-child(3n) { margin-top: 30vh; }

html[data-tier="list"] .work,
.works.catalogue .work {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
html[data-tier="list"] .work-wide,
.works.catalogue .work-wide { width: 56%; margin-right: auto; }
html[data-tier="list"] .work-tall,
.works.catalogue .work-tall { width: 34%; margin-left: auto; }
html[data-tier="list"] .work-inset,
.works.catalogue .work-inset { width: 62%; margin-left: 14%; }

html[data-tier="list"] .work h2,
.works.catalogue .work h2 {
  order: 0;
  font-size: var(--step-small);
  font-weight: 400;
  color: var(--muted);
}
.pic { background: var(--surface); width: 100%; }
.pic-wide { aspect-ratio: 3 / 2; }
.pic-tall { aspect-ratio: 4 / 5; }
.pic-inset { aspect-ratio: 16 / 9; }

.work .line { color: var(--ink); max-width: 38em; }
.work .meta { font-size: var(--step-small); color: var(--muted); }
.work .meta .addr { margin-left: 0.75em; }

/* The one primary action per screen: the project link. */
.work .open {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  padding: 0 20px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
  text-decoration: none;
}
.work .open:hover { text-decoration: underline; }

/* The turn control only means something where an artefact turns. */
.work .turn {
  min-height: var(--target);
  padding: 0 16px;
  background: none;
  border: 0;
  color: var(--ink);
  font-size: var(--step-small);
  cursor: pointer;
}
html[data-tier="list"] .work .turn,
.works.catalogue .work .turn { display: none; }

@media (max-width: 759px) {
  html[data-tier="list"] .works > li,
  .works.catalogue > li,
  html[data-tier="list"] .works > li:nth-child(n),
  .works.catalogue > li:nth-child(n) { margin-top: 72px; }
  html[data-tier="list"] .work-wide,
  .works.catalogue .work-wide { width: 100%; margin: 0; }
  html[data-tier="list"] .work-tall,
  .works.catalogue .work-tall { width: 68%; margin: 0 0 0 auto; }
  html[data-tier="list"] .work-inset,
  .works.catalogue .work-inset { width: 82%; margin: 0 auto 0 0; }
}

/* ---------- The footer text (5.6) ----------
   Laid over the window view. Until a room's window render is wired in, a flat dusk
   colour stands in for it, dark enough that --ink reads on it (the greybox copy of this
   file used a gradient, which the taste lint bans). */

.museum-footer {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--gutter);
  padding-left: calc(var(--gutter) + var(--safe-l));
  padding-right: calc(var(--gutter) + var(--safe-r));
  padding-bottom: calc(var(--gutter) + var(--safe-b));
  background: #2a2a33;
  color: var(--ink);
}
.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  text-decoration: none;
}
.footer-links a:hover { text-decoration: underline; }
.footer-name {
  font-family: var(--font-display);
  font-size: var(--step-display);
  line-height: 0.9;
  letter-spacing: -0.01em;
  white-space: nowrap;
  margin-top: auto;
}
.footer-small { font-size: var(--step-small); color: var(--muted); margin-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
