/* ============================================
   VARIABLES CSS
============================================ */
:root {
    /* Colores principales - Paleta mística */
    --bg-primary: #171E36;
    --bg-secondary: #1E2740;
    --bg-card: #252D47;
    --bg-card-hover: #2A3350;
    
    --gold-primary: #D4AF37;
    --gold-light: #FFD700;
    --gold-dark: #B8960F;
    
    --text-primary: #FFFFFF;
    --text-secondary: #B8C5D6;
    --text-muted: #7A8AA3;
    
    --accent-purple: #9D7BE8;
    --accent-cyan: #4ECDC4;
    
    /* Sombras místicas */
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-strong: 0 12px 48px rgba(0, 0, 0, 0.5);
    --shadow-gold: 0 0 30px rgba(212, 175, 55, 0.3);
    
    /* Tipografía */
    --font-display: 'Cinzel', serif;
    --font-body: 'Cormorant Garamond', serif;
    
    /* Transiciones */
    --transition-smooth: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ============================================
   RESET Y BASE
============================================ */
* {
    box-sizing: border-box;
}

#iching-app {
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ============================================
   PARTÍCULAS MÍSTICAS DE FONDO
============================================ */
.mystic-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(157, 123, 232, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(78, 205, 196, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(212, 175, 55, 0.03) 0%, transparent 70%);
    animation: particleFloat 20s ease-in-out infinite alternate;
}

@keyframes particleFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(20px, -20px) scale(1.05); }
}

/* ============================================
   CONTENEDOR PRINCIPAL
============================================ */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    padding: 20px;
    margin: 0 auto;
}

/* ============================================
   STEPS - TRANSICIONES
============================================ */
.step {
    display: none;
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.6s ease-out forwards;
}

.step.active {
    display: block;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   PASO 1: PREGUNTA
============================================ */
.question-container {
    max-width: 700px;
    margin: 40px auto;
    text-align: center;
}

.app-header {
    margin-bottom: 50px;
}

.trigram-symbol {
    font-size: 48px;
    letter-spacing: 10px;
    color: var(--gold-primary);
    margin-bottom: 20px;
    animation: glowPulse 3s ease-in-out infinite;
    filter: drop-shadow(0 0 10px var(--gold-primary));
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.8; filter: drop-shadow(0 0 10px var(--gold-primary)); }
    50% { opacity: 1; filter: drop-shadow(0 0 20px var(--gold-light)); }
}

.app-title {
    font-family: var(--font-display);
    font-size: 72px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 8px;
}

.app-title::before {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    z-index: -1;
    /*background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));*/
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: blur(15px);
    opacity: 0.5;
}

.app-subtitle {
    font-family: var(--font-body);
    font-size: 20px;
    font-weight: 300;
    color: var(--text-secondary);
    margin-top: 10px;
    letter-spacing: 3px;
}

.question-box {
    background: var(--bg-secondary);
    border: 2px solid rgba(212, 175, 55, 0.2);
    border-radius: 16px;
    padding: 30px;
    margin: 40px 0;
    box-shadow: var(--shadow-medium);
    transition: var(--transition-smooth);
}

.question-box:hover {
    border-color: rgba(212, 175, 55, 0.4);
    box-shadow: var(--shadow-gold);
}

.question-label {
    display: block;
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--gold-primary);
    margin-bottom: 20px;
    letter-spacing: 2px;
}

.label-icon {
    display: inline-block;
    margin: 0 10px;
    animation: twinkle 2s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.question-textarea {
    width: 100%;
    min-height: 120px;
    background: var(--bg-primary);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 12px;
    padding: 20px;
    font-family: var(--font-body);
    font-size: 18px;
    color: var(--text-primary);
    resize: vertical;
    transition: var(--transition-smooth);
}

.question-textarea:focus {
    outline: none;
    border-color: var(--gold-primary);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
}

.question-textarea::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.char-counter {
    text-align: right;
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 10px;
}

/* ============================================
   BOTONES
============================================ */
.btn-primary,
.btn-secondary {
    position: relative;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 2px;
    padding: 18px 50px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition-smooth);
    overflow: hidden;
    text-transform: uppercase;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-dark));
    color: var(--bg-primary);
    box-shadow: var(--shadow-gold);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.5);
}

.btn-primary:active {
    transform: translateY(-1px);
}

.btn-glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.btn-primary:hover .btn-glow {
    left: 100%;
}

.btn-secondary {
    background: transparent;
    color: var(--gold-primary);
    border: 2px solid var(--gold-primary);
}

.btn-secondary:hover {
    background: var(--gold-primary);
    color: var(--bg-primary);
    transform: translateY(-2px);
}

.btn-icon {
    margin-right: 10px;
    display: inline-block;
    transition: transform 0.3s;
}

.btn-secondary:hover .btn-icon {
    transform: rotate(180deg);
}

/* ============================================
   PASO 2: SELECCIÓN DE CARTAS
============================================ */
.selection-container {
    max-width: 1100px;
    margin: 40px auto;
}

.selection-header {
    text-align: center;
    margin-bottom: 50px;
}

