/* ============================================================
   Tarot de los Sueños (ts) - Estilos de la aplicación onírica
   Namespace: .ts-app
   ============================================================ */

/* --- Variables de tema onírico --- */
.ts-app {
    --ts-morado: #8b5cf6;
    --ts-indigo: #6366f1;
    --ts-violeta: #7c3aed;
    --ts-purpura-profundo: #4c1d95;
    --ts-plata: #c4b5fd;
    --ts-oro-lunar: #fbbf24;
    --ts-azul-noche: #1e1b4b;
    --ts-azul-medianoche: #0f0c29;
    --ts-fuego: #f97316;
    --ts-agua: #3b82f6;
    --ts-aire: #a78bfa;
    --ts-tierra: #78716c;

    --ts-gradiente: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #3730a3 100%);
    --ts-gradiente-luna: linear-gradient(135deg, #c4b5fd 0%, #8b5cf6 50%, #6366f1 100%);
    --ts-gradiente-noche: linear-gradient(135deg, #0f0c29 0%, #1e1b4b 40%, #24243e 100%);
    --ts-gradiente-mistico: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
    --ts-gradiente-reverso: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4c1d95 100%);

    --ts-sombra: 0 8px 25px rgba(139, 92, 246, 0.25);
    --ts-sombra-intensa: 0 12px 35px rgba(139, 92, 246, 0.4);
    --ts-radio: 16px;
    --ts-transicion: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    color: #e2e8f0;
}

/* --- Fases comunes --- */
.ts-fase {
    animation: tsFadeIn 0.6s ease;
}

@keyframes tsFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   FASE PREGUNTA
   ============================================================ */
.ts-tiradas-header {
    text-align: center;
    margin-bottom: 2rem;
}

.ts-tiradas-titulo {
    font-size: 1.6rem;
    font-weight: 700;
    background: var(--ts-gradiente-luna);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.4rem;
}

.ts-tiradas-subtitulo {
    opacity: 0.75;
    font-size: 1rem;
}

/* Grid de botones de tirada */
.ts-tiradas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1.2rem;
    margin-bottom: 2.5rem;
}

.ts-btn-tirada {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(196, 181, 253, 0.18);
    border-radius: var(--ts-radio);
    padding: 1.5rem 1.2rem;
    cursor: pointer;
    color: #e2e8f0;
    text-align: center;
    transition: var(--ts-transicion);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    position: relative;
    overflow: hidden;
}

.ts-btn-tirada::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--ts-gradiente-mistico);
    opacity: 0;
    transition: opacity 0.35s ease;
    z-index: 0;
    border-radius: inherit;
}

.ts-btn-tirada > * {
    position: relative;
    z-index: 1;
}

.ts-btn-tirada:hover {
    border-color: var(--ts-violeta);
    transform: translateY(-6px);
    box-shadow: var(--ts-sombra);
}

.ts-btn-tirada:hover::before {
    opacity: 0.12;
}

.ts-btn-tirada:active {
    transform: translateY(-2px) scale(0.98);
}

.ts-tirada-icon {
    font-size: 2.4rem;
    margin-bottom: 0.2rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
}

.ts-tirada-nombre {
    font-weight: 700;
    font-size: 1.1rem;
}

.ts-tirada-cartas {
    background: rgba(139, 92, 246, 0.25);
    padding: 0.15rem 0.9rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ts-plata);
}

.ts-tirada-desc {
    font-size: 0.85rem;
    opacity: 0.65;
    margin-top: 0.2rem;
}

/* Input de pregunta */
.ts-pregunta-container {
    margin-top: 0.5rem;
}

.ts-pregunta-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.7rem;
    font-weight: 500;
    opacity: 0.85;
    font-size: 0.95rem;
}

.ts-label-icon {
    font-size: 1.3rem;
}

.ts-pregunta-input {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(196, 181, 253, 0.22);
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    transition: var(--ts-transicion);
    box-sizing: border-box;
}

.ts-pregunta-input:focus {
    outline: none;
    border-color: var(--ts-violeta);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
    background: rgba(255, 255, 255, 0.07);
}

.ts-pregunta-input::placeholder {
    opacity: 0.45;
    font-style: italic;
}

.ts-contador {
    text-align: right;
    font-size: 0.78rem;
    opacity: 0.55;
    margin-top: 0.35rem;
}

/* Error */
.ts-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    padding: 1rem 1.2rem;
    border-radius: 12px;
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

/* ============================================================
   LOADING
   ============================================================ */
.ts-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    text-align: center;
}

.ts-luna-carga {
    position: relative;
    width: 110px;
    height: 110px;
    margin: 0 auto 2rem;
}

