/* =============================================
   Elven Tarot v3 — App Styles
   ============================================= */

/* --- Variables --- */
:root {
    --gold: #d4af37;
    --dark-purple: #0f0a14;
    --glass: rgba(20, 15, 30, 0.95);
    --ai-size: 18px;
}

/* --- Icons --- */
.icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    fill: currentColor;
    color: currentColor;
}

.icon-sm {
    width: 20px;
    height: 20px;
}

.icon-md {
    width: 28px;
    height: 28px;
}

.icon-lg {
    width: 40px;
    height: 40px;
}

.icon-xl {
    width: 56px;
    height: 56px;
}

.icon-mode {
    width: 48px;
    height: 48px;
    color: var(--gold);
    filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.4));
    margin-bottom: 8px;
}

.icon-menu-item {
    width: 22px;
    height: 22px;
    color: currentColor;
    flex-shrink: 0;
}

.icon-section {
    width: 32px;
    height: 32px;
    color: var(--gold);
    opacity: 0.8;
}

.icon-gold {
    color: var(--gold);
}

.icon-glow {
    filter: drop-shadow(0 0 8px rgba(212, 175, 55, 0.5));
}

/* --- Base --- */
body {
    font-family: 'Calibri', 'Segoe UI', sans-serif;
    background-color: var(--dark-purple);
    color: #e2d8f0;
    background-image: radial-gradient(circle at 50% 0%, #462568 0%, transparent 60%), radial-gradient(circle at 50% 100%, #2a1b3d 0%, #050308 100%);
    background-attachment: fixed;
    background-size: 200% 200%;
    animation: bgGlow 20s ease infinite;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

@keyframes bgGlow {
    0% {
        background-position: 50% 0%;
    }

    50% {
        background-position: 50% 100%;
    }

    100% {
        background-position: 50% 0%;
    }
}

/* --- Typography --- */
.title-font {
    font-family: 'Elsie Swash Caps', cursive;
    font-weight: 900;
}

.elf-font {
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* --- Glass Panel --- */
.glass-panel {
    background: var(--glass);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(212, 175, 55, 0.2);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
}

/* --- Buttons --- */
button {
    position: relative;
    z-index: 1;
}

.btn-primary {
    background: linear-gradient(135deg, #d4af37, #996515);
    color: #000;
    font-weight: 800;
    border: none;
    text-transform: uppercase;
    position: relative;
    z-index: 1;
}

.btn-primary:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.4);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-mystic {
    border: 1px solid var(--gold);
    color: var(--gold);
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
    position: relative;
    z-index: 1;
}

.btn-mystic:hover {
    background: rgba(212, 175, 55, 0.2);
}

.btn-tertiary {
    background: transparent;
    border: none;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-tertiary:hover {
    color: #999;
}

/* --- Animations --- */
.tree-glow {
    filter: drop-shadow(0 0 15px rgba(212, 175, 55, 0.6));
    animation: pulse-glow 3s infinite alternate;
}

@keyframes pulse-glow {
    from {
        filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.4));
    }

    to {
        filter: drop-shadow(0 0 25px rgba(212, 175, 55, 0.8));
    }
}

/* Smooth glow for START button (replaces harsh animate-pulse) */
.btn-glow {
    animation: btn-glow-pulse 2s ease-in-out infinite;
}

@keyframes btn-glow-pulse {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(212, 175, 55, 0.3), 0 0 30px rgba(212, 175, 55, 0.1);
    }

    50% {
        box-shadow: 0 0 20px rgba(212, 175, 55, 0.6), 0 0 50px rgba(212, 175, 55, 0.2);
    }
}

/* Focus visible outline for accessibility */
:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* --- Progress Indicator --- */
#progress-indicator {
    position: fixed;
    top: 64px;
    left: 0;
    width: 100%;
    z-index: 100;
    background: rgba(15, 10, 20, 0.95);
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
}

.progress-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 0;
}

.mode-label {
    font-size: 11px;
    color: var(--gold);
    opacity: 0.7;
    margin-right: 8px;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.progress-step {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #333;
    transition: all 0.3s;
    position: relative;
}

.progress-step.active {
    background: var(--gold);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.5);
}

