/* travel.mcknight.io
 *
 * The palette is taken from mcknight.io, so the subdomain looks like the same
 * person made it. The ocean is the one new colour: the globe needs a water that
 * is not the page background, or the sphere has no edge.
 */

:root {
  --text-primary: #030303;
  --text-secondary: #123458;
  --text-muted: #666;
  --accent: #123458;
  --accent-light: #2978cc;
  --border: #D4C9BE;
  --background: #ffffff;
  --background-alt: #f2f1ef;

  --ocean: #eef2f6;
  --land: #e4e0d9;          /* a country not visited */
  --land-stroke: #b3a897;
  --country-visited: #9db7d4;
  --region-visited: #3f6ea8;
  --city: #1b1b1b;          /* a place I slept, ate, worked */
  --poi: #1f8a4c;           /* a place I went to see */
  --highmark: #1f63c4;      /* a high mark */

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Charter', 'Georgia', 'Times New Roman', serif;
  --font-mono: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--text-primary);
  font-family: var(--font-serif);
  line-height: 1.6;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  padding: 1.25rem 1.5rem 0.75rem;
  max-width: 1100px;
  margin: 0 auto;
}

header h1 {
  font-family: var(--font-sans);
  font-size: 1.5rem;
  margin: 0;
}

header a {
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  text-decoration: none;
  border-bottom: 1px dotted var(--border);
}

header a:hover { border-bottom-color: var(--accent); }

.tally {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  margin-left: auto;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
}

/* Globe on the left, the same places as a list on the right. The list becomes
 * a block under the globe when there is not room for two columns. */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  gap: 1.5rem;
  align-items: start;
}

#outline {
  max-height: 78vh;
  overflow-y: auto;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  border-left: 1px solid var(--border);
  padding-left: 1rem;
}

/* Each level that has children is a <details>. The marker is replaced by a
 * triangle that turns, and the row is laid out as a flex line so the name sits
 * beside it rather than wrapping under it. */
#outline summary {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  cursor: pointer;
  list-style: none;
}

#outline summary::-webkit-details-marker { display: none; }

/* The name inside a summary sizes to its text rather than filling the row.
 * Filling it left only the triangle to tap for collapsing, which is fine with
 * a mouse and impossible with a thumb: on a phone the name covered the whole
 * row, so every tap chose the place and nothing ever collapsed. Now the name
 * chooses and the space beside it collapses. */
#outline summary .entry {
  display: inline-block;
  width: auto;
  flex: 0 1 auto;
}

/* And the row itself is a comfortable target for the part that toggles. */
#outline summary { min-height: 1.6rem; }

/* Drawn with borders rather than set as a character: the triangle glyphs are
 * missing from some fonts, and fell back to a mark too small to read. */
#outline summary::before {
  content: "";
  flex: none;
  width: 0;
  height: 0;
  margin-right: 0.3rem;
  border-left: 5px solid var(--text-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.12s ease;
}

#outline details[open] > summary::before { transform: rotate(90deg); }

/* Each level steps in, so depth is visible without reading the names. The
 * cities have no triangle of their own, so they are stepped in to line up
 * under the names above them rather than under the triangles. */
#outline .level .level { padding-left: 0.7rem; }
#outline ul.places { list-style: none; margin: 0; padding-left: 1.55rem; }

/* A subheading for each kind of place, so forty cities do not bury two points
 * of interest. It reads as a quiet label rather than as another place. */
#outline .kind > summary { color: var(--text-muted); }
#outline .kind-name {
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
#outline .kind-name .count {
  margin-left: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  opacity: 0.75;
}
#outline .kind.poi > summary .kind-name { color: var(--poi); }
#outline .kind.highmark > summary .kind-name { color: var(--highmark); }

/* The gap between a state and its first entry was the summary's own line
 * height plus the list's margin. The list carries the spacing now, once. */
#outline .level > summary { margin: 0; padding: 0.02rem 0; }
#outline details.region > .level { margin-top: 0.1rem; }
#outline details.region { margin-bottom: 0.15rem; }
#outline .nothing-yet {
  color: var(--text-muted);
  font-style: italic;
  margin: 0 0 0 1.55rem;
  font-size: 0.75rem;
}

#outline .entry { padding-top: 0.05rem; padding-bottom: 0.05rem; }

#outline .continent-entry {
  font-size: 0.6875rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-muted);
}

#outline .level.continent { margin-bottom: 0.6rem; }

.entry {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 4px;
  padding: 0.12rem 0.3rem;
  font: inherit;
  color: var(--text-primary);
  cursor: pointer;
  line-height: 1.45;
}

.entry:hover { background: var(--background-alt); }
.entry:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 1px; }

