html,
body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html {
    overflow-x: hidden;
}

:root {
    color-scheme: light dark;
    --app-max-width: 52rem;

    /* Brand */
    --color-primary: #178133;      /* primary actions, links, active nav text */
    --color-primary-rgb: 23, 129, 51;
    --color-primary-dark: #116c29; /* hover/active state of the above */
    --color-primary-emphasis: #116c29; /* primary text on a surface */
    --color-primary-tint: #e8f5eb; /* active nav-link background */
    --color-primary-tint-weak: #f2f7f3; /* hover nav-link background */
    --color-focus-blue: #258cfb;   /* focus rings, hover accents */
    --color-focus-inner: #fff;
    --color-link-blue: #0071c1;       /* inline text links */
    --color-link-blue-dark: #005a9e;  /* link hover/active */
    --color-code: #c02d76;

    /* Text */
    --color-ink: #111827;   /* headings / strongest text */
    --color-ink-strong: #1a1a1a; /* near-black text (consolidates #111/#212529/#222/#252525/#333/#343a40) */
    --color-text: #1f2937;  /* body copy, nav-link text */
    --color-muted: #6b7280; /* muted labels, helper text, secondary meta */

    /* Surfaces & lines */
    --color-surface: #fff;
    --color-border: #e5e7eb;     /* standard hairline border */
    --color-border-strong: #d0d5dd; /* higher-contrast border (consolidates #ced4da/#dee2e6/#d6d8da) */
    --color-surface-alt: #f4f7f5; /* user-card / tinted panel background */
    --color-surface-muted: #f1f3f5; /* muted light-gray panel/hover background */
    --color-overlay-hover: rgba(0, 0, 0, 0.04);
    --color-border-hover: #b7bec7;
    --color-loading-track: #e0e0e0;
    --color-backdrop: rgba(15, 23, 42, 0.42);
    --color-backdrop-strong: rgba(15, 23, 42, 0.52);

    /* Feedback */
    --color-danger: #b42318;      /* destructive text (logout, delete) */
    --color-danger-tint: #fff1f0; /* destructive hover background */
    --color-alert-danger-border: #f0b4b4;
    --color-alert-danger-bg: #fff2f2;
    --color-alert-danger-text: #9b1c1c;
    --color-alert-success-border: #abd8b6;
    --color-alert-success-bg: #f0faf2;
    --color-alert-success-text: #166534;
    --color-alert-warning-border: #e3c65b;
    --color-alert-warning-bg: #fff8d8;
    --color-alert-warning-text: #6b4f00;

    /* Elevation & glass surfaces */
    --color-shadow-soft: rgba(0, 0, 0, 0.12);
    --color-shadow-strong: rgba(0, 0, 0, 0.18);
    --shadow-card: 0 0.2rem 0.8rem rgba(0, 0, 0, 0.05);
    --shadow-floating: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.22);
    --surface-glass: rgba(255, 255, 255, 0.96);

    /* Layering */
    --z-sticky: 10;
    --z-map-marker: 20;
    --z-map-center-marker: 21;
    --z-map-user-location-marker: 22;
    --z-map-control: 23;
    --z-map-filter-backdrop: 29;
    --z-map-search: 30;
    --z-map-popup: 31;
    --z-map-filter-menu: 32;
    --z-map-action: 35;
    --z-map-loading: 40;
    --z-overlay-backdrop: 900;
    --z-overlay: 950;
    --z-editor-backdrop: 960;
    --z-editor: 970;
    --z-header: 1000;
    --z-floating-action: 1035;
    --z-nav-backdrop: 1090;
    --z-nav: 1100;
    --z-toast: 2000;
}

