/* ============================================================
   TIER 8B FEATURES CSS
   Features: Live Train Departures, Specific Door Numbers,
             Interchange Countdown Timer

   Integration: Add <link rel="stylesheet" href="/tier8b-features.css">
   to the <head> of index.html, or copy these styles into the
   existing <style> block.
   ============================================================ */


/* ============================================================
   FEATURE 1: LIVE TRAIN DEPARTURES
   Real-time TfL arrivals shown on result screen.
   Color-coded times, auto-refresh, shimmer loading.
   ============================================================ */

.t8b-departures-card {
  margin: 16px 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.t8b-departures-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.t8b-departures-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.t8b-departures-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.t8b-departures-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text);
}

.t8b-live-badge {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255, 86, 48, 0.15);
  color: var(--red);
  padding: 2px 7px;
  border-radius: 8px;
  animation: t8b-pulse 2s ease-in-out infinite;
}

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

.t8b-departures-refresh {
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: 4px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  border: none;
  background: none;
  line-height: 1;
}
.t8b-departures-refresh:active {
  color: var(--accent);
  background: rgba(76, 154, 255, 0.1);
}

.t8b-departures-body {
  padding: 0;
}

/* Loading shimmer */
.t8b-departures-loading {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.t8b-shimmer {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-card-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: t8b-shimmer-anim 1.5s ease-in-out infinite;
}

@keyframes t8b-shimmer-anim {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Departure groups */
.t8b-departure-group {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.t8b-departure-group:last-child {
  border-bottom: none;
}

.t8b-departure-direction {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.t8b-departure-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  gap: 8px;
}

.t8b-departure-towards {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.t8b-departure-time {
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  min-width: 50px;
  text-align: right;
}

.t8b-time-green { color: var(--green); }
.t8b-time-amber { color: var(--amber); }
.t8b-time-white { color: var(--text); }

/* Fallback state */
.t8b-departures-fallback {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.t8b-departures-fallback-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.t8b-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.t8b-link:hover {
  text-decoration: underline;
}

/* Compact departure badge (exits screen) */
.t8b-compact-departure {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  margin-bottom: 12px;
}

.t8b-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  flex-shrink: 0;
  animation: t8b-pulse 2s ease-in-out infinite;
}

.t8b-compact-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.t8b-compact-time {
  font-size: 13px;
  font-weight: 700;
}


/* ============================================================
   FEATURE 2: SPECIFIC DOOR NUMBERS
   Enhanced carriage/door info with numbered train diagram.
   ============================================================ */

.t8b-door-info {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.t8b-door-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.t8b-door-carriage {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}

.t8b-door-side {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.t8b-door-arrow {
  font-size: 14px;
  line-height: 1;
}

/* Numbered train diagram */
.t8b-train-numbered {
  display: flex;
  gap: 3px;
  margin-bottom: 8px;
}

.t8b-numbered-car {
  flex: 1;
  height: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}

.t8b-numbered-car:first-child {
  border-radius: 10px 4px 4px 10px;
}

.t8b-numbered-car:last-child {
  border-radius: 4px 10px 10px 4px;
}

.t8b-car-number {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
}

.t8b-car-highlight {
  background: var(--accent);
  border-color: var(--accent);
}

.t8b-car-highlight .t8b-car-number {
  color: #fff;
  font-weight: 800;
}

/* Door dot marker */
.t8b-door-dot {
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--bg-elevated);
  z-index: 1;
}

/* Stock info tooltip */
.t8b-door-tooltip {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  padding-top: 2px;
  opacity: 0.7;
}


/* ============================================================
   FEATURE 3: INTERCHANGE COUNTDOWN TIMER
   Walk times between lines, with live countdown overlay.
   ============================================================ */

.t8b-interchange-card {
  margin: 16px 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.t8b-interchange-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.t8b-interchange-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.t8b-interchange-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text);
}

.t8b-interchange-body {
  padding: 0;
}

.t8b-interchange-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.t8b-interchange-row:last-child {
  border-bottom: none;
}

.t8b-interchange-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.t8b-ic-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.t8b-ic-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.t8b-interchange-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.t8b-ic-time {
  font-size: 13px;
  font-weight: 700;
}

.t8b-ic-green { color: var(--green); }
.t8b-ic-amber { color: var(--amber); }
.t8b-ic-red { color: var(--red); }

.t8b-timer-start {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(76, 154, 255, 0.1);
  border: 1px solid rgba(76, 154, 255, 0.2);
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.1s;
}
.t8b-timer-start:active {
  background: rgba(76, 154, 255, 0.2);
  transform: scale(0.96);
}

/* Quick change / cross-platform badges */
.t8b-interchange-badge-row {
  margin-top: 6px;
}

.t8b-quick-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(54, 179, 126, 0.15);
  color: var(--green);
  letter-spacing: 0.3px;
}

.t8b-quick-badge.t8b-cross-platform {
  background: rgba(76, 154, 255, 0.12);
  color: var(--accent);
}

/* Interchange badge (exits screen) */
.t8b-interchange-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  margin-bottom: 12px;
  margin-left: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.t8b-badge-icon {
  font-size: 14px;
}

.t8b-badge-quick {
  font-size: 12px;
}

/* ---- COUNTDOWN TIMER OVERLAY ---- */

.t8b-timer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 500;
  transform: translateY(-100%);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: var(--bg-card);
  border-bottom: 2px solid var(--green);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.t8b-timer-overlay.t8b-timer-visible {
  transform: translateY(0);
}

.t8b-timer-overlay.t8b-timer-warning {
  border-bottom-color: var(--amber);
}

.t8b-timer-overlay.t8b-timer-urgent {
  border-bottom-color: var(--red);
  animation: t8b-timer-flash 1s ease-in-out infinite;
}

.t8b-timer-overlay.t8b-timer-over {
  border-bottom-color: var(--red);
  background: rgba(255, 86, 48, 0.08);
}

@keyframes t8b-timer-flash {
  0%, 100% { background: var(--bg-card); }
  50% { background: rgba(255, 86, 48, 0.08); }
}

.t8b-timer-content {
  max-width: 400px;
  margin: 0 auto;
}

.t8b-timer-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.t8b-timer-label strong {
  color: var(--text);
  font-weight: 700;
}

.t8b-timer-countdown {
  font-size: 32px;
  font-weight: 900;
  color: var(--green);
  letter-spacing: -1px;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.t8b-timer-warning .t8b-timer-countdown {
  color: var(--amber);
}

.t8b-timer-urgent .t8b-timer-countdown,
.t8b-timer-over .t8b-timer-countdown {
  color: var(--red);
}

.t8b-timer-progress-bg {
  height: 4px;
  border-radius: 2px;
  background: var(--bg-elevated);
  overflow: hidden;
  margin-bottom: 10px;
}

.t8b-timer-progress-bar {
  height: 100%;
  border-radius: 2px;
  background: var(--green);
  transition: width 1s linear, background 0.3s;
  width: 0%;
}

.t8b-timer-warning .t8b-timer-progress-bar {
  background: var(--amber);
}

.t8b-timer-urgent .t8b-timer-progress-bar,
.t8b-timer-over .t8b-timer-progress-bar {
  background: var(--red);
}

.t8b-timer-dismiss {
  display: block;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
  text-align: center;
}
.t8b-timer-dismiss:active {
  background: var(--bg-card-hover);
}

/* Success toast */
.t8b-timer-toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--green);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 600;
  opacity: 0;
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
  pointer-events: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.t8b-timer-toast.t8b-toast-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
