/* =========================================================
   Homepage: Live2D hero + model stage
   Uses the colours and fonts from main.css. Everything new is
   prefixed with l2d- so nothing else on the site is affected.
   ========================================================= */

.l2d {
    --l-cream: #fbf6ee;
    --l-deep: #5206b4;
    --l-ease: cubic-bezier(.2, .8, .2, 1);
    --top-h: 132px;                               /* height of the navigation above the hero, set by js */
    --hh: calc(100svh - var(--top-h));            /* hero height: first screen minus navigation */
    --sh: calc(100svh - var(--nav-h));            /* stage height below a sticky navigation */
    position: relative;
}

/* ---------- Scroll snapping, only for the intro and the model stage ----------
   js switches .l2d-snapping on <html> while you are in that part of the page.
   Below it the page scrolls normally. */
html { scroll-padding-top: var(--nav-h); }
html.l2d-snapping { scroll-snap-type: none; } /* settling is done in js (live2d-stage.js), so the wheel never gets stuck */
.l2d-top,
.l2d-snap {
    position: absolute;
    left: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
    scroll-snap-align: start;
}
.l2d-top { top: 0; }
.l2d-snap-end { scroll-snap-align: start; }   /* the first section after the stage */

/* =========================================================
   Shared pieces in the Sandrina CI: square, mono, hard shadow
   ========================================================= */
.l2d-key {
    --face: #fff;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 14px;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: .8125rem;
    line-height: 1.1;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--ink);
    background: var(--face);
    box-shadow: inset 0 0 0 2px var(--ink), 4px 4px 0 var(--ink);
    transition: transform .15s var(--l-ease), box-shadow .15s var(--l-ease), background-color .2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.l2d-key:hover { transform: translate(-2px, -2px); box-shadow: inset 0 0 0 2px var(--ink), 6px 6px 0 var(--ink); }
.l2d-key:active,
.l2d-key[aria-pressed="true"] { transform: translate(3px, 3px); box-shadow: inset 0 0 0 2px var(--ink), 1px 1px 0 var(--ink); }
.l2d-key[aria-pressed="true"] { --face: var(--on, var(--mint-deep)); }
.l2d-key kbd { display: grid; place-items: center; min-width: 22px; height: 22px; font: inherit; letter-spacing: 0; color: #fff; background: var(--ink); }
.l2d-key[disabled] { opacity: .5; pointer-events: none; }
.l2d-key--icon { justify-content: center; width: 48px; min-height: 48px; padding: 0; }
.l2d-key--icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: square; stroke-linejoin: miter; }

.l2d .btn { box-shadow: inset 0 0 0 2px var(--ink), 5px 5px 0 var(--ink); transition: transform .15s var(--l-ease), box-shadow .15s var(--l-ease), background-position .6s ease; }
.l2d .btn:hover { transform: translate(-2px, -2px); box-shadow: inset 0 0 0 2px var(--ink), 7px 7px 0 var(--ink); }
.l2d .btn:active { transform: translate(3px, 3px); box-shadow: inset 0 0 0 2px var(--ink), 1px 1px 0 var(--ink); }
.l2d .btn--outline { color: var(--ink); background: #fff; }
.l2d .btn--outline:hover { color: var(--ink); background: var(--mint-deep); }

.l2d-tape {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px 7px;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: .875rem;
    line-height: 1.2;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--mint-deep);
    transform: rotate(-2deg);
    clip-path: polygon(0 12%, 3% 0, 6% 12%, 9% 0, 100% 0, 100% 88%, 97% 100%, 94% 88%, 91% 100%, 0 100%);
}

.l2d-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: .8125rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}
.l2d-label span + span { letter-spacing: 0; text-transform: none; font-weight: 400; opacity: .9; }
.l2d-keys { display: flex; flex-wrap: wrap; gap: 12px 12px; padding: 0 6px 6px 0; }

