/* ==========================================================================
   Road microsite
   Enhanced (scroll-driven) layout is the default; `.no-js` on <html> switches
   to a plain readable list (no JavaScript, or GSAP failed to load).

   Breakpoint: below 60em ("compact") the stop texts are hidden on the map and
   open as popovers instead. Keep in sync with CONFIG.compactQuery in main.js.
   ========================================================================== */

:root {
  /* Artwork */
  --road-aspect: 1096.926 / 696.471;   /* viewBox of the artwork – never change */
  --road-zoom: max(200%, 252svh);      /* canvas width (incl. padding) relative to the viewport */
  --road-pad: calc(var(--road-zoom) * 0.03); /* white space around the artwork, scales with the zoom */

  /* Colours */
  --road-ink: #1d1d1b;
  --road-bg: #fff;
  --road-placeholder: #f1eee9;         /* shown when assets/road.svg is missing */
  --road-hurdle: #f39b9b;              /* hurdles: trail, buttons, badges */
  --road-path: #86cee1;                /* ways + goal: trail, buttons, badges */
  --road-hurdle-strong: #e97f7f;       /* dashed arrows */
  --road-path-strong: #5cb6cf;
  --road-marker: #1d1d1b;
  --road-marker-ring: #fff;
  --road-focus: #1d1d1b;
  --road-intro-bg: var(--road-hurdle); /* start screen */

  /* Stop buttons – placeholder design, replace with the final one */
  --stop-size: 3.75rem;
  --stop-border: 3px solid var(--road-ink);
  --stop-shadow: 0 0.35rem 1rem rgb(29 29 27 / 0.3);

  /* Panels (popovers, compact screens only) */
  --panel-width: 26rem;
  --panel-gap: 1.5rem;
  --panel-bg: #fff;
  --panel-radius: 1.25rem;
  --panel-shadow: 0 1rem 3rem rgb(29 29 27 / 0.22);
  --panel-duration: 0.45s;
  --panel-ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--road-bg);
  color: var(--road-ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

.road_visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Viewport, canvas, map layers
   -------------------------------------------------------------------------- */

.road_viewport {
  position: relative;
  height: 100svh;
  overflow: clip;
}

.road_canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--road-zoom);
  padding: var(--road-pad);
  background: var(--road-bg);
  will-change: transform;
}

/* Everything inside the map is positioned in artwork units: --u = one unit */
.road_map {
  --u: calc(100cqw / 1096.926);

  position: relative;
  width: 100%;
  aspect-ratio: var(--road-aspect);
  container-type: inline-size;
}

.road_map:has(> .road_art--base[hidden]) {
  background: var(--road-placeholder);
}