.ts-luna-nucleo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    animation: tsPulsoLunar 2s ease-in-out infinite;
    filter: drop-shadow(0 0 18px rgba(196, 181, 253, 0.5));
}

@keyframes tsPulsoLunar {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
    50%      { transform: translate(-50%, -50%) scale(1.18); opacity: 1; }
}

.ts-luna-orbitas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ts-luna-orbita {
    position: absolute;
    border: 1px solid rgba(196, 181, 253, 0.25);
    border-radius: 50%;
    animation: tsOrbitaExpand 3.5s ease-out infinite;
}

.ts-orbita-1 {
    width: 70px; height: 70px;
    margin: -35px 0 0 -35px;
    border-color: rgba(196, 181, 253, 0.35);
}

.ts-orbita-2 {
    width: 100px; height: 100px;
    margin: -50px 0 0 -50px;
    animation-delay: 0.9s;
}

.ts-orbita-3 {
    width: 130px; height: 130px;
    margin: -65px 0 0 -65px;
    animation-delay: 1.8s;
    border-color: rgba(139, 92, 246, 0.18);
}

@keyframes tsOrbitaExpand {
    0%   { transform: scale(0.5); opacity: 0.8; }
    100% { transform: scale(1);   opacity: 0; }
}

.ts-loading-texto {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 1.5rem 0 0.3rem;
    color: #e2e8f0;
}

.ts-loading-subtexto {
    font-size: 0.9rem;
    opacity: 0.55;
    font-style: italic;
}

/* ============================================================
   FASE CARTAS (boca abajo)
   ============================================================ */
.ts-cartas-titulo {
    text-align: center;
    font-size: 1.4rem;
    margin-bottom: 2.5rem;
    background: var(--ts-gradiente-luna);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ts-cartas-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem 1.8rem;
}

/* Wrapper: carta + etiqueta de posición */
.ts-carta-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.ts-carta-posicion {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.7;
    text-align: center;
    max-width: 150px;
}

/* Carta flip */
.ts-carta {
    width: 140px;
    height: 210px;
    perspective: 800px;
    cursor: pointer;
}

.ts-carta-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.ts-carta.ts-revelada .ts-carta-inner {
    transform: rotateY(180deg);
}

/* Caras */
.ts-carta-frontal,
.ts-carta-reverso {
    position: absolute;
    inset: 0;
    border-radius: var(--ts-radio);
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
}

/* Reverso (visible inicialmente) */
.ts-carta-reverso {
    background: var(--ts-gradiente-reverso);
    border: 1px solid rgba(196, 181, 253, 0.2);
    box-shadow: var(--ts-sombra);
}

.ts-reverso-patron {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.ts-patron-luna {
    font-size: 2.2rem;
    opacity: 0.8;
}

.ts-patron-estrellas {
    font-size: 0.8rem;
    opacity: 0.45;
    letter-spacing: 0.3em;
}

.ts-patron-misterio {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--ts-plata);
    opacity: 0.5;
    margin-top: 0.3rem;
}

