/* RC Search - SQLite WASM with pre-baked SVG cards */

/* =============================================================================
   SEARCH MODES (discovery ↔ quick)
   Signal-based swap - Datastar handles show/hide via data-show
   ============================================================================= */

/* Quick mode search bar */
.search-quick {
    padding: 0 4px;
}

.search-quick svg {
    width: 100%;
    display: block;
}

/* Animate input shrinking from full width to 2/3 */
.search-quick .quick-input-bg,
.search-quick .quick-input-border {
    animation: shrink-input 0.3s ease-out forwards;
}

@keyframes shrink-input {
    from { width: 360px; }
    to { width: 240px; }
}

/* =============================================================================
   SEARCH OVERLAY
   ============================================================================= */

/* Search overlay - slides up from bottom */
.search-overlay-rc {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #e8e8e8;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    max-width: 500px;
    margin: 0 auto;
}

.search-overlay-rc.active {
    transform: translateY(0);
}

/* Close button in SVG foreignObject */
.panel-close {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.panel-close svg {
    width: 20px;
    height: 20px;
    color: #989898;
}

.panel-close:hover svg {
    color: #585858;
}

/* Horizontal scroll for stations */
.stations-scroll {
    display: flex;
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
}

.stations-scroll::-webkit-scrollbar {
    display: none;
}

.station {
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    padding: 0;
}

/* Station panels - full width SVG */
.station[data-station="0"] {
    overflow: visible;
}

.station[data-station="0"] svg {
    width: 100%;
    display: block;
    overflow: visible;
}

.station[data-station="0"] svg foreignObject {
    overflow: visible;
}

.station[data-station="1"] svg,
.station[data-station="2"] svg {
    width: 100%;
    display: block;
}

/* Ghost input - invisible HTML input over SVG */
.ghost-input {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    outline: none;
    padding: 0 2rem 0 0.625rem;
    font: 16px var(--font-family);
    color: transparent;
    caret-color: #586878;
}

.ghost-input::placeholder {
    color: transparent;
}

@media (min-width: 768px) {
    .ghost-input {
        padding-left: 0.85rem;
    }
}

/* Clear button inside SVG foreignObject - needs to be HTML for touch events */
.svg-clear-btn {
    width: 32px;
    height: 32px;
    padding: 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

.svg-clear-btn svg {
    display: block;
}

/* Results area - scrollable */
.results-area {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem;
    min-height: 0;
}

#search-results {
    padding: 4px;
}

#search-results .fc {
    display: block;
    width: 100%;
    margin-bottom: 8px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#search-results .fc:hover {
    opacity: 0.9;
}

/* Remove expensive SVG filters for Safari performance */
#search-results .fc g[filter] {
    filter: none;
}

/* Flight card SVG typography */
.fc .id { font: 700 16px var(--font-family); fill: #202020; }
.fc .dt { font: 600 13px var(--font-family); fill: #585858; text-anchor: middle; }
.fc .al { font: 500 13px var(--font-family); fill: #585858; text-anchor: end; }
.fc .og { font: 500 13px var(--font-family); fill: #585858; }
.fc .ar { font: 500 13px var(--font-family); fill: #989898; text-anchor: middle; }
.fc .ds { font: 500 13px var(--font-family); fill: #585858; }
.fc .tm { font: 600 13px var(--font-family); fill: #202020; }

/* + button for adding flight */
.fc .add-btn {
    transition: transform 0.15s ease, fill 0.15s ease;
    transform-box: fill-box;
    transform-origin: center;
}

.fc:hover .add-btn {
    fill: #333;
    transform: scale(1.1);
}

/* SVG date buttons - two states only: default and selected */
.date-btn-svg {
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Date button selected state via CSS class */
.date-btn-svg.selected .date-btn-bg {
    fill: #586878;
    stroke: #4a5a68;
    stroke-width: 2;
}

.date-btn-svg.selected .date-day,
.date-btn-svg.selected .date-num,
.date-btn-svg.selected .date-month {
    fill: #ffffff;
}

/* SVG clear buttons */
.clear-btn {
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.clear-btn:hover circle {
    fill: #d8d8d8;
}

/* Autocomplete popover */
#ac-popover {
    position: fixed;
    margin: 0;
    padding: 0;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 3000;
    min-width: 200px;  /* Wider than input for city names */
}

#ac-popover:popover-open {
    display: block;
}

.ac-popover-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    gap: 12px;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ac-popover-item:last-child {
    border-bottom: none;
}

.ac-popover-item:hover {
    background: #f8f8f8;
}

.ac-popover-item .code {
    font-weight: 600;
    color: #202020;
    flex-shrink: 0;  /* Don't shrink airport code */
}

.ac-popover-item .detail {
    color: #585858;
    font-size: 13px;
    white-space: nowrap;  /* Keep city name on one line */
}
