:root {
  --night: #0e0c0a;
  --panel: rgba(20, 16, 12, 0.82);
  --line: rgba(214, 177, 96, 0.28);
  --gold: #d6b160;
  --gold-soft: #b8975a;
  --cream: #f1e8d8;
  --muted: #b9ac98;
  --panel-w: 400px;
  --gap: 24px;
  --display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --text: "EB Garamond", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
  color: var(--cream);
  font-family: var(--text);
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse 70% 80% at 62% 45%, #2a2118 0%, #15110d 55%, var(--night) 100%);
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- viewer ---------- */

#viewer {
  position: fixed !important; /* the zoom library sets its own inline position */
  inset: 0;
  touch-action: none;
}

/* ---------- golden points ---------- */

.dot {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  display: grid;
  place-items: center;
  transition: opacity 0.5s ease;
}
.dot i {
  position: relative;
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(214, 177, 96, 0.9);
  border: 2px solid #fff6dc;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.6);
  transition: transform 0.2s ease;
}
.dot i::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 240, 200, 0.75);
  animation: pulse 2.6s ease-out infinite;
}
.dot:hover i, .dot:focus-visible i { transform: scale(1.3); }
.dot span {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, 4px);
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(14, 12, 10, 0.9);
  border: 1px solid var(--line);
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.dot:hover span, .dot:focus-visible span { opacity: 1; transform: translate(-50%, 0); }
.dot.is-active { opacity: 0; pointer-events: none; }
body.zoomed .dot:not(.is-active) { opacity: 0.7; }

@keyframes pulse {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(1.7); opacity: 0; }
}

/* ---------- panel ---------- */

#panel {
  position: fixed;
  top: var(--gap);
  left: var(--gap);
  bottom: var(--gap);
  width: var(--panel-w);
  display: flex;
  flex-direction: column;
  padding: 22px 28px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.brand {
  margin: 0;
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}
.lang { display: flex; gap: 2px; }
.lang button {
  padding: 2px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.lang button[aria-pressed="true"] { color: var(--gold); border-color: var(--line); }

#story {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 4px 12px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
#story.out { opacity: 0; transform: translateY(8px); }

.eyebrow {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold-soft);
}
#story h1 {
  margin: 0 0 18px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 38px;
  line-height: 1.08;
  text-wrap: balance;
}
#story p { margin: 0 0 14px; text-wrap: pretty; }
#story em { font-style: italic; }

#story h2.sub {
  margin: 24px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-family: var(--display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-soft);
}
#story sup { font-size: 0.62em; line-height: 0; color: var(--gold); padding-left: 1px; }
#story strong { font-weight: 600; color: var(--gold); }
.refs { margin: 0; padding-left: 20px; font-size: 14.5px; line-height: 1.4; color: var(--muted); }
.refs li { margin-bottom: 7px; }
.refs li::marker { color: var(--gold-soft); }
.refs a { color: var(--gold); text-decoration: none; }
.refs a:hover { text-decoration: underline; }

.facts { margin: 22px 0 0; padding: 0; border-top: 1px solid var(--line); }
.facts div {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.facts dt {
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-soft);
  padding-top: 3px;
}
.facts dd { margin: 0; font-size: 17px; line-height: 1.4; }

.quote {
  margin: 24px 0 0 !important;
  font-family: var(--display);
  font-style: italic;
  font-size: 23px;
  line-height: 1.25;
  color: var(--gold);
}
.hint { margin-top: 20px !important; font-size: 15.5px; color: var(--muted); }

/* ---------- tour controls ---------- */

.tour {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.tour .count {
  margin-left: auto;
  font-family: var(--display);
  font-size: 16px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pill, .round {
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--display);
  font-size: 17px;
  letter-spacing: 0.04em;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.pill { padding: 0 16px; white-space: nowrap; }
.round { width: 40px; padding: 0; display: grid; place-items: center; flex: none; }
.pill:hover, .round:hover { background: rgba(214, 177, 96, 0.12); border-color: var(--gold-soft); }
.pill.primary { background: var(--gold); border-color: var(--gold); color: #1b140a; font-weight: 600; }
.pill.primary:hover { background: #e3c27a; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 14px;
}
.chips button {
  padding: 1px 11px 2px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  font-size: 15.5px;
  color: var(--muted);
}
.chips button:hover { color: var(--cream); border-color: var(--line); }
.chips button[aria-current="true"] { color: var(--gold); border-color: var(--gold-soft); background: none; }

/* ---------- zoom buttons & credit ---------- */

.zoomctl {
  position: fixed;
  right: var(--gap);
  bottom: calc(var(--gap) + 22px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
}
.zoomctl button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
}
.zoomctl button + button { border-top: 1px solid var(--line); }
.zoomctl button:hover { background: rgba(214, 177, 96, 0.12); }

.credit {
  position: fixed;
  right: var(--gap);
  bottom: 10px;
  margin: 0;
  font-size: 12.5px;
  color: rgba(185, 172, 152, 0.65);
}

.debug-box { border: 1px dashed #5ff; background: rgba(80, 255, 255, 0.08); pointer-events: none; }
.debug-read {
  position: fixed; top: 8px; right: 8px; padding: 4px 8px;
  background: #000; color: #5ff; font: 12px monospace; z-index: 10;
}

/* ---------- phones & narrow windows: panel becomes a bottom sheet ---------- */

@media (max-width: 860px) {
  html, body { font-size: 16.5px; }
  #panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 46dvh;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    border-radius: 14px 14px 0 0;
    border-width: 1px 0 0;
  }
  .panel-head { padding-bottom: 8px; }
  .brand { font-size: 13px; }
  #story { padding-top: 14px; }
  #story h1 { font-size: 29px; margin-bottom: 12px; }
  .facts div { grid-template-columns: 84px 1fr; padding: 8px 0; }
  .quote { font-size: 20px; }
  .tour { padding-top: 10px; }
  .chips { display: none; }
  .zoomctl { top: 12px; right: 12px; bottom: auto; }
  .credit { display: none; }
  .dot span { display: none; }
  .dot i { width: 11px; height: 11px; border-width: 1.5px; }
  .dot i::after { inset: -7px; }
}

@media (prefers-reduced-motion: reduce) {
  .dot i::after { animation: none; opacity: 0.6; }
  #story { transition: none; }
}
