/* The tapestry is the screen. Words arrive the way they do in a film: a title over the top,
   subtitles at the bottom, both on soft shadow rather than boxes. */
:root {
  --night: #0b0907;
  --ivory: #f3ead6;
  --ivory-soft: rgba(243, 234, 214, 0.72);
  --ivory-faint: rgba(243, 234, 214, 0.28);
  --gold: #d9b56a;        /* the yellow wool, in candlelight */
  --madder: #93391f;
  /* Roman capitals for the stitched Latin; a book face for the telling; spaced small caps for the credits. */
  --title: "Cinzel", Optima, "Trajan Pro", "Palatino Linotype", Palatino, serif;
  --text: "Cormorant Garamond", "Hoefler Text", Cochin, Baskerville, Georgia, serif;
  --label: "Avenir Next", Avenir, "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  --edge: max(18px, env(safe-area-inset-left));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night);
  color: var(--ivory);
  font-family: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; }

.room { position: fixed; inset: 0; }

/* ---------- the tapestry ---------- */
.wall {
  position: absolute; inset: 0; overflow: hidden;
  background: var(--night);
  touch-action: none; cursor: grab;
  user-select: none; -webkit-user-select: none;
}
.wall.dragging { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; will-change: transform; }
.world img {
  position: absolute; top: 0; display: block;
  pointer-events: none; user-select: none; -webkit-user-drag: none;
  background: #2a241c;
  transition: opacity 0.3s ease;
}
/* shadow at the top and bottom of the frame, so the words sit on the picture without boxes */
.room::before, .room::after {
  content: ""; position: absolute; left: 0; right: 0; z-index: 2; pointer-events: none;
}
.room::before { top: 0; height: 230px; background: linear-gradient(to bottom, rgba(11, 9, 7, 0.9), rgba(11, 9, 7, 0.6) 55%, rgba(11, 9, 7, 0)); }
.room::after { bottom: 0; height: 230px; background: linear-gradient(to top, rgba(11, 9, 7, 0.9), rgba(11, 9, 7, 0.55) 50%, rgba(11, 9, 7, 0)); }
.room.reading::after { height: 440px; background: linear-gradient(to top, rgba(11, 9, 7, 0.96), rgba(11, 9, 7, 0.88) 58%, rgba(11, 9, 7, 0)); transition: height 0.4s; }

/* points of interest: a small light on the cloth */
.mark {
  position: absolute; z-index: 3; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border: 0; padding: 0; background: none; cursor: pointer;
}
.mark::before, .mark::after {
  content: ""; position: absolute; left: 50%; top: 50%; border-radius: 50%;
}
.mark::before {
  width: 8px; height: 8px; margin: calc(-4px - var(--lift, 0px)) 0 0 -4px;
  background: var(--ivory);
  box-shadow: 0 0 0 1.5px rgba(11, 9, 7, 0.35), 0 0 12px 3px rgba(255, 228, 170, 0.75);
}
.mark::after {
  width: 26px; height: 26px; margin: calc(-13px - var(--lift, 0px)) 0 0 -13px;
  border: 1px solid rgba(255, 240, 210, 0.85);
  animation: halo 2.6s ease-out infinite;
}
.mark-label {
  position: absolute; left: 34px; top: calc(50% - var(--lift, 0px)); transform: translate(-4px, -50%);
  font-family: var(--label); font-weight: 500; font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase;
  white-space: nowrap; color: var(--ivory);
  padding: 5px 9px; border-radius: 2px;
  background: rgba(11, 9, 7, 0.62);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.mark-lead {
  position: absolute; left: 50%; top: calc(50% - var(--lift, 0px) + 6px); width: 1px; height: calc(var(--lift, 0px) - 6px);
  margin-left: -0.5px; pointer-events: none; display: none;
  background: repeating-linear-gradient(to bottom, rgba(243, 234, 214, 0.85) 0 2px, transparent 2px 5px);
}
.mark.lifted .mark-lead { display: block; }
.mark.fable .mark-lead { background: repeating-linear-gradient(to bottom, rgba(217, 181, 106, 0.95) 0 2px, transparent 2px 5px); }
.mark.flip .mark-label { left: auto; right: 34px; transform: translate(4px, -50%); }
.mark.near .mark-label { opacity: 1; transform: translate(0, -50%); }
.mark.seen .mark-label { color: var(--ivory-soft); }
.mark.fable::before { background: var(--gold); box-shadow: 0 0 0 1.5px rgba(11, 9, 7, 0.35), 0 0 12px 3px rgba(217, 181, 106, 0.8); }
.mark.fable::after { border-color: rgba(217, 181, 106, 0.95); }
.mark.fable .mark-label { color: var(--gold); }
.mark.seen::before { background: rgba(243, 234, 214, 0.6); box-shadow: 0 0 0 1.5px rgba(11, 9, 7, 0.3); }
.mark.seen::after { animation: none; opacity: 0.45; }
.mark.on { opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.mark:focus-visible { outline: 1px solid var(--gold); outline-offset: -6px; border-radius: 50%; }
@keyframes halo { 0% { transform: scale(0.5); opacity: 0.95; } 100% { transform: scale(1.5); opacity: 0; } }
.spot { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.45s ease; }
.spot.on { opacity: 1; }

/* ---------- small spaced capitals, used for every label ---------- */
.eyebrow, .card-label, .text-btn, .hint, .metres {
  font-family: var(--label); font-weight: 500;
  font-size: 10.5px; letter-spacing: 0.26em; text-transform: uppercase;
}

/* ---------- the title ---------- */
.title {
  position: absolute; z-index: 5;
  top: max(18px, env(safe-area-inset-top)); left: var(--edge);
  max-width: min(560px, calc(100% - var(--edge) - 70px)); /* the top right corner belongs to the app */
  padding: 0; border: 0; background: none; text-align: left; cursor: pointer;
  display: grid; gap: 7px;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.55);
}
.title:focus-visible { outline: 1px solid var(--gold); outline-offset: 6px; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: var(--gold); }
.eyebrow i { width: 22px; height: 1px; background: currentColor; opacity: 0.6; }
.latin {
  font-family: var(--title); font-weight: 400;
  font-size: clamp(15px, 4.3vw, 24px); line-height: 1.32;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ivory);
  text-wrap: balance;
}
.english {
  font-family: var(--text); font-style: italic; font-weight: 400;
  font-size: clamp(17px, 4.6vw, 22px); line-height: 1.25;
  color: var(--ivory-soft);
}

