/**
 * Bus Stop Pages - Shared Styles (PROTOTYPE)
 *
 * Visual parity with /bus-routes/stop.html (the live stop page): same
 * cards, chips, arrival board and section styles. One template, two
 * behaviours: on phones JS collapses flag cards behind the sticky chip
 * bar (like the live page's tabs); on desktop and without JS everything
 * is visible and chips anchor-scroll.
 */

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

html { scroll-behavior: smooth; }

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: 20px;
}

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

/* ---- Site navigation (copy of the bus-routes chrome) ---- */
.site-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

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

.nav-logo {
    font-size: 1.4em;
    font-weight: 800;
    color: #667eea;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s ease;
}

.nav-logo:hover { color: #764ba2; }

.nav-links { display: flex; gap: 8px; flex-wrap: wrap; }

.nav-links a {
    padding: 10px 18px;
    color: #555;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95em;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.nav-links a:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    color: #667eea;
}

.nav-dropdown { position: relative; display: flex; align-items: center; }

.nav-drop-toggle {
    padding: 10px 18px;
    color: #555;
    font-weight: 600;
    font-size: 0.95em;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.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 {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    color: #667eea;
}

.nav-drop-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    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; white-space: nowrap; }

.nav-dropdown-start .nav-drop-menu { left: 0; right: auto; }

/* ---- Page container + header (stop.html look) ---- */
.container {
    max-width: 900px;
    width: 100%;
    margin: 20px auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 40px 50px;
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.3);
}

.stop-page-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 18px;
    border-bottom: 2px solid #e8e8e8;
}

.stop-page-header h1 {
    font-size: 1.5em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.stop-page-sub { color: #667; font-size: 0.9em; }

/* ---- Sticky stop chip bar (parity with stop.html .stop-tabs) ---- */
.stop-tabs {
    position: sticky;
    top: 0;
    z-index: 60;
    margin: 0 -50px 16px;
    padding: 10px 50px;
    background: rgba(255, 255, 255, 0.97);
}

.stop-tabs.stuck {
    border-bottom: 1px solid #eef0f4;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.stop-tabs-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
}

.stop-tabs-row::-webkit-scrollbar { display: none; }

.stop-tabs-row > :first-child { margin-left: auto; }

.stop-tabs-row > :last-child { margin-right: auto; }

.stop-tabs-word {
    align-self: center;
    font-weight: 800;
    color: #1d3557;
    font-size: 1em;
    white-space: nowrap;
    margin-right: 4px;
}

.stop-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    min-width: 44px;
    background: #fff;
    border: 1.5px solid #d9defb;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    color: #5563d6;
    font-size: 0.95em;
    white-space: nowrap;
    text-decoration: none;
    flex: 0 0 auto;
    max-width: 220px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.stop-tab:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.stop-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
    color: #fff;
}

/* ---- Flag card (parity with stop.html .stop-group) ---- */
.flag-card {
    margin-bottom: 20px;
    background: #fbfbfd;
    border: 1px solid #eef0f4;
    border-radius: 14px;
    padding: 14px;
    scroll-margin-top: 70px; /* anchor jumps clear the sticky bar */
}

/* Phones with JS: one card at a time, like the live page's tabs */
.tabs-mode .flag-card { display: none; }
.tabs-mode .flag-card.active { display: block; }

.flag-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.stop-letter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    padding: 6px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-weight: 800;
    border-radius: 10px;
    font-size: 0.95em;
}

.stop-dir { color: #555; font-size: 0.92em; }

.stop-dir .towards { color: #5563d6; font-weight: 600; }

.route-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }

.route-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background: #E41F1F;
    color: #fff;
    font-weight: 700;
    font-size: 0.85em;
    border-radius: 6px;
    text-decoration: none;
}

.route-chip.night { background: #1d3557; }

/* ---- First & last bus: an inset panel so it reads as its own
       section inside the stop card (same surface as the site's hint
       boxes), headed by an arrivals-board-style micro-label ---- */
.flb {
    margin-top: 14px;
    background: #f7f8fc;
    border: 1px solid #e7eafb;
    border-radius: 10px;
    padding: 6px 6px 4px;
}

.flb-title {
    font-weight: 700;
    color: #1d3557;
    font-size: 0.95em;
    padding: 4px 2px 8px;
}

/* 4 fixed columns (label + Mon-Fri + Sat + Sun) always fit a phone;
   each route's chip + destination is a full-width band row above them */
.flb-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-variant-numeric: tabular-nums;
}

.flb-table th {
    background: #1d3557;
    text-align: center;
    font-weight: 700;
    color: #fff;
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 7px 2px;
    white-space: nowrap;
}

.flb-table th.flb-corner {
    width: 20%;
    border-radius: 8px 0 0 8px;
}

.flb-table th:last-child { border-radius: 0 8px 8px 0; }

.flb-table td { padding: 5px 2px; vertical-align: middle; }

tr.flb-band td {
    padding: 9px 0 4px;
    border-top: 1px solid #e3e7f6;
}

.flb-table tbody tr.flb-band:first-child td {
    border-top: none;
}

.flb-dest {
    font-weight: 600;
    color: #1d3557;
    font-size: 0.88em;
    margin-left: 2px;
}

