
/* =========================================
   THE FORGOTTEN LIBRARY
   Cinematic 404 Experience
   ========================================= */

:root {
    --bg: #100d0a;
    --wood: #302016;
    --wood-light: #59402b;
    --gold: #c3a16b;
    --cream: #e5d9bd;
    --muted: #a69a83;
    --font: "Vazirmatn", Tahoma, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--cream);
    font-family: var(--font);
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: 0;
}

/* Main scene */

.scene {
    position: relative;
    isolation: isolate;
    width: 100%;
    min-height: 100vh;
    min-height: 100svh;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 50% 40%,
            #392819 0%, #1b1510 40%, #0b0908 100%);
}

.background {
    position: absolute;
    inset: 0;
    z-index: -5;
    background:
        linear-gradient(90deg,
            rgba(0,0,0,.65),
            transparent 30%,
            transparent 70%,
            rgba(0,0,0,.65)),
        linear-gradient(180deg,
            rgba(0,0,0,.2),
            transparent 45%,
            #090706 100%);
}

.ambient-glow {
    position: absolute;
    z-index: -3;
    width: 650px;
    height: 500px;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(195,161,107,.11);
    filter: blur(110px);
}

/* Library architecture */

.library {
    position: absolute;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.ceiling {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 15%;
    background: linear-gradient(
        180deg, #090706, #21170f 80%, transparent
    );
    opacity: .9;
}

/* Arch window */

.arch-window {
    position: absolute;
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: min(280px, 28vw);
    height: 49%;
    border: 7px solid #39291c;
    border-bottom: 0;
    border-radius: 150px 150px 0 0;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 50% 25%,
            rgba(215,196,153,.8),
            rgba(137,137,117,.25) 38%,
            rgba(29,34,32,.9) 80%);
    box-shadow:
        0 0 35px rgba(199,173,119,.12),
        inset 0 0 30px rgba(0,0,0,.6);
}

.window-glow {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(227,214,174,.22),
        transparent 75%
    );
}

.window-cross {
    position: absolute;
    background: rgba(54,39,26,.8);
}

.window-cross.vertical {
    width: 5px;
    height: 100%;
    left: 50%;
}

.window-cross.horizontal {
    height: 5px;
    width: 100%;
    top: 43%;
}

/* Bookshelves */

.bookshelf {
    position: absolute;
    top: 12%;
    width: 24%;
    height: 68%;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 15px 12px;
    background:
        linear-gradient(90deg,
            #120c08, #392619 15%, #20150e 90%, #0b0806);
    border: 5px solid #20150e;
    box-shadow:
        inset 0 0 30px rgba(0,0,0,.7),
        0 10px 35px rgba(0,0,0,.5);
}

.shelf-left {
    left: -2%;
    transform: perspective(500px) rotateY(8deg);
}

.shelf-right {
    right: -2%;
    transform: perspective(500px) rotateY(-8deg);
}

.shelf-row {
    position: relative;
    height: 27%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    padding: 0 4px 7px;
    border-bottom: 9px solid #493321;
    box-shadow: 0 5px 8px rgba(0,0,0,.5);
}

.shelf-row i {
    display: block;
    width: 12%;
    height: 75%;
    border-radius: 2px 2px 0 0;
    background: #66442b;
    box-shadow: inset 2px 0 rgba(255,255,255,.08);
}

.shelf-row i:nth-child(2n) {
    height: 88%;
    background: #34251c;
}

.shelf-row i:nth-child(3n) {
    height: 65%;
    background: #795637;
}

.shelf-row i:nth-child(4n) {
    background: #49382a;
}

.shelf-row i:nth-child(5n) {
    height: 82%;
    background: #26302b;
}

/* Central portal */

.central-portal {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    height: 230px;
    opacity: .7;
}

.portal-frame {
    position: absolute;
    inset: 0;
    border: 5px solid rgba(191,154,94,.6);
    border-bottom: 0;
    border-radius: 90px 90px 0 0;
    box-shadow:
        0 0 15px rgba(208,165,97,.3),
        inset 0 0 15px rgba(208,165,97,.1);
}

.portal-inner {
    position: absolute;
    inset: 12px 12px 0;
    border-radius: 80px 80px 0 0;
    background: linear-gradient(
        180deg,
        rgba(222,189,129,.22),
        rgba(121,83,42,.05)
    );
}

.portal-light {
    position: absolute;
    width: 220px;
    height: 220px;
    left: 50%;
    top: 20px;
    transform: translateX(-50%);
    background: rgba(220,176,108,.16);
    filter: blur(55px);
    animation: portalPulse 6s ease-in-out infinite;
}

/* Floor */

.library-floor {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30%;
    background:
        repeating-linear-gradient(
            90deg,
            transparent 0 115px,
            rgba(173,128,76,.08) 116px 118px
        ),
        linear-gradient(
            180deg,
            #21170f,
            #100c09 50%,
            #080605
        );
    clip-path: polygon(18% 0,82% 0,100% 100%,0 100%);
    opacity: .85;
}

.library-floor::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(196,157,99,.22);
    box-shadow: 0 0 25px rgba(196,157,99,.15);
}

