/* ============================================================
   OPAL STORY (v2, 22 Nov 2026) · css/opal-story.css
   Everything is scoped to .opal-story and prefixed os-, so nothing
   here touches the rest of the site.
   Two states:
     default   → a plain, readable section (no JS, no WebGL 2, or the
                 3D failed to load). Opal picture, then all chapters.
     .is-live  → set by js/opal-story-scene.js once the 3D is built: a
                 tall scroll track with a pinned 3D stage. (Reduced
                 motion and Save-Data do not keep it static: the 3D
                 always starts, see docs/OPAL-DESIGN.md.)
   ============================================================ */

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/cormorant-garamond-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/cormorant-garamond-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

.opal-story {
  --os-ink: #030405;
  --os-panel: rgba(8, 11, 13, 0.84);
  --os-rule: rgba(214, 236, 240, 0.09);
  --os-rule-2: rgba(214, 236, 240, 0.16);
  --os-text: var(--text-1, #e8eef0);
  --os-text-2: var(--text-2, #a3b3b8);
  --os-text-3: var(--text-3, #6f8188);
  --os-cyan: var(--accent-light, #3dd4e8);
  --os-serif: 'Cormorant Garamond', 'Cormorant', Garamond, 'Times New Roman', serif;
  /* Lining figures: Cormorant's own old-style 1 reads as a dotless i, so "Licensing 1" printed as "Licensing ı". */
  font-variant-numeric: lining-nums;
  --os-sans: var(--font-body, 'IBM Plex Sans', system-ui, sans-serif);
  --os-mono-f: var(--font-mono, 'IBM Plex Mono', ui-monospace, monospace);
  --os-gl: max(var(--gutter, 20px), env(safe-area-inset-left, 0px));
  --os-gr: max(var(--gutter, 20px), env(safe-area-inset-right, 0px));

  position: relative;
  background: var(--os-ink);
  color: var(--os-text);
  font-family: var(--os-sans);
  font-weight: 300;
  font-size: 15px;
  line-height: 1.65;
}
.opal-story *, .opal-story *::before, .opal-story *::after { box-sizing: border-box; }
.opal-story h2, .opal-story h3 { margin: 0; font-family: var(--os-serif); font-weight: 300; letter-spacing: -0.005em; line-height: 1.02; text-wrap: balance; color: var(--os-text); }
.opal-story h2 em, .opal-story h3 em { font-style: italic; font-weight: 300; }
.opal-story p { margin: 0; }
.opal-story a { color: inherit; text-decoration: none; }
.opal-story :focus-visible { outline: 1px solid var(--os-cyan); outline-offset: 3px; }
.opal-story .os-mono { font-family: var(--os-mono-f); font-weight: 400; font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; }

/* ---------- shared pieces (both states) ---------- */
.opal-story .os-eyebrow { color: var(--os-text-3); display: flex; gap: .9rem; align-items: center; }
.opal-story .os-eyebrow b { color: var(--os-cyan); font-weight: 400; }
.opal-story .os-panel h2 { font-size: clamp(3rem, 2rem + 3.6vw, 5.6rem); }
.opal-story .os-panel h3 { font-size: clamp(2.3rem, 1.6rem + 2.4vw, 4rem); }
.opal-story .os-lede { color: var(--os-text-2); max-width: 36ch; }
.opal-story .os-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.opal-story .os-chips span { border: 1px solid var(--os-rule-2); padding: 6px 10px; color: var(--os-text-2); font-size: 9.5px; }
.opal-story .os-parts, .opal-story .os-steps { list-style: none; margin: .4rem 0 0; padding: 0; border-top: 1px solid var(--os-rule); }
.opal-story .os-parts li { display: grid; grid-template-columns: 2.6rem minmax(0,1fr) auto; align-items: baseline; gap: .4rem; padding: .85rem 0; border-bottom: 1px solid var(--os-rule); }
.opal-story .os-n { color: var(--os-text-3); }
.opal-story .os-parts strong { display: block; font-weight: 400; font-size: 15px; }
.opal-story .os-parts em { display: block; font-family: var(--os-serif); font-size: 15px; color: var(--os-text-3); }
.opal-story .os-st { color: var(--os-cyan); font-size: 9px; }
.opal-story .os-st--soon { color: var(--os-text-3); }   /* not open yet */
/* No backdrop blur here: blurring what sits behind a panel over the moving canvas makes the browser redo it every frame. */
.opal-story .os-sheet { border: 1px solid var(--os-rule); background: var(--os-panel); }
.opal-story .os-sheet dl { margin: 0; display: grid; }
.opal-story .os-sheet div { display: grid; grid-template-columns: 9.5rem minmax(0,1fr); gap: 1rem; padding: .7rem 1rem; border-bottom: 1px solid var(--os-rule); }
.opal-story .os-sheet div:last-child { border-bottom: 0; }
.opal-story .os-sheet dt { color: var(--os-text-3); }
.opal-story .os-sheet dd { margin: 0; min-width: 0; font-family: var(--os-mono-f); font-size: 12px; letter-spacing: .02em; text-align: right; overflow-wrap: anywhere; }   /* a long site address wraps on a phone instead of widening the page */
.opal-story .os-steps li { display: grid; grid-template-columns: 2.6rem minmax(0,1fr); gap: .4rem; padding: .8rem 0; border-bottom: 1px solid var(--os-rule); color: var(--os-text-2); }
.opal-story .os-steps .os-n { color: var(--os-cyan); padding-top: .2rem; }
.opal-story .os-steps strong { font-weight: 400; color: var(--os-text); }
.opal-story .os-tech-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--os-rule-2); }
.opal-story .os-tech-col { padding: 1rem 1.5rem 0 0; min-width: 0; }
.opal-story .os-tech-col + .os-tech-col { padding-left: 1.5rem; border-left: 1px solid var(--os-rule); }
.opal-story .os-tech-col h4 { margin: 0 0 .6rem; font-family: var(--os-mono-f); font-weight: 400; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--os-cyan); }
.opal-story .os-row { display: flex; justify-content: space-between; gap: 1rem; padding: .62rem 0; border-bottom: 1px solid var(--os-rule); }
.opal-story .os-row span:first-child { color: var(--os-text-3); font-size: 13px; }
.opal-story .os-row span:last-child { font-family: var(--os-mono-f); font-size: 12px; text-align: right; }
.opal-story .os-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.opal-story .os-pill { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border: 1px solid var(--os-rule-2); border-radius: 2px; color: var(--os-text-2); white-space: nowrap; transition: color .3s, border-color .3s; }
.opal-story .os-pill:hover { color: var(--os-text); border-color: rgba(214,236,240,.35); }
.opal-story .os-pill--solid { color: var(--os-text); border-color: rgba(214,236,240,.45); }

/* ---------- default (static) state ---------- */
.opal-story:not(.is-live) { padding-block: var(--section, 7rem); padding-left: var(--os-gl); padding-right: var(--os-gr); }
.opal-story:not(.is-live) .os-stage { max-width: 73.75rem; margin: 0 auto; display: grid; gap: 4rem; }
.opal-story:not(.is-live) .os-gl,
.opal-story:not(.is-live) .os-fx,
.opal-story:not(.is-live) .os-overlay,
.opal-story:not(.is-live) .os-tag,
.opal-story:not(.is-live) .os-where,
.opal-story:not(.is-live) .os-rail,
.opal-story:not(.is-live) .os-caption,
.opal-story:not(.is-live) .os-loader,
.opal-story:not(.is-live) .os-hint { display: none; }
.opal-story:not(.is-live) .os-fallback { display: block; width: fit-content; margin-inline: auto; }
.opal-story:not(.is-live) .os-fallback img { display: block; width: min(340px, 60vw); height: auto; }
.opal-story:not(.is-live) .os-copy { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: 4rem 3rem; }
.opal-story:not(.is-live) .os-panel { display: grid; gap: 1.1rem; align-content: start; }
.opal-story:not(.is-live) .os-tech { gap: 1.6rem; }

/* ---------- live state: pinned 3D stage ---------- */
/* Links to the story land with the stage flush to the top, not below the page's usual scroll padding */
.opal-story { scroll-margin-top: -6rem; }
.opal-story.is-live { height: 900vh; }
.opal-story.is-live .os-stage { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; }
.opal-story.is-live .os-fallback { display: none; }
.opal-story .os-gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 1.2s ease; }
.opal-story .os-gl.is-ready { opacity: 1; }
.opal-story .os-fx { position: absolute; inset: 0; pointer-events: none; }
.opal-story .os-fx--grid {
  background: linear-gradient(var(--os-rule) 1px, transparent 1px) 0 0 / 100% 25%, linear-gradient(90deg, var(--os-rule) 1px, transparent 1px) 0 0 / 12.5% 100%;
  opacity: 0.35;
  -webkit-mask-image: radial-gradient(70% 70% at 60% 50%, transparent 30%, #000 100%);
          mask-image: radial-gradient(70% 70% at 60% 50%, transparent 30%, #000 100%);
}
.opal-story .os-fx--vignette { background: radial-gradient(120% 90% at 60% 50%, transparent 55%, rgba(0,0,0,0.7) 100%); }
/* The teal glow behind the stone and the film grain are drawn inside the 3D picture's last pass (js/opal-story-scene.js),
   not as blended page layers: those made the browser composite the whole stage again on every frame. */
.opal-story .os-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.opal-story .os-ld { fill: none; stroke: rgba(214,236,240,.28); stroke-width: .75; }
.opal-story .os-mk circle { fill: rgba(3,4,5,.72); stroke: rgba(214,236,240,.55); stroke-width: .75; }
.opal-story .os-mk text { font-family: var(--os-mono-f); font-size: 9.5px; letter-spacing: .08em; fill: var(--os-text); text-anchor: middle; dominant-baseline: central; }
.opal-story .os-tr-base { fill: none; stroke: rgba(214,236,240,.22); stroke-width: .75; }
.opal-story .os-tr-flow { fill: none; stroke: var(--os-cyan); stroke-width: 1; stroke-dasharray: 2 9; stroke-linecap: round; animation: os-dash 1.6s linear infinite; }
.opal-story .os-tr-node { fill: var(--os-ink); stroke: var(--os-cyan); stroke-width: 1; }
.opal-story .os-tr-t { font-family: var(--os-mono-f); font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; fill: var(--os-text-2); }
.opal-story .os-tr-t--a { fill: var(--os-cyan); }
@keyframes os-dash { to { stroke-dashoffset: -11; } }

.opal-story .os-tag { position: absolute; left: 0; top: 0; opacity: 0; pointer-events: none; will-change: transform, opacity; display: grid; gap: 3px; padding-left: 10px; border-left: 1px solid var(--os-rule-2); }
.opal-story .os-tag .os-mono { font-size: 9px; color: var(--os-cyan); }
.opal-story .os-tag b { font-family: var(--os-serif); font-weight: 400; font-size: 21px; line-height: 1.05; white-space: nowrap; }
.opal-story .os-tag i { font-family: var(--os-mono-f); font-style: normal; font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: var(--os-text-3); white-space: nowrap; }

.opal-story .os-where { position: absolute; z-index: 3; bottom: 16px; left: var(--os-gl); color: var(--os-text-3); white-space: nowrap; }
.opal-story .os-where b { color: var(--os-text-2); font-weight: 400; }

.opal-story.is-live .os-copy { position: absolute; z-index: 3; left: var(--os-gl); top: 50%; width: min(31rem, 38vw); padding-left: clamp(0px, 2.6vw, 2.4rem); }
.opal-story.is-live .os-panel { position: absolute; left: 0; top: 0; width: 100%; transform: translateY(-50%); opacity: 0; visibility: hidden; display: grid; gap: 1.15rem; }
.opal-story.is-live .os-tech { left: var(--os-gl); right: var(--os-gr); top: 50%; width: auto; z-index: 3; padding-left: clamp(0px, 2.6vw, 2.4rem); padding-right: clamp(0px, 9vw, 9rem); gap: 2rem; }
.opal-story .os-hint { display: flex; align-items: center; gap: .8rem; color: var(--os-text-3); margin-top: .6rem; }
.opal-story .os-hint::before { content: ""; width: 1px; height: 34px; background: linear-gradient(var(--os-cyan), transparent); animation: os-hint 2.4s ease-in-out infinite; transform-origin: top; }
@keyframes os-hint { 0%,100% { transform: scaleY(.4); opacity: .4 } 50% { transform: scaleY(1); opacity: 1 } }
/* A panel the story has hidden keeps its animation still: running out of sight, it had the browser paint on every frame. */
.opal-story .os-off .os-hint::before { animation-play-state: paused; }

.opal-story .os-rail { position: absolute; z-index: 3; right: var(--os-gr); top: 50%; transform: translateY(-50%); display: grid; justify-items: end; gap: 12px; }
.opal-story .os-pct { font-family: var(--os-mono-f); font-size: 11px; letter-spacing: .1em; font-variant-numeric: tabular-nums; }
.opal-story .os-pct small { display: block; font-size: 8.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--os-text-3); text-align: right; }
.opal-story .os-rail ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; justify-items: end; }
.opal-story .os-rail li { display: flex; align-items: center; gap: 10px; color: var(--os-text-3); transition: color .5s; font-family: var(--os-mono-f); font-size: 9px; letter-spacing: .2em; text-transform: uppercase; }
/* The rail shows where the reader is as a longer tick. It used to spell the chapter out as well, which is already
   in the corner of the stage and above each headline, and the label lay across the stone's parts. */
