/* ============================================================
   PÉNDULO ONLINE — Estilos
   Estética mística oscura — coherente con Oráculo I-Ching
   ============================================================ */

/* --- Variables --- */
:root {
    --gold:         #c9a84c;
    --gold-dim:     rgba(201,168,76,0.35);
    --gold-glow:    rgba(201,168,76,0.15);
    --bg-deep:      #0d1117;
    --bg-card:      rgba(255,255,255,0.04);
    --bg-card-b:    rgba(255,255,255,0.07);
    --white:        #e8e0d0;
    --white-dim:    rgba(232,224,208,0.55);
    --green:        #5aa86a;
    --red:          #c44;
    --amber:        #c9a84c;
    --font-title:   'Cinzel', serif;
    --font-body:    'IM Fell English', serif;
    --font-ui:      'Crimson Pro', serif;
    --shadow-gold:  0 0 40px rgba(201,168,76,0.12);
}

/* --- Reset base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg-deep);
    color: var(--white);
    font-family: var(--font-body);
    min-height: 100vh;
}

/* --- Patrón de fondo estelar (igual que I-Ching) --- */
#pendulo-app {
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(201,168,76,0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(100,80,200,0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 0%,  rgba(201,168,76,0.06) 0%, transparent 60%),
        var(--bg-deep);
    position: relative;
}

#pendulo-app::before {
    content: '';
    position: fixed; inset: 0;
    background-image:
        radial-gradient(1px 1px at 15% 25%, rgba(201,168,76,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 35% 10%, rgba(255,255,255,0.25) 0%, transparent 100%),
        radial-gradient(1px 1px at 55% 40%, rgba(201,168,76,0.3) 0%, transparent 100%),
        radial-gradient(1px 1px at 75% 15%, rgba(255,255,255,0.2) 0%, transparent 100%),
        radial-gradient(1px 1px at 90% 60%, rgba(201,168,76,0.35) 0%, transparent 100%),
        radial-gradient(1px 1px at 10% 70%, rgba(255,255,255,0.15) 0%, transparent 100%),
        radial-gradient(1px 1px at 45% 85%, rgba(201,168,76,0.2) 0%, transparent 100%),
        radial-gradient(1px 1px at 65% 75%, rgba(255,255,255,0.18) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 25% 55%, rgba(201,168,76,0.25) 0%, transparent 100%),
        radial-gradient(1px 1px at 85% 35%, rgba(255,255,255,0.12) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

.pendulo-container {
    position: relative;
    z-index: 1;
    max-width: 680px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

/* ============================================================
   ENCABEZADO
   ============================================================ */
.pendulo-header {
    text-align: center;
    margin-bottom: 44px;
}

.trigram-deco {
    display: block;
    font-size: 18px;
    color: var(--gold-dim);
    letter-spacing: 12px;
    margin-bottom: 18px;
}

.pendulo-title {
    font-family: var(--font-title);
    font-size: clamp(28px, 6vw, 52px);
    font-weight: 600;
    color: var(--gold);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-shadow: 0 0 60px rgba(201,168,76,0.3), 0 2px 20px rgba(0,0,0,0.6);
    margin-bottom: 10px;
}

.pendulo-subtitle {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(13px, 2.5vw, 17px);
    color: var(--white-dim);
    letter-spacing: 0.08em;
}

/* --- Línea decorativa bajo el encabezado --- */
.pendulo-header::after {
    content: '';
    display: block;
    width: 80px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    margin: 20px auto 0;
}

/* ============================================================
   PASOS
   ============================================================ */
.p-step {
    display: none;
    animation: fadeIn 0.5s ease;
}
.p-step.active { display: block; }

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

/* ============================================================
   PASO 1 — PREGUNTA
   ============================================================ */
.question-section {
    background: var(--bg-card);
    border: 1px solid var(--gold-dim);
    border-radius: 12px;
    padding: 28px 28px 20px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-gold);
}

.question-label {
    display: block;
    margin-bottom: 16px;
}

.question-label span:first-child {
    display: block;
    font-family: var(--font-title);
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 6px;
}

.question-hint {
    display: block;
    font-family: var(--font-body);
    font-style: italic;
    font-size: 13px;
    color: var(--white-dim);
}

.question-textarea {
    width: 100%;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(201,168,76,0.2);
    border-radius: 8px;
    color: var(--white);
    font-family: var(--font-body);
    font-size: 16px;
    padding: 14px 16px;
    resize: none;
    transition: border-color 0.3s;
    outline: none;
}
.question-textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201,168,76,0.08);
}
.question-textarea::placeholder { color: rgba(232,224,208,0.25); }