.country-entry { font-weight: 600; }
.region-entry { color: var(--text-secondary); }
.city-entry { color: var(--text-muted); }
.not-located { display: block; color: #a99; font-style: italic; cursor: default; }

/* A height in the list, written by the script once a unit is chosen. */
.elevation {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.entry.focused .elevation { color: rgba(255, 255, 255, 0.8); }

.entry.focused {
  background: var(--region-visited);
  color: #fff;
}

#clear-focus {
  font: inherit;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1rem 0.5rem;
  margin-left: 0.4rem;
  cursor: pointer;
  color: var(--text-secondary);
}

#clear-focus:hover { border-color: var(--accent); color: var(--accent); }

/* Focus mode. Everything that is not the chosen place fades back, so the eye
 * goes to it without the rest of the globe disappearing. */
#globe.focus-active .country,
#globe.focus-active .region { opacity: 0.35; }
#globe.focus-active .place { opacity: 0.4; }
#globe.focus-active .place-label { opacity: 0.35; }
#globe.focus-active .focused { opacity: 1; }
#globe .region.focused { stroke: #0f2740; stroke-width: 1.6; }
#globe .country.focused { stroke: #4a6b8a; stroke-width: 1.4; }

/* The globe sizes itself to the viewport so the whole sphere is always on
 * screen, with room left for the header, legend and footer. */
#globe-figure {
  position: relative;
  margin: 0;
  touch-action: none;   /* dragging rotates the globe; it must not scroll */
}

/* The script sets width and height in pixels so the whole sphere fits the
 * viewport. CSS must not stretch it past that, or the globe overflows and
 * pushes the legend off the screen — only shrink it on a narrow phone. */
#globe {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  cursor: grab;
}

#globe.dragging { cursor: grabbing; }

.sphere { fill: var(--ocean); }
.graticule {
  fill: none;
  stroke: #d8dee6;
  stroke-width: 0.4;
}

.country {
  fill: var(--land);
  stroke: var(--land-stroke);
  stroke-width: 0.7;
}

.country.visited { fill: var(--country-visited); }

.region {
  fill: var(--region-visited);
  stroke: #21405f;
  stroke-width: 0.9;
}

.place {
  stroke: #fff;
  stroke-width: 0.7;
}

.place.city { fill: var(--city); }
.place.poi { fill: var(--poi); }
.place.highmark { fill: var(--highmark); }

/* Unticking "countries" leaves the land where it is and takes away only the
 * mark of having been there. Removing the land would leave an empty ball. */
#globe.hide-countries .country.visited { fill: var(--land); }

.place:hover, .country.visited:hover, .region:hover { cursor: pointer; }
.country.visited:hover, .region:hover { filter: brightness(1.12); }
.place:hover { stroke-width: 1.4; }

/* The outline sits above everything, so the sphere keeps a crisp edge no matter
 * what is drawn under it. */
.globe-outline {
  fill: none;
  stroke: #b9c4d0;
  stroke-width: 1;
  pointer-events: none;
}

/* A label beside each dot. The white stroke under the text is what keeps it
 * readable over a dark region fill as well as over the pale ocean, and
 * paint-order puts that stroke behind the letters instead of through them. */
.place-label {
  font-family: var(--font-sans);
  font-size: 11px;
  fill: #1c1c1c;
  stroke: #fff;
  stroke-width: 2.6px;
  paint-order: stroke fill;
  stroke-linejoin: round;
  pointer-events: none;
  user-select: none;
}

#tooltip {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  line-height: 1.35;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  max-width: 16rem;
}

#tooltip.visible { opacity: 1; }
#tooltip .where { color: var(--text-muted); font-size: 0.75rem; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.75rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.legend > legend {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 0.3rem;
}

.legend label,
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.legend .not-a-layer { cursor: default; color: var(--text-muted); }

/* The unit control sits apart from the layer switches: it changes how a number
 * reads, not whether something is drawn. */
.legend .units {
  display: inline-flex;
  gap: 0.5rem;
  margin-left: auto;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
}
.legend input { margin: 0; cursor: pointer; }
.legend i {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}
.legend i.dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; }
.legend i.country { background: var(--country-visited); }
.legend i.region { background: var(--region-visited); }
.legend i.city { background: var(--city); }
.legend i.poi { background: var(--poi); }
.legend i.highmark { background: var(--highmark); }
.legend i.names {
  background: linear-gradient(transparent 38%, var(--text-muted) 38%, var(--text-muted) 62%, transparent 62%);
  border-color: transparent;
}
.legend i.unvisited { background: var(--land); }

.hint {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0;
}

footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-muted);
}

footer a { color: var(--text-secondary); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  #outline {
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 1rem;
  }
}

@media (max-width: 640px) {
  header { padding: 1rem 1rem 0.5rem; }
  main { padding: 0 1rem 1.5rem; }
  .tally { margin-left: 0; width: 100%; }
}
