/**
 * poll.css
 *
 * Styles for:
 *   1. The poll overlay on instructor-display.html (broadcast display)
 *   2. The poll button and management panel inside the simulator panel (index.html)
 */

/* ═══════════════════════════════════════════════════════════════════
   BROADCAST DISPLAY — POLL SIDE PANEL  (#pollOverlay)
   Right-side slide-in: ECG waveform stays visible on the left.
   ═══════════════════════════════════════════════════════════════════ */

#pollOverlay {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 40%;
    min-width: 340px;
    max-width: 520px;
    z-index: 60;
    /* Deep navy with glass */
    background: linear-gradient(180deg,
        rgba(6, 10, 28, 0.97) 0%,
        rgba(4, 7, 20, 0.97) 100%);
    backdrop-filter: blur(40px) saturate(1.8);
    -webkit-backdrop-filter: blur(40px) saturate(1.8);
    /* Left edge: glowing green seam */
    border-left: 1px solid rgba(0, 230, 118, 0.18);
    box-shadow:
        -40px 0 100px rgba(0, 0, 0, 0.70),
        -1px 0 0 rgba(0, 230, 118, 0.08) inset;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ppSlideIn 0.44s cubic-bezier(0.30, 1.12, 0.60, 1);
}
#pollOverlay[hidden] { display: none; }

@keyframes ppSlideIn {
    from { transform: translateX(108%); }
    to   { transform: translateX(0); }
}

/* Top accent gradient line */
#pollOverlay::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(0, 230, 118, 0.70) 40%,
        rgba(0, 230, 118, 0.30) 100%);
    z-index: 1;
}

/* ── 1. Header ────────────────────────────────────────────────────── */

.pp-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 22px 18px;
    flex-shrink: 0;
    position: relative;
}

/* Subtle separator below header */
.pp-head::after {
    content: '';
    position: absolute;
    bottom: 0; left: 22px; right: 22px;
    height: 1px;
    background: linear-gradient(90deg,
        rgba(255,255,255,0.09) 0%,
        rgba(255,255,255,0.03) 100%);
}

.pp-head-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.pp-eyebrow {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 3.5px;
    text-transform: uppercase;
    color: rgba(0, 230, 118, 0.55);
}

.pp-eyebrow-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #00e676;
    box-shadow: 0 0 8px rgba(0, 230, 118, 0.80);
    flex-shrink: 0;
    animation: dotPulse 1.8s ease-in-out infinite;
}
@keyframes dotPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.55; transform: scale(0.80); }
}

.pp-question {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.5px;
    line-height: 1.15;
}

/* Live vote pill — top right */
.pp-vote-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 230, 118, 0.07);
    border: 1px solid rgba(0, 230, 118, 0.18);
    border-radius: 14px;
    padding: 8px 14px 6px;
    flex-shrink: 0;
    gap: 1px;
}

.pp-vote-num {
    font-size: 32px;
    font-weight: 800;
    color: #00e676;
    line-height: 1;
    letter-spacing: -2px;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 24px rgba(0, 230, 118, 0.45);
    transition: color 0.3s;
    min-width: 2ch;
    text-align: center;
}

.pp-vote-lbl {
    font-size: 8px;
    font-weight: 700;
    color: rgba(0, 230, 118, 0.40);
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
}

/* ── 2. QR hero ───────────────────────────────────────────────────── */

.pp-qr-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 22px 18px;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
}

.pp-qr-hero::after {
    content: '';
    position: absolute;
    bottom: 0; left: 22px; right: 22px;
    height: 1px;
    background: linear-gradient(90deg,
        rgba(255,255,255,0.09) 0%,
        rgba(255,255,255,0.03) 100%);
}

/* The white QR card — prominent, glowing */
.pp-qr-card {
    width: 158px;
    height: 158px;
    background: #ffffff;
    border-radius: 16px;
    padding: 10px;
    position: relative;
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.15),
        0 8px 32px rgba(0, 0, 0, 0.55),
        0 0 48px rgba(0, 230, 118, 0.22),
        0 0 80px rgba(0, 230, 118, 0.10);
    animation: qrCardGlow 4s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes qrCardGlow {
    0%, 100% {
        box-shadow:
            0 0 0 1px rgba(255,255,255,0.15),
            0 8px 32px rgba(0, 0, 0, 0.55),
            0 0 48px rgba(0, 230, 118, 0.22),
            0 0 80px rgba(0, 230, 118, 0.10);
    }
    50% {
        box-shadow:
            0 0 0 1px rgba(255,255,255,0.22),
            0 8px 32px rgba(0, 0, 0, 0.55),
            0 0 60px rgba(0, 230, 118, 0.38),
            0 0 110px rgba(0, 230, 118, 0.16);
    }
}

