/* Incident List */
.incident-list {
    padding: 1rem;
    padding-bottom: 5.5rem;
    max-width: 800px;
    margin: 0 auto;
}

/* 2-column layout for tablets and up */
@media (min-width: 800px) {
    .incident-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        row-gap: 1rem;
        column-gap: 1rem;
        max-width: 1400px;
    }

    .incident-list .no-results,
    .incident-list .loading {
        grid-column: 1 / -1;
    }

    .incident-card {
        margin-bottom: 0 !important;
    }
}

/* 3-column layout for wide screens */
@media (min-width: 1200px) {
    .incident-list {
        grid-template-columns: repeat(3, 1fr);
        max-width: 2000px;
    }
}

/* Incident Card */
.incident-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.875rem;
    padding-left: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.incident-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--secondary-accent);
}

/* Hide accent bar for viewed cards */
.incident-card.viewed::before {
    display: none;
}

/* Show primary accent bar for bookmarked cards (takes precedence) */
.incident-card.bookmarked::before {
    display: block;
    background: var(--primary-accent);
}

.incident-card:active {
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.incident-card.expanded {
    border-color: var(--button-color);
}

/* Allow overflow for info mode so explanation modal isn't clipped */
.incident-card.info-mode {
    overflow: visible;
}

.location-expanded,
.casualties-expanded,
.aircraft-expanded,
.departure-expanded {
    display: none;
}

.incident-card.expanded .location-collapsed,
.incident-card.expanded .casualties-collapsed,
.incident-card.expanded .aircraft-collapsed,
.incident-card.expanded .departure-collapsed {
    display: none;
}

.incident-card.expanded .location-expanded,
.incident-card.expanded .casualties-expanded,
.incident-card.expanded .aircraft-expanded,
.incident-card.expanded .departure-expanded {
    display: inline;
}

/* Event chain - hidden by default, shown when expanded */
.card-expanded-only {
    display: none;
}

.incident-card.expanded .card-expanded-only {
    display: block;
}

/* Expanded-only fields (like departure airfield) - hidden by default */
.expanded-only {
    display: none;
}

.incident-card.expanded .expanded-only {
    display: block;
}

.card-header {
    display: flex;
    flex-direction: row;
    align-items: first baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.875rem;
}

.incident-id-chip {
    background-color: #E5E5E5;
    color: #1a1a1a;
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.date-chip {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex-shrink: 0;
    position: relative;
    text-align: right;
}

/* Prevent auto-detection styling on date elements */
.date-chip,
.date-chip * {
    -webkit-text-decoration-skip: none;
    text-decoration: none;
    border-bottom: none !important;
}

.date-chip-year {
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    flex-basis: 100%;
}

.date-chip-month {
    color: var(--text-secondary);
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
}

.date-chip-day {
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    margin-left: 0.25rem;
    display: inline;
}


.expanded-title-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.bookmark-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 1px solid var(--primary-accent);
    background: transparent;
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bookmark-btn:hover {
    transform: scale(1.1);
    background: color-mix(in srgb, var(--primary-accent) 10%, transparent);
}

.bookmark-btn:active {
    transform: scale(0.95);
}

.bookmark-btn.bookmarked {
    background: var(--primary-accent);
    color: white;
}

.bookmark-btn.bookmarked:hover {
    background: color-mix(in srgb, var(--primary-accent) 90%, black);
}

/* Share Link Button */
.share-link-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 1px solid var(--primary-accent);
    background: transparent;
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.share-link-btn:hover {
    background: color-mix(in srgb, var(--primary-accent) 20%, transparent);
}

.share-link-btn:active {
    background: color-mix(in srgb, var(--primary-accent) 35%, transparent);
}

.share-link-btn.copied {
    background: var(--primary-accent);
    color: white;
}

/* Info Button (for data explanation) */
.info-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 1px solid var(--primary-accent);
    background: transparent;
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-btn:hover {
    background: color-mix(in srgb, var(--primary-accent) 20%, transparent);
}

.info-btn:active {
    background: color-mix(in srgb, var(--primary-accent) 35%, transparent);
}

.info-btn.active {
    background: var(--primary-accent);
    color: white;
}

/* Flag Button Icon (circular, matches other bottom buttons) */
.flag-btn-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 1px solid var(--primary-accent);
    background: transparent;
    color: var(--text-primary);
    font-size: 1.125rem;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flag-btn-icon:hover {
    background: color-mix(in srgb, var(--primary-accent) 20%, transparent);
}

.flag-btn-icon:active {
    background: color-mix(in srgb, var(--primary-accent) 35%, transparent);
}

/* Report Button (opens original report) */
.report-btn {
    height: 2.5rem;
    border-radius: 8px;
    border: 1px solid var(--primary-accent);
    background: transparent;
    color: var(--text-primary);
    padding: 0 0.875rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
}

.report-btn:hover {
    background: color-mix(in srgb, var(--primary-accent) 20%, transparent);
}

.report-btn:active {
    background: color-mix(in srgb, var(--primary-accent) 35%, transparent);
}

.report-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.report-btn:disabled:hover {
    transform: none;
    background: transparent;
}

/* Info Mode - Card state when exploring data fields */
/* Use box-shadow for highlight to avoid layout shifts */
.incident-card.info-mode .info-selectable {
    border-radius: 4px;
    transition: box-shadow 0.2s ease, opacity 0.2s ease, color 0.2s ease;
}

.incident-card.info-mode .info-selectable.info-selected {
    box-shadow: 0 0 0 4px var(--secondary-accent);
}

.incident-card.info-mode .info-selectable.info-dimmed {
    opacity: 0.3;
}

.incident-card.info-mode .swipe-tab.info-selectable {
    border-radius: 0.875rem;
}

.incident-card.info-mode .swipe-tab.info-selectable.info-selected {
    background: var(--secondary-accent);
    color: var(--secondary-accent-text);
    border-color: var(--secondary-accent);
    box-shadow: none;
    opacity: 1;
}

/* Summary uses text color instead of box-shadow when selected */
.incident-card.info-mode .card-summary.info-selectable.info-selected {
    box-shadow: none;
    color: var(--secondary-accent);
}

/* Sources uses text color instead of box-shadow when selected */
.incident-card.info-mode .card-sources.info-selectable.info-selected {
    box-shadow: none;
    color: var(--secondary-accent);
}

/* Disable all links in info mode */
.incident-card.info-mode a,
.incident-card.info-mode .location-link {
    pointer-events: none;
    color: var(--text-secondary);
    text-decoration: none;
}

/* Tags container needs padding adjustment for box-shadow alignment */
.incident-card.info-mode .tags-container.info-selectable {
    padding-top: 0.25rem;
    margin-top: 0.75rem;
}

/* Bottom buttons keep their natural shape in info mode */
.incident-card.info-mode .share-link-btn.info-selectable,
.incident-card.info-mode .bookmark-btn.info-selectable,
.incident-card.info-mode .flag-btn-icon.info-selectable {
    border-radius: 50%;
}

.incident-card.info-mode .report-btn.info-selectable {
    border-radius: 8px;
}

.incident-card.info-mode .report-btn.info-selectable.info-selected,
.incident-card.info-mode .share-link-btn.info-selectable.info-selected,
.incident-card.info-mode .bookmark-btn.info-selectable.info-selected,
.incident-card.info-mode .flag-btn-icon.info-selectable.info-selected {
    box-shadow: none;
    background: var(--secondary-accent);
    color: var(--secondary-accent-text);
    border-color: var(--secondary-accent);
}

/* Expandable needs relative positioning and visible overflow for explanation overlay */
.incident-card.info-mode .card-expandable {
    position: relative;
    overflow: visible;
}

/* Summary needs min-height so explanation can overlay bottom portion */
.incident-card.info-mode .card-summary {
    min-height: 6rem;
}

/* Explanation overlay - modal-like box positioned from bottom so it expands upward */
.info-explanation-container {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 3.5rem;
    background: var(--secondary-bg);
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    border: 1px solid var(--primary-accent);
    padding: 0.75rem;
    z-index: 200;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

/* On desktop, use static flow positioning so it sits naturally after the summary */
@media (min-width: 768px) {
    .info-explanation-container {
        position: relative;
        bottom: auto;
        left: auto;
        right: auto;
        width: 100%;
        margin-top: 0.75rem;
    }
}

/* Ensure carousel controls are clickable */
.info-carousel-nav {
    position: relative;
    z-index: 201;
}

.info-carousel {
    display: flex;
    flex-direction: column;
}

.info-carousel-content {
    background: var(--card-bg);
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-primary);
    overflow-y: auto;
    max-height: 40vh;
    border: 1px solid var(--border-color);
}

.info-carousel-title {
    font-weight: 600;
    color: var(--secondary-accent);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.375rem;
}

.info-carousel-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding-top: 0.75rem;
}

.info-carousel-btn {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: 1px solid var(--secondary-accent);
    background: transparent;
    color: var(--secondary-accent);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.info-carousel-btn:hover {
    background: color-mix(in srgb, var(--secondary-accent) 15%, transparent);
}

.info-carousel-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.info-carousel-progress {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 3rem;
    text-align: center;
}

.info-carousel-close {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    margin-left: 0.5rem;
}

.info-carousel-close:hover {
    border-color: var(--text-secondary);
    background: color-mix(in srgb, var(--text-secondary) 10%, transparent);
}

/* Light theme overrides for better contrast */
:root[data-theme="light"] .info-carousel-title {
    color: #E65100; /* Darker orange for contrast on white */
}

:root[data-theme="light"] .info-carousel-btn {
    border-color: #E65100;
    color: #E65100;
}

:root[data-theme="light"] .info-carousel-btn:hover {
    background: rgba(230, 81, 0, 0.15);
}

:root[data-theme="light"] .info-carousel-progress {
    color: #555555; /* Darker than default --text-secondary */
}

:root[data-theme="light"] .info-carousel-close {
    border-color: #888888;
    color: #555555;
}

:root[data-theme="light"] .info-carousel-close:hover {
    border-color: #555555;
    background: rgba(85, 85, 85, 0.1);
}


/* Help Button */
.help-btn {
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.help-btn:hover {
    background-color: var(--button-color);
    color: white;
    border-color: var(--button-color);
    transform: scale(1.05);
}

.help-btn:active {
    transform: scale(0.95);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-primary);
    text-wrap: balance;
    max-width: calc(100% - 6rem);
}

.card-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.125rem;
    line-height: 1.5;
}

/* Prevent auto-detection styling on location/meta elements */
.card-meta,
.card-meta * {
    -webkit-text-decoration-skip: none;
    text-decoration: none;
    border-bottom: none !important;
}

.card-meta:last-child {
    margin-bottom: 0;
}

.card-meta-label {
    color: var(--text-secondary);
    display: inline-block;
    min-width: 4.5rem;
}

.card-meta-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    min-width: 1.25rem;
    margin-right: 0.5rem;
    color: var(--text-primary);
    vertical-align: middle;
    position: relative;
    top: -1px;
}