:root[data-bs-theme="dark"] {
    color-scheme: dark;

    /* Keep the brand/action colors unchanged; adapt their surrounding UI. */
    --color-primary-emphasis: #73d38c;
    --color-primary-tint: #173820;
    --color-primary-tint-weak: #15291b;
    --color-focus-inner: #111512;
    --color-link-blue: #78b9ff;
    --color-link-blue-dark: #a8d2ff;
    --color-code: #ef8fbd;

    --color-ink: #f8fafc;
    --color-ink-strong: #f1f5f9;
    --color-text: #dbe3dd;
    --color-muted: #a3aca5;

    --color-surface: #111512;
    --color-border: #2d352f;
    --color-border-strong: #465048;
    --color-border-hover: #657168;
    --color-surface-alt: #182019;
    --color-surface-muted: #0c100d;
    --color-overlay-hover: rgba(255, 255, 255, 0.06);
    --color-backdrop: rgba(0, 0, 0, 0.58);
    --color-backdrop-strong: rgba(0, 0, 0, 0.68);
    --color-loading-track: #39413b;

    --color-danger-tint: #321815;
    --color-alert-danger-border: #743b38;
    --color-alert-danger-bg: #2b1715;
    --color-alert-danger-text: #ffaaa3;
    --color-alert-success-border: #356442;
    --color-alert-success-bg: #14291a;
    --color-alert-success-text: #8ee3a5;
    --color-alert-warning-border: #76631f;
    --color-alert-warning-bg: #2a2410;
    --color-alert-warning-text: #f1d775;

    --color-shadow-soft: rgba(0, 0, 0, 0.32);
    --color-shadow-strong: rgba(0, 0, 0, 0.5);
    --shadow-card: 0 0.2rem 0.8rem rgba(0, 0, 0, 0.24);
    --shadow-floating: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.52);
    --surface-glass: rgba(17, 21, 18, 0.96);
}

html,
body,
#app {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--color-surface-muted);
    overflow-x: hidden;
}

h1:focus {
    outline: none;
}

/* Bootstrap / app basics */

a {
    color: var(--color-link-blue);
}

.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--color-primary);
    --bs-btn-border-color: var(--color-primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--color-primary-dark);
    --bs-btn-hover-border-color: var(--color-primary-dark);
    --bs-btn-focus-shadow-rgb: var(--color-primary-rgb);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--color-primary-dark);
    --bs-btn-active-border-color: var(--color-primary-dark);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--color-primary);
    --bs-btn-disabled-border-color: var(--color-primary);
}

[data-bs-theme="dark"] .btn-dark {
    --bs-btn-color: #111512;
    --bs-btn-bg: #f8fafc;
    --bs-btn-border-color: #f8fafc;
    --bs-btn-hover-color: #111512;
    --bs-btn-hover-bg: #dbe3dd;
    --bs-btn-hover-border-color: #dbe3dd;
    --bs-btn-focus-shadow-rgb: 248, 250, 252;
    --bs-btn-active-color: #111512;
    --bs-btn-active-bg: #c5cec7;
    --bs-btn-active-border-color: #c5cec7;
}

.btn:focus,
.btn:active:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.1rem var(--color-focus-inner), 0 0 0 0.25rem var(--color-focus-blue);
}

code {
    color: var(--color-code);
}

/* Shared UI primitives */

.app-button {
    flex: 0 0 auto;
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0 1.1rem;
    border: 1px solid transparent;
    border-radius: 0.75rem;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.app-button:hover {
    text-decoration: none;
}

.app-button:focus-visible {
    outline: 2px solid var(--color-focus-blue);
    outline-offset: 2px;
}

.app-button:disabled,
.app-button[aria-disabled="true"] {
    opacity: 0.65;
    cursor: not-allowed;
}

.app-button svg {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
}

.app-button--primary {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: #fff;
}

.app-button--primary:hover {
    border-color: var(--color-primary-dark);
    background: var(--color-primary-dark);
    color: #fff;
}

.app-button--secondary {
    border-color: var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
}

.app-button--secondary:hover {
    border-color: var(--color-border-hover);
    background: var(--color-surface-muted);
    color: var(--color-text);
}

.app-button--outline-primary {
    border-width: 2px;
    border-color: var(--color-primary);
    background: var(--color-surface);
    color: var(--color-primary-emphasis);
}

.app-button--outline-primary:hover {
    background: var(--color-primary-tint-weak);
    color: var(--color-primary-emphasis);
}

.app-button--block {
    width: 100%;
}

.app-button--large {
    min-height: 3.75rem;
    font-size: 1rem;
}

.ui-icon-button {
    --icon-button-size: 2.5rem;
    --icon-size: 1.4rem;
    width: var(--icon-button-size);
    height: var(--icon-button-size);
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--color-ink);
    cursor: pointer;
}