.road_art,
.road_route,
.road_arrows {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.road_art {
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* Stacking: road < lettering strips < trail + marker < trees < arrows < stops + lettering */
.road_art--base { z-index: 0; }
.road_sign-masks { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.road_route     { z-index: 1; overflow: visible; pointer-events: none; }
.road_art--top  { z-index: 2; }
.road_arrows    { z-index: 3; overflow: visible; pointer-events: none; }
.road_stops     { position: absolute; inset: 0; z-index: 4; }

.road_trail {
  fill: none;
  stroke: var(--road-hurdle);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.road_trail--path {
  stroke: var(--road-path);
}

.road_marker {
  fill: var(--road-marker);
  stroke: var(--road-marker-ring);
  stroke-width: 3;
}

.road_arrow {
  fill: none;
  stroke: var(--road-hurdle-strong);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.road_arrow--line {
  stroke-dasharray: 6 6;
}

.road_arrow[data-type="path"],
.road_arrow[data-type="end"] {
  stroke: var(--road-path-strong);
}

/* --------------------------------------------------------------------------
   Lettering on the road (live text, translatable). The copy in .road_sign-masks
   is an invisible twin with a white background that hides the centre-line
   dashes under the text but stays below the trail.
   -------------------------------------------------------------------------- */

.road_sign {
  position: absolute;
  left: calc(var(--sx) * var(--u));
  top: calc(var(--sy) * var(--u));
  translate: 0 -50%;
  margin: 0;
  padding: calc(3 * var(--u)) calc(5 * var(--u));
  font-size: calc(17 * var(--fit, 1) * var(--u));
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}

.road_sign-masks .road_sign {
  color: transparent;
  background: var(--road-bg);
}

/* --------------------------------------------------------------------------
   Stops: button + label. JS sets --x / --y (fractions of the map) per item.
   -------------------------------------------------------------------------- */

.road_stop-item {
  --type-color: var(--road-hurdle);
}

.road_stop-item[data-type="path"],
.road_stop-item[data-type="end"] {
  --type-color: var(--road-path);
}

.road_stop {
  position: absolute;
  z-index: 2;
  left: calc(var(--x, 0) * 100%);
  top: calc(var(--y, 0) * 100%);
  translate: -50% -50%;
  display: grid;
  place-items: center;
  width: var(--stop-size);
  height: var(--stop-size);
  padding: 0;
  border: var(--stop-border);
  border-radius: 50%;
  background: var(--type-color);
  color: var(--road-ink);
  box-shadow: 0 0 0 5px var(--road-bg), var(--stop-shadow);
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: scale 0.2s ease, opacity 0.3s ease;
}

/* Pulsing ring to draw attention */
.road_stop::before {
  content: "";
  position: absolute;
  inset: -8px;
  border: 3px solid var(--type-color);
  border-radius: 50%;
  pointer-events: none;
  animation: road-pulse 2.4s ease-out infinite;
}

@keyframes road-pulse {
  0%        { scale: 0.9; opacity: 1; }
  70%, 100% { scale: 1.6; opacity: 0; }
}

/* The Ziel button replaces the blue end circle of the artwork, so it scales with the map */
.road_stop-item[data-type="end"] .road_stop {
  width: max(var(--stop-size), calc(54 * var(--u)));
  height: max(var(--stop-size), calc(54 * var(--u)));
  font-size: max(0.9rem, calc(13 * var(--u)));
  letter-spacing: 0.02em;
}

.road.is-ready .road_stop {
  opacity: 1;
}

.road_stop:hover,
.road_stop.is-active {
  scale: 1.1;
}

.road_stop.is-active {
  box-shadow: 0 0 0 5px var(--road-bg), 0 0 0 8px var(--road-ink), var(--stop-shadow);
}

.road_stop.is-active::before {
  animation: none;
  opacity: 0;
}

.road_stop:focus-visible,
.road_panel-close:focus-visible {
  outline: 3px solid var(--road-focus);
  outline-offset: 7px;
}

.road_panel-close:focus-visible {
  outline-offset: 3px;
}

/* Label – desktop: the full text block, placed and sized in artwork units */
.road_label {
  position: absolute;
  z-index: 1;
  left: calc(var(--lx) * var(--u));
  top: calc(var(--ly) * var(--u));
  width: calc(var(--lw) * var(--u));
  font-size: calc(8.6 * var(--u));
  line-height: 1.42;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.road.is-ready .road_label {
  opacity: 1;
}

.road_label-heading {
  margin: 0;
  font-size: inherit;
  font-weight: 400;
}

.road_label-eyebrow {
  display: flex;
  align-items: center;
  gap: calc(5 * var(--u));
  margin-bottom: calc(8 * var(--u));
  font-size: calc(19 * var(--u));
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
}

.road_label-num {
  display: inline-grid;
  place-items: center;
  width: calc(19 * var(--u));
  height: calc(19 * var(--u));
  border-radius: 50%;
  background: var(--type-color);
  font-size: calc(11 * var(--u));
}

.road_label-title {
  display: block;
  margin-bottom: calc(3 * var(--u));
  font-size: calc(11.5 * var(--u));
  font-weight: 700;
  line-height: 1.2;
}

.road_label-text {
  margin: 0;
  hyphens: auto;
  text-wrap: pretty;
}

/* Label – compact: short tag (eyebrow + title) next to the button */
@media (width < 60em) {
  .road_stops {
    --stop-size: 3rem;
  }

  /* Positioned by main.js: --tx / --ty = offset of the tag's corner from its stop */
  .road_label {
    left: calc(var(--x, 0) * 100%);
    top: calc(var(--y, 0) * 100%);
    width: max-content;
    max-width: 10rem;
    translate: var(--tx, -50%) var(--ty, -50%);
    padding: 0.45rem 0.65rem 0.5rem;
    border: 2px solid var(--road-ink);
    border-radius: 0.75rem;
    background: var(--road-bg);
    box-shadow: 0 0.25rem 0.75rem rgb(29 29 27 / 0.15);
    font-size: 0.8125rem;
    line-height: 1.25;
  }

  .road_label-eyebrow {
    gap: 0.35rem;
    margin-bottom: 0.2rem;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }

  .road_label-num {
    width: 1.35rem;
    height: 1.35rem;
    font-size: 0.75rem;
  }

  .road_label-title {
    margin-bottom: 0;
    font-size: 0.9375rem;
  }

  .road_label-text {
    display: none;
  }

  /* By default only the pulsing buttons show on small screens; the headings stay for screen readers.
     Add data-compact-tags to <main class="road"> to show short title tags with arrows instead. */
  .road:not([data-compact-tags]) .road_label {
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
    translate: none;
  }
}

/* --------------------------------------------------------------------------
   Wording that depends on the device: road_if-pointer / road_if-touch (mouse vs.
   finger) and road_if-desktop / road_if-compact (texts on the map vs. popovers)
   -------------------------------------------------------------------------- */

.road_if-touch,
.road_if-compact.road_if-compact {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .road_if-pointer { display: none; }
  .road_if-touch   { display: inline; }
}

@media (width < 60em) {
  .road_if-desktop.road_if-desktop { display: none; }
  .road_if-compact.road_if-compact { display: block; }
}

/* --------------------------------------------------------------------------
   Start screen (slides up during the first screen of scrolling, see main.js)
   -------------------------------------------------------------------------- */

.road_intro {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: max(2rem, env(safe-area-inset-top)) 1.5rem max(2rem, env(safe-area-inset-bottom));
  background: var(--road-intro-bg);
  color: var(--road-ink);
  will-change: transform;
}

/* The road peeks out at the bottom edge, like the start of the map */
.road_intro::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 2.25rem;
  left: 0;
  height: 3.25rem;
  border-block: 3px solid var(--road-ink);
  background:
    linear-gradient(90deg, var(--road-ink) 50%, transparent 0) 0 50% / 2.5rem 3px repeat-x,
    var(--road-bg);
  pointer-events: none;
}

/* Language switch (rendered only when more than one language is enabled in content/site.json) */
.road_lang {
  position: absolute;
  z-index: 2;
  top: max(1.25rem, env(safe-area-inset-top));
  right: 1.25rem;
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 2px solid var(--road-ink);
  border-radius: 99rem;
  background: var(--road-bg);
}

.road_lang-link {
  padding: 0.3rem 0.7rem;
  border-radius: 99rem;
  color: var(--road-ink);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.road_lang-link:hover {
  background: rgb(29 29 27 / 0.08);
}

.road_lang-link[aria-current="page"] {
  background: var(--road-ink);
  color: var(--road-bg);
}

.road_lang-link:focus-visible {
  outline: 3px solid var(--road-focus);
  outline-offset: 2px;
}

.road_intro-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.5rem;
  width: min(46rem, 100%);
  margin-bottom: 4rem;
}

.road_intro-title {
  margin: 0;
  font-size: clamp(2.5rem, 1.2rem + 5.5vw, 5.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.road_intro-kicker {
  display: block;
  margin-bottom: 0.75rem;
  font-size: clamp(0.875rem, 0.8rem + 0.4vw, 1.0625rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.3;
  text-transform: uppercase;
}

.road_intro-lead {
  max-width: 36rem;
  margin: 0;
  font-size: clamp(1.0625rem, 0.95rem + 0.5vw, 1.375rem);
  line-height: 1.45;
  text-wrap: pretty;
}

.road_intro-how {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border: 2px solid var(--road-ink);
  border-radius: 1rem;
  background: var(--road-bg);
}

/* Mouse (pointer) / phone (touch) outline with a moving dot */
.road_intro-icon {
  position: relative;
  flex: none;
  width: 1.5rem;
  height: 2.35rem;
  border: 2px solid var(--road-ink);
  border-radius: 0.8rem;
}

.road_intro-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0.4rem;
  width: 0.3rem;
  height: 0.5rem;
  margin-left: -0.15rem;
  border-radius: 0.2rem;
  background: var(--road-ink);
  animation: road-intro-scroll 1.6s ease-in-out infinite;
}

@keyframes road-intro-scroll {
  0%   { translate: 0 0; opacity: 1; }
  70%  { translate: 0 0.8rem; opacity: 0; }
  100% { translate: 0 0; opacity: 0; }
}

.road_intro-how-text {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.35;
}

.road_intro-how-text > span {
  display: block;
}

.road_intro-how-main {
  font-weight: 700;
}

@media (hover: none) and (pointer: coarse) {
  .road_intro-icon {
    border-radius: 0.35rem;
  }

  .road_intro-icon::after {
    top: auto;
    bottom: 0.4rem;
    animation-name: road-intro-swipe;
  }

  @keyframes road-intro-swipe {
    0%   { translate: 0 0; opacity: 1; }
    70%  { translate: 0 -0.8rem; opacity: 0; }
    100% { translate: 0 0; opacity: 0; }
  }
}

.road_intro-start {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.4rem;
  border: 0;
  border-radius: 99rem;
  background: var(--road-ink);
  color: var(--road-bg);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.road_intro-start::after {
  content: "↓";
  font-size: 1.1em;
  line-height: 1;
}

.road_intro-start:hover {
  background: #000;
}

.road_intro-start:focus-visible {
  outline: 3px solid var(--road-ink);
  outline-offset: 3px;
}

@media (height < 40em) {
  .road_intro-inner { gap: 1rem; margin-bottom: 3rem; }
  .road_intro::after { bottom: 1rem; height: 2.5rem; }
}

/* --------------------------------------------------------------------------
   Tip on compact screens ("tap the dots"), toggled by main.js
   -------------------------------------------------------------------------- */

.road_tip {
  position: absolute;
  z-index: 3;
  top: max(1rem, env(safe-area-inset-top));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: max-content;
  max-width: calc(100% - 2rem);
  margin: 0;
  padding: 0.7rem 1.1rem 0.7rem 0.9rem;
  border: 2px solid var(--road-ink);
  border-radius: 99rem;
  background: var(--road-bg);
  box-shadow: 0 0.5rem 1.5rem rgb(29 29 27 / 0.2);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
  pointer-events: none;
  translate: -50% -1rem;
  opacity: 0;
  visibility: hidden;
  transition:
    translate 0.35s ease,
    opacity 0.35s ease,
    visibility 0s linear 0.35s;
}

.road_tip.is-active {
  translate: -50% 0;
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

/* A mini stop button with the same pulse */
.road_tip-dot {
  position: relative;
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--road-ink);
  border-radius: 50%;
  background: var(--road-hurdle);
}

.road_tip-dot::before {
  content: "";
  position: absolute;
  inset: -5px;
  border: 2px solid var(--road-hurdle);
  border-radius: 50%;
  animation: road-pulse 2.4s ease-out infinite;
}

/* --------------------------------------------------------------------------
   Panels (popovers on compact screens)
   -------------------------------------------------------------------------- */

.road_panels {
  position: absolute;
  inset: 0;
  z-index: 4;
  container-type: inline-size;
  pointer-events: none;
}

.road_panel {
  --panel-accent: var(--road-hurdle);

  position: absolute;
  right: var(--panel-gap);
  bottom: var(--panel-gap);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: min(var(--panel-width), 100% - 2 * var(--panel-gap));
  max-height: calc(100% - 2 * var(--panel-gap));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.5rem 1.75rem 1.75rem;
  border-top: 0.5rem solid var(--panel-accent);
  border-radius: var(--panel-radius);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  pointer-events: auto;
  translate: calc(100% + var(--panel-gap) + 2rem) 0;
  visibility: hidden;
  transition:
    translate var(--panel-duration) var(--panel-ease),
    visibility 0s linear var(--panel-duration);
}

.road_panel[data-type="path"],
.road_panel[data-type="end"] {
  --panel-accent: var(--road-path);
}

.road_panel.is-active {
  translate: 0 0;
  visibility: visible;
  transition-delay: 0s;
}

.road_panel-eyebrow {
  margin: 0 0 0.5rem;
  padding: 0.2rem 0.7rem;
  border-radius: 99rem;
  background: var(--panel-accent);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.road_panel-title {
  margin: 0 0 0.5rem;
  font-size: 1.375rem;
  line-height: 1.2;
  text-wrap: balance;
}

.road_panel-text {
  margin: 0 0 1.25rem;
  font-size: 1rem;
  text-wrap: pretty;
  hyphens: auto;
}

.road_panel-close {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
  padding: 0.55rem 1.1rem;
  border: 2px solid var(--road-ink);
  border-radius: 99rem;
  background: transparent;
  color: var(--road-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.road_panel-close::before {
  content: "×";
  font-size: 1.25em;
  line-height: 1;
}

.road_panel-close:hover {
  background: var(--road-ink);
  color: var(--panel-bg);
}

/* Small screens: full-width bottom sheet */
@container (width < 42em) {
  .road_panel {
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    max-height: 70%;
    padding-bottom: max(1.75rem, env(safe-area-inset-bottom));
    border-radius: var(--panel-radius) var(--panel-radius) 0 0;
    translate: 0 calc(100% + 2rem);
  }

  .road_panel-title {
    font-size: 1.25rem;
  }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .road_panel,
  .road_stop,
  .road_label,
  .road_tip {
    transition: none;
  }

  .road_stop::before,
  .road_tip-dot::before,
  .road_intro-icon::after {
    animation: none;
  }

  .road_stop::before {
    opacity: 0;
  }
}

/* --------------------------------------------------------------------------
   Fallback: no JavaScript or GSAP unavailable – show a readable list
   -------------------------------------------------------------------------- */

.no-js .road_viewport {
  height: auto;
  overflow: visible;
}

.no-js .road_canvas {
  position: relative;
  width: 100%;
  padding: 1rem;
}

.no-js .road_route,
.no-js .road_arrows,
.no-js .road_stop,
.no-js .road_label,
.no-js .road_intro-how,
.no-js .road_tip,
.no-js .road_intro-start,
.no-js .road_intro::after,
.no-js .road_panel-close {
  display: none;
}

.no-js .road_sign {
  background: var(--road-bg);
}

.no-js .road_intro {
  position: static;
  min-height: 60svh;
}

.no-js .road_intro-inner {
  margin-bottom: 0;
}

.no-js .road_panels {
  position: static;
  display: grid;
  gap: 1.5rem;
  max-width: 42rem;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
  container-type: normal;
  pointer-events: auto;
}

.no-js .road_panel {
  position: static;
  width: auto;
  max-height: none;
  overflow: visible;
  translate: none;
  visibility: visible;
  transition: none;
  box-shadow: none;
  border: 1px solid rgb(29 29 27 / 0.15);
  border-top: 0.5rem solid var(--panel-accent);
}