.pp-qr-card img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

/* "Scan to vote" label */
.pp-qr-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.78);
    letter-spacing: 0.2px;
}

.pp-qr-icon {
    color: rgba(0, 230, 118, 0.65);
    flex-shrink: 0;
}

/* URL in tiny monospace */
.pp-qr-url {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.20);
    font-family: 'Courier New', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    letter-spacing: 0.2px;
    text-align: center;
}

/* ── 3. Choices label ─────────────────────────────────────────────── */

.pp-choices-label {
    padding: 12px 22px 4px;
    font-size: 8.5px;
    font-weight: 800;
    letter-spacing: 2.8px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.20);
    flex-shrink: 0;
}

/* ── 4. Answer choices ────────────────────────────────────────────── */

.pp-choices {
    flex: 1;
    overflow-y: auto;
    padding: 4px 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

/* ── Choice card ──────────────────────────────────────────────────── */

/* Card uses background-wash fill technique:
   .poll-bar-fill is an absolute layer that expands left→right
   at very low opacity — giving an elegant "fill" as votes arrive,
   without a visible separate progress bar track.            */

.poll-bar-row {
    position: relative;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    transition: opacity 0.5s ease, transform 0.5s ease,
                border-color 0.5s ease, box-shadow 0.5s ease;
    flex-shrink: 0;
}

/* Background wash layer */
.poll-bar-fill {
    position: absolute;
    inset: 0;
    width: 0%;
    opacity: 0.10;
    transition: width 0.60s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.5s ease;
    pointer-events: none;
    border-radius: inherit;
}

/* Visible content row */
.poll-bar-inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
}

/* Letter badge */
.poll-bar-letter {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.2px;
    transition: background 0.45s, color 0.45s, box-shadow 0.45s;
}

/* Rhythm name */
.poll-bar-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.82);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.4s;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1;
}

/* Percentage */
.poll-bar-pct {
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.28);
    flex-shrink: 0;
    min-width: 38px;
    text-align: right;
    transition: color 0.4s;
    letter-spacing: -0.3px;
}

/* Thin bottom progress bar (secondary indicator — 3px) */
.poll-bar-track {
    height: 3px;
    background: transparent;
    overflow: hidden;
    border-radius: 0 0 11px 11px;
    margin-top: -1px;   /* tuck just inside border */
}
.poll-bar-track-fill {
    height: 100%;
    width: 0%;
    transition: width 0.60s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: inherit;
}

