/* BRai Solutions: the motion layer.
   Adds movement on top of styles.css without changing the layout:
   1. Pages cross-fade into one another (View Transitions), the header stays put.
   2. A foil reading-progress rule along the top of the window.
   3. Photographs drift slowly as the page scrolls (parallax), driven by scroll, not timers.
   4. Hero: a brass picture light that follows the pointer, dust drifting in its beam,
      and the copy settling in on arrival.
   5. Text and panels below the fold rise into place as they come into view.
   6. Buttons: a foil sheen on hover and a gentle lift.
   Everything here is off under prefers-reduced-motion, and the footer's
   "Pause animation" switch (.ai-paused) stops the ambient parts. */

/* ---------- 1. Page transitions ---------- */
/* (9. lights up, 10. the desk, 11. plates, 12. the close, 13. the approval and
   14. the name on the spine are further down.) */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  .site-header { view-transition-name: site-header; }
  .site-footer { view-transition-name: site-footer; }
  /* The lights dip as you leave a room and rise in the next one (no blur, just light). */
  ::view-transition { background: #0b1120; }
  ::view-transition-old(root) { animation: vt-out .3s cubic-bezier(.4, 0, 1, 1) both; }
  ::view-transition-new(root) { animation: vt-in .55s cubic-bezier(.2, .8, .2, 1) .12s both; }
  ::view-transition-group(site-header), ::view-transition-group(site-footer) { animation-duration: .4s; }
  @keyframes vt-out { to { opacity: 0; } }
  @keyframes vt-in { from { opacity: 0; } }

  /* Straight to the desk: arriving at Contact, the page you were on lifts away like a
     sheet of paper and the request slip drops onto the desk underneath. */
  html:active-view-transition-type(desk)::view-transition-old(root) {
    z-index: 2; animation: desk-lift .6s cubic-bezier(.55, 0, .2, 1) both;
    filter: drop-shadow(0 30px 40px rgba(0, 0, 0, .55));
  }
  html:active-view-transition-type(desk)::view-transition-new(root) { animation: none; }
  @keyframes desk-lift { to { transform: translateY(-110vh); } }
}

/* ---------- 2. Reading progress ---------- */
.read-progress {
  position: fixed; inset: 0 0 auto 0; z-index: 60; height: 3px; pointer-events: none;
  background: linear-gradient(90deg, var(--teal) 0%, var(--teal-hi) 45%, var(--foil-hi) 80%, var(--foil) 100%);
  box-shadow: 0 0 12px rgba(44, 196, 183, .55);
  transform-origin: 0 50%; transform: scaleX(var(--p, 0));
  opacity: 0; transition: opacity .3s;
}
.read-progress.is-on { opacity: 1; }
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .read-progress { opacity: 1; animation: read-grow linear both; animation-timeline: scroll(root); }
    @keyframes read-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  }
}
@media (prefers-reduced-motion: reduce) { .read-progress { display: none; } }

/* ---------- 3. Parallax photographs ---------- */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    :root:not(.ai-paused) .hero::before,
    :root:not(.ai-paused) .page-hero::before,
    :root:not(.ai-paused) .contact-hero::before {
      animation: drift-down linear both;
      animation-timeline: view();
      animation-range: exit 0% exit 100%;
    }
    :root:not(.ai-paused) .closing::before,
    :root:not(.ai-paused) .people::before {
      animation: drift-through linear both;
      animation-timeline: view();
      animation-range: cover 0% cover 100%;
    }
    /* the drifting photograph stays inside its own section */
    :root:not(.ai-paused) :is(.hero, .page-hero, .contact-hero, .closing, .people) { overflow: clip; }
    /* the hero and closing photographs also breathe slowly (scale, separate from the drift) */
    :root:not(.ai-paused) .hero::before {
      animation: drift-down linear both, breathe 14s ease-in-out infinite alternate;
      animation-timeline: view(), auto;
      animation-range: exit 0% exit 100%, normal;
    }
    :root:not(.ai-paused) .closing::before {
      animation: drift-through linear both, breathe 14s ease-in-out infinite alternate;
      animation-timeline: view(), auto;
      animation-range: cover 0% cover 100%, normal;
    }
    @keyframes breathe { from { scale: 1; } to { scale: 1.08; } }
    @keyframes drift-down { from { transform: translate3d(0, 0, 0) scale(1.04); } to { transform: translate3d(0, 14%, 0) scale(1.1); } }
    @keyframes drift-through { from { transform: translate3d(0, -7%, 0) scale(1.16); } to { transform: translate3d(0, 7%, 0) scale(1.16); } }
  }
}

