/* krypa.pl audioguide - modern CSS, mobile-first, no framework */

:root {
  --bg: #ffffff;
  --bg-secondary: #f5f4ef;
  --bg-tertiary: #ebeae3;
  --bg-accent: #e6f1fb;
  --text: #1a1a1a;
  --text-secondary: #5f5e5a;
  --text-tertiary: #888780;
  --text-accent: #0c447c;
  --border: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.2);
  --primary: #185fa5;
  --primary-text: #ffffff;
  --water: #b5d4f4;
  --success: #0f6e56;
  --warning: #ba7517;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --header-h: 56px;
  --player-h: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --bg-secondary: #242422;
    --bg-tertiary: #2e2e2c;
    --bg-accent: #0c2540;
    --text: #f5f4ef;
    --text-secondary: #b4b2a9;
    --text-tertiary: #888780;
    --text-accent: #85b7eb;
    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.24);
    --primary: #378add;
    --water: #042c53;
    --success: #5dcaa5;
    --warning: #efaf27;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}

[lang="ar"] body, [dir="rtl"] body {
  font-family: "Segoe UI", Tahoma, sans-serif;
}

img { max-width: 100%; height: auto; display: block; }

button {
  font: inherit;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  transition: background 0.15s, transform 0.05s;
}
button:hover { background: var(--bg-secondary); }
button:active { transform: scale(0.97); }
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

a { color: var(--text-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Visually hidden for a11y */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* === Layout === */

#app {
  max-width: 540px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

.view {
  padding-bottom: calc(var(--player-h) + var(--safe-bottom) + 1rem);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 0.75rem;
}

.topbar h1 {
  font-size: 1rem;
  font-weight: 500;
  margin: 0;
  flex: 1;
  text-align: center;
}

.topbar .icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text);
}
.topbar .icon-btn:hover { background: var(--bg-secondary); }

.content {
  padding: 1rem;
}

/* === Welcome view === */

.welcome {
  padding: 2rem 1.25rem 1.5rem;
  text-align: center;
}
.welcome__logo {
  max-width: 220px;
  margin: 0 auto 1.5rem;
}
.welcome__title {
  font-size: 1.5rem;
  font-weight: 500;
  margin: 0 0 0.25rem;
  line-height: 1.2;
}
.welcome__subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 0 0 1.5rem;
}
.welcome__map {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  overflow: hidden;
  width: 100%;
  height: 280px;
  margin: 0 0 1rem;
  position: relative;
}
.welcome__map.is-leaflet { padding: 0; }
.welcome__map svg { width: 100%; height: 100%; }
.route-water { stroke: var(--water); opacity: 0.7; }
.route-line { stroke: var(--primary); opacity: 0.6; }
.route-dot { fill: var(--primary); }
.welcome__meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 1.25rem;
}
.welcome__notice {
  background: var(--bg-accent);
  color: var(--text-accent);
  font-size: 0.9rem;
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  text-align: left;
  margin: 0 0 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0 1.25rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 500;
  width: 100%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}
.btn--primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn--primary:hover { background: var(--text-secondary); }
.btn--ghost { border: none; color: var(--text-secondary); font-weight: 400; min-height: 40px; }
.btn-stack > * + * { margin-top: 0.5rem; }

/* === Language picker === */

.lang-featured {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  margin: 0 0 1rem;
}
.lang-tile {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem 0.5rem;
  text-align: center;
  background: var(--bg);
  cursor: pointer;
  transition: border 0.15s, background 0.15s;
}
.lang-tile:hover { background: var(--bg-secondary); }
.lang-tile--featured { border-width: 2px; border-color: var(--primary); }
.lang-tile__code {
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.5px;
}
.lang-tile__name {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}
.search-box {
  position: relative;
  margin: 0 0 0.75rem;
}
.search-box input {
  width: 100%;
  font: inherit;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.75rem 0.65rem 2.25rem;
  color: var(--text);
}
.search-box input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.search-box .icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
}
.lang-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.lang-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 48px;
}
.lang-list li:hover { background: var(--bg-secondary); }
.lang-list .code { font-size: 0.8rem; color: var(--text-tertiary); }

/* === Stop list === */

.stops-list { list-style: none; padding: 0; margin: 0; }
.stops-list li {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  padding: 0.85rem 0.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  min-height: 56px;
}
.stops-list li:last-child { border-bottom: none; }
.stops-list li:hover { background: var(--bg-secondary); }
.stops-list .num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 500;
  flex: 0 0 32px;
}
.stops-list li.is-current { background: var(--bg-accent); }
.stops-list li.is-current .num { background: var(--primary); color: var(--primary-text); }
.stops-list li.is-current .stop-title { color: var(--text-accent); font-weight: 500; }
.stops-list li.is-done .num { background: var(--success); color: white; }
.stops-list .stop-body { flex: 1; min-width: 0; }
.stops-list .stop-title { font-size: 0.95rem; line-height: 1.3; }
.stops-list .stop-meta { font-size: 0.75rem; color: var(--text-tertiary); margin-top: 0.15rem; }

