/* Holubník – webová aplikácia
   Paleta: sivé perie holuba, bridlicový text, zelený a fialový lesk krku.
   Výrazný prvok je jediný: dúhová trasa letu na mape. Všetko ostatné je tiché. */

:root {
  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;

  --page: #e8ecf0;          /* perie */
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --ink: #1c2430;           /* bridlica */
  --muted: #5d6978;
  --line: #dde2e8;
  --neck: #157f68;          /* zelený lesk krku */
  --neck-hover: #106a56;
  --neck-soft: rgba(21, 127, 104, 0.11);
  --on-neck: #ffffff;
  --violet: #7650cf;        /* fialový lesk krku */
  --warn: #b0371f;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 10px 30px rgba(16, 24, 40, 0.14);

  --r-panel: 18px;
  --r-ctl: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #10151c;
    --surface: #171d26;
    --surface-2: #1f2732;
    --ink: #e7ebf1;
    --muted: #97a3b3;
    --line: #2a3441;
    --neck: #34b08f;
    --neck-hover: #46c3a1;
    --neck-soft: rgba(52, 176, 143, 0.14);
    --on-neck: #06231b;
    --violet: #a587ef;
    --warn: #f08a72;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--page);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
}
[hidden] { display: none !important; }

#map { position: fixed; inset: 0; }

/* ---------- typografia ---------- */
.brand {
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 0;
}
.brand.small { font-size: 1.3rem; }
.lede { margin: 0.4rem 0 1.4rem; color: var(--muted); }
h2 { font-size: 1rem; font-weight: 700; margin: 0 0 0.6rem; letter-spacing: -0.01em; }

/* ---------- ovládacie prvky ---------- */
label { display: block; font-size: 0.86rem; font-weight: 500; color: var(--muted); margin: 0.75rem 0 0.3rem; }
input, select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-ctl);
  padding: 0.6rem 0.75rem;
  transition: border-color 0.15s, background 0.15s;
}
input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
input:hover, select:hover { border-color: var(--line); }
input:focus, select:focus { outline: none; border-color: var(--neck); background: var(--surface); }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--neck) 45%, transparent); outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--neck-soft); }

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: var(--r-ctl);
  padding: 0.62rem 1rem;
  border: 1px solid transparent;
  cursor: pointer;
  margin-top: 1rem;
}
.btn.primary { background: var(--neck); color: var(--on-neck); }
.btn.primary:hover { background: var(--neck-hover); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: progress; }

.link, .row-action {
  font: inherit;
  background: none;
  border: 0;
  padding: 0.3rem 0;
  color: var(--neck);
  font-weight: 600;
  cursor: pointer;
}
.link:hover, .row-action:hover { text-decoration: underline; text-underline-offset: 3px; }
.row-action { font-size: 0.86rem; white-space: nowrap; }
.row-action.danger { color: var(--warn); }

.msg { font-size: 0.88rem; margin: 0.6rem 0 0; min-height: 1.2em; }
.msg.err { color: var(--warn); }
.msg.ok { color: var(--neck); }
.hint { font-size: 0.82rem; color: var(--muted); margin: 0.3rem 0 0; }

.check { display: flex; gap: 0.55rem; align-items: center; color: var(--ink); font-weight: 400; font-size: 0.9rem; margin: 0.9rem 0 0.4rem; cursor: pointer; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--neck); margin: 0; }

/* segmentové prepínače (záložky, obdobie) */
.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border-radius: 12px;
}
.seg button {
  flex: 1;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  padding: 0.5rem 0.4rem;
  cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"], .seg button[aria-checked="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12);
}
.seg.compact button { font-size: 0.85rem; padding: 0.38rem 0.3rem; }

