/*
 * StarshipOS — Puzzle Base Styles (CC_059 P3)
 * Base styling for the Mini-Game Framework UI components.
 */

/* ── CSS Variables for theming ─────────────────────────────── */
:root {
    --puzzle-bg: #1a1a2e;
    --puzzle-card-bg: #16213e;
    --puzzle-border: #0f3460;
    --puzzle-text: #e0e0e0;
    --puzzle-text-muted: #8a8a9a;
    --puzzle-accent: #00d4ff;
    --puzzle-warning: #ff6b35;
    --puzzle-danger: #e63946;
    --puzzle-success: #2ecc71;

    --difficulty-easy: #2ecc71;
    --difficulty-medium: #3498db;
    --difficulty-hard: #e67e22;
    --difficulty-extreme: #e63946;

    --result-success: #2ecc71;
    --result-failure: #e63946;
    --result-timeout: #e67e22;
    --result-aborted: #8a8a9a;

    --puzzle-radius: 6px;
    --puzzle-gap: 1rem;
}

/* ── Dashboard Layout ──────────────────────────────────────── */
.puzzle-dashboard-layout {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: var(--puzzle-gap);
    padding: var(--puzzle-gap);
    max-width: 1200px;
    margin: 0 auto;
}

.puzzle-header {
    text-align: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--puzzle-border);
}

.puzzle-title {
    margin: 0;
    font-size: 1.5rem;
    color: var(--puzzle-accent);
}

.puzzle-subtitle {
    margin: 0.25rem 0 0;
    color: var(--puzzle-text-muted);
    font-size: 0.85rem;
}

.puzzle-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--puzzle-gap);
    align-items: start;
}

/* ── Trigger Panel (Start Form) ────────────────────────────── */
.puzzle-trigger-panel {
    background: var(--puzzle-card-bg);
    border: 1px solid var(--puzzle-border);
    border-radius: var(--puzzle-radius);
    padding: var(--puzzle-gap);
}

.puzzle-trigger-panel .trigger-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.difficulty-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.difficulty-radio {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.difficulty-radio input[type="radio"] {
    accent-color: var(--puzzle-accent);
}

/* ── Active Puzzles Grid ───────────────────────────────────── */
.puzzle-active-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.puzzle-active-card {
    background: var(--puzzle-card-bg);
    border: 1px solid var(--puzzle-border);
    border-radius: var(--puzzle-radius);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.puzzle-active-name {
    font-weight: 600;
    color: var(--puzzle-text);
}

.puzzle-active-station {
    font-size: 0.8rem;
    color: var(--puzzle-text-muted);
}

.puzzle-active-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.puzzle-remaining-time {
    font-size: 0.85rem;
    color: var(--puzzle-text-muted);
    font-variant-numeric: tabular-nums;
}

.puzzle-active-empty,
.puzzle-empty {
    color: var(--puzzle-text-muted);
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

.puzzle-error {
    color: var(--puzzle-danger);
    font-weight: 600;
    padding: 0.5rem;
    border: 1px solid var(--puzzle-danger);
    border-radius: var(--puzzle-radius);
    text-align: center;
}

/* ── Countdown Bar ─────────────────────────────────────────── */
.puzzle-countdown-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.puzzle-countdown-fill {
    height: 100%;
    background: var(--puzzle-accent);
    border-radius: 4px;
    transition: width 1s linear;
}

.puzzle-countdown-fill.countdown-warning {
    background: var(--puzzle-warning);
    animation: countdown-pulse 0.8s ease-in-out infinite;
}

/* ── Difficulty Badge ──────────────────────────────────────── */
.puzzle-difficulty-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.puzzle-difficulty-badge.difficulty-easy {
    background: var(--difficulty-easy);
    color: #fff;
}

.puzzle-difficulty-badge.difficulty-medium {
    background: var(--difficulty-medium);
    color: #fff;
}

.puzzle-difficulty-badge.difficulty-hard {
    background: var(--difficulty-hard);
    color: #fff;
}

.puzzle-difficulty-badge.difficulty-extreme {
    background: var(--difficulty-extreme);
    color: #fff;
}

/* ── Result Badge ──────────────────────────────────────────── */
.puzzle-result-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.puzzle-result-badge.result-success {
    background: var(--result-success);
    color: #fff;
}

.puzzle-result-badge.result-failure {
    background: var(--result-failure);
    color: #fff;
}

.puzzle-result-badge.result-timeout {
    background: var(--result-timeout);
    color: #fff;
}

.puzzle-result-badge.result-aborted {
    background: var(--result-aborted);
    color: #fff;
}

/* ── Container Overlay (Modal) ─────────────────────────────── */
.puzzle-container-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.puzzle-container-modal {
    background: var(--puzzle-card-bg);
    border: 2px solid var(--puzzle-accent);
    border-radius: var(--puzzle-radius);
    padding: 1.5rem;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.2);
}

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

.puzzle-container-title {
    margin: 0;
    font-size: 1.25rem;
    color: var(--puzzle-accent);
}

.puzzle-container-content {
    min-height: 100px;
}

.puzzle-container-footer {
    text-align: center;
    color: var(--puzzle-text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--puzzle-border);
    padding-top: 0.75rem;
}

/* ── Timer Bar ─────────────────────────────────────────────── */
.puzzle-timer-bar {
    width: 100%;
}

.puzzle-timer-track {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
}

.puzzle-timer-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--puzzle-accent), #00aaff);
    border-radius: 6px;
    animation: timer-shrink linear forwards;
    transition: width 1s linear;
}

.puzzle-timer-fill.timer-fill-warning {
    background: linear-gradient(90deg, var(--puzzle-danger), var(--puzzle-warning));
    animation: countdown-pulse 0.8s ease-in-out infinite, timer-shrink linear forwards;
}

.puzzle-timer-bar.timer-warning .puzzle-timer-track {
    border: 1px solid var(--puzzle-warning);
}

.puzzle-timer-label {
    text-align: center;
    font-size: 0.8rem;
    color: var(--puzzle-text-muted);
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}

/* ── History Panel ─────────────────────────────────────────── */
.puzzle-history-panel {
    background: var(--puzzle-card-bg);
    border: 1px solid var(--puzzle-border);
    border-radius: var(--puzzle-radius);
    padding: var(--puzzle-gap);
}

.puzzle-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.puzzle-history-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--puzzle-radius);
}

.puzzle-history-type {
    font-weight: 600;
    color: var(--puzzle-text);
    flex: 1;
}

.puzzle-history-time {
    font-size: 0.8rem;
    color: var(--puzzle-text-muted);
    font-variant-numeric: tabular-nums;
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes countdown-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes timer-shrink {
    from { width: var(--timer-start-width, 100%); }
    to { width: 0%; }
}

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

    .puzzle-container-modal {
        width: 95%;
        max-height: 90vh;
        padding: 1rem;
    }

    .difficulty-options {
        flex-direction: column;
    }
}
