/* ==========================================================================
   The Living Canvas · art edition
   Palette: ivory, umber, olive, aged gold, midnight
   ========================================================================== */
:root {
  --ivory: #efe6d2;
  --ivory-2: #d9ccb0;
  --muted: #a89a7f;
  --umber: #1a120b;
  --umber-2: #2a1d12;
  --olive: #6f6c3c;
  --gold: #c9a45c;
  --gold-hi: #f0d595;
  --midnight: #0e1424;
  --display: "Instrument Serif", "Cormorant Garamond", Georgia, serif;
  --garamond: "Cormorant Garamond", Georgia, serif;
  --body: "EB Garamond", "Times New Roman", Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--umber); color: var(--ivory);
  font: 400 19px/1.62 var(--body); -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: inherit; }
::selection { background: var(--gold); color: var(--umber); }
:focus-visible { outline: 1.5px solid var(--gold-hi); outline-offset: 4px; border-radius: 4px; }
.skip { position: absolute; left: 16px; top: -60px; z-index: 200; background: var(--ivory); color: var(--umber); padding: 8px 14px; border-radius: 6px; }
.skip:focus { top: 12px; }

/* ---------- stage ---------- */
#stage, .stage-fallback { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; }
#stage { display: block; opacity: 0; transition: opacity 1.2s ease; }
.gl #stage { opacity: 1; }
.stage-fallback { display: none; background: var(--umber); }
.no-gl .stage-fallback { display: block; }
.stage-fallback img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0;
  transition: opacity 1.2s ease; filter: brightness(.62) sepia(.15);
}
.stage-fallback img.is-on { opacity: 1; }

.grain {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse at 50% 40%, transparent 55%, rgba(10, 6, 3, .55) 100%);
}

/* ---------- oculus ---------- */
.lens {
  position: fixed; left: 0; top: 0; z-index: 3; pointer-events: none;
  width: var(--d, 220px); height: var(--d, 220px);
  transform: translate3d(var(--x, 50vw), var(--y, 50vh), 0) translate(-50%, -50%) scale(var(--s, 1));
  opacity: var(--o, 0); will-change: transform, opacity;
}
.lens-ring { position: absolute; inset: -14%; width: 128%; height: 128%; overflow: visible; filter: drop-shadow(0 6px 18px rgba(0,0,0,.55)); }
.lens-inscription { transform-origin: 100px 100px; animation: turn 60s linear infinite; }
.lens-inscription text { font: 500 9.6px var(--garamond); letter-spacing: 3.2px; fill: var(--gold-hi); opacity: .85; }
.lens-ticks { transform-origin: 100px 100px; animation: turn 90s linear infinite reverse; }
@keyframes turn { to { transform: rotate(1turn); } }
.lens-cameo {
  position: absolute; inset: 5%; border-radius: 50%; overflow: hidden; opacity: var(--cameo, 1);
  box-shadow: inset 0 0 0 1px rgba(240, 213, 149, .4), inset 0 0 40px rgba(0,0,0,.6);
}
.lens-cameo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; filter: sepia(.55) contrast(1.08) brightness(.92) saturate(.9); }
.no-gl .lens { display: none; }

/* ---------- nav ---------- */
.anav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 24px;
  padding: 18px clamp(18px, 3vw, 40px);
  background: linear-gradient(rgba(14, 9, 5, .72), rgba(14, 9, 5, 0));
}
.abrand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.monogram { width: 40px; height: 44px; overflow: visible; fill: none; transition: transform .7s var(--ease); }
.monogram .mg-outer { stroke: var(--gold); stroke-width: 1.3; }
.monogram .mg-inner { stroke: var(--gold); stroke-width: .6; opacity: .7; }
.monogram .mg-laurel { stroke: var(--gold); stroke-width: .9; stroke-linecap: round; }
.monogram text { font-family: var(--display); font-style: italic; fill: var(--ivory); }
.monogram .mg-r { font-size: 25px; }
.monogram .mg-j { font-size: 23px; fill: var(--gold-hi); }
.abrand:hover .monogram { transform: rotate(-6deg) scale(1.05); }
.abrand-text { display: flex; flex-direction: column; line-height: 1.05; }
.abrand-text span { font: 600 19px/1 var(--garamond); font-variant: small-caps; letter-spacing: .03em; }
.abrand-text em { font: italic 400 13px/1.2 var(--garamond); color: var(--muted); margin-top: 3px; }