/* ---------- prihlásenie ---------- */
.sheet {
  position: fixed;
  z-index: 5;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(400px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem 1.5rem;
}
.sheet .seg { margin-bottom: 0.25rem; }
.sheet .link { margin-top: 0.75rem; }

/* ---------- panel aplikácie ---------- */
.panel {
  position: fixed;
  z-index: 4;
  top: 16px;
  left: 16px;
  width: 380px;
  max-height: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem 1.25rem;
}
.brand-row { display: flex; align-items: baseline; gap: 0.75rem; }
.live { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.82rem; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.live.on .live-dot { background: var(--neck); box-shadow: 0 0 0 3px var(--neck-soft); }

.tabs { margin: 0 1rem; }
.panel-body { overflow-y: auto; padding: 0.75rem 1.25rem 1.25rem; overscroll-behavior: contain; }

/* menu účtu */
.menu { position: relative; }
.menu summary {
  list-style: none;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-weight: 700;
  color: var(--ink);
}
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { box-shadow: 0 0 0 2px var(--neck); }
.menu-pop {
  position: absolute;
  right: 0;
  top: 42px;
  z-index: 10;
  min-width: 230px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
}
.who { margin: 0.35rem 0.6rem 0.5rem; font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.menu-pop a, .menu-item {
  font: inherit;
  text-align: left;
  color: var(--ink);
  text-decoration: none;
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
}
.menu-pop a:hover, .menu-item:hover { background: var(--surface-2); }
.menu-item { color: var(--warn); border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; margin-top: 0.3rem; }

/* zoznamy */
.list { list-style: none; margin: 0.25rem 0 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.15rem 0.75rem;
  align-items: center;
  padding: 0.75rem 0;
}
.item.clickable { cursor: pointer; border-radius: 10px; margin: 0 -0.5rem; padding: 0.75rem 0.5rem; }
.item.clickable:hover { background: var(--surface-2); }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { grid-column: 2; font-size: 0.84rem; color: var(--muted); }
.item-side { grid-row: 1 / span 2; grid-column: 3; text-align: right; }
.item.no-lead { grid-template-columns: 1fr auto; }
.item.no-lead .item-sub { grid-column: 1; }
.item.no-lead .item-side { grid-column: 2; }

.swatch { grid-row: 1 / span 2; width: 6px; height: 34px; border-radius: 3px; background: var(--g); }

.stats { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; grid-column: 2 / span 2; margin-top: 0.35rem; font-size: 0.84rem; color: var(--muted); }
.stats b { color: var(--ink); font-weight: 600; }

.empty { color: var(--muted); font-size: 0.9rem; margin: 1rem 0; }

.block { border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: 1.25rem; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.75rem; }
.pair label { margin-top: 0.4rem; }

/* ---------- mapa ---------- */
.map-tools {
  position: fixed;
  z-index: 3;
  right: 12px;
  bottom: 40px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tool {
  min-width: 44px;
  height: 40px;
  padding: 0 0.7rem;
  display: grid;
  place-items: center;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--surface);
  border: 0;
  border-radius: var(--r-ctl);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.tool:hover { color: var(--neck); }
.tool[aria-pressed="true"] { color: var(--on-neck); background: var(--neck); }

.map-note {
  position: fixed;
  z-index: 6;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(560px, calc(100vw - 32px));
  margin: 0;
  padding: 0.7rem 1rem;
  background: var(--surface);
  color: var(--ink);
  border-left: 4px solid var(--warn);
  border-radius: var(--r-ctl);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}

/* bez Mapboxu: pokojné pozadie namiesto prázdnej mapy */
body.no-map #map {
  background:
    radial-gradient(1200px 700px at 70% 30%, color-mix(in srgb, var(--violet) 14%, transparent), transparent 60%),
    radial-gradient(900px 600px at 25% 80%, color-mix(in srgb, var(--neck) 14%, transparent), transparent 60%),
    var(--page);
}

/* aktuálna poloha holuba: obrázok natočený v smere letu */
.pin { position: relative; width: 46px; height: 46px; padding: 0; border: 0; background: none; cursor: pointer; }
.pin-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(var(--rot, 0deg));
  transition: transform 0.4s ease;
  pointer-events: none;
  user-select: none;
}
.pin-ring {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--c0) 35%, transparent), transparent 70%);
}
.pin.live .pin-ring::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--c0);
  animation: pulse 2.2s ease-out infinite;
}
.pin-label {
  position: absolute;
  top: 46px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font: 600 12px/1 var(--font);
  padding: 5px 8px;
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
@keyframes pulse {
  from { transform: scale(0.6); opacity: 0.9; }
  to { transform: scale(1.6); opacity: 0; }
}

/* popup Mapboxu v štýle aplikácie */
.mapboxgl-popup-content {
  font-family: var(--font);
  background: var(--surface);
  color: var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.75rem 0.9rem;
  min-width: 180px;
}
.mapboxgl-popup-tip { border-top-color: var(--surface) !important; border-bottom-color: var(--surface) !important; }
.mapboxgl-popup-close-button { color: var(--muted); font-size: 18px; padding: 2px 8px; }
.pop-title { font-weight: 700; margin: 0 1rem 0.15rem 0; }
.pop-sub { color: var(--muted); font-size: 0.84rem; margin: 0 0 0.5rem; }
.pop-grid { display: grid; grid-template-columns: auto auto; gap: 0.15rem 1rem; font-size: 0.86rem; margin: 0; }
.pop-grid dt { color: var(--muted); }
.pop-grid dd { margin: 0; font-weight: 600; text-align: right; }


/* ---------- tlačidlo Prehrať v zozname letov ---------- */
.play-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--neck);
  background: var(--neck-soft);
  border: 0;
  border-radius: 999px;
  padding: 0.35rem 0.75rem 0.35rem 0.6rem;
  cursor: pointer;
  white-space: nowrap;
}
.play-btn:hover { background: var(--neck); color: var(--on-neck); }

