/* 
  =========================================
  Font Licenses & Credits
  -----------------------------------------
  1. Maru Buri (마루 부리)
     - Copyright Naver Corp.
     - License: SIL Open Font License, Version 1.1.
     - Free to use, modify, and distribute.
  
  2. Kaisei Tokumin (카이세이 토쿠민)
     - Copyright (c) 2020, Kaisei Project Authors.
     - License: SIL Open Font License, Version 1.1.
  =========================================
*/

/* Web Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Kaisei+Tokumin:wght@400;700&family=Outfit:wght@400;600;800&display=swap');

@font-face {
  font-family: 'MaruBuri';
  src: url('https://hangeul.pstatic.net/hangeul_static/webfont/MaruBuri/MaruBuri-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'MaruBuri';
  src: url('https://hangeul.pstatic.net/hangeul_static/webfont/MaruBuri/MaruBuri-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Theme variables */
:root {
    --primary: #ff7597;
    --primary-hover: #ff527b;
    --primary-light: #fff0f3;
    --secondary: #70d6ff;
    --text-color: #2b1f23;
    --text-muted: #6b5a5e;
    --font-heading: 'Outfit', 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Outfit', 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
    --border-radius: 28px;
    --transition-smooth: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset and Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    overflow-x: clip;
}

body {
    background-color: #1a0f12;
    color: var(--text-color);
    overflow-x: clip;
    line-height: 1.6;
}

body.lang-ko, body.lang-en {
    font-family: 'MaruBuri', serif;
}

body.lang-ja {
    font-family: 'Kaisei Tokumin', serif;
}

input, button, select, textarea {
    font-family: inherit;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
}
::-webkit-scrollbar-track {
    background: #25161a;
}
::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* Header Navigation (Transparent, Blurred with text glow) */
.header {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10000;
    background: rgba(26, 15, 18, 0.12); /* high transparency */
    backdrop-filter: blur(15px); /* heavy blur */
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.08);
    padding: 0 8%;
    height: 96px; /* taller for larger logo */
}

.header-container {
    width: 100%;
    max-width: 1200px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
}

.logo-img {
    height: 76px; /* doubled logo size from 38px */
    width: auto;
    object-fit: contain;
    filter: invert(1) brightness(2.5); /* turns black logo into pure white */
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 36px;
}

.nav-item {
    font-family: 'MaruBuri', serif !important; /* Always use MaruBuri for nav items regardless of language */
    text-decoration: none;
    color: #fff; /* white text for dark/transparent header */
    font-weight: 700;
    font-size: 1.05rem;
    position: relative;
    transition: var(--transition-smooth);
    padding: 6px 0;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.85); /* text outer glow */
}

.nav-item:hover, .nav-item.active {
    color: var(--primary);
    text-shadow: 0 0 12px rgba(255, 117, 151, 0.8), 0 1px 3px rgba(0, 0, 0, 0.85);
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 3px;
    background: var(--primary);
    border-radius: 4px;
    transition: var(--transition-smooth);
    transform: translateX(-50%);
    box-shadow: 0 0 8px var(--primary);
}

.nav-item.active::after, .nav-item:hover::after {
    width: 80%;
}

/* Language Dropdown Selector */
.lang-selector {
    position: relative;
}

.lang-btn {
    background: rgba(0, 0, 0, 0.35);
    border: 2px solid rgba(255, 255, 255, 0.65);
    color: #fff;
    text-shadow: 0 0 8px rgba(0,0,0,0.5);
    padding: 8px 18px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.lang-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(255, 117, 151, 0.3);
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: rgba(28, 20, 24, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: none;
    flex-direction: column;
    overflow: hidden;
    min-width: 160px;
    z-index: 10100;
    animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.lang-dropdown.show {
    display: flex;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.lang-option {
    background: none;
    border: none;
    padding: 12px 20px;
    text-align: left;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-family: inherit;
}

.lang-option:hover {
    background: rgba(255, 117, 151, 0.2);
    color: var(--primary);
}

/* Main layouts */
main {
    width: 100%;
}

/* Scroll pinning containers */
.scroll-section {
    position: relative;
    width: 100%;
    overflow: visible;
}

.sticky-container {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.section-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 1;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(30, 20, 25, 0.15);
    z-index: 2;
}

.library-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(20, 15, 18, 0.25);
    z-index: 2;
}

/* Game Title Logo (Center/Upper area floating on roof tiles - 3/5 size) */
.game-logo-container {
    position: absolute;
    top: 17vh;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    width: 90%;
    max-width: 580px;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.game-title-logo {
    width: 100%;
    max-width: 350px; /* scaled up 120% of previous 288px */
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.3));
    animation: floatLogo 6s ease-in-out infinite;
}

@keyframes floatLogo {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
    100% { transform: translateY(0px); }
}

/* Character Sprite Container (Consistent coordinates, 30% larger) */
.character-container {
    position: absolute;
    bottom: 0; /* aligned to bottom to hide cut-off edge behind dialogue bar */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    height: 88vh; /* 30% larger */
    max-height: 700px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 5;
    pointer-events: none;
}

.char-sprite {
    height: 100%;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 15px 30px rgba(0,0,0,0.25));
    transform-origin: bottom center;
    opacity: 1;
    transition: opacity 0.22s ease-in-out; /* fast, smooth fade on swap */
    animation: characterBreathe 4s ease-in-out infinite;
}