.opal-story .os-rail li span, .opal-story .os-pct small { display: none; }
.opal-story .os-rail li::after { content: ""; width: 10px; height: 1px; background: var(--os-rule-2); transition: width .5s, background .5s; }
.opal-story .os-rail li.is-on { color: var(--os-text); }
.opal-story .os-rail li.is-on::after { width: 34px; background: var(--os-text); }

.opal-story .os-caption { position: absolute; z-index: 3; bottom: 16px; right: var(--os-gr); color: var(--os-text-3); }
.opal-story .os-loader { position: absolute; inset: 0; display: grid; place-items: center; color: var(--os-text-3); transition: opacity .8s; z-index: 2; pointer-events: none; }
.opal-story .os-loader.is-done { opacity: 0; }
/* While the scene is being built (is-pending, set by js/opal-story.js as soon as the browser is known to run it), the
   section is already in its pinned layout: the first chapter's copy shows where it will stay, and the loader's line
   stands where the stone will appear (on a desktop right of the copy, on a phone above it), so the stone fades in
   with nothing else moving. */
.opal-story.is-pending .os-panel[data-in="0"] { opacity: 1; visibility: visible; }
@media (min-width: 861px), (orientation: landscape) and (max-height: 520px) { .opal-story.is-live .os-loader { padding-left: 26vw; } }
@media (max-width: 860px) and (orientation: portrait), (max-width: 860px) and (min-height: 521px) { .opal-story.is-live .os-loader { padding-bottom: 34vh; } }

