/* ==========================================================================
   iPad Ambient Smart Dashboard - Commute, Photos, Weather & Time
   ========================================================================== */

:root {
  --bg-color: #070b14;
  --bg-gradient: radial-gradient(circle at 15% 20%, #172554 0%, #0a0f1d 55%, #02040a 100%);
  --card-bg: rgba(15, 23, 42, 0.65);
  --card-border: rgba(255, 255, 255, 0.09);
  --card-border-glow: rgba(56, 189, 248, 0.25);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #38bdf8;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--card-border);
  --shadow-glow: 0 0 40px -10px rgba(56, 189, 248, 0.2);
  
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
}

/* Night / Bedside Ambient Dim Mode */
body.night-mode {
  --bg-color: #000000;
  --bg-gradient: #000000;
  --card-bg: rgba(18, 18, 18, 0.7);
  --card-border: rgba(255, 255, 255, 0.04);
  --text-primary: #f59e0b;
  --text-secondary: #b45309;
  --text-muted: #78350f;
  --accent-cyan: #d97706;
  --accent-blue: #b45309;
  --shadow-glow: none;
}

body.night-mode .photo-container {
  filter: brightness(0.35) contrast(0.9);
}

body.night-mode .badge-ontime {
  background: rgba(180, 83, 9, 0.2);
  color: #fbbf24;
  border-color: rgba(180, 83, 9, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: fixed;
  background: var(--bg-color);
  background-image: var(--bg-gradient);
  font-family: var(--font-family);
  color: var(--text-primary);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
}

/* Base App Layout */
#app {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 44% 56%;
  padding: 24px;
  gap: 20px;
  position: relative;
  transition: all 0.4s ease;
}

/* Quick Bar / Ambient Floating Controls */
.ambient-controls {
  position: absolute;
  top: 24px;
  right: 28px;
  display: flex;
  gap: 12px;
  z-index: 50;
  transition: opacity 0.5s ease;
}

.ambient-controls.idle {
  opacity: 0.2;
}

.ambient-controls:hover,
.ambient-controls.active {
  opacity: 1;
}

.ctrl-btn {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ctrl-btn:hover, .ctrl-btn:active {
  color: var(--text-primary);
  background: rgba(30, 41, 59, 0.8);
  border-color: var(--accent-cyan);
  transform: scale(1.05);
}

.ctrl-btn.active {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

/* ==========================================================================
   Left Column: Smart Dashboard Info (Clock, Commute, Weather)
   ========================================================================== */
.info-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  justify-content: space-between;
  overflow: hidden;
  z-index: 10;
}

/* Glass Card Base */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.3s ease, transform 0.2s ease;
  position: relative;
}

/* Clock Widget */
.clock-widget {
  padding: 16px 20px 12px 20px;
}

.clock-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.time-display {
  display: flex;
  align-items: baseline;
  font-weight: 300;
  letter-spacing: -2px;
  line-height: 1;
}

.time-hm {
  font-size: 5rem;
  font-weight: 200;
  letter-spacing: -3px;
}

.time-sec {
  font-size: 1.8rem;
  color: var(--accent-cyan);
  margin-left: 6px;
  font-weight: 400;
  font-family: var(--font-mono);
}

.time-ampm {
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 10px;
  letter-spacing: 0;
}

.date-display {
  margin-top: 6px;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.greeting-text {
  font-size: 0.95rem;
  color: var(--accent-cyan);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 2px;
}

/* Commute Widget (Train & Transit Focused) */
.commute-widget {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 200px;
}

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

.commute-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.commute-icon-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(59, 130, 246, 0.2));
  border: 1px solid rgba(56, 189, 248, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
}

.commute-title {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  color: var(--text-secondary);
}

.swap-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.swap-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.swap-btn:active {
  transform: scale(0.95);
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-cyan);
}

