@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap');

/* Roboto Mono Bold (SIL OFL), lokal eingebunden fuer die Fahrtwerte im Fahrmodus. */
@font-face {
    font-family: "Roboto Mono";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/RobotoMono-Bold.ttf") format("truetype");
}

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

html,
body {
    margin: 0;
    padding: 0;
}

/* Kein rechteckiges (blaues) Tap-Highlight der WebView - es ignoriert border-radius und sieht auf
   Pillen-/Rund-Buttons falsch aus. Die Rueckmeldung beim Druecken kommt aus der :active-Regel unten.
   Die Eigenschaft wird vererbt und gilt damit fuer alle Elemente. */
html {
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
}

.mt-app-shell {
    /* Gleiche maximale Breite fuer alle Seiten wie die Tourenuebersicht (42rem, mittig). */
    max-width: 42rem;
    min-height: 100dvh;
    margin: 0 auto;
    background: var(--bg);
    color: var(--text);
}

/* Fahrmodus nutzt die volle Breite (Querformat mit Raster und Bedienspalte). */
.mt-app-shell:has(.mt-voice-ride-mode) {
    max-width: none;
}

/* Handy im Querformat (gleiche Schwelle wie das Querformat-Raster des Sprachraums): immer die volle Breite, ohne
   Abhaengigkeit von :has(). */
@media (orientation: landscape) and (max-height: 500px) {
    .mt-app-shell {
        max-width: none;
    }
}

.mt-page {
    padding: clamp(16px, 4vw, 32px);
    /* Kamera-Aussparung/abgerundete Ecken im Querformat (viewport-fit=cover in App.razor) */
    padding-left: max(clamp(16px, 4vw, 32px), env(safe-area-inset-left, 0px));
    padding-right: max(clamp(16px, 4vw, 32px), env(safe-area-inset-right, 0px));
}

/* Inhaltsbereich eines Home-Tabs bzw. einer einzelnen Seite (Einstellungen, Fehler). Der
   Aussenabstand kommt von .mt-page; hier nur sicherstellen, dass lange Inhalte nicht ueberlaufen. */
.mt-home-section {
    width: 100%;
    min-width: 0;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover,
a:focus-visible {
    color: var(--accent-hover);
}

button,
input {
    font-family: inherit;
}

/* Buttons ------------------------------------------------------------- */

.mt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-pill);
    font-family: var(--font-family);
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.08s ease, filter 0.08s ease;
}

.mt-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Druck-Rueckmeldung fuer alle Buttons: leicht eindruecken und abdunkeln, folgt jeder Form. Ueber
   :where() ohne Spezifitaet, damit eigene :active-Regeln der Komponenten Vorrang haben. Halten-Buttons
   (Signale/Verlassen) bleiben aussen vor - dort zeigt nur die Fuellung den Timer. */
:where(button, a.mt-btn, [role="button"]):where(:not(:disabled, [data-hold-action], [data-hold-leave])):active {
    transform: scale(0.97);
    filter: brightness(0.92);
}

@media (prefers-reduced-motion: reduce) {
    :where(button, a.mt-btn, [role="button"]):active {
        transform: none;
    }
}

.mt-btn-primary {
    background: var(--accent);
    color: var(--accent-text);
}

.mt-btn-primary:hover:not(:disabled),
.mt-btn-primary:focus-visible {
    background: var(--accent-hover);
}

.mt-btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.mt-btn-secondary:hover:not(:disabled),
.mt-btn-secondary:focus-visible {
    background: rgba(240, 194, 100, 0.12);
}

