/* Countdown timer: one huge readout, one button. The shared shell provides the
   header and footer; everything inside #main is this page's own layout. */

.timer-body {
    /* The stage is exactly one viewport tall, so the readout never scrolls. */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100svh;
}

.timer-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(24px, 5vh, 56px);
    padding: 24px clamp(16px, 4vw, 48px) calc(24px + env(safe-area-inset-bottom));
}

.timer-display {
    margin: 0;
    font-family: var(--display);
    font-weight: 400;
    line-height: .82;
    /* Jersey 10 renders "00:00:00" 2.4914em wide (measured), so the width term
       keeps eight glyphs inside the stage gutters. The height term spends what
       the header, the controls row and their gaps leave over. svh second so
       browsers without it keep the vh value. */
    font-size: min(calc((100vw - 96px) / 2.4914), calc((100vh - 300px) / .82));
    font-size: min(calc((100vw - 96px) / 2.4914), calc((100svh - 300px) / .82));
    letter-spacing: -.01em;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.timer-display[data-state="running"] { color: var(--accent); }
.timer-display[data-state="paused"] { color: var(--muted); }
.timer-display[data-state="over"] {
    color: var(--accent);
    animation: timer-alarm 1s steps(2, jump-none) infinite;
}

@keyframes timer-alarm {
    50% { opacity: .35; }
}

.timer-controls {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
}

.timer-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--muted);
    /* Keep the caption with its field when the row wraps. */
    width: 100%;
    text-align: center;
    order: 1;
}

.timer-input {
    order: 2;
    /* border-box, so the box must carry the padding and letter-spacing too. */
    width: calc(9ch + 34px);
    padding: 14px 16px;
    background: #080808;
    border: 1px solid var(--line);
    border-radius: 0;
    color: var(--text);
    font-family: var(--mono);
    font-size: 20px;
    letter-spacing: .04em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.timer-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.timer-input[aria-invalid="true"] { border-color: var(--accent); }
.timer-input:disabled { color: var(--muted); }

.timer-button {
    order: 3;
    min-width: 168px;
    gap: 0;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.timer-hint {
    order: 4;
    width: 100%;
    margin: 0;
    text-align: center;
    font-size: 13px;
    color: var(--accent);
    min-height: 20px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 860px) {
    .timer-stage { padding-inline: 20px; }
    .timer-display {
        font-size: min(calc((100vw - 40px) / 2.4914), calc((100vh - 260px) / .82));
        font-size: min(calc((100vw - 40px) / 2.4914), calc((100svh - 260px) / .82));
    }
    .timer-input { font-size: 18px; min-height: 48px; width: calc(9ch + 30px); }
    .timer-button { width: 100%; max-width: 320px; min-height: 56px; }
}

/* Short screens (landscape phones, netbooks): keep the controls to one row so
   the readout can claim the height instead of the page scrolling. */
@media (max-height: 560px) {
    .timer-stage {
        gap: 12px;
        padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    }

    .timer-display {
        font-size: min(calc((100vw - 40px) / 2.4914), calc((100vh - 150px) / .82));
        font-size: min(calc((100vw - 40px) / 2.4914), calc((100svh - 150px) / .82));
    }

    .timer-controls { align-items: center; gap: 10px; }
    .timer-label { order: 0; width: auto; font-size: 10px; }
    .timer-input { min-height: 40px; padding: 8px 10px; font-size: 16px; width: calc(9ch + 22px); }
    .timer-button { width: auto; max-width: none; min-height: 40px; min-width: 118px; padding: 8px 18px; font-size: 14px; }
    .timer-hint { order: 5; min-height: 0; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .timer-display[data-state="over"] { animation: none; }
}
