/* ============================================
   START SCREEN - Closed Leather Notebook
   Premium leather-bound journal aesthetic
   ============================================ */

/* === Overlay Container === */
.start-screen {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--wood-dark);
    z-index: 30000;
    transition: opacity 0.8s ease-out, visibility 0.8s ease-out;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
}

.start-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Wood table texture background */
.start-screen::before {
    content: '';
    position: absolute;
    inset: -10%;
    /* Larger to allow for parallax movement */
    background:
        url('../img/fantasy_table_bg.png') center/cover,
        radial-gradient(circle at 50% 50%, #2a1a0a 0%, #0a0603 100%);
    background-blend-mode: multiply;
    opacity: 1;
    transform: translate(calc(var(--mouseX, 0) * -30px),
            calc(var(--mouseY, 0) * -30px));
    transition: transform 0.1s ease-out;
}

/* Atmospheric lighting & Vignette */
.start-screen::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at calc(50% + var(--mouseX, 0) * 80px) calc(40% + var(--mouseY, 0) * 80px),
            rgba(255, 180, 80, 0.12) 0%,
            rgba(0, 0, 0, 0.4) 60%,
            rgba(0, 0, 0, 0.8) 100%),
        /* Floating dust spec simulation */
        radial-gradient(circle at 20% 30%, rgba(255, 200, 150, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 80% 70%, rgba(200, 150, 100, 0.03) 0%, transparent 30%);
    pointer-events: none;
    z-index: 2;
    animation: lanternFlicker 4s ease-in-out infinite;
}

/* Lantern illumination flicker */
@keyframes lanternFlicker {

    0%,
    100% {
        opacity: 0.8;
    }

    33% {
        opacity: 0.85;
    }

    66% {
        opacity: 0.75;
    }
}

/* === The Closed Notebook === */
.notebook-wrapper {
    position: relative;
    z-index: 1;
    perspective: 1500px;
    cursor: default;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    max-height: 100%;
    padding-left: 10px;
    /* Slight offset for optical centering due to perspective */
}

.notebook-closed {
    position: relative;
    width: clamp(280px, 50vw, 360px);
    height: clamp(360px, 55vh, 460px);
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    animation: notebookFloat 4s ease-in-out infinite;
    flex-shrink: 0;
    cursor: pointer;
}

@keyframes notebookFloat {

    0%,
    100% {
        transform: translateY(0) rotateX(2deg) rotateY(-5deg);
    }

    50% {
        transform: translateY(-6px) rotateX(0deg) rotateY(-3deg);
    }
}

.notebook-closed:hover {
    transform: translateY(-8px) rotateX(0deg) rotateY(0deg) scale(1.02);
    animation: none;
}