.mt-btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.mt-btn-danger:hover:not(:disabled),
.mt-btn-danger:focus-visible {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.mt-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

/* Icon-only Buttons: rund, feste Groesse, sichtbarer Text nur noch als title-Tooltip. */
.mt-btn-icon {
    flex: 0 0 auto;
    align-self: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
}

.mt-btn-icon .mt-icon {
    width: 22px;
    height: 22px;
}

/* Touch-Aequivalent zu title-Tooltips, siehe wwwroot/js/touch-tooltip.js. */
.mt-touch-tooltip {
    position: fixed;
    z-index: 2000;
    transform: translate(-50%, calc(-100% - 10px));
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: var(--bg);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
}

.mt-touch-tooltip-visible {
    opacity: 1;
}

/* Bestätigungsdialog (z.B. Tour löschen/verlassen) --------------------- */

.mt-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.mt-confirm-card {
    width: 100%;
    max-width: 480px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.mt-confirm-card h2 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 1.25rem;
    color: var(--text);
}

.mt-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Formulare ------------------------------------------------------------ */

.mt-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
}

.mt-field input,
.mt-field textarea,
.mt-input {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-family);
    /* 16px verhindert den automatischen Zoom von iOS Safari beim Fokussieren */
    font-size: 16px;
}

.mt-field textarea {
    resize: vertical;
    min-height: 88px;
}

.mt-field input:focus-visible,
.mt-field textarea:focus-visible,
.mt-input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.mt-error,
.mt-form-error {
    font-size: 13px;
    font-weight: 700;
    color: var(--danger);
}

/* Blockvariante fuer Lade-/Aktionsfehler in Listen, Detailansichten und Dialogen */
.mt-form-error {
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.mt-error-request-id {
    color: var(--text-soft);
    font-size: 13px;
}

/* Login/Registrieren ---------------------------------------------------- */

.mt-login-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: clamp(24px, 6vh, 48px);
    min-height: 100dvh;
    padding: 24px 20px;
    background: radial-gradient(circle at 50% 0%, var(--surface) 0%, var(--bg) 60%);
}

.mt-login-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.mt-login-logo {
    width: min(220px, 55vw);
    height: auto;
}

.mt-login-helmet {
    width: min(180px, 45vw);
    height: auto;
    border-radius: var(--radius);
    margin-top: 4px;
}

.mt-tagline {
    color: var(--text-muted);
    font-size: 14px;
}