/* Frontal (tras el flip) */
.ts-carta-frontal {
    transform: rotateY(180deg);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Elemento - colores base */
.ts-elem-fuego { background: linear-gradient(135deg, #9a3412 0%, #c2410c 100%); }
.ts-elem-agua  { background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%); }
.ts-elem-aire  { background: linear-gradient(135deg, #4c1d95 0%, #7c3aed 100%); }
.ts-elem-tierra{ background: linear-gradient(135deg, #44403c 0%, #78716c 100%); }

.ts-carta-simbolo {
    font-size: 3rem;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

.ts-carta-nombre {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
}

.ts-carta-elemento {
    font-size: 0.7rem;
    text-transform: uppercase;
    background: rgba(0,0,0,0.35);
    padding: 0.15rem 0.7rem;
    border-radius: 10px;
    letter-spacing: 0.06em;
}

/* Hover carta boca abajo */
.ts-carta:not(.ts-revelada):hover .ts-carta-inner {
    transform: scale(1.06);
    transition: transform 0.25s ease;
}

/* ============================================================
   FASE RESULTADO
   ============================================================ */
.ts-resultado-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.ts-resultado-titulo {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--ts-gradiente-luna);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.ts-resultado-pregunta {
    font-size: 0.95rem;
    opacity: 0.75;
    font-style: italic;
}

.ts-label-pregunta {
    font-weight: 600;
    font-style: normal;
    opacity: 0.9;
}

/* Grid de cartas resultado */
.ts-resultado-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.8rem;
}

/* Tarjeta de resultado */
.ts-resultado-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(196, 181, 253, 0.15);
    border-radius: var(--ts-radio);
    padding: 1.8rem;
    animation: tsFadeIn 0.6s ease both;
}

/* Cabecera superior */
.ts-resultado-top {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.ts-resultado-simbolo {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
}

.ts-resultado-nombre {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
}

.ts-badge {
    display: inline-block;
    font-size: 0.68rem;
    text-transform: uppercase;
    padding: 0.15rem 0.55rem;
    border-radius: 8px;
    letter-spacing: 0.06em;
    opacity: 0.8;
}

.ts-elem-badge-fuego { background: rgba(249, 115, 22, 0.3); }
.ts-elem-badge-agua  { background: rgba(59, 130, 246, 0.3); }
.ts-elem-badge-aire  { background: rgba(167, 139, 250, 0.3); }
.ts-elem-badge-tierra{ background: rgba(120, 113, 108, 0.3); }

/* Posición */
.ts-resultado-pos {
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0.8;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid rgba(196, 181, 253, 0.12);
}

/* Mensaje */
.ts-resultado-mensaje {
    line-height: 1.7;
    opacity: 0.9;
    margin-bottom: 1.2rem;
}

/* Consejo */
.ts-resultado-consejo {
    background: rgba(139, 92, 246, 0.12);
    border-left: 3px solid var(--ts-violeta);
    padding: 1rem 1.2rem;
    border-radius: 0 10px 10px 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.ts-consejo-icon {
    font-size: 1.1rem;
}

.ts-consejo-label {
    font-weight: 700;
    color: var(--ts-plata);
}

/* Botón nueva consulta */
.ts-nueva-consulta {
    text-align: center;
    margin-top: 3rem;
}

.ts-btn-nueva {
    background: var(--ts-gradiente-mistico);
    border: none;
    padding: 0.9rem 2.5rem;
    border-radius: 30px;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--ts-transicion);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.ts-btn-nueva:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.45);
}

.ts-btn-nueva:active {
    transform: translateY(0) scale(0.98);
}

.ts-btn-icon {
    font-size: 1.3rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .ts-tiradas-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .ts-carta {
        width: 120px;
        height: 180px;
    }

    .ts-carta-simbolo {
        font-size: 2.4rem;
    }

    .ts-carta-nombre {
        font-size: 0.75rem;
    }

    .ts-resultado-grid {
        grid-template-columns: 1fr;
    }

    .ts-resultado-titulo {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .ts-tiradas-grid {
        grid-template-columns: 1fr;
    }

    .ts-btn-tirada {
        padding: 1.2rem 1rem;
    }

    .ts-tirada-icon {
        font-size: 2rem;
    }

    .ts-tirada-nombre {
        font-size: 1rem;
    }

    .ts-cartas-grid {
        gap: 1.5rem 1rem;
    }

    .ts-carta {
        width: 105px;
        height: 158px;
    }

    .ts-carta-simbolo {
        font-size: 2rem;
    }

    .ts-luna-carga {
        width: 80px;
        height: 80px;
    }

    .ts-luna-nucleo {
        font-size: 2.2rem;
    }

    .ts-orbita-1 { width: 55px; height: 55px; margin: -27px 0 0 -27px; }
    .ts-orbita-2 { width: 80px; height: 80px; margin: -40px 0 0 -40px; }
    .ts-orbita-3 { width: 100px; height: 100px; margin: -50px 0 0 -50px; }

    .ts-resultado-card {
        padding: 1.3rem;
    }

    .ts-resultado-simbolo {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }

    .ts-resultado-nombre {
        font-size: 1rem;
    }
}

@media (max-width: 320px) {
    .ts-carta {
        width: 90px;
        height: 135px;
    }

    .ts-carta-simbolo {
        font-size: 2rem;
    }

    .ts-btn-nueva {
        padding: 0.75rem 1.8rem;
        font-size: 0.9rem;
    }
}

/* ============================================================
   ACCESIBILIDAD
   ============================================================ */
@media (prefers-contrast: high) {
    .ts-btn-tirada,
    .ts-carta-reverso,
    .ts-carta-frontal,
    .ts-resultado-card {
        border: 2px solid white;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ts-luna-nucleo,
    .ts-luna-orbita,
    .ts-fase,
    .ts-resultado-card {
        animation: none;
    }

    .ts-carta-inner,
    .ts-btn-tirada,
    .ts-btn-nueva {
        transition: none;
    }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    .ts-btn-tirada,
    .ts-pregunta-container,
    .ts-loading,
    .ts-carta {
        display: none;
    }

    .ts-resultado-card {
        break-inside: avoid;
        border: 1px solid #ccc;
        background: white;
        color: black;
    }

    .ts-resultado-titulo,
    .ts-resultado-nombre {
        color: black !important;
        -webkit-text-fill-color: black !important;
    }
}
