/**
 * ais.css — AIS vessel layer styles.
 *
 * Covers:
 *   - Map overlay toggle button (top-right, visible on all screen sizes)
 *   - AIS vessel info panel (bottom sheet)
 *   - Vessel type colour legend
 *   - "Zoom in" overlay message
 */

/* ══════════════════════════════════════════════════════════════════════════════
   Map overlay AIS toggle button
   Sits above the Mapbox zoom controls in the top-right corner of the map.
   ══════════════════════════════════════════════════════════════════════════════ */

.ais-map-btn {
  position: absolute;
  top: var(--space-3);
  inset-inline-end: var(--space-3);
  z-index: 200;

  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);

  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(44, 74, 110, 0.12);
  box-shadow: var(--shadow-md);

  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink-base);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--duration-fast),
    box-shadow       var(--duration-fast),
    transform        var(--duration-fast);
}

.ais-map-btn:hover,
.ais-map-btn:focus-visible {
  background: rgba(255, 255, 255, 1);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
  color: var(--color-ink-strong);
}

.ais-map-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.ais-map-btn__icon {
  font-size: 15px;
  line-height: 1;
  color: var(--color-primary);
}

/* Active state — button turns teal + pulsing dot */
.ais-map-btn.is-active {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  color: var(--color-ink-strong);
}

.ais-map-btn.is-active .ais-map-btn__icon {
  color: var(--color-primary);
}

.ais-map-btn.is-active::after {
  content: '';
  width: 7px;
  height: 7px;
  background: #6BBF8E;   /* score-0 green */
  border-radius: var(--radius-full);
  flex-shrink: 0;
  animation: ais-pulse 2s ease-in-out infinite;
}

@keyframes ais-pulse {
  0%, 100% { opacity: 1;   transform: scale(1);   }
  50%       { opacity: 0.4; transform: scale(1.5); }
}

/* ══════════════════════════════════════════════════════════════════════════════
   AIS vessel info panel
   ══════════════════════════════════════════════════════════════════════════════ */

.ais-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 300;

  /* Force LTR — panel content (vessel names, coords, numbers) is never RTL.
     Without this, an RTL page would mirror flex layouts and misplace the
     close button. Positioning via physical left/right (not logical inset-
     inline-*) for the same reason. */
  direction: ltr;

  display: flex;
  flex-direction: column;
  max-height: 82vh;

  background: var(--color-surface-raised);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-lg);

  /* Hidden by default — JS adds .is-open */
  transform: translateY(100%);
  transition: transform 400ms var(--ease-default);
}

.ais-panel.is-open {
  transform: translateY(0);
}

/* Desktop: narrow panel sliding in from the right (always right, regardless
   of page direction — this is a map overlay, not a document side-bar). */
@media (min-width: 768px) {
  .ais-panel {
    left: auto;
    right: 0;
    width: 360px;
    max-height: none;
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
    top: var(--topbar-height-desktop);
    bottom: 0;
    transform: translateX(100%);
  }

  .ais-panel.is-open {
    transform: translateX(0);
  }
}

/* ── Topbar (non-scrolling, always visible) ─────────────────────────────── */

.ais-panel__topbar {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-4) 0;
}

.ais-panel__topbar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block-end: var(--space-2);
}

.ais-panel__topbar-name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.ais-panel__type-icon-sm {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.ais-panel__name {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--color-ink-strong);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ais-panel__close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--color-surface-sunken);
  border: none;
  cursor: pointer;
  color: var(--color-ink-base);
  font-size: 15px;
  transition: background 150ms ease, color 150ms ease;
}

.ais-panel__close:hover,
.ais-panel__close:focus-visible {
  background: var(--color-surface-hover, rgba(0,0,0,0.08));
  color: var(--color-ink-strong);
}

/* ── Scrollable body ─────────────────────────────────────────────────────── */

.ais-panel__body {
  overflow-y: auto;
  flex: 1;
  padding: 0 var(--space-4) var(--space-6);
  overscroll-behavior: contain;
}

/* ── Hero image ─────────────────────────────────────────────────────────── */

