/* Trasa – vzhľad vychádza z dopravného značenia: asfalt, modrá tabuľa, biela čiara, žltá obchádzka. */

:root {
  --asfalt: #1d2126;
  --asfalt-svetly: #343b45;
  --tabula: #17479e;
  --tabula-tmava: #0f3273;
  --dialnica: #0b7a4b;
  --obchadzka: #ffc629;
  --krajnica: #edf0f3;
  --linka: #d3d9e0;
  --tlmena: #5b6572;
  --chyba: #b3261e;
  --font: "Sofia Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-tabula: "Sofia Sans Condensed", "Sofia Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--asfalt);
  background: var(--krajnica);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

h1,
h2,
p,
ol,
ul,
fieldset {
  margin: 0;
  padding: 0;
}

ol,
ul {
  list-style: none;
}

fieldset {
  border: 0;
  min-width: 0;
}

:focus-visible {
  outline: 3px solid var(--tabula);
  outline-offset: 2px;
}

/* ---------- Rozloženie ---------- */

.app {
  display: grid;
  grid-template-columns: minmax(340px, 400px) 1fr;
  height: 100dvh;
}

.planner {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px 28px 20px;
  background: #fff;
  border-right: 1px solid var(--linka);
  overflow-y: auto;
}

.stage {
  position: relative;
  min-width: 0;
}

/* ---------- Hlavička ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-sign {
  flex: none;
  width: 54px;
  height: 54px;
}

.brand h1 {
  font-family: var(--font-tabula);
  font-weight: 800;
  font-size: 2.75rem;
  line-height: 0.95;
}

.brand p {
  margin-top: 3px;
  color: var(--tlmena);
  font-size: 0.95rem;
}

.demo-note {
  padding: 10px 12px;
  border-left: 5px solid var(--obchadzka);
  background: #fff8e0;
  font-size: 0.92rem;
}

/* ---------- Zadanie trasy: body ležia na „ceste" so stredovou čiarou ---------- */

.stops {
  position: relative;
  display: grid;
  gap: 14px;
  padding-left: 46px;
}

.stops::before {
  content: "";
  position: absolute;
  left: 0;
  top: 16px;
  bottom: 0;
  width: 30px;
  border-radius: 15px;
  background: var(--asfalt);
}

.stops::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 28px;
  bottom: 12px;
  width: 2px;
  background: repeating-linear-gradient(to bottom, #fff 0 9px, transparent 9px 18px);
}

.stop {
  position: relative;
}

.stop-mark {
  position: absolute;
  z-index: 1;
  left: -43px;
  bottom: 11px;
  width: 24px;
  height: 24px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--tabula);
  color: #fff;
  font: 800 0.85rem/20px var(--font-tabula);
  text-align: center;
}

.stop-stop .stop-mark {
  left: -39px;
  bottom: 15px;
  width: 16px;
  height: 16px;
  background: var(--obchadzka);
  border-color: var(--asfalt);
}

.stop label {
  display: block;
  margin-bottom: 4px;
  color: var(--tlmena);
  font-size: 0.84rem;
}

.stop input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1.5px solid var(--linka);
  border-radius: 8px;
  background: #fff;
}

.stop input:focus-visible {
  outline: 3px solid rgba(23, 71, 158, 0.25);
  outline-offset: 0;
  border-color: var(--tabula);
}

.stop input:disabled {
  background: var(--krajnica);
  color: var(--tlmena);
}

.stop-stop input {
  padding-right: 46px;
}

.stop-remove {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--tlmena);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.stop-remove:hover {
  background: var(--krajnica);
  color: var(--asfalt);
}

.suggestions {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 300px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--linka);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(29, 33, 38, 0.18);
}

.suggestions li {
  display: grid;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.suggestions strong {
  font-weight: 600;
}

.suggestions span {
  color: var(--tlmena);
  font-size: 0.86rem;
}

.suggestions li:hover,
.suggestions li[aria-selected="true"] {
  background: #e6edf9;
}

.form-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 12px 0 16px 46px;
  font-size: 0.92rem;
}

#route-form .btn {
  width: 100%;
}

/* ---------- Tlačidlá ---------- */