/* === Map view === */

#map {
  width: 100%;
  height: calc(100vh - var(--header-h) - var(--player-h) - var(--safe-bottom));
  height: calc(100dvh - var(--header-h) - var(--player-h) - var(--safe-bottom));
}
.map-popup {
  font-family: inherit;
  min-width: 180px;
}
.map-popup__title {
  font-weight: 500;
  font-size: 0.95rem;
  margin: 0 0 0.25rem;
}
.map-popup__meta {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin: 0 0 0.5rem;
}
.map-popup__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
}
.leaflet-popup-content-wrapper { border-radius: var(--radius-md); }

/* Custom map marker */
.stop-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--text-tertiary);
  color: white;
  font-weight: 500;
  font-size: 0.85rem;
  border: 2px solid white;
  box-shadow: var(--shadow);
}
.stop-marker--current { background: var(--primary); width: 36px; height: 36px; font-size: 0.9rem; }
.stop-marker--done { background: var(--success); }

.map-legend {
  position: absolute;
  bottom: calc(var(--player-h) + 12px + var(--safe-bottom));
  left: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.65rem;
  font-size: 0.75rem;
  display: flex;
  gap: 0.75rem;
  z-index: 10;
}
.map-legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* === Player view === */

.player-view .stop-image {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}
.player-view__title {
  font-size: 1.35rem;
  font-weight: 500;
  margin: 1rem 0 0.25rem;
  line-height: 1.25;
}
.player-view__subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}
.player-view__desc {
  font-size: 1rem;
  line-height: 1.7;
  margin: 0 0 1rem;
  color: var(--text);
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
}
.tag {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
}

/* === Bottom player bar === */

.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 0.6rem 0.75rem calc(0.6rem + var(--safe-bottom));
  z-index: 40;
  display: none;
}
.player-bar.is-visible { display: block; }
.player-bar__inner {
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.player-bar__playbtn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  border: none;
  flex: 0 0 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.player-bar__info { flex: 1; min-width: 0; }
.player-bar__title {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-bar__progress {
  height: 3px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin: 0.25rem 0;
}
.player-bar__progress > span {
  display: block;
  height: 100%;
  background: var(--primary);
  width: 0;
  transition: width 0.2s linear;
}
.player-bar__time {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* === Full player controls in view === */

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 0.5rem 0 1rem;
}
.player-controls button {
  background: transparent;
  border: none;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text);
}
.player-controls button:hover { background: var(--bg-secondary); }
.player-controls .play {
  width: 64px;
  height: 64px;
  background: var(--text);
  color: var(--bg);
}
.player-controls .play:hover { background: var(--text-secondary); }
.player-controls .skip {
  width: 48px;
  height: 48px;
  font-size: 0.75rem;
  font-weight: 500;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  margin: 0.25rem 0;
}
.progress-bar > span {
  display: block;
  height: 100%;
  background: var(--primary);
  width: 0;
}
.time-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  margin: 0 0 0.5rem;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.25rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
.action-row button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  font-size: 0.75rem;
  border: none;
  color: var(--text-secondary);
}
.action-row button:hover { background: var(--bg-secondary); }

/* === Bottom tab bar === */

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  z-index: 35;
  display: none;
}
.tabbar.is-visible { display: block; }
.tabbar__inner {
  max-width: 540px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 56px;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  text-decoration: none;
  padding: 0.4rem 0;
}
.tabbar a.is-active { color: var(--text-accent); }
.tabbar a svg { width: 22px; height: 22px; }

/* Adjust spacing when both player-bar + tabbar visible */
.has-player.has-tabbar #map {
  height: calc(100vh - var(--header-h) - var(--player-h) - 56px - var(--safe-bottom));
  height: calc(100dvh - var(--header-h) - var(--player-h) - 56px - var(--safe-bottom));
}
.has-player.has-tabbar .player-bar { bottom: 56px; }
.has-tabbar .view { padding-bottom: calc(56px + var(--safe-bottom) + 1rem); }
.has-player.has-tabbar .view { padding-bottom: calc(var(--player-h) + 56px + var(--safe-bottom) + 1rem); }

