/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0a0e17;
  --surface: rgba(12, 18, 30, 0.92);
  --border: rgba(255, 255, 255, 0.06);
  --text: #e0e6f0;
  --text-dim: #6b7a94;
  --accent: #00d4ff;
  --accent-glow: rgba(0, 212, 255, 0.4);
  --green: #22c55e;
  --amber: #f59e0b;
  --ferry-glow: rgba(0, 212, 255, 0.6);
  --stop-color: rgba(70, 182, 64, 0.8);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

[data-theme="harbour"] {
  --bg: #f5f3ec;
  --surface: rgba(255, 252, 245, 0.92);
  --border: rgba(0, 60, 30, 0.1);
  --text: #1a2a1a;
  --text-dim: #4a6040;
  --accent: #5AB031;
  --accent-glow: rgba(90, 176, 49, 0.4);
  --green: #5AB031;
  --amber: #F2C40C;
  --ferry-glow: rgba(242, 196, 12, 0.5);
  --stop-color: rgba(90, 176, 49, 0.8);
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ===== Map ===== */
#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* Hide MapLibre attribution but keep it accessible */
.maplibregl-ctrl-attrib { opacity: 0.3; font-size: 10px; }
.maplibregl-ctrl-attrib:hover { opacity: 1; }

/* ===== Top Bar ===== */
#top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 20px 12px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg) 85%, rgba(0,0,0,0) 100%);
  pointer-events: none;
}

#top-bar > * { pointer-events: auto; }

.top-bar-left, .top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-find { color: var(--text); }
.logo-sirius { color: var(--text); }

[data-theme="harbour"] .logo-find { color: #5AB031; }
[data-theme="harbour"] .logo-sirius { color: #F2C40C; }

.ferry-count {
  font-size: 13px;
  color: var(--text-dim);
  font-family: var(--mono);
}

.ferry-count span {
  color: var(--accent);
  font-weight: 600;
}

#theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: var(--font);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: color 0.2s;
  line-height: 1;
}
#theme-toggle:hover { color: var(--text); }

.app-version {
  font-size: 11px;
  color: var(--accent);
  opacity: 0.6;
  font-family: var(--mono);
}

/* ===== Ferry List ===== */
#ferry-list {
  position: fixed;
  top: 56px;
  left: 12px;
  bottom: 12px;
  width: 240px;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ferry-list-handle {
  display: none;
}

.ferry-list-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.ferry-list-header h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
}

.toggle input { display: none; }

.toggle input + .toggle-label::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 16px;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  vertical-align: middle;
  margin-right: 6px;
  transition: background 0.2s;
  position: relative;
}

.toggle input:checked + .toggle-label::before {
  background: var(--accent);
}

#ferry-list-items {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

#ferry-list-items::-webkit-scrollbar { width: 4px; }
#ferry-list-items::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.ferry-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}

.ferry-item:hover { background: rgba(255, 255, 255, 0.04); }
.ferry-item.active {
  background: rgba(0, 212, 255, 0.08);
  border-left-color: var(--accent);
}
.ferry-item.inactive { opacity: 0.35; }

.ferry-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
  flex-shrink: 0;
}

.ferry-item.inactive .ferry-dot {
  background: var(--text-dim);
  box-shadow: none;
}

.ferry-item-info {
  min-width: 0;
}

.ferry-item-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ferry-item-route {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Ferry Detail Card ===== */
#ferry-detail {
  position: fixed;
  bottom: 12px;
  right: 12px;
  width: 340px;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 20px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

#ferry-detail.hidden {
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
}

.detail-handle {
  display: none;
}

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

.detail-header h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

#detail-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

#detail-close:hover { color: var(--text); }

.detail-route {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 12px;
  font-family: var(--mono);
}

.detail-status {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 16px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}

.detail-stops {
  margin-bottom: 16px;
  font-size: 13px;
}