.char-counter {
    text-align: right;
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--white-dim);
    margin-top: 8px;
    letter-spacing: 1px;
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn-oracle {
    display: block;
    width: 100%;
    background: linear-gradient(135deg, #b8922e, #c9a84c, #d4b56a, #c9a84c);
    background-size: 200% 200%;
    border: none;
    border-radius: 6px;
    color: #1a1200;
    font-family: var(--font-title);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    padding: 18px 32px;
    cursor: pointer;
    transition: opacity 0.2s, box-shadow 0.2s, background-position 0.5s;
    box-shadow: 0 4px 24px rgba(201,168,76,0.25);
}
.btn-oracle:hover {
    opacity: 0.92;
    box-shadow: 0 6px 32px rgba(201,168,76,0.4);
    background-position: right center;
}
.btn-oracle:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--gold-dim);
    border-radius: 6px;
    color: var(--gold);
    font-family: var(--font-title);
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    padding: 14px 40px;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;
}
.btn-secondary:hover {
    border-color: var(--gold);
    background: rgba(201,168,76,0.06);
}

/* ============================================================
   ORNAMENTO
   ============================================================ */
.ornament {
    text-align: center;
    color: var(--gold-dim);
    font-family: var(--font-ui);
    font-size: 14px;
    letter-spacing: 8px;
    margin: 28px 0;
}

/* ============================================================
   PASO 2 — ESCENA DEL PÉNDULO
   ============================================================ */
.pendulo-instruccion {
    text-align: center;
    font-family: var(--font-body);
    font-style: italic;
    font-size: 15px;
    color: var(--white-dim);
    margin-bottom: 28px;
    letter-spacing: 0.03em;
}

.pendulo-scene {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 auto;
    width: 340px;
    max-width: 100%;
}

