/* css/dive-render.css — P3-04. Dive rendering: dashed surface path, dive
   points, depth profile chart, dive popup.

   Everything is scoped under .dive-* / .dived-* so nothing leaks into other
   modules. Colours come exclusively from the styles.css tokens:
   --bg --bg-raised --line --text --text-dim --accent --accent-2 --warn --bad
   --radius --pad --font --mono. The dive accent is --accent-2 throughout.

   The .dived-* chart classes deliberately mirror css/elevation.css (.elev-*)
   — same viewBox (320x176), same font sizes, same grid weight — so the depth
   chart reads as the elevation chart's sibling, just inverted (depth grows
   downward) and blue instead of teal.

   LOADING: js/dive-render.js injects a guarded <link> to this file on first
   use. index.html is owned by another step; once it carries a permanent
   <link rel="stylesheet" href="css/dive-render.css"> the injection is a
   no-op. */

/* --- map: the dashed surface path ---------------------------------------- */

/* Leaflet renders paths as SVG; the class lands on the <path>, so stroke
   here overrides the JS fallback colour with the token. The dash pattern is
   set in JS (dashArray) — do not "fix" it into a solid line; the dashes and
   the gaps between segments are the honest rendering of sparse GPS. */
.dive-surface-path {
  stroke: var(--accent-2);
}

.dive-surface-lone {
  stroke: var(--accent-2);
  fill: var(--accent-2);
}

/* --- map: dive points ----------------------------------------------------- */

.dive-point {
  stroke: var(--accent-2);
  fill: var(--accent-2);
  cursor: pointer;
}

/* Low-confidence join (nearest fix > 300 s away): hollow, dashed ring —
   visibly a weaker claim than a solid point. */
.dive-point--lowconf {
  stroke-dasharray: 3 3;
  fill-opacity: 0.15;
}

/* --- dive popup (depth chart lives inside) -------------------------------- */

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

.dive-popup .leaflet-popup-content {
  margin: 0.5rem;
  font-family: var(--font);
}

.dive-popup .leaflet-popup-tip {
  background: var(--bg-raised);
  border: 1px solid var(--line);
}

.dive-popup .leaflet-popup-close-button {
  color: var(--text-dim);
  /* 44px tap target on a wet thumb */
  width: 44px;
  height: 44px;
  font-size: 1.25rem;
  line-height: 44px;
}

.dive-popup__body {
  min-width: 260px;
}

/* --- the depth profile chart (sibling of .elev) --------------------------- */

.dived {
  margin: 0;
  max-width: 30rem;               /* same scale cap as .elev */
  padding: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

/* When mounted in the side panel rather than a popup, keep the elevation
   card's bottom rhythm. */
.panel .dived { margin-bottom: var(--pad); }

.dived-svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: var(--font);
  overflow: visible;
}

/* plot — depth accent is the dive blue */
.dived-area {
  fill: var(--accent-2);
  fill-opacity: 0.16;
  stroke: none;
}

.dived-line {
  fill: none;
  stroke: var(--accent-2);
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.dived-grid line {
  stroke: var(--line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

/* The SURFACE line — sits at the TOP of this chart, not the bottom. */
.dived-baseline {
  stroke: var(--line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

/* axes — same sizes as .elev-tick / .elev-axis-title */
.dived-tick {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--text-dim);
}

.dived-axis-title {
  font-family: var(--font);
  font-size: 10px;
  fill: var(--text-dim);
  letter-spacing: 0.02em;
}

/* max-depth annotation */
.dived-max-dot {
  fill: var(--accent-2);
  stroke: var(--bg);
  stroke-width: 1;
}

.dived-max-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  fill: var(--text);
}

/* summary row — sibling of .elev-summary */
.dived-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.85rem;
  margin: 0;
  padding: 0.5rem var(--pad) 0.6rem;
  border-top: 1px solid var(--line);
  background: var(--bg-raised);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-dim);
}

.dived-stat {
  white-space: nowrap;
}

.dived-stat b {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}

/* Max depth is the number Dan reads first — it gets the dive accent. */
.dived-stat.is-max b { color: var(--accent-2); }

/* degraded state — never an error dialog */
.dived-unavailable {
  margin: 0;
  padding: var(--pad);
  background: var(--bg-raised);
  border-left: 3px solid var(--warn);
  color: var(--text-dim);
  font-size: 0.8125rem;
  line-height: 1.45;
}

/* --- accessibility -------------------------------------------------------- */

@media (prefers-contrast: more) {
  .dived-area { fill-opacity: 0.28; }
  .dived-line { stroke-width: 2.2; }
  .dived-tick, .dived-axis-title { fill: var(--text); }
  .dived-summary { color: var(--text); }
}

@media print {
  .dived { border-color: #999; background: #fff; }
  .dived-summary { background: #fff; color: #000; border-top-color: #999; }
  .dived-stat b { color: #000; }
  .dived-line { stroke: #000; }
  .dived-area { fill: #000; fill-opacity: 0.10; }
  .dived-tick, .dived-axis-title { fill: #333; }
}
