/* Prediction tooltip (minimal on hover/tap) */
.tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.95);
    color: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    pointer-events: none;
    z-index: 10000;
    width: 280px;
    max-width: 90vw;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

/* Touch devices: tooltip blur isn't needed and can be expensive on iOS.
   Comments in English per project convention. */
@media (hover: none) and (pointer: coarse) {
    .tooltip {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

.tooltip.visible {
    opacity: 1;
}

/* Connector line from tile corner to tooltip - hidden as it's not working correctly */
.tooltip-connector {
    display: none !important;
}

.tooltip-prognose {
    font-size: 16px;
    margin-bottom: 10px;
    line-height: 1.5;
    color: #fff;
    font-weight: 500;
}

.tooltip-id {
    font-size: 11px;
    color: #aaa;
    margin-bottom: 6px;
}

.tooltip-absender {
    font-size: 12px;
    color: #888;
    font-style: italic;
    margin-bottom: 8px;
}

/* Status badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 12px 7px; /* nudge text 1px down */
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 8px;
    line-height: 1;
}

.status-badge.status-true {
    background: #166534; /* darker green for stronger contrast */
    color: #fff;
}

.status-badge.status-false {
    background: #991b1b; /* darker red for stronger contrast */
    color: #fff;
}

.status-badge.status-partially_true {
    background: #92400e; /* darker amber for stronger contrast */
    color: #fff;
}

.status-badge.status-subjective {
    background: #374151; /* darker gray */
    color: #fff;
}

.status-badge.status-unverifiable {
    background: #1e3a8a; /* darker blue for stronger contrast */
    color: #fff;
}

/* Prediction Side Panel (Desktop) */
.prediction-modal {
    position: fixed;
    top: 0;
    right: 0;
    width: 480px;
    max-width: 40vw;
    height: 100%;
    background: #1a1a1a;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 20000;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    /* Keep scrolling inside `.prediction-modal-content` so the close button can stay sticky. */
    overflow: hidden;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.prediction-modal.visible {
    transform: translateX(0);
}

/* Fallback: Slide from bottom if screen too narrow */
@media (max-width: 1200px) {
    .prediction-modal {
        width: 100%;
        max-width: 100%;
        height: auto;
        /* Avoid 100vh/85vh issues on mobile browsers; use small viewport units. */
        max-height: 85svh;
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
    }
    
    .prediction-modal.visible {
        transform: translateY(0);
    }
}

/* Landscape phones: use a true sidepanel (splitscreen) instead of a bottom drawer.
   This intentionally overrides the max-width:1200px fallback above.
   Comments in English per project convention. */
@media (orientation: landscape) and (max-height: 500px) {
    .prediction-modal {
        top: 0;
        bottom: 0;
        left: auto;
        right: 0;
        height: auto;
        width: 420px;
        max-width: 46vw;
        border-radius: 0;
        border-top: none;
        border-left: 1px solid rgba(255, 255, 255, 0.1);
        transform: translateX(100%);
        max-height: none;
    }

    .prediction-modal.visible {
        transform: translateX(0);
    }

    /* Landscape phone sidepanel: reduce wasted right padding while keeping close button usable.
       Comments in English per project convention. */
    .prediction-modal-content {
        padding: 18px;
    }

    .prediction-modal .details-panel--prediction,
    .prediction-modal .details-panel--info {
        padding-right: 0;
    }
}

.prediction-modal-content {
    padding: 30px;
    flex: 1;
    overflow-y: auto;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Do not reserve a right "safe area" for the close button.
   The close button is sticky and stays visible; content may flow under it.
   Comments in English per project convention. */
.prediction-modal .details-panel--prediction,
.prediction-modal .details-panel--info {
    padding-right: 0;
}

/* Make the prediction panel a column layout so the brand can sit at the bottom.
   Comments in English per project convention. */
.prediction-modal .details-panel--prediction {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.prediction-modal .details-panel--prediction .prediction-modal-header {
    flex: 0 0 auto;
}

.prediction-modal .details-panel--prediction .prediction-modal-body {
    flex: 1 1 auto;
}

.prediction-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.prediction-modal-title {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 8px;
}

/* Sidepanel should not show a title, only the prediction text */
.prediction-modal-title {
    display: none;
}

.prediction-modal-id {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 8px;
}

.prediction-modal-prognose {
    font-size: 18px;
    line-height: 1.6;
    margin-bottom: 12px;
    color: #e0e0e0;
}

.prediction-modal-absender {
    font-size: 14px;
    color: #888;
    font-style: italic;
}

/* Close button is now a regular .ui-btn (see css/main.css). Keep only positioning. */
.prediction-modal-close {
    border-radius: 10px;
}

.details-panel-close {
    /* Always visible while panel content scrolls. */
    position: fixed;
    top: var(--floating-ui-inset-y);
    right: var(--floating-ui-inset-x);
    z-index: 20;
}

.prediction-modal-body {
    margin-top: 20px;
}

.prediction-verification {
    margin-top: 24px;
}

.prediction-verification h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #fff;
}

.prediction-verification p {
    font-size: 14px;
    line-height: 1.6;
    color: #ccc;
    margin-bottom: 12px;
}

.prediction-sources {
    margin-top: 20px;
}

.prediction-sources h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #fff;
}

.prediction-source {
    margin-bottom: 8px;
}

.prediction-source a {
    /* Link styling is handled globally in css/main.css (monochrome + underlined). */
    font-size: 14px;
}

/* Hover/active link behavior is handled globally in css/main.css. */

/* Sources: bullet list */
.prediction-sources-list {
    margin: 0;
    padding-left: 18px;
}

.prediction-sources-list li {
    margin-bottom: 8px;
}

/* Hide/show shared panel modes */
.prediction-modal[data-details-mode="info"] .details-panel--prediction,
.prediction-bottom-sheet[data-details-mode="info"] .details-panel--prediction {
    display: none !important;
}

.prediction-modal[data-details-mode="prediction"] .details-panel--info,
.prediction-bottom-sheet[data-details-mode="prediction"] .details-panel--info {
    display: none !important;
}

/* Info panel */
.details-panel--info {
    /* Use a simple column layout so the brand can sit in the bottom-right corner
       without overlaying content, and only becomes visible after scrolling to the end. */
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.details-panel--info .info-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

/* Tabs share the same visual language as other UI buttons (radius, border, hover). */
.details-panel--info .info-tab-btn {
    /* Fallback if the .ui-btn class isn't present. */
    border-radius: 10px;
}

.details-panel--info .ui-btn--tab {
    padding: 6px 10px;
    min-width: auto;
    font-size: 13px;
    font-weight: 700;
    border-radius: 10px;
}

.details-panel--info .ui-btn--tab.active {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.24);
}

.details-panel--info .ui-btn--tab:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.14);
}