/* Lists and data sheets keep to a narrower column than the headlines, so the stone has room beside them. */
@media (min-width: 861px), (orientation: landscape) and (max-height: 520px) {
  .opal-story.is-live .os-copy .os-parts, .opal-story.is-live .os-copy .os-sheet, .opal-story.is-live .os-copy .os-steps { max-width: 26rem; }
}

/* ---------- phone ---------- */
/* Stacked: the stone above the copy. For a narrow screen held upright, or narrow and tall enough; a phone on its side
   gets the copy beside the stone instead (below). The scene asks the same question (section 8). */
@media (max-width: 860px) and (orientation: portrait), (max-width: 860px) and (min-height: 521px) {
  .opal-story { font-size: 14px; --os-foot: max(1.5rem, calc(env(safe-area-inset-bottom, 0px) + .8rem)); }
  .opal-story .os-tech-grid { grid-template-columns: 1fr; }
  .opal-story .os-tech-col + .os-tech-col { padding-left: 0; border-left: 0; }
  .opal-story.is-live { height: 800vh; }
  .opal-story .os-where, .opal-story .os-rail, .opal-story .os-caption { display: none; }
  .opal-story.is-live .os-copy { top: auto; bottom: 0; left: 0; right: 0; width: auto; padding: 0 var(--os-gr) var(--os-foot) var(--os-gl); min-height: 46%; }
  .opal-story.is-live .os-copy::before { content: ""; position: absolute; inset: -4rem 0 0; z-index: -1; background: linear-gradient(180deg, transparent, rgba(3,4,5,.9) 26%, var(--os-ink) 62%); }
  .opal-story.is-live .os-panel { top: auto; bottom: var(--os-foot); left: var(--os-gl); right: var(--os-gr); width: auto; transform: none; gap: .6rem; }
  .opal-story.is-live .os-panel h2 { font-size: 2.9rem; }
  .opal-story.is-live .os-panel h3 { font-size: 2.25rem; }
  .opal-story.is-live .os-parts li { padding: .5rem 0; }
  .opal-story.is-live .os-parts em { display: none; }
  .opal-story.is-live .os-sheet div { grid-template-columns: 5.4rem minmax(0,1fr); gap: .6rem; padding: .42rem .75rem; }
  .opal-story.is-live .os-sheet div:nth-child(n+4) { display: none; }
  .opal-story.is-live .os-steps li { padding: .36rem 0; font-size: 12.5px; line-height: 1.42; }
  .opal-story.is-live .os-tech { top: auto; bottom: var(--os-foot); left: var(--os-gl); right: var(--os-gr); padding: 0; gap: .8rem; }
  .opal-story.is-live .os-actions { flex-wrap: nowrap; }
  .opal-story.is-live .os-actions .os-pill { flex: 1 1 auto; justify-content: center; padding: 0 8px; letter-spacing: .12em; }
  .opal-story.is-live .os-tech::before { content: ""; position: absolute; inset: -5rem calc(-1 * var(--os-gr)) calc(-1 * var(--os-foot)) calc(-1 * var(--os-gl)); z-index: -1; background: linear-gradient(180deg, transparent, rgba(3,4,5,.9) 20%, var(--os-ink) 50%); }
  .opal-story.is-live .os-tech h3 { font-size: 2.1rem; }
  .opal-story.is-live .os-tech-col { padding-top: .6rem; }
  .opal-story.is-live .os-row { padding: .35rem 0; }
  .opal-story.is-live .os-row:nth-of-type(n+3) { display: none; }
  .opal-story .os-tag b { font-size: 17px; }
  .opal-story .os-tag i { display: none; }
}
/* A small phone held upright (an iPhone SE with its toolbars, a 360 x 640 Android): the closing sheet keeps each
   company's status line only, or it runs under the top bar. */
