/* Styles for Cannabis Shop Storytelling Game (Visual Novel) */

/* Global Reset & Base Styling */
:root {
    --bg-dark: #07120b;
    --bg-darker: #040906;
    --primary: #10b981;
    --primary-glow: rgba(16, 185, 129, 0.4);
    --primary-dim: #064e3b;
    --accent-gold: #fbbf24;
    --accent-gold-glow: rgba(251, 191, 36, 0.3);
    --text-light: #f3f4f6;
    --text-muted: #9ca3af;
    --glass-bg: rgba(15, 27, 20, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-active: rgba(16, 185, 129, 0.3);
    --shadow-inset: inset 0 1px 1px rgba(255, 255, 255, 0.1);
    --font-primary: 'Kanit', sans-serif;
    --font-secondary: 'Sarabun', sans-serif;
    --transition-speed: 0.4s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-secondary);
    background-color: var(--bg-darker);
    color: var(--text-light);
    overflow: hidden;
    user-select: none;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
}

/* App Container */
#app-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-speed) ease, visibility var(--transition-speed) ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* Background Ambient Orbs */
.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
    z-index: 1;
    pointer-events: none;
    animation: float-around 20s infinite alternate ease-in-out;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background-color: var(--primary);
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background-color: var(--accent-gold);
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

.orb-green {
    width: 600px;
    height: 600px;
    background-color: var(--primary);
    top: 20%;
    left: 25%;
}

@keyframes float-around {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 80px) scale(1.2); }
}

/* Start / Title Screen Styling */
#start-screen {
    background: radial-gradient(circle at center, var(--bg-dark) 0%, var(--bg-darker) 100%);
    padding: 2rem 1rem;
    text-align: center;
    overflow-y: auto;
}

.start-content {
    max-width: 650px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fade-in-up 1s ease-out;
    margin: auto;
}

.badge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--primary);
    border: 1px solid var(--primary-glow);
    padding: 0.4rem 1rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.main-title {
    font-family: var(--font-primary);
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.2;
    background: linear-gradient(135deg, #ffffff 30%, var(--primary) 70%, var(--accent-gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 4px 12px rgba(16, 185, 129, 0.3));
}

.sub-title {
    font-family: var(--font-primary);
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--text-light);
    margin-bottom: 2rem;
    opacity: 0.9;
}

.description {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-muted);
    margin-bottom: 3rem;
}

.start-footer {
    position: absolute;
    bottom: 2rem;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.25);
    z-index: 5;
}

/* Button Custom System */
.btn-primary {
    font-family: var(--font-primary);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dim) 100%);
    border: none;
    outline: none;
    color: white;
    padding: 1.1rem 2.5rem;
    font-size: 1.15rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 8px 25px var(--primary-glow), var(--shadow-inset);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 30%;
    height: 200%;
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(30deg);
    transition: all 0.5s ease;
    opacity: 0.3;
}

.btn-primary:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(16, 185, 129, 0.6), var(--shadow-inset);
}

.btn-primary:hover::after {
    left: 130%;
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.arrow-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.btn-primary:hover .arrow-icon {
    transform: translateX(4px);
}

/* Game Main Layout */
#game-screen {
    justify-content: flex-end;
    align-items: stretch;
}

/* Background Image Container */
.game-bg-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 1;
    transition: background-image 0.8s ease-in-out;
}

.bg-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, transparent 30%, rgba(4, 9, 6, 0.85) 100%);
    z-index: 2;
    pointer-events: none;
}

/* Game HUD Header */
.game-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 20;
    pointer-events: none;
}

.game-header .logo {
    font-family: var(--font-primary);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: 0.05em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    pointer-events: auto;
}

.header-controls {
    display: flex;
    gap: 0.75rem;
    pointer-events: auto;
}

.control-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(15, 27, 20, 0.5);
    backdrop-filter: blur(10px);
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.control-btn svg {
    width: 20px;
    height: 20px;
}

.control-btn:hover {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.05);
}

.sound-icon {
    display: none;
}

.sound-icon.active {
    display: block;
}