.ui-icon-button:hover {
    background: var(--icon-button-hover-bg, var(--color-surface-muted));
}

.ui-icon-button:focus-visible {
    outline: 2px solid var(--color-focus-blue);
    outline-offset: 2px;
}

.ui-icon-button svg {
    display: block;
    width: var(--icon-size);
    height: var(--icon-size);
}

.surface-card {
    border: 1px solid var(--surface-card-border, var(--color-border));
    border-radius: var(--surface-card-radius, 1rem);
    background: var(--surface-card-background, var(--color-surface));
    box-shadow: var(--surface-card-shadow, var(--shadow-card));
}

.app-shell-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--color-ink);
    font-size: 1.2rem;
    font-weight: 700;
}

.app-shell-brand-logo {
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 0.4rem;
    object-fit: cover;
}

.sv-brand-logo {
    --sv-primary: #161616;
    --sv-secondary: #c2c3c1;
    color-scheme: only light;
}

[data-bs-theme="dark"] .sv-brand-logo {
    --sv-primary: #f8fafc;
    --sv-secondary: #9ca3af;
}

.app-shell-user {
    padding: 0.9rem;
    border-radius: 0.75rem;
    background: var(--color-surface-alt);
}

.app-shell-user-label {
    margin-bottom: 0.15rem;
    color: var(--color-muted);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.app-shell-user-name {
    overflow: hidden;
    color: var(--color-ink);
    font-size: 0.93rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-shell-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.app-shell-nav a {
    min-height: var(--shell-nav-item-height, 2.9rem);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: var(--shell-nav-item-padding, 0.65rem) 0.9rem;
    border-radius: 0.7rem;
    color: var(--color-text);
    font-weight: 600;
    text-decoration: none;
}

.app-shell-nav a:hover {
    background: var(--color-primary-tint-weak);
    color: var(--color-primary-emphasis);
}

.app-shell-nav a.active {
    background: var(--color-primary-tint);
    color: var(--color-primary-emphasis);
}

.app-shell-nav a svg {
    width: var(--shell-nav-icon-size, 1.35rem);
    height: var(--shell-nav-icon-size, 1.35rem);
    flex: 0 0 var(--shell-nav-icon-size, 1.35rem);
}

.app-shell-spacer {
    flex: 1;
}

.app-shell-logout {
    min-height: var(--shell-nav-item-height, 2.9rem);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    padding: var(--shell-nav-item-padding, 0.65rem) 0.9rem;
    border: 0;
    border-radius: 0.7rem;
    background: transparent;
    color: var(--color-danger);
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.app-shell-logout:hover {
    background: var(--color-danger-tint);
}

.app-shell-logout svg {
    width: var(--shell-nav-icon-size, 1.35rem);
    height: var(--shell-nav-icon-size, 1.35rem);
}

/* Blazor error UI */

#blazor-error-ui {
    color-scheme: light only;
    position: fixed;
    bottom: 0;
    left: 0;
    display: none;
    width: 100%;
    box-sizing: border-box;
    padding: 0.6rem 1.25rem 0.7rem;
    background: lightyellow;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    z-index: var(--z-header);
}

    #blazor-error-ui .dismiss {
        position: absolute;
        top: 0.5rem;
        right: 0.75rem;
        cursor: pointer;
    }

.blazor-error-boundary {
    padding: 1rem;
    background: #b32121;
    color: white;
}

    .blazor-error-boundary::after {
        content: "Ein Fehler ist aufgetreten.";
    }

/* Blazor startup progress */

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto;
    margin: 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: var(--color-loading-track);
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: var(--color-primary);
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    font-weight: bold;
    text-align: center;
}

    .loading-progress-text::after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

