/* ============================================================
   R2AK Live Tracker – nautical dark theme
   Fonts: Syne (display) + JetBrains Mono (data)
   ============================================================ */

:root {
  --bg:        #0a0e14;
  --surface:   #111720;
  --surface2:  #18202d;
  --border:    #1e2d42;
  --accent:    #00c8ff;
  --accent2:   #ff6b35;
  --accent3:   #39d98a;
  --text:      #d4e4f7;
  --muted:     #4a6480;
  --danger:    #ff4757;

  --panel-w: 320px;
  --ts-h:    220px;
  --radius:  6px;
  --mono: 'JetBrains Mono', monospace;
  --display: 'Syne', sans-serif;
}

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

html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--display); }

/* ── Layout ────────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  grid-template-rows: 1fr auto;
  height: 100vh;
}

#map {
  grid-column: 2;
  grid-row: 1;
  z-index: 1;
  min-height: 0;
}

#info-panel {
  grid-column: 1;
  grid-row: 1 / 3;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#timeseries-panel.collapsed {
  height: 44px;
}

#timeseries-panel.collapsed .timeseries-body {
  display: none;
}

:root {
  --ts-h: 220px;
}

#timeseries-panel {
  grid-column: 2;
  grid-row: 2;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  overflow: hidden;
  height: var(--ts-h);
}

.timeseries-body {
  flex: 1;
  padding: 8px 16px 10px;
  min-height: 0;
}

/* ── Header ─────────────────────────────────────────────────── */
/* Scoped to #info-panel so this decorative bar only applies to the live
   tracker's own header, not every <header> on the page (e.g. .results-header
   below, which has its own full-bleed accent bar). */
#info-panel header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

#info-panel header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

header h1 {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
  color: #fff;
  margin-bottom: 4px;
}

.subtitle {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

/* ── Modulair link ───────────────────────────────────────────── */
.modulair-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.modulair-link::before {
  content: '↗';
  font-size: 11px;
}

.modulair-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 200, 255, 0.05);
}

/* ── Status pill ─────────────────────────────────────────────── */
.status-pill {
  display: inline-block;
  font-size: 11px;
  font-family: var(--mono);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--muted);
  color: var(--muted);
}

.status-pill.live {
  border-color: var(--accent3);
  color: var(--accent3);
  animation: pulse 2s ease-in-out infinite;
}

.status-pill.stale {
  border-color: var(--accent2);
  color: var(--accent2);
}

.status-pill.error {
  border-color: var(--danger);
  color: var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  margin: 12px;
  padding: 14px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card h2 {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.mono {
  font-family: var(--mono);
}

/* ── Data grid ──────────────────────────────────────────────── */
.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.data-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.label {
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

.value {
  font-size: 22px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
}

.unit {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono);
}

/* ── Compass ─────────────────────────────────────────────────── */
.compass-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.compass-label {
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Chart select ───────────────────────────────────────────── */
.chart-select-label {
  display: block;
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-family: var(--display);
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%234a6480'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Time series panel ───────────────────────────────────────── */
.timeseries-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.timeseries-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.timeseries-title-row h2 {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.timeseries-title-row select {
  width: auto;
  font-size: 11px;
  padding: 4px 28px 4px 8px;
  background-color: var(--surface2);
  border-color: var(--border);
}

.timeseries-sub {
  font-size: 11px;
  color: var(--muted);
}

#timeseries-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--display);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

#timeseries-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#timeseries-chart {
  width: 100% !important;
  height: 100% !important;
}

/* ── Leaflet overrides ───────────────────────────────────────── */
.leaflet-container {
  background: #0a0e14;
  font-family: var(--display);
}

.leaflet-popup-content-wrapper {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.leaflet-popup-tip {
  background: var(--surface2);
}

.popup-content p {
  font-size: 12px;
  font-family: var(--mono);
  margin: 2px 0;
  color: var(--text);
}

.popup-content .popup-time {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

.popup-content strong {
  color: var(--accent);
}

.vessel-arrow-icon { background: transparent; border: none; }

.vessel-arrow-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  transform-origin: center center;
}

.vessel-arrow-wrap::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 28px; height: 28px;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.16);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
}

.vessel-arrow {
  position: absolute;
  left: 50%; top: 2px;
  z-index: 2;
  width: 0; height: 0;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 24px solid #0f172a;
  filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.35));
}

/* ── Scroll cue (points at the full log below) ───────────────── */
.scroll-cue {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 14px 12px 8px;
  padding: 8px 10px;
  font-size: 10px;
  font-family: var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s, color 0.2s;
}

.scroll-cue svg {
  animation: bob 1.6s ease-in-out infinite;
}

.scroll-cue:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

/* ── Scrollbar ───────────────────────────────────────────────── */
#info-panel::-webkit-scrollbar { width: 4px; }
#info-panel::-webkit-scrollbar-track { background: transparent; }
#info-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 700px) {
  :root { --panel-w: 100%; --ts-h: 180px; }
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 50vh auto var(--ts-h);
  }
  #map { grid-column: 1; grid-row: 1; }
  #info-panel { grid-column: 1; grid-row: 2; max-height: none; overflow-y: auto; }
  #timeseries-panel { grid-column: 1; grid-row: 3; }
}

/* ── Error card ──────────────────────────────────────────────── */
.error-text {
  font-size: 11px;
  color: var(--danger);
  line-height: 1.5;
  word-break: break-word;
}

.error-text.no-errors {
  color: var(--accent3);
}

/* ── Card title row (title + pill inline) ────────────────────── */
.card-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.card-title-row h2 {
  margin-bottom: 0;
  flex-shrink: 0;
}

.pos-stale-pill {
  border-color: var(--accent2);
  color: var(--accent2);
  font-size: 9px;
  padding: 2px 7px;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: middle;
}