/* ============================================
   ENARGEIA — 404: The Interdimensional Rift
   Dense central cluster. Spinning mandalas.
   No scrolling. Old web chaos.
   ============================================ */

html:has(.rift-page) {
    overflow: hidden;
}

.rift-page {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-family: 'Comic Sans MS', 'MedievalSharp', cursive;
    color: #f0e6ff;
}

/* --- Spinning mandalas in background --- */

.mandala {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}

.mandala-1 {
    width: clamp(400px, 50vw, 700px);
    height: clamp(400px, 50vw, 700px);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background:
        repeating-conic-gradient(
            from 0deg,
            rgba(168, 85, 247, 0.06) 0deg 10deg,
            transparent 10deg 20deg
        );
    animation: mandala-spin 60s linear infinite;
}

.mandala-2 {
    width: clamp(500px, 65vw, 900px);
    height: clamp(500px, 65vw, 900px);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background:
        repeating-conic-gradient(
            from 15deg,
            rgba(255, 126, 179, 0.04) 0deg 8deg,
            transparent 8deg 16deg
        );
    animation: mandala-spin 45s linear infinite reverse;
}

.mandala-3 {
    width: clamp(300px, 40vw, 550px);
    height: clamp(300px, 40vw, 550px);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background:
        repeating-conic-gradient(
            from 30deg,
            rgba(94, 234, 212, 0.05) 0deg 15deg,
            transparent 15deg 30deg
        );
    animation: mandala-spin 80s linear infinite;
}

/* Mandala ring borders */
.mandala::before,
.mandala::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    border: 1px solid;
    animation: inherit;
}

.mandala-1::before {
    inset: 10%;
    border-color: rgba(168, 85, 247, 0.08);
}

.mandala-1::after {
    inset: 25%;
    border-color: rgba(168, 85, 247, 0.05);
}

.mandala-2::before {
    inset: 15%;
    border-color: rgba(255, 126, 179, 0.06);
}

.mandala-2::after {
    inset: 35%;
    border-color: rgba(255, 126, 179, 0.04);
}

.mandala-3::before {
    inset: 8%;
    border-color: rgba(94, 234, 212, 0.07);
}

.mandala-3::after {
    inset: 20%;
    border-color: rgba(94, 234, 212, 0.04);
    animation-direction: reverse;
}