.card-meta-icon svg {
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

.card-meta-value {
    color: var(--text-primary);
}

/* Tag chips */
.tag {
    display: inline-block;
    height: 1.75rem;
    line-height: 1.75rem;
    padding: 0 0.625rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid;
}

.tag.tag-flight-phase {
    background-color: color-mix(in srgb, var(--tertiary-accent) 20%, transparent);
    border-color: color-mix(in srgb, var(--tertiary-accent) 60%, transparent);
    color: color-mix(in srgb, var(--tertiary-accent) 70%, white);
}

.tag.tag-circumstance {
    background-color: color-mix(in srgb, var(--secondary-accent) 15%, transparent);
    border-color: color-mix(in srgb, var(--secondary-accent) 50%, transparent);
    color: var(--secondary-accent);
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.875rem;
}

/* Event Chain — vertical subway style */
.event-chain {
    display: flex;
    position: relative;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.5rem;
    margin-left: 0.75rem;
    padding-left: 1.25rem;
}
/* Vertical subway line */
.event-chain::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.875rem;
    bottom: 0.875rem;
    width: 2px;
    background: color-mix(in srgb, var(--text-secondary) 35%, transparent);
}
.chain-node {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 1.75rem;
    line-height: 1.75rem;
    padding: 0 0.625rem;
    border-radius: 0.875rem;
    border: 1px solid;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: normal;
    background: var(--bg-card);
    cursor: pointer;
    z-index: 2;
}
/* Horizontal connecting line (hidden in vertical mode) */
.chain-ring {
    display: none;
}
/* Station dot on vertical line */
.chain-node-wrapper::before {
    content: '';
    position: absolute;
    left: calc(-1.25rem - 6px);
    top: 0.875rem;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid currentColor;
    background: var(--card-bg, var(--bg-card, #1a1a2e));
    z-index: 3;
}
/* Default: text color */
.chain-node {
    border-color: color-mix(in srgb, var(--tertiary-accent) 60%, transparent);
    background-color: color-mix(in srgb, var(--tertiary-accent) 20%, transparent);
    color: color-mix(in srgb, var(--tertiary-accent) 70%, white);
}
/* Trigger: amber (where things went wrong) */
.chain-node-trigger {
    border-color: color-mix(in srgb, #f59e0b 70%, transparent);
    background-color: color-mix(in srgb, #f59e0b 15%, transparent);
    color: #f59e0b;
}
/* Outcome: severity-coded */
.chain-node-outcome {
    font-weight: 600;
}
.chain-node-outcome-safe {
    border-color: color-mix(in srgb, #4caf50 60%, transparent);
    background-color: color-mix(in srgb, #4caf50 15%, transparent);
    color: #4caf50;
}
.chain-node-outcome-damage {
    border-color: color-mix(in srgb, #f59e0b 70%, transparent);
    background-color: color-mix(in srgb, #f59e0b 15%, transparent);
    color: #f59e0b;
}
.chain-node-outcome-injury {
    border-color: color-mix(in srgb, #f59e0b 70%, transparent);
    background-color: color-mix(in srgb, #f59e0b 15%, transparent);
    color: #f59e0b;
}
.chain-node-outcome-fatal {
    border-color: color-mix(in srgb, #ef4444 75%, transparent);
    background-color: color-mix(in srgb, #ef4444 15%, transparent);
    color: #ef4444;
}
.chain-node-time {
    margin-left: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 400;
    opacity: 0.7;
}
.chain-node-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
}
.chain-node-indicator {
    margin-left: 0.375rem;
    color: var(--primary-accent);
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1;
}
.chain-node.has-detail {
    cursor: pointer;
}
.chain-node.has-detail:hover {
    border-color: var(--primary-accent);
}
.chain-node-detail {
    display: none;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-top: 0.375rem;
    padding: 0.375rem 0.625rem;
    background: color-mix(in srgb, var(--primary-accent) 8%, transparent);
    border-radius: 6px;
    text-align: left;
}
.chain-node-wrapper.expanded .chain-node-detail {
    display: block;
}


.card-link {
    color: var(--link-color);
    text-decoration: none;
}

.card-link:hover {
    text-decoration: underline;
}

.card-link:active {
    opacity: 0.7;
}

.weather-source {
    color: var(--text-secondary);
    font-size: 0.85em;
}

.weather-panel-section {
    margin-bottom: 0.5rem;
}

.weather-panel-section:last-child {
    margin-bottom: 0;
}

.weather-panel-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.125rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.weather-panel-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.weather-chart-container {
    position: relative;
    width: 100%;
    height: 200px;
    margin-bottom: 0.5rem;
}

@media (min-width: 600px) {
    .weather-chart-container {
        height: 250px;
    }
}

/* Expandable Content */
.card-expandable {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.card-expandable.expanded {
    max-height: 2000px;
    margin-top: 0.75rem;
}

.card-section-heading {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-primary);
    margin-top: 1rem;
    margin-bottom: 0.375rem;
}

.card-summary {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.card-sources {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.card-weather-summary,
.card-metar-display {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.card-weather-summary {
    margin-bottom: 0.125rem;
}

.card-metar-display {
    margin-bottom: 0.5rem;
}

.flag-btn {
    padding: 0.5rem 0.875rem;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    transition: all 0.2s ease;
}

.flag-btn:hover {
    border-color: var(--secondary-accent);
    color: var(--text-primary);
}

.flag-btn:active {
    background-color: var(--secondary-bg);
    border-color: var(--secondary-accent);
    color: var(--secondary-accent);
}

.card-bottom-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-bottom: 0.25rem;
}

.bookmark-btn-bottom {
    margin-top: 0;
    margin-right: 0.25rem;
}

