/* ==========================================================================
   OsmoTools : chronomètre ([osmova_chronometre]) et minuteur ([osmova_minuteur])
   Grand affichage en chiffres à chasse fixe, tours, anneau de progression, plein écran sombre.
   ========================================================================== */

.och {
    --och-noir: #0A0A0A;
    --och-gris: #6B6B6B;
    --och-gris-bg: #F6F7F9;
    --och-border: #E5E7EB;
    --och-blue: #0064FF;
    --och-blue-bg: color-mix(in srgb, var(--och-blue) 7%, white);
    --och-vert: #067647;
    --och-rouge: #B42318;
    --och-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    margin: 0 0 40px;
    padding: 28px;
    border: 1px solid var(--och-border);
    border-radius: 16px;
    background: #fff;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--och-noir);
}

.och *,
.och *::before,
.och *::after {
    box-sizing: border-box;
}

.och__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.och__badge {
    display: inline-block;
    margin: 0 0 12px;
    padding: 4px 10px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--och-blue) 10%, white);
    color: var(--och-blue);
    font: 700 11px/1.4 var(--och-mono);
    letter-spacing: .08em;
    text-transform: uppercase;
}

.och .och__title {
    margin: 0 0 8px;
    font-size: 1.5rem;
    line-height: 1.25;
}

.och__intro {
    margin: 0 0 20px;
    color: var(--och-gris);
}

.och :focus-visible {
    outline: 3px solid color-mix(in srgb, var(--och-blue) 45%, white);
    outline-offset: 2px;
}

/* Le thème impose sa police avec !important sur div, span, td… : les chiffres doivent rester
   à chasse fixe, sinon ils bougent à chaque centième. */
.och .och__badge,
.och .och__main,
.och .och__cs,
.och .och__lapnow,
.och .och__table td,
.och .och__table tbody th,
.och input[type="number"],
.och kbd {
    font-family: var(--och-mono) !important;
    font-variant-numeric: tabular-nums;
}

/* ---------- Écran ---------- */

.och__screen {
    margin: 0 0 20px;
    padding: 32px 20px 26px;
    border-radius: 14px;
    background: var(--och-gris-bg);
    text-align: center;
}

.och__display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    font-family: var(--och-mono);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    letter-spacing: -.02em;
    color: var(--och-noir);
}

.och__main {
    font-size: clamp(52px, 13vw, 112px);
}

.och__cs {
    margin-left: 2px;
    font-size: clamp(26px, 6vw, 52px);
    color: var(--och-gris);
}

.och__sub {
    margin: 14px 0 0;
    color: var(--och-gris);
    font-size: 14px;
    font-weight: 600;
}

.och__lapnow {
    margin-left: 6px;
    font-family: var(--och-mono);
    font-variant-numeric: tabular-nums;
    color: var(--och-noir);
}

.och.is-running .och__screen {
    background: var(--och-blue-bg);
}

/* ---------- Boutons ---------- */

.och__controls {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
    gap: 10px;
    margin: 0 0 8px;
}

.och__btn {
    min-height: 52px;
    padding: 12px 16px;
    border: 1px solid var(--och-border);
    border-radius: 12px;
    background: #fff;
    color: var(--och-noir);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}

.och__btn:hover:not(:disabled) {
    border-color: var(--och-noir);
}

.och__btn:active:not(:disabled) {
    transform: translateY(1px);
}

.och__btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.och__btn--main {
    border-color: var(--och-blue);
    background: var(--och-blue);
    color: #fff;
    font-size: 17px;
}

.och__btn--main:hover:not(:disabled) {
    border-color: #0050CC;
    background: #0050CC;
}

.och.is-running .och__btn--main {
    border-color: var(--och-noir);
    background: var(--och-noir);
}

.och__btn--ghost {
    border-color: var(--och-gris-bg);
    background: var(--och-gris-bg);
}

.och__btn--small {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 9px;
}

