/* =============================================
   Agile Planning Poker — style.css
   Card game aesthetic: dark blue/purple, gold reveals
   ============================================= */

:root {
    --bg: #0d1117;
    --surface: #161b27;
    --surface-2: #1f2740;
    --border: #2a3450;
    --text: #e6edf3;
    --muted: #7d8ca8;
    --primary: #7c5cbf;
    --primary-h: #9b7de8;
    --gold: #f0be5a;
    --gold-bg: rgba(240, 190, 90, 0.1);
    --pass: #3fb950;
    --danger: #e03e3e;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --header-h: 52px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Views ── */
.view {
    display: none;
    flex: 1;
    flex-direction: column;
}

.view.active {
    display: flex;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.18s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-h);
    box-shadow: 0 2px 12px rgba(124, 92, 191, 0.4);
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--muted);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--muted);
}

.btn-ghost:hover {
    color: var(--text);
}

.btn-danger {
    background: transparent;
    border-color: rgba(224, 62, 62, 0.3);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(224, 62, 62, 0.08);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.76rem;
}

.btn-xs {
    padding: 3px 8px;
    font-size: 0.72rem;
}

.btn-lg {
    padding: 11px 28px;
    font-size: 0.92rem;
}

/* ── Lobby ── */
.lobby-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 36px;
    padding: 24px;
}

.lobby-logo {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 3rem;
}

.logo-text h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-h), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text p {
    font-size: 0.88rem;
    color: var(--muted);
}

.lobby-cards {
    display: flex;
    gap: 20px;
    align-items: stretch;
    flex-wrap: wrap;
    justify-content: center;
}

.lobby-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: var(--shadow);
}

.lobby-card-icon {
    font-size: 2rem;
}

.lobby-card h2 {
    font-size: 1rem;
    font-weight: 700;
}

.lobby-card p {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.5;
}

.lobby-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
}

/* ── Fields ── */
.field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.field-group label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.field-group input,
.field-group select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    font-family: inherit;
    font-size: 0.82rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.18s;
}

.field-group input:focus,
.field-group select:focus {
    border-color: var(--primary);
}

.code-input {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    text-align: center;
}

/* ── Session Header ── */
.session-header {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 10px;
    flex-shrink: 0;
}

.session-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.logo-small {
    font-size: 1.2rem;
}

.session-code-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.12em;
    background: var(--gold-bg);
    border: 1px solid rgba(240, 190, 90, 0.25);
    border-radius: var(--radius-sm);
    padding: 3px 8px;
}

.session-info {
    flex: 1;
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
}

.session-header-right {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ── Session Body ── */
.session-body {
    flex: 1;
    display: grid;
    grid-template-columns: 220px 1fr;
    overflow: hidden;
}

/* ── Stories Panel ── */
.stories-panel {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.stories-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.panel-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.stories-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.story-item {
    padding: 9px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: all 0.16s;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
}

.story-item:hover {
    background: var(--surface-2);
}

.story-item.active {
    background: rgba(124, 92, 191, 0.15);
    border-left: 3px solid var(--primary);
}

.story-item-title {
    font-size: 0.78rem;
    line-height: 1.4;
    flex: 1;
}

.story-item-pts {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--gold);
    background: var(--gold-bg);
    border-radius: 10px;
    padding: 2px 6px;
    white-space: nowrap;
}

.story-item-del {
    color: var(--muted);
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.18s;
    cursor: pointer;
}

.story-item:hover .story-item-del {
    opacity: 1;
}

.stories-empty {
    padding: 24px 12px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--muted);
}

/* ── Voting Area ── */
.voting-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    gap: 18px;
    overflow-y: auto;
}

.current-story-header {
    text-align: center;
}

.current-story-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.current-story-name {
    font-size: 1.05rem;
    font-weight: 700;
    margin-top: 4px;
    max-width: 500px;
}

/* ── Participants ── */
.participants-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
    min-height: 80px;
    align-items: center;
}

.participant {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.participant-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    transition: border-color 0.25s;
}

.participant-avatar.voted {
    border-color: var(--pass);
}

.participant-avatar.revealed {
    border-color: var(--gold);
}

.participant-card-back {
    width: 38px;
    height: 52px;
    background: linear-gradient(135deg, var(--primary), var(--primary-h));
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.participant-card-val {
    width: 38px;
    height: 52px;
    background: var(--gold);
    color: #1a1a2e;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(240, 190, 90, 0.3);
    animation: cardReveal 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes cardReveal {
    from {
        transform: rotateY(90deg) scale(0.8);
    }

    to {
        transform: rotateY(0deg) scale(1);
    }
}

.participant-name {
    font-size: 0.68rem;
    color: var(--muted);
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Consensus ── */
.reveal-area {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    text-align: center;
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.consensus-meter {
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--muted);
}

.consensus-stat {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.consensus-stat span {
    color: var(--gold);
}

.outlier {
    color: var(--danger);
    font-weight: 700;
}

.timer-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.timer-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold);
}

.timer-icon {
    font-size: 1rem;
}

/* ── Card Deck ── */
.card-deck {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 560px;
}

.poker-card {
    width: 60px;
    height: 84px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
    user-select: none;
    position: relative;
}

.poker-card:hover {
    border-color: var(--primary-h);
    transform: translateY(-6px);
    color: var(--primary-h);
    background: rgba(124, 92, 191, 0.1);
}

.poker-card.selected {
    border-color: var(--primary);
    background: rgba(124, 92, 191, 0.2);
    color: var(--primary-h);
    transform: translateY(-8px);
    box-shadow: 0 6px 20px rgba(124, 92, 191, 0.35);
}

.poker-card.selected::after {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.poker-card:disabled,
.poker-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ── Host Controls ── */
.host-controls {
    display: flex;
    gap: 10px;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 380px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 18px;
    right: 18px;
    background: var(--text);
    color: var(--bg);
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    font-size: 0.8rem;
    z-index: 999;
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.25s;
    pointer-events: none;
    max-width: 260px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .session-body {
        grid-template-columns: 1fr;
    }

    .stories-panel {
        display: none;
    }
}