/* ============================================================
   WORKS — the hall
   The hall itself is WebGL (js/). This file is the paper laid
   over it: title, the label for the piece in front of you, the
   rail, the bar under something you're holding, and the index.
   ============================================================ */

:root {
  --wall:   #ece5d9;
  --paper:  #f7f3ec;
  --ink:    #2b2420;
  --ink-2:  #6a5e53;
  --ink-3:  #8f8273;
  --line:   rgba(70, 52, 32, .2);
  --glass:  rgba(250, 247, 241, .78);

  --f-display: "Gloock", Georgia, serif;
  --f-text:    "Newsreader", Georgia, "Times New Roman", serif;
  --f-mono:    "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --gut: clamp(18px, 4vw, 56px);
  --ease: cubic-bezier(.22, .8, .3, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  color: var(--ink);
  background: var(--wall);
  font-family: var(--f-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink-2); outline-offset: 3px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

#gl {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  outline: none;
  cursor: default;
}
body.dragging #gl { cursor: grabbing !important; }

/* a little air and grain over the render */
.atmos {
  position: fixed; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 60%, rgba(60, 42, 24, .12) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .14;
}

/* ---------- shared bits ---------- */
.eyebrow {
  margin: 0;
  font: 500 11px/1 var(--f-mono);
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.pill {
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
}

/* ---------- top bar ---------- */
.top {
  position: fixed; left: 0; right: 0; top: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(18px + env(safe-area-inset-top)) var(--gut) 0;
  pointer-events: none;
  z-index: 10;
}
.top > * { pointer-events: auto; }
.brand {
  font: 400 15px/1 var(--f-text);
  color: var(--ink-2);
  text-decoration: none;
  transition: opacity .5s var(--ease), transform .5s var(--ease);
}
.brand b { font-family: var(--f-display); font-weight: 400; color: var(--ink); font-size: 17px; }
body.at-start .brand { opacity: 0; transform: translateY(-6px); pointer-events: none; }
.index-btn {
  padding: 9px 14px 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font: 500 11px/1 var(--f-mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.index-btn span { color: var(--ink-3); letter-spacing: .08em; }
.index-btn:hover { border-color: var(--ink-2); background: var(--paper); }

/* ---------- intro (at the entrance) ---------- */
.intro {
  position: fixed; left: var(--gut); top: 50%;
  transform: translateY(-52%);
  max-width: min(560px, 80vw);
  pointer-events: none;
  transition: opacity .7s var(--ease), transform .9s var(--ease);
  z-index: 5;
}
.intro::before { /* a soft wash so the title reads over the hall */
  content: "";
  position: absolute; z-index: -1;
  left: calc(var(--gut) * -1 - 40px); top: -30%; bottom: -30%; width: min(900px, 120vw);
  background: radial-gradient(60% 55% at 28% 50%, rgba(236, 229, 217, .82), rgba(236, 229, 217, 0) 100%);
}
.intro > * { pointer-events: auto; }
.intro h1 {
  margin: .22em 0 .12em;
  font: 400 clamp(72px, 11vw, 168px)/.86 var(--f-display);
  letter-spacing: -.02em;
}
.intro .sub {
  margin: 0;
  font-style: italic;
  font-size: clamp(18px, 1.7vw, 23px);
  line-height: 1.35;
  color: var(--ink-2);
}
.walk {
  margin-top: 30px;
  padding: 14px 22px 13px;
  border: 0;
  border-radius: 99px;
  background: var(--ink);
  color: var(--paper);
  font: 500 12px/1 var(--f-mono);
  letter-spacing: .2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .2s var(--ease), box-shadow .2s;
}
.walk:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -12px rgba(40, 28, 16, .6); }
.walk span { display: inline-block; margin-left: 6px; animation: nudge 2.4s var(--ease) infinite; }
.how {
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  margin: 18px 0 0;
  font: 400 10.5px/1.6 var(--f-mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.how-touch { display: none; }
@media (pointer: coarse) { .how-keys { display: none; } .how-touch { display: flex; } }
body:not(.at-start) .intro { opacity: 0; transform: translateY(-56%) translateX(-24px); }
body:not(.at-start) .intro > * { pointer-events: none; }
@keyframes nudge { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(3px); } }

/* ---------- the piece in front of you ---------- */
.focus {
  position: fixed; left: var(--gut); bottom: calc(26px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start; align-items: end;
  column-gap: 22px;
  max-width: min(520px, 70vw);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .45s var(--ease), transform .45s var(--ease);
  pointer-events: none;
  z-index: 5;
}
body.has-focus:not(.holding):not(.at-start) .focus { opacity: 1; transform: none; pointer-events: auto; }
.f-num { grid-column: 1 / -1; font: 500 10.5px/1 var(--f-mono); letter-spacing: .2em; color: var(--ink-3); }
.f-name {
  grid-column: 1;
  margin-top: 10px;
  font: 400 clamp(26px, 2.6vw, 36px)/1.02 var(--f-display);
  letter-spacing: -.005em;
  color: var(--ink);
}
.f-kind {
  grid-column: 1;
  margin-top: 8px;
  font: 400 10.5px/1.4 var(--f-mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.f-pick {
  grid-column: 2; grid-row: 2 / span 2;
  align-self: end;
  padding: 11px 16px 10px;
  border: 1px solid var(--ink);
  border-radius: 99px;
  background: transparent;
  font: 500 11px/1 var(--f-mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.f-pick:hover { background: var(--ink); color: var(--paper); }
.focus .f-name, .focus .f-kind, .focus .f-num { text-shadow: 0 0 14px rgba(236, 229, 217, .95), 0 0 3px rgba(236, 229, 217, .9); }
.focus.swap .f-name, .focus.swap .f-kind, .focus.swap .f-num { animation: rise .5s var(--ease) both; }
.focus.swap .f-kind { animation-delay: .05s; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- rail: where you are in the hall ---------- */
.rail {
  position: fixed; right: calc(var(--gut) - 6px); top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: flex-end;
  gap: 2px;
  z-index: 5;
  transition: opacity .4s;
}
body.holding .rail { opacity: 0; pointer-events: none; }
.tick {
  position: relative;
  width: 34px; height: 16px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.tick::after {
  content: "";
  position: absolute; right: 6px; top: 50%;
  width: 12px; height: 1.5px;
  background: var(--ink-3);
  opacity: .55;
  transition: width .35s var(--ease), background .2s, opacity .2s;
}
.tick:hover::after { width: 18px; opacity: 1; }
.tick.on::after { width: 24px; background: var(--ink); opacity: 1; }
.tick-label {
  position: absolute; right: 40px; top: 50%;
  transform: translateY(-50%) translateX(6px);
  white-space: nowrap;
  font: 500 10.5px/1 var(--f-mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .3s var(--ease);
}
.tick:hover .tick-label, .tick:focus-visible .tick-label { opacity: 1; transform: translateY(-50%); }

/* ---------- the end of the hall ---------- */
.outro {
  position: fixed; left: 50%; bottom: calc(9vh + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .6s var(--ease), transform .6s var(--ease);
  z-index: 5;
  width: min(92vw, 520px);
}
body.at-end:not(.holding):not(.has-focus) .outro { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.o-line { margin: 0; font: italic 400 clamp(20px, 2vw, 26px)/1.3 var(--f-text); color: var(--ink); }
.o-back {
  margin-top: 18px;
  padding: 11px 18px 10px;
  border: 1px solid var(--ink);
  border-radius: 99px;
  background: var(--glass);
  font: 500 11px/1 var(--f-mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  cursor: pointer;
}
.o-back:hover { background: var(--ink); color: var(--paper); }
.o-copy { margin: 16px 0 0; font: 400 10.5px/1 var(--f-mono); letter-spacing: .16em; color: var(--ink-3); }

/* ---------- holding something ---------- */
.inspect-ui {
  position: fixed; left: 0; right: 0; bottom: calc(22px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 0 16px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .35s var(--ease), transform .45s var(--ease);
  z-index: 8;
}
body.holding .inspect-ui { opacity: 1; transform: none; transition-delay: .45s; }
body.holding .inspect-ui .ins-bar { pointer-events: auto; }
.ins-hint {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 10px;
  margin: 0;
  font: 400 10px/1.5 var(--f-mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.ins-bar {
  display: flex; align-items: center; gap: 6px;
  max-width: 100%;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: 0 18px 40px -24px rgba(40, 28, 16, .55);
}
.ins-btn {
  flex: none;
  width: 42px; height: 42px;
  padding: 0 0 3px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font: 26px/1 var(--f-text);
  color: var(--ink-2);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.ins-btn:hover { background: rgba(70, 52, 32, .08); color: var(--ink); }
.ins-close { font-size: 24px; }
.ins-title { display: flex; flex-direction: column; gap: 5px; min-width: 0; padding: 0 10px 0 6px; }
.ins-title b { font: 500 16px/1.1 var(--f-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ins-title span { font: 400 9.5px/1 var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }
.ins-cta {
  flex: none;
  padding: 13px 18px 12px;
  border-radius: 99px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  font: 500 11px/1 var(--f-mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: transform .2s var(--ease), box-shadow .2s;
}
.ins-cta:hover { transform: translateY(-1px); box-shadow: 0 8px 18px -10px rgba(40, 28, 16, .7); }

/* a wide piece held on a tall screen: its back, printed below it */
.ins-read { display: none; }
body.wide-held .ins-read {
  display: block;
  width: 100%;
  max-width: 520px;
  margin-bottom: 4px;
  padding: 0 4px;
  color: var(--ink);
}
.ins-read p { margin: 0; }
.r-eyebrow { font: 500 10px/1.5 var(--f-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); }
.r-tag { margin-top: 6px !important; font: italic 400 18px/1.3 var(--f-text); }
.ins-read ul { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.ins-read li { position: relative; padding-left: 16px; font-size: 15px; line-height: 1.42; }
.ins-read li::before { content: ""; position: absolute; left: 1px; top: .55em; width: 6px; height: 6px; background: var(--ink-2); transform: rotate(45deg); }

/* ---------- reading the Bible ---------- */
body.reading .inspect-ui { visibility: hidden; }
.reader-ui {
  position: fixed; left: 0; right: 0; bottom: calc(22px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 0 16px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .35s var(--ease), transform .45s var(--ease);
  z-index: 8;
}
body.reading .reader-ui { opacity: 1; transform: none; transition-delay: .6s; }
body.reading .reader-ui .ins-bar, body.reading .rd-toc { pointer-events: auto; }
.rd-title {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  min-width: 170px; padding: 6px 14px;
  border: 0; border-radius: 99px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.rd-title:hover, .rd-title[aria-expanded="true"] { background: rgba(70, 52, 32, .08); }
.rd-title b { font: 500 16px/1.1 var(--f-text); white-space: nowrap; }
.rd-title b::after { content: " ▾"; font-size: 11px; color: var(--ink-3); }
.rd-title span { font: 400 9.5px/1 var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }
.rd-toc {
  width: min(640px, 100%);
  max-height: min(58vh, 520px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px 18px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(250, 247, 241, .94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 24px 50px -28px rgba(40, 28, 16, .6);
}
.rd-toc[hidden], .rd-toc [hidden] { display: none; }
.rd-toc h3 { margin: 0 0 8px; font: 500 10px/1 var(--f-mono); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); }
.rd-toc h3:not(:first-child) { margin-top: 16px; }
.rd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 2px 6px; }
.rd-grid button, .rd-ch-grid button {
  padding: 7px 8px;
  border: 0; border-radius: 8px;
  background: transparent;
  font: 400 15px/1.2 var(--f-text);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.rd-grid button:hover, .rd-ch-grid button:hover { background: rgba(70, 52, 32, .08); }
.rd-grid button.on, .rd-ch-grid button.on { background: var(--ink); color: var(--paper); }
.rd-ch-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.rd-ch-head b { font: 400 22px/1 var(--f-display); }
.rd-ch-back {
  padding: 7px 12px 6px;
  border: 1px solid var(--line); border-radius: 99px;
  background: transparent;
  font: 500 10.5px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-2);
  cursor: pointer;
}
.rd-ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 4px; }
.rd-ch-grid button { text-align: center; font-variant-numeric: tabular-nums; }
.rd-hint .t { display: none; }
@media (pointer: coarse) { .rd-hint .k { display: none; } .rd-hint .t { display: inline; } }

/* ---------- index ---------- */
.index {
  position: fixed; inset: 0;
  z-index: 20;
  overflow: auto;
  overscroll-behavior: contain;
  background: rgba(236, 229, 217, .9);
  backdrop-filter: blur(18px) saturate(.9);
  -webkit-backdrop-filter: blur(18px) saturate(.9);
  animation: fade .35s var(--ease);
}
.index[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.ix-inner { max-width: 980px; margin: 0 auto; padding: calc(70px + env(safe-area-inset-top)) var(--gut) 80px; }
.ix-head { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px 20px; margin-bottom: 34px; }
.ix-head .eyebrow { grid-column: 1 / -1; }
.ix-head h2 { margin: 0; font: 400 clamp(34px, 4vw, 54px)/1 var(--f-display); letter-spacing: -.01em; }
.ix-close {
  padding: 10px 15px 9px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--glass);
  font: 500 11px/1 var(--f-mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  cursor: pointer;
}
.ix-close:hover { border-color: var(--ink-2); }
.ix-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.ix-item {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 6px 18px;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.ix-num { font: 500 11px/1 var(--f-mono); letter-spacing: .16em; color: var(--ink-3); align-self: start; padding-top: 7px; }
.ix-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ix-name { font: 400 clamp(22px, 2.2vw, 28px)/1.1 var(--f-display); }
.ix-kind { font: 400 10.5px/1.5 var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }
.ix-tag { font-style: italic; font-size: 17px; color: var(--ink-2); }
.ix-actions { display: flex; gap: 8px; }
.ix-go, .ix-open {
  padding: 10px 14px 9px;
  border: 1px solid var(--ink);
  border-radius: 99px;
  background: transparent;
  font: 500 10.5px/1 var(--f-mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.ix-go:hover, .ix-open:hover { background: var(--ink); color: var(--paper); }

/* without WebGL the index is the page */
.no-gl body { overflow: auto; }
.no-gl .index { position: static; background: var(--wall); backdrop-filter: none; -webkit-backdrop-filter: none; animation: none; overflow: visible; }
.no-gl .ix-close, .no-gl .ix-go, .no-gl .intro, .no-gl .focus, .no-gl .rail, .no-gl .outro, .no-gl .inspect-ui,
.no-gl .index-btn, .no-gl #gl, .no-gl .atmos { display: none; }
.no-gl body.at-start .brand { opacity: 1; transform: none; pointer-events: auto; }
.no-gl .top { position: static; }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; font-style: italic; }

/* ---------- loader ---------- */
.loader {
  position: fixed; inset: 0;
  z-index: 30;
  display: grid; place-content: center; justify-items: center; gap: 12px;
  background: var(--wall);
  transition: opacity .8s var(--ease), visibility .8s;
}
.loader.gone { opacity: 0; visibility: hidden; }
.loader p { margin: 0; font: italic 400 20px/1 var(--f-text); color: var(--ink-2); }
.loader span { font: 500 10.5px/1 var(--f-mono); letter-spacing: .2em; color: var(--ink-3); }
.loader i { display: block; width: 140px; height: 1px; background: var(--line); overflow: hidden; }
.loader b { display: block; height: 100%; background: var(--ink); transform: scaleX(0); transform-origin: left; transition: transform .4s var(--ease); }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .intro { top: auto; bottom: calc(10vh + env(safe-area-inset-bottom)); transform: none; max-width: none; right: var(--gut); }
  body:not(.at-start) .intro { transform: translateY(-12px); }
  .intro::before { left: -40px; right: -40px; width: auto; top: -40%; bottom: -60%; background: radial-gradient(70% 60% at 40% 55%, rgba(236, 229, 217, .85), rgba(236, 229, 217, 0) 100%); }
  .how span[aria-hidden] { display: none; }
  .focus { left: var(--gut); right: var(--gut); max-width: none; grid-template-columns: 1fr auto; }
  .f-name { font-size: 26px; }
  .rail { top: auto; bottom: auto; top: calc(64px + env(safe-area-inset-top)); transform: none; flex-direction: row; right: auto; left: var(--gut); gap: 0; }
  .tick { width: 16px; height: 22px; }
  .tick::after { right: 3px; width: 10px; height: 1.5px; }
  .tick:hover::after { width: 10px; }
  .tick.on::after { width: 10px; height: 3px; }
  .tick-label { display: none; }
  .ins-hint span:nth-child(n+4) { display: none; }
  .ins-bar { width: 100%; }
  .ins-title { flex: 1; }
  .ins-title b { font-size: 15px; }
  .ins-cta { padding: 12px 14px 11px; letter-spacing: .1em; }
  .ins-btn { width: 38px; height: 38px; }
  .ix-item { grid-template-columns: 34px 1fr; }
  .ix-actions { grid-column: 2; }
}
@media (max-width: 420px) {
  .ins-prev, #ins-prev, #ins-next { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
}
