/* ============================================================
   TIER 3-4 FEATURES CSS
   Features: TfL Live Status, Exit Comparison, Crowding Prediction,
             Social Sharing Cards, Badges & Streaks System

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


/* ============================================================
   8. TfL LIVE STATUS BANNER
   Shows line-by-line service status on the home screen.
   Color-coded: green/amber/red. Tappable to expand detail.
   ============================================================ */

.tfl-status-banner {
  margin-bottom: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-card);
}

.tfl-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
  gap: 10px;
}
.tfl-status-header:active {
  background: var(--bg-card-hover);
}

.tfl-status-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.tfl-status-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.tfl-status-summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tfl-status-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tfl-status-time {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.tfl-status-chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.tfl-status-banner.expanded .tfl-status-chevron {
  transform: rotate(180deg);
}

/* Mini status dots in the header summary */
.tfl-status-dots {
  display: flex;
  gap: 3px;
  margin-left: 6px;
}

.tfl-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tfl-status-dot.good { background: var(--green); }
.tfl-status-dot.minor { background: var(--amber); }
.tfl-status-dot.severe { background: var(--red); }
.tfl-status-dot.suspended { background: var(--red); }
.tfl-status-dot.closed { background: var(--text-muted); }
.tfl-status-dot.other { background: var(--amber); }

/* Expanded line list */
.tfl-status-lines {
  display: none;
  border-top: 1px solid var(--border);
}
.tfl-status-banner.expanded .tfl-status-lines {
  display: block;
}

.tfl-status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.tfl-status-line:last-child {
  border-bottom: none;
}
.tfl-status-line:active {
  background: var(--bg-card-hover);
}

.tfl-status-line-color {
  width: 4px;
  height: 28px;
  border-radius: 2px;
  flex-shrink: 0;
}

.tfl-status-line-info {
  flex: 1;
  min-width: 0;
}

.tfl-status-line-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1px;
}

.tfl-status-line-detail {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1.3;
  display: none;
}
.tfl-status-line.show-detail .tfl-status-line-detail {
  display: block;
}

.tfl-status-line-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.tfl-status-line-badge.good {
  background: rgba(54,179,126,0.15);
  color: var(--green);
}
.tfl-status-line-badge.minor {
  background: rgba(255,171,0,0.15);
  color: var(--amber);
}
.tfl-status-line-badge.severe {
  background: rgba(255,86,48,0.15);
  color: var(--red);
}
.tfl-status-line-badge.suspended {
  background: rgba(255,86,48,0.2);
  color: var(--red);
}
.tfl-status-line-badge.closed {
  background: rgba(90,97,119,0.15);
  color: var(--text-muted);
}
.tfl-status-line-badge.other {
  background: rgba(255,171,0,0.12);
  color: var(--amber);
}

/* Offline / error state */
.tfl-status-offline {
  padding: 10px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Loading shimmer */
.tfl-status-loading {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.tfl-status-loading .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: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


/* ============================================================
   9. EXIT COMPARISON MODE
   Side-by-side cards comparing multiple exits at a station.
   Shows position, crowding estimate, walking time, recommended.
   ============================================================ */

.exit-comparison {
  margin-bottom: 20px;
}

.exit-comparison-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.exit-comparison-toggle {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  padding: 4px 8px;
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}
.exit-comparison-toggle:active {
  background: rgba(76,154,255,0.1);
}

.exit-comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
/* Single column on very narrow screens */
@media (max-width: 360px) {
  .exit-comparison-grid {
    grid-template-columns: 1fr;
  }
}

.exit-compare-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s, transform 0.1s, box-shadow 0.2s;
  position: relative;
}
.exit-compare-card:active {
  transform: scale(0.98);
}
.exit-compare-card.recommended {
  border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(54,179,126,0.2);
}

.exit-compare-recommended-tag {
  position: absolute;
  top: -8px;
  right: 12px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--green);
  color: #fff;
  padding: 2px 8px;
  border-radius: 8px;
  line-height: 1.4;
}

