/* 
 * Exla's Corner: The "100% Professional Waterfall" (v32.0)
 * Multiple backgrounds to separate repeating streams from fixed foam.
 */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Outfit:wght@300;600;900&display=swap');

:root {
    --brand-magenta: #ff2a6d;
    --font-pixel: 'Press Start 2P', cursive;
    --font-sans: 'Press Start 2P', cursive;
}

body {
    background-color: #0c0d10;
    color: #ffd700;
    font-family: var(--font-sans);
    margin: 0;
    overflow-x: hidden;
}

/* -- DUNGEON BACKGROUND -- */
.dungeon-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    /* Layer 1: Base Stone (Repeating SVG) */
    /* Layer 2: Deep Dark Vignette (Shading) */
    /* Layer 3: Central Ambient Light */
    background:
        radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.9) 100%),
        radial-gradient(circle at 50% 30%, rgba(255, 42, 109, 0.05) 0%, rgba(0, 0, 0, 0) 50%),
        url('/assets/stone_dungeon.svg') repeat;
    background-size: 100% 100%, 100% 100%, 450px;
    opacity: 1;
}

/* Add a very subtle grain/grit texture for 'render' feel */
.dungeon-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.04;
    mix-blend-mode: overlay;
    pointer-events: none;
}

/* Subtle Dust Motes (Artefacts) */
.dungeon-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='dust'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.05' numOctaves='2' result='noise'/%3E%3CfeColorMatrix in='noise' type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 20 -15'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23dust)'/%3E%3C/svg%3E");
    opacity: 0.1;
    pointer-events: none;
    animation: drift 60s linear infinite;
}

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

    to {
        transform: translateY(-512px) rotate(1deg);
    }
}

/* -- GUILD STYLES (PAPER SCROLLS) -- */
.guild-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s;
}

.guild-logo-scroll {
    width: 360px;
    height: 100px;
    background: url('/assets/scroll.svg') no-repeat center;
    background-size: 100% 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.7));
    transition: all 0.3s;
    text-decoration: none;
    width: 100%;
}

.logo-text {
    font-family: var(--font-pixel);
    font-size: 20px;
    color: #331a08;
    letter-spacing: 0.2em;
    padding-top: 10px;
    white-space: nowrap;
}

.mobile-scroll-trigger {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-top: 5px;
    width: 44px;
    height: 34px;
    position: relative !important;
    top: auto !important;
    right: auto !important;
    transform: none !important;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    gap: 4px;
    z-index: 2000;
    transition: 0.2s;
}

.hamburger-line {
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
    transition: 0.3s;
}

.mobile-scroll-trigger:hover {
    background: var(--brand-magenta);
    border-color: var(--brand-magenta);
}

@media (max-width: 768px) {
    .guild-logo-scroll {
        width: 300px;
        height: 110px;
    }
    .logo-text {
        font-size: 14px;
    }
    .mobile-scroll-trigger {
        width: 44px;
        height: 32px;
    }
}

/* HIDE DESKTOP NAV - MOVING TO SIDEBAR */
.guild-header nav {
    display: none !important;
}

.guild-nav-link {
    font-family: var(--font-pixel);
    font-size: 10px;
    font-weight: 900;
    color: #fff;
    /* Restored to white */
    text-decoration: none;
    padding: 8px 18px;
    background: rgba(0, 0, 0, 0.7);
    /* Darker background for max legibility */
    border-radius: 4px;
    transition: 0.2s;
    letter-spacing: 0.05em;
    display: inline-block;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.guild-nav-link:hover {
    background: var(--brand-magenta);
    color: #fff;
    border-color: var(--brand-magenta);
    box-shadow: 0 0 15px rgba(255, 42, 109, 0.4);
}

/* -- DROPDOWN STYLES -- */
.guild-dropdown {
    position: relative;
    display: inline-block;
}

.guild-dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    min-width: 160px;
    background: #1a1a1a;
    border: 3px solid #4a2c10;
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: 0.3s;
    z-index: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.guild-dropdown:hover .guild-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.guild-dropdown-item {
    display: block;
    padding: 10px 20px;
    color: #fff;
    font-weight: 800;
    font-family: var(--font-pixel);
    font-size: 9px;
    text-decoration: none;
    transition: 0.2s;
}

.guild-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--brand-magenta);
}

.scroll-section-header {
    background: url('/assets/scroll.svg') no-repeat center;
    background-size: 100% 100%;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    min-width: 100%;
    padding: 0 15%; /* Safety margin for scroll edges */
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

@media (min-width: 1024px) {
    .scroll-section-header {
        height: 145px;
    }
}

.scroll-section-header h1,
.scroll-section-header h2 {
    margin: 0;
    text-align: center;
    width: 100%;
    color: #331a08;
    line-height: 1.2;
    overflow-wrap: break-word;
    text-wrap: balance;
    font-size: clamp(8px, 4vw, 24px); /* Adaptive scaling */
}

.guild-notice-board h3 {
    color: #331a08;
}

/* -- GUILD CARDS & NOTICE BOARD -- */
.guild-card {
    background: #fdfcf0; /* Match Parchment */
    border: 2px solid #331a08;
    position: relative;
    box-shadow: 8px 8px 0 rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
}

.guild-card-img {
    width: 100%;
    display: block;
    overflow: hidden;
    position: relative;
    background: transparent;
}

.comic-thumb {
    width: 100%;
    height: auto;
    display: block;
}

.guild-card-footer {
    padding: 24px;
    background: #fdfcf0;
    /* Premium Parchment */
    flex-grow: 1;
}

.guild-card-tag {
    font-size: 10px;
    font-weight: 900;
    color: #ffd700;
    background: #331a08;
    padding: 4px 8px;
    display: inline-block;
    margin-bottom: 12px;
}

.guild-card-title {
    font-family: var(--font-pixel);
    font-size: 14px;
    color: #1a1a1a;
    margin-bottom: 8px;
    line-height: 1.4;
}

.guild-card-meta {
    font-size: 13px;
    color: #6d4c31;
    font-weight: 600;
}

.guild-notice-board {
    background: #fdfcf0;
    border: 12px solid #4a2c10;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
}

.view-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 8px;
    max-width: 100%;
    overflow: hidden;
    text-decoration: none;
}

