/* The Whaling Ocean atlas.
   A deep chart sea, buff land, whale-oil amber for tracks, ivory and iron-gall ink for the log panel; moments take
   their own colors. Stamps follow the keepers' own whale stamps. */

:root {
  --sea: #16394a;
  --sea-deep: #0e2733;
  --sea-line: rgba(237, 229, 211, 0.12);
  --oil: #e9b95a;
  --ivory: #ede5d3;
  --ivory-dim: rgba(237, 229, 211, 0.62);
  --paper: #efe8d8;
  --paper-2: #f6f1e4;
  --paper-edge: #d9cfb8;
  --ink: #2a2016;
  --ink-soft: #6b5d4b;

  --display: "IM Fell English SC", "Iowan Old Style", Georgia, serif;
  --body: "Alegreya Sans", "Gill Sans", "Trebuchet MS", sans-serif;
  --mono: "Courier Prime", "Courier New", monospace;

  --side-w: 372px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
  height: 100dvh;
  overflow: hidden;
  background: var(--sea-deep);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
}

button { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--oil); outline-offset: 2px; }

/* ---------- the panel: the voyage list, or one voyage's log, floating over the map ---------- */

.side {
  position: absolute;
  top: 12px;
  left: 12px;
  width: var(--side-w);
  max-height: calc(100dvh - 24px - 112px);   /* clear of the timeline */
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  z-index: 3;
}
body[data-mode="index"] .side { max-height: calc(100dvh - 24px); }

.side-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--paper-edge); }
.side-body { flex: 1; overflow-y: auto; min-height: 0; }

.wordmark { font-family: var(--display); font-size: 22px; font-weight: 400; margin: 0 0 10px; }

.search {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  background: var(--paper-2);
  border: 1px solid var(--paper-edge);
  border-radius: 3px;
  color: var(--ink);
}
.search::placeholder { color: var(--ink-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.chip {
  padding: 2px 9px;
  border: 1px solid var(--paper-edge);
  border-radius: 999px;
  background: none;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.count { margin: 0; padding: 10px 20px 4px; font-size: 13px; color: var(--ink-soft); }

.voyage-list { list-style: none; margin: 0; padding: 0 8px 8px; }
.voyage-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 8px;
  padding: 9px 12px;
  border-radius: 3px;
  text-decoration: none;
}
.voyage-item:hover, .voyage-item:focus-visible { background: var(--paper-2); }
.vi-name { font-family: var(--display); font-size: 18px; line-height: 1.2; }
.vi-years { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); align-self: center; }
.vi-meta, .vi-stats { grid-column: 1 / -1; font-size: 13.5px; color: var(--ink-soft); }
.vi-stats { font-size: 12.5px; }

.about { padding: 12px 20px 18px; font-size: 12px; color: var(--ink-soft); margin: 0; border-top: 1px solid var(--paper-edge); }

/* voyage view */
.back { display: inline-block; font-size: 13px; color: var(--ink-soft); text-decoration: none; margin-bottom: 4px; }
.back:hover { color: var(--ink); }

/* the voyage's cartouche */
.vessel-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.vessel { font-family: var(--display); font-weight: 400; font-size: 25px; line-height: 1.05; margin: 0; }
.vessel-years { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.vessel-meta { margin: 3px 0 0; font-size: 13px; color: var(--ink-soft); }
.tally { display: flex; flex-wrap: wrap; align-items: baseline; margin: 8px 0 0; font-size: 13px; color: var(--ink-soft); }
.tally-l { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; margin-right: 8px; }
.tally b { font-family: var(--mono); font-weight: 400; font-size: 14px; color: var(--ink); }
.sep { margin: 0 6px; color: var(--paper-edge); }
.tally .sep { color: var(--ink-soft); opacity: 0.5; }

.block { padding: 14px 20px 16px; border-bottom: 1px solid var(--paper-edge); }
.block:last-child { border-bottom: 0; }
.label { font-size: 11.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 6px; font-weight: 400; }

/* the day */
.day-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.day-date { font-family: var(--display); font-weight: 400; font-size: 20px; margin: 0; line-height: 1.2; }
.day-n { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.where { margin: 3px 0 0; font-size: 13.5px; color: var(--ink-soft); }
.where .pos { font-family: var(--mono); font-size: 13.5px; color: var(--ink); }
.where .sep { color: var(--ink-soft); opacity: 0.5; }

.events { list-style: none; margin: 10px 0 0; padding: 0; }
.event { display: grid; grid-template-columns: 22px 1fr; gap: 0 8px; padding: 2px 0; font-size: 14.5px; line-height: 1.35; }
.glyph { width: 26px; height: 18px; display: inline-block; background: no-repeat center / contain; }
.event .glyph { width: 22px; height: 16px; margin-top: 1px; }
.event-title { font-weight: 500; }
.event-detail { display: block; font-size: 13px; color: var(--ink-soft); }
.bead { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; box-shadow: 0 0 0 1px var(--sea-deep); }
.event a { color: var(--ink); }

.plain { margin: 10px 0 6px; font-size: 15.5px; line-height: 1.5; }
.none { margin: 10px 0 0; font-size: 14px; font-style: italic; color: var(--ink-soft); }

.original summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink-soft);
  padding: 2px 0;
  list-style-position: inside;
}
.original summary:hover { color: var(--ink); }
.original[open] summary { margin-bottom: 6px; }

.transcript {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  background: var(--paper-2);
  border-left: 3px solid var(--oil);
  padding: 9px 11px;
  margin: 0;
}

.muted { color: var(--ink-soft); }

/* ---------- map ---------- */

.stage { grid-column: 1; grid-row: 1; position: relative; min-height: 0; min-width: 0; }
.map { position: absolute; inset: 0; background: var(--sea); }

.key-btn, .key {   /* bottom right, beside the credits button, clear of the panel */
  position: absolute;
  right: 44px;
  bottom: 10px;
  background: rgba(14, 39, 51, 0.88);
  color: var(--ivory);
  border: 1px solid var(--sea-line);
  border-radius: 3px;
  font-size: 13px;
}
.key-btn { padding: 5px 11px; cursor: pointer; z-index: 2; }
.key { right: 12px; bottom: 46px; padding: 9px 12px; color: var(--ivory-dim); z-index: 2; }
.key-row { display: flex; align-items: center; gap: 9px; height: 20px; }
.swatch { width: 26px; height: 0; border-top: 2px dashed var(--oil); }
.key .bead { margin: 0 8.5px; }

.maplibregl-ctrl-attrib.maplibregl-compact { background: rgba(14, 39, 51, 0.85); color: var(--ivory-dim); }
.maplibregl-ctrl-attrib a { color: var(--ivory); }
.maplibregl-ctrl-attrib-button { filter: invert(0.92); }
.maplibregl-ctrl-group { background: var(--sea-deep); }
.maplibregl-ctrl-group button + button { border-top-color: var(--sea-line); }
.maplibregl-ctrl-icon { filter: invert(0.9); }

/* ---------- timeline, under the map ---------- */

.time {
  grid-column: 1;
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--sea-deep);
  border-top: 1px solid var(--sea-line);
  color: var(--ivory);
  min-width: 0;
  position: relative;
  z-index: 3;
}
body[data-mode="index"] .time { display: none; }
body[data-mode="index"] .stage { grid-row: 1 / span 2; }

