/* ===================================================================
   EINE MILLION — schwarze Bühne, Sterne auf einem Canvas
   =================================================================== */

/* Dunkle Seite → Titel + Ein-/Ausklapp-Pfeil weiß (globaler Opt-in, s. ui.js). */
:root { --header-title-color: #fff; }

html,
body {
    background: #000;
}

.mio-stage {
    position: relative;
    z-index: 1;
    width: 100%;
    height: var(--stage-height);
    overflow: hidden;
    /* durchsichtig + klick-durchlässig: darunter liegt das Sternen-Canvas;
       nur Zahl/Knöpfe sitzen davor */
    pointer-events: none;
}

.mio-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none; /* zwei Finger = Lupe, nicht Browser-Zoom */
}
.mio-canvas.mio-zoomed {
    cursor: grab;
}
.mio-canvas.mio-zoomed:active {
    cursor: grabbing;
}

/* Die Anzahl oben mittig — groß, Zahlenschrift, gegliedert „1 000 000".
   Sie liegt ÜBER den Sternen (die nutzen die ganze Bühne) → dunkler Hof
   als Kontrast statt eigener Fläche. */
.mio-count {
    /* fixed statt absolute: die Bühne schneidet ab (overflow:hidden) — so
       kann die Zahl beim Einklappen der Leiste über die Bühne hinaus nach oben. */
    position: fixed;
    top: calc(var(--header-height) + clamp(4px, 1.5vh, 16px));
    left: 50%;
    /* Wandert mit der Kopfzeile (gleiche .25s ease wie .header) — über
       `translate`, nicht `transform`, das gehört der Pop-Animation. */
    transition: translate 0.25s ease;
    transform: translateX(-50%);
    font-family: var(--math-font, sans-serif);
    font-weight: 900;
    font-size: clamp(32px, min(9vw, 11vh), 110px);
    line-height: 1;
    color: #fff;
    white-space: nowrap;
    pointer-events: none;
    z-index: 2;
    text-shadow:
        0 0 4px #000,
        0 0 10px #000,
        0 0 22px rgba(0, 0, 0, 0.9);
}
/* Leiste eingeklappt (Vollbild/Pfeil) → die Zahl rückt mit nach oben — aber
   nur bis knapp UNTER den Ein-/Ausklapp-Pfeil (#fs-header-toggle, eingeklappt
   oben mittig, 40px hoch) plus kleinem Abstand, sonst läge der Pfeil auf ihr. */
