/* ==========================================================================
   CHROME — global pieces that sit on top of base.css and are driven by main.js:
   loader staging + curtain, cursor refinements, rail details, reader motion,
   sticky CTA visibility, reveal helpers, scrollbar.
   ========================================================================== */

/* ---- page-level niceties ------------------------------------------------ */
html { scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: rgba(22, 22, 22, .35) transparent; }
/* bleeding art must never widen the mobile layout viewport (it would push the fixed bar's button off-screen):
   clipping on <html> too makes body's own overflow-x: clip effective instead of being propagated away */
html { overflow-x: clip; }
html.is-locked { overscroll-behavior: none; }

/* ---- loader ------------------------------------------------------------- */
.loader { overflow: hidden; }
/* with JS + GSAP the flat ink background is swapped for an SVG curtain whose lower edge can bow */
.loader__curtain { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
.loader__curtain path { fill: var(--ink); }
html.is-anim .loader { background: transparent; }
html.is-anim .loader__curtain { display: block; }

.loader__inner { position: relative; z-index: 1; gap: 0; }
.loader .loader__mark { width: clamp(132px, 15vw, 184px); height: auto; border-radius: 50%; box-shadow: 0 0 0 1px rgba(185, 138, 62, .35); }   /* the studio's black-and-gold disc; the faint ring lifts it off the night */
.loader__meter { position: relative; width: clamp(84px, 9vw, 112px); height: 1px; margin-top: 2.1rem; background: rgba(242, 238, 231, .16); overflow: hidden; }
.loader__meter-fill { position: absolute; inset: 0; background: var(--ochre); transform: scaleX(0); transform-origin: 0 50%; }
.loader__count { margin-top: .85rem; min-width: 3ch; text-align: center; font-size: 1.22rem; color: var(--paper-80); }

.loader__jp {
  position: absolute; z-index: 1; right: clamp(1.25rem, 4.2vw, 5rem); top: 50%; transform: translateY(-50%);
  font-size: clamp(.95rem, 1.2vw, 1.15rem); color: var(--paper-40);
}
.loader__foot {
  position: absolute; z-index: 1; left: 0; right: 0; bottom: calc(clamp(1.4rem, 4vh, 2.6rem) + env(safe-area-inset-bottom, 0px));
  display: flex; justify-content: center; align-items: center; gap: 1.1em; color: var(--paper-40); font-size: .58rem;
}
.loader__foot i { display: block; width: 2.2rem; height: 1px; background: currentColor; opacity: .7; }
/* everything inside the loader is staged by JS; keep it quiet until then */
html.is-anim .loader__jp, html.is-anim .loader__foot, html.is-anim .loader__count, html.is-anim .loader__meter { opacity: 0; }

/* ---- custom cursor ------------------------------------------------------ */
/* the native cursor steps aside once a real mouse has moved (form fields keep theirs) */
html.has-cursor *, html.has-cursor *::before, html.has-cursor *::after { cursor: none !important; }
html.has-cursor :is(input, textarea, select, [contenteditable="true"]) { cursor: auto !important; }
.cursor__dot, .cursor__ring { will-change: transform; }
.cursor__ring { line-height: 1; text-align: center; white-space: nowrap; }
.cursor__dot { transition: opacity .3s ease, scale .45s var(--ease-out), background-color .4s ease; }
.cursor__ring { transition: width .5s var(--ease-out), height .5s var(--ease-out), margin .5s var(--ease-out), background-color .45s var(--ease-out), border-color .45s var(--ease-out), color .3s ease, scale .45s var(--ease-out), opacity .3s ease; }
html[data-cursor-theme="dark"] .cursor__dot { background: var(--ochre); }
html[data-cursor-theme="dark"][data-cursor="link"] .cursor__ring { border-color: var(--ochre); }
html[data-cursor="link"] .cursor__dot { scale: .6; }
html[data-cursor="field"] .cursor__dot, html[data-cursor="field"] .cursor__ring { opacity: 0; }
html.cursor-down .cursor__ring { scale: .82; }
html.cursor-out .cursor { opacity: 0; }

/* ---- rail details ------------------------------------------------------- */
@media (min-width: 1200px) {
  .rail__spark { height: 24px; will-change: transform; }
  .rail__seal { font-size: .92rem; }
  .rail__thread-fill, .rail__bead { will-change: transform; }
  .rail__bead { transition: background-color var(--dur-2) ease, box-shadow var(--dur-2) ease; }
  .rail__caption span { display: block; }
}
@media (min-width: 1200px) and (max-height: 640px) {
  .rail__jp { font-size: .95rem; }
  .rail__caption { display: none; }
}

/* ---- reveal helpers ----------------------------------------------------- */
/* line masks: room for Bodoni descenders + italic overhang without shifting layout */
.split-line-mask { padding: .12em .14em .24em; margin: -.12em -.14em -.24em; }
.split-line { will-change: transform; }

/* ---- reader dialog motion (works with or without GSAP) -------------------- */
.reader::backdrop { opacity: 0; transition: opacity .6s ease; }
.reader.is-open::backdrop { opacity: 1; }
.reader__panel { transform: translate3d(104%, 0, 0); transition: transform .95s var(--ease-out); will-change: transform; }
.reader.is-open .reader__panel { transform: translate3d(0, 0, 0); }
.reader.is-closing .reader__panel { transition: transform .6s var(--ease-in-out); }
.reader.is-closing::backdrop { transition-duration: .5s; }
.reader__close { z-index: 2; }
/* the dialog sits in the top layer, above the global grain: give its sheet the same paper tooth */
.reader__panel { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='320'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .3 0 0 0 0 .22 0 0 0 .13 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
/* sections focused programmatically after an anchor jump should not flash a focus ring */
main section[tabindex="-1"]:focus, footer[tabindex="-1"]:focus, [id][tabindex="-1"]:focus:not(:focus-visible) { outline: none; }

/* ---- sticky CTA: out of the tab order while parked off-screen ------------- */
@media (max-width: 767px) {
  .sticky-cta { visibility: hidden; transition: transform .6s var(--ease-out), visibility 0s linear .6s; }
  .sticky-cta.is-visible { visibility: visible; transition: transform .6s var(--ease-out), visibility 0s; }
}

/* ---- reduced motion ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .reader__panel { transform: none; }
}