/* Floating books */

.floating-books {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.book {
    position: absolute;
    width: 43px;
    height: 57px;
    border: 2px solid rgba(210,177,126,.45);
    border-radius: 3px 6px 6px 3px;
    background: linear-gradient(90deg,#39251a,#775337);
    box-shadow: 5px 8px 20px rgba(0,0,0,.5);
    animation: bookFloat 8s ease-in-out infinite;
}

.book::after {
    content: "";
    position: absolute;
    top: 5px;
    bottom: 5px;
    left: 5px;
    width: 2px;
    background: rgba(226,201,157,.35);
}

.book-one {
    top: 32%;
    left: 30%;
    transform: rotate(-18deg);
}

.book-two {
    top: 51%;
    right: 27%;
    width: 32px;
    height: 44px;
    background: linear-gradient(90deg,#25302a,#56634c);
    animation-delay: -2s;
}

.book-three {
    top: 22%;
    right: 17%;
    width: 26px;
    height: 37px;
    animation-delay: -4s;
}

.book-four {
    top: 63%;
    left: 18%;
    width: 29px;
    height: 40px;
    background: linear-gradient(90deg,#29211a,#62402b);
    animation-delay: -1s;
}

.book-five {
    top: 39%;
    right: 38%;
    width: 24px;
    height: 34px;
    animation-delay: -5s;
}

/* Candles */

.candle {
    position: absolute;
    bottom: 18%;
    z-index: 2;
    width: 22px;
    height: 75px;
}

.candle-left {
    left: 12%;
}

.candle-right {
    right: 12%;
}

.candle-body {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 65px;
    border-radius: 3px;
    background: linear-gradient(
        90deg,#8b7048,#e0c58e,#90754c
    );
    box-shadow: 0 0 25px rgba(214,173,104,.15);
}

.flame {
    position: absolute;
    top: -19px;
    left: 7px;
    width: 9px;
    height: 20px;
    border-radius: 70% 30% 60% 40%;
    background: #f3c36f;
    box-shadow:
        0 0 10px #f3c36f,
        0 0 30px rgba(241,171,76,.7);
    transform-origin: bottom center;
    animation: flameFlicker .8s ease-in-out infinite alternate;
}

/* Particles and mist */

.particles {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: rgba(231,204,153,.8);
    box-shadow: 0 0 7px rgba(231,204,153,.5);
    animation: particleRise var(--duration) linear infinite;
}

.mist {
    position: absolute;
    z-index: 2;
    width: 65%;
    height: 120px;
    bottom: 14%;
    border-radius: 50%;
    background: rgba(183,166,137,.06);
    filter: blur(45px);
    pointer-events: none;
}

.mist-one {
    left: -10%;
    animation: mistMove 25s ease-in-out infinite alternate;
}

.mist-two {
    right: -10%;
    bottom: 28%;
    animation: mistMove 30s ease-in-out infinite alternate-reverse;
}

/* Content */

.content {
    position: relative;
    z-index: 4;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 34px clamp(25px,7vw,105px) 27px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    font-family: Arial,sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 3px;
    color: #d6c5a4;
}

.brand-symbol {
    color: var(--gold);
    font-size: 19px;
}

.topbar-label {
    font-family: Arial,sans-serif;
    font-size: 9px;
    letter-spacing: 2px;
    color: rgba(207,188,153,.5);
}

/* Message */

.message {
    width: min(510px,100%);
    margin-right: auto;
    text-align: right;
    animation: revealContent 1.2s ease both;
}

.eyebrow {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    color: #c4a77b;
    font-size: 12px;
}

.eyebrow-line {
    width: 23px;
    height: 1px;
    background: var(--gold);
    opacity: .7;
}

.error-code {
    font-family: Georgia,Arial,sans-serif;
    font-size: clamp(110px,16vw,175px);
    font-weight: 700;
    line-height: .9;
    letter-spacing: -9px;
    color: #e2d6bd;
    text-shadow:
        0 0 35px rgba(222,194,145,.15),
        0 10px 35px rgba(0,0,0,.6);
}

.title {
    margin-top: 20px;
    font-size: clamp(20px,3vw,27px);
    font-weight: 600;
    color: #e5d9c1;
}

.description {
    max-width: 440px;
    margin-top: 13px;
    font-size: 13px;
    line-height: 2.3;
    font-weight: 300;
    color: #b3a58d;
}

/* Buttons */

.actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 11px;
    margin-top: 25px;
}

.btn {
    min-height: 46px;
    padding: 0 19px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-radius: 2px;
    font-size: 12px;
    transition: .3s ease;
}

.btn-primary {
    background: #c3a16b;
    color: #17100a;
    font-weight: 600;
}

.btn-primary:hover {
    background: #dec18c;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(195,161,107,.2);
}

.btn-arrow {
    font-size: 17px;
    transition: transform .3s ease;
}

.btn-primary:hover .btn-arrow {
    transform: translateX(-4px);
}

.btn-secondary {
    color: #d3c3a5;
    border: 1px solid rgba(195,161,107,.3);
    background: rgba(255,255,255,.025);
}

.btn-secondary:hover {
    background: rgba(195,161,107,.1);
    border-color: rgba(195,161,107,.6);
    transform: translateY(-3px);
}

/* Footer */

.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    color: rgba(194,177,146,.55);
    font-size: 10px;
}

.footer-mark {
    font-family: Arial,sans-serif;
    font-size: 9px;
    letter-spacing: 2px;
    color: rgba(194,177,146,.35);
}

/* Vignette */

.vignette {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    box-shadow:
        inset 0 0 150px rgba(0,0,0,.65),
        inset 0 -80px 100px rgba(0,0,0,.6);
}

/* Animations */

@keyframes bookFloat {
    0%,100% {
        translate: 0 0;
        rotate: 0deg;
    }
    50% {
        translate: 0 -17px;
        rotate: 5deg;
    }
}

@keyframes flameFlicker {
    from { transform: rotate(-7deg) scaleY(.95); }
    to { transform: rotate(8deg) scaleY(1.08); }
}

@keyframes particleRise {
    from {
        transform: translateY(25px);
        opacity: 0;
    }
    15% { opacity: .8; }
    85% { opacity: .45; }
    to {
        transform: translateY(-130px);
        opacity: 0;
    }
}

@keyframes portalPulse {
    0%,100% { opacity: .5; scale: .9; }
    50% { opacity: 1; scale: 1.1; }
}

@keyframes mistMove {
    from { transform: translateX(-5%); }
    to { transform: translateX(18%); }
}

@keyframes revealContent {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tablet */

@media (max-width: 900px) {
    .content {
        padding: 28px 35px 23px;
    }

    .message {
        width: min(460px,65%);
    }

    .bookshelf {
        width: 27%;
    }

    .arch-window {
        width: 240px;
    }

    .central-portal {
        transform: translateX(-50%) scale(.85);
        transform-origin: top center;
    }
}

/* Mobile */

@media (max-width: 600px) {
    body {
        overflow: auto;
    }

    .content {
        min-height: 100vh;
        min-height: 100svh;
        padding: 20px 17px 18px;
    }

    .brand {
        font-size: 8px;
        letter-spacing: 1.5px;
        gap: 6px;
    }

    .brand-symbol {
        font-size: 16px;
    }

    .topbar-label {
        font-size: 7px;
        letter-spacing: 1px;
    }

    .arch-window {
        top: 10%;
        width: 180px;
        height: 38%;
        border-width: 5px;
    }

    .bookshelf {
        top: 17%;
        width: 28%;
        height: 57%;
        padding: 8px 5px;
        border-width: 3px;
    }

    .shelf-row {
        gap: 2px;
        padding: 0 2px 5px;
        border-bottom-width: 6px;
    }

    .shelf-row i {
        width: 13%;
    }

    .central-portal {
        top: 36%;
        transform: translateX(-50%) scale(.65);
        transform-origin: top center;
    }

    .book {
        width: 30px;
        height: 41px;
    }

    .book-one { left: 29%; top: 32%; }
    .book-two { right: 25%; top: 50%; }
    .book-three { right: 15%; top: 25%; }
    .book-four { left: 17%; top: 61%; }
    .book-five { right: 35%; top: 41%; }

    .candle {
        bottom: 16%;
        transform: scale(.75);
    }

    .candle-left { left: 8%; }
    .candle-right { right: 8%; }

    .library-floor {
        height: 24%;
    }

    .message {
        width: 100%;
        margin: 0;
        text-align: center;
    }

    .eyebrow {
        justify-content: center;
        font-size: 10px;
        gap: 7px;
    }

    .eyebrow-line {
        width: 16px;
    }

    .error-code {
        font-size: clamp(82px,23vw,112px);
        letter-spacing: -5px;
    }

    .title {
        margin-top: 13px;
        font-size: clamp(17px,4.5vw,21px);
        line-height: 1.8;
    }

    .description {
        max-width: 350px;
        margin: 9px auto 0;
        padding: 0 4px;
        font-size: 11px;
        line-height: 2.1;
    }

    .actions {
        justify-content: center;
        gap: 8px;
        margin-top: 17px;
    }

    .btn {
        min-height: 41px;
        padding: 0 12px;
        gap: 8px;
        font-size: 10px;
    }

    .footer {
        flex-direction: column;
        justify-content: center;
        text-align: center;
        gap: 7px;
        font-size: 8px;
    }

    .footer-mark {
        font-size: 8px;
        letter-spacing: 1.3px;
    }

    .mist {
        height: 80px;
    }
}

/* Small phones */

@media (max-width: 380px) {
    .content {
        padding-right: 13px;
        padding-left: 13px;
    }

    .topbar-label {
        display: none;
    }

    .error-code {
        font-size: 80px;
    }

    .title {
        font-size: 17px;
    }

    .description {
        font-size: 10px;
    }

    .actions {
        gap: 7px;
    }

    .btn {
        padding: 0 10px;
        font-size: 9px;
    }
}

/* Reduced motion */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