/* ---------- 4. Hero: the picture light ---------- */
.hero-light, .hero-dust { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.hero-light {
  opacity: 0; transition: opacity 1.2s ease;
  background:
    radial-gradient(640px 520px at var(--lx, 70%) var(--ly, 30%), rgba(246, 227, 166, .26), rgba(246, 227, 166, .10) 38%, transparent 68%),
    radial-gradient(900px 700px at var(--lx, 70%) var(--ly, 30%), rgba(44, 196, 183, .10), transparent 70%);
  mix-blend-mode: screen;
}
.hero-light.is-on { opacity: 1; }
.hero-dust { width: 100%; height: 100%; opacity: 0; transition: opacity 2s ease; }
.hero-dust.is-on { opacity: 1; }
.ai-paused .hero-light, .ai-paused .hero-dust { display: none; }

/* The bookcase leans toward the pointer, a little. */
.motion-tilt .case {
  transform: perspective(1400px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .9s cubic-bezier(.2, .8, .2, 1);
  will-change: transform;
}
.motion-tilt.is-reading .case { transform: none; }

/* Hero copy settles in on arrival (home, how it works, contact). */
@media (prefers-reduced-motion: no-preference) {
  .motion-on .hero-copy .lede,
  .motion-on .hero-copy .cta-stack,
  .motion-on .page-hero .lede,
  .motion-on .contact-hero .lede {
    animation: settle .9s cubic-bezier(.2, .8, .2, 1) both;
    animation-delay: .55s;
  }
  .motion-on .hero-copy .cta-stack { animation-delay: .75s; }
  .motion-on .hero .case { animation: case-in 1.2s cubic-bezier(.2, .8, .2, 1) .1s both; }
  @keyframes settle { from { opacity: 0; transform: translateY(18px); filter: blur(4px); } }
  @keyframes case-in { from { opacity: 0; translate: 0 26px; } }
}

/* ---------- 5. Reveal on scroll ---------- */
.motion-on .rv {
  opacity: 0; translate: 0 48px; filter: blur(8px);
  transition: opacity .9s cubic-bezier(.2, .8, .2, 1), translate 1s cubic-bezier(.2, .8, .2, 1), filter .9s ease;
  transition-delay: calc(var(--rv-i, 0) * 90ms + var(--rv-d, 0ms));
}
.motion-on .rv.rv-in { opacity: 1; translate: 0 0; filter: none; }
.motion-on .rv-left { translate: -80px 0; }
.motion-on .rv-right { translate: 80px 0; }
.motion-on .rv-left.rv-in, .motion-on .rv-right.rv-in { translate: 0 0; }
.motion-on .rv-scale { scale: .9; transition-property: opacity, translate, filter, scale; }
.motion-on .rv-scale.rv-in { scale: 1; }

/* Folio numerals on How it works swing in like a stamp. */
.motion-on .folio-no.rv { translate: 0 0; scale: 2.2; rotate: -14deg; transition-property: opacity, scale, rotate, filter; }
.motion-on .folio-no.rv.rv-in { scale: 1; rotate: 0deg; }

/* Bullets tick in one after another once their list is showing. */
.motion-on .rv-list > li { opacity: 0; translate: -10px 0; transition: opacity .5s ease, translate .6s cubic-bezier(.2, .8, .2, 1); }
.motion-on .rv-list.rv-in > li { opacity: 1; translate: 0 0; }
.motion-on .rv-list.rv-in > li:nth-child(1) { transition-delay: .25s; }
.motion-on .rv-list.rv-in > li:nth-child(2) { transition-delay: .37s; }
.motion-on .rv-list.rv-in > li:nth-child(3) { transition-delay: .49s; }
.motion-on .rv-list.rv-in > li:nth-child(4) { transition-delay: .61s; }
.motion-on .rv-list.rv-in > li:nth-child(n+5) { transition-delay: .73s; }

/* ---------- 6. Buttons ---------- */
.btn-hot, .nav-cta a { position: relative; overflow: hidden; isolation: isolate; }
@media (prefers-reduced-motion: no-preference) {
  .btn-hot, .nav-cta a {
    transition: transform .35s cubic-bezier(.2, .8, .2, 1), box-shadow .35s ease, background-color .25s ease;
  }
  .btn-hot::after, .nav-cta a::after {
    content: ""; position: absolute; top: -20%; bottom: -20%; left: -60%; width: 45%; z-index: 1; pointer-events: none;
    background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, .55) 50%, transparent 100%);
    transform: skewX(-18deg); opacity: 0;
  }
  @media (hover: hover) and (pointer: fine) {
    .btn-hot:hover { transform: translateY(-2px); background-color: var(--teal-hi); box-shadow: inset 0 0 0 3px var(--teal-hi), inset 0 0 0 4px rgba(255,255,255,.6), 0 18px 32px -14px rgba(0, 169, 157, .95); }
    .btn-hot:hover::after, .nav-cta a:hover::after { animation: btn-sheen .8s cubic-bezier(.4, 0, .2, 1); }
    .nav-cta a:hover { background-color: var(--teal-hi); }
  }
  .btn-hot:active { transform: translateY(1px); }
  @keyframes btn-sheen { 0% { left: -60%; opacity: 0; } 20% { opacity: 1; } 100% { left: 130%; opacity: 0; } }
}

@media (prefers-reduced-motion: reduce) {
  .motion-on .rv, .motion-on .rv-list > li { opacity: 1 !important; translate: none !important; filter: none !important; scale: none !important; rotate: none !important; transition: none !important; }
  .motion-tilt .case { transform: none !important; }
}