/* === Front Cover === */
.notebook-cover {
    position: absolute;
    inset: 0;
    background:
        /* Leather grain texture */
        url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.12'/%3E%3C/svg%3E"),
        /* Main leather gradient */
        linear-gradient(165deg,
            #5c3d1e 0%,
            #4a3016 15%,
            #3d2815 40%,
            #2a1a0a 70%,
            #1a0f08 100%);
    border-radius: 8px 20px 20px 8px;
    box-shadow:
        /* 3D depth */
        0 30px 60px rgba(0, 0, 0, 0.7),
        0 15px 30px rgba(0, 0, 0, 0.5),
        /* Spine shadow */
        inset 30px 0 40px -20px rgba(0, 0, 0, 0.6),
        /* Top light reflection */
        inset 0 2px 0 rgba(255, 255, 255, 0.08),
        /* Pages visible on right edge */
        4px 0 0 #e8ddd0,
        5px 0 0 #d6cab0,
        6px 0 0 #c4b595,
        7px 0 0 #e8ddd0,
        8px 0 0 #d6cab0;
    transform-style: preserve-3d;
    transform: translateZ(15px);
}

/* Leather stitching border */
.notebook-cover::before {
    content: '';
    position: absolute;
    inset: 12px;
    border: 2px dashed rgba(92, 61, 30, 0.4);
    border-radius: 4px 14px 14px 4px;
    pointer-events: none;
}

/* Inner decorative frame */
.notebook-cover::after {
    content: '';
    position: absolute;
    inset: 24px;
    border: 1px solid rgba(212, 168, 75, 0.25);
    border-radius: 2px 10px 10px 2px;
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

/* === Spine Detail === */
.notebook-spine {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 40px;
    background:
        linear-gradient(90deg,
            #2a1a0a 0%,
            #3d2815 40%,
            #4a3016 60%,
            #3d2815 80%,
            #2a1a0a 100%);
    border-radius: 8px 0 0 8px;
    box-shadow:
        inset -10px 0 15px -5px rgba(0, 0, 0, 0.5),
        inset 5px 0 10px -3px rgba(255, 255, 255, 0.05);
}

/* Spine raised bands */
.notebook-spine::before {
    content: '';
    position: absolute;
    left: 8px;
    right: 8px;
    top: 60px;
    height: 4px;
    background: linear-gradient(180deg, #5c3d1e, #3d2815, #5c3d1e);
    border-radius: 2px;
    box-shadow:
        0 50px 0 0 #4a3016,
        0 100px 0 0 #4a3016,
        0 150px 0 0 #4a3016,
        0 200px 0 0 #4a3016,
        0 350px 0 0 #4a3016;
}

/* === Title Embossing === */
.notebook-title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 5;
    width: 85%;
    transition: transform 0.15s ease-out;
}

.title-main {
    font-family: 'Cinzel Decorative', 'Cinzel', serif;
    font-size: 2.4rem;
    font-weight: 700;
    color: transparent;
    background: linear-gradient(180deg,
            #d4a84b 0%,
            #f0d890 30%,
            #d4a84b 50%,
            #a67c30 80%,
            #7a5a20 100%);
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(212, 168, 75, 0.3);
    letter-spacing: 0.08em;
    line-height: 1.1;
    margin-bottom: 8px;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}

.title-sub {
    font-family: 'IM Fell English', serif;
    font-size: 0.95rem;
    font-style: italic;
    color: rgba(212, 168, 75, 0.7);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* === Decorative Corner Ornaments === */
.corner-ornament {
    position: absolute;
    width: 14px;
    height: 14px;
    pointer-events: none;
    background: linear-gradient(135deg,
            #b8860b 0%,
            #d4a84b 30%,
            #f0d890 50%,
            #d4a84b 70%,
            #8b6914 100%);
    border-radius: 50%;
    box-shadow:
        inset 0 1px 2px rgba(255, 255, 255, 0.5),
        0 2px 4px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s ease-out;
}

.corner-ornament.top-left {
    top: 30px;
    left: 55px;
}

.corner-ornament.top-right {
    top: 30px;
    right: 30px;
}

.corner-ornament.bottom-left {
    bottom: 30px;
    left: 55px;
}

.corner-ornament.bottom-right {
    bottom: 30px;
    right: 30px;
}

/* === Leather Clasp === */
.notebook-clasp {
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 65px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clasp-strap {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            #3d2815 0%,
            #5c3d1e 30%,
            #7a4f2a 50%,
            #5c3d1e 70%,
            #3d2815 100%);
    border-radius: 4px 8px 8px 4px;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

/* Strap texture lines */
.clasp-strap::before {
    content: '';
    position: absolute;
    inset: 8px 4px;
    background: repeating-linear-gradient(0deg,
            transparent 0px,
            transparent 6px,
            rgba(0, 0, 0, 0.15) 6px,
            rgba(0, 0, 0, 0.15) 7px);
    border-radius: 2px;
}

.clasp-buckle {
    position: relative;
    z-index: 2;
    width: 20px;
    height: 20px;
    background: linear-gradient(160deg,
            #d4a84b 0%,
            #f0d890 30%,
            #d4a84b 50%,
            #8b6914 100%);
    border-radius: 50%;
    box-shadow:
        0 3px 6px rgba(0, 0, 0, 0.5),
        inset 0 2px 3px rgba(255, 255, 255, 0.4),
        inset 0 -2px 3px rgba(0, 0, 0, 0.3);
}

.clasp-buckle::before {
    content: '✦';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    color: #5c3d1e;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* === Aged Patina Effects === */
.notebook-patina {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(255, 200, 100, 0.08) 0%, transparent 40%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 0, 0, 0.15) 0%, transparent 50%);
    border-radius: 8px 20px 20px 8px;
    pointer-events: none;
    z-index: 6;
}

/* === Click to Open Text === */
.click-prompt {
    position: relative;
    font-family: 'IM Fell English', serif;
    font-size: 1.1rem;
    font-style: italic;
    color: var(--gold-ornament);
    letter-spacing: 0.2em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 1);
    animation: promptPulse 2.5s ease-in-out infinite;
    white-space: nowrap;
    margin-top: 25px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.notebook-wrapper:hover .click-prompt {
    opacity: 1;
    color: var(--gold-highlight);
}

@keyframes promptPulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

.notebook-wrapper.opening .click-prompt {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out 0.5s;
    animation: none;
}

/* ============================================
   NOTEBOOK OPEN STATE - Input Page
   ============================================ */
.notebook-wrapper.opening .notebook-closed {
    animation: notebookOpen 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes notebookOpen {
    0% {
        transform: translateY(0) rotateX(2deg) rotateY(-5deg);
    }

    30% {
        transform: translateY(-30px) rotateX(0) rotateY(-90deg) scale(0.9);
    }

    60% {
        transform: translateY(-20px) rotateX(0) rotateY(-180deg) scale(0.85);
    }

    100% {
        transform: translateY(0) rotateX(0) rotateY(-180deg) scale(0);
        opacity: 0;
    }
}

/* === Open Notebook Page === */
.notebook-open {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: clamp(340px, 85vw, 420px);
    max-height: 85vh;
    overflow-y: auto;
    background:
        url('../img/parchment_bg.png') center/cover,
        linear-gradient(165deg, #fdfcf3 0%, #f5ebe0 50%, #e8dcc8 100%);
    background-blend-mode: multiply, normal;
    border-radius: 4px;
    padding: 50px 45px 50px 75px;
    /* Increased left padding for holes */
    box-shadow:
        /* Deep room shadow */
        0 40px 80px rgba(0, 0, 0, 0.7),
        /* Double stack shadow */
        -4px 4px 0 #d6cab0,
        -8px 8px 0 #c4b595,
        /* Inner binding crease */
        inset 30px 0 40px -20px rgba(0, 0, 0, 0.25),
        /* Top light catch */
        inset 0 1px 1px rgba(255, 255, 255, 0.8);
    opacity: 0;
    z-index: 10;
    pointer-events: none;

    /* Improved page edge shading instead of jagged clip-path */
    border: 1px solid rgba(0, 0, 0, 0.05);
    cursor: default;
}

/* Stains and texture */
.notebook-open::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        /* Coffee stain */
        radial-gradient(ellipse at 15% 85%, rgba(139, 90, 43, 0.08) 0%, transparent 40%),
        /* Ink spatter */
        radial-gradient(circle at 85% 15%, rgba(26, 18, 9, 0.05) 0%, transparent 20%),
        /* Paper fiber texture */
        url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1;
}

.notebook-wrapper.opening .notebook-open {
    animation: pageReveal 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.6s forwards;
    pointer-events: auto;
}

@keyframes pageReveal {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Page binding holes */
.notebook-open::before {
    content: '';
    position: absolute;
    left: 24px;
    top: 50px;
    width: 12px;
    height: 12px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    box-shadow:
        0 60px 0 rgba(0, 0, 0, 0.15),
        0 120px 0 rgba(0, 0, 0, 0.15),
        0 180px 0 rgba(0, 0, 0, 0.15),
        0 240px 0 rgba(0, 0, 0, 0.15);
}

/* Decorative page header */
.page-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--gold-ornament);
    position: relative;
}

.page-header::after {
    content: '✵ ✵ ✵';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: #f5ebe0;
    padding: 0 20px;
    color: var(--gold-ornament);
    font-size: 0.9rem;
    letter-spacing: 0.4em;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
    z-index: 2;
}

.page-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--ink-brown);
    letter-spacing: 0.1em;
    margin-bottom: 8px;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.page-subtitle {
    font-family: 'IM Fell English', serif;
    font-size: 0.9rem;
    font-style: italic;
    color: var(--ink-faded);
    letter-spacing: 0.1em;
}

/* === Hero Name Input === */
.hero-input-section {
    margin: 30px 0 35px;
    position: relative;
    z-index: 5;
}

.input-label {
    display: block;
    font-family: 'IM Fell English', serif;
    font-size: 1.1rem;
    font-style: italic;
    color: var(--ink-brown);
    margin-bottom: 18px;
    text-align: center;
    letter-spacing: 0.02em;
}

.hero-name-input {
    width: 100%;
    padding: 18px 20px;
    font-family: 'MedievalSharp', serif;
    font-size: 1.4rem;
    color: var(--ink-black);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-bottom: 2px solid rgba(139, 90, 43, 0.3);
    border-radius: 2px;
    text-align: center;
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
    box-shadow: none;
    position: relative;
    z-index: 5;
}

/* Hand-drawn underline look */
.hero-name-input:focus {
    outline: none;
    background: rgba(139, 90, 43, 0.03);
    border-bottom: 2px solid var(--ink-brown);
}

.hero-name-input::placeholder {
    color: var(--ink-faded);
    font-style: italic;
    opacity: 0.4;
    font-size: 1.1rem;
}

.hero-name-input:focus {
    outline: none;
    border-color: var(--gold-ornament);
    box-shadow:
        inset 0 2px 6px rgba(0, 0, 0, 0.08),
        0 0 0 3px rgba(212, 168, 75, 0.2),
        0 4px 12px rgba(212, 168, 75, 0.15);
}

/* === Begin Adventure Button === */
.btn-begin {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 16px 32px;
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--parchment-light);
    background: linear-gradient(165deg,
            var(--red-wax-light) 0%,
            var(--red-wax) 60%,
            #5a0a0a 100%);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    box-shadow:
        0 4px 0 #5a0a0a,
        0 6px 20px rgba(139, 26, 26, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        inset 0 -2px 0 rgba(0, 0, 0, 0.2);
    transition: all 0.15s ease;
}

.btn-begin::before {
    content: '⚔';
    margin-right: 12px;
    font-size: 1.3rem;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}

.btn-begin::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: left 0.5s ease;
}

.btn-begin:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 0 #5a0a0a,
        0 10px 30px rgba(139, 26, 26, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    background: linear-gradient(165deg, #c03838 0%, #9b2020 50%, #7b1515 100%);
}

.btn-begin:hover::after {
    left: 100%;
}

.btn-begin:active {
    transform: translateY(2px);
    box-shadow:
        0 2px 0 #5a0a0a,
        0 4px 10px rgba(139, 26, 26, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-begin:disabled {
    background: linear-gradient(165deg, #888 0%, #666 100%);
    box-shadow: 0 4px 0 #444, 0 6px 20px rgba(0, 0, 0, 0.3);
    cursor: not-allowed;
    opacity: 0.7;
}

/* === Decorative Footer === */
.page-footer {
    margin-top: 40px;
    text-align: center;
    font-family: 'IM Fell English', serif;
    font-size: 0.9rem;
    font-style: italic;
    color: var(--ink-faded);
    letter-spacing: 0.05em;
    opacity: 0.7;
}

.page-footer::before {
    content: '— ';
}

.page-footer::after {
    content: ' —';
}

/* === Quill Decoration === */
.quill-decoration {
    position: absolute;
    bottom: 25px;
    right: 35px;
    font-size: 2.2rem;
    opacity: 0.15;
    transform: rotate(-25deg);
    pointer-events: none;
    filter: sepia(1) brightness(0.5);
    z-index: 2;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 500px) {
    .notebook-closed {
        width: 320px;
        height: 440px;
    }

    .title-main {
        font-size: 1.9rem;
    }

    .notebook-open {
        width: 340px;
        padding: 40px 30px;
    }

    .page-title {
        font-size: 1.5rem;
    }
}