@media (max-width: 860px) and (orientation: portrait) and (max-height: 640px) {
  .opal-story.is-live .os-tech .os-row:nth-of-type(n+2) { display: none; }
  .opal-story.is-live .os-tech h3 { font-size: 1.9rem; }
}

/* ---------- a short desktop window ---------- */
/* A laptop at 125 to 150 %, or a browser with its toolbars: 1366 x 657 and 1280 x 600 are common. The copy is centred
   in the room below the top bar, the type and the rows are tighter, and below 640 px the longer lists are cut. */
@media (min-width: 861px) and (max-height: 760px) {
  .opal-story.is-live .os-copy, .opal-story.is-live .os-tech { top: calc(50% + 2.3rem); }
  .opal-story.is-live .os-panel { gap: .8rem; }
  .opal-story .os-panel h2 { font-size: clamp(2.4rem, 1.4rem + 2.4vw, 3.8rem); }
  .opal-story .os-panel h3 { font-size: clamp(2rem, 1.2rem + 1.9vw, 3rem); }
  .opal-story.is-live .os-sheet div { padding: .45rem 1rem; }
  .opal-story.is-live .os-parts li { padding: .5rem 0; }
  .opal-story.is-live .os-steps li { padding: .45rem 0; }
}
@media (min-width: 861px) and (max-height: 640px) {
  .opal-story.is-live .os-sheet div:nth-child(n+5) { display: none; }
  .opal-story.is-live .os-parts em, .opal-story.is-live .os-chips { display: none; }
  .opal-story.is-live .os-steps li { padding: .3rem 0; font-size: 13.5px; line-height: 1.4; }
  .opal-story.is-live .os-lede { font-size: 14.5px; }
}

