:root {
  --paper: #f4ecdf;
  --paper-deep: #e8dcc9;
  --ink: #2d3330;
  --muted: #6f756f;
  --blue: #215b6d;
  --blue-soft: #d9e5e5;
  --terracotta: #b85237;
  --terracotta-deep: #913a29;
  --transfer: #747a78;
  --white: #fffdf9;
  --shadow: 0 12px 38px rgb(52 43 31 / 18%);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
  font: inherit;
}

.album-shell {
  display: grid;
  grid-template-areas:
    "header map"
    "days map";
  grid-template-columns: minmax(19rem, 22rem) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
}

.journey-header {
  z-index: 2;
  grid-area: header;
  padding: 1.7rem 1.5rem 1.3rem;
  border-right: 1px solid rgb(92 77 58 / 15%);
  border-bottom: 1px solid rgb(92 77 58 / 12%);
  background: var(--paper);
}

.period,
.day-detail-date {
  margin: 0 0 0.35rem;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 720;
  letter-spacing: 0.115em;
  line-height: 1.25;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: break-word;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.85rem, 4vw, 2.55rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.02;
}

.journey-totals,
.day-detail dl {
  display: grid;
  gap: 0.55rem;
  margin: 1.25rem 0 0;
}

.journey-totals {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.journey-totals div,
.day-detail dl div {
  min-width: 0;
}

dt {
  margin-bottom: 0.12rem;
  color: var(--muted);
  font-size: 0.63rem;
  font-weight: 680;
  letter-spacing: 0.045em;
  line-height: 1.2;
  text-transform: uppercase;
}

dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 680;
  line-height: 1.2;
}

.journey-totals dd {
  font-size: 0.88rem;
  white-space: nowrap;
}

.gpx-link {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  margin-top: 1.05rem;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 680;
  text-decoration: none;
}

.gpx-link:hover,
.gpx-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.gpx-link svg {
  width: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.day-browser {
  z-index: 1;
  grid-area: days;
  min-height: 0;
  overflow: auto;
  padding: 1.1rem 0.8rem 2rem;
  border-right: 1px solid rgb(92 77 58 / 15%);
  background: linear-gradient(180deg, var(--paper), #f8f2e9);
  scrollbar-color: var(--paper-deep) transparent;
}

.day-browser-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 0.65rem 0.65rem;
}

.day-browser h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 500;
}

.quiet-button {
  padding: 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 680;
}

.quiet-button:hover,
.quiet-button:focus-visible {
  border-color: currentColor;
  outline: 0;
}

