/* Digigami landing entry (v4): the mark alone first; the invocation turns it 90° and the avatar rises out of it.
   Loaded only by index.html. Driven by js/entry.js through attributes on <html>:
     data-entry="on"      the intro is showing (set before paint by the inline head script; first visit only)
     data-entry-ready     js/entry.js has started (without it, a fail-safe shows the page after 4 s)
     data-entry-state     "still" (wrong pattern) | "init" (turning) | "rise" (avatar up) | "out" (fading away)
   The page content stays in the DOM the whole time (opacity only), so screen readers and crawlers have it. */

.entry { display: none; }
:root[data-entry="on"] .entry {
    position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 1.1rem; padding: 1.5rem 1rem 2rem; text-align: center; color: #f0f0f8;
    transition: opacity 0.6s ease;
}
:root[data-entry="on"] :is(.site-header, main, .footer) {
    opacity: 0; pointer-events: none; transition: opacity 0.7s ease;
}
/* Fail-safe: if js/entry.js never starts, the page appears anyway. */
:root[data-entry="on"]:not([data-entry-ready]) :is(.site-header, main, .footer) { animation: entryFailsafe 0.01s linear 4s forwards; }
:root[data-entry="on"]:not([data-entry-ready]) .entry { animation: entryFailsafeOut 0.01s linear 4s forwards; }
@keyframes entryFailsafe { to { opacity: 1; pointer-events: auto; } }
@keyframes entryFailsafeOut { to { opacity: 0; visibility: hidden; } }

.entry-skip {
    position: absolute; top: 1rem; right: 1rem; font: 600 0.85rem var(--font-body); color: #d8d8e6; background: rgba(10, 10, 15, 0.7);
    border: 1px solid #3a3a4a; border-radius: 100px; padding: 0.45rem 0.9rem; min-height: 40px; cursor: pointer;
}
.entry-skip:focus-visible, .fold:focus-visible, .entry-type :is(input, button):focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

/* The stage: the viewer looks slightly down on the portal, so the mark turned 90° about x reads as a floor disc. */
.entry-stage { position: relative; width: min(300px, 72vw); aspect-ratio: 1 / 1.05; perspective: 900px; perspective-origin: 50% -55%; }
.entry-portal {
    position: absolute; left: 0; right: 0; bottom: 0; aspect-ratio: 1; transform-origin: 50% 50%;
    transform-style: preserve-3d; transition: transform 1s cubic-bezier(0.55, 0, 0.25, 1), filter 0.4s ease;
}
.entry-mark {
    width: 100%; height: 100%; display: block; border-radius: 50%;
    filter: drop-shadow(0 0 18px rgba(94, 213, 213, 0.45)) drop-shadow(0 0 6px rgba(155, 109, 214, 0.5));
    transition: filter 0.4s ease;
}
/* Wrong pattern: the mark stays still and turns stone grey for a moment. */
:root[data-entry-state="still"] .entry-mark { filter: grayscale(1) brightness(0.75) drop-shadow(0 6px 10px rgba(5, 5, 8, 0.5)); }