/* Letter reveal (js wraps letters in .l2d-ch) */
.l2d-ch { display: inline-block; }
.l2d-clip { display: inline-block; overflow: hidden; vertical-align: bottom; }

/* =========================================================
   Hero: the live model
   ========================================================= */
.l2d-hero { position: sticky; top: var(--nav-h); z-index: 0; height: var(--hh); min-height: 560px; }
.l2d-hero-pin { position: relative; height: 100%; overflow: clip; color: var(--l-cream); background: var(--purple); }
.l2d-hero.is-covered .l2d-hero-pin { visibility: hidden; }

.l2d-hero-bg, .l2d-hero-bg i { position: absolute; inset: 0; }
.l2d-marble { background: var(--l-deep); -webkit-mask: url(../Sources/img/web/Pattern.webp) 50% 50% / 190% auto no-repeat; mask: url(../Sources/img/web/Pattern.webp) 50% 50% / 190% auto no-repeat; transform: translate3d(calc(var(--mx, 0) * -14px), calc(var(--my, 0) * -10px), 0); }
.l2d-hero-bg .l2d-disc { inset: auto; left: 50%; top: 50%; width: min(calc(var(--hh) * .82), 56vw); aspect-ratio: 1; border-radius: 50%; background: var(--pink); transform: translate(-50%, -50%) scale(var(--disc, .2)); transition: transform 1.1s var(--l-ease); }
.l2d-hero-bg .l2d-dots { inset: auto; left: 50%; top: 50%; width: min(calc(var(--hh) * 1.03), 71vw); aspect-ratio: 1; border-radius: 50%; color: var(--pink); background: radial-gradient(circle, currentColor 0 32%, transparent 34%) 0 0 / 15px 15px; -webkit-mask: radial-gradient(circle closest-side, transparent 0 79%, #000 80%, transparent 100%); mask: radial-gradient(circle closest-side, transparent 0 79%, #000 80%, transparent 100%); transform: translate(-50%, -50%) rotate(calc(var(--hp, 0) * 40deg)); }

.l2d-title { position: absolute; left: 0; right: 0; top: clamp(16px, 5svh, 60px); margin: 0; text-align: center; pointer-events: none; }
.l2d-word { font: 400 14vw/1.3 var(--font-display); letter-spacing: -.02em; text-transform: uppercase; white-space: nowrap; color: var(--l-cream); transform: translate3d(calc(var(--mx, 0) * 18px), calc(var(--hp, 0) * -60px), 0); }
.l2d-word.l2d-clip { padding-block: .3em; margin-block: -.3em; }
.l2d-word .l2d-ch { transform: translateY(110%) rotate(6deg); transition: transform .9s var(--l-ease); transition-delay: calc(var(--i) * 45ms); }
.l2d.is-ready .l2d-word .l2d-ch { transform: none; }

.l2d-rig { position: absolute; left: 50%; bottom: 0; height: min(calc(var(--hh) * .95), 76vw); aspect-ratio: 3600 / 4060; opacity: 0; transform: translate3d(calc(-50% + var(--mx, 0) * -10px), calc(var(--hp, 0) * 70px), 0); transition: opacity .6s .15s; }
.l2d.is-ready .l2d-rig { opacity: 1; }
.l2d-rig-poster, .l2d-rig-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.l2d-rig-canvas { opacity: 0; cursor: pointer; touch-action: pan-y; transition: opacity .5s; }
.l2d-rig.is-live .l2d-rig-canvas { opacity: 1; }
.l2d-rig.is-live .l2d-rig-poster { opacity: 0; transition: opacity .3s .35s; }
.l2d-zzz { position: absolute; left: 62%; top: 9%; font: 400 clamp(1.4rem, 2.4vw, 2.4rem)/1 var(--font-display); color: var(--l-cream); opacity: 0; transform: translateY(12px) rotate(-8deg); transition: opacity .5s, transform .8s var(--l-ease); pointer-events: none; }
.l2d-rig.is-asleep .l2d-zzz { opacity: 1; transform: rotate(-8deg); animation: l2d-zzz 2.6s ease-in-out infinite; }
@keyframes l2d-zzz { 50% { transform: translate(8px, -10px) rotate(-3deg); } }
.l2d-wake { position: absolute; left: 50%; bottom: 20%; transform: translateX(-50%); }
.l2d .l2d-wake:hover { transform: translate(calc(-50% - 2px), -2px); }
[hidden] { display: none !important; }

.l2d-copy { position: absolute; left: var(--gutter); bottom: clamp(24px, 5svh, 56px); width: min(340px, 25vw); display: grid; justify-items: start; gap: 18px; }
.l2d-lead { font-size: 1.0625rem; line-height: 1.55; }
.l2d-actions { display: flex; flex-wrap: wrap; gap: 16px; padding: 0 6px 6px 0; }
.l2d-actions .btn { padding: 16px 22px; }
.l2d-socials { display: flex; gap: 12px; padding: 0 5px 5px 0; }
.l2d-socials a { display: grid; place-items: center; width: 44px; height: 44px; background: #fff; box-shadow: inset 0 0 0 2px var(--ink), 4px 4px 0 var(--ink); transition: transform .15s var(--l-ease), box-shadow .15s var(--l-ease); }
.l2d-socials a:hover { transform: translate(-2px, -2px); box-shadow: inset 0 0 0 2px var(--ink), 6px 6px 0 var(--ink); }
.l2d-socials img { width: 22px; height: 22px; object-fit: contain; }
.l2d-socials img.vgen { width: 28px; height: 28px; }

.l2d-deck { position: absolute; right: var(--gutter); bottom: clamp(24px, 5svh, 56px); width: min(430px, 30vw); display: grid; gap: 14px; }
.l2d-deck .l2d-key { --on: var(--mint-deep); }
.l2d-deck.is-loading .l2d-key { opacity: .55; }

/* entrance */
.l2d-hero .l2d-tape, .l2d-lead, .l2d-actions, .l2d-socials, .l2d-deck { opacity: 0; transform: translateY(26px); transition: opacity .7s var(--l-ease), transform .9s var(--l-ease); }
.l2d-hero .l2d-tape { transform: translateY(26px) rotate(-2deg); }
.l2d.is-ready .l2d-hero .l2d-tape, .l2d.is-ready .l2d-lead, .l2d.is-ready .l2d-actions, .l2d.is-ready .l2d-socials, .l2d.is-ready .l2d-deck { opacity: 1; transform: none; }
.l2d.is-ready .l2d-hero .l2d-tape { transform: rotate(-2deg); transition-delay: .55s; }
.l2d.is-ready .l2d-lead { transition-delay: .65s; }
.l2d.is-ready .l2d-actions { transition-delay: .75s; }
.l2d.is-ready .l2d-socials { transition-delay: .8s; }
.l2d.is-ready .l2d-deck { transition-delay: .85s; }
.l2d.is-ready .l2d-hero-bg .l2d-disc { --disc: 1; }

/* =========================================================
   Model stage
   ========================================================= */
.l2d-cast { position: relative; z-index: 1; height: calc(var(--sh) + var(--n, 8) * 85svh); }
.l2d-cast-pin {
    --c-bg: #c7b1ff; --c-disc: #ffe9a8; --c-text: #241e2f; --c-key: #ffd45c;
    position: sticky;
    top: var(--nav-h);
    height: var(--sh);
    min-height: 520px;
    overflow: clip;
    color: var(--c-text);
    background: var(--c-bg);
    transition: color .5s;
}
.l2d-cast-bg, .l2d-cast-bg i { position: absolute; inset: 0; }
.l2d-wipe { background: var(--c-bg); clip-path: circle(0% at 60% 50%); }
.l2d-cast-marble { background: var(--c-text); opacity: .07; -webkit-mask: url(../Sources/img/web/Pattern.webp) 30% 60% / 210% auto no-repeat; mask: url(../Sources/img/web/Pattern.webp) 30% 60% / 210% auto no-repeat; transition: background-color .5s; }
.l2d-cast-bg .l2d-cast-disc { inset: auto; left: 60%; top: 50%; width: min(calc(var(--sh) * .88), 58vw); aspect-ratio: 1; border-radius: 50%; background: var(--c-disc); transform: translate(-50%, -50%); }
.l2d-cast-bg .l2d-cast-disc::after { content: ""; position: absolute; inset: -17%; border-radius: 50%; color: var(--c-disc); background: radial-gradient(circle, currentColor 0 32%, transparent 34%) 0 0 / 15px 15px; -webkit-mask: radial-gradient(circle, transparent 0 60%, #000 61%, transparent 71%); mask: radial-gradient(circle, transparent 0 60%, #000 61%, transparent 71%); animation: l2d-spin 90s linear infinite; }
@keyframes l2d-spin { to { transform: rotate(1turn); } }

.l2d-name { position: absolute; left: var(--gutter); right: calc(var(--gutter) + 360px); bottom: clamp(12px, 3svh, 34px); margin: 0; font: 400 10vw/1.02 var(--font-display); letter-spacing: -.02em; text-transform: uppercase; color: inherit; pointer-events: none; transform: translate3d(calc(var(--seg, 0) * -4vw), 0, 0); }
.l2d-name .l2d-line { display: block; white-space: nowrap; overflow: hidden; padding: .16em 0 .2em; margin: -.16em 0 -.2em; }
.l2d-name .l2d-line + .l2d-line { margin-top: -.2em; }
.l2d-name .l2d-ch { transform: translateY(115%); }
.l2d-name.in .l2d-ch { transform: none; transition: transform .8s var(--l-ease); transition-delay: calc(var(--i) * 32ms + 120ms); }

.l2d-fig { position: absolute; left: 60%; bottom: calc(var(--sh) * .025); height: calc(var(--sh) * .95); aspect-ratio: var(--ar, .6); margin: 0; transform: translate3d(calc(-50% + var(--mx, 0) * -12px), calc(var(--seg, 0) * -5svh), 0); pointer-events: none; }
.l2d-fig.is-chibi { height: calc(var(--sh) * .8); bottom: calc(var(--sh) * .07); }
.l2d-fig img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%; opacity: 0; will-change: transform, opacity; filter: drop-shadow(12px 16px 0 rgb(20 14 30 / .26)); }

.l2d-info { position: absolute; left: var(--gutter); top: clamp(20px, 4svh, 40px); width: min(440px, 31vw); display: grid; justify-items: start; gap: 22px; }
.l2d-info .l2d-tape { color: var(--c-on, var(--c-bg)); background: var(--c-text); transition: background-color .5s, color .5s; }
.l2d-info .l2d-tape b { font: 400 1rem/1 var(--font-display); letter-spacing: 0; }
.l2d-quote { position: relative; margin: 0 0 10px; padding: 18px 22px; font-size: 1rem; line-height: 1.5; color: var(--ink); background: #fff; box-shadow: inset 0 0 0 2px var(--ink), 5px 5px 0 var(--ink); }
.l2d-quote::after { content: ""; position: absolute; left: 40px; bottom: -16px; width: 26px; height: 18px; background: var(--ink); clip-path: polygon(0 0, 100% 0, 10% 100%); }
.l2d-quote cite { display: block; margin-top: 10px; font-family: var(--font-mono); font-weight: 700; font-size: .8125rem; font-style: normal; letter-spacing: 1.5px; text-transform: uppercase; }
.l2d-quote:empty, .l2d-quote[hidden], .l2d-cast-pin.is-tight .l2d-quote { display: none; }
.l2d-handle { font-family: var(--font-mono); font-weight: 700; font-size: 1rem; letter-spacing: 1px; border-bottom: 2px solid currentColor; padding-bottom: 2px; }
.l2d-toggles { display: grid; gap: 12px; margin-top: 4px; }
.l2d-toggles .l2d-key { --on: var(--c-key); }
.l2d-info > * { transition: opacity .4s .1s, transform .6s .1s var(--l-ease); }
.l2d-cast-pin.is-swapping .l2d-info > :not(.l2d-tape) { opacity: 0; transform: translateY(16px); transition: none; }

.l2d-rail { position: absolute; right: var(--gutter); top: 50%; transform: translateY(-50%); display: grid; gap: clamp(8px, 1.2svh, 12px); }
.l2d-rail button { --s: clamp(44px, 7svh, 64px); position: relative; width: var(--s); height: var(--s); transition: transform .2s var(--l-ease); }
.l2d-rail-face { display: block; width: 100%; height: 100%; overflow: hidden; background: var(--tile); box-shadow: inset 0 0 0 2px var(--ink), 4px 4px 0 var(--ink); transition: box-shadow .2s var(--l-ease); }
.l2d-rail img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.12) translateY(6%); transition: transform .35s var(--l-ease); }
.l2d-rail-name { position: absolute; right: calc(100% + 16px); top: 50%; padding: 8px 12px; font-family: var(--font-mono); font-weight: 700; font-size: .8125rem; letter-spacing: 1.5px; text-transform: uppercase; white-space: nowrap; color: #fff; background: var(--ink); opacity: 0; transform: translate(10px, -50%); transition: opacity .2s, transform .3s var(--l-ease); pointer-events: none; }
.l2d-rail button:hover, .l2d-rail button:focus-visible { transform: translate(-3px, -3px); z-index: 2; }
.l2d-rail button:hover .l2d-rail-face { box-shadow: inset 0 0 0 2px var(--ink), 7px 7px 0 var(--ink); }
.l2d-rail button:hover img { transform: scale(1.24) translateY(4%); }
.l2d-rail button:hover .l2d-rail-name, .l2d-rail button:focus-visible .l2d-rail-name { opacity: 1; transform: translate(0, -50%); }
.l2d-rail button[aria-current="true"] { transform: translateX(-14px); z-index: 1; }
.l2d-rail button[aria-current="true"] .l2d-rail-face { box-shadow: inset 0 0 0 3px var(--ink), 0 0 0 4px #fff, 8px 8px 0 4px var(--ink); }
.l2d-rail-gap { height: clamp(4px, 1svh, 12px); }

.l2d-step { position: absolute; right: calc(var(--gutter) + 104px); bottom: clamp(18px, 4svh, 40px); display: flex; align-items: center; gap: 18px; }
.l2d-count { display: flex; align-items: baseline; gap: 8px; margin: 0; font: 400 1rem/1 var(--font-display); }
.l2d-count b { font-weight: 400; font-size: 2rem; min-width: 2.4ch; text-align: right; }
.l2d-count span::before { content: "/ "; }
.l2d-nojs { position: absolute; left: var(--gutter); top: 40%; max-width: 30ch; font: 700 1.25rem/1.4 var(--font-round); }
.l2d-nojs a { text-decoration: underline; }

/* =========================================================
   Smaller screens
   ========================================================= */
@media (max-width: 1100px) {
    .l2d-rig { height: min(calc(var(--hh) * .95), 62vw); }
    .l2d-copy { width: 25vw; }
    .l2d-lead { font-size: 1rem; }
    .l2d-deck { width: 31vw; }
    .l2d-info { width: min(340px, 36vw); }
}

@media (max-width: 860px) {
    /* Hero: normal flow. The model is shown as a bust (head to hips), so she stays big. */
    .l2d-hero { position: relative; top: auto; height: auto; min-height: 0; scroll-snap-align: start; }
    .l2d-hero-pin { display: grid; padding: 18px 0 34px; }
    .l2d-title { position: relative; top: auto; }
    .l2d-hero-bg .l2d-disc { top: 40vw; width: 96vw; transform: translate(-50%, 0) scale(var(--disc, .2)); }
    .l2d-hero-bg .l2d-dots { top: 40vw; width: 130vw; transform: translate(-50%, -13%); }
    .l2d-rig { position: relative; left: auto; bottom: auto; height: auto; width: 100vw; margin: -10vw 0 0; aspect-ratio: 2300 / 2700; transform: none; overflow: hidden; }
    .l2d-rig-poster { width: 156.5%; max-width: none; height: auto; inset: auto; left: -28.26%; top: 0; margin-top: -3.48%; }
    .l2d-wake { bottom: 12%; }
    .l2d-deck, .l2d-copy { position: relative; inset: auto; width: auto; padding: 0 var(--gutter); }
    .l2d-deck { order: 3; margin-top: 20px; }
    .l2d-copy { order: 4; margin-top: 30px; }
    .l2d-deck .l2d-keys { flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(var(--gutter) * -1); padding: 4px var(--gutter) 12px; scrollbar-width: none; }
    .l2d-deck .l2d-keys::-webkit-scrollbar { display: none; }

    /* Stage: tag and handle on top, name, figure, toggles, rail */
    .l2d-cast { height: calc(var(--sh) + var(--n, 8) * 70svh); }
    .l2d-info { display: contents; }
    .l2d-info .l2d-tape { position: absolute; left: var(--gutter); top: 16px; }
    .l2d-handle { position: absolute; right: var(--gutter); top: 22px; font-size: .875rem; }
    .l2d-quote, .l2d-toggles .l2d-label, .l2d-step { display: none; }
    .l2d-name { left: var(--gutter); right: var(--gutter); bottom: auto; top: 58px; font-size: 11vw; transform: none; }
    .l2d-cast-bg .l2d-cast-disc { left: 50%; top: 54%; width: 100vw; }
    /* The figure fills the space between name and toggles. Full models are shown
       from head to knees so they stay big; chibis are shown whole. */
    .l2d-fig { left: 0; right: 0; top: 118px; bottom: 128px; width: auto; height: auto; aspect-ratio: auto; transform: none; overflow: hidden; }
    .l2d-fig img { left: -50%; right: -50%; top: 0; bottom: auto; width: auto; height: calc(100% / .66); max-width: none; margin-inline: auto; object-fit: fill; }
    .l2d-fig.is-chibi { top: 118px; bottom: 128px; height: auto; }
    .l2d-fig.is-chibi img { height: 100%; }
    .l2d-toggles { position: absolute; left: 0; right: 0; bottom: 70px; margin: 0; }
    .l2d-toggles .l2d-keys { flex-wrap: nowrap; overflow-x: auto; padding: 4px var(--gutter) 10px; scrollbar-width: none; }
    .l2d-toggles .l2d-keys::-webkit-scrollbar { display: none; }
    .l2d-rail { right: auto; left: 50%; top: auto; bottom: 14px; transform: translateX(-50%); display: flex; gap: 6px; }
    .l2d-rail button { --s: min(40px, 9.4vw); }
    .l2d-rail-face { box-shadow: inset 0 0 0 2px var(--ink), 2px 2px 0 var(--ink); }
    .l2d-rail-name { display: none; }
    .l2d-rail button:hover { transform: none; }
    .l2d-rail button[aria-current="true"] { transform: translateY(-7px); }
    .l2d-rail button[aria-current="true"] .l2d-rail-face { box-shadow: inset 0 0 0 2px var(--ink), 0 0 0 3px #fff, 3px 3px 0 3px var(--ink); }
    .l2d-rail-gap { width: 2px; height: auto; }
}

@media (prefers-reduced-motion: reduce) {
    .l2d *, .l2d *::before, .l2d *::after { animation: none !important; transition: none !important; }
    .l2d-word .l2d-ch, .l2d-name .l2d-ch { transform: none; }
}
