/* =========================================================
   TfL Bus Times — style.css
   Clean, London-inspired. Red, white, dark type.
   ========================================================= */

:root {
  --red:        #DC241F;
  --red-dark:   #B01C18;
  --red-light:  #FDECEA;
  --ink:        #1A1A1A;
  --ink-2:      #555555;
  --ink-3:      #888888;
  --surface:    #FFFFFF;
  --surface-2:  #F5F4F2;
  --surface-3:  #EEECE9;
  --border:     rgba(0,0,0,0.09);
  --border-md:  rgba(0,0,0,0.15);
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  22px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --font:       'DM Sans', system-ui, sans-serif;
  --mono:       'DM Mono', monospace;
  --transition: 0.18s ease;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--surface-2);
  color: var(--ink);
  min-height: 100vh;
  padding: 0 0 3rem;
}

/* ---- App container ---- */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0;
}

/* ---- Header ---- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.25rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* TfL Roundel */
.tfl-roundel {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.roundel-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 8px solid var(--red);
  background: white;
}

.roundel-bar {
  position: absolute;
  top: 50%;
  left: -6px;
  right: -6px;
  height: 11px;
  transform: translateY(-50%);
  background: var(--red);
}

.app-title {
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.app-sub {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 1px;
}

/* Geo button */
.geo-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--red-light);
  color: var(--red-dark);
  border: 1px solid rgba(220,36,31,0.2);
  border-radius: var(--radius-xl);
  padding: 7px 14px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.geo-btn:hover { background: #fad5d4; }
.geo-btn:active { transform: scale(0.97); }
.geo-btn.loading { opacity: 0.65; pointer-events: none; }

/* ---- Search ---- */
.search-section {
  padding: 1rem 1.25rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.search-row {
  display: flex;
  gap: 8px;
}

.search-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--ink-3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 42px;
  padding: 0 36px 0 38px;
  border: 1.5px solid var(--border-md);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: var(--surface-2);
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}

.search-input:focus {
  border-color: var(--red);
  background: white;
}

.search-input::placeholder { color: var(--ink-3); }

.search-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 13px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: none;
  line-height: 1;
}

.search-clear.visible { display: block; }
.search-clear:hover { color: var(--ink); background: var(--surface-3); }

.search-btn {
  height: 42px;
  padding: 0 20px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  flex-shrink: 0;
}

.search-btn:hover { background: var(--red-dark); }
.search-btn:active { transform: scale(0.97); }

.search-hint {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 8px;
  line-height: 1.5;
}

.search-hint strong { color: var(--ink-2); font-weight: 500; }

/* ---- Section shared ---- */
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink-3);
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.5rem;
}

.back-btn {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 13px;
  color: var(--red);
  cursor: pointer;
  padding: 2px 0;
  flex-shrink: 0;
}

.back-btn:hover { text-decoration: underline; }

/* ---- Nearby stop list ---- */
.stop-list-section {
  padding-bottom: 0.5rem;
}

.stop-list {
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  text-align: left;
  font-family: var(--font);
  width: 100%;
}

.stop-item:hover {
  border-color: var(--border-md);
  box-shadow: var(--shadow-sm);
}

.stop-item-badge {
  font-family: var(--mono);
  font-size: 10px;
  background: var(--surface-3);
  color: var(--ink-2);
  border-radius: 4px;
  padding: 3px 6px;
  flex-shrink: 0;
  white-space: nowrap;
}

.stop-item-name {
  flex: 1;
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stop-item-dist {
  font-size: 12px;
  color: var(--ink-3);
  flex-shrink: 0;
}

/* ---- Arrivals view ---- */
.arrivals-section {
  padding-bottom: 0;
}

.arrivals-stop-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.arrivals-stop-meta {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
  font-family: var(--mono);
}

/* Route filter chips */
.filter-row {
  display: flex;
  gap: 6px;
  padding: 0 1.25rem 0.75rem;
  flex-wrap: wrap;
}

.filter-chip {
  background: var(--surface);
  border: 1.5px solid var(--border-md);
  border-radius: var(--radius-xl);
  padding: 4px 12px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--transition);
}