/* Barra soporte superior */
.pendulo-pivot-bar {
    position: relative;
    width: 200px;
    height: 14px;
    background: linear-gradient(180deg, #3a3020, #2a2215, #3a3020);
    border-radius: 7px;
    border: 1px solid rgba(201,168,76,0.35);
    box-shadow: 0 2px 12px rgba(0,0,0,0.6), inset 0 1px 0 rgba(201,168,76,0.2);
    z-index: 3;
    margin-bottom: 0;
}

.pivot-cap {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 10px; height: 18px;
    background: linear-gradient(180deg, #c9a84c, #8a6a28);
    border-radius: 3px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.pivot-cap.left  { left: 10px; }
.pivot-cap.right { right: 10px; }

.pivot-center {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 12px; height: 12px;
    border-radius: 50%;
    background: radial-gradient(circle, #e8c86a, #a07830);
    box-shadow: 0 0 8px rgba(201,168,76,0.6);
}

/* Brazo del péndulo (hilo + cristal, gira desde arriba) */
.pendulo-arm {
    position: absolute;
    top: 7px; /* centro del pivot-bar */
    left: 50%;
    transform-origin: top center;
    transform: translateX(-50%) rotate(0deg);
    width: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 4;
    /* La animación se añade via JS */
}

.pendulo-string {
    width: 1.5px;
    height: 160px;
    background: linear-gradient(180deg,
        rgba(201,168,76,0.8) 0%,
        rgba(201,168,76,0.5) 60%,
        rgba(201,168,76,0.3) 100%);
    box-shadow: 0 0 4px rgba(201,168,76,0.2);
}

/* Cristal del péndulo */
.pendulo-crystal {
    position: relative;
    width: 28px;
    height: 52px;
    margin-top: -1px;
}

.crystal-inner {
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 38px;
    background: linear-gradient(160deg,
        rgba(180,200,255,0.25) 0%,
        rgba(100,120,200,0.45) 30%,
        rgba(50,60,140,0.7)   60%,
        rgba(20,25,80,0.85)   100%);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    box-shadow:
        inset 0 0 12px rgba(150,180,255,0.2),
        0 0 20px rgba(100,130,255,0.15);
    border: 1px solid rgba(180,200,255,0.3);
}

.crystal-glare {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-40%);
    width: 5px;
    height: 14px;
    background: linear-gradient(180deg, rgba(255,255,255,0.6), transparent);
    clip-path: polygon(40% 0%, 100% 10%, 80% 100%, 0% 80%);
    opacity: 0.7;
}

.crystal-point {
    position: absolute;
    bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: 0; height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 14px solid rgba(40,50,120,0.9);
    filter: drop-shadow(0 4px 8px rgba(100,130,255,0.3));
}

.crystal-glow {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 40px; height: 40px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(100,130,255,0.15), transparent 70%);
    pointer-events: none;
    transition: opacity 0.3s;
    opacity: 0;
}

/* Glow activo durante animación */
.pendulo-arm.swinging .crystal-glow {
    opacity: 1;
    animation: crystalPulse 1.8s ease-in-out infinite;
}

@keyframes crystalPulse {
    0%, 100% { transform: translate(-50%,-50%) scale(1);   opacity: 0.5; }
    50%       { transform: translate(-50%,-50%) scale(1.3); opacity: 1;   }
}

/* ============================================================
   TABLERO SVG
   ============================================================ */
.pendulo-board {
    position: relative;
    margin-top: 160px; /* espacio para que el hilo quede encima */
    width: 340px;
    max-width: 100%;
    z-index: 1;
}

.board-svg {
    width: 100%;
    height: auto;
    overflow: visible;
}

.board-label {
    font-family: 'Cinzel', serif;
    font-size: 13px;
    fill: rgba(201,168,76,0.55);
    letter-spacing: 2px;
    text-transform: uppercase;
}
.board-label-si     { fill: rgba(90,168,106,0.7); }
.board-label-no     { fill: rgba(200,80,80,0.7); }
.board-label-quizas { fill: rgba(201,168,76,0.7); }

/* Zonas activas al revelar resultado */
.board-zone-active path { filter: brightness(2); transition: filter 0.5s; }

/* ============================================================
   PREGUNTA MOSTRADA BAJO EL PÉNDULO
   ============================================================ */
.pregunta-display {
    margin-top: 20px;
    text-align: center;
    font-family: var(--font-body);
    font-style: italic;
    font-size: 15px;
    color: var(--white-dim);
    padding: 0 20px;
    min-height: 24px;
}

/* ============================================================
   ANIMACIONES DEL PÉNDULO
   ============================================================ */

/* Oscilación genérica (exploración) */
@keyframes swing-explore {
    0%   { transform: translateX(-50%) rotate(-8deg); }
    50%  { transform: translateX(-50%) rotate(8deg);  }
    100% { transform: translateX(-50%) rotate(-8deg); }
}

/* Oscilación vertical: Sí (atrás-adelante = izquierda leve) */
@keyframes swing-si {
    0%   { transform: translateX(-50%) rotate(-22deg); }
    50%  { transform: translateX(-50%) rotate(22deg);  }
    100% { transform: translateX(-50%) rotate(-22deg); }
}

/* Oscilación horizontal: No (de lado a lado = amplio) */
@keyframes swing-no {
    0%   { transform: translateX(-50%) rotate(-35deg); }
    50%  { transform: translateX(-50%) rotate(35deg);  }
    100% { transform: translateX(-50%) rotate(-35deg); }
}

/* Circular: Quizás (pseudo-circular con rotación sinusoidal compleja) */
@keyframes swing-quizas-a {
    0%   { transform: translateX(-50%) rotate(-18deg); }
    25%  { transform: translateX(-50%) rotate(5deg);   }
    50%  { transform: translateX(-50%) rotate(18deg);  }
    75%  { transform: translateX(-50%) rotate(-5deg);  }
    100% { transform: translateX(-50%) rotate(-18deg); }
}

/* Frenada hasta posición final */
@keyframes swing-stop-si {
    0%   { transform: translateX(-50%) rotate(-22deg); }
    60%  { transform: translateX(-50%) rotate(10deg);  }
    80%  { transform: translateX(-50%) rotate(-5deg);  }
    90%  { transform: translateX(-50%) rotate(2deg);   }
    100% { transform: translateX(-50%) rotate(0deg);   }
}

@keyframes swing-stop-no {
    0%   { transform: translateX(-50%) rotate(35deg);  }
    60%  { transform: translateX(-50%) rotate(-15deg); }
    80%  { transform: translateX(-50%) rotate(6deg);   }
    90%  { transform: translateX(-50%) rotate(-2deg);  }
    100% { transform: translateX(-50%) rotate(0deg);   }
}

@keyframes swing-stop-quizas {
    0%   { transform: translateX(-50%) rotate(18deg);  }
    30%  { transform: translateX(-50%) rotate(-8deg);  }
    60%  { transform: translateX(-50%) rotate(4deg);   }
    80%  { transform: translateX(-50%) rotate(-1deg);  }
    100% { transform: translateX(-50%) rotate(0deg);   }
}

/* Estado idle: pequeñísima oscilación respiratoria */
.pendulo-arm.idle {
    animation: swing-idle 4s ease-in-out infinite;
}
@keyframes swing-idle {
    0%, 100% { transform: translateX(-50%) rotate(-3deg); }
    50%       { transform: translateX(-50%) rotate(3deg);  }
}

/* Clases que JS asigna */
.pendulo-arm.exploring {
    animation: swing-explore 1.8s ease-in-out infinite;
}
.pendulo-arm.answering-si {
    animation: swing-si 0.9s ease-in-out infinite;
}
.pendulo-arm.answering-no {
    animation: swing-no 1.1s ease-in-out infinite;
}
.pendulo-arm.answering-quizas {
    animation: swing-quizas-a 2.2s ease-in-out infinite;
}

/* ============================================================
   RESALTADO DE ZONAS DEL TABLERO AL REVELAR
   ============================================================ */
#board-si, #board-quizas, #board-no {
    transition: fill 0.6s ease, filter 0.6s ease;
}

.zone-lit-si {
    fill: rgba(80,168,100,0.28) !important;
    filter: drop-shadow(0 0 8px rgba(80,200,100,0.4));
}
.zone-lit-no {
    fill: rgba(200,60,60,0.28) !important;
    filter: drop-shadow(0 0 8px rgba(220,80,80,0.4));
}
.zone-lit-quizas {
    fill: rgba(201,168,76,0.28) !important;
    filter: drop-shadow(0 0 8px rgba(201,168,76,0.4));
}

/* ============================================================
   PASO 3 — RESULTADO
   ============================================================ */
.result-title {
    font-family: var(--font-title);
    font-size: 11px;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--gold);
    text-align: center;
    margin-bottom: 32px;
}