.btn {
  height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-sign {
  background: var(--tabula);
  color: #fff;
}

.btn-sign:hover:not(:disabled) {
  background: var(--tabula-tmava);
}

.btn-go {
  width: 100%;
  background: var(--obchadzka);
  color: var(--asfalt);
}

.btn-go:hover:not(:disabled) {
  background: #f5b800;
}

.btn-quiet {
  border: 1.5px solid var(--linka);
  background: transparent;
}

.btn-quiet:hover {
  border-color: var(--asfalt);
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--tabula);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.status {
  color: var(--tlmena);
  font-size: 0.95rem;
}

.status:empty {
  display: none;
}

.status.error {
  color: var(--chyba);
  font-weight: 600;
}

/* ---------- Výber trasy ---------- */

.planner h2 {
  margin-bottom: 8px;
  font-family: var(--font-tabula);
  font-weight: 800;
  font-size: 1.45rem;
  line-height: 1.1;
}

.route {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  align-items: baseline;
  width: 100%;
  padding: 14px 12px 14px 18px;
  border: 0;
  border-top: 1px solid var(--linka);
  background: none;
  text-align: left;
  cursor: pointer;
}

.route::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background: transparent;
}

.route:hover {
  background: #f6f8fa;
}

.route[aria-pressed="true"] {
  background: #edf2fb;
}

.route[aria-pressed="true"]::before {
  background: var(--tabula);
}

.route-time {
  font-family: var(--font-tabula);
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1;
}

.route-dist {
  color: var(--tlmena);
}

.route-name,
.plates,
.profile,
.route-facts {
  grid-column: 1 / -1;
}

.route-name {
  font-weight: 600;
}

.plates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.plates:empty {
  display: none;
}

.plate {
  padding: 2px 9px 1px;
  border-radius: 4px;
  background: var(--tabula);
  color: #fff;
  font: 600 0.86rem/1.4 var(--font-tabula);
  letter-spacing: 0.01em;
}

.plate-highway {
  background: var(--dialnica);
}

.plate-plain {
  background: var(--asfalt);
}

.profile {
  height: 8px;
  border-radius: 4px;
  background: #c5ccd5;
}

.route-facts {
  color: var(--tlmena);
  font-size: 0.88rem;
}

.legend {
  padding-top: 10px;
  border-top: 1px solid var(--linka);
  color: var(--tlmena);
  font-size: 0.82rem;
}

.legend span {
  display: inline-block;
  width: 18px;
  height: 8px;
  margin: 0 4px 0 0;
  border-radius: 4px;
  vertical-align: baseline;
}

.legend .legend-fast {
  background: var(--dialnica);
}

.legend .legend-slow {
  margin-left: 10px;
  background: #c5ccd5;
}

/* ---------- Nastavenie videa ---------- */

.detail {
  display: flex;
  border: 1.5px solid var(--linka);
  border-radius: 8px;
  overflow: hidden;
}

.detail legend {
  float: left;
  width: 100%;
  margin-bottom: 6px;
  color: var(--tlmena);
  font-size: 0.84rem;
}

.video-setup .detail {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 0;
  overflow: visible;
}

.video-setup .detail legend {
  grid-column: 1 / -1;
}

.detail label {
  position: relative;
}

.detail input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.detail span {
  display: block;
  padding: 9px 6px;
  border: 1.5px solid var(--linka);
  margin-left: -1.5px;
  text-align: center;
  font-weight: 600;
}

.detail label:first-of-type span {
  margin-left: 0;
  border-radius: 8px 0 0 8px;
}

.detail label:last-of-type span {
  border-radius: 0 8px 8px 0;
}

.detail input:checked + span {
  position: relative;
  border-color: var(--asfalt);
  background: var(--asfalt);
  color: #fff;
}

.detail input:focus-visible + span {
  outline: 3px solid var(--tabula);
  outline-offset: 2px;
}

.estimate {
  margin: 10px 0 14px;
  color: var(--tlmena);
  font-size: 0.92rem;
}

.planner-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--linka);
  color: var(--tlmena);
  font-size: 0.86rem;
}