.detail-stops-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.detail-stop-main {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  color: var(--text);
}

.detail-stop-after {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  padding-left: 2px;
}

.detail-meta {
  display: flex;
  gap: 12px;
}

.meta-item {
  flex: 1;
  text-align: center;
}

.meta-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.meta-value {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--mono);
}

/* ===== Stop Labels ===== */
.stop-label {
  font-size: 11px;
  color: var(--stop-color);
  text-shadow: 0 0 8px rgba(0,0,0,0.8);
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
}

/* ===== Mobile Ferry List Toggle ===== */
#ferry-list-toggle {
  display: none;
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
  #top-bar { padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px; }
  .logo { font-size: 16px; }
  .ferry-count { font-size: 12px; }
  .app-version { display: none; }

  #ferry-list {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 45vh;
    border-radius: var(--radius) var(--radius) 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 250;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #ferry-list.mobile-open {
    transform: translateY(0);
  }

  .ferry-list-handle {
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 8px auto 4px;
  }

  #ferry-list-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    z-index: 200;
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font);
    transition: opacity 0.2s;
  }

  #ferry-list-toggle .toggle-icon {
    color: var(--accent);
    font-size: 16px;
  }

  #ferry-detail {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    max-height: 35vh;
    overflow-y: auto;
    z-index: 210;
  }

  #ferry-detail.hidden {
    transform: translateY(100%);
  }

  .detail-handle {
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 0 auto 8px;
    cursor: grab;
  }

  .detail-header { margin-bottom: 8px; }
  .detail-header h2 { font-size: 17px; }
  .detail-route { margin-bottom: 8px; font-size: 12px; }
  .detail-status { margin-bottom: 10px; padding: 6px 10px; font-size: 13px; }
  .detail-stops { margin-bottom: 10px; }

  #departures-board {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 40vh;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  #departures-board.hidden {
    transform: translateY(100%);
  }

  .departures-handle {
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 0 auto 8px;
  }

}

/* ===== Mobile overlay backdrop ===== */
#mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 240;
  opacity: 0;
  transition: opacity 0.3s;
}

#mobile-overlay.visible {
  display: block;
  opacity: 1;
}

/* ===== Animations ===== */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px var(--ferry-glow), 0 0 20px rgba(0, 212, 255, 0.15); }
  50% { box-shadow: 0 0 12px var(--ferry-glow), 0 0 30px rgba(0, 212, 255, 0.25); }
}

/* ===== Ferry HTML Labels ===== */
/* ===== Departures Board ===== */
#departures-board {
  position: fixed;
  bottom: 12px;
  right: 12px;
  width: 340px;
  max-height: 400px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  z-index: 200;
  overflow-y: auto;
  transition: opacity 0.3s, transform 0.3s;
}

#departures-board.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.departure-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.departure-item:last-child { border-bottom: none; }

.departure-ferry {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}

.departure-route {
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 2px;
}

.departure-status {
  text-align: right;
  font-size: 12px;
  color: var(--ferry-glow);
  white-space: nowrap;
}

.departure-status.stopped {
  color: #ff9f1c;
}

.departures-empty {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 16px 0;
}

.departures-handle {
  display: none;
}

/* ===== Timelapse Controls ===== */
#timelapse-btn {
  position: fixed;
  top: 70px;
  right: 12px;
  z-index: 200;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

#timelapse-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: var(--accent);
}

.timelapse-icon {
  font-size: 16px;
  color: var(--accent);
}

#timelapse-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 20px;
  width: min(640px, calc(100vw - 32px));
  transition: opacity 0.3s, transform 0.3s;
}

#timelapse-bar.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(20px);
}

.timelapse-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timelapse-track {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timelapse-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 2px;
}

.timelapse-labels #timelapse-time {
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}

#timelapse-slider {
  width: 100%;
  height: 6px;
  accent-color: var(--accent);
  cursor: pointer;
  border-radius: 3px;
}

