/* Last Trip — station live-arrivals page (shared styles)
   Mobile-first responsive layout. Keeps the original purple-gradient look
   while fixing horizontal overflow on multi-platform stations and tightening
   spacing / animation cost on small screens. */

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    padding-bottom: 40px;
    overflow-x: hidden;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Navigation Bar */
.main-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(250, 250, 255, 0.98) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.12), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
    border-bottom: 1px solid rgba(102, 126, 234, 0.1);
    animation: fadeInUp 0.4s ease-out;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.nav-logo {
    font-size: 1.8em;
    font-weight: 800;
    text-decoration: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.nav-logo:hover {
    transform: translateY(-3px) scale(1.02);
    filter: drop-shadow(0 6px 12px rgba(102, 126, 234, 0.4));
    background-position: 100% 0;
}

.nav-center {
    display: flex;
    align-items: center;
    gap: 40px;
    flex: 1;
    justify-content: center;
}

.nav-links {
    display: flex;
    gap: 32px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.nav-links a {
    white-space: nowrap;
}

.nav-links a {
    text-decoration: none;
    color: #444;
    font-weight: 600;
    font-size: 1.1em;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 10px 16px;
    border-radius: 8px;
}

.nav-links a:hover {
    color: #667eea;
    transform: translateY(-2px);
}

/* "Plan" and "Live" dropdowns keep the nav to one row on small screens */
.nav-dropdown { position: relative; display: flex; align-items: center; }
.nav-drop-toggle {
    color: #444;
    font-weight: 600;
    font-size: 1.1em;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.3s;
}
.drop-caret { font-size: 0.7em; margin-left: 5px; opacity: 0.75; }
.nav-dropdown:hover .nav-drop-toggle,
.nav-dropdown:focus-within .nav-drop-toggle,
.nav-drop-toggle.active { color: #667eea; }
.nav-drop-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: column;
    gap: 2px;
    min-width: 190px;
    padding: 8px;
    background: #ffffff;
    border: 1px solid rgba(102, 126, 234, 0.15);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    z-index: 1200;
}
.nav-dropdown:hover .nav-drop-menu,
.nav-dropdown:focus-within .nav-drop-menu { display: flex; }
.nav-links .nav-drop-menu a { display: block; font-size: 1em; padding: 10px 14px; }
.nav-links .nav-drop-menu a::before,
.nav-links .nav-drop-menu a::after { display: none; }
.nav-links .nav-drop-menu a:hover { transform: none; background: rgba(102, 126, 234, 0.08); }
.nav-links .nav-drop-menu a.active { color: #667eea; }

/* Article Container */
.article-container {
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 20px;
}

/* Back to Live Status Link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    font-weight: 600;
    margin-bottom: 30px;
    transition: all 0.3s ease;
}

.back-link:hover {
    color: white;
    transform: translateX(-4px);
}

/* Article Card */
.article-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 50px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    animation: fadeInUp 0.6s ease-out;
}

/* Station Header */
.station-header {
    text-align: center;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 30px;
    margin-bottom: 40px;
}

.station-title {
    font-size: 2.5em;
    font-weight: 800;
    color: #1d3557;
    margin-bottom: 10px;
    line-height: 1.15;
}

.station-subtitle {
    color: #667eea;
    font-size: 1.2em;
    font-weight: 600;
}

.last-updated {
    margin-top: 15px;
    color: #777;
    font-size: 0.9em;
}

/* Status indicator */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 16px;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 20px;
    color: #4caf50;
    font-weight: 600;
}

.status-dot {
    width: 10px;
    height: 10px;
    background: #4caf50;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Lines Container */
.lines-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

/* Line Card */
.line-card {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.02) 100%);
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.3s ease;
}

.line-header {
    font-size: 1.4em;
    font-weight: 800;
    color: #667eea;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Platform Grid within each line.
   min(100%, 340px) guarantees the column never demands more width than the
   container, so 3+ platform stations collapse cleanly instead of overflowing. */
.platforms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: 12px;
}

.platform-card {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.platform-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.12);
}

