/*
 * The Living City (M7): layered scenes, parallax, door kinds, transit, and the small motions that
 * keep the city breathing (lanterns sway, water shimmers, steam drifts). Every motion stops for
 * people who ask their system for reduced motion.
 */

/* ---------- Scene layers and parallax ---------- */
.city { position: absolute; inset: 0; overflow: hidden; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.city.pannable { cursor: grab; }
.city.dragging { cursor: grabbing; }
.city-scene { position: absolute; inset: 0; animation: city-fade-in .6s ease both; }
.city-scene.leaving { animation: city-fade-out .6s ease both; }
.city-layer, .city-hit {
  position: absolute; top: 0; left: 0; height: 100%;
  transform: translate3d(calc(var(--pan, 0) * var(--travel, 0px) * var(--depth, 1) * -1), 0, 0);
  will-change: transform;
}
.city-layer { pointer-events: none; }
.city-layer svg { display: block; width: 100%; height: 100%; }
.city-overlay { transform: none; }
.city-hit { --depth: 1; z-index: 1; }
.city.smooth .city-layer, .city.smooth .city-hit { transition: transform .45s cubic-bezier(.3, .7, .3, 1); }
.city .doors, .city .seats { position: absolute; inset: 0; }
.stage.in-city .bg { opacity: 0; }
.stage.moving .city-scene { filter: brightness(.65) saturate(.85); transition: filter .3s ease; }
@keyframes city-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes city-fade-out { from { opacity: 1; } to { opacity: 0; } }

.city-edge {
  position: absolute; top: 50%; z-index: 2; transform: translateY(-50%);
  width: 2.4rem; height: 4.5rem; min-height: 0; padding: 0;
  border: 1px solid rgba(255, 255, 255, .18); border-radius: 999px;
  background: rgba(10, 6, 22, .55); color: var(--ink, #ece8f7); font-size: 1.6rem; line-height: 1;
  opacity: .55; transition: opacity .2s ease;
}
.city-edge:hover, .city-edge:focus-visible { opacity: 1; }
.city-edge-left { left: .4rem; }
.city-edge-right { right: .4rem; }

/* ---------- Door kinds ---------- */
.city .door { border-radius: 14px 14px 6px 6px; }
.city .door .door-label { opacity: 0; transform: translateY(4px); transition: opacity .2s ease, transform .2s ease; }
.city .door:hover .door-label, .city .door:focus-visible .door-label, .city .door.target .door-label { opacity: 1; transform: none; }
@media (hover: none) { .city .door .door-label { opacity: .92; transform: none; } }
.city .door.kind-street { justify-content: center; border-radius: 10px; }
.city .door.kind-street .door-label { opacity: .9; transform: none; }
.city .door.kind-street.street-left .door-label::before { content: '‹ '; }
.city .door.kind-stairs-down, .city .door.kind-stairs-up { border-radius: 10px; }
/* Hidden ways are not outlined: you find them by looking (or by tabbing, which reveals them). */
.city .door.kind-hidden { border-color: transparent; background: transparent; }
.city .door.kind-hidden:hover, .city .door.kind-hidden:focus-visible { border-color: rgba(127, 243, 255, .35); background: rgba(127, 243, 255, .06); }
.city .door.kind-sealed { border-color: rgba(127, 243, 255, .45); animation: city-seal 3.5s ease-in-out infinite; }
@keyframes city-seal { 50% { box-shadow: 0 0 28px rgba(127, 243, 255, .45) inset; } }

/* ---------- Transit (tram, lift, elevator) ---------- */
.city-transit {
  position: absolute; left: .6rem; bottom: .6rem; z-index: 2; max-width: min(70%, 34rem);
  background: rgba(10, 6, 22, .82); border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px;
  padding: .45rem .55rem; box-shadow: 0 8px 26px rgba(0, 0, 0, .45);
}
.city-transit-title { cursor: pointer; list-style: none; margin: 0; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--gold, #f2c35b); }
.city-transit-title::-webkit-details-marker { display: none; }
.city-transit-title::after { content: ' ▾'; }
.city-transit[open] .city-transit-title { margin-bottom: .3rem; }
.city-transit[open] .city-transit-title::after { content: ' ▴'; }
.city-transit-stops { display: flex; flex-wrap: wrap; gap: .3rem; }
.city-transit-stops button { min-height: 30px; padding: .15rem .6rem; font-size: .78rem; }
.city-transit-stops button[aria-current] { opacity: .55; }
.stage.riding .city-scene { animation: city-ride-out 1.1s ease-in both; }
.stage.riding[data-ride="lift"] .city-scene, .stage.riding[data-ride="elevator"] .city-scene { animation-name: city-descend; }
@keyframes city-ride-out { to { transform: translateX(-12%); filter: blur(6px) brightness(.4); opacity: .3; } }
@keyframes city-descend { to { transform: translateY(14%); filter: blur(3px) brightness(.3); opacity: .3; } }

/* ---------- Signs and inscriptions drawn in the scenes ---------- */
.city-sign { font-family: Georgia, 'Times New Roman', serif; font-weight: 600; }

/* ---------- The city breathing ---------- */
.fx-twinkle { animation: fx-twinkle 4s ease-in-out infinite; }
.fx-pulse { animation: fx-pulse 5s ease-in-out infinite; }
.fx-flicker { animation: fx-flicker 2.6s steps(6, end) infinite; }
.fx-shimmer { animation: fx-shimmer 6s ease-in-out infinite; }
.fx-sway { animation: fx-sway 5s ease-in-out infinite; } /* origins are given per element, in scene units */
.fx-float { animation: fx-float 9s ease-in-out infinite; }
.fx-drift { animation: fx-drift 14s ease-in-out infinite alternate; }
.fx-drift-slow { animation: fx-drift 60s linear infinite alternate; }
.fx-rise { animation: fx-rise 12s linear infinite; }
.fx-rise-fast { animation: fx-rise 4s linear infinite; }
.fx-fall { animation: fx-fall 14s linear infinite; }
.fx-glide { animation: fx-glide 40s linear infinite; }
.fx-spin { animation: fx-spin 18s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes fx-twinkle { 50% { opacity: .25; } }
@keyframes fx-pulse { 50% { opacity: .45; } }
@keyframes fx-flicker { 0%, 100% { opacity: 1; } 30% { opacity: .82; } 55% { opacity: .95; } 80% { opacity: .75; } }
@keyframes fx-shimmer { 50% { opacity: .55; transform: translateX(6px); } }
@keyframes fx-sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes fx-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes fx-drift { from { transform: translateX(-40px); } to { transform: translateX(40px); } }
@keyframes fx-rise { from { transform: translateY(0); opacity: 0; } 15% { opacity: .9; } to { transform: translateY(-320px); opacity: 0; } }
@keyframes fx-fall { from { transform: translateY(-60px) rotate(0); opacity: 0; } 10% { opacity: .9; } to { transform: translateY(520px) rotate(220deg); opacity: 0; } }
@keyframes fx-glide { from { transform: translateX(-200px); } to { transform: translateX(1800px); } }
@keyframes fx-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .city-scene, .city-scene.leaving, .stage.riding .city-scene, .city .door.kind-sealed { animation: none; }
  .city.smooth .city-layer, .city.smooth .city-hit { transition: none; }
  [class*="fx-"] { animation: none !important; }
}

/* ---------- Static scene art (homepage, map, place pages) ---------- */
.city-art { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #120a24; }
.city-art svg { display: block; width: 100%; height: 100%; }

@media (max-width: 640px) {
  .city-transit { left: .3rem; bottom: .3rem; max-width: calc(100% - .6rem); padding: .3rem .45rem; }
  .city-transit-title { font-size: .66rem; }
  .city-edge { width: 2rem; height: 3.4rem; font-size: 1.3rem; }
}

/* ---------- The map page ---------- */
.map-page .eyebrow a { color: inherit; text-decoration: none; }
.map-h { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-weight: 400; font-size: 1.6rem; margin: 2rem 0 .25rem; }
.map-lede { color: var(--muted, #b7aed3); margin: 0 0 1rem; max-width: 44rem; }
.map-figure { margin: 0 0 1.25rem; }
.map { border-radius: 16px; overflow: hidden; background: #140c2a; box-shadow: 0 10px 40px rgba(0, 0, 0, .45); }
.map-svg { display: block; width: 100%; height: auto; }
.map-ground { fill: #1a1233; }
.map-sea { fill: #0f2a3a; }
.map-hill { fill: #241a40; }
.map-tram { fill: none; stroke: rgba(242, 195, 91, .35); stroke-width: 10; stroke-linejoin: round; }
.map-tram-dash { fill: none; stroke: #f2c35b; stroke-width: 2; stroke-dasharray: 10 12; animation: map-tram 6s linear infinite; }
@keyframes map-tram { to { stroke-dashoffset: -88; } }
.map-node { cursor: pointer; }
.map-disc { opacity: .9; stroke: rgba(255, 255, 255, .25); stroke-width: 2; transition: opacity .2s ease; }
.map-node:hover .map-disc, .map-node:focus-visible .map-disc { opacity: 1; stroke: #3fe0f0; stroke-width: 4; }
.map-stop { stroke: #0b0716; stroke-width: 3; }
.map-label { fill: #ece8f7; font: 600 22px Georgia, "Times New Roman", serif; paint-order: stroke; stroke: #0b0716; stroke-width: 5px; }
.map-card img { display: block; width: calc(100% + 28px); margin: -14px -14px 10px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 14px 14px 0 0; }
.map-streets { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem .8rem; font-size: .92rem; }
.strata { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.stratum { padding: .8rem 1rem; border-radius: 10px; color: #ece8f7; }
.stratum-cistern { background: linear-gradient(90deg, #0d2a30, #0a1c22); }
.stratum-kingdom { background: linear-gradient(90deg, #3a1610, #220c08); }
.stratum-archive { background: linear-gradient(90deg, #141a3a, #0b0f24); }
.stratum-deep { background: linear-gradient(90deg, #06141a, #02070a); }
.stratum span { color: #b7aed3; }
.stratum-found { font-size: .85rem; }
.codex-list { display: grid; gap: .5rem; padding-left: 1.6rem; max-width: 46rem; }
.codex-list q { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-size: 1.05rem; }
.codex-missing { opacity: .45; }
.codex-empty { list-style: none; margin-left: -1.6rem; color: #b7aed3; }
@media (prefers-reduced-motion: reduce) { .map-tram-dash { animation: none; } }
