/* ===== noelp.dev — Design Tokens ===== */
:root {
    --primary: #d946ef;
    /* fuchsia-500 */
    --primary-2: #ec4899;
    /* pink-500 */
    --primary-soft: rgba(217, 70, 239, 0.08);
    --primary-glow: rgba(217, 70, 239, 0.25);
    --bg: #f6f5f8;
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-border: rgba(255, 255, 255, 0.6);
    --text: #0f172a;
    /* slate-900 */
    --text-sub: #64748b;
    /* slate-500 */
    --input-bg: rgba(255, 255, 255, 0.7);
    --input-border: #e2e8f0;
    /* slate-200 */
    --input-focus: #d946ef;
    --danger: #ef4444;
    --success: #22c55e;
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 8px 32px rgba(15, 23, 42, 0.09);
    --shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.13);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --primary: #e879f9;
    /* fuchsia-400 */
    --primary-2: #f472b6;
    /* pink-400 */
    --primary-soft: rgba(232, 121, 249, 0.1);
    --primary-glow: rgba(232, 121, 249, 0.22);
    --bg: #020617;
    /* slate-950 */
    --card-bg: rgba(15, 23, 42, 0.8);
    /* slate-900 */
    --card-border: rgba(255, 255, 255, 0.06);
    --text: #f1f5f9;
    /* slate-100 */
    --text-sub: #94a3b8;
    /* slate-400 */
    --input-bg: rgba(30, 41, 59, 0.8);
    --input-border: #334155;
    /* slate-700 */
    --input-focus: #e879f9;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100dvh;
    margin: 0;
    padding: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Kill double-tap / pinch zoom annoyance */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 20%, rgba(217, 70, 239, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(236, 72, 153, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

[data-theme="dark"] body::before {
    background: radial-gradient(circle at 30% 20%, rgba(232, 121, 249, 0.08) 0%, transparent 45%),
        radial-gradient(circle at 70% 80%, rgba(244, 114, 182, 0.05) 0%, transparent 45%);
}

/* ===== Card ===== */
.card {
    position: relative;
    z-index: 1;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    padding: 2rem 1.75rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 420px;
    width: 100%;
}

/* ===== Brand ===== */
.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 0.5rem;
}

.brand-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

h1 {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    color: var(--text);
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.brand-tld {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-sub);
    font-size: 0.9rem;
    margin: 0.25rem 0 1.75rem;
    line-height: 1.5;
}

/* ===== PIN input ===== */
.pin-wrapper {
    margin-bottom: 1rem;
}

#pin {
    width: 100%;
    text-align: center;
    font-family: 'Space Grotesk', monospace;
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: 0.7em;
    text-indent: 0.7em;
    padding: 16px 14px;
    background-color: var(--input-bg);
    color: var(--text);
    border: 1.5px solid var(--input-border);
    border-radius: var(--radius-md);
    height: 72px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

#pin:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

#pin:disabled {
    opacity: 0.5;
}

#pin.shake {
    animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {

    10%,
    90% {
        transform: translateX(-2px);
    }

    20%,
    80% {
        transform: translateX(4px);
    }

    30%,
    50%,
    70% {
        transform: translateX(-8px);
    }

    40%,
    60% {
        transform: translateX(8px);
    }
}

.validation-msg {
    font-size: 0.8rem;
    margin-top: 6px;
    font-weight: 500;
}

.validation-msg.error {
    color: var(--danger);
}

/* ===== Buttons ===== */
button {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: var(--radius-md);
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
    letter-spacing: 0.2px;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

button:active {
    transform: translateY(0);
    box-shadow: none;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

button.secondary {
    background: var(--input-bg);
    color: var(--text-sub);
    border: 1.5px solid var(--input-border);
    margin-top: 12px;
    font-weight: 600;
}

button.secondary:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: none;
    transform: translateY(-1px);
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    color: var(--text);
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: transform var(--transition), box-shadow var(--transition);
    z-index: 100;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: var(--shadow-md);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* ===== QR Display ===== */
#qrcode {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1.5rem auto 0;
    padding: 16px;
    width: min(86vw, 360px);
    height: min(86vw, 360px);
    background: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}

#qrcode:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

#qrcode:active {
    transform: scale(0.98);
}

#qrImg {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    shape-rendering: crispEdges;
}

.info {
    color: var(--text-sub);
    font-size: 0.85rem;
    margin-top: 1.25rem;
    line-height: 1.6;
}

.info a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.info a:hover {
    opacity: 0.8;
}

/* ===== Progress Bar ===== */
.progress-bar {
    height: 4px;
    background: var(--input-border);
    border-radius: var(--radius-full);
    margin-top: 1rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-2) 100%);
    width: 100%;
    transform-origin: left;
    animation: progress 5s linear infinite;
    border-radius: var(--radius-full);
}

@keyframes progress {
    0% {
        transform: scaleX(1);
    }

    100% {
        transform: scaleX(0);
    }
}

/* ===== Cooldown / Info Banner ===== */
.cooldown-info {
    background: var(--primary-soft);
    border: 1px solid var(--primary-glow);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.5;
    text-align: center;
    font-weight: 500;
}

code {
    background-color: var(--primary-soft);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--primary);
    font-size: 0.85em;
    font-weight: 600;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: var(--text);
    color: var(--bg);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== Footer ===== */
.footer {
    position: relative;
    z-index: 1;
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-sub);
    opacity: 0.8;
}

.footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.footer a:hover {
    text-decoration: underline;
}

/* ===== Fullscreen Mode ===== */
.exit-fullscreen {
    display: none;
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    background: rgba(0, 0, 0, 0.06);
    border: none;
    padding: 10px 24px;
    border-radius: var(--radius-full);
    cursor: pointer;
    color: #666;
    font-weight: 600;
    font-size: 0.85rem;
}

[data-theme="dark"] .exit-fullscreen {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
}

#qrDisplay.fullscreen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 9999;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

[data-theme="dark"] #qrDisplay.fullscreen {
    background: #0b0b0f;
}

body.fullscreen-active>*:not(.card) {
    display: none !important;
}

body.fullscreen-active>.card {
    position: static;
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    max-width: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#qrDisplay.fullscreen>*:not(#qrcode):not(.exit-fullscreen) {
    display: none !important;
}

#qrDisplay.fullscreen #qrcode {
    width: min(92vw, 92vh);
    height: min(92vw, 92vh);
    margin: 0;
    box-shadow: none;
    border-radius: 0;
    transform: none;
}

#qrDisplay.fullscreen .exit-fullscreen {
    display: block;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .card {
        padding: 1.5rem 1.25rem;
        border-radius: var(--radius-md);
    }

    h1 {
        font-size: 1.55rem;
    }
}

@media (hover: none) {

    button:hover,
    #qrcode:hover,
    .btn-icon:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }
}