/* Per-choice accent palettes */
.poll-bar-row[data-idx="0"] { border-left: 3px solid rgba(0, 212, 255, 0.45); }
.poll-bar-row[data-idx="0"] .poll-bar-letter { background: rgba(0, 212, 255, 0.14); color: #00d4ff; }
.poll-bar-row[data-idx="0"] .poll-bar-fill   { background: #00d4ff; }
.poll-bar-row[data-idx="0"] .poll-bar-track-fill { background: rgba(0, 212, 255, 0.55); }
.poll-bar-row[data-idx="0"] .poll-bar-pct    { color: rgba(0, 212, 255, 0.50); }

.poll-bar-row[data-idx="1"] { border-left: 3px solid rgba(255, 176, 0, 0.45); }
.poll-bar-row[data-idx="1"] .poll-bar-letter { background: rgba(255, 176, 0, 0.14); color: #ffb000; }
.poll-bar-row[data-idx="1"] .poll-bar-fill   { background: #ffb000; }
.poll-bar-row[data-idx="1"] .poll-bar-track-fill { background: rgba(255, 176, 0, 0.55); }
.poll-bar-row[data-idx="1"] .poll-bar-pct    { color: rgba(255, 176, 0, 0.50); }

.poll-bar-row[data-idx="2"] { border-left: 3px solid rgba(175, 82, 222, 0.45); }
.poll-bar-row[data-idx="2"] .poll-bar-letter { background: rgba(175, 82, 222, 0.14); color: #af52de; }
.poll-bar-row[data-idx="2"] .poll-bar-fill   { background: #af52de; }
.poll-bar-row[data-idx="2"] .poll-bar-track-fill { background: rgba(175, 82, 222, 0.55); }
.poll-bar-row[data-idx="2"] .poll-bar-pct    { color: rgba(175, 82, 222, 0.50); }

.poll-bar-row[data-idx="3"] { border-left: 3px solid rgba(255, 99, 72, 0.45); }
.poll-bar-row[data-idx="3"] .poll-bar-letter { background: rgba(255, 99, 72, 0.14); color: #ff6348; }
.poll-bar-row[data-idx="3"] .poll-bar-fill   { background: #ff6348; }
.poll-bar-row[data-idx="3"] .poll-bar-track-fill { background: rgba(255, 99, 72, 0.55); }
.poll-bar-row[data-idx="3"] .poll-bar-pct    { color: rgba(255, 99, 72, 0.50); }

/* ── Revealed state ───────────────────────────────────────────────── */

#pollOverlay.is-revealed .poll-bar-row {
    opacity: 0.18;
    transform: scale(0.97);
    border-left-color: rgba(255,255,255,0.06) !important;
}

#pollOverlay.is-revealed .poll-bar-row.is-correct {
    opacity: 1;
    transform: scale(1.0);
    background: rgba(0, 230, 118, 0.07);
    border-color: rgba(0, 230, 118, 0.40);
    border-left-color: rgba(0, 230, 118, 0.80) !important;
    box-shadow:
        0 0 0 1px rgba(0, 230, 118, 0.10) inset,
        0 4px 30px rgba(0, 230, 118, 0.12);
}

#pollOverlay.is-revealed .poll-bar-row.is-correct .poll-bar-fill {
    background: #00e676 !important;
    opacity: 0.12 !important;
}

#pollOverlay.is-revealed .poll-bar-row.is-correct .poll-bar-track-fill {
    background: #00e676 !important;
}

#pollOverlay.is-revealed .poll-bar-row.is-correct .poll-bar-letter {
    background: rgba(0, 230, 118, 0.22) !important;
    color: #00e676 !important;
    animation: correctLetterPulse 2.4s ease-in-out infinite;
}

@keyframes correctLetterPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0,230,118,0); }
    50%       { box-shadow: 0 0 16px 4px rgba(0,230,118,0.32); }
}

#pollOverlay.is-revealed .poll-bar-row.is-correct .poll-bar-name {
    color: #00e676 !important;
}

#pollOverlay.is-revealed .poll-bar-row.is-correct .poll-bar-pct {
    color: rgba(0, 230, 118, 0.80) !important;
}

/* "✓ Correct" inline pill */
.poll-correct-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px 2px 6px;
    background: rgba(0, 230, 118, 0.14);
    border: 1px solid rgba(0, 230, 118, 0.32);
    border-radius: 99px;
    font-size: 9px;
    font-weight: 800;
    color: #00e676;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
    vertical-align: middle;
}


/* ═══════════════════════════════════════════════════════════════════
   INSTRUCTOR — POLL SIDEBAR  (#pollSidebar)
   Matches POI sidebar pattern: fixed right panel, slides in.
   ═══════════════════════════════════════════════════════════════════ */

.poll-sidebar {
    position: fixed;
    right: 16px;
    top: 16px;
    bottom: 16px;
    width: 292px;
    background: #fff;
    border-radius: 16px;
    z-index: 202;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0,0,0,0.16), 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid rgba(0, 98, 158, 0.12);
    overflow: hidden;
    animation: pollSbSlideIn 0.22s ease;
}
.poll-sidebar[hidden] { display: none; }

@keyframes pollSbSlideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Header ───────────────────────────────────────────────────── */

.poll-sb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 13px;
    background: linear-gradient(135deg, #00629e 0%, #0081c8 100%);
    flex-shrink: 0;
}

.poll-sb-header-left {
    display: flex;
    align-items: center;
    gap: 9px;
}

.poll-sb-title {
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    letter-spacing: 0.2px;
}

.poll-sb-close {
    background: rgba(255,255,255,0.18);
    border: none;
    font-size: 12px;
    cursor: pointer;
    color: #fff;
    padding: 4px 9px;
    border-radius: 8px;
    transition: background 0.15s;
    line-height: 1.2;
    font-weight: 500;
}
.poll-sb-close:hover { background: rgba(255,255,255,0.32); }

/* ── Scrollable body ──────────────────────────────────────────── */

.poll-sb-body {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,98,158,0.15) transparent;
}
.poll-sb-body::-webkit-scrollbar { width: 4px; }
.poll-sb-body::-webkit-scrollbar-thumb { background: rgba(0,98,158,0.18); border-radius: 4px; }
.poll-sb-body::-webkit-scrollbar-track { background: transparent; }

