.route-atlas {
  --panel-pad: clamp(1.05rem, 1.8vw, 2.6rem);
  position: relative;
  isolation: isolate;
  background: var(--ink);
  color: var(--white);
}

.atlas-header {
  position: absolute;
  z-index: 2;
  inset: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1.1rem, 2.2vw, 2.4rem);
  pointer-events: none;
  text-shadow: 0 1px 6px #21212185;
}
.atlas-header::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 0 -70%;
  background: linear-gradient(to bottom, #212121b5, #2121219e 45%, transparent);
}

.atlas-header h2, .atlas-header p {
  margin: 0;
  font: 500 clamp(.83rem, 1.12vw, 1.15rem)/1.2 var(--sans);
  letter-spacing: -.025em;
}

.route-board {
  --route-ease: cubic-bezier(.21,.68,.27,1);
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 22rem;
  overflow: hidden;
  background: var(--ink);
}

.route-panel, .route-face {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
}

.route-panel { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
/* Overlap adjacent photographic faces at their clipped edges. WebKit rounds each
   clip separately at fractional device scales. The semantic card keeps its grid size. */
.route-face {
  width: calc(100% + 1px);
  height: calc(100% + 1px);
  overflow: hidden;
  background: var(--ink);
}
.route-cover {
  position: absolute;
  top: -1px;
  left: -1px;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  max-width: none;
  object-fit: cover;
}
.route-panel[data-route="suzhou"] { --route-scene: url("/images/suzhou.webp"); }
.route-panel[data-route="shanyin"] { --route-scene: url("/images/shanyin.webp"); }
.route-panel[data-route="westbund"] { --route-scene: url("/images/westbund.webp"); }
.route-panel[data-route="bespoke"] { --route-scene: url("/images/bespoke.webp"); }

.route-toggle {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(3.25rem, 1.35fr) auto minmax(4rem, .65fr);
  width: 100%;
  height: 100%;
  min-width: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0 var(--panel-pad);
  text-align: left;
  color: var(--white);
  background: transparent;
}
/* Anchor the fade to the start of the actual text, including long CMS titles. */
.route-toggle::before {
  content: "";
  --fade: clamp(2.5rem, 11vh, 8rem);
  position: absolute;
  grid-area: 2 / 1 / 4 / 2;
  inset: calc(0px - var(--fade)) calc(0px - var(--panel-pad)) 0;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, #212121b8 var(--fade), #212121c2 82%, #212121a8);
}
.route-summary {
  grid-row: 2;
  position: relative;
  display: grid;
  align-content: start;
  min-width: 0;
}

.route-number, .route-detail-top p {
  margin: 0;
  font: 500 .75rem/1.2 var(--sans);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.route-number, .route-title { color: var(--lime); }

.route-title, .route-detail-copy h3 {
  margin: .65rem 0 .85rem;
  font: 400 clamp(1.85rem, 3.15vw, 4.2rem)/1.01 var(--serif);
  letter-spacing: -.045em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.route-place { font: 500 clamp(.9rem, 1.05vw, 1.14rem)/1.3 var(--sans); }
.route-intro {
  max-width: 29ch;
  margin-top: .58rem;
  font: 400 clamp(.88rem, 1vw, 1.06rem)/1.42 var(--sans);
  color: inherit;
}

.atlas-plus {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.55rem;
  height: 2.55rem;
  padding: 0;
  border: 1px solid currentColor;
  border-radius: 50%;
  color: var(--lime);
}

.atlas-plus svg { display: block; width: 1rem; height: 1rem; }
.route-toggle > .atlas-plus { position: absolute; bottom: var(--panel-pad); right: var(--panel-pad); }
.route-summary, .route-toggle > .atlas-plus {
  opacity: 1;
  transform: none;
  transition: opacity 175ms ease-out 90ms, transform 230ms var(--route-ease) 90ms;
}
.route-panel.is-open .route-summary, .route-panel.is-open .route-toggle > .atlas-plus {
  opacity: 0;
  transform: translateY(-.36rem);
  transition: opacity 95ms ease-out, transform 130ms var(--route-ease);
}
.route-close svg { transform: rotate(45deg); }
.route-close { color: var(--white); border-color: #ffffff80; }
.route-close:hover, .route-close:focus-visible { background: #ffffff1c; }
.route-toggle:focus-visible { outline: 2px solid var(--lime); outline-offset: -5px; }
.route-detail button:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }

.route-detail {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(1.25rem, 4vh, 3rem);
  padding: clamp(3.8rem, 9vh, 7rem) var(--panel-pad) var(--panel-pad);
  overflow-y: auto;
  background: linear-gradient(180deg, #19191960, #191919cd 48%, #191919e8);
  color: var(--white);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 165ms ease-out, visibility 0s linear 165ms;
  scrollbar-width: thin;
  scrollbar-color: var(--line) var(--ink);
}

.route-panel.is-open .route-detail {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 190ms ease-out;
}
.route-detail > div {
  opacity: 0;
  transform: translateY(.55rem);
  transition: opacity 95ms ease-out, transform 155ms var(--route-ease);
}
.route-panel.is-open .route-detail > div {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 175ms ease-out 90ms, transform 245ms var(--route-ease) 70ms;
}
.route-detail-top, .route-detail-footer { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.route-detail-top p { line-height: 1.5; color: var(--lime); text-shadow: 0 0 1px #000c, 0 1px 4px #0008; }
.route-detail-copy { margin-block: auto; }
.route-detail-copy h3 { margin: 0; font-size: clamp(1.8rem, 2.6vw, 3.5rem); }
.route-theme { margin: 1.05rem 0 .7rem; color: var(--lime); font: 500 clamp(.9rem, 1vw, 1.1rem)/1.38 var(--sans); }
.route-story { margin: 0; max-width: 48ch; font: 400 clamp(.94rem, 1.07vw, 1.13rem)/1.52 var(--sans); white-space: pre-line; overflow-wrap: anywhere; }
.route-detail-footer { border-top: 1px solid #ffffff55; padding-top: .95rem; flex-wrap: wrap; }
.route-detail-footer p { margin: 0; font: 400 .81rem/1.45 var(--sans); color: var(--white); }
.route-choose { min-height: 2.75rem; padding: .55rem .9rem; border: 1px solid currentColor; border-radius: 2rem; font: 500 .86rem/1.1 var(--sans); color: var(--lime); background: transparent; }
.route-choose:hover { color: var(--ink); background: var(--lime); }

@media (min-width: 661px) and (max-height: 650px) {
  .route-toggle { grid-template-rows: minmax(3rem, 1fr) auto minmax(3.75rem, .65fr); }
  .route-title { font-size: clamp(1.8rem, 3vw, 3rem); }
  .route-detail { gap: 1rem; }
}

@media (max-width: 660px), (max-width: 950px) and (max-height: 500px) {
  .route-atlas { --panel-pad: clamp(.85rem, 3.7vw, 1.4rem); }
  .route-board { grid-template-columns: repeat(2, minmax(0,1fr)); grid-template-rows: repeat(2,minmax(0,1fr)); min-height: 33rem; }
  .atlas-header { padding: .9rem var(--edge); }
  .atlas-header h2, .atlas-header p { font-size: .76rem; }
  .route-panel { position: static; overflow: visible; }
  .route-toggle { grid-template-rows: minmax(0, 1fr) auto 3.3rem; }
  .route-title { margin: .45rem 0 .55rem; font-size: clamp(1.55rem, 6.3vw, 2.5rem); }
  .route-place { font-size: .83rem; }
  .route-intro { margin-top: .34rem; font-size: .79rem; line-height: 1.32; }
  .route-toggle > .atlas-plus { bottom: .7rem; width: 1.95rem; height: 1.95rem; }
  .route-toggle > .atlas-plus svg { width: .8rem; height: .8rem; }
  .route-detail {
    z-index: 3;
    gap: 1.8rem;
    padding: clamp(1.4rem,5vw,2.2rem);
    background: linear-gradient(170deg, #191919b3, #191919e8 52%, #191919f7), var(--route-scene) center/cover var(--ink);
  }
  .route-detail-copy h3 { font-size: clamp(2.5rem, 9vw, 3.6rem); }
  .route-story { font-size: 1rem; line-height: 1.55; }
  .route-theme { margin: 1.1rem 0 .75rem; font-size: 1rem; }
}

@media (min-width: 560px) and (max-width: 950px) and (max-height: 500px) {
  .route-atlas { --panel-pad: clamp(.85rem, 2.2vw, 1.4rem); }
  .route-board { min-height: 23rem; }
  .atlas-header { padding: .5rem var(--panel-pad); }
  .route-toggle { grid-template-rows: minmax(1.75rem, 1fr) auto minmax(.6rem, .65fr); }
  .route-summary { padding-right: 1.9rem; }
  .route-title { margin: .18rem 0 .24rem; font-size: clamp(1.4rem, 3.4vw, 1.85rem); }
  .route-intro { margin-top: .2rem; }
  .route-detail { gap: .85rem; padding: .9rem clamp(1rem, 3.5vw, 2.1rem); }
  .route-detail-copy h3 { font-size: clamp(1.8rem, 5vw, 2.6rem); }
  .route-story { max-width: 72ch; font-size: .98rem; }
  .route-theme { margin-block: .45rem; }
}

@media (prefers-reduced-motion: reduce) {
  .route-board .route-panel .route-detail, .route-board .route-panel .route-detail > div,
  .route-board .route-panel .route-summary, .route-board .route-panel .route-toggle > .atlas-plus {
    transform: none;
    transition: none;
  }
}