.char-sprite.hidden {
    opacity: 0;
}

@keyframes characterBreathe {
    0% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.015) translateY(-3px); }
    100% { transform: scale(1) translateY(0); }
}

/* Visual Novel Dialogue UI Box (First image style - Full width bottom black bar, custom name box) */
.dialogue-box-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    z-index: 10;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.7) 85%, rgba(0, 0, 0, 0) 100%);
    padding: 30px 0 52px 0; /* large bottom padding to avoid overlapping the fixed footer */
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.dialogue-box-container.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.dialogue-box-wrapper {
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.dialogue-speaker-box {
    background: url('./images/nametag.png') no-repeat center;
    background-size: 100% 100%;
    width: 180px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    box-shadow: none;
    border: none;
    padding: 0;
}

.dialogue-speaker {
    font-weight: 700;
    font-size: 1.15rem;
    color: #fff;
    letter-spacing: 0.5px;
    display: block;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    margin-top: -2px; /* centered vertical offset */
}

.dialogue-content-box {
    min-height: 84px;
    width: 100%;
}

.dialogue-text {
    font-size: 1.35rem; /* larger font size */
    line-height: 1.7;
    color: #fff;
    word-break: keep-all;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Ensure Japanese dialogue wraps properly at any character boundary instead of overflowing */
.lang-ja .dialogue-text {
    word-break: normal;
    overflow-wrap: break-word;
}

/* Dialogue text typewriter blink cursor */
.dialogue-text::after {
    content: '|';
    animation: blink 0.8s infinite;
    font-weight: 300;
    opacity: 0.8;
    margin-left: 2px;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* Card Panel layouts (Download, Social) */
.download-panel, .social-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 8;
    padding: 20px;
}

/* Premium Glassmorphic Card (Replaced bezel image backdrop) */
.bezel-card {
    width: 600px;
    max-width: 90vw;
    background: rgba(26, 15, 18, 0.52); /* increased transparency for background visibility */
    backdrop-filter: blur(25px); /* heavy background glass blur */
    -webkit-backdrop-filter: blur(25px);
    border: 1.5px solid rgba(255, 117, 151, 0.28); /* delicate rose gold/pink accent border */
    border-radius: 28px; /* elegant rounded corners */
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    margin-top: 0;
    transition: var(--transition-smooth);
}

.bezel-header {
    width: 100%;
    margin-bottom: 24px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.bezel-title {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary); /* gorgeous accent pink color */
    text-shadow: 0 0 15px rgba(255, 117, 151, 0.35);
    margin-top: 0;
    letter-spacing: 1px;
    position: relative;
    padding-bottom: 12px;
}

/* Elegant accent underline below title */
.bezel-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    border-radius: 2px;
}

.bezel-body {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 12px;
}

.bezel-desc {
    font-size: 1.15rem;
    color: rgba(255, 255, 255, 0.88); /* crisp white text */
    margin-bottom: 32px;
    text-align: center;
    font-weight: 700;
    line-height: 1.7;
    word-break: keep-all; /* prevents awkward word breaks */
    max-width: 90%;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Ensure Japanese card descriptions wrap properly instead of overflowing */
.lang-ja .bezel-desc {
    word-break: normal;
    overflow-wrap: break-word;
}

/* Store button styles */
.store-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: nowrap; /* keep side by side on desktop */
}

.store-btn-wrapper {
    position: relative;
}

.badge-store-disabled {
    position: relative;
    display: inline-block;
    cursor: default;
    border-radius: 8px;
    overflow: visible;
}

.badge-store-disabled .store-badge-img {
    opacity: 0.45; /* only dim the store graphic */
    filter: grayscale(0.2);
}

.store-badge-img {
    height: 52px; /* official look height */
    width: auto;
    display: block;
    object-fit: contain;
}

.coming-soon-badge {
    position: absolute;
    top: -12px;
    right: 50%;
    transform: translateX(50%);
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 3px 12px;
    border-radius: 50px;
    box-shadow: 0 4px 10px rgba(255, 117, 151, 0.3);
    white-space: nowrap;
}

.social-links-container {
    display: flex;
    justify-content: center;
    gap: 28px;
    flex-wrap: nowrap; /* prevent icons from wrapping to next line */
}

.social-icon-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.85); /* white text for contrast on dark card */
    font-weight: 700;
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}

