/* =========================================
   1. GLOBAL RESET & FOUNDATION
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: #000;
    color: #fff;
    font-family: "Montserrat", system-ui, -apple-system, sans-serif;
    position: relative; 
    overscroll-behavior: none; 
    scrollbar-width: none;
    -ms-overflow-style: none;
}

html::-webkit-scrollbar, 
body::-webkit-scrollbar {
    display: none;
}

/* =========================================
   2. INTRO CONTAINER & ANIMATION OVERLAY
   ========================================= */
.intro {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;  
    height: 100dvh; /* Ignores mobile URL bars to prevent bottom clipping */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    background: #000;
    transition: opacity 1s ease, visibility 1s;
}

.intro-frame {
    position: relative;
    width: 70%;
    max-width: 1200px;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* THE SCROLL KILL SWITCH */
#animation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; 
    overflow: hidden;     
    z-index: 1000;
}

#samurai-sequence, 
#ryuzaki-wrapper, 
.stage,
.slash-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* =========================================
   3. ANIMATED TEXT ELEMENTS
   ========================================= */
.intro-left {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 50%;
    text-align: left;
}

.intro-right {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 50%;
    text-align: right;
}

.text-element {
    opacity: 0;
    filter: blur(6px);
    transform: scale(1.05);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, filter, transform;
}

#intro-line {
    font-size: 18px;
    font-weight: 300;
    letter-spacing: 0px;
    color: rgba(255, 255, 255, 0.6);
}

#intro-word {
    font-size: clamp(40px, 5vw, 80px);
    font-weight: 700;
    letter-spacing: 10px;
    color: #fff;
}

.text-element.active {
    opacity: 1;
    filter: blur(0px);
    transform: scale(1);
}

#intro-line.active { letter-spacing: 2px; }
#intro-word.active { letter-spacing: 4px; }

/* =========================================
   4. INTRO CONTROLS
   ========================================= */
.intro-controls {
    position: absolute;
    bottom: 40px;
    right: 40px;
    display: flex;
    gap: 15px;
    z-index: 2002;
    max-width: 100%;
    padding-right: 10px;
}

#skip-btn, #sound-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.5);
    padding: 12px 24px;
    font-family: "Montserrat", sans-serif;
    font-size: 11px;
    letter-spacing: 1px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.4s ease;
    font-weight: 700;
    outline: none;
    opacity: 0.4;
}

#skip-btn:hover, #sound-btn:hover {
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.8);
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1); 
}

#skip-btn { display: none; }
#skip-btn.visible { display: block; }

#sound-btn {
    display: block;
    min-width: 120px;
    text-align: center;
}

#sound-btn.active {
    color: rgba(255, 255, 255, 0.6);
    border-color: rgba(255, 255, 255, 0.3);
    opacity: 0.5;
    box-shadow: none; 
}

#sound-btn.active:hover {
    opacity: 1;
    border-color: #fff;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

@keyframes pulse-subtle {
    0% { border-color: rgba(255, 255, 255, 0.2); opacity: 0.4; }
    50% { border-color: rgba(255, 255, 255, 0.8); opacity: 1; } 
    100% { border-color: rgba(255, 255, 255, 0.2); opacity: 0.4; }
}

#sound-btn.attention {
    animation: pulse-subtle 2.5s infinite;
    color: rgba(255, 255, 255, 0.9);
}

/* =========================================
   5. SAMURAI SEQUENCE ASSETS
   ========================================= */
.stage { z-index: 1; }

#ryuzaki-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0; 
    pointer-events: none; 
    transition: opacity 1.0s ease-in-out;
}

