.entry-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s var(--transition-smooth), visibility 0.6s;
    isolation: isolate;
}

body.entry-active .wrapper,
body.entry-active .theme-toggle,
body.entry-active .project-preview-modal {
    visibility: hidden;
}

.entry-screen-grain {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 999;
    pointer-events: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 150px 150px;
    will-change: transform, opacity;
    opacity: var(--noise-opacity);
    animation: grainPulse 8s ease-in-out infinite;
    transition: opacity 0.3s var(--transition-smooth);
}

.entry-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.entry-container {
    text-align: center;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.slide-button-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.slide-button-container {
    width: 12rem;
    height: 2.25rem;
    background: #ffffff;
    border-radius: 9999px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: visible;
}

.slide-button-container.completed {
    width: 8rem;
}

.slide-button-track {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: #3f3f46;
    border-radius: 9999px;
    width: 0;
    z-index: 0;
    pointer-events: none;
    will-change: width;
}

:root[data-theme="light"] .slide-button-track {
    background: #f3f4f6;
}

.slide-button-container.completed .slide-button-track {
    display: none;
}

.slide-button-handle {
    position: absolute;
    left: -1rem;
    top: 50%;
    margin-top: -1.25rem;
    width: 2.5rem;
    height: 2.5rem;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    will-change: transform;
}

/* Expand the drag handle's touch target to >=44px without changing its look */
.slide-button-handle::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
}

.slide-button-handle svg {
    width: 1rem;
    height: 1rem;
    color: #1a1a1a;
    pointer-events: none;
}

.slide-button-container.completed .slide-button-handle {
    display: none;
}

.slide-button-status {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5;
    border-radius: 9999px;
}

.slide-button-container.completed .slide-button-status {
    display: flex;
}

.slide-button-status-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: #1a1a1a;
    animation: statusAppear 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.slide-button-status-icon.loading {
    animation: spin 1s linear infinite;
}

@keyframes statusAppear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@media (pointer: coarse) {
    .slide-button-handle {
        cursor: auto;
    }

    .slide-button-handle:active {
        cursor: auto;
    }
}

@keyframes grainPulse {

    0%,
    100% {
        opacity: var(--noise-opacity);
    }

    50% {
        opacity: calc(var(--noise-opacity) * 1.5);
    }
}

@media (max-width: 640px) {
    .slide-button-container {
        width: 10rem;
    }

    .slide-button-container.completed {
        width: 6rem;
    }
}

/* Entry hint — tells the visitor the gate is a slider without killing the ritual */
.entry-hint {
    margin: 1.6rem 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55em;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
    opacity: 0;
    transition: opacity 0.4s var(--transition-smooth), transform 0.4s var(--transition-smooth);
    animation: entryHintIn 0.8s var(--transition-smooth) 1.1s forwards;
    user-select: none;
    -webkit-user-select: none;
}

.entry-hint__label {
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    /* cancel the trailing tracking so the arrow sits at an even optical gap */
    margin-right: -0.16em;
}

.entry-hint__arrow {
    flex: none;
    color: var(--muted);
    animation: entryHintArrow 1.8s var(--transition-smooth) infinite;
}

.entry-hint.is-hidden {
    opacity: 0 !important;
    transform: translateY(-4px);
    animation: none;
    pointer-events: none;
}

@keyframes entryHintIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 0.9; transform: translateY(0); }
}

@keyframes entryHintArrow {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(3px); }
}

/* Pulsing ring signals the handle is interactive (the native cursor is hidden) */
.slide-button-container:not(.completed) .slide-button-handle {
    animation: entryHandlePulse 2.4s var(--transition-smooth) infinite;
}

@keyframes entryHandlePulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50%      { box-shadow: 0 0 0 9px rgba(244, 146, 240, 0); }
}

/* Keyboard focus affordance — must be visible since body cursor is hidden */
.slide-button-container:not(.completed) .slide-button-handle:focus-visible {
    outline: none;
    animation: none;
    box-shadow: 0 0 0 3px var(--accent-glow), 0 0 0 1px var(--accent);
}

@media (prefers-reduced-motion: reduce) {
    .entry-hint {
        animation: none;
        opacity: 0.9;
    }

    .entry-hint__arrow,
    .slide-button-container:not(.completed) .slide-button-handle {
        animation: none;
    }
}

/* ───────────────────────────────────────────────
   No-JS fallback — the hub's core (links, projects,
   navigation) must stay usable without JavaScript:
   disabled, blocked, crawler, or CDN failure.
   `.js` is set synchronously in <head>; these rules
   apply only when it is absent, so JS users never
   see a flash.
   ─────────────────────────────────────────────── */
html:not(.js) .entry-screen {
    display: none;
}

html:not(.js) body.entry-active .wrapper,
html:not(.js) body.entry-active .theme-toggle,
html:not(.js) body.entry-active .project-preview-modal {
    visibility: visible;
}

/* Connect links are hidden-by-default for the JS reveal; show them when no JS runs */
html:not(.js) .link-card {
    opacity: 1;
    visibility: visible;
    transform: none;
}

/* Projects are JS-positioned (masonry); fall back to a clean single column */
html:not(.js) .projects-row {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

html:not(.js) .projects-row > li {
    position: relative;
    width: 100%;
}

/* These sections are populated by JS (playlists injected, Spotify fetched).
   Without JS they would sit empty or stuck on "Loading…" — hide them so the
   no-JS view shows only real content (links, projects, static stats, footer). */
html:not(.js) .playlists-section,
html:not(.js) .spotify-widget-container {
    display: none;
}

/* Restore a real cursor whenever the custom one is not proven active
   (no JS, coarse pointer, or a failed cursor init) */
body:not(.has-custom-cursor),
body:not(.has-custom-cursor) a,
body:not(.has-custom-cursor) button,
body:not(.has-custom-cursor) .project-card,
body:not(.has-custom-cursor) .theme-toggle,
body:not(.has-custom-cursor) .slide-button-handle {
    cursor: auto;
}
