:root {
  color-scheme: dark;
  --ink: #131d22;
  --lake: #082d3a;
  --lake-light: #0b4354;
  --paper: #f5e7be;
  --paper-deep: #d2b673;
  --brass: #e2a83d;
  --brass-light: #ffcf68;
  --cream: #fff9df;
  --muted: #bbccd0;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 30% 10%, rgba(38, 113, 127, .24), transparent 34rem),
    linear-gradient(150deg, #071b23, var(--lake));
  color: var(--cream);
  font-family: Georgia, "Times New Roman", serif;
}

button { font: inherit; }

.map-header {
  height: 5.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem clamp(1rem, 3vw, 2.75rem);
  border-bottom: 1px solid rgba(245, 231, 190, .24);
  background: rgba(5, 25, 32, .9);
}

.eyebrow, .panel-kicker {
  margin: 0 0 .2rem;
  color: var(--brass-light);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .76rem;
  font-weight: 750;
  letter-spacing: .15em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: clamp(1.45rem, 3vw, 2.15rem); line-height: 1; }

.help-button, .map-controls button, .scene-button, .panel-close {
  border: 1px solid rgba(255, 207, 104, .5);
  color: var(--cream);
  background: rgba(19, 29, 34, .82);
  cursor: pointer;
}

.help-button { padding: .65rem .85rem; border-radius: 999px; font-family: ui-sans-serif, system-ui, sans-serif; }

.map-shell { position: relative; height: min(68vw, 50rem); min-height: 38rem; }
.map-stage { position: absolute; inset: 0; overflow: hidden; }

.map-viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.map-viewport.dragging { cursor: grabbing; }
.map-canvas { position: absolute; transform-origin: center; }
.map-canvas > img { width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; pointer-events: none; }

.toe-label {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}

.toe-label {
  color: #073b70;
  font-size: clamp(.68rem, 1.12vw, 1.08rem);
  font-weight: 700;
  font-style: italic;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  -webkit-text-stroke: 2px rgba(102, 211, 226, .92);
  paint-order: stroke fill;
  text-shadow: 0 1px rgba(255,255,255,.3);
}
.toe-label-1 { left: 75%; top: 6%; }
.toe-label-2 { left: 82%; top: 27%; }
.toe-label-3 { left: 92%; top: 45%; }
.toe-label-4 { left: 83%; top: 64%; }
.toe-label-5 { left: 76%; top: 88%; }

.place-marker {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 2;
  display: grid;
  place-items: center;
  align-items: center;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  border: 1px solid rgba(255, 242, 199, .9);
  border-radius: 50%;
  background: rgba(8, 45, 58, .88);
  color: white;
  box-shadow: 0 .25rem .8rem rgba(0,0,0,.42);
  transform: translate(-50%, -50%);
  cursor: pointer;
  font: 700 .78rem/1 ui-sans-serif, system-ui, sans-serif;
  white-space: nowrap;
  transition: transform .16s ease, background .16s ease;
}

.place-marker:hover, .place-marker:focus-visible, .place-marker.active {
  z-index: 6;
  background: #123f4b;
  transform: translate(-50%, -50%) scale(1.08);
  outline: 3px solid rgba(255, 207, 104, .55);
  outline-offset: 2px;
}

.story-marker { background: rgba(84, 43, 19, .94); }
.story-marker .marker-dot { background: #fff0a6; }
.neighborhood-marker { border-color: rgba(230, 242, 185, .9); background: rgba(35, 78, 45, .92); }
.neighborhood-marker .marker-dot { background: #bfe878; box-shadow: inset 0 0 0 2px #335b22; }

.marker-dot { width: .72rem; height: .72rem; border-radius: 50%; background: var(--brass-light); box-shadow: inset 0 0 0 2px #664512; }
.marker-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + .55rem);
  width: max-content;
  max-width: 15rem;
  padding: .38rem .58rem;
  border: 1px solid rgba(255, 242, 199, .9);
  border-radius: .45rem;
  color: white;
  background: rgba(19, 29, 34, .96);
  box-shadow: 0 .3rem .8rem rgba(0,0,0,.42);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, .25rem) scale(.92);
  transform-origin: bottom center;
  transition: opacity .14s ease, transform .14s ease;
}
.marker-label::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  border: .32rem solid transparent;
  border-top-color: rgba(19, 29, 34, .96);
  transform: translateX(-50%);
}
.place-marker:hover .marker-label,
.place-marker:focus-visible .marker-label,
.place-marker.active .marker-label {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.map-controls {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  z-index: 5;
  display: flex;
  align-items: center;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: .7rem;
  overflow: hidden;
  background: rgba(5, 25, 32, .9);
  box-shadow: 0 .6rem 1.5rem rgba(0,0,0,.3);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.map-controls button { min-width: 2.75rem; min-height: 2.75rem; border: 0; border-right: 1px solid rgba(255,255,255,.16); }
.map-controls output { min-width: 4rem; text-align: center; font-size: .85rem; }
#resetMap { padding-inline: .8rem; }

.help-card {
  position: absolute;
  z-index: 5;
  top: 1rem;
  right: 1rem;
  width: min(20rem, calc(100% - 2rem));
  padding: 1rem 1.1rem;
  border: 1px solid rgba(255,207,104,.55);
  border-radius: .8rem;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 1rem 2rem rgba(0,0,0,.35);
}
.help-card p { margin: .45rem 0 0; line-height: 1.45; }

.place-panel {
  position: absolute;
  z-index: 8;
  top: 1rem;
  right: 1rem;
  width: min(25rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  overflow: auto;
  padding: 1.4rem;
  border: 1px solid rgba(255, 207, 104, .55);
  border-radius: 1rem;
  color: var(--ink);
  background:
    linear-gradient(rgba(255,255,255,.16), rgba(255,255,255,0)),
    var(--paper);
  box-shadow: 0 1rem 3rem rgba(0,0,0,.46);
  transform: translateX(calc(100% + 2rem));
  transition: transform .28s ease;
}
.place-panel.open { transform: translateX(0); }
.place-panel h2 { margin: .2rem 2rem .7rem 0; font-size: 2rem; }
.place-panel > p:not(.panel-kicker) { margin: 0; line-height: 1.55; font-size: 1.02rem; }
.panel-close { position: absolute; top: .7rem; right: .7rem; width: 2.25rem; height: 2.25rem; border-radius: 50%; color: var(--ink); background: transparent; font-size: 1.5rem; }
.place-facts { margin: 1.3rem 0; border-block: 1px solid rgba(19,29,34,.25); }
.place-facts div { display: grid; grid-template-columns: 6rem 1fr; gap: .75rem; padding: .75rem 0; }
.place-facts div + div { border-top: 1px solid rgba(19,29,34,.16); }
.place-facts dt { font-weight: 700; }
.place-facts dd { margin: 0; }
.scene-button { width: 100%; padding: .8rem 1rem; border-radius: .55rem; background: var(--ink); }
.scene-button:disabled { opacity: .66; cursor: not-allowed; }

.scene-dialog {
  width: min(76rem, calc(100% - 2rem));
  max-width: none;
  max-height: calc(100% - 2rem);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 207, 104, .65);
  border-radius: 1rem;
  color: var(--cream);
  background: #081f28;
  box-shadow: 0 1.5rem 5rem rgba(0,0,0,.72);
}
.scene-dialog::backdrop { background: rgba(3, 14, 18, .86); backdrop-filter: blur(5px); }
.scene-dialog-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem; }
.scene-dialog-bar h2 { margin: 0; font-size: clamp(1.35rem, 3vw, 2rem); }
.scene-close { flex: none; width: 2.6rem; height: 2.6rem; border: 1px solid rgba(255,207,104,.55); border-radius: 50%; color: var(--cream); background: transparent; font-size: 1.7rem; cursor: pointer; }
.scene-viewer { margin: 0; background: #02090c; }
.scene-viewer img { display: block; width: 100%; max-height: calc(100vh - 15rem); object-fit: contain; }
.scene-viewer figcaption { display: flex; gap: .55rem; align-items: baseline; padding: .7rem 1.2rem; color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; }
.scene-viewer figcaption strong { color: var(--cream); }
.scene-tabs { display: flex; gap: .55rem; padding: .9rem 1.2rem 1.15rem; overflow-x: auto; }
.scene-tabs button { flex: none; min-height: 2.75rem; padding: .55rem .85rem; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; color: var(--cream); background: rgba(255,255,255,.06); cursor: pointer; }
.scene-tabs button.active { border-color: var(--brass-light); color: #1c1407; background: var(--brass-light); }

.loft-feature {
  display: grid;
  grid-template-columns: minmax(14rem, 22rem) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: center;
  padding: clamp(2rem, 6vw, 5rem) clamp(1rem, 6vw, 6rem);
  border-top: 1px solid rgba(245, 231, 190, .24);
  background:
    radial-gradient(circle at 80% 25%, rgba(226, 168, 61, .14), transparent 32rem),
    #061820;
}
.loft-feature-copy h2 { margin: .25rem 0 .8rem; font-size: clamp(2rem, 5vw, 4rem); line-height: .98; }
.loft-feature-copy > p:last-child { margin: 0; color: var(--muted); font-size: 1.05rem; line-height: 1.55; }
.loft-feature figure { margin: 0; overflow: hidden; border: 1px solid rgba(255, 207, 104, .45); border-radius: 1rem; background: #f5efe5; box-shadow: 0 1.5rem 4rem rgba(0,0,0,.38); }
.loft-feature img { display: block; width: 100%; height: auto; max-height: 48rem; object-fit: contain; }

@media (max-width: 720px) {
  .map-header { height: 4.8rem; }
  .map-shell { height: min(82vw, 44rem); min-height: 34rem; }
  .eyebrow { display: none; }
  h1 { max-width: 12rem; font-size: 1.25rem; line-height: 1.02; }
  .help-button { padding: .55rem .7rem; font-size: .85rem; }
  .map-canvas {
    width: calc((100vh - 4.8rem) * 2.083);
    height: 100%;
    margin-left: calc((100% - (100vh - 4.8rem) * 2.083) / 2);
  }
  .map-canvas > img { object-fit: fill; }
  .marker-label { display: none; }
  .place-marker { width: 1.75rem; height: 1.75rem; }
  .marker-dot { width: .85rem; height: .85rem; }
  .place-panel { inset: auto .6rem .6rem; width: auto; max-height: 58%; transform: translateY(calc(100% + 1rem)); }
  .place-panel.open { transform: translateY(0); }
  .scene-dialog { width: calc(100% - 1rem); max-height: calc(100% - 1rem); }
  .scene-viewer img { max-height: calc(100vh - 18rem); }
  .scene-viewer figcaption { display: grid; }
  .loft-feature { grid-template-columns: 1fr; }
}

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