html.header-collapsed .mio-count {
    translate: 0 calc(40px + 8px - var(--header-height) - clamp(4px, 1.5vh, 16px));
}
.mio-count.mio-pop {
    animation: mio-pop 0.6s ease;
}
@keyframes mio-pop {
    0%   { transform: translateX(-50%) scale(1); }
    40%  { transform: translateX(-50%) scale(1.18); color: var(--mio-pop-color, #ffd23f); }
    100% { transform: translateX(-50%) scale(1); }
}

/* Rechts an der Seite: ▲ / ▼ untereinander, vertikal mittig. */
.mio-controls {
    --mio-btn: clamp(52px, min(11vw, 14vh), 96px);
    position: absolute;
    right: clamp(8px, 2vw, 24px);
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: calc(var(--mio-btn) * 0.35);
    z-index: 2;
    pointer-events: auto;
}

.mio-btn {
    width: var(--mio-btn);
    height: var(--mio-btn);
    padding: 0;
    border: 3px solid rgba(255, 255, 255, 0.55);
    border-radius: 18px;
    /* liegt über den Sternen → dunkle, halbdurchsichtige Fläche */
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, opacity 0.2s ease, background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.mio-btn:active:not(:disabled) {
    transform: scale(0.94);
    background: rgba(255, 255, 255, 0.18);
}
.mio-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

/* Das Dreieck selbst (kein Emoji): eine Fläche per clip-path. */
.mio-tri {
    width: 56%;
    height: 48%;
    background: #ffd23f;
}
.mio-up .mio-tri {
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
    margin-bottom: 6%;
}
.mio-down .mio-tri {
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    margin-top: 6%;
    background: #fff;
}

/* Anordnung „Quadrate": weißer Grund → Titel, Zahl und Knöpfe dunkel
   (Klasse setzt ui-million-numbers.js). */
html.mio-squares {
    --header-title-color: #1d3557;
    --mio-pop-color: #e09b00;
}
html.mio-squares,
html.mio-squares body {
    background: #fff;
}
html.mio-squares .mio-count {
    color: #1d3557;
    text-shadow:
        0 0 4px #fff,
        0 0 10px #fff;
}
html.mio-squares .mio-btn {
    border-color: rgba(29, 53, 87, 0.35);
    background: rgba(255, 255, 255, 0.85);
}
html.mio-squares .mio-btn:active:not(:disabled) {
    background: rgba(29, 53, 87, 0.12);
}
html.mio-squares .mio-up .mio-tri {
    background: #f0b400;
}
html.mio-squares .mio-down .mio-tri {
    background: #1d3557;
}

/* ---- Farbeimer (Seiten-Knopf #mio-paint, Optik global .side-btn) ---- */
.mio-bucket {
    width: 78%;
    height: 78%;
}
#mio-paint:disabled {
    opacity: 0.35;
    cursor: default;
}

/* Auswahl der früheren Anzahlen: rechts neben dem Eimer (Lage setzt JS),
   bricht auf schmalen Schirmen in Zeilen um (max-width aus JS). */
.mio-pick {
    position: fixed;
    z-index: 500;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.72);
    border: 2px solid rgba(255, 255, 255, 0.35);
}
.mio-pick[hidden] {
    display: none;
}
.mio-pick-btn {
    min-width: var(--side-btn-size);
    height: var(--side-btn-size);
    padding: 0 10px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.55);
    background: transparent;
    color: #fff;
    font-family: var(--math-font, sans-serif);
    font-weight: 800;
    font-size: calc(var(--side-btn-size) * 0.42);
    white-space: nowrap;
    cursor: pointer;
}
.mio-pick-btn.is-on {
    background: #ffd23f;
    border-color: #ffd23f;
    color: #1d1d1d;
}
html.mio-squares .mio-pick {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(29, 53, 87, 0.25);
}
html.mio-squares .mio-pick-btn {
    color: #1d3557;
    border-color: rgba(29, 53, 87, 0.35);
}
html.mio-squares .mio-pick-btn.is-on {
    color: #1d1d1d;
    border-color: #f0b400;
}

/* Pfeil auf einen winzigen gelben Block: Ursprung = Pfeilspitze, Lage +
   Drehung setzt JS. Über der Kopfzeile (die Sterne liegen auch darunter),
   aber weg, sobald ein Kopfzeilen-Menü offen ist. */
.mio-arrow {
    --mio-arrow-len: clamp(56px, 12vmin, 110px);
    position: fixed;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    z-index: 1001;
    pointer-events: none;
    transform-origin: 0 0;
}
.mio-arrow[hidden],
html.header-menu-open .mio-arrow {
    display: none;
}
.mio-arrow-bob {
    position: absolute;
    right: 0;
    top: calc(var(--mio-arrow-len) * -0.22);
    width: var(--mio-arrow-len);
    height: calc(var(--mio-arrow-len) * 0.44);
    animation: mio-arrow-bob 0.8s ease-in-out infinite alternate;
}
.mio-arrow-bob svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}
.mio-arrow-bob path {
    fill: #ffd23f;
    stroke: #000;
    stroke-width: 3;
    stroke-linejoin: round;
}
@keyframes mio-arrow-bob {
    from { transform: translateX(-12px); }
    to   { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .mio-count.mio-pop { animation: none; }
    .mio-count { transition: none; }
    .mio-arrow-bob { animation: none; }
}