.anav nav { margin-left: auto; }
.chapters { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.chapters a {
  position: relative; display: flex; align-items: baseline; gap: 7px; padding: 8px 12px; text-decoration: none;
  color: var(--muted); transition: color .3s;
}
.chapters .num { font: italic 500 17px/1 var(--garamond); color: var(--gold); opacity: .7; transition: opacity .3s; }
.chapters .lbl { font: 500 15px/1 var(--garamond); letter-spacing: .08em; font-variant: small-caps; }
.chapters a::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px; height: 1px; background: var(--gold);
  transform: scaleX(0); transform-origin: left; transition: transform .6s var(--ease);
}
.chapters a:hover, .chapters a.is-active { color: var(--ivory); }
.chapters a.is-active .num { opacity: 1; }
.chapters a.is-active::after { transform: scaleX(1); }

.art-toggle {
  display: inline-flex; align-items: center; gap: 9px; padding: 6px 7px 6px 14px; border-radius: 999px;
  border: 1px solid rgba(201, 164, 92, .45); background: rgba(20, 13, 8, .55); text-decoration: none; color: var(--ivory);
  font: italic 500 16px/1 var(--garamond); letter-spacing: .03em; backdrop-filter: blur(6px);
  transition: border-color .3s, transform .3s var(--ease);
}
.art-toggle:hover { border-color: var(--gold-hi); transform: translateY(-1px); }
.at-track { position: relative; width: 34px; height: 20px; border-radius: 999px; background: rgba(201, 164, 92, .35); border: 1px solid rgba(201, 164, 92, .6); }
.at-knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--gold-hi); transform: translateX(14px); transition: transform .5s var(--ease), background .4s; box-shadow: 0 0 12px rgba(240, 213, 149, .7); }
.art-toggle:hover .at-knob { transform: translateX(10px); }
.art-toggle.is-going .at-knob { transform: translateX(0); background: var(--muted); box-shadow: none; }

