/* Works without Tailwind. Tailwind v3 CDN can still enhance utility classes. */

:root {
  --color-sea-900: #0b1c2a;
  --color-sea-800: #123044;
  --color-sea-700: #1c3d56;
  --color-paper: #f8fafc;
  --color-copper: #c45c26;
  --color-signal-none: #7b8794;
  --color-signal-stale: #d7a03c;
  --color-map-canvas: #e2e5e9;
  --color-border: #34506a;
  --color-muted-fg: #9fb0bf;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--color-sea-900);
  color: var(--color-paper);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--color-border);
  background: rgba(11, 28, 42, 0.96);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 80rem;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
}

.site-brand {
  display: flex;
  align-items: center;
  min-width: 0;
}

.site-logo {
  display: block;
  height: 2.35rem;
  width: auto;
  max-width: min(18rem, 58vw);
  object-fit: contain;
  object-position: left center;
}

@media (max-width: 639px) {
  .site-header-inner {
    padding: 0.45rem 0.75rem 0.55rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  .site-logo {
    height: 1.7rem;
    max-width: min(12rem, 70vw);
  }

  .site-header-right {
    width: 100%;
    align-items: stretch;
  }

  .ais-updated {
    font-size: 0.65rem;
    text-align: left;
  }

  .site-nav {
    width: 100%;
    max-width: none;
    flex-wrap: wrap;
    overflow: visible;
    gap: 0.3rem;
  }

  .site-nav a {
    padding: 0.32rem 0.55rem;
    font-size: 0.75rem;
  }
}

@media (min-width: 640px) {
  .site-logo {
    height: 2.6rem;
  }
}

.site-nav {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
}

.site-nav a {
  padding: 0.35rem 0.7rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: var(--color-muted-fg);
  white-space: nowrap;
}

.site-nav a:hover,
.site-nav a.is-active {
  background: var(--color-sea-700);
  color: var(--color-paper);
}

.site-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
  min-width: 0;
}

.ais-updated {
  margin: 0;
  font-size: 0.75rem;
  color: var(--color-muted-fg);
  white-space: nowrap;
  text-align: right;
}

.ais-updated.is-hidden {
  display: none;
}

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 0.9rem 1.25rem;
  font-size: 0.75rem;
  color: var(--color-muted-fg);
}

.map-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.map-pane {
  position: relative;
  width: 100%;
  height: 55vh;
  min-height: 280px;
  flex-shrink: 0;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  background: var(--color-map-canvas);
}

.recent-banner {
  position: absolute;
  left: 3.25rem;
  right: 3.25rem;
  top: 0.75rem;
  z-index: 1200;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  pointer-events: none;
}

.recent-banner[hidden] {
  display: none;
}

.recent-chip {
  pointer-events: auto;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  padding: 0.2rem 0.65rem;
  background: rgba(11, 28, 42, 0.88);
  color: var(--color-paper);
  font-size: 0.75rem;
  cursor: pointer;
}

.recent-chip.is-sar {
  border-color: #d946ef;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  font-family: inherit;
}

.leaflet-tooltip.boat-label {
  display: none;
  background: rgba(11, 28, 42, 0.88);
  color: var(--color-paper);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  box-shadow: none;
  font-size: 11px;
  line-height: 1.2;
  padding: 2px 6px;
  white-space: nowrap;
  pointer-events: none;
}

.leaflet-tooltip.boat-label::before {
  display: none;
}

.show-boat-labels .leaflet-tooltip.boat-label {
  display: block;
}

@keyframes boat-pulse {
  0% { stroke-opacity: 0.85; stroke-width: 2; }
  70% { stroke-opacity: 0; stroke-width: 10; }
  100% { stroke-opacity: 0; stroke-width: 10; }
}

path.boat-pulse {
  animation: boat-pulse 1.8s ease-out infinite;
  pointer-events: none;
}

#station-map,
#track {
  height: 22.5rem;
  min-height: 22.5rem;
}

.map-sidebar {
  width: 100%;
  border-top: 1px solid var(--color-border);
  background: var(--color-sea-900);
}

.sheet-handle {
  display: none;
}

