/* Asap: the typeface of hafogvatn.is (Omnibus-Type, SIL OFL), for the ship names. */
@font-face {
  font-family: "Asap";
  src: url("fonts/asap-latin-600-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

:root {
  --problem: #b3261e;   /* errors */
  --ink: #0b2a3c;       /* chart navy */
  --chart: #4d6577;     /* chart grey, 4.5:1 on the glass */
  --glass: rgba(255, 255, 255, 0.74);
  --glass-edge: rgba(11, 42, 60, 0.1);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --brand: "Asap", var(--sans);
}

html, body, main { height: 100%; margin: 0; }
body { font: 15px/1.4 var(--sans); color: var(--ink); background: #cfe3ee; }
#map { position: absolute; inset: 0; background: #cfe3ee; }

/* Hafró's mark printed on the chart, the way a nautical chart carries its title and publisher over
   the sea: no plate, Hafró blár (Pantone 7690 C) with a white halo like chart lettering. */
.brand { position: absolute; top: 16px; left: 18px; z-index: 600; margin: 0; font-size: 1rem; }
.brand a {
  display: flex; align-items: center; gap: 0.7rem;
  color: #00618c; text-decoration: none; opacity: 0.85;
  transition: opacity 150ms;
}
.brand a:hover, .brand a:focus-visible { opacity: 1; }
.brand a:focus-visible { outline: 2px solid #00618c; outline-offset: 6px; border-radius: 4px; }
.brand img { display: block; height: 34px; width: auto; filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.9)); }
.brand-text {
  display: flex; flex-direction: column; line-height: 1.15;
  text-shadow: 0 0 2px #fff, 0 0 6px rgba(255, 255, 255, 0.95), 0 0 12px rgba(255, 255, 255, 0.7);
}
.brand-wordmark { font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand-orgline { font-weight: 500; font-size: 0.76rem; color: #2f6f8f; }

/* Frosted glass over the sea: the panel and the popups share it. */
.panel, .glass .leaflet-popup-content-wrapper, .glass .leaflet-popup-tip {
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  backdrop-filter: blur(14px) saturate(1.5);
  border: 1px solid var(--glass-edge);
  box-shadow: 0 6px 24px rgba(11, 42, 60, 0.16);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .panel, .glass .leaflet-popup-content-wrapper, .glass .leaflet-popup-tip { background: rgba(255, 255, 255, 0.92); }
}

.panel {
  position: absolute; left: 16px; bottom: 28px; z-index: 500;
  width: 330px; max-width: calc(100% - 32px); box-sizing: border-box;
  padding: 8px 6px 10px; border-radius: 10px;
}

.ships { list-style: none; margin: 0; padding: 0; }
.ship { display: flex; align-items: center; gap: 2px; }

/* Show/hide: a checkbox in the ship's colour. Ticked and filled when shown, an empty grey box when hidden. */
.toggle { display: flex; align-items: center; padding: 8px 6px 8px 8px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .swatch {
  position: relative; display: block; width: 18px; height: 18px; box-sizing: border-box;
  border-radius: 4px; background: var(--c); border: 2px solid var(--c);
  transition: background-color 120ms, border-color 120ms;
}
.toggle .swatch::after { /* the tick */
  content: ""; position: absolute; left: 4.5px; top: 1px; width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.toggle input:not(:checked) + .swatch { background: rgba(255, 255, 255, 0.7); border-color: #9aaab6; }
.toggle input:not(:checked) + .swatch::after { display: none; }
.toggle:hover .swatch { box-shadow: 0 0 0 3px rgba(11, 42, 60, 0.08); }
.toggle input:focus-visible + .swatch { outline: 2px solid var(--ink); outline-offset: 3px; }

.goto {
  flex: 1; display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  padding: 7px 10px 7px 4px; border: 0; border-radius: 6px; background: none;
  color: inherit; text-align: left; cursor: pointer; font: inherit;
}
.goto:hover { background: rgba(255, 255, 255, 0.55); }
.goto:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; }
.ship.hidden .goto { opacity: 0.45; }
.ship + .ship { border-top: 1px solid rgba(11, 42, 60, 0.07); }

.name { font: 600 1.02rem/1.2 var(--brand); letter-spacing: -0.005em; }
.when { color: var(--chart); font-size: 0.86rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.when.live { color: var(--ink); }

/* How far back the wake goes. */
.period { margin: 8px 10px 0 38px; padding-top: 10px; border-top: 1px solid rgba(11, 42, 60, 0.1); }
.period-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.86rem; }
.period-row label { color: var(--ink); }
.period-row output { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.period input { width: 100%; margin: 6px 0 0; accent-color: var(--ink); cursor: ew-resize; }
.period input:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 2px; }

.status { margin: 6px 10px 0 38px; color: var(--chart); font-size: 0.8rem; }
.status.problem { color: var(--problem); }

/* Current position: an arrow along the heading. A ship heard from in the last hour pulses. */
.boat { overflow: visible; }
/* Colours are SVG attributes set in map.js: the Content Security Policy allows no inline styles. */
.boat .ring { fill: none; stroke-width: 2; opacity: 0; transform-box: fill-box; transform-origin: center; }
.boat.live .ring { animation: ping 2.8s ease-out infinite; }
@keyframes ping {
  0% { transform: scale(0.4); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

.glass .leaflet-popup-content-wrapper { border-radius: 10px; color: var(--ink); }
.glass .leaflet-popup-tip { border-top: 0; border-left: 0; }
.glass .leaflet-popup-content { margin: 9px 14px 10px; font: 0.88rem/1.45 var(--sans); }
.glass .leaflet-popup-content .name { display: block; margin-bottom: 1px; }
.glass .detail { color: var(--chart); font-variant-numeric: tabular-nums; }

.leaflet-container .leaflet-control-attribution { font-size: 10px; background: rgba(255, 255, 255, 0.6); }

@media (max-width: 600px) {
  .brand { top: 10px; left: 12px; }
  .brand img { height: 28px; }
  .panel { left: 8px; right: 8px; bottom: 40px; width: auto; max-width: none; } /* above the attribution, which wraps to two lines on phones */
}

@media (prefers-reduced-motion: reduce) {
  .boat.live .ring { animation: none; opacity: 0.6; transform: scale(1.2); }
}

/* Phones: the panel folds to one line (the ships' colours and "Skipin") so the map gets the screen. */
.panel-toggle { display: none; }
@media (max-width: 600px) {
  .panel-toggle {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: 6px; background: none;
    color: var(--ink); font: 600 0.95rem/1.2 var(--brand); cursor: pointer;
  }
  .panel-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; }
  .panel-toggle .chevron { margin-left: auto; transition: transform 150ms; }
  .panel.collapsed .chevron { transform: rotate(180deg); }
  .panel.collapsed .panel-body { display: none; }
  .panel:not(.collapsed) .panel-toggle { border-bottom: 1px solid rgba(11, 42, 60, 0.1); border-radius: 6px 6px 0 0; margin-bottom: 4px; }
  .dots { display: flex; gap: 4px; }
  .dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
}