.platform-header {
    font-size: 1.05em;
    font-weight: 700;
    color: #1d3557;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(102, 126, 234, 0.15);
}

.train-item {
    background: rgba(248, 249, 250, 0.6);
    border-radius: 5px;
    padding: 6px 10px;
    margin-bottom: 4px;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 15px;
    align-items: center;
    border-left: 2px solid #667eea;
    transition: all 0.2s ease;
}

.train-item:hover {
    transform: translateX(3px);
    background: rgba(102, 126, 234, 0.08);
    border-left-color: #764ba2;
}

.train-destination {
    font-weight: 600;
    color: #1d3557;
    font-size: 0.95em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.train-minutes {
    font-weight: 700;
    color: #667eea;
    font-size: 0.95em;
    white-space: nowrap;
    min-width: 55px;
    text-align: right;
}

.train-clock {
    color: #777;
    font-size: 0.9em;
    white-space: nowrap;
    min-width: 45px;
    text-align: right;
}

.no-trains {
    text-align: center;
    padding: 20px;
    color: #777;
    font-style: italic;
    font-size: 0.9em;
}

.loading {
    text-align: center;
    padding: 30px;
    color: #667eea;
    font-size: 1em;
}

.error-message {
    background: rgba(244, 67, 54, 0.1);
    color: #f44336;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    border: 2px solid rgba(244, 67, 54, 0.2);
}

/* ===== Tablet / small-desktop ===== */
@media (max-width: 768px) {
    body { padding-bottom: 24px; }

    .article-container {
        margin: 24px auto;
        padding: 0 14px;
    }

    .nav-container { padding: 14px 18px; }
    .nav-logo { font-size: 1.5em; }
    .nav-links { gap: 18px; }
    .nav-links a { font-size: 1em; padding: 8px 12px; }

    .back-link { margin-bottom: 20px; }

    .article-card {
        padding: 26px 18px;
        border-radius: 16px;
    }

    .station-header {
        padding-bottom: 22px;
        margin-bottom: 26px;
    }

    .station-title { font-size: 1.9em; }
    .station-subtitle { font-size: 1.05em; }

    .line-card { padding: 14px; }
    .line-header { font-size: 1.3em; }

    /* Single column on phones — also overrides .multi-platform specificity */
    .platforms-grid { grid-template-columns: 1fr; }

    .train-destination { font-size: 0.9em; }
    .train-minutes { font-size: 1em; min-width: 48px; }
    .train-clock { font-size: 0.85em; min-width: 42px; }
}

/* ===== Phones ===== */
@media (max-width: 480px) {
    /* Stack the brand above the links so both stay usable on narrow screens */
    .nav-container {
        flex-direction: column;
        gap: 8px;
        padding: 12px 14px;
    }
    .nav-logo { font-size: 1.35em; }
    .nav-center { gap: 0; }
    .nav-links { gap: 10px; }
    .nav-links a { font-size: 0.95em; padding: 6px 10px; }

    .article-container {
        margin: 16px auto;
        padding: 0 10px;
    }

    .article-card {
        padding: 20px 13px;
        border-radius: 14px;
    }

    .station-title { font-size: 1.6em; }
    .station-subtitle { font-size: 1em; }
    .status-indicator { font-size: 0.9em; padding: 7px 14px; }

    .line-card { padding: 12px; }
    .line-header { font-size: 1.15em; }

    /* Let long destinations wrap rather than truncate on the narrowest screens */
    .train-item {
        gap: 8px 10px;
        padding: 8px 10px;
    }

    .train-destination {
        white-space: normal;
        line-height: 1.25;
    }

    .train-minutes { min-width: 44px; }
    .train-clock { min-width: 38px; }

    /* Hover transforms feel laggy on touch — neutralise them */
    .train-item:hover { transform: none; }
    .platform-card:hover { transform: none; }
}

/* Respect users who prefer less motion / save battery */
@media (prefers-reduced-motion: reduce) {
    body { animation: none; }
    .status-dot { animation: none; }
    .article-card, .main-nav { animation: none; }
    * { transition: none !important; }
}