/* ---------- placard & rail ---------- */
.placard {
  position: fixed; right: clamp(40px, 4vw, 64px); bottom: 22px; z-index: 15; display: flex; gap: 14px; align-items: flex-start;
  max-width: 380px; padding: 12px 16px 12px 14px; border-left: 1px solid var(--gold);
  background: linear-gradient(90deg, rgba(16, 10, 6, .72), rgba(16, 10, 6, .2));
  transition: opacity .5s ease, transform .5s var(--ease);
}
.placard[data-side="left"] { right: auto; left: clamp(18px, 3vw, 40px); }
.placard.is-swapping { opacity: 0; transform: translateY(6px); }
.pl-num { font: italic 500 26px/1 var(--display); color: var(--gold); min-width: 26px; }
.pl-text { display: flex; flex-direction: column; gap: 3px; }
.pl-title { font: italic 400 16px/1.25 var(--garamond); color: var(--ivory); }
.pl-meta { font: 500 12.5px/1.2 var(--garamond); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.progress-rail { position: fixed; right: clamp(14px, 2vw, 28px); top: 50%; height: 34vh; width: 1px; transform: translateY(-50%); background: rgba(239, 230, 210, .18); z-index: 15; }
.progress-rail span { position: absolute; left: 0; top: 0; width: 1px; height: 100%; background: linear-gradient(var(--gold-hi), var(--gold)); transform-origin: top; transform: scaleY(var(--p, 0)); }

/* ---------- chapters ---------- */
main { position: relative; z-index: 5; overflow-x: clip; }
.chapter { position: relative; min-height: 100vh; padding: 0 clamp(20px, 6vw, 96px) 36vh; }
#prologue { padding-bottom: 46vh; }
#epilogue { padding-bottom: 0; }

.opening { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding-top: 80px; }
.overline { font: italic 400 20px/1.2 var(--garamond); color: var(--ivory-2); margin: 0 0 8px; letter-spacing: .02em; }
.sub { font: 500 15px/1.3 var(--garamond); letter-spacing: .22em; text-transform: uppercase; color: var(--gold); margin: 18px 0 0; }
.scroll-hint { display: flex; align-items: center; gap: 14px; margin-top: 12vh; font: italic 400 17px/1 var(--garamond); color: var(--muted); }
.scroll-hint i { display: block; width: 72px; height: 1px; background: var(--gold); transform-origin: left; animation: hint 2.6s var(--ease) infinite; }
@keyframes hint { 0% { transform: scaleX(0); } 60% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }

/* art-to-text: letters filled with the painting, drying into ink */
.paint-title {
  position: relative; display: inline-block; margin: 0; font: 400 clamp(64px, 10.5vw, 168px)/.9 var(--display);
  letter-spacing: -.02em; --ink: 0;
}
.paint-title.big { font-size: clamp(76px, 14vw, 230px); }
.pt-paint {
  display: block; color: transparent; background: var(--img) center 40% / cover no-repeat;
  -webkit-background-clip: text; background-clip: text;
  filter: saturate(1.35) contrast(1.15) brightness(1.3) drop-shadow(0 3px 18px rgba(6, 4, 2, .7));
  padding: .04em .06em .12em 0;
}
.pt-ink {
  position: absolute; inset: 0; color: var(--ivory); padding: .04em .06em .12em 0;
  -webkit-mask-image: linear-gradient(100deg, #000 calc(var(--ink) * 130% - 30%), transparent calc(var(--ink) * 130% - 4%));
  mask-image: linear-gradient(100deg, #000 calc(var(--ink) * 130% - 30%), transparent calc(var(--ink) * 130% - 4%));
  text-shadow: 0 2px 30px rgba(0,0,0,.35);
}
.no-gl .pt-ink, .reduced .pt-ink { -webkit-mask-image: none; mask-image: none; }

.ch-head { padding-top: 26vh; margin-bottom: 18vh; }
.ch-head.right { text-align: right; }
.ch-head.center { text-align: center; }
.numeral { font: italic 500 24px/1 var(--garamond); color: var(--gold); margin: 0 0 14px; letter-spacing: .04em; }
.numeral em { color: var(--ivory-2); }

.plate { position: relative; max-width: 540px; margin-bottom: 30vh; text-shadow: 0 1px 18px rgba(8, 5, 2, .8), 0 0 2px rgba(8, 5, 2, .6); }
.plate::before {
  content: ""; position: absolute; inset: -12% -18%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(12, 8, 4, .62), rgba(12, 8, 4, .3) 60%, transparent);
  filter: blur(10px);
}
.plate.right { margin-left: auto; }
.plate.center { margin-left: auto; margin-right: auto; text-align: center; max-width: 640px; margin-bottom: 14vh; }
.plate p { margin: 0 0 1em; color: var(--ivory-2); }
.plate strong { color: var(--ivory); font-weight: 500; }
.plate .lead { font: italic 400 clamp(25px, 2.3vw, 33px)/1.3 var(--garamond); color: var(--ivory); margin-bottom: 1.1em; }
.plate h3 { font: 400 clamp(30px, 2.6vw, 38px)/1.1 var(--display); margin: 1.5em 0 .25em; color: var(--ivory); }
.plate .lead + h3 { margin-top: .6em; }
.plate .when { font: 500 14px/1.4 var(--garamond); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin-bottom: .8em; }
.plate .aside { font-style: italic; font-size: 17px; color: var(--muted); border-left: 1px solid rgba(201,164,92,.5); padding-left: 14px; margin-top: 1.6em; }

/* blur-to-focus reveal for plates (restrained) */
.js .plate > * { opacity: 0; filter: blur(8px); transform: translateY(14px); transition: opacity 1.1s var(--ease), filter 1.1s var(--ease), transform 1.1s var(--ease); transition-delay: calc(var(--k, 0) * 90ms); }
.js .plate.is-in > * { opacity: 1; filter: none; transform: none; }

.route { list-style: none; margin: 1.6em 0 0; padding: 0; position: relative; }
.route::before { content: ""; position: absolute; left: 5px; top: 10px; bottom: 10px; width: 1px; background: linear-gradient(var(--gold), rgba(201,164,92,.1)); }
.route li { position: relative; display: flex; align-items: baseline; gap: 14px; padding: 8px 0 8px 28px; }
.route li::before { content: ""; position: absolute; left: 0; top: 18px; width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--gold); background: var(--umber); }
.route span { font: 400 30px/1 var(--display); color: var(--ivory); }
.route em { font: italic 400 17px/1 var(--garamond); color: var(--muted); }

.contact { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 14px; margin: 1.6em 0 2.2em; }
.contact a {
  position: relative; padding: 12px 22px; border: 1px solid rgba(201, 164, 92, .55); border-radius: 999px; text-decoration: none;
  font: 500 18px/1 var(--garamond); letter-spacing: .03em; color: var(--ivory); overflow: hidden; isolation: isolate;
  transition: color .4s, border-color .4s;
}
.contact a::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--gold); transform: translateY(101%); transition: transform .5s var(--ease); }
.contact a:hover { color: var(--umber); border-color: var(--gold); }
.contact a:hover::before { transform: none; }
.back-classic { font: italic 400 18px/1 var(--garamond); color: var(--muted); text-decoration: none; border-bottom: 1px solid rgba(201,164,92,.5); padding-bottom: 3px; }
.back-classic:hover { color: var(--gold-hi); }

