/* ============================================================
   DEFERRED STYLES — Loaded async after first paint
   Contains: results card, timeline, map, manifest, accordion,
   breakdown, history, tooltips, split-mode layout
   ============================================================ */

/* COMPACT RESULTS CARD - High contrast */
.results-card {
    background:
        linear-gradient(135deg, rgba(255, 149, 0, 0.25), rgba(75, 0, 130, 0.25)),
        rgba(15, 23, 42, 0.85);
    border: 2px solid #FF9500;
    padding: 14px;
}

.result-primary {
    text-align: center;
    padding: 12px 0;
}

.result-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.65);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 6px;
    font-weight: 700;
}

.result-value {
    font-size: 48px;
    font-weight: 900;
    color: #FF9500;
    line-height: 1;
    letter-spacing: -2px;
    text-shadow: 0 0 25px rgba(255, 149, 0, 0.4);
}

.result-explanation {
    font-size: 11px;
    color: #FFBF00;
    text-align: center;
    margin-top: 8px;
    font-weight: 600;
    font-style: italic;
    line-height: 1.4;
}

.result-secondary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.result-item {
    text-align: center;
}

.result-item-label {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-item-value {
    font-size: 18px;
    font-weight: 700;
    color: #FFF;
    margin-top: 4px;
}

/* PROPORTIONAL PREMIUM TIMELINE */
.timeline-container {
    position: relative;
    margin: 4px 0;
    padding: 28px 0 20px 0;
}

.timeline-bar {
    width: 100%;
    height: 32px;
    border-radius: 16px;
    display: flex;
    overflow: hidden;
    /* CLIPPING MASK - rounds all segment ends */
    background: linear-gradient(to bottom, #1e293b 0%, #0f172a 100%);
    position: relative;
    box-shadow:
        0 3px 16px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.timeline-segment {
    height: 100%;
    transition: width 0.3s ease;
    position: relative;
    /* NO border-radius - clipping mask handles it */
}

/* RICH & MUTED GRADIENTS (Flighty Style) */
.timeline-segment.day {
    background: linear-gradient(to right, #eab308 0%, #fef9c3 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.timeline-segment.twilight {
    background: linear-gradient(to right, #ea580c 0%, #ca8a04 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.timeline-segment.night {
    background: linear-gradient(to right, #0f172a 0%, #1e1b4b 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Inline duration labels - Premium Pill Style */
.segment-duration {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 12px;
    font-weight: 800;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.35);
    padding: 2px 8px;
    border-radius: 999px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

/* Inverted style for day segment */
.timeline-segment.day .segment-duration {
    color: rgba(0, 0, 0, 0.8);
    background: rgba(255, 255, 255, 0.4);
    text-shadow: none;
}

/* Smaller labels for narrow segments */
.timeline-segment .segment-duration.compact {
    font-size: 9px;
    padding: 1px 5px;
}

/* FLOATING PILL BADGES - Integrated Look */
.timeline-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: visible;
}

.floating-pill {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.floating-pill.above {
    bottom: calc(100% + 1px);
}

.floating-pill.below {
    top: calc(100% + 1px);
}

.pill-connector {
    width: 1.5px;
    height: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 1px;
}

.pill-label {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.8);
    padding: 3px 8px;
    border-radius: 999px;
    border: 0.5px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 4px;
}

.pill-icon {
    font-size: 10px;
    line-height: 1;
}

.pill-time {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.65);
    font-size: 10px;
}

/* AIRPLANE ICONS */
.timeline-endpoint {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    z-index: 10;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.timeline-endpoint.takeoff {
    left: 6px;
}

.timeline-endpoint.landing {
    right: 6px;
}

/* Edge time labels */
.timeline-ticks {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 18px;
    pointer-events: none;
}

.timeline-tick {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.timeline-tick.left {
    left: 0;
    transform: none;
    align-items: flex-start;
}

.timeline-tick.right {
    right: 0;
    left: auto;
    transform: none;
    align-items: flex-end;
}

.tick-label {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: rgba(148, 163, 184, 0.85);
    white-space: nowrap;
}

.timeline-waiting {
    width: 100%;
    height: 32px;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    font-style: italic;
    margin: 4px 0;
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 20px;
    font-weight: 600;
}

/* Compact inline legend */
.timeline-legend-inline {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 6px;
    font-size: 9px;
    font-weight: 600;
}

.legend-item-inline {
    display: flex;
    align-items: center;
    gap: 4px;
    color: rgba(255, 255, 255, 0.7);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.legend-dot.night {
    background: #3b0764;
}

.legend-dot.twilight {
    background: #f97316;
}

.legend-dot.day {
    background: #facc15;
}

/* Tooltip CSS removed - was not working properly */

.timeline-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 12px;
    font-size: 10px;
    font-weight: 600;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.8);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.legend-color.day {
    background: #facc15;
}

.legend-color.twilight {
    background: #f97316;
}

.legend-color.night {
    background: #3b0764;
}

/* SOLAR INTERCEPT MAP */
.map-card {
    padding: 12px;
}

.map-card #flightMap {
    width: 100%;
    height: 220px;
    border-radius: 8px;
    overflow: hidden;
    background: #c5d6e0;
}

/* Leaflet map overrides */
.leaflet-container {
    background: #c5d6e0 !important;
}

/* FLIGHT MANIFEST CARD */
.flight-manifest-card {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    gap: 16px;
    font-family: 'Inter', -apple-system, sans-serif;
}

.manifest-divider {
    background: rgba(255, 255, 255, 0.15);
}

.manifest-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.manifest-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.manifest-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.manifest-label {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.65);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.manifest-value {
    font-size: 12px;
    font-weight: 700;
    color: #FFFFFF;
    font-variant-numeric: tabular-nums;
}

.manifest-sub-value {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

.manifest-value.highlight {
    color: #FF9500;
    font-weight: 800;
    font-size: 14px;
}

.manifest-split {
    display: flex;
    gap: 12px;
    font-size: 12px;
}

.manifest-split-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.manifest-split-item.day {
    color: #facc15;
}

.manifest-split-item.night {
    color: #a855f7;
}

@media (max-width: 600px) {
    .flight-manifest-card {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 10px;
    }

    .manifest-divider {
        display: none;
    }

    .manifest-column {
        gap: 8px;
    }

    .manifest-row {
        gap: 2px;
    }

    .manifest-grid {
        grid-template-columns: 1.2fr 1fr;
        /* Preserve side-by-side where possible */
        gap: 12px;
    }

    .manifest-value {
        font-size: 14px;
    }
}

/* DUAL-RESULT 50/50 SPLIT CARD */
.dual-result-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0;
    margin-bottom: 12px;
}

.result-column {
    text-align: center;
    padding: 8px 12px;
}

.result-column-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.result-column-subtitle {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.result-column-value {
    font-size: 42px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}

.result-column-explanation {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.3;
}

.result-column.logbook .result-column-title {
    color: #6366f1;
}

.result-column.logbook .result-column-value {
    color: #6366f1;
}

.result-column.visual .result-column-title {
    color: #818cf8;
}

.result-column.visual .result-column-value {
    color: #818cf8;
}

.result-divider {
    width: 1px;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.2), transparent);
    margin: 10px 0;
}

.result-stats-row {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.result-stat {
    text-align: center;
}

.result-stat-label {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 2px;
}

/* COMPACT AIRPORT CARDS */
.airport-detail-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
}

.airport-detail-card {
    background: linear-gradient(135deg, rgba(255, 149, 0, 0.08), rgba(0, 0, 0, 0.4));
    border-radius: 10px;
    padding: 12px;
    border: 1px solid rgba(255, 149, 0, 0.2);
}

.airport-detail-header {
    font-size: 24px;
    font-weight: 900;
    color: #FF9500;
    margin-bottom: 6px;
    letter-spacing: 1px;
}

.airport-coords {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 10px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    min-height: 2.4em;
}

.sun-data-item {
    font-size: 10px;
    margin: 5px 0;
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sun-data-label {
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    gap: 4px;
}

.sun-data-time {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    color: #FFF;
}

.sun-data-time.critical {
    color: #f59e0b;
    font-weight: 800;
}

.results-section.visible {
    display: block;
    opacity: 1;
    transform: translateX(0);
    pointer-events: all;
}

/* SOLAR INTERCEPT MAP */
#flightMap {
    height: 300px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    overflow: hidden;
    margin-bottom: 10px;
}

.map-card {
    background: rgba(20, 25, 35, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 12px;
    flex: 1;
}

/* MAP AND BREAKDOWN SIDE BY SIDE */
.map-breakdown-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    min-height: 200px;
}

.map-breakdown-row .map-card {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

.map-breakdown-row .map-card #flightMap {
    height: 220px;
    min-height: 180px;
}

.breakdown-card {
    flex: 1;
    min-width: 0;
    background: rgba(20, 25, 35, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.breakdown-card .calculation-breakdown {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.breakdown-card .section-title {
    margin-bottom: 8px;
}

.leaflet-popup-content-wrapper {
    background: rgba(20, 25, 35, 0.95);
    color: #fff;
    border-radius: 8px;
    border: 1px solid rgba(255, 149, 0, 0.3);
}

.leaflet-popup-tip {
    background: rgba(20, 25, 35, 0.95);
}

.leaflet-popup-content {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
}

/* HOW WAS THIS CALCULATED - FRIENDLY EXPLANATION */
.calculation-breakdown {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.breakdown-title {
    color: #FF9500;
    font-weight: 700;
    font-size: 11px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.breakdown-step {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border-left: 2px solid rgba(255, 149, 0, 0.4);
}

.breakdown-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.breakdown-text {
    font-size: 10px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.85);
}

.accuracy-note {
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(74, 222, 128, 0.08);
    border: 1px solid rgba(74, 222, 128, 0.2);
    border-radius: 6px;
    font-size: 9px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.7);
}

.accuracy-badge {
    display: inline-block;
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 4px;
    font-size: 9px;
}

/* RESPONSIVE: Stack on narrow screens */
@media (max-width: 1400px) {
    .map-breakdown-row .map-card #flightMap {
        height: 160px;
    }

    .breakdown-step {
        padding: 5px 6px;
        margin-bottom: 4px;
    }

    .breakdown-text {
        font-size: 9px;
    }
}

@media (max-width: 1200px) {
    .map-breakdown-row {
        flex-direction: column;
        min-height: auto;
    }

    .map-breakdown-row .map-card #flightMap {
        height: 180px;
    }

    .breakdown-card {
        padding: 12px;
    }

    .breakdown-step {
        padding: 8px 10px;
        margin-bottom: 8px;
    }

    .breakdown-text {
        font-size: 11px;
    }

    .accuracy-note {
        font-size: 10px;
    }
}

/* MOBILE TIMELINE AND MAP FIXES */
@media (max-width: 600px) {

    /* Result card - align times on same level */
    .result-column {
        padding: 6px 8px;
    }

    .result-column-title {
        font-size: 9px;
        min-height: 30px;
    }

    .result-column-subtitle {
        font-size: 8px;
        min-height: 14px;
        margin-bottom: 4px;
    }

    .result-column-value {
        font-size: 32px;
    }

    .result-column-explanation {
        font-size: 8px;
        min-height: 40px;
    }

    /* Timeline container */
    .timeline-container {
        padding: 20px 0 16px 0;
    }

    /* Hide floating pills on mobile - they overlap */
    .floating-pill {
        display: none;
    }

    /* Make timeline bar taller for touch */
    .timeline-bar {
        height: 28px;
        border-radius: 14px;
    }

    /* Smaller airplane icons */
    .timeline-endpoint {
        font-size: 10px;
    }

    .timeline-endpoint.takeoff {
        left: 4px;
    }

    .timeline-endpoint.landing {
        right: 4px;
    }

    /* Simplify timeline label at edges */
    .tick-label {
        font-size: 9px;
    }

    /* Legend improvements */
    .timeline-legend-inline {
        flex-wrap: wrap;
        gap: 8px;
        font-size: 8px;
    }

    /* Map fixes */
    .map-card #flightMap {
        height: 200px !important;
        min-height: 180px;
    }

    /* Timeline labels row */
    .timeline-labels {
        font-size: 9px;
    }

    /* Section header fixes */
    .glass-panel h3 {
        font-size: 11px;
    }
}

/* HELP FOOTER ACCORDION */
.help-footer {
    margin-top: 30px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.help-footer-title {
    font-size: 12px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.accordion-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.accordion-item:last-child {
    border-bottom: none;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    cursor: pointer;
    transition: color 0.2s ease;
}

.accordion-header:hover {
    color: #FF9500;
}

.accordion-header-text {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
}

.accordion-icon {
    font-size: 16px;
}

.accordion-chevron {
    transition: transform 0.3s ease;
    opacity: 0.5;
}

.accordion-item.open .accordion-chevron {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.accordion-item.open .accordion-content {
    max-height: 400px;
    padding-bottom: 12px;
}

.accordion-body {
    font-size: 12px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.75);
    padding-left: 26px;
}

.accordion-body strong {
    color: #FF9500;
}

.accordion-body ul {
    margin: 8px 0;
    padding-left: 20px;
}

.accordion-body li {
    margin-bottom: 4px;
}

.accordion-body .highlight-box {
    background: rgba(255, 149, 0, 0.1);
    border-left: 3px solid #FF9500;
    padding: 10px 12px;
    margin: 10px 0;
    border-radius: 0 6px 6px 0;
}

/* CONTEXTUAL TOOLTIPS */
.tooltip-trigger {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.4);
}

.tooltip-trigger::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 25, 35, 0.95);
    color: #fff;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.5;
    min-width: 220px;
    max-width: 320px;
    width: max-content;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 100;
    border: 1px solid rgba(255, 149, 0, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.tooltip-trigger:hover::after {
    opacity: 1;
    visibility: visible;
}

/* SPLIT-MODE LAYOUT */
.app-container.split-mode {
    max-width: 1400px;
    display: grid;
    grid-template-columns: 40% 60%;
    gap: 20px;
    align-items: start;
}

.split-mode .app-header {
    grid-column: 1 / -1;
}

/* RESPONSIVE SPLIT-MODE */
@media (max-width: 1200px) {
    .app-container.split-mode {
        display: flex;
        flex-direction: column;
        max-width: 480px;
        margin: 0 auto;
        gap: 20px;
    }

    .results-section {
        transform: translateY(20px);
    }

    .results-section.visible {
        transform: translateY(0);
    }
}