.planner-foot p {
  margin-bottom: 4px;
}

/* ---------- Mapa ---------- */

.map {
  position: absolute;
  inset: 16px;
  border-radius: 14px;
  overflow: hidden;
  background: #dde3e8;
}

.sketch-map {
  display: block;
  width: 100%;
  height: 100%;
}

.app[data-state="setup"] .map,
.app[data-state="loading"] .map {
  display: none;
}

/* ---------- Video ---------- */

.viewer {
  display: none;
}

.app[data-state="video"] .stage {
  background: var(--asfalt);
}

.app[data-state="video"] .viewer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.app[data-state="video"] .map {
  z-index: 3;
  inset: 16px 16px auto auto;
  width: clamp(200px, 24%, 320px);
  height: clamp(150px, 27%, 230px);
  border: 3px solid #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.film-area {
  flex: 1;
  min-height: 0;
  container-type: size;
  display: grid;
  place-items: center;
}

.film {
  position: relative;
  width: min(100cqw, calc(100cqh * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--asfalt);
}

.film canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Tabuľa s najbližším manévrom – ako smerová značka pri ceste. */
.sign {
  position: absolute;
  left: 16px;
  top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(58%, 430px);
  padding: 13px 18px 12px 13px;
  border-radius: 12px;
  background: var(--tabula);
  box-shadow: inset 0 0 0 3px var(--tabula), inset 0 0 0 5.5px #fff, 0 6px 20px rgba(0, 0, 0, 0.35);
  color: #fff;
}

.sign-icon {
  flex: none;
  width: 54px;
  height: 54px;
}

.sign-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sign-body strong {
  display: block;
  font: 800 2rem/1 var(--font-tabula);
}

.sign-body span {
  display: block;
  margin-top: 3px;
  font-size: 0.98rem;
  line-height: 1.25;
}

.sign-body span:empty {
  display: none;
}

.film-msg {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 18px;
  border-radius: 8px;
  background: rgba(29, 33, 38, 0.86);
  color: #fff;
  font-weight: 600;
}

.film-date {
  position: absolute;
  left: 16px;
  bottom: 12px;
  color: #fff;
  font-size: 0.82rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-top: 1px solid var(--asfalt-svetly);
  background: var(--asfalt);
  color: #fff;
}

.controls :focus-visible {
  outline-color: var(--obchadzka);
}

.play {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--obchadzka);
  color: var(--asfalt);
  cursor: pointer;
}

.play svg {
  width: 22px;
  height: 22px;
}

#scrub {
  flex: 1;
  min-width: 0;
  accent-color: var(--obchadzka);
}

.progress {
  color: #c9d0d8;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ctl {
  height: 40px;
  padding: 0 14px;
  border: 1.5px solid #4a525d;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.ctl:hover {
  border-color: #fff;
}

#speed {
  min-width: 58px;
}

/* ---------- Prepojenie s Google Maps ---------- */

.setup {
  display: none;
}

.app[data-state="setup"] .setup {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  overflow: auto;
}

.app[data-state="setup"] #route-form {
  opacity: 0.45;
}

.setup-inner {
  max-width: 580px;
  padding: 36px;
  border: 1px solid var(--linka);
  border-radius: 16px;
  background: #fff;
}

.setup h2 {
  font-family: var(--font-tabula);
  font-weight: 800;
  font-size: 2.1rem;
  line-height: 1.05;
}

.setup-inner > p {
  margin-top: 12px;
}

.setup ol {
  display: grid;
  gap: 8px;
  margin: 18px 0 22px;
  padding-left: 1.3em;
  list-style: decimal;
}

.setup ol li::marker {
  font-weight: 700;
  color: var(--tabula);
}

.setup a {
  color: var(--tabula);
  font-weight: 600;
}

.setup label {
  display: block;
  margin-bottom: 4px;
  color: var(--tlmena);
  font-size: 0.84rem;
}

.key-row {
  display: flex;
  gap: 8px;
}

.key-row input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 12px;
  border: 1.5px solid var(--linka);
  border-radius: 8px;
}

.setup-error {
  margin-top: 8px;
  color: var(--chyba);
  font-weight: 600;
}