.flb-meta {
    color: #6b7280;
    font-size: 0.8em;
    margin-left: 2px;
    white-space: nowrap;
}

.flb-meta a {
    color: #5563d6;
    font-weight: 600;
    text-decoration: none;
}

.flb-meta a:hover { text-decoration: underline; }

.flb-cell {
    text-align: center;
    white-space: nowrap;
    font-size: 0.9em;
    color: #1d3557;
}

td.flb-lbl {
    color: #6b7280;
    font-size: 0.78em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    padding-left: 8px;
}

tr.flb-first .flb-cell { font-weight: 700; }

tr.flb-last td { padding-top: 0; }

tr.flb-last .flb-cell { color: #555; }

.flb-cell.flb-empty { color: #c3c8d4; font-weight: 400; }

.flb-terminus {
    margin-top: 12px;
    padding: 10px 12px;
    background: #f7f8fc;
    border: 1px solid #e7eafb;
    border-radius: 10px;
    color: #555;
    font-size: 0.88em;
    line-height: 1.5;
}

/* ---- Live arrivals board (parity with stop.html arrival cards) ---- */
.live-slot { margin-top: 10px; }

.arrivals-head {
    display: flex;
    gap: 10px;
    color: #6b7280;
    font-size: 0.78em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 4px 0;
    border-bottom: 1px solid #e8eaf1;
}

.arrivals-head .head-bus { min-width: 44px; }

.arrivals-head .head-destination { flex: 1; }

.arrival-card {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid #f0f1f5;
}

.arrival-route {
    min-width: 44px;
    text-align: center;
    padding: 3px 8px;
    background: #E41F1F;
    color: #fff;
    font-weight: 700;
    font-size: 0.85em;
    border-radius: 6px;
    text-decoration: none;
}

.arrival-route.night { background: #1d3557; }

.arrival-destination {
    flex: 1;
    color: #555;
    font-size: 0.9em;
    min-width: 0;
    overflow-wrap: anywhere;
}

.arrival-time {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85em;
    white-space: nowrap;
}

.arrival-time.due { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }

/* ---- Detail cards: rail / shops / nearby / reads / FAQ ---- */
.stop-card {
    margin: 4px 0 16px;
    background: #fbfbfd;
    border: 1px solid #eef0f4;
    border-radius: 14px;
    padding: 14px;
}

.stop-card h2 {
    font-size: 1.05em;
    color: #1d3557;
    margin-bottom: 10px;
}

/* Name takes the flexible space and wraps within it; the distance stays
   pinned right on the first line instead of dropping raggedly below */
.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    padding: 7px 0;
    border-top: 1px solid #f0f1f5;
}

.detail-row > .detail-name,
.detail-row > .shop-main { flex: 1; min-width: 0; }

.detail-row > .detail-meta { flex-shrink: 0; }

.detail-name { font-weight: 600; color: #1d3557; font-size: 0.92em; }

a.detail-name { color: #5563d6; text-decoration: none; }

a.detail-name:hover { text-decoration: underline; }

.detail-meta { color: #6b7280; font-size: 0.85em; }

/* Address dropdown: native <details>, no JS needed */
.shop-main { flex: 1; min-width: 0; }

.shop-addr {
    margin-top: 2px;
    font-size: 0.85em;
}

.shop-addr summary {
    cursor: pointer;
    color: #6b7280;
    font-size: 0.94em;
    list-style: none;
}

.shop-addr summary::-webkit-details-marker { display: none; }

.shop-addr summary::after { content: ' ▾'; }

.shop-addr[open] summary::after { content: ' ▴'; }

.shop-addr summary:hover { color: #5563d6; }

.shop-addr .addr-text { color: #555; padding-top: 2px; }

.attrib { margin-top: 10px; color: #6b7280; font-size: 0.75em; }

/* Good to know (parity with stop.html .stop-reads) ---- */
.stop-read-row {
    display: block;
    padding: 8px 0;
    border-top: 1px solid #f0f1f5;
    text-decoration: none;
}

.stop-read-title {
    display: block;
    font-weight: 600;
    color: #5563d6;
    font-size: 0.92em;
}

.stop-read-row:hover .stop-read-title { text-decoration: underline; }

.stop-read-sub {
    display: block;
    color: #6b7280;
    font-size: 0.85em;
    margin-top: 2px;
}

/* FAQ */
.faq-item { padding: 10px 0; border-top: 1px solid #f0f1f5; }

.faq-item h3 { font-size: 0.95em; color: #1d3557; margin-bottom: 4px; }

.faq-item p { color: #555; font-size: 0.9em; line-height: 1.5; }

/* Index page list */
.stop-index-list a {
    display: block;
    padding: 10px 4px;
    border-top: 1px solid #f0f1f5;
    color: #5563d6;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.95em;
}

.stop-index-list a:hover { text-decoration: underline; }

.stop-index-list .idx-meta { color: #6b7280; font-weight: 400; font-size: 0.85em; }

@media (max-width: 768px) {
    .container { padding: 24px 20px; margin: 10px; border-radius: 20px; }
    .stop-page-header h1 { font-size: 1.3em; }
    .stop-tabs { margin: 0 -20px 16px; padding: 8px 20px; }
    .flag-card { scroll-margin-top: 62px; }
}