/* The folds: five tappable points around the mark (keyboard reachable, 44 px targets). */
.entry-folds { position: absolute; inset: 0; transition: opacity 0.3s ease; }
/* Positions: on a circle at 34% of the mark (precomputed: angles 300°, 140°, 20°, 220°, 80°). */
.fold {
    position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%;
    font: 700 0.95rem var(--font-display); color: #0a0a0f; background: #f0f0f8; border: 2px solid #0a0a0f; cursor: pointer;
    box-shadow: 0 0 0 3px rgba(155, 109, 214, 0.55), 0 6px 14px rgba(5, 5, 8, 0.45);
    transition: background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.fold[data-fold="1"] { left: 67%; top: 20.6%; } .fold[data-fold="2"] { left: 24%; top: 71.9%; } .fold[data-fold="3"] { left: 82%; top: 61.6%; }
.fold[data-fold="4"] { left: 24%; top: 28.1%; } .fold[data-fold="5"] { left: 55.9%; top: 83.5%; }
.fold.is-target { background: var(--yellow); box-shadow: 0 0 0 4px rgba(243, 224, 110, 0.7), 0 6px 14px rgba(5, 5, 8, 0.45); }
.fold[aria-disabled="true"] { opacity: 0.45; cursor: default; }

/* The 8 brand colour nodes, in brand order clockwise from the top; unlit = dim. Lit = cel-shaded glow (two stepped
   rings) and one soft pulse when it lights (a ring that grows and fades once: not a flash). */
.entry-nodes { position: absolute; left: 0; right: 0; bottom: 0; aspect-ratio: 1; list-style: none; margin: 0; padding: 0; pointer-events: none; }
.entry-nodes li {
    --c: #888; position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%;
    background: color-mix(in srgb, var(--c) 22%, #14141c); border: 2px solid #0a0a0f; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
    transition: background 0.35s ease, box-shadow 0.35s ease;
}
.entry-nodes li:nth-child(1) { left: 50%; top: -8%; } .entry-nodes li:nth-child(2) { left: 91%; top: 9%; }
.entry-nodes li:nth-child(3) { left: 108%; top: 50%; } .entry-nodes li:nth-child(4) { left: 91%; top: 91%; }
.entry-nodes li:nth-child(5) { left: 50%; top: 108%; } .entry-nodes li:nth-child(6) { left: 9%; top: 91%; }
.entry-nodes li:nth-child(7) { left: -8%; top: 50%; } .entry-nodes li:nth-child(8) { left: 9%; top: 9%; }
.entry-nodes [data-node="pink"] { --c: var(--pink); } .entry-nodes [data-node="coral"] { --c: var(--coral); }
.entry-nodes [data-node="orange"] { --c: var(--orange); } .entry-nodes [data-node="yellow"] { --c: var(--yellow); }
.entry-nodes [data-node="green"] { --c: var(--green); } .entry-nodes [data-node="cyan"] { --c: var(--cyan); }
.entry-nodes [data-node="blue"] { --c: var(--blue); } .entry-nodes [data-node="purple"] { --c: var(--purple); }
.entry-nodes li.is-lit { background: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 45%, transparent), 0 0 0 9px color-mix(in srgb, var(--c) 18%, transparent); }
.entry-nodes li.is-lit::after {
    content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--c); opacity: 0;
    animation: nodePulse 0.9s ease-out 1;
}
@keyframes nodePulse { 0% { transform: scale(1); opacity: 0.55; } 100% { transform: scale(2.6); opacity: 0; } }
:root[data-motion="reduce"] .entry-nodes li.is-lit::after { animation: none; }

/* Breathing step: a circle that fills over the set time; Ready when it's full. Reduced motion: a still circle and a
   count instead of the growth. */
