/*
 * style.css
 * -----------------------------------------------------------------------
 * Farben, Abstände und Strukturen sind aus den .qml-Dateien übernommen.
 * Wo das Original eine Schriftart "Caroni" referenziert (FontLoader auf
 * qrc:/fonts/fonts/Caroni-Regular.ttf), wird hier mangels dieser Schrift-
 * datei eine Web-Fallback-Schriftfamilie genutzt (--bq-font-handwritten).
 * Die echte Schriftdatei kann unter fonts/caroni-regular.ttf (klein
 * geschrieben!) nachgereicht werden, siehe README.
 *
 * Der 25px-Hintergrundraster (main.qml: backgroundGrid, Rectangle-Repeater,
 * "property real size: 25") wird hier aus Performance-Gründen als
 * CSS-Hintergrundmuster statt vieler einzelner DOM-Elemente erzeugt -
 * optisch identisch (gleiche Zellgröße, gleiche Farbe "lightblue"), aber
 * deutlich günstiger im Browser.
 * -----------------------------------------------------------------------
 */

@font-face {
    font-family: "Caroni";
    /* Sobald die echte Schriftdatei hier abgelegt wird (Dateiname exakt
       "caroni-regular.ttf", klein geschrieben), verwendet die Seite
       automatisch die Original-Handschrift für alle Variablen, Zahlen
       und Vorzeichen. Das Multiplikationszeichen ist davon ausgenommen,
       siehe Hinweis bei .bq-mul-dot weiter unten. */
    src: url("../fonts/caroni-regular.ttf") format("truetype");
    font-display: swap;
}

:root {
    --bq-font-handwritten: "Caroni", "Segoe Print", "Comic Sans MS", cursive, sans-serif;
    --bq-grid-size: 25px;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    color: #000;
    overflow: hidden;
}

#bqBackgroundGrid {
    position: fixed;
    inset: 0;
    z-index: -2;
    /* Hinweis (Fehlerbehebung): 0.5px-Linien werden in echten Browsern je
       nach Gerätepixelverhältnis so stark weggerundet/wegeditiert, dass sie
       praktisch unsichtbar werden - anders als Qts eigene Anti-Aliasing-
       Linien (border.width: 0.5 in main.qml). Volle 1px-Linien rendern
       zuverlässig in jedem Browser. */
    background-image:
        linear-gradient(to right, lightblue 1px, transparent 1px),
        linear-gradient(to bottom, lightblue 1px, transparent 1px);
    background-size: var(--bq-grid-size) var(--bq-grid-size);
    background-color: #fff;
}

/* Vorschlag (siehe README): groß, aber sehr dezent (geringe Deckkraft),
   in einer Ecke, "pointer-events: none" -> kann NIE Klicks abfangen und
   liegt zudem unter jeglichem Inhalt (z-index -1), blockiert also auch
   visuell nichts Interaktives. */
#bqLogoWatermark {
    position: fixed;
    right: -40px;
    bottom: -40px;
    width: 380px;
    height: 380px;
    z-index: -1;
    background-image: url("../icons/icon-256.png");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.12;
    pointer-events: none;
}
@media (max-width: 600px) {
    #bqLogoWatermark { width: 220px; height: 220px; }
}

#bqApp {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
}

#bqScrollArea {
    flex: 1 1 auto;
    overflow: auto;
    padding: 20px;
    box-sizing: border-box;
}

#bqStepsColumn {
    display: flex;
    flex-direction: column;
    gap: 40px;
    width: fit-content;
}

#bqStepRepeaterRect {
    background: rgba(255, 255, 255, 0.4); /* "#66ffffff" */
    padding: 10px 5px;
    width: fit-content;
}

#bqStepRepeater {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.bq-equation {
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--bq-font-handwritten);
    position: relative;
    padding-right: 60px; /* Platz für den "?"-Knopf */
}

/* Hinweis (Fehlerbehebung): Diese Klasse fehlte komplett in der vorherigen
   Fassung. Ohne sie ist ein <span> ein normales "inline"-Element, dessen
   Kinder nach der Standard-Baseline ausgerichtet werden statt nach der
   Mitte - das war die tatsächliche Ursache dafür, dass bei den 4
   Antwortmöglichkeiten das Gleichheitszeichen und die kürzere Seite nicht
   zur Mitte der höheren Seite ausgerichtet waren. */
.bq-equation-inline {
    display: inline-flex;
    align-items: center;
    gap: 14px;
}

.bq-equals {
    font-size: 25px;
    font-weight: bold;
    color: #000;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.bq-el {
    display: inline-flex;
    align-items: center;
}