.ais-panel__hero {
  position: relative;
  height: 160px;
  margin-bottom: var(--space-3);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface-sunken);
}

.ais-panel__photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none; /* shown by JS when the image loads */
}

.ais-panel__photo-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  /* background colour is set by JS per vessel type */
}

.ais-panel__photo-fallback::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.06) 0%,
    rgba(0, 0, 0, 0.15) 100%
  );
  pointer-events: none;
}

/* Type + status badges overlaid on the hero image */
.ais-panel__hero-badges {
  position: absolute;
  bottom: var(--space-2);
  inset-inline-start: var(--space-2);
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.ais-panel__badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.ais-panel__badge--type {
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}

.ais-panel__badge--status {
  color: #fff;
  /* background colour set by JS from NAV_STATUS_COLORS */
}

/* ── Identity pills ─────────────────────────────────────────────────────── */

.ais-panel__identity {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.ais-panel__pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--color-surface-sunken);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

.ais-panel__pill-label {
  color: var(--color-ink-muted);
  font-weight: 500;
}

.ais-panel__pill-value {
  color: var(--color-ink-strong);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── Divider ─────────────────────────────────────────────────────────────── */

.ais-panel__divider {
  border: none;
  border-block-start: 1px solid var(--color-ink-subtle);
  margin: var(--space-3) 0;
}

/* ── Motion grid (4-column) ─────────────────────────────────────────────── */

.ais-panel__grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: var(--space-2) var(--space-1);
  margin-bottom: var(--space-2);
}

.ais-panel__cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ais-panel__cell-label {
  font-size: var(--text-xs);
  color: var(--color-ink-muted);
  font-weight: 500;
}

.ais-panel__cell-value {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-ink-strong);
  font-variant-numeric: tabular-nums;
}

/* ── Details section ──────────────────────────────────────────────────────── */

.ais-panel__details {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ais-panel__detail-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.ais-panel__detail-icon {
  width: 16px;
  flex-shrink: 0;
  color: var(--color-ink-muted);
  font-size: var(--text-xs);
  text-align: center;
}

.ais-panel__detail-label {
  color: var(--color-ink-muted);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 80px;
}

.ais-panel__detail-value {
  color: var(--color-ink-base);
}

.ais-panel__detail-value--mono {
  font-family: var(--font-mono, ui-monospace, 'SF Mono', 'Fira Code', monospace);
  font-size: var(--text-xs);
  letter-spacing: 0.02em;
}

.ais-panel__mt-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-primary);
  text-decoration: none;
  padding: var(--space-2) 0;
  transition: opacity 150ms ease;
}

.ais-panel__mt-link:hover {
  opacity: 0.75;
  text-decoration: underline;
}

/* ══════════════════════════════════════════════════════════════════════════════
   Vessel type colour legend
   (shown as a small floating card when AIS is enabled)
   ══════════════════════════════════════════════════════════════════════════════ */

.ais-legend {
  position: fixed;
  inset-block-end: var(--space-16);      /* above panel / FABs */
  inset-inline-end: var(--space-3);
  z-index: 250;

  background: var(--color-surface-raised);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-3) var(--space-4);

  display: none;   /* JS toggles display */
  flex-direction: column;
  gap: var(--space-2);
  min-width: 140px;
}

.ais-legend.is-visible {
  display: flex;
}

.ais-legend__title {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}

.ais-legend__row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-ink-base);
}

.ais-legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════════════════════
   "Zoom in" banner — shown when map zoom < 8 while AIS is enabled
   ══════════════════════════════════════════════════════════════════════════════ */

.ais-zoom-banner {
  position: fixed;
  inset-block-start: calc(var(--topbar-height-mobile) + var(--space-3));
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 400;

  background: var(--color-surface-raised);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  padding: var(--space-2) var(--space-4);

  font-size: var(--text-sm);
  color: var(--color-ink-base);
  white-space: nowrap;
  pointer-events: none;

  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-default);
}

.ais-zoom-banner.is-visible {
  opacity: 1;
}

@media (min-width: 768px) {
  .ais-zoom-banner {
    inset-block-start: calc(var(--topbar-height-desktop) + var(--space-3));
  }
}