.social-icon-link:hover {
    color: var(--primary);
    transform: translateY(-5px);
}

.social-img-icon {
    width: 72px; /* increased size from 56px */
    height: 72px;
    object-fit: contain;
    filter: drop-shadow(0 8px 16px rgba(0,0,0,0.1));
    transition: var(--transition-smooth);
}

.social-icon-link:hover .social-img-icon {
    filter: drop-shadow(0 12px 24px rgba(255, 117, 151, 0.3));
}

/* Floating Center-Bottom Footer Credit */
.footer-credit {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    text-align: center;
    pointer-events: none; /* click pass-through */
    transition: opacity 0.28s ease-in-out; /* smooth fade transitions */
    opacity: 1;
}

/* Hide footer during dialogue playback to prevent overlaps */
.footer-credit.hide-for-dialogue {
    opacity: 0 !important;
}

.footer-credit p {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.55);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.85);
    margin: 2.5px 0;
    white-space: nowrap; /* prevent line wrapping */
}

.footer-credit .font-attribution {
    font-size: 0.62rem;
    opacity: 0.5;
}

/* Shrink footer font size dynamically on narrow viewports instead of wrapping */
@media (max-width: 480px) {
    .footer-credit {
        font-size: 2.5vw; /* scale base font size relative to viewport width */
        bottom: 8px;
        width: 100%;
        padding: 0 16px;
    }
    .footer-credit p {
        font-size: 1em; /* inherits 2.5vw base scale */
    }
    .footer-credit .font-attribution {
        font-size: 0.86em; /* scales down slightly relative to base */
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .header {
        padding: 0 4%;
        height: 80px;
    }

    .logo-img {
        height: 52px;
    }
    
    .nav-menu {
        gap: 14px;
    }

    .nav-item {
        font-size: 0.82rem;
    }

    .lang-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .game-logo-container {
        top: 18vh;
        max-width: 200px;
    }

    .character-container {
        height: 70vh;
        max-height: 450px;
        bottom: 0; /* aligned to bottom in mobile too */
    }

    .dialogue-box-container {
        padding: 20px 0 40px 0;
    }

    .dialogue-box-wrapper {
        width: 92%;
    }

    .dialogue-speaker-box {
        width: 140px;
        height: 34px;
        margin-bottom: 10px;
        padding: 0;
        border: none;
        box-shadow: none;
    }

    .dialogue-speaker {
        font-size: 0.95rem;
        margin-top: -1px; /* centered vertical offset */
    }

    .dialogue-text {
        font-size: 1.05rem;
    }

    .bezel-card {
        width: 100%;
        max-width: 420px;
        padding: 36px 24px;
        border-radius: 20px;
    }

    .bezel-title {
        font-size: 1.6rem;
        margin-top: 0;
    }

    .bezel-desc {
        font-size: 0.95rem;
        margin-bottom: 24px;
    }

    .store-badge-img {
        height: 40px; /* slightly smaller to fit side-by-side on mobile screen width 320px */
    }

    .store-buttons {
        flex-wrap: nowrap;
        gap: 10px;
    }

    .social-links-container {
        flex-wrap: nowrap;
        gap: 16px;
    }

    .social-img-icon {
        width: 60px; /* scaled up from 48px */
        height: 60px;
    }
}
