/* Shared admin UI (js/admin.js): pixel popup windows, floating admin bar and the
   commission status sign. Same pixel look on every page. */

/* Pixel window: a little retro OS window with a striped title bar.
   Every popup on the site uses it (login, messages, confirmations). */
.px-window {
    margin: auto;
    width: min(400px, calc(100vw - 2rem));
    border: 0;
    padding: 0;
    color: #e8edf5;
    background: #101a31;
    overflow: visible;
    box-shadow:
        3px 0 0 0 #5f7fc0, -3px 0 0 0 #5f7fc0, 0 3px 0 0 #5f7fc0, 0 -3px 0 0 #5f7fc0,
        9px 9px 0 0 rgba(5, 8, 15, 0.85);
    font: 400 1.05rem/1.5 'Alegreya Sans', 'Segoe UI', system-ui, sans-serif;
}
.px-window[open] { animation: pxw-pop 180ms steps(3); }
.px-window.shake { animation: pxw-shake 280ms steps(6); }
.px-window::backdrop {
    background:
        repeating-linear-gradient(0deg, rgba(5, 8, 15, 0.25) 0 2px, transparent 2px 4px),
        rgba(5, 8, 15, 0.72);
}
@keyframes pxw-pop {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: none; opacity: 1; }
}
@keyframes pxw-shake {
    0%, 100% { transform: none; }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.pxw-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.45rem 0.45rem 0.7rem;
    background:
        repeating-linear-gradient(0deg, #2f4170 0 2px, #1a2847 2px 4px);
    border-bottom: 3px solid #5f7fc0;
}
.pxw-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background: center / contain no-repeat;
    image-rendering: pixelated;
}
.pxw-icon-lock { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath fill='%23ffd27a' d='M2 0h4v1H2zM1 1h1v2H1zM6 1h1v2H6zM0 3h8v5H0z'/%3E%3Cpath fill='%230b1224' d='M3 4h2v2H3zM3.5 6h1v1h-1z'/%3E%3C/svg%3E"); }
.pxw-icon-warn { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath fill='%23ffd27a' d='M3 0h2v1H3zM2 1h4v2H2zM1 3h6v2H1zM0 5h8v3H0z'/%3E%3Cpath fill='%230b1224' d='M3.5 2h1v3h-1zM3.5 6h1v1h-1z'/%3E%3C/svg%3E"); }
.pxw-icon-info { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath fill='%23ffd27a' d='M1 0h6v8H1zM0 1h8v6H0z'/%3E%3Cpath fill='%230b1224' d='M3.5 1h1v1h-1zM3.5 3h1v4h-1z'/%3E%3C/svg%3E"); }
.pxw-title {
    margin: 0;
    font: 600 1.1rem/1 'Pixelify Sans', 'Courier New', monospace;
    font-style: normal;
    color: #ffd27a;
    letter-spacing: 0.02em;
    text-shadow: 2px 2px 0 #0b1224;
    padding: 0.2rem 0.4rem;
    background: #1a2847;
    white-space: nowrap;
    margin-right: auto;
}
.pxw-close {
    width: 28px;
    height: 28px;
    border: 0;
    background: #f0727f;
    color: #0b1224;
    font: 700 1.2rem/1 'Pixelify Sans', 'Courier New', monospace;
    cursor: pointer;
    box-shadow: 0 0 0 2px #0b1224, inset -2px -2px 0 rgba(0, 0, 0, 0.3), inset 2px 2px 0 rgba(255, 255, 255, 0.35);
}
.pxw-close:hover { background: #ff9aa4; }
.pxw-close:active { transform: translateY(1px); }

.pxw-body { padding: 1.1rem 1.2rem 0.4rem; }
.pxw-body p { margin: 0 0 0.75rem; }
.pxw-note { color: #a9b6cf; font-size: 0.95rem; }
.pxw-body code {
    font: 500 0.9rem/1 'Pixelify Sans', 'Courier New', monospace;
    background: #0b1224;
    color: #ffd27a;
    padding: 0.1rem 0.35rem;
}
.pxw-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 0.4rem 1.1rem 1.1rem;
}

.admin-form { display: grid; gap: 0.5rem; }
.admin-form label { color: #a9b6cf; }
.admin-form input[type=password] {
    background: #0b1224;
    color: #e8edf5;
    border: 0;
    box-shadow: 0 0 0 2px #2f4170;
    padding: 0.65rem 0.75rem;
    margin: 2px;
    font: 500 1.05rem/1.2 'Pixelify Sans', 'Courier New', monospace;
}
.admin-form input[type=password]:focus { outline: none; box-shadow: 0 0 0 2px #ffd27a; }
.admin-user { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.admin-error { min-height: 1.3em; margin: 0; color: #f0727f; font-size: 0.95rem; }

.admin-btn {
    font: 600 1rem/1 'Pixelify Sans', 'Courier New', monospace;
    color: #0b1224;
    background: #72bcec;
    border: 0;
    padding: 0.6rem 1rem 0.7rem;
    margin: 3px;
    cursor: pointer;
    box-shadow:
        0 0 0 3px #0b1224,
        inset -3px -3px 0 0 rgba(0, 0, 0, 0.3),
        inset 3px 3px 0 0 rgba(255, 255, 255, 0.35);
}
.admin-btn:hover { background: #9ad2f4; }
.admin-btn:active { transform: translateY(2px); box-shadow: 0 0 0 3px #0b1224, inset 3px 3px 0 0 rgba(0, 0, 0, 0.3); }
.admin-btn:disabled { opacity: 0.6; cursor: wait; }
.admin-btn.ghost { background: #1a2847; color: #e8edf5; }
.admin-btn.ghost:hover { background: #2f4170; }
.admin-btn.danger { background: #f0727f; }
.admin-btn.danger:hover { background: #ff9aa4; }
.admin-btn.small { font-size: 0.85rem; padding: 0.4rem 0.6rem 0.45rem; }

/* Floating bar while logged in. Pages with a bottom bar set --admin-bottom. */
.admin-bar {
    position: fixed;
    right: 16px;
    bottom: var(--admin-bottom, 16px);
    z-index: 5000;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.5rem 0.45rem 0.8rem;
    background: #0b1224;
    color: #e8edf5;
    box-shadow: 3px 0 0 0 #ffd27a, -3px 0 0 0 #ffd27a, 0 3px 0 0 #ffd27a, 0 -3px 0 0 #ffd27a;
    font: 500 0.9rem/1 'Pixelify Sans', 'Courier New', monospace;
    max-width: calc(100vw - 32px);
}
.admin-dot { width: 8px; height: 8px; background: #8fd6a2; box-shadow: 0 0 0 2px #1d3a2c; }
.admin-label { color: #ffd27a; text-transform: uppercase; letter-spacing: 0.08em; }

.admin-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    cursor: pointer;
    padding: 0.25rem;
}
.admin-switch-track {
    position: relative;
    width: 36px;
    height: 18px;
    background: #4a2230;
    box-shadow: 0 0 0 2px #2f4170;
}
.admin-switch-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 12px;
    height: 12px;
    background: #f0727f;
    transition: left 120ms steps(3);
}
.admin-switch.on .admin-switch-track { background: #1d3a2c; }
.admin-switch.on .admin-switch-knob { left: 21px; background: #8fd6a2; }
.admin-switch-state { min-width: 3.6em; text-align: left; color: #f0727f; }
.admin-switch.on .admin-switch-state { color: #8fd6a2; }
.admin-switch:focus-visible { outline: 3px solid #ffd27a; outline-offset: 2px; }

/* Status sign: a plain label for visitors, a switch for the admin. */
[data-comms-status].is-closed { background: #f0727f !important; color: #0b1224 !important; }
button[data-comms-status] { border: 0; font: inherit; cursor: default; }
button[data-comms-status]:disabled { opacity: 1; }
button[data-comms-status].is-toggle { cursor: pointer; box-shadow: 0 0 0 2px #0b1224, 0 0 0 4px #ffd27a; }
button[data-comms-status].is-toggle::after { content: " \21C4"; font-size: 0.85em; }

@media (max-width: 520px) {
    .admin-bar { left: 16px; right: 16px; justify-content: space-between; }
    .admin-label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .admin-switch-knob { transition: none; }
    .px-window[open], .px-window.shake { animation: none; }
}

/* Leave room so the floating admin bar never covers the end of the page. */
body:has(.admin-bar) { padding-bottom: 80px; }