.bq-variable, .bq-constant {
    font-family: var(--bq-font-handwritten);
    font-size: 25px;
    line-height: 1;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
}
.bq-variable { font-weight: bold; color: blue; }
.bq-constant { color: #000; }

.bq-addmulsub { align-items: center; gap: 4px; }
.bq-operator-sign {
    font-size: 25px;
    line-height: 1;
    color: blue;
    padding: 0 2px;
    font-family: var(--bq-font-handwritten);
    display: inline-flex;
    align-items: center;
}
/* Hinweis (zwingend nötige Anpassung, siehe README): Das Original nutzt
   für die Multiplikation einen Zeichencode, an dem NUR die (fehlende)
   Caroni-Schriftdatei selbst einen Punkt-Glyph hinterlegt (Kommentar im
   Original: "bigger than QChar(183)", also größer als der normale
   Mittelpunkt "·"). Dieser Trick funktioniert in Browsern grundsätzlich
   nicht: Steuerzeichen-Codepunkte werden von der Text-Engine generell
   nicht angezeigt - auch nicht, wenn die echte Schriftdatei vorliegt.
   Deshalb wird hier unabhängig von der Schriftdatei immer ein echter,
   sichtbarer großer Punkt ("•") verwendet, der optisch genau dem
   Original-Kommentar entspricht. */
.bq-mul-dot { font-size: 30px; font-weight: bold; }

.bq-div { flex-direction: column; }
.bq-div-top, .bq-div-bottom { display: flex; justify-content: center; }
.bq-div-line { height: 2px; background: blue; width: 100%; margin: 2px 0; }

.bq-root { align-items: center; gap: 2px; }
.bq-root-graphic { position: relative; display: inline-flex; align-items: flex-end; }
.bq-root-degree { position: absolute; top: -10px; left: -2px; font-size: 11px; line-height: 1; color: blue; }
.bq-root-svg { display: block; }
.bq-root-content { border-top: 2px solid blue; padding: 0 3px; display: inline-flex; align-items: center; }

.bq-pow { flex-direction: row; align-items: flex-end; position: relative; }
.bq-pow-base { display: inline-flex; align-items: flex-end; }
.bq-pow-exp { display: inline-flex; align-items: flex-start; transform: translateY(-0.6em); }

/* Hinweis (Fehlerbehebung): Höhe wird NICHT mehr fix per CSS (1.6em)
   vorgegeben, sondern von render.js nach dem Einfügen anhand der
   tatsächlichen Höhe des eingeklammerten Inhalts gesetzt (style.height/
   style.width). Eine feste Höhe hätte bei eingeklammerten Brüchen zu
   einer falschen (zu kurzen) Klammer geführt - genau der von dir
   beschriebene Effekt, dass Brüche die Höhe/Ausrichtung verschieben. */
.bq-brackets { align-items: center; }
.bq-bracket { height: 1.6em; flex: none; }

.bq-question-button {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid red;
    background: rgba(255, 255, 178, 0.5);
    color: red;
    font-weight: bold;
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.8s cubic-bezier(.34, 1.56, .64, 1);
}
.bq-question-button-pop { transform: translateY(-50%) scale(1) !important; }

@keyframes bq-pulse {
    0%, 100% { transform: scale(0.8); }
    50% { transform: scale(1.2); }
}
.bq-pulse { animation: bq-pulse 0.8s infinite; }

/* ChoiceOfFour / ChoiceButton */
#bqChoiceOfFour {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bq-choice-button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 10px 18px;
    border: 1px solid #bbb;
    border-radius: 8px;
    background: #e9e9e9;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 1px 2px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    font-family: var(--bq-font-handwritten);
    width: fit-content;
    min-height: 0;
    transition: height 0.15s, background 0.15s;
}
.bq-choice-button:hover { background: #ddd; }
.bq-choice-button[hidden] { display: none; }

.bq-choice-circle {
    margin-left: auto;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #fff;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
}
.bq-choice-circle.bq-correct { background: #fff; color: green; font-size: 22px; }
.bq-choice-circle.bq-wrong { background: red; color: #fff; font-family: "Times New Roman", serif; font-weight: bold; font-size: 15px; }
.bq-choice-circle.bq-wrong-pulse { animation: bq-circle-pulse 0.8s 5; }
@keyframes bq-circle-pulse {
    0% { transform: scale(0.7); }
    100% { transform: scale(1.0); }
}

#bqTopRightButtons {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 5;
}
.bq-textbutton {
    font-family: var(--bq-font-handwritten);
    font-size: 16px;
    padding: 6px 14px;
    border: 1px solid #999;
    border-radius: 4px;
    background: #eee;
    cursor: pointer;
}

.bq-language-switcher {
    font-size: 14px;
    padding: 5px 8px;
    border: 1px solid #999;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}

#bqLine { height: 1px; background: blue; width: 100%; flex: none; }

#bqBottomRect {
    flex: none;
    height: 65px;
    background: #fafafa;
    display: flex;
    align-items: center;
    padding: 0 15px;
    box-sizing: border-box;
    justify-content: space-between;
}
#bqButtonRow { display: flex; align-items: center; gap: 10px; height: 100%; }

.bq-new-button {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: lawngreen;
    border: none;
    font-family: var(--bq-font-handwritten);
    font-size: 15px;
    cursor: pointer;
}

.bq-stat-column { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 70px; }
.bq-stat-label { font-size: 12px; text-align: center; }
.bq-stat-number { font-size: 16px; font-weight: bold; text-align: center; padding: 1px 6px; border-radius: 3px; }

#bqColorsColumn { display: none; flex-direction: column; height: 100%; width: 22px; }
#bqColorsColumn.bq-visible { display: flex; }
.bq-color-swatch { flex: 1; }

.bq-difficulty-combo {
    font-family: var(--bq-font-handwritten);
    font-size: 14px;
    height: 36px;
    border-radius: 4px;
    border: 1px solid #999;
}

#bqSolvedLayer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
}
.bq-confetti-canvas {
    position: absolute;
    top: 0;
    left: 0;
}

/* Dialoge */
dialog.bq-dialog {
    border: 1px solid #999;
    border-radius: 6px;
    padding: 16px;
    max-width: 90vw;
    max-height: 85vh;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}
dialog.bq-dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.bq-about-dialog { width: 600px; }
.bq-equationinfo-dialog { width: 500px; }
.bq-dialog-scroll { overflow: auto; max-height: 60vh; }
.bq-dialog-scroll h3, .bq-dialog-scroll h4 { margin-top: 1.2em; }
.bq-dialog-footer { margin-top: 12px; text-align: right; }
.bq-dialog-footer button { padding: 6px 18px; }

.bq-guide-dialog { width: 420px; }
.bq-guide-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    font-size: 13px;
    color: #444;
    cursor: pointer;
}
.bq-guide-checkbox-row input { cursor: pointer; }