.filter-chip:hover { border-color: var(--red); color: var(--red); }

.filter-chip.active {
  background: var(--red);
  border-color: var(--red);
  color: white;
}

/* Refresh row */
.refresh-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem 0.6rem;
}

.refresh-time {
  font-size: 12px;
  color: var(--ink-3);
}

.icon-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-xl);
  padding: 5px 12px;
  font-family: var(--font);
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--transition);
}

.icon-btn:hover { border-color: var(--red); color: var(--red); }
.icon-btn svg { transition: transform 0.4s ease; }
.icon-btn.spinning svg { transform: rotate(360deg); }

/* Arrivals list */
.arrivals-list {
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.arrival-card {
  display: flex;
  align-items: center;
  gap: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 13px 16px;
  animation: fadeUp 0.2s ease both;
}

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

.route-badge {
  background: var(--red);
  color: white;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  min-width: 48px;
  text-align: center;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}

/* Night buses */
.route-badge.night { background: #1a1a2e; }

.arrival-info { flex: 1; min-width: 0; }

.arrival-dest {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.arrival-towards {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.arrival-time-wrap {
  text-align: right;
  flex-shrink: 0;
  min-width: 44px;
}

.arrival-mins {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.arrival-mins.due { color: var(--red); }
.arrival-mins.soon { color: #e07020; }

.arrival-unit {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
}

/* Status messages */
.status-msg {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.6;
}

.status-msg.error { color: #c0392b; }

.status-msg .status-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 0.75rem;
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

.skeleton-card {
  height: 66px;
  border-radius: var(--radius-lg);
  margin-bottom: 7px;
}

/* Loading dots for search */
.status-msg .loading-dots::after {
  content: '';
  animation: dots 1.2s steps(3, end) infinite;
}
@keyframes dots {
  0%   { content: '.'; }
  33%  { content: '..'; }
  66%  { content: '...'; }
}

/* Responsive tweaks */
@media (max-width: 360px) {
  .header { padding: 1rem; }
  .search-section { padding: 0.875rem 1rem 0.75rem; }
  .arrivals-list, .stop-list { padding: 0 1rem; }
  .filter-row, .refresh-row, .section-header { padding-left: 1rem; padding-right: 1rem; }
}

/* =========================================================
   NEARBY STOPS
   ========================================================= */
.nearby-section { padding: 1.25rem 1.25rem 0; }
.nearby-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.nearby-list { display: flex; flex-direction: column; gap: 6px; }

.nearby-card {
  display: flex; align-items: center; gap: 13px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px 16px;
  cursor: pointer; text-align: left; width: 100%; font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.nearby-card:hover { border-color: var(--border-md); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.nearby-card:active { transform: scale(0.99); }

.nearby-card-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--red-light); color: var(--red);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.nearby-card-info { flex: 1; min-width: 0; }
.nearby-card-name { font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nearby-card-meta { margin-top: 4px; }
.nearby-card-dist { font-size: 11px; color: var(--ink-3); flex-shrink: 0; text-align: right; line-height: 1.4; }
.nearby-card-dist strong { display: block; font-size: 14px; font-weight: 500; color: var(--ink-2); }

.nearby-routes { display: flex; gap: 4px; flex-wrap: wrap; }
.nearby-route-pill { background: var(--red-light); color: var(--red-dark); font-family: var(--mono); font-size: 10px; font-weight: 500; border-radius: 3px; padding: 1px 5px; }

.location-prompt { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.75rem 1.25rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.location-prompt-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--red-light); color: var(--red); display: flex; align-items: center; justify-content: center; }
.location-prompt-title { font-size: 15px; font-weight: 500; color: var(--ink); }
.location-prompt-sub { font-size: 13px; color: var(--ink-3); line-height: 1.5; max-width: 260px; }
.location-prompt-btn { margin-top: 4px; height: 40px; padding: 0 20px; background: var(--red); color: white; border: none; border-radius: var(--radius-xl); font-family: var(--font); font-size: 14px; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: background var(--transition); }
.location-prompt-btn:hover { background: var(--red-dark); }