.selection-title {
    font-family: var(--font-display);
    font-size: 42px;
    font-weight: 700;
    color: var(--gold-primary);
    margin-bottom: 30px;
    letter-spacing: 3px;
}

.selection-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.progress-orbs {
    display: flex;
    gap: 20px;
}

.orb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--gold-dark);
    transition: var(--transition-smooth);
}

.orb.active {
    background: var(--gold-primary);
    box-shadow: 0 0 20px var(--gold-light);
    animation: orbPulse 1s ease-in-out;
}

@keyframes orbPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

.progress-text {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--text-secondary);
    letter-spacing: 2px;
}

#cards-selected {
    color: var(--gold-primary);
    font-weight: 700;
}

/* ============================================
   GRID DE CARTAS
============================================ */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px;
    padding: 20px;
}

.card {
    position: relative;
    aspect-ratio: 2.5 / 3.5;
    cursor: pointer;
    transition: var(--transition-smooth);
    transform-style: preserve-3d;
    perspective: 1000px;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-medium);
}

.card-back {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-card-hover));
    border: 2px solid var(--gold-dark);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-back-pattern {
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(212, 175, 55, 0.05) 10px, rgba(212, 175, 55, 0.05) 20px),
        repeating-linear-gradient(-45deg, transparent, transparent 10px, rgba(212, 175, 55, 0.05) 10px, rgba(212, 175, 55, 0.05) 20px);
}

.card-back-symbol {
    position: absolute;
    font-size: 48px;
    color: var(--gold-dark);
    opacity: 0.3;
}

.card-front {
    transform: rotateY(180deg);
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Efecto hover */
.card:hover {
    transform: translateY(-10px) scale(1.05);
    filter: brightness(1.2);
}

/* Efecto seleccionada */
.card.selected {
    animation: goldenGlow 1.5s ease-in-out infinite;
}

@keyframes goldenGlow {
    0%, 100% {
        box-shadow: 0 0 20px var(--gold-primary), 0 0 40px var(--gold-light);
        transform: translateY(-10px) scale(1.05);
    }
    50% {
        box-shadow: 0 0 40px var(--gold-light), 0 0 60px var(--gold-primary);
        transform: translateY(-15px) scale(1.08);
    }
}

.card.selected .card-face {
    border: 3px solid var(--gold-light);
}

/* ============================================
   PASO 3: LECTURA
============================================ */
.reading-container {
    max-width: 900px;
    margin: 40px auto;
}

.reading-header {
    text-align: center;
    margin-bottom: 50px;
}

.trigram-decoration {
    font-size: 32px;
    letter-spacing: 15px;
    color: var(--gold-dark);
    margin-bottom: 20px;
    opacity: 0.5;
}

.reading-title {
    font-family: var(--font-display);
    font-size: 42px;
    font-weight: 700;
    color: var(--gold-primary);
    letter-spacing: 3px;
}

/* Hexagramas seleccionados */
.selected-hexagrams {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-bottom: 50px;
}

.hexagram-slot {
    text-align: center;
}

.hexagram-label {
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--gold-primary);
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.hexagram-card {
    aspect-ratio: 2.5 / 3.5;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-medium);
    border: 2px solid var(--gold-dark);
}

.hexagram-card img {
    width: 100%;
    height: 100%;
    /*object-fit: cover;*/
}

/* Loading */
.loading-reading {
    text-align: center;
    padding: 60px 20px;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--bg-card);
    border-top: 4px solid var(--gold-primary);
    border-radius: 50%;
    margin: 0 auto 30px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--text-secondary);
    letter-spacing: 2px;
}

/* Resultado */
.reading-result {
    display: none;
    background: var(--bg-secondary);
    border: 2px solid rgba(212, 175, 55, 0.2);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-medium);
    font-size: 18px;
    line-height: 1.8;
    color: var(--text-primary);
}

.reading-result.visible {
    display: block;
    animation: fadeInUp 0.6s ease-out;
}

.reading-actions {
    text-align: center;
    margin-top: 40px;
}

/* ============================================
   MODAL
============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-secondary);
    border: 2px solid var(--gold-dark);
    border-radius: 16px;
    padding: 40px;
    max-width: 500px;
    text-align: center;
    box-shadow: var(--shadow-strong);
    animation: modalSlideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes modalSlideIn {
    from { transform: scale(0.7) translateY(-50px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-icon {
    font-size: 60px;
    margin-bottom: 20px;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 28px;
    color: var(--gold-primary);
    margin-bottom: 20px;
}

.modal-message {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 30px;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* ============================================
   RESPONSIVE
============================================ */
@media (max-width: 768px) {
    .app-title {
        font-size: 48px;
        letter-spacing: 4px;
    }
    
    .app-subtitle {
        font-size: 16px;
    }
    
    .selection-title,
    .reading-title {
        font-size: 32px;
    }
    
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 15px;
    }
    
    .selected-hexagrams {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .btn-primary,
    .btn-secondary {
        font-size: 16px;
        padding: 15px 35px;
    }
    
    .question-textarea {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 36px;
    }
    
    .trigram-symbol {
        font-size: 36px;
    }
    
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 10px;
    }
}