.colophon { max-width: 760px; margin: 18vh auto 0; padding: 28px 0 120px; border-top: 1px solid rgba(201, 164, 92, .3); font-size: 15px; color: var(--muted); text-align: center; }
.colophon strong { color: var(--ivory-2); font-weight: 500; }

/* curtain for leaving / entering */
.curtain {
  position: fixed; inset: 0; z-index: 300; pointer-events: none; background: #f4efe6;
  clip-path: circle(0px at var(--cx, 90%) var(--cy, 4%)); transition: clip-path 1.05s cubic-bezier(.7,0,.2,1);
}
.curtain.is-on { clip-path: circle(150vmax at var(--cx, 90%) var(--cy, 4%)); }
.veil { position: fixed; inset: 0; z-index: 290; background: #120d08; pointer-events: none; transition: opacity 1.4s ease .2s; }
.veil.is-off { opacity: 0; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .chapters .lbl { display: none; }
  .chapters a { padding: 8px 8px; }
}
@media (max-width: 720px) {
  body { font-size: 18px; }
  .anav { gap: 10px; padding: 12px 14px; }
  .abrand-text em { display: none; }
  .abrand-text span { font-size: 17px; }
  .chapters { gap: 0; }
  .chapters a { padding: 8px 6px; }
  .chapters .num { font-size: 15px; }
  .at-label { display: none; }
  .art-toggle { padding-left: 7px; }
  .plate, .plate.right { max-width: none; margin-left: 0; }
  .ch-head.right { text-align: left; }
  .placard, .placard[data-side="left"] { max-width: 76vw; bottom: 10px; right: 12px; left: auto; padding: 6px 10px; }
  .pl-meta { font-size: 11px; }
  .pl-title { font-size: 14px; }
  .progress-rail { display: none; }
}
@media (max-width: 460px) {
  .abrand-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .lens-inscription, .lens-ticks, .scroll-hint i { animation: none; }
  .js .plate > * { opacity: 1; filter: none; transform: none; transition: none; }
  .curtain, .veil { transition: none; }
}
@media (max-width: 720px) {
  .anav nav { min-width: 0; }
  .chapters a { padding: 8px 5px; }
  .monogram { width: 34px; height: 38px; }
  .art-toggle { flex: none; }
}