/* Validation */

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid var(--color-danger);
}

.validation-message {
    color: var(--color-danger);
}

/* Shared map styles */

/*
 * Used by FestivalMap (under MainLayout) and LocationPicker (under
 * AdminLayout). Kept global because CSS isolation can't share a rule
 * between components in different layout trees.
 */
.maplibregl-marker {
    color-scheme: light;
}

:root[data-bs-theme="dark"] .maplibregl-marker {
    color-scheme: dark;
}

/*
 * Pin artwork supports both page schemes, but intentionally uses the same
 * fixed palette in each one.
 */
img[src*="/images/pins/"],
img[src^="images/pins/"],
img[src*="/pins/"] {
    color-scheme: light;
    forced-color-adjust: none;
}

:root[data-bs-theme="dark"] img[src*="/images/pins/"],
:root[data-bs-theme="dark"] img[src^="images/pins/"],
:root[data-bs-theme="dark"] img[src*="/pins/"] {
    color-scheme: dark;
}

.spot-location-marker {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: var(--z-map-marker);
    width: 2.75rem;
    height: 3.75rem;
    color: var(--color-primary);
    pointer-events: none;
    transform: translate(-50%, -100%);
    filter: drop-shadow(0 0.2rem 0.2rem rgba(0, 0, 0, 0.35));
}

    .spot-location-marker svg {
        display: block;
        width: 100%;
        height: 100%;
    }

.festival-center-marker {
    z-index: var(--z-map-center-marker);
    pointer-events: none;
}

.user-location-marker {
    z-index: var(--z-map-user-location-marker);
}

/*
 * Keep this global because MapLibre creates the popup DOM dynamically.
 */
.maplibregl-popup {
    z-index: var(--z-map-popup);
}

.festival-spot-popup-host {
    width: min(15rem, calc(100vw - 1rem));
    max-width: 15rem;
}

.festival-spot-popup-host .maplibregl-popup-content {
    overflow: visible;
    padding: 0;
    border: 1px solid var(--color-border-strong);
    border-radius: 1rem;
    background: var(--color-surface);
    box-shadow: var(--shadow-floating);
}

.festival-spot-popup-host .maplibregl-popup-close-button {
    z-index: 2;
    top: 0.7rem;
    right: 0.7rem;
    display: grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--color-text);
    font-size: 1.35rem;
    line-height: 1;
}

.festival-spot-popup-host .maplibregl-popup-close-button:hover {
    background: var(--color-surface-muted);
}

.festival-spot-popup-host .maplibregl-popup-close-button:focus-visible {
    outline: 2px solid var(--color-focus-blue);
    outline-offset: 2px;
}

.festival-spot-popup-host.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.festival-spot-popup-host.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.festival-spot-popup-host.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
    border-top-color: var(--color-surface);
}

.festival-spot-popup-host.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.festival-spot-popup-host.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.festival-spot-popup-host.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
    border-bottom-color: var(--color-surface);
}

.festival-spot-popup-host.maplibregl-popup-anchor-left .maplibregl-popup-tip {
    border-right-color: var(--color-surface);
}

.festival-spot-popup-host.maplibregl-popup-anchor-right .maplibregl-popup-tip {
    border-left-color: var(--color-surface);
}

.festival-spot-popup {
    width: 100%;
}

.pin-popup-header {
    display: grid;
    gap: 0.3rem;
    padding: 1rem 3.5rem 0.75rem 1rem;
}