.och__status {
    min-height: 22px;
    margin: 0 0 12px;
    color: var(--och-gris);
    font-size: 14px;
}

.och__keys {
    margin: 16px 0 0;
    color: var(--och-gris);
    font-size: 13px;
}

.och kbd {
    display: inline-block;
    min-width: 22px;
    margin: 0 2px;
    padding: 1px 6px;
    border: 1px solid var(--och-border);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: #fff;
    font: 600 12px/1.5 var(--och-mono);
    text-align: center;
    color: var(--och-noir);
}

/* ---------- Tours (chronomètre) ---------- */

.och__laps {
    margin: 8px 0 0;
    border: 1px solid var(--och-border);
    border-radius: 12px;
    overflow: hidden;
}

.och__laps[hidden] {
    display: none;
}

.och__laps-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--och-border);
    background: var(--och-gris-bg);
}

.och__laps-title {
    margin: 0;
    font-weight: 700;
}

.och__laps-actions {
    display: flex;
    gap: 8px;
}

.och__table-wrap {
    max-height: 320px;
    overflow: auto;
}

.och__table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    font-size: 15px;
}

.och__table th,
.och__table td {
    padding: 10px 14px;
    border: 0;
    border-bottom: 1px solid var(--och-border);
    text-align: right;
    font-family: var(--och-mono);
    font-variant-numeric: tabular-nums;
}

.och__table thead th {
    position: sticky;
    top: 0;
    background: #fff;
    color: var(--och-gris);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.och__table th:first-child {
    text-align: left;
}

.och__table tbody tr:last-child th,
.och__table tbody tr:last-child td {
    border-bottom: 0;
}

.och__table tr.is-best th,
.och__table tr.is-best td {
    color: var(--och-vert);
    font-weight: 700;
}

.och__table tr.is-worst th,
.och__table tr.is-worst td {
    color: var(--och-rouge);
    font-weight: 700;
}

.och__legend {
    margin: 0;
    padding: 10px 14px;
    border-top: 1px solid var(--och-border);
    color: var(--och-gris);
    font-size: 12px;
}

.och__dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin: 0 4px 0 10px;
    border-radius: 50%;
    vertical-align: 0;
}

.och__dot:first-child {
    margin-left: 0;
}

.och__dot--best {
    background: var(--och-vert);
}

.och__dot--worst {
    background: var(--och-rouge);
}

/* ---------- Minuteur ---------- */

.och__presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 18px;
}

.och__chip {
    padding: 9px 14px;
    border: 1px solid var(--och-border);
    border-radius: 999px;
    background: #fff;
    color: var(--och-noir);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.och__chip:hover {
    border-color: var(--och-blue);
    color: var(--och-blue);
}

.och__chip.is-on {
    border-color: var(--och-blue);
    background: var(--och-blue-bg);
    color: var(--och-blue);
}

.och__screen--timer {
    padding: 24px 16px;
}

.och__ring-wrap {
    position: relative;
    width: min(100%, 340px);
    margin: 0 auto;
    aspect-ratio: 1;
}

.och__ring {
    display: block;
    width: 100%;
    height: 100%;
}

.och__ring-bg,
.och__ring-fg {
    fill: none;
    stroke-width: 9;
}

.och__ring-bg {
    stroke: var(--och-border);
}

.och__ring-fg {
    stroke: var(--och-blue);
    stroke-linecap: round;
    stroke-dasharray: 1000;
    stroke-dashoffset: 0;
}

.och__ring-in {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.och--timer .och__main {
    font-size: clamp(48px, 15vw, 84px);
}

.och--timer.is-long .och__main {
    font-size: clamp(38px, 11vw, 64px);
}

.och--timer .och__sub {
    margin-top: 10px;
}

.och.is-done .och__screen {
    background: color-mix(in srgb, var(--och-rouge) 9%, white);
}

.och.is-done .och__main {
    color: var(--och-rouge);
    animation: och-pulse 1s ease-in-out infinite;
}

.och.is-done .och__ring-fg {
    stroke: var(--och-rouge);
}

.och.is-done .och__btn--main {
    border-color: var(--och-rouge);
    background: var(--och-rouge);
}

@keyframes och-pulse {
    50% {
        opacity: .35;
    }
}

.och__set {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 14px;
    padding: 0;
    border: 0;
}

.och__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
}

.och input[type="number"],
.och select {
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--och-border);
    border-radius: 10px;
    background: #fff;
    color: var(--och-noir);
    font-family: var(--och-mono);
    font-size: 18px;
    font-weight: 600;
}

