/* Fullscreen, chrome-free by default: #stage fills the viewport and
   centers the countdown; every secondary control lives in .fade-ui and is
   only shown on mouse/touch/keyboard activity (or while idle/paused, or
   while the settings drawer is open) — see app.js showUI()/scheduleHide(). */

html, body { height: 100%; }
body { overflow: hidden; }

#stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px;
    text-align: center;
}

/* opacity handles the visual fade; visibility is the hard guarantee that an
   element is actually gone once the fade finishes (delayed on the way out,
   instant on the way in) — belt-and-suspenders against any single element
   getting stuck visible if its opacity transition doesn't settle. */
.fade-ui { opacity: 1; visibility: visible; transition: opacity 0.4s ease, visibility 0s linear 0s; }
body.ui-hidden .fade-ui { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.4s ease, visibility 0s linear 0.4s; }
body.ui-hidden { cursor: none; }

.back-link {
    position: fixed;
    top: 16px;
    left: 20px;
    z-index: 30;
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
}
.back-link:hover { color: var(--primary); }

#corner-actions { position: fixed; top: 16px; right: 20px; z-index: 30; display: flex; gap: 8px; }

/* Ambient whole-queue progress, always visible but intentionally tiny. */
#progress-sliver { position: fixed; top: 0; left: 0; width: 100%; height: 3px; background: var(--border); z-index: 40; }
#progress-sliver-fill { height: 100%; width: 0%; background: var(--primary); transition: width 0.2s linear; }

/* Segmented control (shared look with control/certificates) */
.segmented { display: flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; min-width: 0; }
.segmented button {
    flex: 1;
    min-width: 0;
    padding: 6px 4px;
    border: none;
    background: var(--surface);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    border-right: 1px solid var(--border-strong);
    color: var(--text);
}
.segmented button:last-child { border-right: none; }
.segmented button.active { background: var(--primary); color: #fff; }

#queue-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.queue-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    font-size: 13px;
}
.queue-item.current { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface-2)); }
.queue-item .qi-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item .qi-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.queue-item .qi-actions { display: flex; gap: 2px; }
.queue-item button { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 13px; padding: 2px 4px; }
.queue-item button:hover { color: var(--primary); }

#preset-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.preset-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; }
.preset-row .pr-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#step-nav { display: flex; gap: 14px; align-items: baseline; color: var(--muted); font-size: 14px; }
#step-position { font-weight: 600; color: var(--text); }

#display-stage { display: flex; align-items: center; justify-content: center; width: 100%; max-width: 560px; cursor: pointer; }
.anim-block { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }

.time-display {
    font-size: 108px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
    color: var(--text);
    white-space: nowrap;
    transition: color 0.3s;
}
.time-display-huge { font-size: 26vw; line-height: 1; }
/* Emoji glyphs have a fixed native bitmap resolution — scaling one to a
   fraction of the viewport width (like the huge digits do) upscales past
   that ceiling and looks visibly soft/pixelated. Cap it, but only when
   showing the celebration emoji; the numeric countdown keeps its full size. */
.time-display-huge.finished { font-size: min(26vw, 160px); }
.step-name { font-size: 19px; font-weight: 600; color: var(--muted); text-align: center; }

/* Ring */
#anim-ring svg { width: 52vh; height: 52vh; max-width: 75vw; max-height: 75vw; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--border); stroke-width: 10; }
.ring-progress {
    fill: none;
    stroke: var(--primary);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 552.9;
    stroke-dashoffset: 0;
    transition: stroke 0.3s;
}
#anim-ring { position: relative; }
.ring-label {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 15%;
    pointer-events: none;
}

/* Bar */
.bar-track { width: 100%; max-width: 560px; height: 30px; border-radius: 15px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; width: 100%; background: var(--primary); transition: width 0.2s linear, background 0.3s; }

#controls { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }

.time-display.warn-amber { color: #d98c00; }
.time-display.warn-red { color: var(--danger); }
.ring-progress.warn-amber { stroke: #d98c00; }
.ring-progress.warn-red { stroke: var(--danger); }
.bar-fill.warn-amber { background: #d98c00; }
.bar-fill.warn-red { background: var(--danger); }

/* Each character of the clock is its own span so only the digit that
   actually changed animates — not the whole time string. white-space:nowrap
   on the parent (.time-display) keeps these from ever line-wrapping, which
   inline-block siblings are otherwise free to do even with no whitespace
   between them in the markup. */
.digit-char { display: inline-block; border-radius: 0.15em; }

/* While setting the time by typing, the digit slot that the next keystroke
   will replace is clearly marked and blinks, like a classic segmented time
   input — otherwise it's not obvious which position is being edited. */
.digit-char.editing-active {
    background: color-mix(in srgb, var(--primary) 20%, transparent);
    animation: editCursorBlink 1s step-start infinite;
}
@keyframes editCursorBlink { 50% { background: color-mix(in srgb, var(--primary) 5%, transparent); } }

/* Last 30s of a step: a small pulse, only on the digit(s) that changed.
   Otherwise: a barely-there fade — kept subtle since a full-screen clock
   ticking every second is already enough motion on its own. */
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.pulse-tick { animation: pulse 0.3s ease-out; }
@keyframes fadeTick { 0% { opacity: 0.7; } 100% { opacity: 1; } }
.fade-tick { animation: fadeTick 0.4s ease-out; }

/* Settings drawer */
#drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 25, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 45;
}
#drawer-backdrop.open { opacity: 1; pointer-events: auto; }
#settings-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 400px;
    max-width: 92vw;
    background: var(--bg);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    z-index: 50;
    padding: 18px 18px 40px 18px;
}
#settings-drawer.open { transform: translateX(0); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.drawer-header h2 { font-size: 17px; margin: 0; }
#settings-drawer .databanner { border-radius: var(--r); margin-bottom: 16px; }

@media (max-width: 640px) {
    .time-display { font-size: 72px; }
    #anim-ring svg { width: 56vh; height: 56vh; }
}