.details-panel--info .info-tab-panels {
    padding-bottom: 24px;
    flex: 1;
}

.details-panel--info .info-tab-panel {
    color: #e0e0e0;
    line-height: 1.65;
    font-size: 14px;
}

.details-panel--info .info-tab-panel h1 {
    font-size: 18px;
    line-height: 1.3;
    margin: 0 0 12px;
    color: #fff;
}

.details-panel--info .info-tab-panel h2 {
    font-size: 15px;
    margin: 18px 0 10px;
    color: #fff;
}

.details-panel--info .info-tab-panel h3,
.details-panel--info .info-tab-panel h4 {
    font-size: 13px;
    margin: 14px 0 8px;
    color: #fff;
}

.details-panel--info .info-tab-panel p {
    margin-bottom: 12px;
}

.details-panel--info .info-tab-panel ul {
    padding-left: 18px;
    margin: 8px 0 12px;
}

.details-panel--info .info-tab-panel li {
    margin-bottom: 6px;
}

.details-panel--info .info-tab-panel a {
    word-break: break-word;
}

.details-panel--info .info-panel-brand {
    /* Desktop: brand sits in the bottom-right corner of the panel.
       For long content it will only be visible after scrolling to the end. */
    margin-top: auto;
    align-self: flex-end;
    padding-top: 14px;
    /* padding-bottom: 20px; */
    /* Keep the logo aligned with the panel padding. */
    margin-right: 0;
    margin-bottom: 0;
    opacity: 0.6;
    filter: invert(1);
    pointer-events: none;
    transform: scale(0.95);
    transform-origin: right bottom;
}