@media (max-width: 1023px) {
  body.is-map-home {
    overflow: hidden;
  }

  body.is-map-home .site-shell {
    height: 100dvh;
    max-height: 100dvh;
  }

  body.is-map-home .site-footer {
    display: none;
  }

  body.is-map-home .map-shell {
    position: relative;
    flex: 1;
    min-height: 0;
    height: auto;
  }

  body.is-map-home .map-pane {
    height: 100%;
    min-height: 0;
    padding-bottom: calc(3.4rem + env(safe-area-inset-bottom));
  }

  body.is-map-home .leaflet-top.leaflet-right {
    top: 0.4rem;
    right: 0.4rem;
    z-index: 1100;
  }

  body.is-map-home .leaflet-control-zoom a {
    width: 2.1rem;
    height: 2.1rem;
    line-height: 2.1rem;
    font-size: 1.15rem;
  }

  .map-sidebar {
    position: fixed !important;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5000;
    width: 100%;
    max-height: 3.5rem;
    overflow: hidden;
    border-top: 2px solid var(--color-copper);
    border-radius: 0.85rem 0.85rem 0 0;
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.4);
    background: #123044;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transition: max-height 0.2s ease;
  }

  .map-sidebar.is-open {
    max-height: min(72dvh, 36rem);
  }

  .sheet-handle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    width: 100%;
    min-height: 3.25rem;
    padding: 0.45rem 1rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    background: #123044;
    color: var(--color-paper);
    font-size: 0.85rem;
    font-weight: 600;
    border: 0;
    cursor: pointer;
  }

  body.is-map-home .sheet-grip {
    display: block;
    width: 2.5rem;
    height: 0.28rem;
    border-radius: 9999px;
    background: #9fb0bf;
  }

  body.is-map-home .sheet-body {
    overflow-y: auto;
    max-height: calc(min(72dvh, 36rem) - 3.25rem);
    -webkit-overflow-scrolling: touch;
  }

  .chip {
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
    min-height: 2.4rem;
  }

  .page,
  main.mx-auto {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .watch-form {
    flex-direction: column;
    align-items: stretch;
  }

  .watch-form input,
  .watch-form button {
    width: 100%;
    min-height: 2.75rem;
  }

  #station-map,
  #track {
    height: 18rem;
    min-height: 18rem;
  }

  body.is-map-home .sidebar-intro {
    display: none;
  }

  body.is-map-home .recent-banner {
    left: 0.6rem;
    right: 0.6rem;
    top: 0.5rem;
  }
}

@media (min-width: 1024px) {
  .map-shell {
    flex-direction: row;
    height: calc(100vh - 7.25rem);
    overflow: hidden;
  }

  .map-pane {
    flex: 1;
    height: auto;
    min-height: 0;
  }

  .map-sidebar {
    position: relative !important;
    width: 22rem;
    max-height: none;
    flex-shrink: 0;
    border-top: 0;
    border-left: 1px solid var(--color-border);
    border-radius: 0;
    box-shadow: none;
    overflow-y: auto;
    padding-bottom: 0;
  }

  .sheet-handle {
    display: none !important;
  }
}

@media (min-width: 1280px) {
  .map-sidebar {
    width: 24rem;
  }
}

.boat-hull-wrap {
  background: transparent !important;
  border: 0 !important;
}

.boat-hull {
  display: block;
  width: 12px;
  height: 30px;
  transform-origin: 50% 50%;
}

.boat-hull svg {
  display: block;
  width: 12px;
  height: 30px;
  overflow: visible;
  filter: drop-shadow(0 0 1px rgba(11, 28, 42, 0.85));
}

.boat-hull-wrap.is-pulse .boat-hull {
  animation: hull-pulse 1.6s ease-out infinite;
}

@keyframes hull-pulse {
  0% { filter: drop-shadow(0 0 0 rgba(196, 92, 38, 0.7)); }
  70% { filter: drop-shadow(0 0 8px rgba(196, 92, 38, 0)); }
  100% { filter: drop-shadow(0 0 0 rgba(196, 92, 38, 0)); }
}

@media (prefers-reduced-motion: reduce) {
  .boat-hull-wrap.is-pulse .boat-hull {
    animation: none;
  }
}

.marker-station {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  transform: rotate(45deg);
  background: var(--color-paper);
  border: 1px solid var(--color-sea-900);
}

.marker-boat {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 9999px;
  border: 2px solid var(--color-copper);
  background: transparent;
  flex-shrink: 0;
}

.marker-boat.is-underway {
  background: var(--color-copper);
  border-style: solid;
}

.marker-boat.is-moored {
  background: transparent;
  border-style: dashed;
  border-color: var(--color-copper);
}

.marker-boat.is-oor {
  background: transparent;
  border-style: dashed;
  border-color: var(--color-signal-none);
}

.marker-boat.is-none {
  background: var(--color-signal-none);
  border-color: var(--color-signal-none);
  opacity: 0.55;
}

.marker-boat.is-sar {
  background: #d946ef;
  border-color: #d946ef;
}

.bg-copper { background: var(--color-copper); }
.bg-paper { background: var(--color-paper); }
.bg-signal-none { background: var(--color-signal-none); }
.bg-transparent { background: transparent; }
.border-dashed { border-style: dashed; }
.border-muted-fg { border-color: var(--color-muted-fg); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.25rem;
  color: var(--color-paper);
  background: transparent;
  cursor: pointer;
}

.chip:hover {
  background: var(--color-sea-700);
}

.chip-active {
  border-color: var(--color-paper);
  background: var(--color-sea-700);
  font-weight: 600;
}

.page {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.stale-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-sea-800);
  color: var(--color-signal-stale);
  font-size: 0.75rem;
}

.stale-banner.is-hidden {
  display: none !important;
}

.stale-dismiss {
  flex-shrink: 0;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  padding: 0.15rem 0.65rem;
  background: transparent;
  color: var(--color-paper);
  cursor: pointer;
  font-size: 0.75rem;
}

.boat-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.boat-row:hover {
  background: var(--color-sea-800);
}

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
