/* Timer: one page, one column, the time large. Light and dark follow the
   system, the palette is a warm off-white and a true black for OLED phones,
   with one quiet teal for the primary control and the rung bells. */

:root {
    color-scheme: light dark;
    --bg: #f7f6f2;
    --ink: #1c1c1a;
    --ink-dim: #a8a7a0;
    --muted: #6b6a65;
    --line: #d5d3cb;
    --hover: rgba(28, 28, 26, 0.06);
    --accent: #1f5f6e;
    --accent-hover: #184c58;
    --accent-ink: #ffffff;
    --bell: #d5d3cb;
    --bell-rung: #1f5f6e;
    --focus: #1f5f6e;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
        --ink: #d9d6cf;
        --ink-dim: #4a4946;
        --muted: #8a8983;
        --line: #2c2c30;
        --hover: rgba(217, 214, 207, 0.08);
        --accent: #24687a;
        --accent-hover: #1f5f6e;
        --accent-ink: #ffffff;
        --bell: #2c2c30;
        --bell-rung: #7fb6c4;
        --focus: #7fb6c4;
    }
}

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

html {
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    padding-top: calc(1.5rem + env(safe-area-inset-top));
    padding-right: calc(1.5rem + env(safe-area-inset-right));
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    padding-left: calc(1.5rem + env(safe-area-inset-left));
    -webkit-tap-highlight-color: transparent;
}

/* The timer */

.timer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.75rem;
    width: 100%;
    max-width: 32rem;
    text-align: center;
}

.bells {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    height: 1rem;
}

.bell {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    background: var(--bell);
    transition: background-color 600ms ease;
}

.bell--closing {
    width: 0.875rem;
    height: 0.875rem;
}

.bell--rung {
    background: var(--bell-rung);
}

/* The time reserves its space: a fixed line height, tabular digits, and the
   same five characters from 00:00 to 20:00, so nothing moves as it counts. */
.time {
    font-size: clamp(4.5rem, 24vw, 9rem);
    font-weight: 200;
    line-height: 1;
    min-height: 1em;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    transition: color 800ms ease;
}

.status {
    min-height: 1.5rem;
    line-height: 1.5rem;
    color: var(--muted);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    transition: opacity 800ms ease;
}

.button {
    font: inherit;
    font-size: 1.0625rem;
    font-weight: 500;
    min-height: 3rem;
    min-width: 7.5rem;
    padding: 0 1.5rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color 150ms ease, opacity 800ms ease;
}

.button:disabled {
    opacity: 0.4;
    cursor: default;
}

.button:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
}

.button--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.button--quiet {
    min-width: 0;
    border-color: transparent;
    color: var(--muted);
}

.dev-note {
    font-size: 0.875rem;
    color: var(--muted);
}

/* Hover styles only where a pointer can hover. A touchscreen leaves a sticky
   hover state on whatever was last tapped, which would hold the tapped
   control at full colour and full opacity for the rest of the sit. */

@media (hover: hover) {
    .button:hover {
        background: var(--hover);
    }

    .button:disabled:hover {
        background: transparent;
    }

    .button--primary:hover {
        background: var(--accent-hover);
    }
}

/* While running, the display dims and the controls recede. They come back
   under a hovering pointer or on keyboard focus (:focus-visible, which a tap
   never sets), and stay full size to tap. */

.timer[data-state="running"] .time {
    color: var(--ink-dim);
}

.timer[data-state="running"] .controls,
.timer[data-state="running"] .button--quiet {
    opacity: 0.35;
}

.timer[data-state="running"] .controls:has(:focus-visible),
.timer[data-state="running"] .button--quiet:focus-visible {
    opacity: 1;
}

@media (hover: hover) {
    .timer[data-state="running"] .controls:hover,
    .timer[data-state="running"] .button--quiet:hover {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
}

/* Plain pages (page not found) */

.doc {
    width: 100%;
    max-width: 32rem;
    line-height: 1.6;
}

.doc h1 {
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.doc p {
    margin-bottom: 1rem;
}

.doc a {
    color: var(--accent);
}

.page-footer {
    margin-top: 2rem;
    font-size: 0.875rem;
    color: var(--muted);
}
