/* VoteWise Demo — design tokens mirrored from the app's design-system/variables.css */

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1e40af;
    --color-primary-light: #3b82f6;

    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #3b82f6;

    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --border-color: #e2e8f0;
    --border-color-dark: #cbd5e1;

    --bg-secondary: #f8fafc;
    --bg-hover: #f1f5f9;
}

/* Alpine's x-cloak is not styled by the Tailwind CDN build */
[x-cloak] { display: none !important; }

/* Visible keyboard focus everywhere (theme-consistent blue ring) */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

.page-shell { padding-top: 4.5rem; }

/* ─── Brand ─── */
.brand-mark {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}
.brand-mark .glyph {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, var(--color-primary), #1e40af);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 0.85rem;
}

/* ─── Nav ─── */
.vw-nav {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}
.vw-nav .nav-link {
    position: relative;
    padding: 0.35rem 0.7rem;
    border-radius: 0.4rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    transition: color 0.15s, background-color 0.15s;
}
.vw-nav .nav-link:hover { color: var(--text-primary); background: var(--bg-hover); }
.vw-nav .nav-link.active { color: var(--color-primary); background: rgba(37, 99, 235, 0.08); }

/* ─── Status badge ─── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}
.status-badge.live { background: rgba(239, 68, 68, 0.1); color: #dc2626; }
.status-badge.final { background: rgba(16, 185, 129, 0.12); color: #059669; }
.pulse-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 999px;
    background: #dc2626;
    animation: pulse-ring 1.6s ease-out infinite;
}
@keyframes pulse-ring {
    0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
    70%  { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* ─── Cards ─── */
.vw-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.vw-card-hover { transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; }
.vw-card-hover:hover {
    transform: translateY(-2px);
    border-color: var(--border-color-dark);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

/* ─── Stat cards ─── */
.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--gray-500);
}
.stat-number { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.stat-icon {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.6rem;
    display: grid;
    place-items: center;
    font-size: 0.95rem;
}

/* ─── Candidate cards ─── */
.candidate-card {
    position: relative;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.candidate-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-color-dark);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.09);
}
.candidate-card.is-winner { border-color: rgba(16, 185, 129, 0.5); }
.candidate-photo {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: var(--gray-100);
    display: block;
}
.candidate-rank {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    min-width: 1.9rem;
    height: 1.6rem;
    padding: 0 0.4rem;
    border-radius: 0.35rem;
    background: rgba(15, 23, 42, 0.82);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: grid;
    place-items: center;
    backdrop-filter: blur(4px);
}
.winner-badge {
    position: absolute;
    top: 0;
    right: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.7rem 0.3rem 0.85rem;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom-left-radius: 0.6rem;
}
.partylist-flag {
    display: inline-block;
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 0.2rem;
    border: 1px solid var(--border-color);
    vertical-align: -0.15rem;
}
.vote-count { font-size: 1.35rem; font-weight: 700; }
.vote-pct { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }

/* Vote bar — width is set inline from the app's candidate.percentage */
.vote-bar {
    height: 0.4rem;
    border-radius: 999px;
    background: var(--gray-100);
    overflow: hidden;
}
.vote-bar > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--color-primary-light), var(--color-primary));
    transition: width 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}