/* ---------- 7. Bolder ambience ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* Hero headline: each word rises out of the line. */
  .motion-on .hero-copy h1 .w { display: inline-block; overflow: clip; overflow-clip-margin: .2em; vertical-align: top; padding-bottom: .12em; margin-bottom: -.12em; }
  .motion-on .hero-copy h1 .w > i { display: inline-block; font-style: inherit; animation: word-up 1s cubic-bezier(.2, .9, .2, 1) both; animation-delay: calc(.15s + var(--wi) * 75ms); }
  @keyframes word-up { from { transform: translateY(110%) rotate(4deg); opacity: 0; } 60% { opacity: 1; } }

  /* The books drop onto their shelves one after another. */
  .motion-on .hero .shelf .spine:not(.spine-blank) { animation: spine-in .9s cubic-bezier(.3, 1.35, .5, 1) backwards; animation-delay: calc(.5s + var(--si, 0) * 70ms); }
  @keyframes spine-in { from { translate: 0 -70px; opacity: 0; } 55% { opacity: 1; } }


  /* The main button glows like a lit lamp. */
  .motion-on .hero-copy .btn-hot, .motion-on .closing .btn-hot { animation: lamp-glow 3.2s ease-in-out 1.6s infinite; }
  @keyframes lamp-glow {
    0%, 100% { box-shadow: inset 0 0 0 3px var(--teal), inset 0 0 0 4px rgba(255,255,255,.5), 0 0 0 0 rgba(44,196,183,0), 0 10px 24px -12px rgba(0,169,157,.8); }
    50% { box-shadow: inset 0 0 0 3px var(--teal), inset 0 0 0 4px rgba(255,255,255,.5), 0 0 0 10px rgba(44,196,183,.14), 0 14px 36px -8px rgba(0,169,157,.9); }
  }
  .ai-paused .hero-copy .btn-hot, .ai-paused .closing .btn-hot { animation: none; }

  /* A foil rule draws itself across the top of each light section. */
  .motion-on .catalogue, .motion-on .house-rules { position: relative; }
  .motion-on .catalogue::before, .motion-on .house-rules::before {
    content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; z-index: 3; pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--foil) 20%, var(--foil-hi) 50%, var(--foil) 80%, transparent);
    transform: scaleX(0); transition: transform 1.6s cubic-bezier(.65, 0, .35, 1);
  }
  .motion-on .catalogue.rule-in::before, .motion-on .house-rules.rule-in::before { transform: scaleX(1); }

  /* Each book lifts higher and glows when hovered. */
  @media (hover: hover) and (pointer: fine) {
    .motion-on .hero .spine { transition: transform .35s cubic-bezier(.2, .8, .2, 1), filter .35s ease; }
    .motion-on .hero .spine:hover { filter: brightness(1.18) drop-shadow(0 10px 18px rgba(44, 196, 183, .35)); }
  }
}

/* ---------- 8. The door: the home page opens on the library's front entrance ---------- */
/* You arrive standing back from it: the whole doorway, the sign over it, the wall and the
   floor in front. The bronze doors swing open and you walk through into the room, and on
   to the wall of shelves. The entrance is drawn here rather than filmed, so it is sharp on
   any screen and never cropped. motion.js builds it and sets --u (one hundredth of the
   scene's height) and --oy (where the scene starts). */
