/* --- Palette: GOV.UK-inspiriert, Schwarz/Weiß --- */
:root {
    --text: #0b0c0c;
    --secondary: #505a5f;
    --border: #b1b4b6;
    --hover: #f3f2f1;
    --bg: #fff;
    --font: 'Inter', -apple-system, "Segoe UI", Arial, sans-serif;
    --left-width: 30%;
}

[data-theme="dark"] {
    --text: #f3f2f1;
    --secondary: #a1a7aa;
    --border: #3f4345;
    --hover: #1a1c1d;
    --bg: #0b0c0c;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    /* Platz für die Scrollleiste dauerhaft reservieren, sonst springt
       die Spaltenbreite beim Auf-/Zuklappen von Entscheidungen */
    scrollbar-gutter: stable;
}

body {
    font-family: var(--font);
    font-size: 1rem;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* GOV.UK-Signatur: Links immer unterstrichen, Hover verdickt den Strich */
a {
    color: var(--text);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    transition: text-decoration-thickness 0.05s ease;
}

a:hover {
    text-decoration-thickness: 3px;
}

:focus-visible {
    outline: 3px solid var(--text);
    outline-offset: 2px;
}

/* --- Layout: Sidebar links, Liste rechts --- */
.content {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--left-width);
    padding: 2rem 1.75rem;
    display: flex;
    flex-direction: column;
    z-index: 2;
    background: var(--bg);
    overflow-y: auto;
}

.vertical-line {
    position: fixed;
    top: 0;
    left: var(--left-width);
    bottom: 0;
    width: 1px;
    background: var(--border);
    z-index: 1;
    pointer-events: none;
}

.main {
    margin-left: var(--left-width);
    width: calc(100% - var(--left-width));
    padding: 2rem 2.5rem 4rem 2rem;
    max-width: calc(52rem + var(--left-width));
}

/* --- Sidebar: Intro --- */
h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.01em;
    margin-bottom: 1rem;
}

.subtitle {
    font-size: 0.95rem;
    color: var(--secondary);
    line-height: 1.55;
    max-width: 26em;
}

/* --- Sidebar: Suche --- */
.controls {
    margin-top: 2rem;
}

.search-label {
    display: block;
    font-weight: 700;
    font-size: 1rem;
}

.search-hint {
    display: block;
    font-size: 0.85rem;
    color: var(--secondary);
    margin-bottom: 0.4rem;
}

.search-bar input {
    width: 100%;
    max-width: 24em;
    padding: 0.45rem 0.6rem;
    border: 2px solid var(--text);
    border-radius: 0;
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
}

.search-bar input:focus {
    outline: 3px solid var(--text);
    outline-offset: 0;
}

/* --- Sidebar: Themenfilter --- */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 1.1rem;
    max-width: 26em;
}

.tag-pill {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 0;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--text);
    color: var(--text);
    background: var(--bg);
    line-height: 1.4;
    font-family: inherit;
}

.tag-pill:hover {
    background: var(--hover);
}

.tag-pill.active {
    background: var(--text);
    color: var(--bg);
}

.pill-count {
    margin-left: 0.45em;
    font-weight: 400;
    opacity: 0.65;
}

/* --- Sidebar: Ansichten --- */
.sort-toggle {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 1.5rem;
    align-items: flex-start;
}

.sort-btn {
    padding: 0;
    font-size: 0.95rem;
    border: none;
    background: none;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}

.sort-btn:hover {
    text-decoration-thickness: 3px;
}

.sort-btn.active {
    font-weight: 700;
    text-decoration: none;
    cursor: default;
}

#count {
    font-size: 0.9rem;
    color: var(--secondary);
    margin-top: 1.5rem;
}

/* --- Sidebar: Bottom --- */
.sidebar-bottom {
    margin-top: auto;
    padding-top: 2rem;
    font-size: 0.9rem;
    color: var(--secondary);
    line-height: 1.55;
    max-width: 26em;
}

.sidebar-bottom p {
    margin-bottom: 0.5rem;
}

.sidebar-bottom p:last-child {
    margin-bottom: 0;
}

.sidebar-bottom a {
    color: inherit;
}

.sidebar-bottom a:hover {
    color: var(--text);
}

.theme-toggle {
    margin-bottom: 0.75rem;
}

.theme-toggle button {
    background: none;
    border: 0;
    padding: 0;
    color: var(--secondary);
    cursor: pointer;
    line-height: 0;
    transition: color 0.15s ease, transform 0.2s ease;
}

.theme-toggle button:hover {
    color: var(--text);
}

