/* ── Changelog ───────────────────────────────────────────────────────────── */

.changelog-view {
    --cl-accent: var(--behnke-design, #2f6df6);
    --cl-surface: var(--surface, #ffffff);
    --cl-border: var(--border, #e3e7ee);
    --cl-ink: var(--text, #1f2733);
    --cl-muted: var(--text-muted, #6b7280);
    max-width: calc(var(--behnke-basic, 12px) * 60);
    margin: 0 auto calc(var(--behnke-basic, 12px) * 4);
    padding: calc(var(--behnke-basic, 12px) * 3) var(--behnke-basic, 12px) 0;
    color: var(--cl-ink);
}

.changelog-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: var(--behnke-basic, 12px);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--cl-muted, #6b7280);
    transition: color 0.12s ease;
}

.changelog-back:hover {
    color: var(--cl-accent, #2f6df6);
}

.changelog-back-icon {
    width: 16px;
    height: 16px;
}

.changelog-view-head {
    margin-bottom: calc(var(--behnke-basic, 12px) * 1.5);
}

.changelog-eyebrow {
    margin: 0 0 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--behnke-design, #2f6df6);
}

.changelog-view-head h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text, #1f2733);
}

.changelog-view-version {
    color: var(--text-muted, #6b7280);
    font-weight: 600;
}

/* ── Entry card (matches .fw-notes-card) ─────────────────────────────────── */

.changelog-entry {
    --cl-accent: var(--behnke-design, #2f6df6);
    --cl-surface: var(--surface, #ffffff);
    --cl-border: var(--border, #e3e7ee);
    --cl-ink: var(--text, #1f2733);
    --cl-muted: var(--text-muted, #6b7280);
    background: var(--cl-surface);
    border: 1px solid var(--cl-border);
    border-left: 4px solid var(--cl-accent);
    border-radius: 14px;
    padding: 22px 26px;
    color: var(--cl-ink);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 18px rgba(16, 24, 40, 0.06);
}

.changelog-entry-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--cl-border);
}

.changelog-entry-version {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--cl-ink);
}

.changelog-entry-head .badge {
    font-size: 0.72rem;
    padding: 2px 9px;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.changelog-entry-head .badge.release { background: var(--success-bg, #dcfce7); color: var(--success, #166534); }
.changelog-entry-head .badge.alpha   { background: var(--danger-bg, #fee2e2);  color: var(--danger, #991b1b); }
.changelog-entry-head .badge.legacy  { background: var(--legacy-bg, #f1f5f9);  color: var(--legacy, #64748b); }
.changelog-entry-head .badge.next    { background: var(--cl-accent); color: #fff; }

.changelog-entry-date {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--cl-muted);
}

/* ── Body: subject groups + item lists (markdown-body-like typography) ───── */

.changelog-lead {
    margin: 0 0 1.1em;
    line-height: 1.55;
    color: var(--cl-ink);
}

.changelog-lead:last-child {
    margin-bottom: 0;
}

.changelog-subject + .changelog-subject {
    margin-top: 1.3em;
}

.changelog-subject-title {
    margin: 0 0 0.5em;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--cl-ink);
}

.changelog-items {
    list-style: disc;
    margin: 0;
    padding-left: 1.4em;
}

.changelog-item {
    margin: 4px 0;
    line-height: 1.5;
}

.changelog-tag {
    display: inline-block;
    margin-right: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: 1px;
    white-space: nowrap;
}

.changelog-tag--new    { background: var(--success-bg, #dcfce7); color: var(--success, #166534); }
.changelog-tag--change { background: var(--legacy-bg, #fef3c7);  color: var(--legacy, #d97706); }

.changelog-empty {
    margin: 0;
    color: var(--cl-muted);
    font-size: 0.9rem;
    font-style: italic;
}

/* ── Firmware-notice page: the "Änderungen in {version}" section ─────────── */

.firmware-notice .fw-changelog-section {
    margin-top: 28px;
}

.firmware-notice .fw-changelog-section .fw-notes-heading {
    margin-bottom: 4px;
}

.firmware-notice .fw-changelog-section .changelog-entry {
    margin-top: 14px;
}

/* ── Download-area popup trigger + modal ─────────────────────────────────── */

.changelog-open {
    display: inline-block;
}

.widget-download-table .changelog-open-link {
    display: inline-block;
    margin: 0 4px 2px 0;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid var(--behnke-design, #2f6df6);
    background: transparent;
    color: var(--behnke-design, #2f6df6);
    font-size: 0.8rem;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.widget-download-table .changelog-open-link:hover {
    background: var(--behnke-design, #2f6df6);
    color: #fff;
}

.widget-download-table .changelog-open-link--next {
    background: var(--behnke-design, #2f6df6);
    color: #fff;
    font-weight: 600;
}

.widget-download-table .changelog-open-link--next:hover {
    filter: brightness(1.08);
}

.changelog-modal-source { display: none; }

.changelog-modal {
    position: fixed;
    inset: 0;
    z-index: 10500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: calc(var(--behnke-basic, 12px) * 2) var(--behnke-basic, 12px);
    background: rgba(16, 24, 40, 0.55);
}

.changelog-modal.is-open {
    display: flex;
}

.changelog-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    margin: auto;
    display: flex;
}

.changelog-modal-content {
    display: flex;
    width: 100%;
    min-height: 0;
}

.changelog-modal .changelog-entry {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 85vh;
    padding: 0;
    overflow: hidden;
}

.changelog-modal .changelog-entry-head {
    margin: 0;
    padding: 18px 26px;
    background: var(--cl-surface);
    border-bottom: 1px solid var(--cl-border);
    border-radius: 14px 14px 0 0;
}

.changelog-modal .changelog-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 26px 22px;
}

.changelog-modal-close {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 999px;
    background: var(--surface, #fff);
    color: var(--text, #1f2733);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.2);
}

.changelog-modal-close:hover {
    filter: brightness(0.95);
}

/* ── Dark theme ──────────────────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
    .changelog-entry {
        --cl-surface: var(--surface, #1f2430);
        --cl-border: var(--border, #374151);
        --cl-ink: var(--text, #e5e7eb);
        --cl-muted: var(--text-muted, #9ca3af);
    }

    .changelog-modal-close {
        background: var(--surface, #1f2430);
        color: var(--text, #e5e7eb);
    }
}
