/*
 * IDAL-Design: warmes Orange auf Weiß, leicht abgerundete Buttons und Karten.
 * Bootstrap wird nur über seine CSS-Variablen angepasst.
 */

:root {
    --idal-orange: #ea580c;        /* Hauptfarbe für Flächen, Buttons, Linien, große Schrift */
    --idal-orange-dark: #c2410c;   /* Hover/aktiv */
    --idal-orange-text: #c2410c;   /* Orange für kleinen Text auf Weiß (4,5:1) */
    --idal-orange-light: #f97316;  /* Button-Fläche */
    --idal-orange-lighter: #fb923c; /* Hover der Buttons */
    --idal-on-orange: #1c1410;     /* Schrift auf orangen Flächen */
    --idal-orange-soft: #fff1e6;   /* Flächen-Tönung */
    --idal-line: #f3c9a8;          /* dünne Linien */
    --idal-text: #2b211c;          /* warmes Fast-Schwarz */
    --idal-muted: #6b5a50;         /* Nebentext, warm statt grau */
    --idal-danger: #b91c1c;        /* Warnungen, z. B. Push aus (4,5:1 auf Weiß) */
    --idal-shadow: 0 6px 20px rgba(120, 53, 15, 0.10), 0 1px 3px rgba(120, 53, 15, 0.08);

    --bs-body-font-family: 'Poppins', system-ui, -apple-system, sans-serif;
    --bs-body-color: var(--idal-text);
    --bs-secondary-color: var(--idal-muted);
    --bs-link-color: var(--idal-orange-text);
    --bs-link-color-rgb: 194, 65, 12;
    --bs-link-hover-color: #9a3412;
    --bs-link-hover-color-rgb: 154, 52, 18;
    --bs-primary: var(--idal-orange);
    --bs-primary-rgb: 234, 88, 12;
    --bs-border-radius: 0.5rem;
    --bs-focus-ring-color: rgba(234, 88, 12, 0.35);
}

::selection {
    background: #fed7aa;
    color: var(--idal-text);
}

body {
    accent-color: var(--idal-orange);
    caret-color: var(--idal-orange);
}

a {
    text-underline-offset: 0.2em;
}

h1, h2, h3, .h1, .h2, .h3, .h4 {
    font-weight: 600;
    text-wrap: balance;
}

/* Buchstabenabstand nach Größe: große Schrift enger, kleine leicht weiter.
   Die Klasse (.h3) gewinnt gegen das Element (h1), also zählt die sichtbare Größe. */
h1, .h1 {
    letter-spacing: -0.025em;
    line-height: 1.15;
}

h2, .h2 {
    letter-spacing: -0.02em;
    line-height: 1.2;
}

h3, .h3 {
    letter-spacing: -0.015em;
    line-height: 1.25;
}

h4, .h4, h5, .h5 {
    letter-spacing: -0.01em;
    line-height: 1.3;
}

small, .small, .form-text {
    letter-spacing: 0.01em;
}

.badge {
    letter-spacing: 0.02em;
}

/* Gleich breite Ziffern, damit Zähler und Ergebnisse nicht springen */
.badge, .table, .pagination {
    font-variant-numeric: tabular-nums;
}

/* Rückmeldung schon beim Drücken, nicht erst beim Loslassen */
.btn, .nav-link, .dropdown-item, .page-link, .list-group-item-action, .bottom-nav a {
    touch-action: manipulation;
}

/* Buttons in hellem Orange */
.btn {
    --bs-btn-border-radius: 0.5rem;
    --bs-btn-font-weight: 600;
    --bs-btn-padding-x: 1.4rem;
}

.btn-sm {
    --bs-btn-padding-x: 0.9rem;
}

.btn {
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out,
        box-shadow 0.15s ease-in-out, transform 100ms ease-out;
}

.btn:active {
    transform: scale(0.97);
}

.list-group-item-action {
    transition: background-color 0.15s ease-in-out, transform 100ms ease-out;
}

.list-group-item-action:active {
    transform: scale(0.99);
}

/* Flex-Kind darf schrumpfen, damit lange Titel umbrechen statt die Zeile zu sprengen */
.min-w-0 {
    min-width: 0;
}

