/* assets/css/game.css
   Spielseite außerhalb des HUDs: Canvas, Simulationsrahmen, Musik-Telemetrie. Das HUD steht in
   `hud.css`. Die frühere `:root`-Überschreibung globaler Tokens ist entfallen – sie galt auf der
   Spielseite für alle Elemente, auch für die Dialoge (Konzept 25, Kapitel 1.2). */

/* Seitengerüst des Spiels: fest auf Fenstergröße, ohne Scrollen. Menü und Spiel liegen in einem
   Dokument (docs/34_Spielstart_ohne_Seitenwechsel_Konzept.md, Kapitel 15); die Regeln gelten nur,
   solange das Spiel aktiv ist (`html.app-game`, AppShell). */
html.app-game,
html.app-game body {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

html.app-game body {
    margin: 0;
    padding: 0;
    /* Kurzform, damit das Hintergrundbild des Menüs (global.css) im Spiel wegfällt */
    background: var(--clr-canvas-bg);
}

/* Im Menü ist das Spiel nicht zu sehen; seine Dialoge sind dann geschlossen */
html.app-menu #game-root {
    display: none !important;
}

/* Kein Markieren von Text im Spiel: Ein Doppelklick oder Ziehen über HUD und Spielfeld markierte
   sonst Beschriftungen und Werte. Eingabefelder bleiben markierbar. Dialoge hängt jQuery UI beim
   Öffnen an `body`; sie sind davon nicht betroffen. */
html.app-game #game-root {
    user-select: none;
    -webkit-user-select: none;
}

html.app-game #game-root :is(input, textarea, [contenteditable="true"]) {
    user-select: text;
    -webkit-user-select: text;
}

#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

/* Touch-Gesten gehören auf dem Spielfeld der Kamera, nicht dem Browser: Ohne diese Regel
   scrollt oder zoomt die Seite, statt dass Pinch-to-Zoom die Karte skaliert (GDD 5.1).
   Außerhalb des Canvas bleibt der Seiten-Zoom unangetastet. */
#game-container canvas {
    touch-action: none;
}

/* Simulation Mode 2px Red Viewport Frame (nur im Spiel; im Menü desselben Dokuments nie) */
html.app-game body.simulation-mode #game-container {
    box-sizing: border-box;
    border: 2px solid var(--clr-status-danger);
}

html.app-game body.simulation-mode #game-container canvas {
    box-sizing: border-box;
    outline: 2px solid var(--clr-status-danger);
    outline-offset: -2px;
}

html.app-game body.simulation-mode::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    border: 2px solid var(--clr-status-danger);
    box-sizing: border-box;
    pointer-events: none;
    z-index: 999999;
}

/* ==========================================================================
   Music Telemetry Overlay (Top-Left)
   ========================================================================== */
.hud-music-overlay {
    position: absolute;
    /* Liegt das HUD oben bzw. links, rückt die Anzeige daneben (Offsets setzt HUDTopBar) */
    top: calc(1rem + var(--hud-offset-top, 0px));
    left: calc(1rem + var(--hud-offset-left, 0px));
    width: 19em;
    max-width: 90vw;
    z-index: 100;
    pointer-events: none;
    user-select: none;

    background: var(--clr-surface-main);
    backdrop-filter: blur(0.75em);
    -webkit-backdrop-filter: blur(0.75em);
    border: 1px solid var(--clr-surface-border);
    box-shadow: 0 0.35em 1.25em rgba(0, 0, 0, 0.35);
    padding: var(--pad-col);
    font-family: var(--font-regular);
    color: var(--clr-text-primary);
}

.hud-music-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5em;
    border-bottom: 1px solid var(--clr-border-light);
    padding-bottom: 0.35em;
    margin-bottom: 0.4em;
}

.hud-music-overlay-title {
    font-size: var(--fs-label);
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.4em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--clr-text-primary);
}

.hud-music-overlay-badge {
    font-size: 0.75em;
    padding: 0.15em 0.5em;
    background: var(--clr-surface-subcard);
    border: 1px solid var(--clr-border-light);
    color: var(--clr-text-muted);
    white-space: nowrap;
    font-family: var(--font-narrow);
}