.details-panel--info .info-panel-brand img {
    height: 20px;
    width: auto;
    display: block;
}

/* Mobile: keep it subtle and in-flow (avoid overlaying readable content). */
@media (max-width: 768px) {
    .prediction-bottom-sheet .details-panel--info .info-panel-brand {
        margin-top: auto;
        align-self: flex-end;
        padding-top: 12px;
        /* Mobile uses smaller content padding; add margins to reach ~30px edge spacing. */
        margin-right: 14px;
        margin-bottom: 14px;
        opacity: 0.6;
        transform: scale(0.9);
        transform-origin: right bottom;
    }
}

/* Mobile: hide prediction expand button in info mode */
.prediction-bottom-sheet[data-details-mode="info"] #bottomSheetExpandBtn,
.prediction-bottom-sheet[data-details-mode="info"] .prediction-bottom-sheet-meta-row {
    display: none !important;
}

/* Prediction Bottom Sheet (Mobile) */
/* Default clearance for the floating info button.
   JS refines `--sheet-top-clearance` by measuring the actual button position.
   Comments in English per project convention. */
:root {
    --sheet-top-clearance: 60px;
}

.prediction-bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #1a1a1a;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px 20px 0 0;
    z-index: 20000;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    touch-action: pan-y; /* Allow vertical scrolling */
    /* Fallback first (vh), then prefer svh/dvh to avoid mobile browser UI bugs. */
    max-height: calc(100vh - var(--sheet-top-clearance));
    pointer-events: auto;
    /* Prevent iOS Safari text autosizing inside the sheet. */
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
}

@supports (height: 100svh) {
    .prediction-bottom-sheet {
        max-height: calc(100svh - var(--sheet-top-clearance));
    }
}

@supports (height: 100dvh) {
    .prediction-bottom-sheet {
        max-height: calc(100dvh - var(--sheet-top-clearance));
    }
}

.prediction-bottom-sheet.visible {
    transform: translateY(0);
}

/* Collapsed state should be compact */
.prediction-bottom-sheet.collapsed {
    height: var(--collapsed-height, 160px);
    max-height: var(--collapsed-height, 160px);
}

/* Expanded: height is handled by base max-height + inner scroll containers. */

.prediction-bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    margin: 8px auto;
    cursor: grab;
    flex-shrink: 0;
    touch-action: none;
    pointer-events: auto;
}

.prediction-bottom-sheet-handle:active {
    cursor: grabbing;
}

.prediction-bottom-sheet-content {
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
    padding: 0;
    padding-bottom: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Allow inner scroll containers to shrink properly in flex layout (critical for iOS). */
    min-height: 0;
}

/* Mobile/BottomSheet: make info content scrollable.
   The bottom sheet container itself is overflow-hidden; only the tab panels should scroll.
   Comments in English per project convention. */
.prediction-bottom-sheet[data-details-mode="info"] .details-panel--info {
    flex: 1 1 auto;
    min-height: 0;
}

.prediction-bottom-sheet[data-details-mode="info"] .details-panel--info .info-tab-panels {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Allow scrolling inside a flex item (otherwise it can refuse to scroll on mobile Safari). */
    min-height: 0;
    touch-action: pan-y;
}