/* ---------- a phone on its side ---------- */
/* Copy beside the stone, as on a desktop, made compact: the stage is only some 340 px tall. No rail, no name tags (the
   numbered markers carry the names), and the longer lists cut to what fits. */
@media (orientation: landscape) and (max-height: 520px) {
  .opal-story { font-size: 13px; }
  .opal-story .os-where, .opal-story .os-rail, .opal-story .os-caption { display: none; }
  .opal-story.is-live .os-copy { width: min(26rem, 46vw); top: calc(50% + 1.9rem); }
  .opal-story.is-live .os-panel { gap: .45rem; }
  .opal-story.is-live .os-panel h2 { font-size: 1.85rem; }
  .opal-story.is-live .os-panel h3 { font-size: 1.6rem; }
  .opal-story.is-live .os-lede { font-size: 12.5px; line-height: 1.45; }
  .opal-story.is-live .os-hint, .opal-story.is-live .os-chips, .opal-story.is-live .os-parts em { display: none; }
  .opal-story.is-live .os-parts li { padding: .28rem 0; }
  .opal-story.is-live .os-sheet div { grid-template-columns: 5.2rem minmax(0,1fr); gap: .5rem; padding: .3rem .6rem; }
  .opal-story.is-live .os-sheet div:nth-child(n+3) { display: none; }
  .opal-story.is-live .os-steps li { padding: .22rem 0; font-size: 11.5px; line-height: 1.35; }
  .opal-story.is-live .os-tech { top: calc(50% + 1.9rem); gap: .55rem; padding-right: 0; }
  .opal-story.is-live .os-tech h3 { font-size: 1.45rem; }
  .opal-story.is-live .os-tech-col { padding-top: .4rem; }
  .opal-story.is-live .os-row { padding: .22rem 0; }
  .opal-story.is-live .os-row:nth-of-type(n+3) { display: none; }
  .opal-story.is-live .os-pill { height: 32px; }
}
@media (orientation: landscape) and (max-height: 360px) {
  /* the smallest phones on their side: each step of the loan keeps its first two lines */
  .opal-story.is-live .os-steps li { font-size: 11px; padding: .15rem 0; }
  .opal-story.is-live .os-steps li p { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .opal-story .os-tr-flow, .opal-story .os-hint::before { animation: none; }
  .opal-story .os-gl { transition: none; }
}
/* Lenis (smooth scroll) hooks; harmless when Lenis is not running */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
