/* Reset básico */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Paleta de marca: naranja + negro (Coro Cantar de Cantares) */
:root {
    --wine-950: #150c05;
    --wine-800: #2b1608;
    --wine-650: #5a2a0a;
    --wine-500: #d9480f;
    --gold-400: #ff8a1e;
    --gold-300: #ffb768;
    --cream-100: #fdf0e4;
    --cream-50: #fff8f2;
    --ink-900: #1a1005;
}

html, body {
    height: 100%;
}

/* Fondo en tonos negro y naranja */
body {
    position: relative;
    overflow-x: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4vh 20px;
    background: linear-gradient(160deg, var(--wine-800) 0%, var(--wine-950) 55%, #0d0703 100%);
    background-size: 180% 180%;
    animation: bgDrift 22s ease-in-out infinite;
}

@keyframes bgDrift {
    0%   { background-position: 20% 0%; }
    50%  { background-position: 80% 100%; }
    100% { background-position: 20% 0%; }
}

/* Notas musicales subiendo por el fondo */
.note {
    position: fixed;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--gold-400);
    box-shadow: 0 0 10px rgba(255, 138, 30, 0.65);
    opacity: 0;
    pointer-events: none;
    animation: rise 10s ease-in infinite, twinkle 2.6s ease-in-out infinite;
}

.note::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 3px;
    width: 2px;
    height: 26px;
    background: var(--gold-400);
    border-radius: 2px;
}

.note.sway { animation-name: riseSway, twinkle; }
.note.gold-soft { background: var(--gold-300); }
.note.gold-soft::after { background: var(--gold-300); }

.note.n1  { left: 8%;  top: 90%; animation-delay: 0s; }
.note.n2  { left: 22%; top: 94%; animation-delay: 1.4s; }
.note.n3  { left: 38%; top: 88%; animation-delay: 2.8s; }
.note.n4  { left: 54%; top: 96%; animation-delay: 4.2s; }
.note.n5  { left: 68%; top: 89%; animation-delay: 5.6s; }
.note.n6  { left: 82%; top: 93%; animation-delay: 7s; }
.note.n7  { left: 93%; top: 88%; animation-delay: 8.4s; }
.note.n8  { left: 14%; top: 82%; animation-delay: 3.5s; transform: scale(0.7); }
.note.n9  { left: 47%; top: 98%; animation-delay: 1.9s; animation-duration: 12s, 2.6s; transform: scale(0.55); }
.note.n10 { left: 4%;  top: 96%; animation-delay: 6.3s; animation-duration: 13s, 2.6s; transform: scale(0.6); }
.note.n11 { left: 62%; top: 100%; animation-delay: 9.6s; animation-duration: 11s, 2.6s; transform: scale(0.85); }
.note.n12 { left: 30%; top: 100%; animation-delay: 5s; animation-duration: 14s, 2.6s; transform: scale(0.5); }
.note.n13 { left: 87%; top: 97%; animation-delay: 2.4s; animation-duration: 9.5s, 2.6s; transform: scale(0.9); }
.note.n14 { left: 76%; top: 100%; animation-delay: 10.8s; animation-duration: 12.5s, 2.6s; transform: scale(0.65); }

@keyframes rise {
    0%   { transform: translateY(0) rotate(0deg); opacity: 0; }
    12%  { opacity: 0.9; }
    88%  { opacity: 0.12; }
    100% { transform: translateY(-90vh) rotate(10deg); opacity: 0; }
}

@keyframes riseSway {
    0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
    12%  { opacity: 0.9; }
    35%  { transform: translate(16px, -32vh) rotate(5deg); }
    65%  { transform: translate(-16px, -62vh) rotate(-5deg); }
    88%  { opacity: 0.12; }
    100% { transform: translate(8px, -92vh) rotate(10deg); opacity: 0; }
}

@keyframes twinkle {
    0%, 100% { filter: brightness(1); }
    50%      { filter: brightness(1.6); }
}

/* Tarjeta de login (crema) */
.login-box {
    position: relative;
    z-index: 1;
    background: var(--cream-100);
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    padding: 52px 30px 30px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    overflow: visible;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.login-box::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    border-radius: 18px 18px 0 0;
    background: linear-gradient(90deg, var(--gold-400), var(--wine-500), var(--gold-400));
    background-size: 200% 100%;
    animation: shimmerBar 6s linear infinite;
}

