/* SeaBathy web app. A full-screen chart with a few round buttons, a readout at the foot, and a
   panel that slides up from the bottom. Sized for a phone held in one hand; the insets keep
   everything clear of the notch and the home bar. */

:root {
  --bg: #060b14;
  --panel: #111827;
  --panel-2: #172033;
  --line: #243044;
  --text: #e5e7eb;
  --muted: #9aa7b8;
  --accent: #2dd4bf;
  --accent-ink: #04201c;
  --danger: #f87171;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --left: env(safe-area-inset-left, 0px);
  --right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  /* A finger held on the chart adds a waypoint: no text selection or pop-up menu instead. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
input, textarea { -webkit-user-select: text; user-select: text; }
button { cursor: pointer; }

#map { position: fixed; inset: 0; background: #0b1220; }
.maplibregl-canvas { outline: none; }

/* ---------------------------------------------------------------- on the chart */

#crosshair {
  position: fixed; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; pointer-events: none;
  background:
    linear-gradient(#fff, #fff) center / 2px 100% no-repeat,
    linear-gradient(#fff, #fff) center / 100% 2px no-repeat;
  filter: drop-shadow(0 0 1.5px #000) drop-shadow(0 0 1.5px #000);
  opacity: .85;
}

.corner { position: fixed; display: flex; flex-direction: column; gap: 10px; z-index: 5; }
.top-left { top: calc(var(--top) + 12px); left: calc(var(--left) + 12px); }
.top-right { top: calc(var(--top) + 12px); right: calc(var(--right) + 12px); }

.fab {
  width: 48px; height: 48px; padding: 11px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(17, 24, 39, .92); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}
.fab svg { display: block; width: 100%; height: 100%; }
.fab:active { background: var(--panel-2); }
.fab.word { padding: 0; font-size: 16px; font-weight: 700; letter-spacing: .02em; color: var(--accent); border-color: var(--accent); }
#btn-gps.on { color: var(--accent); border-color: var(--accent); }
#btn-gps.follow { background: var(--accent); color: var(--accent-ink); }

#gps-hud {
  position: fixed; z-index: 5; top: calc(var(--top) + 18px); left: 50%; transform: translateX(-50%);
  padding: 6px 12px; border-radius: 16px; border: 1px solid var(--line); background: rgba(17, 24, 39, .92);
  font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap;
}

.licence {
  margin: 0; padding: 4px 2px 24px; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #d5dbe5;
}

#update {
  position: fixed; z-index: 30; top: calc(var(--top) + 8px); left: 50%; transform: translateX(-50%);
  padding: 10px 16px; border-radius: 20px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600;
  max-width: calc(100% - 24px);
}

.foot {
  position: fixed; z-index: 4; left: 0; right: 0; bottom: 0; pointer-events: none;
  padding: 0 calc(var(--right) + 8px) calc(var(--bottom) + 4px) calc(var(--left) + 8px);
}
#readout {
  display: inline-flex; gap: 10px; align-items: baseline; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(17, 24, 39, .9); font-size: 14px; font-variant-numeric: tabular-nums;
}
#readout-depth { color: var(--accent); font-weight: 600; }
#credits {
  margin-top: 4px; font-size: 10px; line-height: 1.25; color: #d5dbe5; text-shadow: 0 0 2px #000, 0 0 2px #000;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; pointer-events: auto;
}

.maplibregl-ctrl-bottom-right { bottom: calc(var(--bottom) + 46px); right: calc(var(--right) + 2px); }
.maplibregl-ctrl-scale { background: rgba(17, 24, 39, .75); color: var(--text); border-color: var(--text); font-size: 10px; }

#toast {
  position: fixed; z-index: 40; left: 50%; bottom: calc(var(--bottom) + 76px); transform: translateX(-50%);
  width: max-content; max-width: min(92vw, 460px); padding: 11px 15px; border-radius: 14px;
  background: #f3f4f6; color: #111827; font-size: 15px; box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
}

/* Waypoints and the boat */

.wpt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0; border: 0; background: none; cursor: pointer; }
.wpt-dot {
  display: block; width: 26px; height: 26px; padding: 3px; border-radius: 50%; background: var(--c); border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .6);
}
.wpt-dot svg { display: block; }
.wpt-name {
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; color: #fff;
  text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 2px #000;
}

.boat { position: relative; width: 22px; height: 22px; pointer-events: none; }
.boat-dot { position: absolute; inset: 3px; border-radius: 50%; background: #38bdf8; border: 2.5px solid #fff; box-shadow: 0 0 6px rgba(0, 0, 0, .6); }
.boat-arrow { position: absolute; inset: -12px; }
.boat-arrow::before {
  content: ""; position: absolute; left: 50%; top: 0; margin-left: -7px;
  border: 7px solid transparent; border-top-width: 0; border-bottom: 12px solid #38bdf8; filter: drop-shadow(0 0 1px #fff);
}

/* The 3D seabed view: a page of its own in a frame, kept clear of the notch and the home bar.
   Panels, messages and cards of the app still show over it. */
#view3d-holder { position: fixed; inset: 0; z-index: 15; background: #07111c; }
#view3d {
  position: absolute; border: 0;
  top: var(--top); left: var(--left);
  width: calc(100% - var(--left) - var(--right)); height: calc(100% - var(--top) - var(--bottom));
}
#view3d-wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }

