/* Online Timer & Stopwatch - scoped styles (light + dark) */

.bg-subtle-grid-timer {
    background-size: 40px 40px;
    background-image:
        linear-gradient(to right, rgba(6, 182, 212, 0.04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(6, 182, 212, 0.04) 1px, transparent 1px);
}

html.dark .bg-subtle-grid-timer {
    background-image:
        linear-gradient(to right, rgba(6, 182, 212, 0.03) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(6, 182, 212, 0.03) 1px, transparent 1px);
}

/* Glass cards (same treatment as the Date Calculator) */
.apple-glass {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(228, 228, 231, 0.9);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.04);
}

html.dark .apple-glass {
    background: rgba(10, 10, 14, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

@media (max-width: 767px) {
    .apple-glass,
    html.dark .apple-glass {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
}

/* iOS zoom prevention */
#ots-workspace input[type="number"] {
    font-size: 16px !important;
    line-height: 1.5;
}

/* Big digits. Font size scales with the viewport and steps down for longer readings
   (H:MM:SS, or the stopwatch's hundredths) so nothing overflows a 320px screen. */
.ots-digits {
    font-size: clamp(3.5rem, 21vw, 7.5rem);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ots-digits--long {
    font-size: clamp(2.5rem, 14vw, 6rem);
}

.ots-digits--sw {
    font-size: clamp(3rem, 16vw, 6.5rem);
}

.ots-digits--sw.ots-digits--long {
    font-size: clamp(2.25rem, 12vw, 5.25rem);
}

.ots-cs {
    font-size: 0.6em;
    opacity: 0.75;
}

#timerProgress {
    transition: width 0.25s linear;
}

/* Preset chips */
.ots-preset {
    background: #f4f4f5;
    border-color: rgba(228, 228, 231, 0.9);
    color: #3f3f46;
    touch-action: manipulation;
}

.ots-preset:hover:not(:disabled) {
    border-color: rgba(6, 182, 212, 0.5);
    color: #18181b;
}

html.dark .ots-preset {
    background: rgba(9, 9, 11, 0.6);
    border-color: rgba(255, 255, 255, 0.08);
    color: #d4d4d8;
}

html.dark .ots-preset:hover:not(:disabled) {
    color: #ffffff;
}

.ots-preset.is-active {
    background: rgba(6, 182, 212, 0.15);
    border-color: rgba(6, 182, 212, 0.55);
    color: #0e7490;
}

html.dark .ots-preset.is-active {
    background: rgba(6, 182, 212, 0.18);
    color: #67e8f9;
}

.ots-preset:disabled,
.ots-input:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Hide number spinners: the fields are short and spinners steal width on phones */
.ots-input::-webkit-inner-spin-button,
.ots-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ots-input {
    -moz-appearance: textfield;
}

/* Toggle switch */
.ots-toggle {
    width: 2.75rem;
    height: 1.5rem;
    background-color: #cbd5e1;
    border: 1px solid #94a3b8;
    border-radius: 9999px;
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

html.dark .ots-toggle {
    background-color: #27272a;
    border-color: #3f3f46;
}

.ots-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1.125rem;
    height: 1.125rem;
    background-color: #ffffff;
    border-radius: 9999px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

input:checked + .ots-toggle {
    background-color: #06b6d4;
    border-color: #0891b2;
}

input:checked + .ots-toggle::after {
    transform: translateX(1.25rem);
}

input:focus-visible + .ots-toggle {
    outline: 2px solid #06b6d4;
    outline-offset: 2px;
}

/* Keyboard hint */
.ots-hint kbd {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
    padding: 0.05rem 0.35rem;
    border-radius: 0.375rem;
    border: 1px solid rgba(161, 161, 170, 0.5);
}

/* Paused: digits dim slightly */
.ots-stage.is-paused #timerDisplay,
.ots-stage.is-sw-paused #swDisplay {
    opacity: 0.7;
}

/* Time's up */
.ots-stage.is-done {
    border-color: rgba(244, 63, 94, 0.6) !important;
    animation: ots-pulse 1s ease-in-out infinite;
}

.ots-stage.is-done #timerDisplay,
.ots-stage.is-done .ots-status {
    color: #e11d48;
}

html.dark .ots-stage.is-done #timerDisplay,
html.dark .ots-stage.is-done .ots-status {
    color: #fb7185;
}

.ots-stage.is-done #timerProgress {
    background-color: #f43f5e;
}

@keyframes ots-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.0); }
    50% { box-shadow: 0 0 0 6px rgba(244, 63, 94, 0.25); }
}

@media (prefers-reduced-motion: reduce) {
    .ots-stage.is-done { animation: none; }
    #timerProgress { transition: none; }
}

/* Full screen: real Fullscreen API, or the fixed-overlay fallback (.is-pseudo-fs) */
.ots-stage.is-fullscreen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 0 !important;
    padding: 1.5rem;
    background: #ffffff !important;
}

html.dark .ots-stage.is-fullscreen {
    background: #09090b !important;
}

.ots-stage.is-pseudo-fs {
    position: fixed;
    inset: 0;
    z-index: 10050;
    height: 100vh;
    height: 100dvh;
}

.ots-stage.is-fullscreen > div:first-child {
    position: absolute;
    top: 1rem;
    left: 1.5rem;
    right: 1.5rem;
}

.ots-stage.is-fullscreen .ots-digits {
    font-size: min(24vw, 42vh);
}

.ots-stage.is-fullscreen .ots-digits--long {
    font-size: min(15vw, 34vh);
}

.ots-stage.is-fullscreen .ots-digits--sw {
    font-size: min(17vw, 36vh);
}

.ots-stage.is-fullscreen .ots-digits--sw.ots-digits--long {
    font-size: min(12vw, 30vh);
}

.ots-stage.is-fullscreen .ots-controls {
    max-width: 36rem;
    margin: 0 auto;
    width: 100%;
}

.ots-stage.is-fullscreen .ots-progress {
    max-width: 36rem;
    margin-left: auto;
    margin-right: auto;
}

.ots-stage.is-fullscreen .ots-hint {
    display: none;
}

/* Lap list */
.ots-lap-fast { color: #059669; }
.ots-lap-slow { color: #e11d48; }
html.dark .ots-lap-fast { color: #34d399; }
html.dark .ots-lap-slow { color: #fb7185; }

.ots-scroll::-webkit-scrollbar { width: 4px; }
.ots-scroll::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 9999px;
}

@media print {
    #ots-workspace button { display: none !important; }
}