/* ---------- ghost buttons ---------- */
.ghost {
  width: 40px; height: 40px; border-radius: 50%; padding: 0; cursor: pointer;
  display: grid; place-items: center;
  border: 1px solid var(--ivory-faint); background: rgba(11, 9, 7, 0.28);
  color: var(--ivory);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: border-color 0.2s, opacity 0.2s;
}
.ghost:hover { border-color: var(--ivory-soft); }
.ghost:disabled { opacity: 0.3; cursor: default; }
.ghost:focus-visible, .text-btn:focus-visible { outline: 1px solid var(--gold); outline-offset: 3px; }
.ghost.small { width: 32px; height: 32px; border: 0; background: none; color: var(--ivory-soft); -webkit-backdrop-filter: none; backdrop-filter: none; }
.zoom {
  position: absolute; z-index: 5; right: var(--edge);
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 70px);
  display: grid; gap: 10px;
}
.room.reading .zoom { opacity: 0; pointer-events: none; }

.text-btn {
  border: 0; background: none; padding: 10px 0; cursor: pointer;
  color: var(--ivory-soft); transition: color 0.2s;
}
.text-btn:hover { color: var(--ivory); }

/* ---------- the foot: subtitles and the timeline ---------- */
.foot {
  position: absolute; z-index: 5;
  left: var(--edge); right: var(--edge); bottom: max(10px, env(safe-area-inset-bottom));
  display: grid; gap: 4px;
}
.card {
  max-width: 34em; margin: 0 auto 6px; text-align: center;
  animation: fadeup 0.4s ease-out;
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.7);
}
@keyframes fadeup { from { opacity: 0; transform: translateY(6px); } }
.card-label { margin: 0 0 8px; color: var(--gold); }
.card-src {
  margin: 10px auto 0; max-width: 30em;
  font-family: var(--label); font-size: 10.5px; line-height: 1.6; letter-spacing: 0.04em; color: var(--ivory-soft);
}
.card-src a { color: var(--ivory-soft); text-decoration: none; border-bottom: 1px solid var(--ivory-faint); }
.card-src a:hover { color: var(--gold); border-color: var(--gold); }
.card-text {
  margin: 0;
  font-size: clamp(19px, 5vw, 23px); line-height: 1.32; font-weight: 400;
  color: var(--ivory);
  text-wrap: pretty;
}
.card { cursor: pointer; }
.card-actions { display: flex; justify-content: center; gap: 22px; margin: 4px 0 0; }
.card-actions:empty, .card-actions:not(:has(button:not([hidden]))) { display: none; }

.hint {
  margin: 0 0 6px; text-align: center; color: var(--ivory-soft); white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: opacity 0.6s ease;
}
.hint i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; }
.hint.gone { opacity: 0; pointer-events: none; }
.room.reading .hint { display: none; }