@keyframes shimmerBar {
    0%   { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}

.login-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 24px 55px rgba(0, 0, 0, 0.4);
}

/* Insignia del logo, superpuesta al borde superior de la tarjeta */
.logo-badge {
    position: absolute;
    top: -38px;
    left: 50%;
    transform: translateX(-50%);
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: linear-gradient(160deg, var(--wine-800) 0%, var(--wine-950) 100%);
    border: 3px solid var(--gold-400);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
}

/* Eyebrow y título */
.eyebrow {
    font-size: 0.68rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--wine-650);
    font-weight: 600;
    margin-bottom: 6px;
}

.login-box h2 {
    font-family: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
    font-size: 1.55rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--ink-900);
}

.login-box .sub {
    font-size: 0.85rem;
    color: #8a6b56;
    margin-bottom: 28px;
}

/* Campos con label flotante */
.field {
    position: relative;
    margin-bottom: 26px;
    text-align: left;
}

.login-box input[type="text"],
.login-box input[type="password"] {
    width: 100%;
    border: none;
    border-bottom: 1.5px solid rgba(43, 22, 8, 0.22);
    background: transparent;
    padding: 8px 2px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--ink-900);
    outline: none;
}

.field label {
    position: absolute;
    left: 2px;
    top: 8px;
    font-size: 1rem;
    color: #8a6b56;
    pointer-events: none;
    transition: transform 0.2s ease, font-size 0.2s ease, color 0.2s ease;
    transform-origin: left top;
}

.login-box input:focus + label,
.login-box input:not(:placeholder-shown) + label {
    transform: translateY(-21px);
    font-size: 0.72rem;
    color: var(--wine-650);
    letter-spacing: 0.03em;
}

.field .underline {
    position: absolute;
    left: 0;
    bottom: -1.5px;
    height: 2px;
    width: 0;
    background: linear-gradient(90deg, var(--gold-400), var(--wine-500));
    transition: width 0.3s ease;
}

.login-box input:focus ~ .underline {
    width: 100%;
}

/* Botón */
.login-box button {
    width: 100%;
    margin-top: 4px;
    padding: 13px;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.96rem;
    letter-spacing: 0.02em;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(135deg, var(--wine-650), var(--wine-800));
    box-shadow: 0 6px 18px rgba(43, 22, 8, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.login-box button:hover,
.login-box button:focus {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(43, 22, 8, 0.38);
    filter: brightness(1.07);
    outline: none;
}

.login-box button:active {
    transform: translateY(0) scale(0.98);
}

.login-box button .arrow {
    transition: transform 0.2s ease;
}

.login-box button:hover .arrow {
    transform: translateX(3px);
}

/* Mensaje de error */
.mensaje-error {
    background-color: #fdeceb;
    color: var(--wine-650);
    border: 1px solid rgba(217, 72, 15, 0.25);
    padding: 8px 10px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 15px;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* Alternativa: ingresar con QR */
.login-box .qr-toggle-btn {
    width: 100%;
    margin-top: 14px;
    padding: 11px;
    background: transparent;
    border: 1.5px solid rgba(43, 22, 8, 0.2);
    border-radius: 8px;
    color: var(--wine-650);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.login-box .qr-toggle-btn:hover {
    background: rgba(255, 138, 30, 0.1);
    border-color: var(--gold-400);
    transform: none;
}

.qr-login-panel {
    margin-top: 14px;
    text-align: center;
}

#qr-reader {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 260px;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    border: 3px solid var(--gold-400);
}

.qr-login-hint {
    margin-top: 12px;
    font-size: 0.82rem;
    color: #8a6b56;
}

.login-box .qr-cancel-btn {
    width: 100%;
    margin-top: 14px;
    padding: 10px;
    background: none;
    border: none;
    color: var(--wine-650);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.login-box .qr-cancel-btn:hover {
    background: none;
    transform: none;
}

/* Footer */
.footer {
    margin-top: 22px;
    font-size: 12px;
    color: #8a6b56;
    text-align: center;
}

/* Responsivo */
@media (max-width: 400px) {
    .login-box {
        max-width: 90%;
        padding: 48px 22px 22px;
    }

    .logo-badge {
        width: 64px;
        height: 64px;
        top: -32px;
    }

    .logo {
        width: 46px;
        height: 46px;
    }
}

/* Respeta la preferencia de reducción de movimiento del usuario */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
