:root {
  --navy-deep: #071b2e;
  --navy: #0e2f4d;
  --navy-mid: #17436a;
  --teal: #12777f;
  --teal-light: #1fa3ad;
  --brass: #c9a35b;
  --brass-light: #ecd9ab;
  --fog: #eef3f6;
  --white: #ffffff;
  --ink: #10202c;
  --muted: #63727d;
  --unknown: #a2acb3;
  --border: #d7e1e8;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--fog);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2 {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  margin: 0;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  background: var(--navy-deep);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 2px solid var(--teal-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar__anchor {
  font-size: 1.9rem;
  color: var(--brass-light);
}

.topbar h1 {
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.topbar__tagline {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: #b9cbdb;
}

.topbar__filters-toggle {
  display: none;
  background: var(--navy-mid);
  color: var(--white);
  border: 1px solid var(--teal-light);
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
}

/* ---------------------------------------------------------------- layout */

.layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.filters {
  width: 300px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 1rem;
  overflow-y: auto;
}

.filters__section {
  margin-bottom: 1.5rem;
}

.filters__heading-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.filters__section h2 {
  font-size: 0.95rem;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filters__clear {
  background: none;
  border: none;
  color: var(--teal);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.filters__search {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
}

.filters__ais-status {
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  border: 1px solid var(--teal);
  background: var(--white);
  color: var(--teal);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chip[aria-pressed="true"] {
  background: var(--teal);
  color: var(--white);
}

.yacht-checklist {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.yacht-checklist label {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.yacht-checklist label:last-child {
  border-bottom: none;
}

.yacht-checklist label:hover {
  background: var(--fog);
}

.yacht-checklist .yacht-real {
  color: var(--muted);
  font-size: 0.78rem;
}

/* ---------------------------------------------------------------- content */

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

.map {
  height: 55vh;
  height: 55dvh;
  min-height: 420px;
  background: var(--navy);
}

.results {
  padding: 1rem 1.25rem 2rem;
}

.results__heading-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.results__heading-row h2 {
  color: var(--navy);
}

.results__legend {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.results__toggle {
  display: none;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-left: 0.6rem;
  margin-right: 0.3rem;
}

.dot:first-child {
  margin-left: 0;
}

.dot--live {
  background: var(--teal-light);
  box-shadow: 0 0 0 2px rgba(31, 163, 173, 0.25);
}

.dot--unknown {
  background: var(--unknown);
}

.yacht-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.yacht-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
}

.yacht-card__top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.yacht-card__name {
  font-weight: 600;
  font-size: 1rem;
}

.yacht-card__real {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0 0 0.4rem;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--white);
  border-radius: 4px;
  padding: 0.12rem 0.5rem;
  white-space: nowrap;
}

.yacht-card__meta {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

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

/* Leaflet popups, themed */
.leaflet-popup-content-wrapper {
  border-radius: 8px;
}

.popup h3 {
  margin: 0 0 0.3rem;
  font-size: 0.95rem;
  color: var(--navy);
}

.popup p {
  margin: 0.15rem 0;
  font-size: 0.82rem;
}

.popup .badge {
  margin-right: 0.3rem;
}

/* ---------------------------------------------------------------- mobile */

@media (max-width: 860px) {
  .topbar__filters-toggle {
    display: inline-block;
  }

  .layout {
    flex-direction: column;
  }

  .filters {
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: none;
  }

  .filters.is-open {
    display: block;
  }

  .content {
    position: relative;
    overflow: hidden;
  }

  .map {
    flex: 1;
    height: auto;
    min-height: 240px;
  }

  .yacht-list {
    grid-template-columns: 1fr;
  }

  /* Collapsed by default: just a floating pill over the map, bottom-right —
     the map is the point of the app, the list is one tap away. */
  .results {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15;
    background: var(--fog);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
    padding: 0.75rem 1rem 1rem;
    max-height: 65vh;
    max-height: 65dvh;
    overflow-y: auto;
  }

  .results.is-collapsed {
    background: none;
    box-shadow: none;
    max-height: none;
    overflow: visible;
    padding: 0 1rem 1rem;
  }

  .results.is-collapsed .results__heading-row {
    justify-content: flex-end;
    margin-bottom: 0;
  }

  .results.is-collapsed #results-count,
  .results.is-collapsed .results__legend {
    display: none;
  }

  .results.is-collapsed .yacht-list {
    display: none;
  }

  .results__toggle {
    display: inline-block;
    border-radius: 999px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  }
}

@media (max-width: 420px) {
  .topbar__tagline {
    display: none;
  }
}