/* ── Sections ─────────────────────────────────────────────────── */

.poll-sb-section {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f2f5;
}

.poll-sb-section:last-child { border-bottom: none; }

.poll-sb-section-label {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: #9ea6b0;
    margin-bottom: 9px;
}

/* ── Rhythm picker ────────────────────────────────────────────── */

.poll-sb-picker {
    width: 100%;
    padding: 8px 30px 8px 11px;
    border-radius: 8px;
    border: 1.5px solid #d4d9e2;
    background: #f8f9fb;
    color: #2c3340;
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='rgba(44,51,64,0.45)' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.poll-sb-picker:focus {
    outline: none;
    border-color: #00629e;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(0, 98, 158, 0.12);
}

/* ── Start Poll button ────────────────────────────────────────── */

.poll-sb-start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    border-radius: 9px;
    border: 1.5px solid rgba(0, 98, 158, 0.40);
    background: rgba(0, 98, 158, 0.07);
    color: #00629e;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.2px;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}
.poll-sb-start-btn:hover:not(:disabled) {
    background: rgba(0, 98, 158, 0.14);
    border-color: rgba(0, 98, 158, 0.65);
    box-shadow: 0 2px 8px rgba(0, 98, 158, 0.12);
}
.poll-sb-start-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.poll-sb-hint {
    font-size: 11px;
    color: #9ea6b0;
    text-align: center;
    margin-top: 8px;
    line-height: 1.5;
}

/* ── Active poll panel ────────────────────────────────────────── */

.poll-sb-active-panel {
    padding: 12px 16px 4px;
    animation: pollSbPanelIn 0.22s ease;
}
@keyframes pollSbPanelIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.poll-sb-live-label {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 12px;
}

.poll-sb-live-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #00a854;
    box-shadow: 0 0 6px rgba(0,168,84,0.7);
    animation: liveBlip 1.5s ease-in-out infinite;
}
@keyframes liveBlip {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* QR code */
.poll-sb-qr-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.poll-sb-qr-img {
    display: block;
    border-radius: 10px;
    border: 1px solid #e4e7ed;
}

.poll-sb-qr-url {
    font-size: 8.5px;
    color: #b0b8c4;
    text-align: center;
    word-break: break-all;
    line-height: 1.5;
    margin-bottom: 12px;
    font-family: 'Courier New', monospace;
}

/* Vote count */
.poll-sb-vote-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    justify-content: center;
    margin-bottom: 14px;
}

.poll-sb-votes {
    font-size: 36px;
    font-weight: 800;
    color: #00629e;
    letter-spacing: -2px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    transition: color 0.3s;
}

.poll-sb-votes-label {
    font-size: 11px;
    font-weight: 600;
    color: #9ea6b0;
    letter-spacing: 0.2px;
}

.poll-sb-divider {
    height: 1px;
    background: #f0f2f5;
    margin: 0 0 12px;
}

/* Action buttons */
.poll-sb-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    padding: 9px 14px;
    border-radius: 8px;
    border: 1.5px solid transparent;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.2px;
    transition: all 0.15s;
    font-family: inherit;
    margin-bottom: 7px;
}

.poll-sb-action-reveal {
    background: #f0faf5;
    border-color: rgba(0,168,84,0.30);
    color: #00a854;
}
.poll-sb-action-reveal:hover:not(:disabled) {
    background: #e1f5ea;
    border-color: rgba(0,168,84,0.55);
}
.poll-sb-action-reveal:disabled { opacity: 0.38; cursor: not-allowed; }

.poll-sb-action-close {
    background: #f8f9fb;
    border-color: #e0e3ea;
    color: #707882;
}
.poll-sb-action-close:hover {
    background: #fff0f0;
    border-color: rgba(255,59,48,0.28);
    color: #d63030;
}

/* ── Poll tab button (edge tab on right side) ─────────────────── */

.poll-tab-btn {
    position: fixed;
    right: 0;
    /* sits above the POI reopen button (which is vertically centred at top:50%) */
    top: calc(50% - 96px);
    background: #00629e;
    border: none;
    border-radius: 10px 0 0 10px;
    color: #fff;
    padding: 13px 9px;
    cursor: pointer;
    z-index: 201;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    box-shadow: -3px 0 16px rgba(0,98,158,0.30);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.6px;
    transition: background 0.15s, padding-right 0.15s;
    font-family: inherit;
}
.poll-tab-btn:hover { background: #00527f; padding-right: 13px; }
.poll-tab-btn[hidden] { display: none; }