.hud-music-overlay-meta {
    font-size: 0.8em;
    color: var(--clr-text-muted);
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5em;
    font-family: var(--font-narrow);
}

.hud-music-overlay-meta strong {
    color: var(--clr-primary-text);
}

.hud-music-overlay-stems {
    display: flex;
    flex-direction: column;
    gap: 0.4em;
}

.hud-music-stem-item {
    background: var(--clr-surface-subcard);
    border: 1px solid var(--clr-border-light);
    padding: 0.35em 0.5em;
    transition: opacity 0.2s ease, border-color 0.2s ease;
}

.hud-music-stem-item.muted {
    opacity: 0.65;
}

.hud-music-stem-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8em;
    margin-bottom: 0.25em;
}

.hud-music-stem-name {
    font-weight: bold;
    color: var(--clr-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 10em;
}

.hud-music-stem-time {
    font-family: var(--font-narrow);
    font-size: 0.95em;
    color: var(--clr-text-muted);
    letter-spacing: 0.03em;
}

.hud-music-stem-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.hud-music-stem-bar-bg {
    flex: 1;
    height: 0.45em;
    background: var(--clr-surface-dark);
    overflow: hidden;
    border: 1px solid var(--clr-border-light);
}

.hud-music-stem-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--clr-primary-main);
    transition: width 0.15s ease-out;
}

.hud-music-stem-item.muted .hud-music-stem-bar-fill {
    background: var(--clr-text-muted);
}

.hud-music-stem-vol {
    font-size: 0.75em;
    font-family: var(--font-narrow);
    width: 2.6em;
    text-align: right;
    color: var(--clr-text-primary);
    font-weight: bold;
}

.hud-music-stem-item.muted .hud-music-stem-vol {
    color: var(--clr-text-muted);
    font-weight: normal;
}

.hud-music-stem-status {
    font-size: 0.65em;
    font-weight: bold;
    padding: 0.1em 0.35em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.hud-music-stem-status.active {
    background: var(--clr-primary-subtle);
    color: var(--clr-primary-text);
}

.hud-music-stem-status.muted {
    background: var(--clr-surface-dark);
    color: var(--clr-text-muted);
}

/* Ergebnis-Dialog: Text der erreichten Bewertung (Markdown des Map-Autors,
   docs/41_Kampagnen_Achievements.md „Wertung"). Der Dialog hängt am `body`, deshalb die
   Modus-Klasse. */
html.app-game .hud-result-rating-text {
    margin: 0.25rem 0 0.5rem;
    padding: 0.4rem 0.6rem;
    background: var(--clr-surface-dark);
}

html.app-game .hud-result-rating-text p {
    margin: 0 0 0.4em;
}

html.app-game .hud-result-rating-text > :last-child {
    margin-bottom: 0;
}

/* Kampagnen-Teil des Ergebnis-Dialogs (docs/41_Kampagnen_Achievements.md „Ablauf"):
   Freischaltungen, Hinweis bei einer früheren Operation, Sieg- bzw. Niederlage-Nachricht */
html.app-game .hud-result-campaign-list {
    margin: 0.25rem 0 0.5rem;
    padding-left: 1.4em;
}

html.app-game .hud-result-campaign-note {
    margin: 0.5rem 0;
    padding: 0.4rem 0.6rem;
    background: var(--clr-primary-subtle);
    border-left: 0.2rem solid var(--clr-primary-main);
}

html.app-game .hud-result-campaign-message {
    margin: 0.5rem 0;
    padding: 0.4rem 0.6rem;
    border-left: 0.25rem solid var(--clr-status-success);
    background: var(--clr-surface-dark);
}

html.app-game .hud-result-campaign-message.is-lost {
    border-left-color: var(--clr-status-danger);
}

html.app-game .hud-result-campaign-message p {
    margin: 0 0 0.4em;
}

html.app-game .hud-result-campaign-message .hud-result-rating-text {
    padding: 0;
    background: none;
}

html.app-game .hud-result-campaign-audio {
    margin-top: 0.5rem;
}