/* keep legacy rule, but collapsed max-height above is the effective limiter */
.prediction-bottom-sheet.collapsed {
    height: auto;
}

.prediction-bottom-sheet.collapsed .prediction-bottom-sheet-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
}

.prediction-bottom-sheet.expanded {
    height: auto;
}

.prediction-bottom-sheet.expanded .prediction-bottom-sheet-body {
    /* Keep body scrollable below header/controls. */
    max-height: calc(100vh - var(--sheet-top-clearance) - 200px);
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

@supports (height: 100svh) {
    .prediction-bottom-sheet.expanded .prediction-bottom-sheet-body {
        max-height: calc(100svh - var(--sheet-top-clearance) - 200px);
    }
}

@supports (height: 100dvh) {
    .prediction-bottom-sheet.expanded .prediction-bottom-sheet-body {
        max-height: calc(100dvh - var(--sheet-top-clearance) - 200px);
    }
}

.bottom-sheet-expand-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.bottom-sheet-expand-btn .expand-icon {
    transition: transform 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.prediction-bottom-sheet.expanded .bottom-sheet-expand-btn .expand-icon {
    transform: rotate(180deg);
}

/* Keep the label visible in both states */

.bottom-sheet-close {
    /* Keep close button visible while `.prediction-bottom-sheet-content` scrolls. */
    position: fixed;
    /* top: 8px; */
    margin-top: -16px;
    right: var(--floating-ui-inset-x);
    /* Visual styling comes from .ui-btn / .ui-btn--icon in css/main.css. */
    z-index: 10;
    pointer-events: auto;
    touch-action: manipulation;
}

/* Close button interaction states are handled by `.ui-btn` in css/main.css. */

.prediction-bottom-sheet-header {
    /* Move header content slightly up to avoid clipped buttons in collapsed mode */
    padding: 10px 14px 10px;
    padding-right: 64px; /* keep text clear of the close button */
    flex-shrink: 0;
    touch-action: none; /* ensure drag gestures are delivered */
    display: flex;
    flex-direction: column;
}

.prediction-bottom-sheet.collapsed .prediction-bottom-sheet-header {
    padding-bottom: 12px;
}

/* New compact meta row (status + expand button) */
.prediction-bottom-sheet-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    touch-action: none; /* allow drag from this row */
    margin-top: auto; /* pin to bottom of collapsed sheet */
}

.bottom-sheet-expand-btn {
    /* Visual styling comes from .ui-btn in css/main.css. */
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: auto;
    height: auto;
    pointer-events: auto;
    flex-shrink: 0;
    border-radius: 10px;
}

.bottom-sheet-expand-btn .expand-text {
    display: inline;
}

/* Slightly smaller chevron inside the expand button to match the overall UI rhythm. */
.bottom-sheet-expand-btn .ui-icon--chev {
    width: 18px;
    height: 18px;
}

.prediction-bottom-sheet-id {
    font-size: 13px;
    color: #aaa;
    font-weight: 500;
}

.prediction-bottom-sheet-prognose {
    font-size: 15px;
    line-height: 1.4;
    margin-bottom: 6px;
    color: #e0e0e0;
}

.prediction-bottom-sheet-absender {
    font-size: 12px;
    color: #888;
    font-style: italic;
}

/* In collapsed mode keep header content compact so status/button never clip */
.prediction-bottom-sheet.collapsed .prediction-bottom-sheet-prognose {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.prediction-bottom-sheet.collapsed .prediction-bottom-sheet-absender {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.prediction-bottom-sheet-header .status-badge {
    margin: 0;
}

.prediction-bottom-sheet-body {
    padding: 0 14px;
    margin-top: 0;
}

/* Backdrop for mobile bottom sheet */
.prediction-backdrop {
    /* No dimming/backdrop (keep element for compatibility) */
    display: none !important;
}

.prediction-backdrop.visible {
    display: none !important;
}