.btn-primary {
    /* Dunkle Schrift auf hellem Orange, Weiß hätte zu wenig Kontrast */
    --bs-btn-color: var(--idal-on-orange);
    --bs-btn-bg: var(--idal-orange-light);
    --bs-btn-border-color: var(--idal-orange-light);
    --bs-btn-hover-color: var(--idal-on-orange);
    --bs-btn-hover-bg: var(--idal-orange-lighter);
    --bs-btn-hover-border-color: var(--idal-orange-lighter);
    --bs-btn-active-color: var(--idal-on-orange);
    --bs-btn-active-bg: var(--idal-orange-lighter);
    --bs-btn-active-border-color: var(--idal-orange-lighter);
    --bs-btn-disabled-color: var(--idal-on-orange);
    --bs-btn-disabled-bg: var(--idal-orange-light);
    --bs-btn-disabled-border-color: var(--idal-orange-light);
}

.btn-outline-primary {
    --bs-btn-color: var(--idal-orange-text);
    --bs-btn-border-color: var(--idal-orange-light);
    --bs-btn-hover-color: var(--idal-on-orange);
    --bs-btn-hover-bg: var(--idal-orange-light);
    --bs-btn-hover-border-color: var(--idal-orange-light);
    --bs-btn-active-color: var(--idal-on-orange);
    --bs-btn-active-bg: var(--idal-orange-lighter);
    --bs-btn-active-border-color: var(--idal-orange-lighter);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--idal-orange);
    box-shadow: 0 0 0 0.25rem var(--bs-focus-ring-color);
}

:focus-visible {
    outline: 2px solid var(--idal-orange);
    outline-offset: 2px;
}

/* Kopfzeile mit Wortmarke und dünner orangefarbener Linie */
.site-header {
    border-bottom: 2px solid var(--idal-line);
    background: #fff;
}

.wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--idal-orange);
    font-weight: 700;
    font-size: clamp(1.15rem, 1rem + 1vw, 1.6rem);
    letter-spacing: -0.02em;
    text-decoration: none;
}

.wordmark img {
    width: clamp(2.75rem, 2rem + 2vw, 3.5rem);
    height: auto;
}

.wordmark:hover {
    color: var(--idal-orange-dark);
}

.site-nav a:not(.btn) {
    color: var(--idal-text);
    font-weight: 500;
    text-decoration: none;
}

.site-nav a:not(.btn):hover {
    color: var(--idal-orange-text);
}

/* Interne Navigation (Bootstrap-Navbar): durchscheinende Leiste, der Inhalt scrollt darunter durch */
.navbar.site-header {
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(234, 88, 12, 0.18);
}

.navbar.site-header .navbar-brand {
    color: var(--idal-orange);
    font-weight: 700;
}

.navbar .nav-link.active {
    color: var(--idal-orange-text);
}

main {
    padding-top: 2rem;
    padding-bottom: 3rem;
}

/* Listen: Der Kopf sitzt direkt unter der oberen Leiste und springt beim Scrollen nicht erst hoch. */
main:has(.list-header) {
    padding-top: 0;
}

main:has(.list-header) > .alert:first-child {
    margin-top: 1rem;
}

/* Mindestens so hoch wie das Fenster, damit der Footer unten sitzt. dvh statt vh: 100vh ist auf dem Handy
   höher als der sichtbare Bereich (Adressleiste), sonst wäre jede Seite ein Stück scrollbar. */
body {
    min-height: 100vh;
    min-height: 100dvh;
}

/* Startseite: helles Banner statt Illustration */
.hero {
    background: var(--idal-orange-soft);
    border: 1px solid var(--idal-line);
    color: var(--idal-text);
    border-radius: 1rem;
    padding: clamp(2.5rem, 6vw, 5rem) clamp(1.5rem, 5vw, 4rem);
    text-align: center;
    box-shadow: var(--idal-shadow);
}

.hero-logo {
    display: block;
    width: clamp(7rem, 5rem + 8vw, 11rem);
    height: auto;
    margin: 0 auto 1.5rem;
}

