/* ═══════════════════════════════════════════════════════════════════════════
   home.css — SCENE 01 · the threshold (the title screen)

   One composed viewport: logo assembly left, the three realities right, the
   archive's own credits on the floor. Nothing below the fold.
   ═══════════════════════════════════════════════════════════════════════════ */

.title-screen {
    position: relative;
    min-height: 100svh;
    display: grid;
    grid-template-rows: var(--bar-height) minmax(0, 1fr) auto;
    overflow: clip;
}

/* ── the field behind the logo ─────────────────────────────────────────── */
.title-screen__field { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.field__ring {
    position: absolute;
    left: 71%; top: 46%;
    translate: -50% -50%;
    border-radius: 50%;
    border: 1px solid var(--scene-rule);
    opacity: 0.5;
}
.field__ring--outer { width: min(76vw, 980px); aspect-ratio: 1; }
.field__ring--inner { width: min(48vw, 620px); aspect-ratio: 1; border-color: oklch(72% 0.105 82 / 0.18); }
.field__ring--outer::after {
    content: ''; position: absolute; inset: 0; border-radius: 50%;
    border: 1px solid transparent;
    border-top-color: var(--accent);
    opacity: 0.5;
    transform: rotate(-24deg);
}
.field__sun {
    position: absolute; left: 71%; top: 46%;
    translate: -50% -50%;
    width: min(34vw, 420px); aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle, oklch(72% 0.105 82 / 0.16) 0%, oklch(72% 0.105 82 / 0.04) 46%, transparent 68%);
}
.field__horizon {
    position: absolute; left: 0; right: 0; bottom: 14%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--scene-rule) 22%, var(--scene-rule) 78%, transparent);
    opacity: 0.6;
}

/* ── the gate ──────────────────────────────────────────────────────────── */
.gate {
    position: relative; z-index: 1;
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: clamp(var(--space-6), 4vh, var(--space-10)) var(--page-gutter);
    display: grid;
    grid-template-columns: minmax(0, 1.22fr) minmax(320px, 0.88fr);
    align-items: center;
    gap: clamp(var(--space-6), 4vw, var(--space-16));
}

.gate__intro { position: relative; max-width: 640px; }
.gate__eyebrow {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: 0.26em;
    text-transform: uppercase;
    color: var(--accent);
    opacity: 0.85;
    margin-bottom: clamp(var(--space-3), 2.2vh, var(--space-6));
}

.gate__logo { margin: 0; }
.logo__word {
    display: block;
    font-family: var(--font-display);
    font-weight: var(--weight-medium);
    font-size: var(--text-logo);
    line-height: 0.82;
    letter-spacing: -0.012em;
    color: var(--scene-ink);
}
.logo__ruled {
    display: flex; align-items: center; gap: clamp(var(--space-3), 1.6vw, var(--space-5));
    margin-top: clamp(var(--space-2), 1.6vh, var(--space-4));
}
.logo__rule {
    position: relative;
    height: 1px; width: clamp(24px, 5vw, 92px);
    background: var(--accent);
    opacity: 0.7;
}
.logo__rule::after {
    content: ''; position: absolute; right: -3px; top: -2px;
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--accent);
}
.logo__worlds {
    font-family: var(--font-mono);
    font-weight: var(--weight-regular);
    font-size: clamp(0.9rem, 1.9vw, 1.5rem);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--scene-dim);
}

.gate__line {
    margin-top: clamp(var(--space-4), 2.6vh, var(--space-6));
    font-family: var(--font-display);
    font-size: clamp(1.05rem, 1.5vw, 1.35rem);
    font-style: italic;
    color: var(--scene-dim);
    letter-spacing: 0.01em;
}
.gate__premise {
    margin-top: var(--space-3);
    max-width: 34ch;
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--scene-faint);
}

.gate__acts {
    margin-top: clamp(var(--space-5), 3.4vh, var(--space-8));
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-5);
}
.arcade-key {
    display: inline-flex; align-items: center; gap: var(--space-3);
    min-height: var(--control-lg);
    padding: 0 var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    text-decoration: none;
    color: var(--scene-dim);
    border-bottom: 1px solid transparent;
    transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.arcade-key:hover { color: var(--scene-ink); border-bottom-color: var(--scene-accent); }
.arcade-key__count {
    display: inline-grid; place-items: center;
    min-width: 22px; height: 18px;
    border: 1px solid var(--scene-rule);
    font-size: var(--text-3xs);
    color: var(--scene-faint);
}

/* ── the portals ───────────────────────────────────────────────────────── */
.portals {
    position: relative;
    display: grid;
    gap: 2px;
    padding: 0;
    align-content: center;
}
.portals::before {
    content: ''; position: absolute; left: 0; top: 26px; bottom: 30px;
    width: 1px; background: var(--scene-rule);
}
.portals__head {
    display: flex; align-items: baseline; justify-content: space-between;
    padding: 0 0 var(--space-3) var(--space-4);
    font-family: var(--font-mono);
    font-size: var(--text-3xs);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--scene-faint);
}
.portals__count { color: var(--accent); }