.bar { display: flex; align-items: center; gap: 14px; height: 52px; }
.read {
  flex: none; width: 36px; height: 40px; margin-left: -8px; padding: 0; border: 0; background: none; cursor: pointer;
  display: grid; place-items: center; color: var(--ivory); transition: color 0.2s, transform 0.2s;
}
.read svg { width: 24px; height: 24px; }
.read .sheet { fill: currentColor; stroke: currentColor; stroke-width: 1; stroke-linejoin: round; }
.read .fold { fill: none; stroke: var(--night); stroke-width: 1.2; }
.read .lines { fill: none; stroke: var(--night); stroke-width: 1; opacity: 0.8; }
.read:hover { transform: translateY(-1px); }
.read[aria-expanded="true"] { color: var(--gold); }
.read:focus-visible { outline: 1px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.ribbon { position: relative; flex: 1; height: 44px; cursor: ew-resize; touch-action: none; outline: none; min-width: 0; }
.ribbon canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.ribbon:focus-visible { outline: 1px solid var(--gold); outline-offset: 2px; }
.metres { flex: none; color: var(--ivory-soft); font-variant-numeric: tabular-nums; letter-spacing: 0.14em; min-width: 6.2ch; text-align: right; }
.metres span { color: var(--ivory); }

/* ---------- looking at a detail: the title and the top shadow step aside ---------- */
.room.focus .title { opacity: 0; pointer-events: none; }
.room.focus::before { opacity: 0; }

/* ---------- the opening: a title sequence ---------- */
.wall { transition: opacity 0.38s ease; }
.room.cut .wall { opacity: 0; }
.room.opening .title, .room.opening .zoom, .room.opening .foot, .room.opening .mark { opacity: 0; pointer-events: none; }
.room.opening::before, .room.opening::after { opacity: 0; }
.title, .zoom, .foot, .room::before, .room::after { transition: opacity 0.8s ease; }
.intro {
  position: absolute; inset: 0; z-index: 20;
  display: grid; grid-template-rows: auto 1fr auto;
  padding: max(16px, env(safe-area-inset-top)) var(--edge) max(18px, env(safe-area-inset-bottom));
  /* the cloth stays visible above; the words sit in the dark below, like the end of a reel */
  background:
    linear-gradient(to bottom, rgba(11, 9, 7, 0.7), rgba(11, 9, 7, 0) 18%),
    linear-gradient(to top, rgba(11, 9, 7, 1), rgba(11, 9, 7, 1) 20%, rgba(11, 9, 7, 0) 40%);
  cursor: pointer;
  animation: fade 1.2s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.intro-bars[hidden] { display: block !important; visibility: hidden; }
.intro-bars { display: flex; gap: 5px; margin-right: 64px; /* the top right corner belongs to the app */ }
.intro-bars span { flex: 1; height: 2px; border-radius: 1px; background: var(--ivory-faint); overflow: hidden; }
.intro-bars span b { display: block; height: 100%; width: 0; background: var(--ivory); }
.intro-bars span.done b { width: 100%; }
.intro-bars span.now b { width: 100%; transition: width 0.9s ease; }
.intro-body { align-self: end; max-width: 34em; padding-bottom: 18px; position: relative; isolation: isolate; }
/* the words sit on solid black, which fades out just above the title, wherever the title lands */
.intro-body::before {
  content: ""; position: absolute; z-index: -1;
  left: -50vw; right: -50vw; top: -90px; bottom: -40vh;
  background: linear-gradient(to bottom, rgba(11, 9, 7, 0), rgba(11, 9, 7, 0.92) 70px, var(--night) 110px);
  pointer-events: none;
}
.intro-kicker { margin: 0 0 14px; }
.intro-title {
  margin: 0 0 8px; font-family: var(--title); font-weight: 400;
  font-size: clamp(34px, 10.5vw, 64px); line-height: 1.02; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ivory);
}
.intro-sub { margin: 0 0 22px; font-style: italic; font-size: clamp(15px, 4vw, 18px); color: var(--ivory-soft); }
.intro.later .intro-title, .intro.later .intro-sub { display: none; }
.intro-quote {
  position: relative; margin: 0; padding-left: 0.62em;
  font-size: clamp(15px, 4vw, 19px); line-height: 1.45; font-weight: 400;
  color: var(--ivory); text-wrap: pretty;
}
.intro-quote .gap { color: var(--gold); letter-spacing: 0.08em; white-space: nowrap; }
.intro-quote::before {
  content: "“"; position: absolute; left: -0.08em; top: -0.12em;
  font-size: 1.6em; line-height: 1; color: var(--gold);
}
.intro-quote.quoted::before { content: none; }
.intro-quote.in { animation: fadeup 0.9s ease-out; }
.intro-cite {
  display: grid; justify-items: start; gap: 6px; margin: 20px 0 0;
  padding-left: calc(0.62 * clamp(15px, 4vw, 19px));
  font-family: var(--label); font-weight: 500; font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ivory-soft);
}
.intro-cite i { width: 18px; height: 1px; background: currentColor; opacity: 0.6; }
.intro-cite a { color: var(--gold); text-decoration: none; border-bottom: 1px solid rgba(217, 181, 106, 0.4); padding-bottom: 1px; }
.intro-foot { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; }
.intro-tap { font-family: var(--label); font-weight: 500; font-size: 10.5px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--ivory-soft); animation: breath 2.4s ease-in-out infinite; }
@keyframes breath { 50% { opacity: 0.45; } }
.cta {
  display: grid; place-items: center; margin-left: auto;
  width: 56px; height: 48px; margin-right: -10px; padding: 0; cursor: pointer;
  border: 0; background: none; color: var(--ivory);
  animation: fadeup 0.6s ease-out;
  transition: transform 0.25s ease;
}
.cta:hover { transform: translateX(4px); }
.cta svg { width: 32px; height: 32px; stroke-width: 1.3; animation: nudge-on 2.4s ease-in-out 1.2s infinite; }
/* a slow drift to the right and back, like a hand beckoning you along */
@keyframes nudge-on { 0%, 100% { transform: translateX(0); opacity: 0.85; } 50% { transform: translateX(6px); opacity: 1; } }
.cta:hover svg { animation-play-state: paused; }
.cta:focus-visible { outline: 1px solid var(--gold); outline-offset: 4px; }
@media (min-width: 760px) {
  .intro { padding-left: max(56px, 8vw); padding-right: max(56px, 8vw); }
  .intro-body { padding-bottom: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .intro, .intro-quote.in, .cta, .cta svg, .intro-tap { animation: none; }
}

/* ---------- credits ---------- */
.suggest { margin: 0 0 6px; display: grid; gap: 8px; }
.suggest-body { display: grid; gap: 8px; }
.suggest label { font-family: var(--label); font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold); }
.suggest textarea {
  width: 100%; resize: vertical; min-height: 96px; padding: 10px 12px;
  font: inherit; font-size: 16px; line-height: 1.4; color: var(--ivory);
  background: rgba(243, 234, 214, 0.06); border: 1px solid var(--ivory-faint); border-radius: 2px;
}
.suggest textarea:focus { outline: 1px solid var(--gold); outline-offset: 1px; }
.suggest-note { margin: 0; font-size: 13px; font-style: italic; color: var(--ivory-soft); }
.suggest-error { margin: 0; font-size: 13px; color: #e8a38f; min-height: 0; }
.suggest-error:empty, .suggest-status:empty { display: none; }
.suggest-status { margin: 0; font-size: 14px; color: var(--gold); }
.suggest .send { justify-self: start; color: var(--ivory); }
.suggest .send:disabled { opacity: 0.5; cursor: default; }
.credit {
  max-width: min(520px, calc(100% - 36px));
  border: 1px solid var(--ivory-faint); border-radius: 2px;
  background: rgba(16, 13, 10, 0.96); color: var(--ivory);
  padding: 24px 26px 14px; font-size: 17px; line-height: 1.45;
}
.credit::backdrop { background: rgba(0, 0, 0, 0.6); }
.credit p { margin: 0 0 12px; }
.credit .eyebrow { color: var(--gold); margin: 0; }
.credit-head { display: flex; align-items: center; gap: 10px; margin: -8px 0 16px -10px; }
.back-btn { width: 40px; height: 40px; padding: 0; border: 0; background: none; cursor: pointer; color: var(--ivory); display: grid; place-items: center; }
.back-btn svg { width: 20px; height: 20px; }
.back-btn:focus-visible { outline: 1px solid var(--gold); outline-offset: 0; border-radius: 50%; }
.credit #credit-line { font-size: 15px; color: var(--ivory-soft); }
.credit a { color: var(--gold); }
.credit .note { font-size: 14px; font-style: italic; color: var(--ivory-soft); border-top: 1px solid var(--ivory-faint); padding-top: 12px; }
.credit form { display: flex; gap: 22px; flex-wrap: wrap; }

@media (min-width: 760px) {
  .room::before { height: 220px; }
  .zoom { bottom: auto; top: 50%; transform: translateY(-50%); }
  .foot { left: 50%; right: auto; transform: translateX(-50%); width: min(820px, calc(100% - 2 * var(--edge))); }
}
@media (prefers-reduced-motion: reduce) {
  .mark::after { animation: none; }
  .card { animation: none; }
  .spot, .hint, .world img { transition: none; }
}