.setup-error:empty {
  display: none;
}

.hint {
  margin-top: 8px;
  color: var(--tlmena);
  font-size: 0.86rem;
}

.setup .btn-quiet {
  margin-top: 22px;
}

/* ---------- Mobil ---------- */

@media (max-width: 880px) {
  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
  }

  .planner {
    padding: 20px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--linka);
    overflow: visible;
  }

  .map {
    position: relative;
    inset: auto;
    height: 68dvh;
    margin: 12px;
  }

  .app[data-state="video"] .viewer {
    position: static;
  }

  .app[data-state="video"] .map {
    inset: auto;
    width: auto;
    height: 230px;
    border-width: 0;
    box-shadow: none;
  }

  .film-area {
    container-type: normal;
    display: block;
  }

  .film {
    width: 100%;
  }

  .sign {
    left: 8px;
    top: 8px;
    gap: 8px;
    max-width: 78%;
    padding: 10px 12px 9px 10px;
  }

  .sign-icon {
    width: 36px;
    height: 36px;
  }

  .sign-body strong {
    font-size: 1.35rem;
  }

  .sign-body span {
    font-size: 0.82rem;
  }

  .controls {
    flex-wrap: wrap;
    gap: 10px;
  }

  #scrub {
    order: -1;
    flex-basis: 100%;
  }

  .progress {
    flex: 1;
  }

  .app[data-state="setup"] .setup {
    position: static;
    padding: 12px;
  }

  .setup-inner {
    padding: 22px 18px;
  }

  .key-row {
    flex-direction: column;
  }
}

/* ---------- Režim bez kľúča: okná Street View a mapa OpenStreetMap ---------- */

.map {
  z-index: 0; /* vrstvy mapy Leaflet zostanú vnútri mapy */
}

.embeds {
  position: absolute;
  inset: 0;
}

.embeds iframe {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--asfalt);
}

/* Počas prehrávania sa do okna nedá kliknúť; po pozastavení sa v ňom dá rozhliadať. */
.embeds.is-playing iframe {
  pointer-events: none;
}

.app[data-video="canvas"] .embeds {
  display: none;
}

.film canvas {
  position: absolute;
  inset: 0;
}

.app[data-video="embed"] .film canvas {
  z-index: 5;
  pointer-events: none;
}

.sign,
.film-msg,
.film-date {
  z-index: 6;
}

/* Vľavo hore má okno Street View vlastnú tabuľku s adresou, tabuľa s manévrom ide dole. */
.app[data-video="embed"] .sign {
  top: auto;
  bottom: 16px;
}

.map-pin {
  box-sizing: border-box;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--asfalt);
  color: #fff;
  font: 700 13px/20px var(--font);
  text-align: center;
}

.map-car svg {
  display: block;
  width: 28px;
  height: 28px;
}

.leaflet-container {
  font-family: var(--font);
}

@media (max-width: 880px) {
  /* Na mobile by tabuľa dole zakryla logo Google, preto ide vpravo hore. */
  .app[data-video="embed"] .sign {
    top: 8px;
    right: 8px;
    bottom: auto;
    left: auto;
    max-width: 52%;
  }
}

/* V malej mapke pri videu tlačidlá priblíženia len zavadzajú. */
.app[data-state="video"] .leaflet-control-zoom {
  display: none;
}

/* Prepínač Autom / Pešo */
.travel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 16px;
  border: 0;
  overflow: visible;
}

.travel legend {
  grid-column: 1 / -1;
}

/* Výber druhu kľúča */
.key-kinds {
  display: grid;
  gap: 10px;
  margin: 18px 0 20px;
}

.setup .key-kinds legend {
  margin-bottom: 8px;
  color: var(--tlmena);
  font-size: 0.84rem;
}

.setup .key-kinds label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border: 1.5px solid var(--linka);
  border-radius: 8px;
  color: var(--asfalt);
  font-size: 0.95rem;
  cursor: pointer;
}

.key-kinds label:has(input:checked) {
  border-color: var(--tabula);
  background: #edf2fb;
}

.key-kinds input {
  margin-top: 4px;
  accent-color: var(--tabula);
}