.door-wait body::before { content: ""; position: fixed; inset: 0; z-index: 199; background: #182036; }
.door-wait.door-built body::before { content: none; }
.door-wait, .door-wait body { overflow: hidden; }
/* The strip kept free for the scroll bar (styles.css) would show beside the entrance, so it
   is given up while the intro plays and the page is held at its usual width (--sbw is that
   strip's width, measured by motion.js). Nothing moves when the scroll bar comes back. */
.door-wide { scrollbar-gutter: auto; }
.door-wide body { margin-right: var(--sbw, 0px); }
.door-wait .hero * { animation-play-state: paused !important; }
.door-intro { position: fixed; inset: 0; z-index: 200; cursor: pointer; will-change: transform, opacity; overflow: hidden; background: #0b1120; --u: 1vh; --oy: 0px; }
/* The room sits on a stage (sized like object-fit: cover by motion.js) that the camera push moves. */
.door-stage { position: absolute; left: 0; top: 0; width: 100%; height: 100%; transform-origin: 0 0; will-change: transform; }
.door-room { position: absolute; inset: 0; will-change: transform; }
.door-still { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; display: block; }
/* The sharp shelves, laid exactly over the patch of the room picture they were made from. */
.door-near { position: absolute; left: 37.5%; top: 10.4167%; width: 56.25%; height: 66.6667%; max-width: none; opacity: 0; display: block; }
/* The entrance, over the whole screen: a stone wall (fine grain, panel joints, the lamps
   washing it up and down), the sign under its picture light, and the polished floor. */
.door-out { position: absolute; pointer-events: none; }
.door-cam { position: absolute; left: 0; top: 0; width: 100%; height: 100%; will-change: transform; }
.door-cam > * { position: absolute; }
.door-wall {
  inset: 0;
  background:
    radial-gradient(120% 95% at 50% 56%, rgba(3, 5, 10, 0) 38%, rgba(3, 5, 10, .62) 100%),
    url("img/grain.png?v=1") 0 0 / 128px 128px,
    radial-gradient(ellipse calc(15 * var(--u)) calc(9 * var(--u)) at 50% calc(var(--oy) + 17 * var(--u)), rgba(255, 228, 170, .13), rgba(255, 228, 170, 0) 100%),
    radial-gradient(ellipse calc(4.6 * var(--u)) calc(13 * var(--u)) at calc(50% - 24 * var(--u)) calc(var(--oy) + 46.5 * var(--u)), rgba(255, 214, 140, .2) 0, rgba(255, 214, 140, .06) 55%, rgba(255, 214, 140, 0) 100%),
    radial-gradient(ellipse calc(4.6 * var(--u)) calc(15 * var(--u)) at calc(50% - 24 * var(--u)) calc(var(--oy) + 61.5 * var(--u)), rgba(255, 214, 140, .2) 0, rgba(255, 214, 140, .06) 55%, rgba(255, 214, 140, 0) 100%),
    radial-gradient(circle at calc(50% - 24 * var(--u)) calc(var(--oy) + 53.5 * var(--u)), rgba(255, 214, 140, .16) 0, rgba(255, 214, 140, .05) calc(6 * var(--u)), rgba(255, 214, 140, 0) calc(15 * var(--u))),
    radial-gradient(ellipse calc(4.6 * var(--u)) calc(13 * var(--u)) at calc(50% + 24 * var(--u)) calc(var(--oy) + 46.5 * var(--u)), rgba(255, 214, 140, .2) 0, rgba(255, 214, 140, .06) 55%, rgba(255, 214, 140, 0) 100%),
    radial-gradient(ellipse calc(4.6 * var(--u)) calc(15 * var(--u)) at calc(50% + 24 * var(--u)) calc(var(--oy) + 61.5 * var(--u)), rgba(255, 214, 140, .2) 0, rgba(255, 214, 140, .06) 55%, rgba(255, 214, 140, 0) 100%),
    radial-gradient(circle at calc(50% + 24 * var(--u)) calc(var(--oy) + 53.5 * var(--u)), rgba(255, 214, 140, .16) 0, rgba(255, 214, 140, .05) calc(6 * var(--u)), rgba(255, 214, 140, 0) calc(15 * var(--u))),
    linear-gradient(90deg, rgba(4, 7, 14, 0) calc(50% - .07 * var(--u)), rgba(4, 7, 14, .6) calc(50% - .07 * var(--u)), rgba(4, 7, 14, .6) calc(50% + .07 * var(--u)), rgba(4, 7, 14, 0) calc(50% + .07 * var(--u))) 50% 0 / calc(30 * var(--u)) 100%,
    linear-gradient(180deg, rgba(4, 7, 14, .6) 0, rgba(4, 7, 14, .6) calc(.14 * var(--u)), rgba(255, 255, 255, .025) calc(.14 * var(--u)), rgba(255, 255, 255, 0) calc(.5 * var(--u))) 0 calc(var(--oy) + 12 * var(--u)) / 100% calc(22 * var(--u)),
    linear-gradient(90deg, rgba(255, 255, 255, 0) calc(50% - 15 * var(--u)), rgba(255, 255, 255, .04) calc(50% - 15 * var(--u)), rgba(255, 255, 255, .04) calc(50% + 15 * var(--u)), rgba(255, 255, 255, 0) calc(50% + 15 * var(--u))),
    linear-gradient(180deg, #131a2c 0%, #1c2640 58%, #182036 100%);
  -webkit-clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, calc(50% - 12.5 * var(--u)) calc(var(--oy) + 33 * var(--u)), calc(50% - 12.5 * var(--u)) calc(var(--oy) + 78 * var(--u)), calc(50% + 12.5 * var(--u)) calc(var(--oy) + 78 * var(--u)), calc(50% + 12.5 * var(--u)) calc(var(--oy) + 33 * var(--u)), calc(50% - 12.5 * var(--u)) calc(var(--oy) + 33 * var(--u)));
          clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, calc(50% - 12.5 * var(--u)) calc(var(--oy) + 33 * var(--u)), calc(50% - 12.5 * var(--u)) calc(var(--oy) + 78 * var(--u)), calc(50% + 12.5 * var(--u)) calc(var(--oy) + 78 * var(--u)), calc(50% + 12.5 * var(--u)) calc(var(--oy) + 33 * var(--u)), calc(50% - 12.5 * var(--u)) calc(var(--oy) + 33 * var(--u)));
}
/* the polished floor in front of the doors: it mirrors the lamps and the bronze, then the light from inside */
.door-floor {
  left: 0; right: 0; top: calc(var(--oy) + 78 * var(--u)); bottom: 0; overflow: hidden;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, .55) 0, rgba(0, 0, 0, 0) calc(1.6 * var(--u))),
    linear-gradient(180deg, rgba(255, 255, 255, .09) 0, rgba(255, 255, 255, 0) calc(.25 * var(--u))),
    url("img/grain.png?v=1") 0 0 / 128px 128px,
    radial-gradient(ellipse calc(3.4 * var(--u)) 90% at calc(50% - 24 * var(--u)) 0, rgba(255, 214, 140, .2), rgba(255, 214, 140, 0) 100%),
    radial-gradient(ellipse calc(3.4 * var(--u)) 90% at calc(50% + 24 * var(--u)) 0, rgba(255, 214, 140, .2), rgba(255, 214, 140, 0) 100%),
    radial-gradient(ellipse 70% 130% at 50% 0, rgba(60, 84, 140, .2), rgba(60, 84, 140, 0) 100%),
    linear-gradient(180deg, #0f1728 0%, #060911 100%);
}
.door-floor i { position: absolute; inset: 0; }
.door-glow { background: radial-gradient(ellipse calc(15 * var(--u)) 110% at 50% 0, rgba(200, 158, 96, .3), rgba(200, 158, 96, 0) 72%); }
.door-spill { opacity: 0; filter: blur(calc(1.1 * var(--u))); }
.door-spill::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(126, 168, 240, .5), rgba(126, 168, 240, .14) 70%, rgba(126, 168, 240, 0));
  -webkit-clip-path: polygon(calc(50% - 11.5 * var(--u)) 0, calc(50% + 11.5 * var(--u)) 0, calc(50% + 30 * var(--u)) 100%, calc(50% - 30 * var(--u)) 100%);
          clip-path: polygon(calc(50% - 11.5 * var(--u)) 0, calc(50% + 11.5 * var(--u)) 0, calc(50% + 30 * var(--u)) 100%, calc(50% - 30 * var(--u)) 100%);
}
.door-way { left: calc(50% - 12.5 * var(--u)); top: calc(var(--oy) + 33 * var(--u)); width: calc(25 * var(--u)); height: calc(45 * var(--u)); overflow: hidden; perspective: calc(70 * var(--u)); perspective-origin: 50% 55%; }
.door-leaf {
  position: absolute; top: 0; bottom: 0; width: 50%; will-change: transform; backface-visibility: hidden;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, .34) 0%, rgba(0, 0, 0, 0) 22%, rgba(0, 0, 0, 0) 66%, rgba(255, 205, 130, .16) 100%),
    repeating-linear-gradient(90deg, rgba(255, 236, 196, .05) 0, rgba(255, 236, 196, .05) 1px, rgba(0, 0, 0, .06) 1px, rgba(0, 0, 0, .06) 2px, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0) 4px),
    linear-gradient(90deg, #3b2d19 0%, #7c6138 20%, #92754a 46%, #735a33 74%, #46361e 100%);
  box-shadow: inset 0 0 0 calc(.16 * var(--u)) rgba(255, 224, 160, .22);
}
.door-leaf.l { left: 0; transform-origin: 0 50%; border-right: calc(.1 * var(--u)) solid #ffe6ae; }
.door-leaf.r { right: 0; transform-origin: 100% 50%; border-left: calc(.1 * var(--u)) solid #ffe6ae; }
/* each leaf has a tall recessed panel, like a cast bronze door */
.door-leaf::before {
  content: ""; position: absolute; left: calc(2.1 * var(--u)); right: calc(2.9 * var(--u)); top: calc(2.4 * var(--u)); bottom: calc(2.4 * var(--u));
  border: calc(.12 * var(--u)) solid rgba(255, 226, 166, .22);
  box-shadow: inset 0 0 calc(1.6 * var(--u)) rgba(0, 0, 0, .28), 0 0 0 calc(.12 * var(--u)) rgba(0, 0, 0, .25);
}
.door-leaf.l::before { left: calc(2.1 * var(--u)); right: calc(2.9 * var(--u)); }
.door-leaf.r::before { left: calc(2.9 * var(--u)); right: calc(2.1 * var(--u)); }
.door-leaf::after {
  content: ""; position: absolute; top: calc(13 * var(--u)); height: calc(18 * var(--u)); width: calc(.5 * var(--u)); border-radius: calc(.25 * var(--u));
  background: linear-gradient(90deg, #a8843f, #ffe9b0 45%, #c9a453);
  box-shadow: 0 0 calc(1 * var(--u)) rgba(255, 220, 150, .35), calc(.3 * var(--u)) 0 calc(.5 * var(--u)) rgba(0, 0, 0, .35);
}
.door-leaf.l::after { right: calc(1.5 * var(--u)); }
.door-leaf.r::after { left: calc(1.5 * var(--u)); }
.door-frame {
  left: calc(50% - 13.5 * var(--u)); top: calc(var(--oy) + 32 * var(--u)); width: calc(27 * var(--u)); height: calc(46 * var(--u)); box-sizing: border-box;
  border: calc(1 * var(--u)) solid #8f7140; border-bottom: 0; border-top-color: #a5854e;
  box-shadow: 0 0 0 calc(.14 * var(--u)) #4d3b1f, inset 0 0 0 calc(.14 * var(--u)) #e3c27c, 0 0 calc(5 * var(--u)) rgba(0, 0, 0, .55);
}
.door-sill { left: calc(50% - 14.5 * var(--u)); top: calc(var(--oy) + 77.7 * var(--u)); width: calc(29 * var(--u)); height: calc(.7 * var(--u)); background: linear-gradient(180deg, #c9a868, #6d5327); box-shadow: 0 calc(.3 * var(--u)) calc(1 * var(--u)) rgba(0, 0, 0, .6); }
.door-sign {
  left: calc(50% - 11 * var(--u)); top: calc(var(--oy) + 17 * var(--u)); width: calc(22 * var(--u)); height: calc(11.5 * var(--u)); box-sizing: border-box;
  display: grid; place-items: center; background: #14203a; border: calc(.38 * var(--u)) solid #b8934f;
  box-shadow: 0 0 0 calc(.12 * var(--u)) #5d4721, 0 calc(1.2 * var(--u)) calc(3 * var(--u)) rgba(0, 0, 0, .6), inset 0 0 calc(2 * var(--u)) rgba(0, 0, 0, .45);
}
.door-sign img { width: 76%; height: auto; display: block; }
.door-sign::before { content: ""; position: absolute; left: 50%; top: calc(-2.3 * var(--u)); width: calc(9 * var(--u)); height: calc(.55 * var(--u)); margin-left: calc(-4.5 * var(--u)); border-radius: calc(.3 * var(--u)); background: linear-gradient(180deg, #e9cf8f, #a8843f); box-shadow: 0 calc(.6 * var(--u)) calc(2.4 * var(--u)) rgba(255, 224, 160, .5); }
.door-sign::after { content: ""; position: absolute; inset: 0; background: radial-gradient(70% 100% at 50% -20%, rgba(255, 228, 170, .2), rgba(255, 228, 170, 0) 70%); }
.door-lamp {
  top: calc(var(--oy) + 50.2 * var(--u)); width: calc(2.4 * var(--u)); height: calc(6.6 * var(--u)); border-radius: calc(.45 * var(--u));
  background: linear-gradient(180deg, #fff3cc 0%, #efd086 55%, #c9a453 100%);
  box-shadow: 0 0 calc(2 * var(--u)) calc(.3 * var(--u)) rgba(255, 214, 140, .5), 0 0 calc(8 * var(--u)) calc(1 * var(--u)) rgba(255, 200, 120, .18);
}
.door-lamp.l { left: calc(50% - 25.2 * var(--u)); }
.door-lamp.r { left: calc(50% + 22.8 * var(--u)); }
/* The home page's own scrim (styles.css, .hero::before), gathered in as the camera arrives. */
.door-scrim { position: absolute; opacity: 0; pointer-events: none; }
.door-scrim {
  background:
    radial-gradient(48% 70% at 22% 50%, rgba(10,16,30,.86) 0%, rgba(10,16,30,.55) 55%, rgba(10,16,30,0) 85%),
    linear-gradient(180deg, rgba(10,16,30,.55) 0%, rgba(10,16,30,.18) 30%, rgba(10,16,30,.25) 65%, rgba(10,16,30,.85) 100%);
}
/* The edges of the frame darken while the camera is moving, and clear as it settles. */
.door-vignette { position: absolute; inset: 0; opacity: 0; pointer-events: none; background: radial-gradient(120% 95% at 62% 42%, transparent 52%, rgba(4, 8, 18, .62) 100%); }
.door-intro .door-skip { position: absolute; right: 20px; bottom: 18px; z-index: 2; font: italic 400 15px var(--display); color: var(--foil-hi); background: none; border: 0; opacity: .8; cursor: pointer; }
/* While the intro plays, the photograph holds still (its slow breathe starts on arrival) and
   the "lights up" bands stay away: the camera has already brought the room up to full light. */
.door-wait .hero::before { animation-play-state: paused !important; }
/* On the way to the bookcase the header slides back in over the room (motion.js). */
.door-wait .site-header { z-index: 202; }
.door-wait .lights-down, .door-arrive .lights-down { display: none !important; }
/* The walk in: the page's own bookcase stands in the wall of shelves and the camera goes
   straight in on it (motion.js), so the hero is lifted over the intro with all but the case hidden,
   and nothing in it can be clicked until we arrive. Its books are already on their shelves. */
.door-ride .hero { z-index: 201; visibility: hidden; background: transparent; pointer-events: none; }
.door-ride .hero .case { visibility: visible; will-change: transform, opacity; }
.door-arrive .hero .case, .door-arrive .hero .shelf .spine:not(.spine-blank) { animation: none; }
/* Near the end of the push the headline and text start to rise in over the room. */
.door-words .hero .hero-copy { visibility: visible; }
.door-wait.door-words .hero .hero-copy * { animation-play-state: running !important; }
/* (the underline under "finance" waits for them, then draws as it always has) */
.door-wait:not(.door-words) .hero .mark.in svg { clip-path: inset(-60% 100% -60% 0) !important; transition: none !important; }
/* Landing: the hero stays over the intro while its photograph comes up behind the bookcase. */
.door-settle .hero { z-index: 201; background: transparent; }

/* ---------- 9. Lights up: you arrive after hours and the room's lights come up ---------- */
/* Three bands of darkness over the home page room lift one after another: the bookcase
   side first (with a flicker, like a real light catching), the middle, then the desk.
   Pure CSS, so it runs from the first frame. While the front door film plays it waits. */
.lights-down { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .ai-motion .lights-down { display: block; position: absolute; inset: 0; z-index: 1; pointer-events: none; }
  .ai-motion .hero-copy { position: relative; z-index: 2; }
  .ai-motion .lights-down i { position: absolute; top: 0; bottom: 0; background: #050a16; opacity: .8; animation: lights-band .45s ease-out forwards; }
  .ai-motion .lights-down i:nth-child(1) { left: 0; width: 36%; animation-delay: .85s; animation-duration: .5s; }
  .ai-motion .lights-down i:nth-child(2) { left: 36%; width: 20%; animation-delay: .6s; }
  .ai-motion .lights-down i:nth-child(3) { left: 56%; right: 0; animation-name: lights-flicker; animation-duration: .6s; animation-delay: .3s; }
  @keyframes lights-band { to { opacity: 0; } }
  @keyframes lights-flicker { 0% { opacity: .8; } 25% { opacity: .25; } 40% { opacity: .6; } 100% { opacity: 0; } }
  @media (max-width: 759px), (max-aspect-ratio: 1/1) {
    /* stacked layout on phones: the bands lift top to bottom instead */
    .ai-motion .lights-down i:nth-child(1) { left: 0; right: 0; width: auto; top: 0; bottom: 60%; }
    .ai-motion .lights-down i:nth-child(2) { left: 0; right: 0; width: auto; top: 40%; bottom: 35%; }
    .ai-motion .lights-down i:nth-child(3) { left: 0; right: 0; top: 65%; bottom: 0; }
  }
}
.ai-paused .lights-down { display: none !important; }

/* ---------- 10. The desk: the request slip drops onto it ---------- */
@media (prefers-reduced-motion: no-preference) {
  .ai-motion .contact-page .slip { animation: slip-drop .7s cubic-bezier(.2, .8, .2, 1) .45s both; }
  .ai-motion .contact-page .next-steps > li { animation: step-in .45s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(1.05s + var(--n, 0) * 140ms); }
  .ai-motion .contact-page .next-steps > li:nth-child(2) { --n: 1; }
  .ai-motion .contact-page .next-steps > li:nth-child(3) { --n: 2; }
  @keyframes slip-drop { 0% { opacity: 0; translate: 0 -80px; rotate: 2.4deg; } 70% { opacity: 1; translate: 0 5px; rotate: -.2deg; } 100% { translate: 0 0; rotate: 0deg; } }
  @keyframes step-in { from { opacity: 0; translate: 18px 0; } }
}

/* ---------- 11. Plates that play (motion.js animates the plate once a volume is open) ---------- */
.plate svg .pl-draw { stroke-dasharray: var(--len) var(--len); }

/* ---------- 12. The close gets shorter (home, foot of "Why a library?") ---------- */
.close-plate { margin: 72px 0 0; padding: 28px 22px 22px; background: #fbfaf5; border: 1px solid rgba(45, 68, 113, .2); box-shadow: inset 0 0 0 5px #fbfaf5, inset 0 0 0 6px rgba(45, 68, 113, .12); color: var(--ink); }
@media (min-width: 760px) { .close-plate { padding: 40px 44px 30px; margin-top: 96px; } }
.close-kick { margin: 0 0 6px; font: 700 12px var(--sans); letter-spacing: .16em; text-transform: uppercase; color: #00877d; }
.close-title { margin: 0 0 30px; font: 400 clamp(1.6rem, 4.4vw, 2.5rem)/1.1 var(--display); letter-spacing: -.015em; color: var(--ink); }
.close-chart { --lab: 0px; --night: 0px; display: grid; gap: 18px; }
.close-axis, .close-row { display: grid; grid-template-columns: var(--lab) var(--night) minmax(0, 1fr); column-gap: 16px; align-items: start; }
.close-axis > :nth-child(1), .close-axis > :nth-child(2) { min-width: 0; }
.close-axis-label { grid-column: 3; display: block; font: 500 11.5px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: #8a93a6; margin-bottom: 4px; }
.close-days { grid-column: 3; display: grid; grid-template-columns: repeat(10, 1fr); margin: 0; padding: 0; list-style: none; font: 400 16px var(--display); color: var(--muted); text-align: center; }
.close-lab { grid-column: 1 / -1; margin: 0; font: italic 400 20px/1.2 var(--display); color: var(--ink); }
.close-lab small { display: block; margin-top: 3px; font: 400 14px var(--sans); font-style: normal; color: var(--muted); }
.close-night { grid-column: 1 / -1; }
.close-before .close-night { display: none; }
.close-track { grid-column: 1 / -1; position: relative; height: 54px; margin-top: 12px;
  background: repeating-linear-gradient(90deg, #e3e4db 0 1px, transparent 1px 10%); }
.close-seg { position: absolute; top: 0; height: 54px; left: calc(var(--s) * 10%); width: calc(var(--n) * 10% - 4px);
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 4px; overflow: hidden;
  border-radius: 3px; background: #d8dbd2; color: var(--ink); font: 500 12.5px/1.15 var(--sans); }
.close-seg.is-rev { background: var(--navy); color: #f4f5f0; }
.close-flag { position: absolute; top: -18px; height: 88px; width: 2px; left: calc(var(--s) * 10% - 2px); background: #6e2a30; }
.close-flag > span { position: absolute; right: 6px; top: -2px; white-space: nowrap; font: italic 400 15px var(--display); color: #f4f5f0; background: #6e2a30; padding: 2px 9px; }
.close-flag .ft-before { display: none; }
.close-gain { position: absolute; top: 0; height: 54px; left: calc(var(--s) * 10% + 4px); width: calc(var(--n) * 10% - 8px); display: grid; place-items: center; text-align: center; padding: 0 8px;
  border-radius: 3px; border: 1px solid rgba(0, 169, 157, .35); color: #00877d; font: italic 400 clamp(14px, 2vw, 21px)/1.15 var(--display);
  background: repeating-linear-gradient(135deg, rgba(0, 169, 157, .10) 0 10px, rgba(0, 169, 157, .04) 10px 20px); }
.close-night { border: 1px dashed #9fb3b0; border-radius: 4px; padding: 8px 10px; }
.close-night h4 { margin: 0 0 6px; font: 700 11px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: #00877d; }
.close-night ul { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 5px; }
.close-night li { display: flex; gap: 8px; justify-content: space-between; padding: 2px 8px; border-radius: 2px; background: var(--teal); color: #05221f; font: 500 12px var(--sans); }
.close-after .close-seg.is-prep { opacity: 0; }
.close-plate figcaption { margin-top: 26px; font: italic 400 15px var(--display); color: var(--muted); }
.close-plate figcaption b { font-style: normal; }
/* phones: day labels only on the long bars */
@media (max-width: 759px) {
  .close-seg:not(.is-rev) { font-size: 0; }
  .close-flag > span { font-size: 13px; }
  .close-after .close-flag > span { right: auto; left: 6px; }
}
@media (min-width: 900px) {
  .close-chart { --lab: 170px; --night: 150px; gap: 26px; }
  .close-lab { grid-column: 1; }
  .close-night { grid-column: 2; }
  .close-before .close-night { display: block; visibility: hidden; }
  .close-track { grid-column: 3; margin-top: 0; }
  .close-night ul { display: block; }
  .close-night li { margin-bottom: 5px; }
  .close-row { min-height: 70px; }
}
/* Before it plays (set by moments.js only when motion is on): the lower row starts as the top one does. */
.close-chart.is-before .close-seg.is-prep { opacity: 1; translate: 0 0; scale: 1; }
.close-chart.is-before .close-move { --s: 6 !important; }
.close-chart.is-before .close-flag.close-move { --s: 9 !important; }
.close-chart.is-before .close-flag .ft-before { display: inline; }
.close-chart.is-before .close-flag .ft-after { display: none; }
.close-chart.is-before .close-gain, .close-chart.is-before .close-night li { opacity: 0; }
.close-chart.is-before .close-night { border-color: transparent; }
.close-chart.is-before .close-night h4 { opacity: 0; }
@media (prefers-reduced-motion: no-preference) {
  .close-chart.is-playing .close-seg.is-prep { transition: opacity .6s ease, translate .7s cubic-bezier(.65, 0, .25, 1), scale .7s ease; transition-delay: calc(.4s + var(--i) * 130ms); translate: -60px 0; scale: .8; }
  .close-chart.is-playing .close-night, .close-chart.is-playing .close-night h4 { transition: border-color .4s ease .5s, opacity .4s ease .5s; }
  .close-chart.is-playing .close-night li { transition: opacity .35s ease, translate .35s cubic-bezier(.2, .8, .2, 1); transition-delay: calc(.95s + var(--i) * 130ms); }
  .close-chart.is-playing .close-seg.close-move { transition: left 1.1s cubic-bezier(.65, 0, .25, 1) 1.8s; }
  .close-chart.is-playing .close-flag.close-move { transition: left 1.1s cubic-bezier(.65, 0, .25, 1) 1.95s; }
  .close-chart.is-playing .close-gain { transition: opacity .7s ease-out 3.2s; }
  .close-chart.is-before .close-night li { translate: -8px 0; }
}

/* ---------- 13. The approval that waits (About, "Our standards") ---------- */
.approval { position: relative; margin-top: 30px; padding: 18px 22px 18px; background: #fdfcf7; border: 1px solid #d3d7cd; box-shadow: 0 18px 40px -24px rgba(27, 40, 68, .45); color: var(--ink); }
.approval-hd { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-bottom: 9px; border-bottom: 2px solid var(--navy); font: 700 11.5px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--navy); }
.approval-hd span:last-child { font: italic 400 14px var(--display); letter-spacing: 0; text-transform: none; color: var(--muted); }
.approval-log { margin: 0; padding: 0; list-style: none; }
.approval-log li { display: grid; grid-template-columns: 96px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid #e3e4db; font: 400 16px/1.4 var(--sans); }
.approval-log time { font: 500 14px var(--sans); color: #00877d; font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 1px; }
.approval-log li[hidden] { display: none; }
.approval-wait { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.approval-wait[hidden] { display: none; }
.approval-wait p { margin: 0 6px 0 0; font: italic 400 18px var(--display); }
.approval-wait p b { font-style: normal; color: #00877d; }
.approval-wait button { font: 500 15px var(--sans); padding: 9px 18px; border-radius: 2px; cursor: pointer; border: 2px solid var(--teal); }
.approval-yes { background: var(--teal); color: #05221f; }
.approval-hold { background: transparent; color: var(--ink); border-color: var(--navy) !important; }
.approval-wait button:focus-visible { outline: 3px solid var(--foil); outline-offset: 2px; }
.approval-stamp { display: none; width: max-content; margin: 16px 0 0 auto; padding: 4px 14px; border: 3px double #00877d; color: #00877d; font: italic 400 28px var(--display); transform: rotate(-9deg); opacity: 0; pointer-events: none; mix-blend-mode: multiply; }
.approval-stamp.is-held { border-color: #6e2a30; color: #6e2a30; }
.approval-stamp.is-on { display: block; opacity: .9; }
.approval-note { margin: 12px 0 0; font: italic 400 14px var(--display); color: var(--muted); }
.rule-tick { display: inline-block; margin-left: 10px; color: var(--teal); font: 700 18px var(--sans); }
@media (prefers-reduced-motion: no-preference) {
  .approval-log li.is-new { animation: ln-in .45s cubic-bezier(.2, .8, .2, 1) both; }
  @keyframes ln-in { from { opacity: 0; translate: -10px 0; } }
  .approval-wait:not([hidden]) { animation: fade-up .4s ease both; }
  @keyframes fade-up { from { opacity: 0; translate: 0 6px; } }
  .approval-stamp.is-on { animation: stamp-in .38s cubic-bezier(.3, 0, .4, 1) .45s both; }
  @keyframes stamp-in { 0% { opacity: 0; scale: 1.8; } 70% { opacity: .95; scale: .96; } 100% { opacity: .9; scale: 1; } }
  .rule-tick { animation: tick-in .4s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: var(--d, .7s); }
  @keyframes tick-in { from { opacity: 0; scale: .4; } }
}

/* ---------- 14. Your name on the spine (Contact, the request slip) ---------- */
.slip-volume { display: flex; align-items: center; gap: 14px; margin: 0 0 20px; }
.sv-book { position: relative; flex: 1 1 auto; min-width: 0; height: 54px; border-radius: 3px; overflow: hidden; background-color: var(--sv, #56657d);
  background-image: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,0) 35%, rgba(0,0,0,.25)), repeating-linear-gradient(90deg, rgba(255,255,255,.035) 0 1px, transparent 1px 3px);
  box-shadow: 0 12px 22px -12px rgba(0,0,0,.75); transition: background-color .6s ease; }
.sv-book::before, .sv-book::after { content: ""; position: absolute; top: 0; bottom: 0; width: 4px; border-left: 2px solid var(--foil); border-right: 2px solid var(--foil); }
.sv-book::before { left: 22px; } .sv-book::after { right: 22px; }
.sv-name { position: absolute; left: 44px; right: 78px; top: 0; bottom: 0; display: flex; align-items: center; justify-content: center; white-space: nowrap; overflow: hidden;
  font: 400 clamp(17px, 2.4vw, 24px) var(--display); letter-spacing: .04em; color: var(--foil-hi); text-shadow: 0 1px 0 rgba(0,0,0,.45); }
.sv-name .sv-ph { font-style: italic; color: rgba(244,245,240,.55); text-shadow: none; }
.sv-name i { display: inline-block; font-style: normal; white-space: pre; }
.sv-no { position: absolute; right: 36px; top: 0; bottom: 0; display: flex; align-items: center; font: 400 15px var(--display); color: var(--foil-hi); }
.sv-glint { position: absolute; top: 0; bottom: 0; left: -120px; width: 90px; background: linear-gradient(100deg, rgba(255,255,255,0), rgba(255,246,214,.38), rgba(255,255,255,0)); }
.sv-tag { flex: 0 0 auto; position: relative; margin: 0; max-width: 150px; padding: 7px 10px 8px 24px; background: #f6f1dc; color: var(--navy); transform: rotate(5deg); transform-origin: 0 0; box-shadow: 0 8px 16px -8px rgba(0,0,0,.6); font: italic 400 17px/1.15 var(--display); }
.sv-tag::before { content: ""; position: absolute; left: 8px; top: 13px; width: 7px; height: 7px; border-radius: 50%; border: 2px solid var(--foil-lo); }
.sv-tag small { display: block; margin-top: 2px; font: 400 12.5px/1.25 var(--sans); font-style: normal; color: var(--muted); overflow-wrap: anywhere; }
@media (max-width: 479px) { .sv-tag { display: none; } }
