/* ============================================================
   ANTI-BOT PUZZLE — self-made, non-annoying
   ============================================================ */

.puzzle {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 14px;
    padding: 1.2rem 1.35rem;
    max-width: 460px;
    margin: 0 auto;
    box-shadow: 0 10px 30px -15px rgba(0,0,0,.12);
}

.puzzle-head {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: .9rem;
}
.puzzle-head-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(200, 150, 92, .15);
    color: var(--atacama-gold, #c8965c);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.puzzle-head strong {
    display: block;
    font-family: var(--font-display, 'Fraunces', Georgia, serif);
    font-weight: 500;
    font-size: 1.05rem;
    color: var(--on-light, #222);
    margin-bottom: .1rem;
}
.puzzle-head span {
    font-size: .78rem;
    color: var(--on-light-muted, #666);
}

/* ── Prompt (secuencia pedida) ─────────────────────────── */
.puzzle-prompt {
    display: flex;
    align-items: center;
    gap: .5rem;
    list-style: none;
    padding: .8rem 1rem;
    margin: 0 0 1rem;
    background: linear-gradient(90deg, rgba(200,150,92,.08), rgba(200,150,92,.02));
    border: 1px dashed rgba(200, 150, 92, .4);
    border-radius: 10px;
    counter-reset: step;
    flex-wrap: wrap;
}
.puzzle-prompt li {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .7rem;
    background: #fff;
    border-radius: 8px;
    border: 1px solid rgba(200, 150, 92, .3);
    font-size: .82rem;
    color: var(--on-light, #333);
    position: relative;
    counter-increment: step;
}
.puzzle-prompt li::before {
    content: counter(step);
    font-size: .62rem;
    font-weight: 700;
    color: var(--atacama-gold, #c8965c);
    background: rgba(200, 150, 92, .15);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: .15rem;
}
.puzzle-prompt li i {
    color: var(--atacama-gold-dk, #a37241);
    font-size: .9rem;
}

/* ── Piezas (grid clickeable) ──────────────────────────── */
.puzzle-pieces {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: .5rem;
    margin-bottom: .9rem;
}
.puzzle-piece {
    aspect-ratio: 1;
    border: 2px solid rgba(0,0,0,.1);
    background: linear-gradient(145deg, #FBF7EE, #F0E9DA);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--on-light, #4a3f33);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 1px 2px rgba(0,0,0,.05);
    transition: transform .2s ease, border-color .2s ease, background .2s ease, color .2s ease, box-shadow .2s ease;
    position: relative;
    padding: 0;
}
.puzzle-piece:hover:not(:disabled) {
    transform: translateY(-3px);
    border-color: var(--atacama-gold, #c8965c);
    color: var(--atacama-gold-dk, #a47340);
    background: linear-gradient(145deg, #fff, #FBF3E6);
    box-shadow: 0 8px 20px -10px rgba(184, 110, 60, .5);
}
.puzzle-piece.picked {
    background: var(--atacama-gold-dk, #a47340);
    border-color: var(--atacama-gold-dk, #a47340);
    color: #fff;
    transform: scale(.96);
    box-shadow: 0 4px 14px -6px rgba(164, 115, 64, .6);
}
/* badge de orden: círculo claro arriba-izquierda, legible */
.puzzle-piece.picked::after {
    content: attr(data-pick-order);
    position: absolute;
    top: -7px;
    left: -7px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    color: var(--atacama-gold-dk, #a47340);
    border: 2px solid var(--atacama-gold-dk, #a47340);
    font-size: .72rem;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.puzzle-piece:disabled { cursor: not-allowed; opacity: .55; }
.puzzle-piece.wrong {
    background: rgba(220, 53, 69, .14);
    border-color: #dc3545;
    color: #c0392b;
    animation: piece-wrong .4s ease;
}
@keyframes piece-wrong {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.1); }
}

/* Shake the whole puzzle on a wrong pick */
.puzzle.shake { animation: puzzle-shake .45s cubic-bezier(.36,.07,.19,.97); }
@keyframes puzzle-shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-7px); }
    40%, 60% { transform: translateX(7px); }
}

/* ── Status bar ────────────────────────────────────────── */
.puzzle-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .55rem .8rem;
    background: rgba(0,0,0,.03);
    border-radius: 8px;
    font-size: .78rem;
    color: var(--on-light-muted, #666);
}
.puzzle-status.ok {
    background: rgba(39, 201, 63, .1);
    color: #1a8a2a;
}
.puzzle-status.err {
    background: rgba(220, 53, 69, .1);
    color: #c0392b;
}
.puzzle-reset {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: .85rem;
    padding: .2rem .4rem;
    border-radius: 4px;
    opacity: .7;
}
.puzzle-reset:hover { opacity: 1; }

/* ── Gladys 3D walk animation ──────────────────────────── */
.gate-gladys3d {
    margin-bottom: 1.5rem;
}
.gate-gladys3d-stage {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    background: #f0ece4;
    border: 1px solid rgba(200,150,92,.2);
    box-shadow: 0 8px 24px -8px rgba(0,0,0,.15);
    margin-bottom: 1rem;
}
.gate-gladys3d-gif {
    width: 100%;
    height: auto;
    display: block;
    image-rendering: auto;
}
.gate-gladys3d-label {
    position: absolute;
    bottom: .5rem;
    right: .65rem;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .04em;
    color: rgba(0,0,0,.45);
    background: rgba(255,255,255,.7);
    backdrop-filter: blur(4px);
    padding: .18rem .5rem;
    border-radius: 6px;
    pointer-events: none;
}
[data-theme="dark"] .gate-gladys3d-stage {
    background: #1a1510;
    border-color: rgba(200,150,92,.18);
}
[data-theme="dark"] .gate-gladys3d-label {
    background: rgba(0,0,0,.5);
    color: rgba(255,255,255,.55);
}
/* happy state: GIF pulsa al dar el dulce */
.gate-gladys3d.mascota-happy .gate-gladys3d-stage {
    animation: gladys3d-happy .6s ease;
    border-color: var(--atacama-gold, #c8965c);
    box-shadow: 0 8px 32px -8px rgba(200,150,92,.4);
}
@keyframes gladys3d-happy {
    0%,100% { transform: scale(1); }
    40%     { transform: scale(1.03) translateY(-3px); }
}
.dulce-hearts {
    text-align: center;
    font-size: 1.4rem;
    overflow: hidden;
    max-height: 0;
    transition: max-height .4s ease, opacity .4s ease;
    opacity: 0;
}
.dulce-hearts.show { max-height: 3rem; opacity: 1; }

/* ── Gate page wrapper ─────────────────────────────────── */
.gate-section {
    min-height: 80vh;
    display: flex;
    align-items: center;
    padding: 4rem 0;
}
.gate-box {
    max-width: 620px;
    margin: 0 auto;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(200, 150, 92, .25);
    border-radius: 18px;
    padding: 2.5rem 2.25rem;
    box-shadow: 0 30px 80px -30px rgba(0,0,0,.35);
}
.gate-hello {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.gate-hello i {
    font-size: 1.8rem;
    color: var(--atacama-gold, #c8965c);
}
.gate-hello h1 {
    font-family: var(--font-display, 'Fraunces', Georgia, serif);
    font-weight: 500;
    font-size: clamp(1.6rem, 3.5vw, 2.2rem);
    margin: 0;
    color: var(--on-light, #222);
    line-height: 1.15;
}
.gate-lead {
    color: var(--on-light-muted, #666);
    font-size: .92rem;
    line-height: 1.65;
    margin-bottom: 1.5rem;
}
.gate-alert {
    background: rgba(220, 53, 69, .10);
    border: 1px solid rgba(220, 53, 69, .35);
    border-left: 3px solid #dc3545;
    border-radius: 10px;
    padding: .85rem 1.1rem;
    margin-bottom: 1.25rem;
    animation: gate-alert-in .4s cubic-bezier(.16,1,.3,1);
}
.gate-alert p {
    margin: 0;
    font-size: .88rem;
    color: #c0392b;
    display: flex;
    align-items: center;
    gap: .55rem;
    font-weight: 500;
}
.gate-alert i { color: #dc3545; font-size: 1rem; }
@keyframes gate-alert-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
[data-theme="dark"] .gate-alert { background: rgba(220, 53, 69, .18); }
[data-theme="dark"] .gate-alert p { color: #ff8a93; }

.gate-form { display: flex; flex-direction: column; align-items: center; gap: 1.25rem; }
.gate-submit {
    width: 100%;
    max-width: 460px;
    justify-content: center;
}
.gate-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--on-light-muted, #666);
}
.gate-footer i { color: var(--atacama-gold, #c8965c); margin-right: .3rem; }

@media (max-width: 520px) {
    .puzzle-pieces { grid-template-columns: repeat(3, 1fr); }
    .puzzle-piece { font-size: 1.1rem; }
    .gate-box { padding: 1.75rem 1.35rem; }
}

/* ============================================================
   DARK MODE
   El gate y el puzzle fijan superficies CLARAS (#fff / #fafafa /
   rgba(255,255,255,.96)), pero los textos usan --on-light* que en
   oscuro se vuelven CLAROS → texto claro sobre fondo claro = invisible.
   Acá las superficies adoptan tonos oscuros y el texto recupera contraste.
   ============================================================ */
[data-theme="dark"] .gate-box {
    background: rgba(28, 24, 20, .93);
    border-color: rgba(212, 165, 110, .24);
    box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .6);
}
[data-theme="dark"] .puzzle {
    background: var(--card-bg, rgba(30, 26, 22, .94));
    border-color: var(--card-border, rgba(212, 165, 110, .22));
    box-shadow: 0 10px 30px -15px rgba(0, 0, 0, .5);
}
[data-theme="dark"] .puzzle-head-icon { background: rgba(200, 150, 92, .22); }
[data-theme="dark"] .puzzle-prompt {
    background: linear-gradient(90deg, rgba(200, 150, 92, .14), rgba(200, 150, 92, .04));
    border-color: rgba(200, 150, 92, .4);
}
[data-theme="dark"] .puzzle-prompt li {
    background: rgba(250, 247, 242, .06);
    border-color: rgba(200, 150, 92, .3);
}
[data-theme="dark"] .puzzle-piece {
    background: rgba(250, 247, 242, .045);
    border-color: rgba(250, 247, 242, .14);
}
[data-theme="dark"] .puzzle-piece:hover:not(:disabled) {
    background: rgba(200, 150, 92, .16);
}
[data-theme="dark"] .puzzle-piece.picked { color: #1a1207; }
[data-theme="dark"] .puzzle-status { background: rgba(250, 247, 242, .05); }