#timelapse-play {
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-size: 16px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

#timelapse-play:hover {
  background: var(--accent-glow);
}

#timelapse-speed {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  flex-shrink: 0;
}

#timelapse-exit {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  flex-shrink: 0;
  font-family: var(--font);
  transition: all 0.2s;
}

#timelapse-exit:hover {
  background: rgba(255,80,80,0.15);
  border-color: rgba(255,80,80,0.4);
  color: #ff6b6b;
}

/* ===== Timelapse Mobile ===== */
@media (max-width: 768px) {
  #timelapse-btn {
    top: auto;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    right: 12px;
    padding: 8px 14px;
  }
  #timelapse-bar {
    bottom: env(safe-area-inset-bottom, 0px);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    width: calc(100vw - 16px);
    border-radius: 12px 12px 0 0;
  }
  .timelapse-row { flex-wrap: nowrap; gap: 8px; }
  .timelapse-labels { font-size: 10px; }
  .timelapse-labels #timelapse-time { font-size: 11px; }
  #timelapse-play { width: 32px; height: 32px; font-size: 12px; flex-shrink: 0; }
  #timelapse-speed { padding: 4px 8px; font-size: 11px; }
  #timelapse-exit { padding: 4px 8px; font-size: 11px; }
}

/* ===== About Button ===== */
#about-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: var(--font);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: color 0.2s;
  line-height: 1;
}
#about-toggle:hover { color: var(--text); }

/* ===== About Panel ===== */
#about-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(400px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  z-index: 400;
  overflow-y: auto;
  transition: opacity 0.3s, transform 0.3s;
}

#about-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.95);
}

.about-content p {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}

.about-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.about-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin-bottom: 6px;
}

.about-content a {
  color: var(--accent);
  text-decoration: none;
}

.about-content a:hover {
  text-decoration: underline;
}

.about-features {
  list-style: none;
  padding: 0;
}

.about-features li {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  padding: 4px 0;
}

.about-features li strong {
  color: var(--text);
}

@media (max-width: 768px) {
  #about-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    transform: none;
    border-radius: 16px 16px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    max-height: 70vh;
  }
  #about-panel.hidden {
    transform: translateY(20px);
  }
}

/* ===== Photo Upload Button ===== */
#photo-upload-btn {
  position: fixed;
  top: 150px;
  right: 12px;
  z-index: 200;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

#photo-upload-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: var(--accent);
}

.photo-icon {
  font-size: 16px;
}

/* ===== Photo Mode Bar ===== */
#photo-mode-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  padding: calc(12px + env(safe-area-inset-top, 0px)) 20px 12px;
  transition: opacity 0.3s;
}

#photo-mode-bar.hidden {
  opacity: 0;
  pointer-events: none;
}

.photo-mode-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.photo-mode-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

#photo-mode-result {
  flex: 1;
  font-size: 13px;
  color: var(--text);
}

#photo-mode-result strong {
  color: var(--accent);
}

#photo-mode-exit {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  flex-shrink: 0;
  font-family: var(--font);
  transition: all 0.2s;
}

#photo-mode-exit:hover {
  background: rgba(255,80,80,0.15);
  border-color: rgba(255,80,80,0.4);
  color: #ff6b6b;
}

/* ===== Photo Camera Marker ===== */
.photo-camera-marker {
  font-size: 28px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
  cursor: default;
}

/* ===== Photo Mode Mobile ===== */
@media (max-width: 768px) {
  #photo-upload-btn {
    top: auto;
    bottom: calc(52px + env(safe-area-inset-bottom, 0px));
    right: 12px;
    padding: 8px 14px;
  }
  #photo-mode-bar {
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
  }
  .photo-mode-row { gap: 8px; }
  .photo-mode-label { font-size: 12px; }
  #photo-mode-result { font-size: 12px; }
  #photo-mode-exit { padding: 4px 8px; font-size: 11px; }
}
