/* ============================================================
    CSS VARIABLES — edit these to retheme the whole app
============================================================ */
:root {
    --bg:          #0d0d0d;
    --surface:     #161616;
    --border:      #2a2a2a;
    --text:        #e8e8e8;
    --muted:       #555;
    --accent:      #f0c040;   /* the yellow highlight color */
    --danger:      #e05252;   /* used when time is almost up */
    --success:     #52c07a;
    --font:        'IBM Plex Mono', monospace;
    --radius:      4px;
}

/* ============================================================
    RESET & BASE
============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* ============================================================
    SCREENS
    There are 3 screens: #setup-screen, #waiting-screen, #running-screen.
    Only one is visible at a time. JS toggles the 'hidden' class.
============================================================ */
.screen { width: 100%; max-width: 680px; }
.hidden { display: none !important; }

/* ============================================================
    SHARED COMPONENTS
============================================================ */
h1 {
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 32px;
}

label {
    display: block;
    font-size: 11px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}

input, textarea, select {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    padding: 12px 14px;
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
}
textarea {
    resize: vertical;
    min-height: 90px;
}

.field { margin-bottom: 24px; }

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

button {
    font-family: var(--font);
    font-size: 13px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: var(--radius);
    padding: 13px 24px;
    border: none;
    transition: opacity 0.15s, background 0.15s;
}
button:hover { opacity: 0.85; }

.btn-primary {
    background: var(--accent);
    color: #0d0d0d;
    font-weight: 700;
    width: 100%;
    margin-top: 8px;
}
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 11px;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

/* ============================================================
    SETUP SCREEN
============================================================ */
#hint {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.7;
    margin-bottom: 32px;
}

/* ============================================================
    WAITING SCREEN — shown after setup, before jam start time
============================================================ */
#waiting-screen { text-align: center; }

#waiting-countdown {
    font-size: clamp(36px, 8vw, 72px);
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.05em;
    margin: 16px 0;
}

#waiting-label {
    font-size: 12px;
    color: var(--muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 32px;
}

#waiting-goal-preview {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    padding: 16px 20px;
    text-align: left;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    margin-bottom: 24px;
}

/* ============================================================
    RUNNING SCREEN — the main countdown experience
============================================================ */
#running-screen { text-align: center; }

/* The big dramatic countdown display */
#countdown-display {
    font-size: clamp(52px, 13vw, 120px);
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 1;
    margin: 8px 0 4px;
    transition: color 0.5s;
    /* flicker animation defined below */
}
#countdown-display.urgent { color: var(--danger); }
#countdown-display.normal { color: var(--accent); }

#time-label {
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 32px;
}

/* Progress bar */
#progress-track {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 32px;
    overflow: hidden;
}
#progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 1s linear, background 0.5s;
}
#progress-fill.urgent { background: var(--danger); }

/* Milestone markers inside the progress track */
#milestone-markers {
    position: relative;
    height: 0; /* overlaid on the track above via negative margin */
    margin-top: -4px;
    margin-bottom: 32px;
}
.milestone-dot {
    position: absolute;
    top: -4px;
    width: 4px;
    height: 12px;
    background: var(--bg);
    transform: translateX(-50%);
}

/* Goal box */
#goal-display {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    padding: 16px 20px;
    text-align: left;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    margin-bottom: 24px;
}

/* Milestone checkpoints */
#milestones {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 28px;
}
.milestone {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 11px;
    text-align: center;
}
.milestone .ms-pct {
    color: var(--accent);
    font-weight: 700;
    font-size: 14px;
    display: block;
    margin-bottom: 2px;
}
.milestone .ms-time {
    color: var(--muted);
    font-size: 10px;
    display: block;
    margin-bottom: 4px;
}
.milestone .ms-label { color: var(--muted); }
.milestone.passed { opacity: 0.4; }
.milestone.passed .ms-pct { color: var(--muted); text-decoration: line-through; }

/* Stats row */
#stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 32px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
}
.stat-value { font-size: 18px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 10px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 2px; }

/* Bottom strip: deadline info + abort */
#bottom-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}
#deadline-info { font-size: 11px; color: var(--muted); text-align: left; line-height: 1.7; }

/* ============================================================
    FINISHED SCREEN
============================================================ */
#finished-screen { text-align: center; }
#finished-screen h2 { font-size: 48px; color: var(--accent); margin-bottom: 8px; }
#finished-screen p { color: var(--muted); font-size: 13px; line-height: 1.7; }

/* ============================================================
    BLINKING CURSOR — cosmetic detail on the countdown
============================================================ */
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
#cursor { animation: blink 1.2s step-end infinite; color: var(--muted); }

/* ============================================================
    FLICKER — very subtle, fires when timer ticks
============================================================ */
@keyframes flicker {
    0%   { opacity: 1; }
    5%   { opacity: 0.85; }
    10%  { opacity: 1; }
}
.tick-flicker { animation: flicker 0.2s ease-out; }