.petal {
    position: absolute;
    width: 40px;
    height: 40px;
    pointer-events: none;
}
.petal svg { width: 100%; height: 100%; display: block; }
.petal path { fill: url(#petalGradient); }

.sword-container {
    position: absolute;
    bottom: -25%; 
    left: -7%;
    width: 50vh; 
    height: auto;
    z-index: 500;
    opacity: 0;
    transform-origin: bottom left; 
}

.sword-active {
    animation: swordEntrance 1.8s cubic-bezier(0.1, 0.5, 0.1, 1) forwards;
}

@keyframes swordEntrance {
    0% { opacity: 0; transform: translate(-50px, 100px) rotate(0deg); }
    20% { opacity: 1; }
    80% { opacity: 1; transform: translate(0, 0) rotate(-15deg); }
    100% { opacity: 0; transform: translate(0, 0) rotate(-15deg); }
}

.slash-line {
    position: absolute;
    top: 90%; 
    left: -10vw;
    height: 3px;
    width: 150vw;
    background: #fff;
    border-radius: 2px;
    box-shadow: 0 0 5px rgba(201, 115, 115, 0.8);
    opacity: 0;
    transform-origin: left center;
    transform: translateY(-50%) rotate(-15deg) scaleX(0); 
    z-index: 999;
}

.slash-active {
    animation: slashSequence 2.5s cubic-bezier(0.05, 0.7, 0.1, 1) forwards;
}

@keyframes slashSequence {
    0% { opacity: 0; transform: translateY(-50%) rotate(-15deg) scaleX(0); box-shadow: 0 0 2px #ebc7c7; }
    15% { transform: translateY(-50%) rotate(-15deg) scaleX(1); opacity: 1; box-shadow: 0 0 5px #e7c3c3; }
    100% { transform: translateY(-50%) rotate(-15deg) scaleX(1); opacity: 0; box-shadow: 0 0 20px rgba(255, 255, 255, 0); }
}

#main-svg {
    width: 60%;
    max-width: 1200px;
    overflow: visible; 
    transform-origin: center; 
    position: relative;
}

#main-svg path {
    stroke: #ffffff;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill-opacity: 0; 
    stroke-opacity: 1;
}

#shockwave { opacity: 0; pointer-events: none; }

/* =========================================
   6. BOOT SCREEN (Cinematic Loader)
   ========================================= */
.boot-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.boot-content {
    text-align: center;
    font-family: 'Montserrat', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 0 20px; 
}

.boot-logo {
    font-size: 28px;
    font-weight: 200;
    letter-spacing: 16px;
    text-indent: 16px; 
    margin-bottom: 48px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.95);
    white-space: nowrap; 
}

.boot-loader-wrapper {
    width: 320px; 
    max-width: 80%; 
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    margin-bottom: 40px;
}

.boot-loader-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: rgba(255, 255, 255, 0.9);
    transition: width 0.1s linear;
}

.boot-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    animation: fadeInActions 0.1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    width: 100%;
}

.audio-prompt {
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 4px;
    text-indent: 4px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 4px;
}

.btn-row {
    display: flex;
    gap: 20px; 
    align-items: center;
    justify-content: center;
}

.cinematic-btn {
    background: transparent;
    font-family: 'Montserrat', sans-serif;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 4px;
    text-indent: 4px; 
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 14px 32px;
    min-width: 220px; 
}

.cinematic-btn {
    border: 1px solid rgba(255, 255, 255, 0.4); 
    color: rgba(255, 255, 255, 0.9);
}

.cinematic-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    color: #000;
    border-color: rgba(255, 255, 255, 0.95);
}

.cinematic-btn.text-only {
    border: 1px solid rgba(255, 255, 255, 0.1); 
    color: rgba(255, 255, 255, 0.4); 
}

.cinematic-btn.text-only:hover {
    background: rgba(255, 255, 255, 0.05); 
    color: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.3);
}

@keyframes fadeInActions {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   7. MOBILE OPTIMIZATION
   ========================================= */
@media screen and (max-width: 768px) {
    .intro-frame { width: 90%; }

    .intro-left, .intro-right {
        width: 100%;
        text-align: center;
        left: 0; right: 0;
    }
    .intro-left { top: 42%; transform: translateY(-50%); }
    .intro-right { top: 52%; transform: translateY(-50%); }

    #intro-word { font-size: 13vw; letter-spacing: 5px; }
    #intro-line { font-size: 14px; }

    .sword-container {
        width: 100vw; 
        left: -20%;
        bottom: -15%;
    }

    #main-svg { width: 95%; }

    .intro-controls {
        width: 100%;
        justify-content: center;
        right: 0;
        bottom: 30px;
    }
    #skip-btn, #sound-btn {
        padding: 16px 28px;
        font-size: 12px;
        background: rgba(0,0,0,0.3);
    }

    /* THE MOBILE SLASH FIX
       Forces the slash to shoot as a projectile from bottom-left to top-right
       instead of growing outwards from the center */
    .slash-line {
        top: 70%;      
        left: -10vw;   
        width: 180vw;  
        transform-origin: left center; 
    }

    .slash-active {
        animation: slashSequenceMobile 2.5s cubic-bezier(0.05, 0.7, 0.1, 1) forwards;
    }

    .boot-logo {
        font-size: 16px; 
        letter-spacing: 10px; 
        text-indent: 10px;
        margin-bottom: 30px;
        white-space: normal; 
    }

    .btn-row {
        flex-direction: column; 
        gap: 12px;
        width: 100%;
    }

    .cinematic-btn {
        width: 100%; 
        max-width: 280px; 
        padding: 16px 20px; 
        font-size: 10px;
    }
}

@keyframes slashSequenceMobile {
    0%   { opacity: 0; transform: translateY(-50%) rotate(-35deg) scaleX(0); box-shadow: 0 0 2px #ebc7c7; }
    15%  { transform: translateY(-50%) rotate(-35deg) scaleX(1); opacity: 1; box-shadow: 0 0 5px #e7c3c3; }
    100% { transform: translateY(-50%) rotate(-35deg) scaleX(1); opacity: 0; box-shadow: 0 0 20px rgba(255, 255, 255, 0); }
}