.view-item:last-child {
    border-bottom: none;
}

.view-rank {
    font-family: var(--font-pixel);
    font-size: 13px;
    color: var(--brand-magenta);
    min-width: 20px;
    flex-shrink: 0;
}

.view-thumb-container {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border: 1px solid #4a2c10;
    overflow: hidden;
    background: #000;
}

.view-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.view-title {
    font-weight: 800;
    color: #1a1a1a;
    font-size: 11px;
    line-height: 1.2;
    overflow-wrap: break-word;
    word-break: break-all;
    max-width: 100%;
}

.view-subtitle {
    font-size: 10px;
    color: #6d4c31;
    font-weight: 600;
    text-transform: uppercase;
    display: block;
}


.scroll-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(12px);
    z-index: 5000;
    opacity: 0;
    visibility: hidden;
    transition: 0.4s;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
}

.scroll-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.scroll-sidebar-unroll {
    width: 100%;
    max-width: 100%;
    height: 0;
    /* Starts closed at top */
    background: url('/assets/scroll_vertical.svg') no-repeat center;
    background-size: cover;
    transition: height 0.8s cubic-bezier(0.19, 1, 0.22, 1);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow-y: auto;
    position: relative;
    padding: 60px 20px;
    border-bottom: 8px solid #4a2c10;
}

.scroll-sidebar-overlay.active .scroll-sidebar-unroll {
    height: 100vh;
    /* Full screen unroll from top */
}

.mobile-nav-links {
    opacity: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    text-align: center;
}

.scroll-sidebar-overlay.active .mobile-nav-links {
    opacity: 1;
}

.mobile-header-logo-container {
    display: block;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 280px;
    height: 70px;
    background: url('/assets/scroll.svg') no-repeat left center;
    background-size: 100% 100%;
    z-index: 10;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}

.mobile-header-logo {
    display: block;
    font-family: var(--font-pixel);
    font-size: 11px;
    color: #331a08;
    position: absolute;
    left: 45px;
    top: 52%;
    transform: translateY(-50%);
    white-space: nowrap;
}

@media (min-width: 1760px) {
    .mobile-header-logo-container {
        display: none !important;
    }
}

@media (min-width: 1760px) {
    .mobile-header-logo-container {
        display: none !important;
    }
}

.text-magenta {
    color: #ff2a6d !important;
}

a.text-magenta:hover, 
button.text-magenta:hover {
    color: #fff !important;
}

.bg-magenta {
    background-color: #ff2a6d !important;
}

.font-bold {
    font-weight: 700 !important;
}

.font-black {
    font-weight: 900 !important;
}

/* -- POPUP & CHEST -- */
#gatekeeper {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 1s;
    background: rgba(0,0,0,0.95);
}

.popup-modal {
    text-align: center;
    padding: 80px 100px;
    background: linear-gradient(135deg, #0a1422 0%, #050a11 100%);
    border: 12px solid #1a1a1a;
    box-shadow: 0 40px 120px rgba(0, 0, 0, 0.9), inset 0 0 0 4px #2a2a2a;
    position: relative;
    width: 90%;
    max-width: 900px;
    margin: 20px;
}

#chest-root {
    width: 100%;
    max-width: 448px;
    aspect-ratio: 448/350;
}

.chest-display {
    width: 100%;
    height: 100%;
    margin: 0 auto;
    background: url('/assets/chest.svg') no-repeat center;
    background-size: contain;
    position: relative;
}

#pixel-lock-container {
    position: absolute;
    top: 60%;
    left: 50%;
    width: 100px;
    height: 120px;
    background: url('/assets/lock.svg') no-repeat center;
    background-size: contain;
    z-index: 20;
    transform: translate(-50%, -50%);
    transition: 0.7s;
}

.pixel-btn {
    font-family: var(--font-pixel);
    padding: 24px 56px;
    border: 4px solid #fff;
    box-shadow: 8px 8px 0 #000;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 14px;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

.pixel-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 4px 4px 0 #000;
}

.magenta-pixel {
    background: var(--brand-magenta);
    color: #fff;
}

.grey-pixel {
    background: #444;
    color: #fff;
}

@keyframes shakeLock {

    0%,
    100% {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    20% {
        transform: translate(-55%, -50%) rotate(-10deg);
    }

    40% {
        transform: translate(-45%, -50%) rotate(10deg);
    }
}

.animate-shake-lock {
    animation: shakeLock 0.3s ease-in-out;
}

/* -- RESPONSIVE TWEAKS -- */
@media (max-width: 768px) {
    .popup-modal {
        padding: 40px 20px;
        border-width: 8px;
    }

    .popup-modal h1 {
        font-size: 1.5rem !important;
        letter-spacing: 0.2em !important;
        padding-left: 0.2em !important;
        margin-bottom: 30px !important;
    }

    #pixel-lock-container {
        width: 60px;
        height: 72px;
    }

    .pixel-btn {
        padding: 16px 32px;
        font-size: 11px;
    }

    #chest-root {
        margin-bottom: 30px !important;
    }
}

/* Font helpers */
.font-pixel { font-family: var(--font-pixel); }
.font-sans { font-family: var(--font-sans); }