.portal {
    position: relative;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) 24px;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
    text-decoration: none;
    color: inherit;
    border: 1px solid transparent;
    transition: background-color var(--dur-base) var(--ease-out),
                border-color var(--dur-base) var(--ease-out),
                padding var(--dur-base) var(--ease-out);
}
.portal:hover, .portal:focus-visible {
    background: oklch(100% 0 0 / 0.045);
    border-color: var(--scene-rule);
    padding-left: var(--space-5);
}
.portal__scene {
    position: relative;
    display: block;
    width: 64px; aspect-ratio: 1;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid var(--scene-rule);
    /* the miniature is absolutely positioned inside this box; without its own
       positioning context it escapes and paints over the whole portal row */
    isolation: isolate;
    transition: width var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.portal:hover .portal__scene,
.portal:focus-visible .portal__scene { width: 72px; border-color: var(--scene-accent); }
.portal__body { display: grid; gap: 1px; min-width: 0; }
.portal__no {
    font-family: var(--font-mono);
    font-size: var(--text-3xs);
    letter-spacing: var(--tracking-caps);
    color: var(--scene-faint);
}
.portal__title {
    font-family: var(--font-display);
    font-size: clamp(1.15rem, 1.5vw, 1.4rem);
    font-weight: var(--weight-regular);
    line-height: 1.1;
    color: var(--scene-ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.portal__genre {
    font-family: var(--font-mono);
    font-size: var(--text-3xs);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--scene-faint);
}
.portal__enter {
    display: inline-flex; width: 20px;
    color: var(--scene-faint);
    opacity: 0; transform: translateX(-4px);
    transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}
.portal__enter svg { width: 100%; fill: none; stroke: currentColor; stroke-width: 1.4; }
.portal:hover .portal__enter,
.portal:focus-visible .portal__enter { opacity: 1; transform: none; color: var(--scene-accent); }

.portals__foot {
    padding: var(--space-3) 0 0 var(--space-4);
    font-family: var(--font-mono);
    font-size: var(--text-3xs);
    letter-spacing: 0.1em;
    color: var(--scene-dim);
}

/* the portal miniatures: abstract, drawn from each world's palette only */
.pscene { position: absolute; inset: 0; display: block; }
.pscene--teaser {
    background:
        radial-gradient(38% 52% at 62% 46%, oklch(88% 0.01 80) 0 26%, transparent 62%),
        radial-gradient(70% 90% at 50% 110%, oklch(22% 0.09 22) 0%, transparent 60%),
        oklch(8% 0.004 20);
}
.pscene--teaser::after {
    content: ''; position: absolute; left: 26%; top: 12%; bottom: 12%;
    width: 1.5px; background: oklch(50% 0.19 22);
    box-shadow: 0 0 8px oklch(50% 0.19 22);
}
.pscene--shd {
    background:
        radial-gradient(40% 40% at 72% 26%, oklch(98% 0.03 90) 0%, transparent 70%),
        linear-gradient(180deg, oklch(86% 0.04 220) 0%, oklch(94% 0.03 84) 54%, oklch(80% 0.06 130) 56%, oklch(62% 0.07 135) 100%);
}
.pscene--shd::after {
    content: ''; position: absolute; left: 12%; right: 12%; bottom: 18%;
    height: 1px; background: oklch(98% 0.02 90 / 0.7);
}
.pscene--at {
    background:
        radial-gradient(55% 55% at 26% 22%, oklch(99% 0.05 95) 0 22%, transparent 60%),
        linear-gradient(180deg, oklch(86% 0.06 230) 0%, oklch(96% 0.02 220) 58%, oklch(78% 0.11 140) 60%, oklch(66% 0.12 145) 100%);
}
.pscene--at::after {
    content: ''; position: absolute; left: -18%; right: 30%; bottom: 6%;
    height: 44%; border-radius: 50% 50% 0 0 / 100% 100% 0 0;
    background: oklch(72% 0.13 143);
}

/* ── the floor ─────────────────────────────────────────────────────────── */
.floor {
    position: relative; z-index: 2;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-4);
    padding: 0 var(--page-gutter) var(--space-4);
    min-height: 46px;
    font-family: var(--font-mono);
    font-size: var(--text-3xs);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--scene-faint);
}
.floor__rule {
    position: absolute; left: var(--page-gutter); right: var(--page-gutter); top: 0;
    height: 1px; background: var(--scene-rule);
}
.floor__read { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.floor__pulse {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 0 oklch(72% 0.105 82 / 0.5);
    animation: pulse 3.4s var(--ease-out) infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}
.floor__links {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    justify-self: end;
    text-align: right;
}
.floor__line { color: var(--scene-dim); }
.floor__dot { opacity: 0.5; }
.floor__links a { color: var(--scene-dim); text-decoration: none; }
.floor__links a:hover { color: var(--accent); }

/* ── assembly ──────────────────────────────────────────────────────────── */
/* Movement only: content is never hidden behind an opacity ramp, so the first
   paint contains the title screen and a reader (or a measurement tool) never
   samples an empty frame. */
.is-ready .gate__eyebrow,
.is-ready .logo__word,
.is-ready .logo__ruled,
.is-ready .gate__line,
.is-ready .gate__premise,
.is-ready .gate__acts,
.is-ready .portal,
.is-ready .portals__head,
.is-ready .portals__foot {
    animation: gate-in var(--dur-slow) var(--ease-out) both;
}
.is-ready .gate__eyebrow { animation-delay: 40ms; }
.is-ready .logo__word { animation-delay: 90ms; }
.is-ready .logo__ruled { animation-delay: 170ms; }
.is-ready .gate__line { animation-delay: 240ms; }
.is-ready .gate__premise { animation-delay: 300ms; }
.is-ready .gate__acts { animation-delay: 360ms; }
.is-ready .portals__head { animation-delay: 180ms; }
.is-ready .portal:nth-child(2) { animation-delay: 240ms; }
.is-ready .portal:nth-child(3) { animation-delay: 320ms; }
.is-ready .portal:nth-child(4) { animation-delay: 400ms; }
.is-ready .portals__foot { animation-delay: 470ms; }

@keyframes gate-in {
    from { transform: translateY(14px); filter: blur(3px); }
    to { transform: none; filter: none; }
}

/* ── portal atmosphere: choosing a world re-lights the field ───────────── */
body[data-portal='teaser'] { --scene-glow: oklch(50% 0.17 22 / 0.34); }
body[data-portal='shd'] { --scene-glow: oklch(88% 0.05 80 / 0.30); }
body[data-portal='at'] { --scene-glow: oklch(78% 0.11 340 / 0.30); }

/* ── narrow: a vertical gate ───────────────────────────────────────────── */
@media (max-width: 1020px) {
    .gate {
        grid-template-columns: minmax(0, 1fr);
        gap: clamp(var(--space-6), 4vh, var(--space-10));
        padding-top: var(--space-6);
        padding-bottom: var(--space-6);
    }
    .gate__intro { max-width: none; }
    .gate__premise { max-width: 46ch; }
    .portals { max-width: 620px; }
    .floor { grid-template-columns: minmax(0, 1fr); min-height: 40px; }
    .floor__read { display: none; }
    .floor__links { justify-self: start; text-align: left; grid-column: 1 / -1; }
    body[data-layer='home'] #view { min-height: 0; }
    .title-screen { grid-template-rows: var(--bar-height) minmax(0, 1fr) auto; }
}

@media (max-width: 560px) {
    .gate { padding-top: var(--space-4); gap: var(--space-5); }
    .gate__eyebrow { letter-spacing: 0.16em; }
    .logo__worlds { letter-spacing: 0.26em; }
    .portal { grid-template-columns: 48px minmax(0, 1fr) 18px; gap: var(--space-3); padding-left: var(--space-3); }
    .portal__scene { width: 48px; }
    .portal:hover .portal__scene, .portal:focus-visible .portal__scene { width: 52px; }
    .portal__title { font-size: var(--text-base); }
    .portal__enter { opacity: 1; transform: none; }
    .gate__acts { flex-direction: column; align-items: stretch; gap: var(--space-2); }
    .start { justify-content: space-between; }
    .arcade-key { justify-content: space-between; border-top: 1px solid var(--scene-rule); }
    .floor { font-size: var(--text-3xs); padding-bottom: var(--space-4); }
    .floor__line { display: none; }
    .floor__links { gap: 4px; }
}