@keyframes mandala-spin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* --- Star dots in background --- */
.rift-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 10% 20%, #c4b5fd 50%, transparent 50%),
        radial-gradient(1px 1px at 40% 70%, #ff7eb3 50%, transparent 50%),
        radial-gradient(1px 1px at 70% 30%, #5eead4 50%, transparent 50%),
        radial-gradient(1px 1px at 90% 80%, #fde68a 50%, transparent 50%),
        radial-gradient(1px 1px at 25% 50%, #d946ef 50%, transparent 50%),
        radial-gradient(1px 1px at 55% 15%, #818cf8 50%, transparent 50%),
        radial-gradient(1px 1px at 80% 45%, #fca5a5 50%, transparent 50%);
    background-size: 200px 200px;
    z-index: 0;
}

/* --- Top marquee --- */
.rift-marquee-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    padding: 2px 0;
    font-size: 0.55rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    background: linear-gradient(90deg, #a855f7, #ff7eb3, #5eead4, #fde68a, #a855f7);
    background-size: 300% 100%;
    animation: shimmer 4s linear infinite;
    color: #000;
    font-weight: bold;
    z-index: 50;
}

.rift-marquee-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    padding: 2px 0;
    font-size: 0.55rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    background: linear-gradient(90deg, #ff7eb3, #fde68a, #5eead4, #c4b5fd, #ff7eb3);
    background-size: 300% 100%;
    animation: shimmer 6s linear infinite reverse;
    color: #000;
    font-weight: bold;
    z-index: 50;
}

.marquee-scroll {
    display: inline-block;
    animation: marquee-scroll 12s linear infinite;
}

@keyframes marquee-scroll {
    0% { transform: translateX(100vw); }
    100% { transform: translateX(-100%); }
}

/* ============================================
   THE CLUSTER — one dense central object
   Everything lives inside this.
   ============================================ */

.rift-cluster {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: clamp(340px, 50vw, 520px);
    transform: rotate(-0.5deg);
}

/* --- Outer decorative frame (triple border chaos) --- */
.rift-outer-frame {
    border: 3px solid #a855f7;
    outline: 3px dashed #ff7eb3;
    outline-offset: 4px;
    box-shadow:
        0 0 15px rgba(168, 85, 247, 0.4),
        0 0 40px rgba(168, 85, 247, 0.15),
        0 0 80px rgba(255, 126, 179, 0.08),
        inset 0 0 20px rgba(168, 85, 247, 0.1);
    background: rgba(5, 2, 10, 0.92);
    padding: clamp(0.6rem, 2vw, 1.2rem);
    position: relative;
}

/* Spinning corner decorations */
.rift-outer-frame::before,
.rift-outer-frame::after {
    content: '✦';
    position: absolute;
    font-size: 1rem;
    animation: corner-spin 4s linear infinite;
    z-index: 20;
}
.rift-outer-frame::before { top: -7px; left: -7px; color: #ff7eb3; }
.rift-outer-frame::after { bottom: -7px; right: -7px; color: #5eead4; animation-direction: reverse; }

@keyframes corner-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Additional corner symbols via extra elements */
.rift-corner { position: absolute; font-size: 1rem; animation: corner-spin 5s linear infinite; z-index: 20; }
.rift-corner-tr { top: -7px; right: -7px; color: #fde68a; animation-direction: reverse; }
.rift-corner-bl { bottom: -7px; left: -7px; color: #d946ef; }

/* --- 404 title --- */
.rift-404 {
    font-family: 'Uncial Antiqua', serif;
    font-size: clamp(3.5rem, 10vw, 6rem);
    line-height: 1;
    text-align: center;
    background: linear-gradient(
        135deg, #ff7eb3, #c4b5fd, #5eead4, #fde68a, #ff7eb3, #c4b5fd
    );
    background-size: 300% 300%;
    animation: shimmer 3s ease-in-out infinite, rift-throb 2s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 15px rgba(168, 85, 247, 0.5));
    margin-bottom: 0.2rem;
}

@keyframes rift-throb {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 15px rgba(168, 85, 247, 0.5));
    }
    50% {
        transform: scale(1.02);
        filter: drop-shadow(0 0 25px rgba(168, 85, 247, 0.7))
               drop-shadow(0 0 50px rgba(255, 126, 179, 0.2));
    }
}

/* --- Subtitle --- */
.rift-subtitle {
    font-family: 'Uncial Antiqua', serif;
    font-size: clamp(0.7rem, 1.8vw, 0.9rem);
    color: #d946ef;
    text-shadow: 0 0 8px rgba(217, 70, 239, 0.5), 1px 1px 0 #1a0a2e;
    text-align: center;
    letter-spacing: 0.08em;
}

/* --- Rainbow bar --- */
.rift-rainbow {
    height: 3px;
    width: 100%;
    background: linear-gradient(
        90deg, #ff0000, #ff7700, #ffff00, #00ff00,
        #00ffff, #0000ff, #8800ff, #ff00ff, #ff0000
    );
    background-size: 200% 100%;
    animation: rainbow-scroll 2s linear infinite;
    margin: 0.4rem 0;
}

@keyframes rainbow-scroll {
    from { background-position: 0% 0%; }
    to { background-position: 200% 0%; }
}

/* --- Blink text --- */
.rift-blink {
    animation: old-blink 1s step-end infinite;
    color: #fca5a5;
    font-weight: bold;
    font-size: clamp(0.6rem, 1.3vw, 0.75rem);
    text-shadow: 0 0 5px rgba(252, 165, 165, 0.4);
    text-align: center;
}

@keyframes old-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* --- Iridescent divider --- */
.rift-hr {
    border: none;
    height: 1px;
    background: linear-gradient(
        90deg, transparent, #ff7eb3, #c4b5fd, #5eead4, transparent
    );
    margin: 0.3rem 0;
    animation: shimmer 5s linear infinite;
    background-size: 300% 100%;
    width: 100%;
}

/* --- Middle content area --- */
.rift-content {
    display: flex;
    gap: clamp(0.4rem, 1vw, 0.8rem);
    align-items: stretch;
    width: 100%;
    margin: 0.3rem 0;
}

/* Vortex on the left */
.rift-vortex-col {
    flex: 0 0 clamp(70px, 10vw, 100px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.rift-vortex {
    width: clamp(60px, 9vw, 90px);
    height: clamp(60px, 9vw, 90px);
    position: relative;
}

.rift-ring {
    position: absolute;
    inset: 0;
    border: 1.5px solid transparent;
    border-radius: 50%;
    animation: vortex-spin 6s linear infinite;
}
.rift-ring:nth-child(1) { border-top-color: #ff7eb3; border-bottom-color: #ff7eb3; animation-duration: 3s; }
.rift-ring:nth-child(2) { inset: 8px; border-left-color: #c4b5fd; border-right-color: #c4b5fd; animation-duration: 4s; animation-direction: reverse; }
.rift-ring:nth-child(3) { inset: 16px; border-top-color: #5eead4; border-bottom-color: #5eead4; animation-duration: 2.5s; }
.rift-ring:nth-child(4) { inset: 24px; border-left-color: #fde68a; border-right-color: #fde68a; animation-duration: 5s; animation-direction: reverse; }
.rift-ring:nth-child(5) { inset: 30px; border-top-color: #d946ef; border-bottom-color: #d946ef; animation-duration: 2s; }

.rift-vortex-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9rem;
    animation: old-blink 0.8s step-end infinite;
    color: #fde68a;
    text-shadow: 0 0 8px rgba(253, 230, 138, 0.6);
}

@keyframes vortex-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Text on the right */
.rift-text-col {
    flex: 1;
    font-size: clamp(0.6rem, 1.2vw, 0.75rem);
    line-height: 1.5;
}

.rift-text-col em {
    color: #c4b5fd;
    font-style: normal;
    text-shadow: 0 0 5px rgba(196, 181, 253, 0.3);
}

/* --- Construction banner --- */
.rift-construction {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    font-size: clamp(0.5rem, 1vw, 0.6rem);
    color: #fde68a;
    width: 100%;
    text-align: center;
}

.rift-construction-icon {
    display: inline-block;
    animation: construction-flash 0.6s ease-in-out infinite alternate;
}

@keyframes construction-flash {
    0% { color: #fde68a; transform: rotate(-10deg); }
    100% { color: #f97316; transform: rotate(10deg); }
}

/* --- Buttons — BIG and OBVIOUS --- */
.rift-choices {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    margin: 0.3rem 0;
}

.rift-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.5rem 1rem;
    font-family: 'MedievalSharp', cursive;
    font-size: clamp(0.85rem, 2vw, 1.05rem);
    border: 2px solid;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.08em;
}

.rift-btn-escape {
    color: #5eead4;
    border-color: #5eead4;
    background: rgba(94, 234, 212, 0.08);
    text-shadow: 0 0 8px rgba(94, 234, 212, 0.4);
    font-weight: bold;
}

.rift-btn-escape:hover {
    background: rgba(94, 234, 212, 0.2);
    box-shadow: 0 0 15px rgba(94, 234, 212, 0.4), 0 0 30px rgba(94, 234, 212, 0.15);
    transform: scale(1.03);
}

.rift-btn-surrender {
    color: #ff7eb3;
    border-color: #ff7eb3;
    background: rgba(255, 126, 179, 0.08);
    text-shadow: 0 0 8px rgba(255, 126, 179, 0.4);
    font-size: clamp(0.75rem, 1.6vw, 0.9rem);
}

.rift-btn-surrender:hover {
    background: rgba(255, 126, 179, 0.2);
    box-shadow: 0 0 15px rgba(255, 126, 179, 0.4), 0 0 30px rgba(255, 126, 179, 0.15);
    transform: scale(1.03);
}

/* --- Counter --- */
.rift-counter {
    font-family: 'Courier New', monospace;
    font-size: 0.55rem;
    color: #8a8098;
    text-align: center;
    margin-top: 0.2rem;
}

.rift-counter span {
    background: #1a0f2e;
    border: 1px inset #8a8098;
    padding: 1px 4px;
    font-weight: bold;
    color: #5eead4;
}

/* --- Floating debris OUTSIDE the cluster --- */
.debris {
    position: absolute;
    pointer-events: none;
    z-index: 5;
    user-select: none;
}

.debris-text {
    font-family: 'Courier New', monospace;
    font-size: 0.55rem;
    opacity: 0.15;
    white-space: nowrap;
}

.debris-symbol {
    font-size: clamp(0.8rem, 2vw, 1.5rem);
    opacity: 0.12;
    animation: debris-pulse 4s ease-in-out infinite alternate;
}

@keyframes debris-pulse {
    0% { opacity: 0.06; }
    100% { opacity: 0.2; }
}

/* Floating glitch text from JS */
.rift-glitch-float {
    position: fixed;
    font-family: 'Courier New', monospace;
    font-size: 0.55rem;
    opacity: 0.1;
    pointer-events: none;
    white-space: nowrap;
    color: #c4b5fd;
    z-index: 2;
}

/* Broken image icons scattered around */
.rift-broken-img {
    position: absolute;
    width: clamp(25px, 3vw, 40px);
    height: clamp(25px, 3vw, 40px);
    border: 1px solid rgba(138, 128, 152, 0.4);
    background: rgba(26, 15, 46, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    pointer-events: none;
}
.rift-broken-img::before {
    content: '✕';
    font-size: 0.9rem;
    color: #fca5a5;
    opacity: 0.4;
}

/* --- Responsive: tighten up on small screens --- */
@media (max-width: 500px) {
    .rift-cluster {
        max-width: 92vw;
    }

    .rift-content {
        flex-direction: column;
        align-items: center;
    }

    .rift-vortex-col {
        flex: 0 0 auto;
    }
}