.entry-breath { display: grid; justify-items: center; gap: 0.5rem; }
.entry-breath[hidden] { display: none; }
.breath-circle { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--cyan); background: rgba(94, 213, 213, 0.18); transform: scale(0.4); }
.entry-breath.is-filling .breath-circle { transform: scale(1); transition: transform var(--breath, 4s) linear; }
.entry-breath.is-full .breath-circle { transform: scale(1); background: rgba(94, 213, 213, 0.38); }
:root[data-motion="reduce"] .breath-circle { transform: scale(1); transition: none !important; }
.breath-count { font: 600 0.9rem var(--font-mono); color: #c8c8dc; min-height: 1.2em; }
.breath-ready { font: 600 0.9rem var(--font-body); color: #0a0a0f; background: #f0f0f8; border: 0; border-radius: 10px; padding: 0 1.1rem; min-height: 42px; cursor: pointer; }
.breath-ready:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.entry-type[hidden] { display: none; }
.entry-progress { font: 600 0.85rem var(--font-mono); color: #c8c8dc; margin: 0; letter-spacing: 0.04em; }

.entry-prompt { font: 600 1.05rem var(--font-body); margin: 0.4rem 0 0; color: #e8e8f2; }
/* Entry text sits on its own dark pill, so it reads on both sides of the divider. */
:is(.entry-prompt, .entry-progress, .entry-msg:not(:empty), .entry-type, .entry-breath) {
    background: rgba(10, 10, 15, 0.86); border: 1px solid rgba(155, 109, 214, 0.25); border-radius: 12px; padding: 0.45rem 0.85rem;
    max-width: min(30rem, calc(100vw - 2rem));
}
.entry-type { display: grid; gap: 0.35rem; justify-items: center; font-size: 0.88rem; color: #c8c8dc; }
.entry-type kbd { font-family: var(--font-mono); font-size: 0.85rem; background: #1b1b26; border: 1px solid #3a3a4a; border-radius: 6px; padding: 0.05rem 0.4rem; color: #fff; }
.entry-type-row { display: flex; gap: 0.4rem; }
.entry-type input { font: 1rem var(--font-body); color: #f0f0f8; background: #121219; border: 1px solid #3a3a4a; border-radius: 10px; padding: 0.45rem 0.7rem; min-height: 42px; width: 12rem; }
.entry-type button { font: 600 0.9rem var(--font-body); color: #0a0a0f; background: #f0f0f8; border: 0; border-radius: 10px; padding: 0 1rem; min-height: 42px; cursor: pointer; }
.entry-msg { min-height: 1.4em; font-size: 0.9rem; color: #c8c8dc; margin: 0; }

/* The avatar rises out of the portal. */
.entry-avatar {
    position: absolute; left: 50%; bottom: 46%; width: 62%; height: auto; transform: translate(-50%, 40%) scale(0.4); transform-origin: 50% 100%;
    opacity: 0; transition: transform 1.1s cubic-bezier(0.2, 0.9, 0.25, 1.15), opacity 0.6s ease; pointer-events: none;
    filter: drop-shadow(0 10px 14px rgba(5, 5, 8, 0.45));
}

/* Initialise: the mark turns 90° (axis from window.DIGIGAMI_ENTRY.axis; default x = tilts back into a floor disc). */
:root[data-entry-state="init"] .entry-folds, :root[data-entry-state="rise"] .entry-folds, :root[data-entry-state="out"] .entry-folds { opacity: 0; pointer-events: none; }
:root[data-entry-state="init"] :is(.entry-prompt, .entry-type, .entry-msg, .entry-breath),
:root[data-entry-state="rise"] :is(.entry-prompt, .entry-type, .entry-msg, .entry-breath),
:root[data-entry-state="out"] :is(.entry-prompt, .entry-type, .entry-msg, .entry-breath) { opacity: 0; transition: opacity 0.3s ease; }
:root[data-entry-axis="x"]:is([data-entry-state="init"], [data-entry-state="rise"], [data-entry-state="out"]) .entry-portal { transform: rotateX(90deg); }
:root[data-entry-axis="z"]:is([data-entry-state="init"], [data-entry-state="rise"], [data-entry-state="out"]) .entry-portal { transform: rotate(90deg); }
:root:is([data-entry-state="init"], [data-entry-state="rise"], [data-entry-state="out"]) .entry-mark {
    filter: drop-shadow(0 0 26px rgba(94, 213, 213, 0.8)) drop-shadow(0 0 10px rgba(155, 109, 214, 0.8));
}
:root:is([data-entry-state="rise"], [data-entry-state="out"]) .entry-avatar { opacity: 1; transform: translate(-50%, 0) scale(1); }
:root[data-entry-state="out"] .entry { opacity: 0; }

/* Reduced motion: no turning, no rising; a short crossfade only. */
:root[data-motion="reduce"] .entry-portal, :root[data-motion="reduce"] .entry-avatar { transition: none; }
:root[data-motion="reduce"]:is([data-entry-state="init"], [data-entry-state="rise"], [data-entry-state="out"]) .entry-portal { transform: none; }
:root[data-motion="reduce"]:is([data-entry-state="rise"], [data-entry-state="out"]) .entry-avatar { transform: translate(-50%, 0) scale(1); }
:root[data-motion="reduce"] .entry, :root[data-motion="reduce"][data-entry="on"] :is(.site-header, main, .footer) { transition-duration: 0.25s; }

@media (max-width: 640px) {
    .entry-stage { width: min(260px, 70vw); }
    .entry-skip { top: 0.75rem; right: 0.75rem; }
}