.controls { display: flex; align-items: center; gap: 6px; }

.play {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--oil);
  background: rgba(233, 185, 90, 0.08);
  color: var(--oil);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.play svg { width: 16px; height: 16px; fill: currentColor; }
.play .icon-play { margin-left: 2px; }       /* optically centre the triangle */
.play .icon-pause { display: none; }
.play:hover { background: rgba(233, 185, 90, 0.18); box-shadow: 0 0 0 4px rgba(233, 185, 90, 0.12); }
.play:active { transform: scale(0.95); }
.play[aria-pressed="true"] { background: var(--oil); color: var(--sea-deep); }
.play[aria-pressed="true"] .icon-play { display: none; }
.play[aria-pressed="true"] .icon-pause { display: block; }

.speed {
  min-width: 34px; height: 24px;
  padding: 0 6px;
  border: 1px solid var(--sea-line);
  border-radius: 12px;
  background: none;
  color: var(--ivory-dim);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.speed:hover { color: var(--ivory); border-color: var(--ivory-dim); }

.readout { display: flex; flex-direction: column; line-height: 1.2; min-width: 104px; }
.readout-date { font-family: var(--mono); font-size: 14px; }
.readout-day { font-size: 12px; color: var(--ivory-dim); }

.timeline { width: 100%; height: 80px; display: block; cursor: pointer; }

.tl-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  max-width: 300px;
  padding: 8px 11px 9px;
  background: rgba(14, 39, 51, 0.96);
  border: 1px solid var(--sea-line);
  border-radius: 3px;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.6);
  font-size: 13.5px;
  line-height: 1.35;
  pointer-events: none;
}
.tl-tip[hidden] { display: none; }
.tl-tip p { margin: 0; }
.tl-tip .tip-date { font-family: var(--mono); font-size: 12.5px; color: var(--ivory-dim); margin-bottom: 4px; }
.tl-tip ul { list-style: none; margin: 0; padding: 0; }
.tl-tip li { display: flex; align-items: center; gap: 7px; padding: 1px 0; }
.tl-tip li .glyph { width: 18px; height: 13px; flex: none; }
.tl-tip li .bead { margin: 0 4.5px; }
.tl-tip .muted, .tl-tip .tip-plain { color: var(--ivory-dim); }

.steps { display: flex; gap: 4px; }
.step {
  width: 30px; height: 30px;
  border: 1px solid var(--sea-line);
  border-radius: 3px;
  background: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.step:hover, .key-btn:hover { border-color: var(--ivory-dim); }

/* ---------- narrow screens: map, timeline, then the sidebar ---------- */

@media (max-width: 820px) {
  html, body { height: auto; }
  body { display: flex; flex-direction: column; overflow: visible; min-height: 100dvh; }
  .stage { order: 1; height: 50vh; flex: none; }
  .time { order: 2; position: sticky; top: 0; z-index: 4; grid-template-columns: auto auto 1fr; }
  .timeline { grid-column: 1 / -1; grid-row: 2; }
  .steps { grid-column: 3; grid-row: 1; justify-self: end; }
  .side { order: 3; position: static; width: auto; max-height: none; border: 0; border-radius: 0; box-shadow: none; overflow: visible; }
  body[data-mode="index"] .side { max-height: none; }
  .side-body { overflow: visible; }
  .tl-tip { bottom: auto; top: calc(100% + 6px); }
  .key, .key-btn { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