.swap-btn svg {
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.swap-btn.swapping svg {
  transform: rotate(180deg);
}

@keyframes swapFlash {
  0% {
    opacity: 0.4;
    transform: translateY(-4px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.route-info.swapped,
.departure-hero.swapped,
.upcoming-strip.swapped {
  animation: swapFlash 0.35s ease-out;
}

.route-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.25);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.station-nodes {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.15rem;
  font-weight: 600;
}

.station-arrow {
  color: var(--accent-cyan);
  font-size: 1.2rem;
}

.badge-ontime {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.badge-ontime::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Primary Live Train Departure Hero */
.departure-hero {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 4px 0 12px 0;
}

.countdown-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.countdown-label {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.countdown-mins {
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -1px;
  line-height: 1;
}

.countdown-unit {
  font-size: 1.3rem;
  color: var(--accent-cyan);
  font-weight: 500;
}

/* Transit Mode Selector (Southeastern High Speed vs Tube) */
.transit-mode-selector {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 12px;
}

.transit-mode-btn {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  border-radius: calc(var(--radius-sm) - 2px);
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.transit-mode-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.transit-mode-btn.active {
  background: rgba(0, 152, 212, 0.2);
  border-color: rgba(0, 152, 212, 0.45);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.transit-mode-btn[data-mode="tube"].active {
  background: rgba(105, 80, 161, 0.25);
  border-color: rgba(147, 51, 234, 0.5);
}

.mode-duration-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-cyan);
}

.transit-mode-btn.active .mode-duration-tag {
  background: rgba(16, 185, 129, 0.25);
  color: var(--accent-emerald);
}

.train-meta-box {
  text-align: right;
}

.train-line-badge {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #002f6c, #0077c8);
  border: 1px solid rgba(0, 152, 212, 0.4);
  padding: 3px 10px;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 4px;
  box-shadow: 0 2px 6px rgba(0, 47, 108, 0.3);
  transition: all 0.25s ease;
}

.train-line-badge.badge-tube {
  background: linear-gradient(135deg, #4a154b, #6950a1);
  border-color: rgba(147, 51, 234, 0.45);
  box-shadow: 0 2px 6px rgba(105, 80, 161, 0.35);
}

.train-times {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* Upcoming Departures Carousel/List */
.upcoming-strip {
  display: flex;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 10px;
}

.upcoming-pill {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.8rem;
  transition: background 0.2s;
}

.upcoming-pill .pill-time {
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

.upcoming-pill .pill-rel {
  font-size: 0.75rem;
  color: var(--accent-cyan);
}

/* Weather Widget */
.weather-widget {
  padding: 18px 22px;
}

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

.weather-current {
  display: flex;
  align-items: center;
  gap: 16px;
}

.weather-icon-large {
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.temp-large {
  font-size: 3.2rem;
  font-weight: 300;
  letter-spacing: -2px;
  line-height: 1;
}

.weather-details {
  display: flex;
  flex-direction: column;
}

.weather-condition {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

.weather-location {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.weather-stats {
  display: flex;
  gap: 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: right;
}

.stat-item span {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
}

/* Hourly Forecast Timeline */
.hourly-forecast {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  scrollbar-width: none;
}

.hourly-forecast::-webkit-scrollbar {
  display: none;
}

.hourly-item {
  flex: 0 0 58px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
}

.hourly-time {
  color: var(--text-secondary);
  font-weight: 500;
}

.hourly-icon {
  width: 26px;
  height: 26px;
}

.hourly-temp {
  font-weight: 600;
  color: var(--text-primary);
}

/* ==========================================================================
   Right Column: Ambient Google Photos Digital Frame
   ========================================================================== */
.photo-column {
  height: 100%;
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--card-border);
  background: #000;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.photo-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* Crossfade & Ken Burns layers */
.photo-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.4s ease-in-out;
  transform-origin: center center;
}

.photo-slide.active {
  opacity: 1;
}

/* Ken Burns Subtle Animation */
.kenburns-1 {
  animation: kenburns-effect-1 25s ease-in-out infinite alternate;
}

.kenburns-2 {
  animation: kenburns-effect-2 25s ease-in-out infinite alternate;
}

@keyframes kenburns-effect-1 {
  0% { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.08) translate(-1.5%, -1%); }
}

@keyframes kenburns-effect-2 {
  0% { transform: scale(1.08) translate(1%, -1%); }
  100% { transform: scale(1) translate(-1%, 1.5%); }
}

/* Ambient Vignette & Bottom Gradient */
.photo-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 65%, rgba(0, 0, 0, 0.4) 100%),
              linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 35%);
  pointer-events: none;
  z-index: 2;
}

/* Photo Caption / Album Meta */
.photo-caption-pill {
  position: absolute;
  bottom: 24px;
  left: 24px;
  z-index: 5;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 16px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-size: 0.85rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  max-width: 80%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.3s;
}

.photo-caption-icon {
  color: var(--accent-cyan);
}

.photo-album-tag {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

/* Photo Navigation Gestures / Controls */
.photo-nav-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  opacity: 0;
  transition: opacity 0.3s;
}

.photo-column:hover .photo-nav-overlay,
.photo-column:active .photo-nav-overlay {
  opacity: 1;
}

.photo-nav-btn {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s;
}

.photo-nav-btn:hover {
  transform: scale(1.1);
  background: rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   Full-Screen Photo Frame Mode (Tap to Maximize)
   ========================================================================== */
#app.photo-maximized {
  grid-template-columns: 0 100%;
  padding: 0;
  gap: 0;
}

#app.photo-maximized .info-column {
  display: none;
}

#app.photo-maximized .photo-column {
  border-radius: 0;
  border: none;
}

/* Floating HUD in Fullscreen Photo Mode */
.fullscreen-hud {
  display: none;
  position: absolute;
  top: 28px;
  left: 28px;
  z-index: 30;
  gap: 16px;
}

#app.photo-maximized .fullscreen-hud {
  display: flex;
  align-items: center;
}

.hud-pill {
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 10px 18px;
  border-radius: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Slide-Over Settings Modal
   ========================================================================== */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  display: flex;
  justify-content: flex-end;
}

.settings-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.settings-drawer {
  width: 480px;
  max-width: 90vw;
  height: 100%;
  background: #0f172a;
  border-left: 1px solid var(--card-border);
  padding: 32px 28px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.8);
}

.settings-overlay.open .settings-drawer {
  transform: translateX(0);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 16px;
}

.settings-title {
  font-size: 1.4rem;
  font-weight: 600;
}

.settings-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-cyan);
  font-weight: 600;
  margin-bottom: 12px;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input, .form-select {
  width: 100%;
  background: rgba(2, 6, 23, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 10px 14px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus {
  border-color: var(--accent-cyan);
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 12px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 12px;
  transition: opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.9;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid var(--accent-cyan);
  color: #fff;
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Responsive Adaptations for iPad Portrait / Smaller Screens
   ========================================================================== */
@media (max-width: 900px), (orientation: portrait) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    padding: 16px;
    gap: 14px;
    overflow-y: auto;
  }

  .time-hm {
    font-size: 3.8rem;
  }

  .countdown-mins {
    font-size: 2.5rem;
  }

  .photo-column {
    min-height: 380px;
  }
}