.candidate-card.is-winner .vote-bar > span {
    background: linear-gradient(90deg, #34d399, #059669);
}

/* Scroll-reveal (mirrors the app's IntersectionObserver behaviour) */
.reveal {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ─── Buttons ─── */
.btn { transition: transform 0.15s, box-shadow 0.15s, background-color 0.15s; }
.btn:hover { transform: translateY(-1px); }

/* ─── Biometric wizard ─── */
.face-stage {
    position: relative;
    aspect-ratio: 4 / 3;
    background: #0f172a;
    border-radius: 0.9rem;
    overflow: hidden;
}
.face-stage video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}
.face-oval {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 46%;
    height: 62%;
    border: 2px dashed rgba(255, 255, 255, 0.55);
    border-radius: 48% 48% 45% 45% / 58% 58% 42% 42%;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.face-oval.is-locked { border-color: #34d399; box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55), 0 0 22px rgba(52, 211, 153, 0.5); }
.face-oval.is-fail  { border-color: #f87171; box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55), 0 0 22px rgba(248, 113, 113, 0.5); }
.scan-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #34d399, transparent);
    box-shadow: 0 0 12px rgba(52, 211, 153, 0.9);
    animation: scan 2.4s ease-in-out infinite;
}
@keyframes scan {
    0%, 100% { top: 18%; opacity: 0.25; }
    50%      { top: 82%; opacity: 1; }
}
.liveness-track {
    height: 0.45rem;
    border-radius: 999px;
    background: var(--gray-200);
    overflow: hidden;
}
.liveness-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #34d399, #059669);
    transition: width 0.5s ease;
}

/* Anti-spoofing gauntlet rows */
.gauntlet-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: #fff;
    font-size: 0.82rem;
}
.gauntlet-row .threshold { font-size: 0.72rem; color: var(--text-muted); font-family: 'Courier New', monospace; }
.chk { color: var(--gray-300); }
.chk.ok { color: #059669; }
.chk.no { color: var(--gray-300); }

/* ─── Ballot ─── */
.ballot-group { scroll-margin-top: 5.5rem; }
.ballot-pick {
    position: relative;
    display: block;
    cursor: pointer;
}
.ballot-pick input { position: absolute; opacity: 0; pointer-events: none; }
.ballot-pick .pick-surface {
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    overflow: hidden;
    transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}
.ballot-pick:hover .pick-surface { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08); }
.ballot-pick input:checked + .pick-surface { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
/* Native radios are visually hidden but keyboard-focusable — mirror the
   checked ring so tab focus is visible on the card surface. */
.ballot-pick input:focus-visible + .pick-surface { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35); }
.ballot-pick input:focus-visible { outline: none; }
.radio-dot {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border-color-dark);
    border-radius: 999px;
    display: grid;
    place-items: center;
    flex: none;
    transition: border-color 0.18s, background-color 0.18s;
}
.radio-dot::after {
    content: '';
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 999px;
    background: #fff;
    transform: scale(0);
    transition: transform 0.18s;
}
.ballot-pick input:checked ~ .pick-meta .radio-dot { border-color: var(--color-primary); background: var(--color-primary); }
.ballot-pick input:checked ~ .pick-meta .radio-dot::after { transform: scale(1); }
.ballot-pick input:disabled ~ .pick-surface { opacity: 0.5; cursor: not-allowed; }

/* ─── Tables ─── */
.vw-table { width: 100%; border-collapse: separate; border-spacing: 0; }
/* Floor the table width inside scroll wrappers so narrow viewports scroll
   horizontally instead of crushing columns. */
.overflow-x-auto .vw-table { min-width: 38rem; }
.vw-table thead th {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gray-500);
    text-align: left;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--gray-50);
}
.vw-table thead th:first-child { border-top-left-radius: 0.5rem; }
.vw-table thead th:last-child  { border-top-right-radius: 0.5rem; }
.vw-table tbody td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.86rem;
}
.vw-table tbody tr:hover { background: var(--bg-hover); }

/* ─── Admin ─── */
.kpi {
    background: #fff;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--color-primary);
    border-radius: 0.6rem;
    padding: 1rem 1.1rem;
}
.kpi.success { border-left-color: var(--color-success); }
.kpi.warning { border-left-color: var(--color-warning); }
.kpi.danger  { border-left-color: var(--color-danger); }
.chart-box { position: relative; height: 230px; }

.seg {
    display: inline-flex;
    padding: 0.2rem;
    background: var(--gray-100);
    border-radius: 0.5rem;
    gap: 0.15rem;
}
.seg button {
    padding: 0.3rem 0.7rem;
    border-radius: 0.35rem;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--gray-500);
    transition: background-color 0.15s, color 0.15s;
}
.seg button.is-on { background: #fff; color: var(--color-primary); box-shadow: 0 1px 2px rgba(15,23,42,0.08); }

.demo-note {
    font-size: 0.7rem;
    color: var(--text-muted);
    border-left: 2px solid var(--border-color);
    padding-left: 0.6rem;
}

.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.skeleton { background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 37%, var(--gray-100) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media (prefers-reduced-motion: reduce) {
    .reveal { opacity: 1; transform: none; transition: none; }
    .scan-line, .pulse-dot { animation: none; }
}

/* ─── Small screens (360px) ─── */
@media (max-width: 40rem) {
    .chart-box { height: 12.5rem; }
    .stat-number { font-size: 1.5rem; }
    .vote-count { font-size: 1.15rem; }
}
