/*
 * Timer – Feld in Tinte. Links die Anzeige (Restzeit, Balken, Skala), rechts die Bedienung (330 px).
 * Gesperrt: nur die Anzeige über die ganze Breite. Unter 900 px oder hochkant: alles untereinander.
 */

.timer {
    min-height: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(240px, 30vw, 330px);
    gap: clamp(20px, 3vw, 36px);
    padding: clamp(16px, 4.9vh, 40px) clamp(16px, 3.4vw, 40px) clamp(16px, 4.4vh, 36px) clamp(20px, 4.7vw, 56px);
}

/* Einblenden nur für Anzeige und Bedienung – Schloss und „Fertig“ bleiben am Bildschirm fest */
.timer__anzeige, .timer__bedienung { animation: inhalt-einblenden .38s ease-out .08s backwards; }

/* ---------- Anzeige ---------- */

.timer__anzeige {
    container-type: inline-size;        /* Ziffern richten sich nach der Breite der Anzeige */
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.timer__beschriftung { font-size: 22px; font-weight: 700; color: var(--tinte-leise); }
.timer__rest {
    margin: 6px 0 clamp(14px, 4.1vh, 34px);
    font-family: var(--schrift-titel);
    font-size: clamp(44px, min(36cqi, 26vh), 200px);   /* „30:00“ ist etwa 2,7-mal so breit wie hoch */
    font-weight: 700;
    line-height: .9;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    transition: color .6s ease;
}

/* Balken: Spur mit Innenschatten, Füllung von links (Breite setzt skript.js pro Bild) */
.timer__balken {
    position: relative;
    height: clamp(56px, 13.4vh, 110px);
    border-radius: 55px;
    background: var(--tinte-knopf);
    overflow: hidden;
    box-shadow: inset 0 4px 10px rgba(0, 0, 0, .35);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.timer.ist-ziehbar .timer__balken { cursor: ew-resize; }
.timer__fuellung {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    border-radius: 55px;
    background: var(--balken-fuellung);
    box-shadow: var(--glanz-knopf);
    transition: background .6s ease;
}

.timer__skala {
    display: flex;
    justify-content: space-between;
    padding: 12px 18px 0;
    font-family: var(--schrift-titel);
    font-size: 18px;
    font-weight: 600;
    color: var(--tinte-leise);
    font-variant-numeric: tabular-nums;
}
.timer__skala span { white-space: nowrap; }

/* Vorwarnung: ruhig auf Türkis, ohne Blinken */
.timer.ist-vorwarnung .timer__fuellung { background: linear-gradient(#6CC3D2, #49AEC0 45%, #3794A6); }
.timer.ist-vorwarnung .timer__rest { color: var(--tuerkis); }

/* ---------- Bedienung ---------- */

.timer__bedienung {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.timer__haupt { flex: none; height: clamp(56px, 10.7vh, 88px); font-size: clamp(22px, 3.4vh, 28px); gap: 12px; }
.timer__haupt .knopf__symbol { width: 26px; height: 26px; }
/* Symbol im Hauptknopf: ❚❚ beim Laufen, ▶ in der Pause */
.timer__haupt-pause, .timer__haupt-weiter { display: inline-flex; }
.timer.ist-pause .timer__haupt-pause,
.timer:not(.ist-pause) .timer__haupt-weiter { display: none; }

.timer__minuten {
    display: grid;
    grid-template-columns: 60px minmax(0, 1fr) 60px;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}
.timer__plusminus { height: clamp(48px, 7.3vh, 60px); padding: 0; font-size: 28px; }
.timer__plusminus:active { transform: scale(.9); }
.timer__minuten-wert { text-align: center; font-family: var(--schrift-titel); font-size: 40px; font-weight: 700; line-height: 1; }
.timer__einheit { font-size: 22px; color: var(--tinte-leise); }

.timer__chips { display: flex; flex-wrap: wrap; gap: 4px; }
.timer__chip {
    flex: 1;
    min-width: 44px;                    /* groß genug für einen Finger – sonst lieber zwei Reihen */
    height: 48px;
    border: 0;
    border-radius: var(--radius-voll);
    background: transparent;
    color: var(--tinte-leise-2);
    font-family: var(--schrift-titel);
    font-size: 19px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .45s var(--feder), background-color .25s;
}
.timer__chip:active { transform: scale(.88); }
.timer__chip.ist-gewaehlt { background: var(--creme); color: var(--tinte); }

.timer__nebenknoepfe { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.timer__nebenknoepfe .knopf { height: 60px; padding: 0 8px; font-size: 20px; }

.timer__unten { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.timer__unten .knopf { height: clamp(48px, 6.8vh, 56px); padding: 0 10px; }
.timer__unten .knopf__symbol { width: 20px; height: 20px; }

/* Einstellungen (ersetzen die Bedienung, die Anzeige bleibt) */
.timer__einstellungen { gap: 0; overflow-y: auto; }
.timer__einstellungen-kopf { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.timer__einstellungen-kopf h2 { font-family: var(--schrift-titel); font-size: 28px; font-weight: 700; }
.timer__einstellungen-kopf .knopf { height: 52px; padding: 0 24px; font-size: 19px; }
.timer__zeile { border-top: 1px solid var(--tinte-knopf); padding: 10px 0; font-size: 18px; font-weight: 700; }
.timer__zeile--regler { padding: 12px 0; }
.timer__zeile-kopf { display: flex; justify-content: space-between; gap: 12px; }
.timer__wert { color: var(--orange); }
.timer.skala-ist-zeit [data-wert-skala] { color: var(--tinte-leise); text-decoration: line-through; }
.timer .kaestchen { font-size: 16px; color: var(--tinte-leise-2); }

/* ---------- Gesperrt ---------- */

body.ist-gesperrt .timer { grid-template-columns: minmax(0, 1fr); }
body.ist-gesperrt .timer__bedienung { display: none !important; }

.timer__schloss {
    position: fixed;
    z-index: 5;
    right: 48px;
    bottom: 48px;
    width: 108px;
    height: 108px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--petrol-tief);
    color: var(--creme);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .35);
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
.timer__schloss-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.timer__schloss-ring circle {
    fill: none;
    stroke: var(--tuerkis);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 1 1;
    stroke-dashoffset: 1;
    transition: stroke-dashoffset .25s ease-out;       /* Loslassen: Ring läuft zurück */
}
.timer__schloss.haelt .timer__schloss-ring circle { stroke-dashoffset: 0; transition: stroke-dashoffset 3s linear; }
.timer__schloss-symbol { width: 30px; height: 30px; }
.timer__schloss-text { font-family: var(--schrift-titel); font-size: 13px; font-weight: 700; }

/* ---------- Fertig: vier Streifen, Band quer darüber ---------- */

.timer__ende {
    position: fixed;
    z-index: 20;
    inset: 0;
    overflow: hidden;
    background: var(--petrol);
    color: var(--creme);
    cursor: pointer;
}
.timer__ende-streifen { position: absolute; inset: 0; display: flex; justify-content: center; }
.timer__ende-streifen span {
    width: 10.6vw;
    height: 100%;
    transform-origin: top;
    animation: ende-streifen .62s var(--gleiten) backwards;
}
.timer__ende-streifen span:nth-child(2) { animation-delay: .09s; }
.timer__ende-streifen span:nth-child(3) { animation-delay: .18s; }
.timer__ende-streifen span:nth-child(4) { animation-delay: .27s; }
@keyframes ende-streifen {
    from { transform: scaleY(0); }
}

.timer__ende-band {
    position: absolute;
    left: 0;
    right: 0;
    top: 30.5%;
    height: 39%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--band-waagerecht);
    box-shadow: 0 24px 48px rgba(0, 20, 30, .4), inset 0 3px 0 rgba(255, 255, 255, .2);
    animation: ende-band .9s var(--gleiten) .32s backwards;
}
@keyframes ende-band {
    from { transform: translateX(-105%); }
}
.timer__ende-text {
    display: flex;
    align-items: center;
    gap: 3vmin;
    font-family: var(--schrift-titel);
    font-size: clamp(72px, 20vmin, 170px);
    font-weight: 800;
    line-height: 1;
    animation: ende-text .52s ease-out .9s backwards;
}
@keyframes ende-text {
    from { opacity: 0; transform: translateX(-40px); }
}
.timer__ende-haken {
    width: .88em;
    height: .88em;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--creme);
    color: var(--tinte);
}
.timer__ende-haken svg { width: 64%; height: 64%; }
.timer__ende-hinweis { position: absolute; left: 0; right: 0; bottom: 56px; text-align: center; font-size: 22px; font-weight: 700; }
.timer__ende-hinweis span { display: inline-block; padding: 10px 22px; border-radius: 24px; background: var(--petrol-tief); }

/* Solange „Fertig“ zu sehen ist, liegt nichts darüber */
body.hat-ueberlagerung .leiste { visibility: hidden; }

/* ---------- Schmal oder hochkant: untereinander ---------- */

@media (max-width: 599px), (orientation: portrait) {
    .timer { grid-template-columns: minmax(0, 1fr); padding: 28px 24px; gap: 28px; }
    .timer__balken { height: 88px; }
    .timer__unten { margin-top: 10px; }
}
@media (max-width: 720px) {
    .timer { padding: 20px 16px; }
    .timer__skala { font-size: 15px; padding: 10px 8px 0; }
    .timer__schloss { right: 24px; bottom: 24px; }
}