/* === Utilities === */

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.center { text-align: center; }
.hidden { display: none !important; }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* === Partner / cross-promo card === */
.partner-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fef5e7;
  color: #633806;
  border: 1px solid #fac775;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
  text-decoration: none;
  transition: transform 0.12s, background 0.12s;
}
.partner-card:hover { background: #fce8c8; text-decoration: none; }
.partner-card:active { transform: scale(0.99); }
.partner-card__icon {
  flex: 0 0 32px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #ba7517; color: #fff; border-radius: 50%;
}
.partner-card__icon svg { width: 18px; height: 18px; }
.partner-card__body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.partner-card__hook {
  font-weight: 500; font-size: 0.95rem; line-height: 1.2;
}
.partner-card__name {
  font-size: 0.8rem; opacity: 0.85;
}
.partner-card__cta {
  flex-shrink: 0;
  font-size: 0.85rem; font-weight: 500;
  white-space: nowrap;
}
@media (prefers-color-scheme: dark) {
  .partner-card { background: #3a2a10; color: #fac775; border-color: #854f0b; }
  .partner-card:hover { background: #4a3416; }
  .partner-card__icon { background: #efaf27; color: #2a1c00; }
}


/* === Cruise picker on welcome === */
.cruise-pick { display: flex; flex-direction: column; gap: 0.5rem; margin: 0 0 1rem; }
.cruise-pick__label {
  font-size: 0.85rem; color: var(--text-secondary);
  text-align: left; margin: 0 0 0.25rem;
}
.cruise-tile {
  display: flex; align-items: center; gap: 0.85rem;
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  font: inherit; color: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.cruise-tile:hover { background: var(--bg-secondary); border-color: var(--border-strong); }
.cruise-tile:active { transform: scale(0.99); }
.cruise-tile:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.cruise-tile__dur {
  flex: 0 0 64px;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--text); color: var(--bg);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 500; line-height: 1;
}
.cruise-tile__dur small {
  font-size: 0.65rem; font-weight: 400; opacity: 0.85; margin-top: 1px;
}
.cruise-tile__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cruise-tile__name { font-size: 1rem; font-weight: 500; }
.cruise-tile__desc { font-size: 0.8rem; color: var(--text-secondary); }
.cruise-tile__arrow { color: var(--text-tertiary); font-size: 1.25rem; flex: 0 0 auto; }
.welcome__lang-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.85rem; color: var(--text-secondary);
  margin-top: 0.5rem;
}

/* === Cruise badge in topbar === */
.cruise-badge {
  height: 32px;
  padding: 0 0.65rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.75rem; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px;
}
.cruise-badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary); display: inline-block;
}
.cruise-badge:hover { background: var(--bg-tertiary); }


/* === End of cruise view === */
.end-view {
  padding: 2rem 1.25rem 2rem;
  text-align: center;
  min-height: calc(100vh - 2rem);
  display: flex; flex-direction: column;
}
.end-view__hero { margin: 0.5rem 0 1.5rem; }
.end-view__check {
  width: 72px; height: 72px;
  margin: 0 auto 1rem;
  color: var(--success);
}
.end-view__check svg { width: 100%; height: 100%; }
.end-view__title {
  font-size: 1.75rem; font-weight: 500;
  margin: 0 0 0.5rem; line-height: 1.15;
}
.end-view__subtitle {
  color: var(--text-secondary);
  font-size: 1rem; margin: 0;
}
.end-view__stat {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin: 0 0 1.5rem;
}
.end-view__stat-num {
  font-size: 2.25rem; font-weight: 500; line-height: 1;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.end-view__stat-label {
  font-size: 0.85rem; color: var(--text-secondary);
  margin-top: 0.35rem;
}
.end-view__review {
  background: var(--bg-accent);
  border-radius: var(--radius-md);
  padding: 1.25rem 1rem;
  margin: 0 0 1rem;
}
.end-view__stars {
  font-size: 1.5rem; letter-spacing: 4px;
  color: #efaf27;
  margin-bottom: 0.75rem;
}
.end-view__review-text {
  font-size: 0.95rem;
  color: var(--text-accent);
  margin: 0 0 1rem;
  line-height: 1.5;
}
.end-view a.btn { text-decoration: none; }


/* === Marina invite on end screen === */
.end-view__marina {
  background: #fef5e7;
  color: #633806;
  border: 1px solid #fac775;
  border-radius: var(--radius-md);
  padding: 1.25rem 1rem;
  margin: 0.5rem 0 0;
  text-align: center;
}
.end-view__marina-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #ba7517;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.5rem;
}
.end-view__marina-text {
  font-size: 0.95rem;
  margin: 0 0 1rem;
  line-height: 1.4;
}
.btn.btn--marina {
  background: #ba7517;
  color: #fff;
  border-color: #ba7517;
  text-decoration: none;
}
.btn.btn--marina:hover { background: #854f0b; border-color: #854f0b; }
@media (prefers-color-scheme: dark) {
  .end-view__marina { background: #3a2a10; color: #fac775; border-color: #854f0b; }
  .end-view__marina-icon { background: #efaf27; color: #2a1c00; }
  .btn.btn--marina { background: #efaf27; color: #2a1c00; border-color: #efaf27; }
  .btn.btn--marina:hover { background: #fac775; border-color: #fac775; }
}

/* RTL */
[dir="rtl"] .topbar .icon-btn:first-child svg { transform: scaleX(-1); }