.progress-step.completed {
    background: rgba(212, 175, 55, 0.4);
}

.progress-connector {
    width: 24px;
    height: 2px;
    background: #333;
    transition: background 0.3s;
}

/* --- Screens & Layout --- */
.screen {
    display: none;
    box-sizing: border-box;
    transition: padding-top 0.3s ease;
}

body.has-progress-bar .screen {
    padding-top: 100px;
    /* Adjusted Header + Progress Bar */
}

.screen.active {
    display: flex;
}

/* Centered screens (Start, Language) without navigation padding or bottom padding to ensure true center */
#screen-start,
#screen-language {
    justify-content: center;
    padding: 0;
}

/* --- Header --- */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 101;
    /* Higher than progress indicator */
    background: rgba(15, 10, 20, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    height: 64px;
    display: flex;
    align-items: center;
}

/* --- Side Menu --- */
#side-menu {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100vh;
    background: #15101a;
    border-left: 1px solid #333;
    transition: right 0.3s ease;
    z-index: 200;
    /* Highest layer */
    padding: 20px;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

#side-menu.open {
    right: 0;
}

.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 199;
    /* Just below menu */
    display: none;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.menu-overlay.open {
    display: block;
}

/* --- Mode Cards --- */
.mode-card {
    background: rgba(20, 15, 25, 0.9);
    border: 1px solid #333;
    border-radius: 16px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.mode-card:hover {
    border-color: var(--gold);
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(212, 175, 55, 0.2);
}

/* --- Spread Cards --- */
.spread-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Ensure child elements don't block button clicks */
.spread-card>*,
.mode-card>*,
.gallery-card>* {
    pointer-events: none;
}

.spread-card:hover {
    border-color: var(--gold);
    transform: translateX(4px);
}

/* Button reset for spread cards */
button.spread-card {
    background: rgba(20, 15, 25, 0.9);
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* --- Language Buttons --- */
.lang-btn {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    background: rgba(20, 15, 25, 0.9);
    border: 1px solid #444;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn:hover {
    border-color: var(--gold);
    background: rgba(212, 175, 55, 0.1);
}

/* --- Tarot Cards --- */
.card-container {
    perspective: 1000px;
    cursor: pointer;
    width: 28vw;
    max-width: 140px;
    height: calc(28vw * 1.6);
    max-height: 224px;
}

/* Bigger cards on desktop */
@media (min-width: 768px) {
    .card-container {
        max-width: 180px;
        max-height: 288px;
    }

    .card-container:hover .card-inner {
        transform: scale(1.08);
        filter: drop-shadow(0 0 12px rgba(212, 175, 55, 0.4));
    }

    .card-container.flipped:hover .card-inner {
        transform: rotateY(180deg) scale(1.08);
        filter: drop-shadow(0 0 12px rgba(212, 175, 55, 0.4));
    }
}

.card-inner {
    width: 100%;
    height: 100%;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    border: 1px solid rgba(212, 175, 55, 0.4);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.card-back {
    background: url('/static/Card_back.png') center/cover no-repeat;
}

.card-front {
    transform: rotateY(180deg);
    background: #1a1025;
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* --- Modals --- */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
    /* Above header (101) and progress bar (100) */
    background: rgba(0, 0, 0, 0.8);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal.open {
    opacity: 1;
    pointer-events: auto;
}

/* --- AI Content --- */
#ai-content {
    font-size: var(--ai-size);
    line-height: 1.8;
    transition: opacity 0.5s;
}

#ai-content h3 {
    color: var(--gold);
    margin-top: 1.5em;
}

#ai-content p {
    margin-bottom: 1em;
}

/* --- Form Elements --- */
.styled-select {
    appearance: none;
    background-color: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(212, 175, 55, 0.5);
    border-radius: 8px;
    color: var(--gold);
    padding-right: 2.5rem;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    background: #1a1025;
    border: 1px solid var(--gold);
    padding: 12px 24px;
    border-radius: 8px;
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    display: flex;
    gap: 8px;
    align-items: center;
    max-width: 90vw;
}

.toast.show {
    opacity: 1;
}

/* --- Star Rating --- */
.star-rating {
    display: flex;
    gap: 5px;
    justify-content: center;
    font-size: 30px;
    cursor: pointer;
}

.star {
    color: #444;
    transition: color 0.2s;
}

.star.active {
    color: #ffd700;
    text-shadow: 0 0 10px #ffd700;
}

/* --- Gallery --- */
.gallery-filter {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #444;
    color: #999;
    transition: all 0.2s;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 14px;
}

.gallery-filter:hover {
    border-color: #d4af37;
    color: #d4af37;
}

.gallery-filter.active {
    background: #d4af37;
    color: #000;
    border-color: #d4af37;
    font-weight: bold;
}

/* --- Suit Tabs (Manual Selection) --- */
.suit-tab {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #444;
    color: #999;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.suit-tab:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.suit-tab.active {
    background: var(--gold);
    color: #000;
    border-color: var(--gold);
}

.suit-tab[data-suit="major"].active {
    background: #6b21a8;
    /* Purple for Major Arcana */
    color: var(--gold);
    border-color: var(--gold);
}

/* Button reset for gallery cards */
button.gallery-card {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    color: inherit;
}

.gallery-card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border-radius: 6px;
    overflow: hidden;
}