.pin-popup-eyebrow {
    color: var(--color-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.2;
    text-transform: uppercase;
}

.pin-popup-title {
    min-width: 0;
    color: var(--color-ink);
    font-size: 1.08rem;
    line-height: 1.3;
}

.pin-popup-body {
    padding: 0 1rem 1rem;
}

.pin-popup-description {
    color: var(--color-text);
    font-size: 0.9rem;
    line-height: 1.4;
}

.pin-popup-actions {
    position: relative;
    flex: 0 0 auto;
}

.pin-popup-actions-toggle {
    display: inline-grid;
    width: 2.25rem;
    height: 2.25rem;
    place-items: center;
    padding: 0;
    border: 1px solid var(--color-border-strong);
    border-radius: 0.65rem;
    background: var(--color-surface);
    color: var(--color-text);
}

.pin-popup-actions-toggle:hover,
.pin-popup-actions-toggle[aria-expanded="true"] {
    background: var(--color-surface-muted);
}

.pin-popup-actions-toggle:focus-visible,
.pin-popup-action:focus-visible,
.pin-popup-confirm-button:focus-visible {
    outline: 2px solid var(--color-focus-blue);
    outline-offset: 2px;
}

.pin-popup-actions-toggle svg {
    width: 1.1rem;
    height: 1.1rem;
}

.pin-popup-action-menu {
    position: absolute;
    z-index: 3;
    bottom: calc(100% + 0.35rem);
    right: 0;
    min-width: 10.5rem;
    padding: 0.25rem;
    border: 1px solid var(--color-border-strong);
    border-radius: 0.65rem;
    background: var(--color-surface);
    box-shadow: var(--shadow-floating);
}

.pin-popup-action {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    border: 0;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--color-text);
    font: inherit;
    font-size: 0.85rem;
    text-align: left;
    white-space: nowrap;
}

.pin-popup-action:hover {
    background: var(--color-surface-muted);
}

.pin-popup-action--danger {
    color: var(--color-danger);
}

.pin-popup-action--danger:hover {
    background: var(--color-danger-tint);
}

.pin-popup-action-icon {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
}

.pin-popup-delete-confirmation {
    padding: 0.8rem 1rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-danger-tint);
}

.pin-popup-delete-confirmation p {
    margin: 0;
    color: var(--color-text);
    font-size: 0.82rem;
    line-height: 1.4;
}

.pin-popup-delete-confirmation strong {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--color-ink);
}

.pin-popup-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
    margin-top: 0.65rem;
}

.pin-popup-confirm-button {
    min-height: 2rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--color-border-strong);
    border-radius: 0.45rem;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
}

.pin-popup-confirm-button:hover {
    background: var(--color-surface-muted);
}

.pin-popup-confirm-button--danger {
    border-color: var(--color-danger);
    background: var(--color-danger);
    color: #fff;
}

.pin-popup-confirm-button--danger:hover {
    background: #8f1c13;
}

.pin-popup-confirm-button:disabled {
    opacity: 0.65;
    cursor: wait;
}

.pin-popup-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 4rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border);
}

.pin-popup-author {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 0.55rem;
}

.pin-popup-author-icon {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    color: var(--color-muted);
}

.pin-popup-author-text {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    gap: 0.15rem 0.35rem;
    color: var(--color-muted);
    font-size: 0.75rem;
    line-height: 1.3;
}

@media (max-width: 767.98px) {
    .festival-spot-popup-host {
        top: auto !important;
        right: 0.75rem !important;
        bottom: calc(0.75rem + env(safe-area-inset-bottom)) !important;
        left: 0.75rem !important;
        width: auto;
        max-width: none;
        transform: none !important;
    }

    .festival-spot-popup-host .maplibregl-popup-content {
        width: 100%;
        max-height: min(55dvh, 26rem);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .festival-spot-popup-host .maplibregl-popup-tip {
        display: none;
    }

    .map-page:has(.festival-spot-popup-host) .map-add-spot-button,
    .admin-festival-map:has(.festival-spot-popup-host) .admin-map-actions,
    .map-wrapper:has(.festival-spot-popup-host) .map-festival-home-button,
    .map-wrapper:has(.festival-spot-popup-host) .map-locate-button {
        display: none;
    }
}

@media (max-width: 380px) {
    .pin-popup-author-text {
        display: grid;
        gap: 0;
    }

    .pin-popup-author-text > [aria-hidden="true"] {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