.theme-toggle button:active {
    transform: scale(0.92);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    display: block;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
}

:root:not([data-theme="dark"]) .theme-toggle .icon-sun {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: block;
}

/* --- Liste: zweispaltige Zeilen (Datum | Entscheidung) --- */
.card {
    display: grid;
    grid-template-columns: 6.5rem 1fr auto;
    gap: 0 1.25rem;
    padding: 0.85rem 0;
    border-top: 1px solid var(--border);
    position: relative;
}

#urteile-list > .card:last-child {
    border-bottom: 1px solid var(--border);
}

.card.has-details {
    cursor: pointer;
}

.card.has-details:hover {
    background: var(--hover);
}

.card-date {
    color: var(--secondary);
    font-size: 0.95rem;
    padding-top: 0.1rem;
    font-variant-numeric: tabular-nums;
}

.card-body {
    min-width: 0;
    overflow-wrap: break-word;
}

.card-title {
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.4;
}

.card-title a {
    color: var(--text);
}

.card-meta {
    font-size: 0.9rem;
    color: var(--secondary);
    margin-top: 0.15rem;
}

.card-meta .sep {
    color: var(--border);
    margin: 0 0.35rem;
}

/* --- Schlagworte in der Zeile: dezenter Kasten, ruhiger als die Filter-Pills --- */
.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.4rem;
}

.card-tag {
    display: inline-block;
    padding: 0.05rem 0.45rem;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--secondary);
    border: 1px solid var(--border);
}

/* --- Leitsatz-Vorschau in der Zeile --- */
.card-teaser {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--secondary);
    margin-top: 0.35rem;
    max-width: 46em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card.open .card-teaser {
    display: none;
}

/* --- Marker für hervorgehobene Entscheidungen --- */
.card.highlight::before {
    content: "";
    position: absolute;
    left: -1rem;
    top: 0.85rem;
    bottom: 0.85rem;
    width: 5px;
    background: var(--text);
}

/* --- Auf-/Zuklappen --- */
.card-chevron {
    font-size: 0.9rem;
    color: var(--secondary);
    padding-top: 0.15rem;
    transition: transform 0.2s ease;
}

.card.open .card-chevron {
    transform: rotate(90deg);
    color: var(--text);
}

/* --- Details --- */
.card-details {
    display: none;
    margin-top: 0.9rem;
}

.card.open .card-details {
    display: block;
}

.detail-section h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.detail-section + .detail-section,
.related-section {
    margin-top: 1.1rem;
}

.detail-section p {
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text);
    margin-bottom: 0.4rem;
    max-width: 42em;
}

.related-link {
    display: inline-block;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    margin-right: 1rem;
    margin-bottom: 0.25rem;
}

.related-link:hover {
    text-decoration-thickness: 3px;
}

/* --- Gruppierung (Gericht / Thema / Zuletzt hinzugefügt) --- */
.group-header {
    font-size: 1.375rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--text);
    padding: 2rem 0 0.5rem;
    border-bottom: 2px solid var(--text);
}

.group-header:first-child {
    padding-top: 0;
}

.group-header + .card {
    border-top: none;
}

/* --- Keine Ergebnisse --- */
.no-results {
    color: var(--secondary);
    padding: 1.25rem 0;
    font-size: 1rem;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 12, 12, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.75);
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    background: var(--bg);
    border: 2px solid var(--text);
    border-radius: 0;
    max-width: 540px;
    width: 100%;
    padding: 2rem;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h2 {
    font-size: 1.375rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.modal h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-top: 1.25rem;
    margin-bottom: 0.35rem;
}

.modal-body p {
    font-size: 0.95rem;
    line-height: 1.55;
    margin-bottom: 0.5rem;
}

.modal-close {
    position: absolute;
    top: 0.6rem;
    right: 0.9rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
    font-family: inherit;
}

.modal-close:hover {
    color: var(--text);
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .sidebar {
        position: relative;
        width: 100%;
        padding: 1.5rem;
        overflow-y: visible;
    }

    .sidebar-bottom {
        margin-top: 1.75rem;
        padding-top: 0;
    }

    .vertical-line {
        display: none;
    }

    .main {
        margin-left: 0;
        width: 100%;
        max-width: none;
        padding: 1.5rem;
        padding-bottom: 3rem;
        border-top: 1px solid var(--border);
    }

    .controls {
        margin-top: 1.5rem;
    }

    .card {
        grid-template-columns: 5.5rem 1fr auto;
        gap: 0 0.9rem;
    }

    .card.highlight::before {
        left: -0.75rem;
    }
}