#day-list {
  display: grid;
  gap: 0.38rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.day-button {
  display: grid;
  grid-template-columns: 2.05rem minmax(0, 1fr) auto;
  gap: 0.72rem;
  align-items: center;
  width: 100%;
  min-height: 3.75rem;
  padding: 0.6rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.day-button:hover {
  background: rgb(255 253 249 / 65%);
}

.day-button:focus-visible {
  border-color: var(--blue);
  outline: 2px solid transparent;
}

.day-button[aria-current="true"] {
  border-color: rgb(184 82 55 / 22%);
  background: var(--white);
  box-shadow: 0 3px 14px rgb(72 56 36 / 8%);
  transform: translateX(0.15rem);
}

.day-number {
  display: grid;
  place-items: center;
  width: 2.05rem;
  height: 2.05rem;
  border: 1px solid rgb(184 82 55 / 40%);
  border-radius: 50%;
  color: var(--terracotta-deep);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.day-button[aria-current="true"] .day-number {
  border-color: var(--terracotta);
  background: var(--terracotta);
  color: white;
}

.day-text {
  min-width: 0;
}

.day-text strong,
.day-text span,
.day-distance {
  display: block;
}

.day-text strong {
  overflow: hidden;
  font-size: 0.84rem;
  font-weight: 690;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-text span,
.day-distance {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.2;
}

.day-distance {
  margin: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty-days {
  margin: 1rem 0.65rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.map-stage {
  position: relative;
  z-index: 0;
  grid-area: map;
  min-width: 0;
  min-height: 0;
  background: #d9dfda;
}

#map {
  width: 100%;
  height: 100%;
}

.leaflet-container {
  background: #d9dfda;
  font-family: inherit;
}

.leaflet-tile-pane {
  filter: saturate(0.72) sepia(0.07) brightness(1.035);
}

.leaflet-control-zoom a {
  border-color: rgb(63 65 59 / 12%) !important;
  background: rgb(255 253 249 / 92%) !important;
  color: var(--ink) !important;
}

.leaflet-control-attribution {
  background: rgb(255 253 249 / 78%) !important;
  color: #5f625e;
  font-size: 0.58rem !important;
}

.leaflet-control-attribution a {
  color: var(--blue);
}

.map-legend {
  position: absolute;
  z-index: 500;
  top: 1rem;
  right: 1rem;
  display: grid;
  gap: 0.38rem;
  padding: 0.62rem 0.72rem;
  border: 1px solid rgb(67 59 48 / 10%);
  border-radius: 0.55rem;
  background: rgb(255 253 249 / 92%);
  box-shadow: 0 5px 20px rgb(57 48 37 / 12%);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.map-legend span {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  color: #555b57;
  font-size: 0.64rem;
  font-weight: 640;
  white-space: nowrap;
}

.legend-line {
  display: inline-block;
  width: 1.8rem;
  height: 0;
  border-top: 3px solid;
}

.legend-line.ride {
  border-color: var(--terracotta);
}

.legend-line.train {
  border-color: var(--transfer);
  border-top-style: dashed;
}

.legend-line.connector {
  border-color: var(--terracotta-deep);
  border-top-style: dotted;
}

.day-detail {
  position: absolute;
  z-index: 500;
  bottom: 1.35rem;
  left: 1.35rem;
  width: min(21rem, calc(100% - 2.7rem));
  padding: 1rem 1.05rem 0.95rem;
  border: 1px solid rgb(67 59 48 / 10%);
  border-radius: 0.8rem;
  background: rgb(255 253 249 / 95%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.day-detail h2 {
  margin: 0;
  padding-right: 1.5rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.15;
}

.day-detail dl {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0.8rem;
}

.day-detail dd {
  font-size: 0.84rem;
}

.day-detail-close {
  position: absolute;
  top: 0.55rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.day-detail-close:hover,
.day-detail-close:focus-visible {
  color: var(--terracotta-deep);
  outline: 0;
}

.map-message {
  position: absolute;
  z-index: 600;
  top: 50%;
  left: 50%;
  width: min(24rem, calc(100% - 2rem));
  padding: 0.9rem 1rem;
  border-radius: 0.6rem;
  background: rgb(255 253 249 / 94%);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: center;
  transform: translate(-50%, -50%);
}

.place-icon,
.media-icon,
.media-cluster {
  background: transparent;
  border: 0;
}

.place-marker {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: max-content;
  transform: translate(-0.1rem, -50%);
}

.place-marker-dot {
  display: block;
  width: 0.78rem;
  height: 0.78rem;
  flex: 0 0 auto;
  border: 2px solid var(--white);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 1px 5px rgb(34 45 43 / 35%);
}

.place-marker.finish .place-marker-dot {
  background: var(--terracotta);
}

.place-marker-label {
  padding: 0.2rem 0.38rem;
  border-radius: 0.25rem;
  background: rgb(255 253 249 / 88%);
  box-shadow: 0 1px 5px rgb(34 45 43 / 12%);
  color: var(--ink);
  font-size: 0.63rem;
  font-weight: 720;
  letter-spacing: 0.025em;
  white-space: nowrap;
}

.media-marker {
  position: relative;
  width: 2.7rem;
  height: 2.7rem;
  overflow: hidden;
  border: 2px solid var(--white);
  border-radius: 0.5rem;
  background: var(--blue-soft);
  box-shadow: 0 4px 11px rgb(37 40 36 / 32%);
  transform: rotate(-1.5deg);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.media-marker:hover,
.leaflet-marker-icon:focus .media-marker {
  box-shadow: 0 6px 17px rgb(37 40 36 / 40%);
  transform: scale(1.08) rotate(0);
}

.media-marker img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-marker .video-badge {
  position: absolute;
  right: 0.18rem;
  bottom: 0.18rem;
  display: grid;
  place-items: center;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: rgb(31 43 43 / 82%);
  color: white;
  font-size: 0.55rem;
  line-height: 1;
}

.cluster-marker {
  display: grid;
  place-items: center;
  width: 2.45rem;
  height: 2.45rem;
  border: 2px solid var(--white);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 3px 12px rgb(37 40 36 / 34%);
  color: white;
  font-size: 0.74rem;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--white);
  color: var(--ink);
}

.leaflet-popup-content-wrapper {
  border-radius: 0.55rem;
  box-shadow: 0 5px 22px rgb(49 43 35 / 20%);
}

.transfer-popup {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
}

.transfer-popup strong,
.transfer-popup span {
  display: block;
}

.transfer-popup span {
  margin-top: 0.12rem;
  color: var(--muted);
}

.media-viewer {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: white;
}

.media-viewer::backdrop {
  background: rgb(22 24 23 / 94%);
  backdrop-filter: blur(10px);
}

.media-viewer-frame {
  position: relative;
  display: grid;
  grid-template-areas:
    "previous canvas next"
    ". caption .";
  grid-template-columns: 4.5rem minmax(0, 1fr) 4.5rem;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.media-canvas {
  display: grid;
  grid-area: canvas;
  place-items: center;
  min-width: 0;
  min-height: 0;
}

.media-canvas img,
.media-canvas video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 0.25rem;
  box-shadow: 0 10px 44px rgb(0 0 0 / 40%);
  object-fit: contain;
}

.media-caption {
  grid-area: caption;
  padding: 0.8rem 0 0.15rem;
  text-align: center;
}

.media-caption h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 500;
}

.media-caption p {
  margin: 0.25rem 0 0;
  color: rgb(255 255 255 / 68%);
  font-size: 0.7rem;
}

.media-close,
.media-step {
  border: 0;
  background: transparent;
  color: rgb(255 255 255 / 82%);
  cursor: pointer;
}

.media-close:hover,
.media-close:focus-visible,
.media-step:hover,
.media-step:focus-visible {
  color: white;
  outline: 0;
}

.media-close {
  position: absolute;
  z-index: 2;
  top: max(0.8rem, env(safe-area-inset-top));
  right: max(0.8rem, env(safe-area-inset-right));
  width: 2.75rem;
  height: 2.75rem;
  font-size: 2rem;
  line-height: 1;
}

.media-step {
  width: 100%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3rem;
}

.media-step.previous {
  grid-area: previous;
}

.media-step.next {
  grid-area: next;
}

.media-step[hidden] {
  display: block;
  visibility: hidden;
}

noscript {
  position: fixed;
  z-index: 10000;
  inset: 1rem;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
}

@media (max-width: 720px) {
  body {
    overflow: auto;
  }

  .album-shell {
    grid-template-areas:
      "header"
      "map"
      "days";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(62vh, 70dvh) auto;
    height: auto;
    min-height: 100dvh;
  }

  .journey-header {
    padding: max(1.15rem, env(safe-area-inset-top)) 1rem 1rem;
    border-right: 0;
  }

  h1 {
    font-size: clamp(1.8rem, 9vw, 2.4rem);
  }

  .journey-totals {
    margin-top: 1rem;
  }

  .day-browser {
    overflow: hidden;
    padding: 1rem 0 1.4rem;
    border-top: 1px solid rgb(92 77 58 / 12%);
    border-right: 0;
  }

  .day-browser-heading {
    padding: 0 1rem 0.65rem;
  }

  #day-list {
    display: flex;
    gap: 0.48rem;
    overflow-x: auto;
    padding: 0 1rem 0.45rem;
    scroll-padding-inline: 1rem;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  #day-list li {
    flex: 0 0 min(78vw, 18rem);
    scroll-snap-align: start;
  }

  .day-button {
    border-color: rgb(92 77 58 / 10%);
    background: rgb(255 253 249 / 55%);
  }

  .day-button[aria-current="true"] {
    transform: translateY(-0.1rem);
  }

  .map-legend {
    top: 0.65rem;
    right: 0.65rem;
    gap: 0.3rem;
    padding: 0.5rem 0.58rem;
  }

  .map-legend span {
    font-size: 0.58rem;
  }

  .day-detail {
    bottom: 0.75rem;
    left: 0.75rem;
    width: calc(100% - 1.5rem);
    padding: 0.82rem 0.9rem 0.78rem;
  }

  .day-detail h2 {
    font-size: 1.08rem;
  }

  .media-viewer-frame {
    grid-template-areas:
      "canvas canvas"
      "previous next"
      "caption caption";
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(0, 1fr) 3rem auto;
    padding: max(3.7rem, env(safe-area-inset-top)) max(0.65rem, env(safe-area-inset-right)) max(0.8rem, env(safe-area-inset-bottom)) max(0.65rem, env(safe-area-inset-left));
  }

  .media-step {
    font-size: 2.35rem;
    line-height: 1;
  }

  .media-step.previous {
    text-align: left;
  }

  .media-step.next {
    text-align: right;
  }

  .media-caption {
    padding-top: 0.35rem;
  }
}

@media (max-width: 410px) {
  .journey-totals {
    gap: 0.35rem;
  }

  .journey-totals dt {
    font-size: 0.57rem;
  }

  .journey-totals dd {
    font-size: 0.78rem;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