.gallery-card:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

.gallery-card img {
    width: 100%;
    aspect-ratio: 1/1.6;
    object-fit: cover;
}

.gallery-card-name {
    font-size: 12px;
    text-align: center;
    padding: 4px 2px;
    background: rgba(0, 0, 0, 0.8);
    color: #d4af37;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* --- Skeleton Loader --- */
.skeleton {
    background: linear-gradient(90deg, #1a1025 25%, #2a1b3d 50%, #1a1025 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-card {
    width: 100%;
    height: 80px;
    margin-bottom: 12px;
}

.skeleton-gallery {
    aspect-ratio: 1/1.6;
    width: 100%;
}

/* --- Glowing Orb Loader --- */
.orb-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
}

.orb-loader {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff, #d4af37 20%, #6b21a8 60%, #1a1025 100%);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.6), inset -5px -5px 20px rgba(0, 0, 0, 0.5);
    animation: orb-pulse 2s ease-in-out infinite alternate;
    position: relative;
    z-index: 10;
}

.orb-loader::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 15%;
    width: 25%;
    height: 25%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.9), transparent);
    border-radius: 50%;
    animation: orb-float 3s ease-in-out infinite alternate;
}

.orb-loader::after {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: rgba(212, 175, 55, 0.6);
    border-bottom-color: rgba(107, 33, 168, 0.6);
    border-left-color: rgba(212, 175, 55, 0.2);
    border-right-color: rgba(107, 33, 168, 0.2);
    animation: orb-spin 3s linear infinite;
    filter: drop-shadow(0 0 5px rgba(212, 175, 55, 0.5));
    z-index: -1;
}

@keyframes orb-pulse {
    0% {
        box-shadow: 0 0 15px rgba(212, 175, 55, 0.4), inset -5px -5px 20px rgba(0, 0, 0, 0.5);
        transform: scale(0.95) translateY(0);
    }

    100% {
        box-shadow: 0 0 35px rgba(212, 175, 55, 0.9), 0 0 60px rgba(107, 33, 168, 0.8), inset -5px -5px 15px rgba(0, 0, 0, 0.3);
        transform: scale(1.05) translateY(-5px);
    }
}

@keyframes orb-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes orb-float {
    0% {
        transform: translate(0, 0);
        opacity: 0.5;
    }

    100% {
        transform: translate(8px, 8px);
        opacity: 1;
    }
}

.consulting-text {
    font-size: 1.125rem;
    color: var(--gold);
    animation: text-pulse 1.5s ease-in-out infinite alternate;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: bold;
}

@keyframes text-pulse {
    0% {
        opacity: 0.6;
        text-shadow: 0 0 5px rgba(212, 175, 55, 0.2);
    }

    100% {
        opacity: 1;
        text-shadow: 0 0 15px rgba(212, 175, 55, 0.8);
    }
}