:root {
  --bg: #f5efe2;
  --bg-strong: #e5d4b1;
  --panel: rgba(255, 251, 244, 0.86);
  --panel-strong: #fffaf1;
  --text: #2d241d;
  --muted: #69594c;
  --line: rgba(86, 66, 47, 0.14);
  --gold: #ba8b33;
  --gold-soft: rgba(186, 139, 51, 0.18);
  --green: #5d7f57;
  --wine: #7b4e45;
  --shadow: 0 22px 60px rgba(76, 52, 32, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 233, 178, 0.8), transparent 30%),
    radial-gradient(circle at bottom right, rgba(123, 78, 69, 0.16), transparent 28%),
    linear-gradient(180deg, #fbf7ef 0%, var(--bg) 100%);
}

img {
  display: block;
  max-width: 100%;
}

.page-shell {
  width: min(1380px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: 1.8fr 0.8fr;
  gap: 20px;
  margin-bottom: 24px;
}

.hero-copy,
.hero-note,
.explorer,
.detail-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  border-radius: 28px;
}

.hero-copy {
  padding: 32px;
}

.hero-note {
  padding: 28px;
  display: grid;
  align-content: center;
  gap: 8px;
  background:
    linear-gradient(145deg, rgba(93, 127, 87, 0.15), rgba(255, 251, 244, 0.9)),
    var(--panel);
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.76rem;
  color: var(--muted);
}

h1,
h2,
h3,
h4 {
  font-family: "Cormorant Garamond", serif;
  margin: 0;
  line-height: 0.96;
  font-weight: 600;
}

h1 {
  font-size: clamp(3rem, 7vw, 5.6rem);
  max-width: 10ch;
  margin-bottom: 16px;
}

.lede {
  max-width: 64ch;
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--muted);
}

.hero-note p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.hero-note strong {
  font-family: "Cormorant Garamond", serif;
  font-size: 2rem;
  font-weight: 600;
}

.layout {
  display: block;
}

.explorer {
  padding: 24px;
}

.explorer-topbar {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 18px;
}

.explorer-topbar h2 {
  font-size: clamp(2rem, 3vw, 3.2rem);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
}

.tab {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.55);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.tab:hover,
.tab:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(93, 127, 87, 0.25);
}

.tab.is-active {
  background: linear-gradient(135deg, rgba(186, 139, 51, 0.18), rgba(93, 127, 87, 0.14));
  border-color: rgba(186, 139, 51, 0.32);
}

.diagram-card {
  position: relative;
  min-height: 560px;
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 246, 222, 0.88), rgba(243, 231, 204, 0.92)),
    var(--panel-strong);
  border: 1px solid rgba(186, 139, 51, 0.14);
}

.photo-backdrop {
  position: absolute;
  inset: 0;
  background-position: center 34%;
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 0.16;
  filter: sepia(0.18) saturate(0.8) contrast(1.02);
  z-index: 0;
}

.diagram {
  width: 100%;
  height: 100%;
  min-height: 560px;
  position: relative;
  z-index: 1;
}

.diagram-popover {
  position: absolute;
  left: 24px;
  top: 24px;
  width: min(340px, calc(100% - 48px));
  padding: 18px 14px 14px;
  border-radius: 22px;
  border: 1px solid rgba(86, 66, 47, 0.14);
  background: rgba(255, 251, 244, 0.94);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 44px rgba(63, 43, 26, 0.2);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 3;
}

.diagram-popover.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.popover-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 251, 244, 0.96);
  color: var(--text);
  font: inherit;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(63, 43, 26, 0.16);
  z-index: 5;
}

.popover-meta {
  display: grid;
  gap: 8px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.92rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.legend-dot,
.legend-line {
  display: inline-block;
  flex: 0 0 auto;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 6px rgba(186, 139, 51, 0.18);
}

.legend-line {
  width: 28px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--wine), transparent);
}

.diagram-popover img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 235, 188, 0.6), rgba(123, 78, 69, 0.16));
  border: 1px solid rgba(93, 127, 87, 0.16);
  margin-bottom: 12px;
}

.detail-badge {
  display: inline-flex;
  width: fit-content;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--gold-soft);
  color: #7c5a1a;
}

.popover-meta h3 {
  font-size: clamp(2rem, 3vw, 2.9rem);
}

.detail-summary,
.detail-reading {
  margin: 0;
  color: var(--muted);
  line-height: 1.68;
}

.detail-reading {
  color: var(--text);
}

.reference-strip {
  margin-top: 18px;
  padding: 18px 20px 10px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 251, 244, 0.72);
}

.reference-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
  line-height: 1.55;
  color: var(--muted);
}

.source-note {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.facade-label {
  font-family: "Cormorant Garamond", serif;
  font-size: 42px;
  font-weight: 600;
  fill: rgba(45, 36, 29, 0.9);
}

.facade-subtitle {
  font-size: 16px;
  fill: rgba(105, 89, 76, 0.9);
  letter-spacing: 0.06em;
}

.tower-fill {
  fill: rgba(255, 250, 241, 0.72);
  stroke: rgba(86, 66, 47, 0.18);
  stroke-width: 2;
}

.tower-window {
  fill: rgba(123, 78, 69, 0.12);
}

.portal-fill {
  fill: rgba(255, 248, 236, 0.72);
  stroke: rgba(86, 66, 47, 0.16);
  stroke-width: 2;
}

.portal-line {
  fill: none;
  stroke: rgba(123, 78, 69, 0.26);
  stroke-width: 2.4;
  stroke-linecap: round;
}

.outline-stroke {
  fill: rgba(255, 250, 241, 0.5);
  stroke: rgba(86, 66, 47, 0.22);
  stroke-width: 2;
}

.ridge {
  fill: none;
  stroke: rgba(123, 78, 69, 0.3);
  stroke-width: 2.2;
  stroke-linecap: round;
}

.point {
  cursor: pointer;
}

.point-core {
  fill: var(--gold);
  stroke: rgba(255, 250, 241, 0.95);
  stroke-width: 3;
}

.point-ring {
  fill: rgba(186, 139, 51, 0.18);
  transform-origin: center;
  animation: pulse 2.4s ease-in-out infinite;
}

.point-label {
  font-size: 13px;
  fill: rgba(45, 36, 29, 0.78);
  font-weight: 700;
}

.point-halo {
  stroke: rgba(123, 78, 69, 0.18);
  stroke-width: 1.5;
  fill: none;
  stroke-dasharray: 4 6;
}

.point.is-active .point-core {
  fill: var(--green);
}

.point.is-active .point-ring {
  fill: rgba(93, 127, 87, 0.2);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.86);
    opacity: 0.62;
  }

  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

@media (max-width: 1080px) {
  .hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 20px, 1380px);
    padding-top: 12px;
  }

  .hero-copy,
  .hero-note,
  .explorer {
    border-radius: 22px;
  }

  .hero-copy,
  .hero-note,
  .explorer {
    padding: 18px;
  }

  .explorer-topbar {
    align-items: start;
    flex-direction: column;
  }

  .tabs {
    justify-content: start;
  }

  .diagram-card,
  .diagram {
    min-height: 460px;
  }

  .diagram-popover {
    left: 12px;
    top: auto;
    bottom: 12px;
    width: calc(100% - 24px);
    max-height: min(62vh, 420px);
    overflow: auto;
    padding-top: 20px;
  }

  .popover-close {
    position: sticky;
    top: 0;
    margin-left: auto;
    margin-bottom: 8px;
    display: block;
  }
}