.tool-group { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }

/* ---------- prehrávač letu ---------- */
.player {
  position: fixed;
  z-index: 4;
  left: 412px;
  right: 76px;
  bottom: 16px;
  max-width: 920px;
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
  padding: 0.9rem 1.1rem 0.8rem;
}
.pl-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.9rem;
}
.pl-head .swatch { height: 36px; }
.pl-name { min-width: 0; }
.pl-title { margin: 0; font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-time { margin: 0.1rem 0 0; font-size: 0.84rem; color: var(--muted); }
.pl-read { display: flex; gap: 1.4rem; margin: 0; }
.pl-read div { min-width: 4.5rem; }
.pl-read dt { font-size: 0.76rem; color: var(--muted); }
.pl-read dd { margin: 0; font-size: 1.08rem; font-weight: 700; letter-spacing: -0.01em; }
.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { color: var(--warn); }

.pl-profile-wrap { position: relative; margin-top: 0.7rem; }
.pl-legend { display: flex; gap: 1rem; align-items: center; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.2rem; }
.lg { display: inline-flex; align-items: center; gap: 0.4rem; }
.lg::before { content: ""; display: inline-block; }
.lg-alt::before { width: 14px; height: 2px; border-radius: 1px; background: linear-gradient(90deg, #2bc39b, #4f86e3, #8b5cd6); }
.lg-ground::before { width: 10px; height: 10px; border-radius: 2px; background: color-mix(in srgb, var(--muted) 30%, transparent); }
.pl-range { margin-left: auto; }
.pl-profile { height: 72px; cursor: ew-resize; touch-action: none; }
.pl-profile svg { display: block; width: 100%; height: 72px; overflow: visible; }
.prof-ground { fill: color-mix(in srgb, var(--muted) 22%, transparent); }
.prof-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.prof-head { stroke: var(--ink); stroke-width: 1.5; }
.prof-hover { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.prof-dot { fill: var(--surface); stroke-width: 2.5; }
.pl-tip {
  position: absolute;
  top: -6px;
  transform: translate(-50%, -100%);
  margin: 0;
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
  white-space: nowrap;
  color: var(--ink);
  background: var(--surface);
  border-radius: 7px;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.pl-controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.9rem;
  margin-top: 0.6rem;
}
.pl-play {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--neck);
  color: var(--on-neck);
  cursor: pointer;
}
.pl-play:hover { background: var(--neck-hover); }
.pl-play .i-pause { display: none; }
.pl-play.is-playing .i-play { display: none; }
.pl-play.is-playing .i-pause { display: block; }
.pl-slider { width: 100%; padding: 0; background: none; border: 0; accent-color: var(--neck); height: 28px; cursor: pointer; }
.pl-slider:hover { border: 0; }
.pl-speed { min-width: 190px; }

.pl-opts { display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; align-items: center; margin-top: 0.4rem; }
.pl-opts .check { margin: 0; }
.pl-scale { display: flex; align-items: center; gap: 0.5rem; margin: 0; color: var(--ink); font-weight: 400; font-size: 0.9rem; }
.pl-scale select { width: auto; padding: 0.35rem 0.55rem; }

@media (max-width: 1100px) {
  .pl-head { grid-template-columns: auto minmax(0, 1fr) auto; }
  .pl-head .swatch { grid-row: 1; grid-column: 1; }
  .pl-name { grid-row: 1; grid-column: 2; min-width: 0; }
  #pl-close { grid-row: 1; grid-column: 3; }
  .pl-read { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; gap: 0.75rem; }
  .pl-read div { min-width: 0; }
}


/* ---------- skrytie panelu ---------- */
.head-actions { display: flex; align-items: center; gap: 0.5rem; }
.panel-toggle svg { transition: transform 0.2s; }
.panel.collapsed .panel-toggle svg { transform: rotate(180deg); }
.panel.collapsed .tabs,
.panel.collapsed .panel-body { display: none; }
.panel.collapsed .panel-head { padding-bottom: 1rem; }
.grabber { display: none; }
.panel-toggle:hover { color: var(--neck); }

/* ---------- mobil: panel ako spodný list ---------- */
@media (max-width: 720px) {
  body.playing .panel { display: none; }
  .grabber {
    display: grid;
    place-items: center;
    width: 100%;
    height: 22px;
    padding: 0;
    margin: 0;
    border: 0;
    background: none;
    cursor: grab;
    touch-action: none;
  }
  .grabber span { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
  .panel-toggle { display: none; }
  .panel .panel-head { padding-top: 0.15rem; }
  .panel.collapsed .panel-head { padding-bottom: 0.75rem; }
  .player { padding-top: 0; }
  .player.collapsed .pl-read,
  .player.collapsed .pl-profile-wrap,
  .player.collapsed .pl-opts,
  .player.collapsed .pl-speed { display: none; }
  .player { left: 0; right: 0; bottom: 0; border-radius: var(--r-panel) var(--r-panel) 0 0; padding-bottom: calc(0.8rem + env(safe-area-inset-bottom)); }
  .pl-controls { grid-template-columns: auto 1fr; }
  .pl-speed { grid-column: 1 / -1; }
  .map-tools { flex-wrap: wrap; right: 64px; gap: 5px; }
  .tool { min-width: 38px; height: 36px; padding: 0 0.55rem; }
  .tool-group { flex-direction: row; gap: 5px; margin-top: 0; }
  #btn-rot-left, #btn-rot-right { display: none; }
  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 56vh;
    border-radius: var(--r-panel) var(--r-panel) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel-head { padding-top: 0.85rem; }
  .map-tools { flex-direction: row; top: 12px; left: 12px; right: auto; bottom: auto; }
  .map-note { top: 64px; }
  .pair { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .pin.live .pin-ring::after { animation: none; opacity: 0.5; transform: none; }
  .pin-img { transition: none; }
  * { transition: none !important; }
}
