/*
 * 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-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);
}

/* Aufgeklapptes Handy-Menü fast deckend, damit der Text lesbar bleibt */
.navbar.site-header:has(.navbar-collapse.show, .navbar-collapse.collapsing) {
    background: rgba(255, 255, 255, 0.96);
}

.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;
}

/* 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; }

/* Konto-Menü oben rechts */
.account-menu .btn {
    --bs-btn-padding-y: 0.25rem;
    --bs-btn-font-weight: 500;
    color: var(--idal-text);
    border: 0;
}

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

.account-menu .dropdown-menu.show {
    transform-origin: top right;
}

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

.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);
}

/* 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;
}

@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);
    }
}