.exit-compare-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.exit-compare-position {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 14px;
  color: #fff;
  margin-bottom: 10px;
}
.exit-compare-position.front { background: var(--green); }
.exit-compare-position.middle { background: var(--amber); color: #1D3557; }
.exit-compare-position.back { background: var(--red); }

.exit-compare-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.exit-compare-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.exit-compare-stat-icon {
  font-size: 12px;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.exit-compare-stat-value {
  font-weight: 600;
  color: var(--text);
}

/* Crowding indicator dots */
.exit-compare-crowding {
  display: flex;
  gap: 3px;
  align-items: center;
}
.exit-compare-crowding-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bg-elevated);
}
.exit-compare-crowding-dot.active.quiet { background: var(--green); }
.exit-compare-crowding-dot.active.moderate { background: var(--amber); }
.exit-compare-crowding-dot.active.busy { background: var(--red); }


/* ============================================================
   10. CROWDING PREDICTION
   Time-of-day crowding estimates shown on result screen.
   Color-coded: green (quiet), amber (moderate), red (busy).
   ============================================================ */

.crowding-prediction {
  margin-top: 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 14px 16px;
  border: 1px solid var(--border);
}

.crowding-prediction-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.crowding-prediction-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.crowding-prediction-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.crowding-prediction-current {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.crowding-level-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
}

.crowding-bar {
  width: 4px;
  border-radius: 2px;
  background: var(--bg-card);
  transition: background 0.3s, height 0.3s;
}
.crowding-bar:nth-child(1) { height: 8px; }
.crowding-bar:nth-child(2) { height: 12px; }
.crowding-bar:nth-child(3) { height: 16px; }
.crowding-bar:nth-child(4) { height: 20px; }
.crowding-bar:nth-child(5) { height: 24px; }

.crowding-level-indicator.quiet .crowding-bar:nth-child(1),
.crowding-level-indicator.quiet .crowding-bar:nth-child(2) {
  background: var(--green);
}

.crowding-level-indicator.moderate .crowding-bar:nth-child(1),
.crowding-level-indicator.moderate .crowding-bar:nth-child(2),
.crowding-level-indicator.moderate .crowding-bar:nth-child(3) {
  background: var(--amber);
}

.crowding-level-indicator.busy .crowding-bar:nth-child(1),
.crowding-level-indicator.busy .crowding-bar:nth-child(2),
.crowding-level-indicator.busy .crowding-bar:nth-child(3),
.crowding-level-indicator.busy .crowding-bar:nth-child(4),
.crowding-level-indicator.busy .crowding-bar:nth-child(5) {
  background: var(--red);
}

.crowding-level-text {
  font-size: 14px;
  font-weight: 700;
}
.crowding-level-text.quiet { color: var(--green); }
.crowding-level-text.moderate { color: var(--amber); }
.crowding-level-text.busy { color: var(--red); }

.crowding-detail {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  font-weight: 500;
}

/* Crowding timeline bar */
.crowding-timeline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 32px;
  margin-top: 10px;
  padding-top: 4px;
}

.crowding-timeline-bar {
  flex: 1;
  border-radius: 2px 2px 0 0;
  min-height: 4px;
  transition: background 0.3s;
  position: relative;
}
.crowding-timeline-bar.quiet { background: rgba(54,179,126,0.4); height: 33%; }
.crowding-timeline-bar.moderate { background: rgba(255,171,0,0.4); height: 66%; }
.crowding-timeline-bar.busy { background: rgba(255,86,48,0.4); height: 100%; }
.crowding-timeline-bar.current {
  outline: 2px solid var(--text);
  outline-offset: -1px;
  border-radius: 2px;
}

.crowding-timeline-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.crowding-timeline-label {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 600;
}


/* ============================================================
   11. SOCIAL SHARING CARDS
   Enhanced share button with branded share text.
   Uses Web Share API with clipboard fallback.
   ============================================================ */