/* ---------------------------------------------------------------- the panel */

#sheet {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; max-height: 78%; display: flex; flex-direction: column;
  background: var(--panel); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(0, 0, 0, .55);
}
#sheet header { display: flex; align-items: center; gap: 4px; padding: 8px 8px 6px; border-bottom: 1px solid var(--line); flex: none; }
#sheet-title { flex: 1; margin: 0 6px; font-size: 18px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-button { width: 42px; height: 42px; padding: 10px; border: 0; border-radius: 50%; background: none; color: var(--text); flex: none; }
.sheet-button svg { display: block; width: 100%; height: 100%; }
.sheet-button:active { background: var(--panel-2); }
#sheet-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 6px calc(var(--right) + 12px) calc(var(--bottom) + 18px) calc(var(--left) + 12px);
}

@media (min-width: 760px) {
  #sheet { left: auto; right: 12px; bottom: 12px; top: 12px; width: 400px; max-height: none; border: 1px solid var(--line); border-radius: 18px; }
}

.heading { margin: 18px 4px 6px; font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.note { margin: 8px 4px; font-size: 14px; color: var(--muted); }

.row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; margin: 6px 0; padding: 9px 12px; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text);
}
.row:active { background: #1e2a44; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-size: 16px; overflow-wrap: anywhere; }
.row-detail { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row-value { flex: none; font-size: 14px; color: var(--accent); font-variant-numeric: tabular-nums; }
.row.danger .row-value, .row.danger .row-title { color: var(--danger); }
.row.danger .row-detail { color: var(--muted); }
.toggle input { flex: none; width: 24px; height: 24px; accent-color: var(--accent); }

.field { display: block; margin: 10px 0; }
.field-label { display: block; margin: 0 4px 4px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea, #sheet-body > input[type="search"] {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: #0b1220; color: var(--text); font-size: 16px;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.slider { margin: 8px 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; }
.slider input { width: 100%; margin: 8px 0 2px; accent-color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin: 12px 0 4px; }
.btn {
  min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-weight: 600;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .45; }

.legend { display: block; width: 100%; height: 14px; margin: 4px 0 8px; border-radius: 7px; border: 1px solid var(--line); }
.swatches, .icon-choices { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 4px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; }
.swatch.on { border-color: #fff; }
.icon-choice { width: 46px; height: 46px; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: #334155; }
.icon-choice.on { border-color: var(--accent); background: #0f766e; }
.icon-choice .svg, .icon-choice svg { display: block; width: 100%; height: 100%; }
.steps { margin: 8px 0; padding-left: 26px; font-size: 15px; }
.steps li { margin: 7px 0; }

/* ---------------------------------------------------------------- cards and full screens */

.overlay {
  position: fixed; z-index: 50; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: calc(var(--top) + 16px) 16px calc(var(--bottom) + 16px); background: rgba(3, 7, 14, .72);
}
.card {
  width: 100%; max-width: 440px; max-height: 100%; overflow-y: auto; padding: 20px; border-radius: 18px;
  border: 1px solid var(--line); background: var(--panel); box-shadow: 0 10px 40px rgba(0, 0, 0, .6);
}
.card-badge { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.card-title { margin: 4px 0 8px; font-size: 21px; }
.card-subtitle { margin: 0 0 10px; font-weight: 600; }
.card-text { margin: 8px 0; font-size: 15px; color: #cbd5e1; }
.card-fine { margin: 12px 0 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.bar { height: 10px; margin: 12px 0 6px; border-radius: 5px; background: #0b1220; border: 1px solid var(--line); overflow: hidden; }
.bar-fill { width: 0; height: 100%; background: var(--accent); transition: width .2s linear; }

#install, #fatal {
  position: fixed; z-index: 60; inset: 0; overflow-y: auto; display: flex; align-items: center; justify-content: center;
  padding: calc(var(--top) + 20px) 18px calc(var(--bottom) + 20px); background: var(--bg);
}
.install-card { width: 100%; max-width: 460px; }
.install-card img { display: block; border-radius: 16px; }
.install-card h1 { margin: 16px 0 8px; font-size: 24px; }
.install-card p { margin: 8px 0; color: #cbd5e1; }
.install-note { font-size: 14px; color: var(--muted) !important; }
.install-card .btn { margin-top: 14px; width: 100%; }