.hero h1 {
    font-size: clamp(2rem, 1.4rem + 3vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: 1rem;
}

.hero p {
    max-width: 44rem;
    margin: 0 auto 2rem;
    font-size: 1.1rem;
    color: var(--idal-muted);
}

.hero .btn {
    --bs-btn-padding-y: 0.75rem;
    --bs-btn-padding-x: 2rem;
    --bs-btn-font-size: 1.1rem;
}

.section {
    margin-top: clamp(3rem, 6vw, 4.5rem);
}

.section h2 {
    margin-bottom: 1.25rem;
}

.prose {
    max-width: 68ch;
}

/* Impressum und Datenschutz: Überschriften aus dem Editor wie im ursprünglichen Layout */
.legal-text h2 {
    font-size: 1.25rem;
    margin-top: 1.5rem;
}

.legal-text h3 {
    font-size: 1.1rem;
    margin-top: 1.25rem;
}

.legal-text > :first-child {
    margin-top: 0;
}

.rich-text-editor {
    max-width: 68ch;
    background: #fff;
}

.rich-text-editor .ql-editor {
    min-height: 24rem;
    font-family: inherit;
    font-size: 1rem;
}

/* Karten: weich, gerundet, mit Schatten */
.soft-card {
    background: #fff;
    border-radius: 0.875rem;
    box-shadow: var(--idal-shadow);
    padding: 1.5rem;
    height: 100%;
}

.soft-card h3 {
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}

.soft-card p {
    color: var(--idal-muted);
    margin-bottom: 0;
}

/* Kontaktkarte: Zeilen mit dünner Trennlinie */
.contact-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
}

.contact-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--idal-line);
}

.contact-list li:last-child {
    border-bottom: 0;
}

.contact-list .label {
    color: var(--idal-orange-text);
    font-weight: 600;
    margin-right: 0.35rem;
}

.feature-list {
    padding-left: 1.2rem;
}

.feature-list li {
    margin-bottom: 0.75rem;
}

.feature-list li::marker {
    color: var(--idal-orange);
}

.closing {
    color: var(--idal-orange-text);
    font-weight: 600;
    font-size: 1.15rem;
}

/* Login-Karte */
.auth-card {
    max-width: 26rem;
    margin: 1rem auto 0;
}

/* Fußzeile mit orangefarbener Linie */
.site-footer {
    border-top: 2px solid var(--idal-orange);
    margin-top: 4rem;
    padding: 1.25rem 0;
    font-size: 0.9rem;
}

.site-footer a {
    color: var(--idal-text);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--idal-orange-text);
    text-decoration: underline;
}

/* Postfach: ungelesene Nachrichten hervorheben */
.inbox-table tr.is-unread td {
    font-weight: 600;
}

.inbox-table tr {
    position: relative;
}

/* Profilbild bzw. Initialen, rund. Größe über --avatar-size (siehe _avatar.html.twig). */
.avatar {
    --avatar-size: 32px;
    width: var(--avatar-size);
    height: var(--avatar-size);
    flex-shrink: 0;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--avatar-size) * 0.4);
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.02em;
    user-select: none;
}