.share-card-btn {
  padding: 12px 20px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  background: rgba(76,154,255,0.08);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  color: var(--accent);
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, transform 0.1s;
}
.share-card-btn:active {
  background: rgba(76,154,255,0.15);
  transform: scale(0.97);
}

/* Share success toast */
.share-toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--green);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
  pointer-events: none;
  white-space: nowrap;
}
.share-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Share options menu */
.share-menu {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 20px 16px calc(16px + var(--safe-bottom, 0px));
  z-index: 150;
  transform: translateY(100%);
  transition: transform 0.3s ease-out;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.4);
}
.share-menu.visible {
  transform: translateY(0);
}

.share-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 140;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.share-menu-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.share-menu-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
  color: var(--text);
}

.share-menu-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.share-menu-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: none;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
  width: 100%;
  text-align: left;
}
.share-menu-option:active {
  background: var(--bg-card-hover);
}

.share-menu-option-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.share-menu-cancel {
  margin-top: 8px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}


/* ============================================================
   12. BADGES & STREAKS SYSTEM
   Gamification: consecutive day streaks, badge collection.
   Badge gallery accessible from nav/settings.
   ============================================================ */

/* Streak counter on home screen */
.streak-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.streak-counter:active {
  background: var(--bg-card-hover);
}
.streak-counter:empty {
  display: none;
}

.streak-flame {
  font-size: 18px;
  flex-shrink: 0;
}

.streak-number {
  font-size: 20px;
  font-weight: 900;
  background: linear-gradient(135deg, #FF6B35 0%, #FF3E00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

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

/* Badge earned notification */
.badge-notification {
  position: fixed;
  top: calc(16px + var(--safe-top, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(-120px);
  background: var(--bg-card);
  border: 1.5px solid var(--amber);
  border-radius: var(--radius);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 300;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease-out;
  max-width: calc(100vw - 32px);
}
.badge-notification.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.badge-notification-icon {
  font-size: 32px;
  flex-shrink: 0;
  animation: badgeBounce 0.6s ease-out 0.4s;
}

@keyframes badgeBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.3); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.badge-notification-text {
  flex: 1;
  min-width: 0;
}

.badge-notification-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--amber);
  margin-bottom: 2px;
}

.badge-notification-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

/* Badge collection screen */
.badges-screen-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.1s;
  position: relative;
}
.badges-screen-btn:active {
  background: var(--bg-card-hover);
  transform: scale(0.95);
}

.badges-screen-btn .badge-count-pip {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--amber);
  color: #1D3557;
  font-size: 9px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
}

/* Badge gallery modal */
.badges-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.badges-modal-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.badges-modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 85vh;
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 260;
  transform: translateY(100%);
  transition: transform 0.3s ease-out;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--safe-bottom, 0px);
}
.badges-modal.visible {
  transform: translateY(0);
}

.badges-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 12px;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
  border-bottom: 1px solid var(--border);
}

.badges-modal-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.badges-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.badges-modal-streak {
  padding: 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.badges-modal-streak-number {
  font-size: 42px;
  font-weight: 900;
  background: linear-gradient(135deg, #FF6B35 0%, #FF3E00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

.badges-modal-streak-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-top: 2px;
}

.badges-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 16px;
}

.badge-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 14px;
  text-align: center;
  transition: opacity 0.3s;
}
.badge-card.locked {
  opacity: 0.4;
}
.badge-card.earned {
  border-color: rgba(255,171,0,0.3);
  background: rgba(255,171,0,0.05);
}

.badge-card-icon {
  font-size: 36px;
  margin-bottom: 8px;
  display: block;
}
.badge-card.locked .badge-card-icon {
  filter: grayscale(100%);
}

.badge-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.badge-card-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  font-weight: 500;
}

.badge-card-progress {
  margin-top: 8px;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-card);
  overflow: hidden;
}

.badge-card-progress-bar {
  height: 100%;
  border-radius: 2px;
  background: var(--amber);
  transition: width 0.5s ease-out;
}

.badge-card-earned-date {
  font-size: 10px;
  color: var(--amber);
  font-weight: 600;
  margin-top: 6px;
}