.och select {
    font-family: inherit;
    font-size: 15px;
}

.och input:disabled {
    background: var(--och-gris-bg);
    color: var(--och-gris);
}

.och__opts {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--och-border);
    border-radius: 12px;
}

.och__field--inline {
    flex: 1 1 160px;
}

.och__field--vol input {
    width: 100%;
    accent-color: var(--och-blue);
}

/* ---------- Plein écran (natif ou couche fixe sur iPhone) ---------- */

.och.is-full {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 0;
    padding: max(24px, env(safe-area-inset-top)) 5vw max(24px, env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    background: var(--och-noir);
    color: #fff;
    overflow: auto;
}

.och.is-full .och__badge,
.och.is-full .och__title,
.och.is-full .och__intro,
.och.is-full .och__keys,
.och.is-full .och__opts,
.och.is-full .och__set,
.och.is-full .och__presets,
.och.is-full .och__legend {
    display: none;
}

.och.is-full .och__screen,
.och.is-full.is-running .och__screen,
.och.is-full.is-done .och__screen {
    background: transparent;
}

.och.is-full .och__display,
.och.is-full .och__lapnow {
    color: #fff;
}

.och.is-full .och__main {
    font-size: clamp(72px, 19vw, 280px);
}

.och.is-full .och__cs {
    font-size: clamp(36px, 9vw, 130px);
    color: #9CA3AF;
}

.och.is-full .och__ring-wrap {
    width: min(78vh, 90vw);
}

.och--timer.is-full .och__main {
    font-size: clamp(56px, 13vmin, 200px);
}

.och.is-full .och__ring-bg {
    stroke: #262626;
}

.och.is-full.is-done .och__main {
    color: #FF6B5F;
}

.och.is-full .och__sub,
.och.is-full .och__status {
    color: #9CA3AF;
    text-align: center;
}

.och.is-full .och__controls {
    width: min(100%, 760px);
    margin: 0 auto 8px;
}

.och.is-full .och__btn {
    border-color: #333;
    background: #171717;
    color: #fff;
}

.och.is-full .och__btn--main {
    border-color: var(--och-blue);
    background: var(--och-blue);
}

.och.is-full .och__laps {
    width: min(100%, 760px);
    margin: 8px auto 0;
    border-color: #333;
}

.och.is-full .och__laps-head,
.och.is-full .och__table thead th {
    border-color: #333;
    background: #171717;
}

.och.is-full .och__table th,
.och.is-full .och__table td {
    border-color: #262626;
    color: #E5E7EB;
}

/* ---------- Hero et mobile ---------- */

.och--hero {
    margin-bottom: 0;
}

@media (max-width: 640px) {
    .och {
        padding: 20px 16px;
    }

    .och__screen {
        padding: 26px 10px 20px;
    }

    .och__controls {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .och__controls .och__btn:not(.och__btn--main) {
        min-height: 48px;
        padding: 8px 6px;
        font-size: 14px;
    }

    .och__controls .och__btn--main {
        grid-column: 1 / -1;
    }

    .och__set {
        gap: 8px;
    }

    .och__table th,
    .och__table td {
        padding: 9px 8px;
        font-size: 14px;
    }

    .och__keys {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .och__btn,
    .och__chip {
        transition: none;
    }

    .och.is-done .och__main {
        animation: none;
    }
}