.result-answer-box {
    background: var(--bg-card);
    border: 1px solid var(--gold-dim);
    border-radius: 14px;
    padding: 36px 28px;
    text-align: center;
    box-shadow: var(--shadow-gold);
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.result-answer-box::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(ellipse at 50% 30%, rgba(201,168,76,0.05), transparent 70%);
    pointer-events: none;
}

.result-answer-icon {
    font-size: 52px;
    margin-bottom: 16px;
    animation: iconReveal 0.8s cubic-bezier(0.34,1.56,0.64,1) both;
}

.result-answer-text {
    font-family: var(--font-title);
    font-size: clamp(36px, 10vw, 72px);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 12px;
    animation: textReveal 0.9s cubic-bezier(0.34,1.56,0.64,1) 0.1s both;
}

.result-answer-text.answer-si     { color: #5aa86a; text-shadow: 0 0 30px rgba(90,168,106,0.4); }
.result-answer-text.answer-no     { color: #c44;    text-shadow: 0 0 30px rgba(200,80,80,0.4); }
.result-answer-text.answer-quizas { color: var(--gold); text-shadow: 0 0 30px rgba(201,168,76,0.4); }

.result-answer-sub {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 15px;
    color: var(--white-dim);
    animation: textReveal 1s ease 0.3s both;
}

@keyframes iconReveal {
    from { transform: scale(0) rotate(-20deg); opacity: 0; }
    to   { transform: scale(1) rotate(0deg);   opacity: 1; }
}
@keyframes textReveal {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.result-question-echo {
    background: rgba(255,255,255,0.03);
    border-left: 2px solid var(--gold-dim);
    border-radius: 0 8px 8px 0;
    padding: 14px 20px;
    font-family: var(--font-body);
    font-style: italic;
    font-size: 15px;
    color: var(--white-dim);
}

/* ============================================================
   BOTÓN ACTIVAR PÉNDULO
   ============================================================ */
.btn-activate {
    width: auto;
    padding: 16px 48px;
    display: block;
    margin: 0 auto;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 400px) {
    .pendulo-container { padding: 28px 16px 48px; }
    .pendulo-scene     { width: 100%; }
    .pendulo-board     { width: 100%; }
    .question-section  { padding: 20px 16px 14px; }
}