/* Portraits Setup */
.portraits-container {
    position: absolute;
    left: 0;
    right: 0;
    top: 10%;
    bottom: 32%;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 10%;
    z-index: 5;
    pointer-events: none;
}

.portrait {
    height: 100%;
    max-height: 520px;
    width: 32%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.1), opacity 0.5s ease, filter 0.5s ease;
    opacity: 0;
    filter: brightness(0.4) saturate(0.8) blur(1px);
    transform: translateY(50px);
}

.portrait img {
    height: 100%;
    width: auto;
    object-fit: contain;
    pointer-events: none;
    /* Clean up keying outline/border if generated image has small artifacts */
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}

/* Character alignment specifics */
.portrait.left-side {
    justify-content: flex-start;
}

.portrait.right-side {
    justify-content: flex-end;
}

/* Portrait Active/Focus states */
.portrait.visible {
    opacity: 0.75;
    transform: translateY(0);
}

.portrait.focus {
    opacity: 1;
    filter: brightness(1) saturate(1) blur(0);
    transform: translateY(0) scale(1.04);
    z-index: 10;
}

.portrait.talking {
    animation: soft-pulse 1.5s infinite alternate ease-in-out;
}

@keyframes soft-pulse {
    0% { transform: translateY(0) scale(1.04); }
    100% { transform: translateY(-4px) scale(1.05); }
}

/* Dialogue HUD area */
.hud-container {
    position: relative;
    z-index: 15;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto 3rem auto;
    padding: 0 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Dialogue Glass Box */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), var(--shadow-inset);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#dialogue-box {
    position: relative;
    padding: 2.5rem 2.2rem 1.8rem 2.2rem;
    cursor: pointer;
    min-height: 160px;
}

#dialogue-box:hover {
    border-color: var(--glass-border-active);
}