.mt-login-content,
.mt-login-actions {
    width: min(100%, 360px);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mt-login-content form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mt-login-switch {
    text-align: center;
    font-size: 13.5px;
    color: var(--text-muted);
}

.mt-login-version {
    text-align: center;
    font-size: 12px;
    color: var(--text-soft);
}

/* Handys im Querformat: niedrige Viewport-Hoehe - Marke und Formular/Aktionen
   nebeneinander statt untereinander, damit nichts abgeschnitten wird/gescrollt werden muss. */
@media (orientation: landscape) and (max-height: 500px) {
    .mt-page {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .mt-confirm-card {
        padding: 16px 20px;
    }

    .mt-confirm-card h2 {
        margin-bottom: 8px;
    }

    .mt-confirm-actions {
        margin-top: 14px;
    }

    .mt-login-page {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: clamp(24px, 5vw, 64px);
        padding: 16px clamp(16px, 5vw, 48px);
    }

    .mt-login-helmet {
        display: none;
    }

    .mt-login-content form {
        gap: 10px;
    }
}

/* Leaflet-Marker der Tankstellen-Navigation (Sprachraum-Karte, wwwroot/js/map.js). Die Marker
   werden von Leaflet ausserhalb der Blazor-Komponente erzeugt, daher hier global statt in
   Voice.razor.css. */
.mt-map-station-marker,
.mt-map-waypoint-marker,
.mt-map-destination-marker {
    display: grid;
    place-items: center;
    border: 3px solid var(--accent-text);
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-text);
    font-family: var(--font-family);
    font-weight: 900;
    box-shadow: var(--shadow-card);
}

.mt-map-station-marker {
    font-size: 20px;
}

.mt-map-destination-marker {
    font-size: 24px;
}

.mt-map-waypoint-marker {
    font-size: 18px;
}

/* Heading-up der Live-Karte (wwwroot/js/map.js setBearing): Leaflet sitzt im Drehkoerper .mt-map-rotator. Er ist quadratisch mit
   der Diagonale des Ausschnitts (.mt-map-viewport) als Seitenlaenge (Groesse setzt map.js), liegt mittig und dreht um
   --mt-map-rotation, damit beim Drehen keine leeren Ecken entstehen. Der Uebergang dauert so lange wie das Mindestintervall der
   Drehungen (MapHeadingFilter.MinUpdateInterval) und laeuft linear, dann wirkt die Drehung fliessend; ohne Bewegung
   (prefers-reduced-motion) springt sie. .mt-map-heading-up setzt map.js mit der ersten Drehung. */
.mt-map-viewport {
    --mt-map-turn-duration: 0.75s;
    position: relative;
    overflow: hidden;
}

.mt-map-rotator {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(var(--mt-map-rotation, 0deg));
    transition: transform var(--mt-map-turn-duration) linear;
}

/* Erste Ausrichtung ohne Uebergang. */
.mt-map-no-transition,
.mt-map-no-transition * {
    transition: none !important;
}

/* Marker und Beschriftungen richten sich gegen die Drehung der Karte wieder auf (gleiche Dauer und Kurve wie der Drehkoerper,
   dadurch heben sich beide Drehungen in jedem Moment auf). */
.mt-map-upright {
    display: grid;
    place-items: center;
    transform: rotate(calc(-1 * var(--mt-map-rotation, 0deg)));
    transition: transform var(--mt-map-turn-duration) linear;
}

/* Eigene Position: blaue Scheibe mit weissem Rand, bei gedrehter Karte mit Pfeil nach oben (Fahrtrichtung). */
.mt-map-self-dot {
    width: 26px;
    height: 26px;
    box-sizing: border-box;
    border: 3px solid #fff;
    border-radius: 50%;
    background: #2563eb;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.mt-map-self-arrow {
    display: none;
    width: 14px;
    height: 14px;
    fill: #fff;
}

.mt-map-heading-up .mt-map-self-arrow {
    display: block;
}

/* Nordpfeil oben links (nur bei gedrehter Karte): das "N" zeigt dorthin, wo Norden liegt. Er ueberdeckt nichts und nimmt keine
   Beruehrung an. */
.mt-map-compass {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 450;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.mt-map-compass-needle {
    display: grid;
    justify-items: center;
    align-content: center;
    width: 100%;
    height: 100%;
    color: var(--danger);
    font-family: var(--font-family);
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
    transform: rotate(var(--mt-map-rotation, 0deg));
    transition: transform var(--mt-map-turn-duration) linear;
}

.mt-map-compass-needle::before {
    content: "";
    width: 0;
    height: 0;
    margin-top: 2px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 7px solid currentColor;
}

@media (prefers-reduced-motion: reduce) {
    .mt-map-rotator,
    .mt-map-upright,
    .mt-map-compass-needle {
        transition: none;
    }
}

/* Glaseffekt fuer alle Overlays ueber der Karte im Fahrmodus (Anweisungsleiste, Manoever/Tempo-Karte, Manoever-Symbol): halbtransparente
   Flaeche, Unschaerfe mit staerkerer Saettigung des Hintergrunds, feine helle Kante, gleicher Radius. --mt-glass-bg steht den
   Elementen fuer abgeleitete Hintergruende (z. B. Betonung) zur Verfuegung. */
:root {
    --mt-glass-opacity: 55%;
    --mt-glass-blur: 8px;
    --mt-glass-saturation: 1.6;
}

.mt-glass {
    --mt-glass-bg: color-mix(in srgb, var(--surface) var(--mt-glass-opacity), transparent);
    background: var(--mt-glass-bg);
    -webkit-backdrop-filter: blur(var(--mt-glass-blur)) saturate(var(--mt-glass-saturation));
    backdrop-filter: blur(var(--mt-glass-blur)) saturate(var(--mt-glass-saturation));
    border: 1px solid color-mix(in srgb, #fff 28%, transparent);
    border-radius: var(--radius);
}
