.maggrid {
  --photo-height: clamp(315px, 29vw, 375px);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: var(--photo-height);
  gap: clamp(13px, 1.6vw, 21px);
  list-style: none;
  margin: 0;
  padding: 0;
}

.hub-item { grid-column: span 2; min-width: 0; }
.hub-item--featured { grid-column: span 4; }
.hub-item--half { grid-column: span 3; }

.magcard {
  --shade: 36 29 23;
  --card-pad: clamp(14px, 1.65vw, 24px);
  display: block;
  height: 100%;
  border-radius: 15px;
  perspective: 1100px;
  -webkit-tap-highlight-color: transparent;
}

.magcard:focus-visible { outline: 2px solid var(--cinnabar, #a63830); outline-offset: 4px; }
.magcard[data-city="beijing"] { --crop: 52% 30%; }
.magcard[data-city="tianjin"] { --crop: 50% 40%; --shade: 39 35 31; }
.magcard[data-city="datong"] { --crop: 50% 39%; }
.magcard[data-city="jinshanling"] { --crop: 50% 39%; }

.magcard-face {
  position: relative;
  display: flex;
  align-items: end;
  height: 100%;
  isolation: isolate;
  overflow: hidden;
  padding: var(--card-pad);
  border-radius: inherit;
  color: #fff;
  background: rgb(var(--shade));
  box-shadow: 0 3px 8px rgb(25 24 22 / .15);
}

.magcard img,
.magcard-face::before,
.magcard-face::after {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.magcard img { z-index: -3; object-fit: cover; object-position: var(--crop, 50% 47%); }

.magcard-face::before {
  content: "";
  z-index: -2;
  background: linear-gradient(to top, rgb(var(--shade) / .98), rgb(var(--shade) / .82) 17%,
    rgb(var(--shade) / .38) 32%, transparent 53%);
}

.magcard-duration {
  position: absolute;
  inset: 14px auto auto 14px;
  margin: 0;
  padding: 5px 10px;
  border-radius: 999px;
  color: #272019;
  background: #fff8f0;
  font: 650 .75rem/1.25 Inter, system-ui, sans-serif;
  white-space: nowrap;
}

.magcard-copy {
  position: relative;
  min-width: 0;
  width: 100%;
}

.magcard-copy h3 {
  margin: 0;
  color: #fff;
  font: 440 clamp(25px, 2.75vw, 41px)/1.04 Fraunces, Georgia, serif;
  letter-spacing: -.024em;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 4px rgb(0 0 0 / .55);
}

.hub-item--featured .magcard-copy h3 { font-size: clamp(39px, 4.5vw, 59px); }

.magcard-copy h3 span {
  margin-inline-start: 4px;
  color: #f7eee6;
  font: 450 .8125rem/1.28 "Noto Sans SC", "PingFang SC", system-ui, sans-serif;
  letter-spacing: 0;
  white-space: nowrap;
}

.magcard-highlights {
  margin: 7px 0 0;
  color: #fffaf5;
  font: 540 .9rem/1.43 Inter, system-ui, sans-serif;
  text-wrap: pretty;
}

.magcard-landmark {
  margin: 6px 0 0;
  padding-inline-end: 30px;
  color: #f2e7dc;
  font: 450 .8125rem/1.4 Inter, system-ui, sans-serif;
  overflow-wrap: anywhere;
}

.magcard-arrow {
  position: absolute;
  inset: auto 4px 1px auto;
  color: #fff;
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .magcard-face {
    transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) translateY(var(--lift, 0px));
    transition: transform 350ms cubic-bezier(.22, 1, .36, 1);
  }

  .magcard-face::after {
    content: "";
    z-index: -1;
    opacity: 0;
    background: radial-gradient(ellipse at var(--glare-x, 50%) var(--glare-y, 50%),
      rgb(255 248 230 / .15), transparent 55%);
    transition: opacity 260ms ease;
  }

  .magcard-arrow { transition: transform 250ms cubic-bezier(.22, 1, .36, 1); }
  .magcard[data-tilting] .magcard-face { --lift: -2px; transition-duration: 140ms; }
  .magcard[data-tilting] .magcard-face::after { opacity: 1; }
  .magcard:is([data-tilting], :focus-visible) .magcard-arrow { transform: translateX(3px); }
}

@media (max-width: 930px) {
  .maggrid {
    --photo-height: clamp(288px, 46vw, 350px);
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .maggrid > .hub-item { grid-column: auto; }
  .maggrid > .hub-item--featured,
  .maggrid:has(.hub-item--featured) > :last-child:nth-child(even),
  .maggrid:not(:has(.hub-item--featured)) > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  /* Keep the compact header within the directory viewport. */
  body:has(.dest-hub) nav.nav#ctcnav { gap: 8px; }
  body:has(.dest-hub) nav.nav#ctcnav .nav-links { display: none; }
  body:has(.dest-hub) nav.nav#ctcnav .nav-left { gap: 8px; }
  body:has(.dest-hub) nav.nav#ctcnav .nav-left b { font-size: 16px !important; }
  body:has(.dest-hub) nav.nav#ctcnav .nav-cta { white-space: nowrap; }
}

@media (max-width: 560px) {
  .maggrid { --photo-height: clamp(220px, 58vw, 290px); gap: 12px; }
  .magcard { --card-pad: 12px; border-radius: 13px; }
  .magcard-duration { inset: 10px auto auto 10px; }
  .magcard-copy h3 { font-size: clamp(22px, 5.7vw, 30px); }
  .magcard-copy h3 span { font-size: .6875rem; }
  .magcard-highlights { font-size: .8125rem; line-height: 1.38; }
  .magcard-landmark { font-size: .75rem; }
  .magcard-arrow { width: 16px; height: 16px; inset-inline-end: 2px; }
  .magcard-face::before {
    background: linear-gradient(to top, rgb(var(--shade) / .98), rgb(var(--shade) / .81) 23%,
      rgb(var(--shade) / .40) 40%, transparent 60%);
  }
}

@media (max-width: 359px) {
  .maggrid { --photo-height: 245px; grid-template-columns: 1fr; }
}