/* Speaker Name Badge */
.speaker-badge {
    position: absolute;
    top: -16px;
    left: 2rem;
    background: linear-gradient(135deg, var(--primary-dim) 0%, #0c2b20 100%);
    border: 1px solid var(--primary);
    color: white;
    padding: 0.4rem 1.8rem;
    border-radius: 8px;
    font-family: var(--font-primary);
    font-size: 1.05rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
}

.speaker-badge.pm-style {
    background: linear-gradient(135deg, #1e3a8a 0%, #172554 100%);
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.speaker-badge.narrator-style {
    background: linear-gradient(135deg, #374151 0%, #111827 100%);
    border-color: #9ca3af;
    box-shadow: 0 4px 12px rgba(156, 163, 175, 0.2);
}

.dialogue-content {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    font-size: 1.15rem;
    line-height: 1.8;
    color: var(--text-light);
    font-weight: 400;
}

.dialogue-placeholder {
    grid-area: 1 / 1 / 2 / 2;
    visibility: hidden;
    pointer-events: none;
    line-height: inherit;
    font-size: inherit;
    font-family: inherit;
}

#dialogue-text {
    grid-area: 1 / 1 / 2 / 2;
    line-height: inherit;
    font-size: inherit;
    font-family: inherit;
}

/* Next Indicator Pulse */
.next-indicator {
    position: absolute;
    bottom: 1rem;
    right: 1.5rem;
    width: 24px;
    height: 24px;
    color: var(--primary);
    animation: bounce-pulse 1s infinite alternate ease-in-out;
}

@keyframes bounce-pulse {
    0% { transform: translateY(0); opacity: 0.5; }
    100% { transform: translateY(4px); opacity: 1; }
}

/* Choices Panel Layout */
.choices-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    animation: fade-in-up 0.5s ease-out;
}

.choice-btn {
    font-family: var(--font-primary);
    background: rgba(15, 27, 20, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-light);
    padding: 1.1rem 2rem;
    font-size: 1.05rem;
    font-weight: 400;
    cursor: pointer;
    text-align: left;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.choice-btn:hover {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--primary);
    color: white;
    transform: translateX(6px);
    box-shadow: 0 4px 20px var(--primary-glow);
}

.choice-btn::after {
    content: '→';
    font-size: 1.2rem;
    color: var(--primary);
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.25s ease;
}

.choice-btn:hover::after {
    opacity: 1;
    transform: translateX(0);
}

.choice-btn:active {
    transform: translateX(2px);
}

/* Ending Screen Panel Styling */
#ending-screen {
    background: radial-gradient(circle at center, #0a1f14 0%, var(--bg-darker) 100%);
    padding: 2rem 1rem;
    overflow-y: auto;
}

.ending-content {
    max-width: 600px;
    width: 90%;
    padding: 3rem 2.5rem;
    text-align: center;
    z-index: 5;
    animation: fade-in-up 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: auto;
}

.ending-badge {
    background: rgba(251, 191, 36, 0.15);
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold-glow);
    padding: 0.4rem 1.5rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
}

.ending-title {
    font-family: var(--font-primary);
    font-size: 2.2rem;
    margin-bottom: 1.25rem;
    color: white;
    text-shadow: 0 2px 10px rgba(251, 191, 36, 0.2);
}

.ending-description {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.ending-stat-card {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 1.25rem 1.8rem;
    margin-bottom: 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

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

.stat-label {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.stat-value {
    color: white;
    font-weight: 500;
    font-size: 1rem;
}

.text-gold {
    color: var(--accent-gold);
}

/* Animations Keyframes */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Responsiveness Settings */
@media (max-width: 900px) {
    .portraits-container {
        padding: 0 5%;
        bottom: 35%;
    }
    
    .portrait {
        width: 45%;
        max-height: 420px;
    }
    
    #dialogue-box {
        min-height: 140px;
    }
}

@media (max-width: 600px) {
    body {
        font-size: 14px;
    }
    
    .main-title {
        font-size: 2.4rem;
    }
    
    .sub-title {
        font-size: 1.2rem;
        margin-bottom: 1.5rem;
    }
    
    .description {
        font-size: 0.95rem;
        margin-bottom: 2rem;
    }
    
    .portraits-container {
        padding: 0;
        bottom: 40%;
    }
    
    .portrait {
        width: 50%;
        max-height: 330px;
    }
    
    /* When on small mobile, dim and scale down inactive characters for clarity */
    .portrait.visible {
        opacity: 0.25;
        transform: scale(0.9) translateY(10px);
        filter: brightness(0.3) saturate(0.7) blur(1.5px);
    }
    
    .portrait.focus {
        opacity: 1;
        transform: scale(1.06) translateY(0);
        filter: brightness(1) saturate(1) blur(0);
        z-index: 10;
    }
    
    .hud-container {
        padding: 0 1rem;
        margin-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }
    
    #dialogue-box {
        padding: 1.6rem 1.25rem 1.25rem 1.25rem;
        min-height: 130px;
    }

    .dialogue-content {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    .speaker-badge {
        left: 1rem;
        padding: 0.3rem 1.2rem;
        font-size: 0.95rem;
    }
    
    .choice-btn {
        padding: 0.9rem 1.25rem;
        font-size: 0.95rem;
    }
    
    .ending-content {
        padding: 2rem 1.5rem;
    }
    
    .ending-title {
        font-size: 1.8rem;
    }
}

.btn-secondary {
    font-family: var(--font-primary);
    background: rgba(15, 27, 20, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary:hover {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-secondary:active {
    transform: scale(0.98);
}

.btn-secondary-link {
    font-family: var(--font-primary);
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    padding: 1rem 2.2rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--accent-gold-glow);
    width: 100%;
}

.btn-secondary-link:hover {
    background: rgba(251, 191, 36, 0.22);
    box-shadow: 0 8px 25px rgba(251, 191, 36, 0.35);
    transform: translateY(-2px);
    color: #ffffff;
}

.btn-secondary-link:active {
    transform: translateY(0);
}

/* Height-based responsiveness for short viewports */
@media (max-height: 650px) {
    .portraits-container {
        top: 12%;
        bottom: 36%;
    }
    
    .portrait {
        max-height: 250px;
    }
    
    #dialogue-box {
        min-height: 110px;
        padding: 1.8rem 1.5rem 1.2rem 1.5rem;
    }
    
    .hud-container {
        margin-bottom: 1.2rem;
        gap: 0.8rem;
    }
    
    .choice-btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.95rem;
    }
}