/* Feste Farbe je Nutzer (ID modulo 6), alle Paare mit mindestens 4,5:1 Kontrast */
.avatar-color-0 { background: #fde68a; color: #78350f; }
.avatar-color-1 { background: #fed7aa; color: #7c2d12; }
.avatar-color-2 { background: #fecaca; color: #7f1d1d; }
.avatar-color-3 { background: #d9f99d; color: #365314; }
.avatar-color-4 { background: #bae6fd; color: #0c4a6e; }
.avatar-color-5 { background: #e9d5ff; color: #581c87; }
.avatar-color-none { background: #e7e5e4; color: #57534e; }

/* Nutzerliste: Push an/aus */
.push-state {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.push-state svg {
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.push-state.is-on {
    color: var(--idal-orange-text);
}

/* Konto-Button oben rechts, öffnet das Menü von rechts */
.account-button {
    --bs-btn-padding-y: 0.25rem;
    --bs-btn-font-weight: 500;
    color: var(--idal-text);
    border: 0;
}

.account-button.active,
.account-button:hover {
    color: var(--idal-orange-text);
}

.account-button-icon {
    width: 1.5rem;
    height: 1.5rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.account-button-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 0.7rem;
    height: 0.7rem;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--idal-orange);
}

/* Menü von rechts (Bootstrap-Offcanvas) */
.account-menu {
    --bs-offcanvas-width: min(85vw, 20rem);
    border-left: 1px solid rgba(234, 88, 12, 0.18);
}

.account-menu .offcanvas-header {
    border-bottom: 1px solid var(--idal-line);
}

.account-menu .offcanvas-body {
    padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
}

.menu-list {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
}

.menu-list a {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-radius: var(--bs-border-radius);
    color: var(--idal-text);
    font-weight: 500;
    text-decoration: none;
}

.menu-list a:hover {
    background: var(--idal-orange-soft);
    color: var(--idal-orange-text);
}

.menu-list a.active {
    background: var(--idal-orange-soft);
    color: var(--idal-orange-text);
    font-weight: 600;
}

.menu-heading {
    margin: 0.5rem 0.75rem 0.25rem;
    color: var(--idal-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Unternavigation der TOP-Seiten; auf dem Handy horizontal scrollbar statt umzubrechen */
.section-tabs {
    overflow-x: auto;
    border-bottom: 1px solid var(--idal-line);
    margin-bottom: 1.5rem;
}

/* Kopf einer Liste (_list_header.html.twig): bleibt unter der oberen Leiste stehen.
   --idal-header-height setzt assets/app.js aus der echten Höhe der oberen Leiste. */
.list-header {
    position: sticky;
    top: var(--idal-header-height, 3.9rem);
    z-index: 1010;
    margin-bottom: 1.5rem;
    padding-top: 0.5rem;
    /* Hintergrund über die volle Breite ziehen, damit Inhalt nicht seitlich durchscheint */
    border-image: linear-gradient(rgba(255, 255, 255, 0.94) 0 0) fill 0 / 0 / 0 100vmax;
}

.list-header .section-tabs {
    margin-bottom: 0;
}

.list-header-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--idal-line);
}

/* ⋯-Menü mit „+ Neu“, Suche und Filtern (_list_menu.html.twig) */
.list-menu-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--idal-text);
}

.list-menu-button:hover,
.list-menu-button[aria-expanded="true"] {
    background: var(--idal-orange-soft);
    color: var(--idal-orange-text);
}

.list-menu-button svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
}

.list-menu-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 0.7rem;
    height: 0.7rem;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--idal-orange);
}

.list-menu-panel {
    width: min(90vw, 18rem);
    padding: 0.75rem;
}

.list-menu-panel.show {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.list-menu-label {
    display: block;
    margin-bottom: 0.15rem;
    color: var(--idal-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.section-tabs .nav {
    white-space: nowrap;
}

.section-tabs .nav-link {
    color: var(--idal-muted);
}

.section-tabs .nav-link.active,
.section-tabs .nav-link:hover {
    color: var(--idal-orange-text);
}

/* Reiterwechsel: nur der Inhalt schiebt seitlich, Kopf, Reiterleiste und untere Leiste bleiben stehen.
   Die Richtung setzt das Skript im Head von base.html.twig als View-Transition-Typ. */
/* Namen nur während eines Reiterwechsels: Ein view-transition-name macht main sonst dauerhaft zu einem eigenen
   Stapelkontext, und der Backdrop des ⋯-Menüs läge über dem Dropdown. */
html:active-view-transition-type(tab-forward, tab-back) main.container {
    view-transition-name: tab-content;
}

html:active-view-transition-type(tab-forward, tab-back) .section-tabs {
    view-transition-name: section-tabs;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation: none;
}

::view-transition-group(tab-content) {
    overflow: hidden;
    animation-duration: 0.25s;
}

::view-transition-old(tab-content),
::view-transition-new(tab-content) {
    animation-duration: 0.25s;
    animation-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

html:active-view-transition-type(tab-forward)::view-transition-old(tab-content) {
    animation-name: idal-slide-out-left;
}

html:active-view-transition-type(tab-forward)::view-transition-new(tab-content) {
    animation-name: idal-slide-in-right;
}

html:active-view-transition-type(tab-back)::view-transition-old(tab-content) {
    animation-name: idal-slide-out-right;
}

html:active-view-transition-type(tab-back)::view-transition-new(tab-content) {
    animation-name: idal-slide-in-left;
}

@keyframes idal-slide-out-left {
    to {
        opacity: 0;
        transform: translateX(-30%);
    }
}

@keyframes idal-slide-in-right {
    from {
        opacity: 0;
        transform: translateX(30%);
    }
}

@keyframes idal-slide-out-right {
    to {
        opacity: 0;
        transform: translateX(30%);
    }
}

@keyframes idal-slide-in-left {
    from {
        opacity: 0;
        transform: translateX(-30%);
    }
}

/* App-Navigation unten (nur Handy, siehe _bottom_nav.html.twig) */
.bottom-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1030;
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.78);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(234, 88, 12, 0.18);
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
    letter-spacing: 0.01em;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    min-height: 3.5rem;
    padding: 0.5rem 0.25rem 0.4rem;
    font-size: 0.75rem;
    color: var(--idal-muted);
    text-decoration: none;
}

.bottom-nav a.active {
    color: var(--idal-orange-text);
    font-weight: 600;
}

.bottom-nav a:active svg {
    transform: scale(0.9);
}

.bottom-nav svg {
    transition: transform 100ms ease-out;
    width: 1.5rem;
    height: 1.5rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.bottom-nav-icon {
    position: relative;
    display: inline-flex;
}

.bottom-nav-icon .badge {
    position: absolute;
    top: -0.35rem;
    left: 1rem;
    font-size: 0.65rem;
}

/* Push auf diesem Gerät aus: Symbol rot, dazu das „!“-Badge (assets/push.js) */
.bottom-nav a.push-off svg {
    stroke: var(--idal-danger);
}

.push-alert {
    --bs-danger-rgb: 185, 28, 28;
}

@media (max-width: 991.98px) {
    /* Platz für die untere Leiste, damit nichts verdeckt wird */
    body.has-bottom-nav {
        padding-bottom: calc(4rem + env(safe-area-inset-bottom));
    }
}

/* Tabellen werden auf dem Handy zu Karten: jede Zeile ein Block, jede Zelle mit Beschriftung. */
@media (max-width: 767.98px) {
    .table-stack thead {
        display: none;
    }

    .table-stack tr {
        display: block;
        margin-bottom: 0.75rem;
        padding: 0.75rem 1rem;
        border: 1px solid var(--idal-line);
        border-radius: var(--bs-border-radius);
        background: #fff;
    }

    .table-stack td {
        display: block;
        padding: 0.25rem 0;
        border: 0;
        text-align: left !important;
        white-space: normal !important;
    }

    .table-stack td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 0.75rem;
        font-weight: 400;
        color: var(--idal-muted);
    }

    /* Größere Touch-Flächen */
    .btn-sm {
        --bs-btn-padding-y: 0.45rem;
    }
}

/* Dropdown wächst aus seinem Auslöser heraus */
.dropdown-menu.show {
    transform-origin: top left;
    animation: idal-pop 160ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

/* Flash-Meldungen gleiten von oben herein */
.alert[role="alert"] {
    animation: idal-slide-in 220ms ease-out;
}

@keyframes idal-pop {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(-4px);
    }
}

@keyframes idal-slide-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
}

@keyframes idal-fade {
    from {
        opacity: 0;
    }
}

/* Systemeinstellung „Bewegung reduzieren“: nur noch überblenden */
@media (prefers-reduced-motion: reduce) {
    .btn:active,
    .list-group-item-action:active,
    .bottom-nav a:active svg {
        transform: none;
    }

    .dropdown-menu.show,
    .alert[role="alert"] {
        animation-name: idal-fade;
    }
}

/* Ohne Weichzeichner-Unterstützung, bei „Transparenz reduzieren“ oder „Mehr Kontrast“: feste Flächen */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .navbar.site-header,
    .bottom-nav {
        background: #fff;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .navbar.site-header,
    .bottom-nav {
        background: #fff;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

@media (prefers-contrast: more) {
    .navbar.site-header,
    .bottom-nav {
        background: #fff;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        border-color: var(--idal-orange-text);
    }
}
