:root {
  color: #fffdf8;
  background: #2a2622;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

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

body { overflow: hidden; }

button, input {
  font: inherit;
  color: inherit;
}

:focus { outline: none; }

:focus-visible {
  outline: 2px solid #fffdf8;
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #fffdf8;
  color: #1c1915;
  border-bottom: 1px solid #1c1915;
}

.title {
  margin: 0;
  min-width: 0;
  flex: 1;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 1.25rem;
  font-weight: 500;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.zoom, .dots-menu { position: relative; }

.zoom, .bar button {
  min-height: 44px;
}

.zoom {
  display: flex;
  border: 1px solid #d9d0c3;
  border-radius: 8px;
}

.bar button {
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 0 12px;
  cursor: pointer;
}

.zoom button { min-width: 44px; }

#dots-toggle { border: 1px solid #d9d0c3; }

#dots-list {
  position: absolute;
  right: 0;
  z-index: 5;
  margin: 4px 0 0;
  padding: 4px;
  width: 16rem;
  max-height: 20rem;
  overflow: auto;
  list-style: none;
  background: #fffdf8;
  border: 1px solid #e3dcd0;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(28, 25, 21, 0.12);
}

#dots-list button {
  width: 100%;
  text-align: left;
}

#stage {
  position: relative;
  z-index: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

.media-box { position: absolute; }

.media-box img {
  width: 100%;
  height: 100%;
  user-select: none;
}

.pin {
  position: absolute;
  transform: translate(-50%, -50%);
}

.pin button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.disc {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  overflow: hidden;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid #000;
  animation: pulse 2.6s ease-out infinite;
}

.disc svg {
  display: block;
  width: 62%;
  height: 62%;
}

.svg-scene {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.svg-scene svg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--dot) 55%, transparent); }
  70% { box-shadow: 0 0 0 12px transparent; }
}

.tip {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #1c1915;
  color: #fffdf8;
  font-size: 0.875rem;
  white-space: nowrap;
  pointer-events: none;
}

.pin:hover .tip, .pin:focus-within .tip { display: block; }

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(28, 25, 21, 0.45);
}

.card {
  display: grid;
  width: min(40rem, calc(100vw - 1.5rem));
  height: min(580px, calc(100dvh - 1.5rem));
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  border-radius: 16px;
  background: #fffdf8;
  color: #1c1915;
  box-shadow: 0 30px 80px rgba(28, 25, 21, 0.28);
}

.card.has-media {
  width: min(920px, calc(100vw - 1.5rem));
  height: min(var(--card-h, 580px), calc(100dvh - 1.5rem));
  grid-template-rows: auto minmax(0, 1fr);
}

.media-pane {
  min-width: 0;
  min-height: 0;
  width: 100%;
  aspect-ratio: var(--media-aspect, 0.8);
  max-height: 46vh;
  background: #241f1b;
  color: #fffdf8;
}

.media-pane img, .media-pane video, .media-pane iframe {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
  background: #241f1b;
}

.copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.copy-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 0;
}

.copy h2 {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 1.875rem;
  font-weight: 500;
  line-height: 1.15;
}

.copy p {
  margin: 0;
  padding: 12px 20px;
  overflow: auto;
  flex: 1;
  font-size: 1.125rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-synthesis: weight style;
}

.copy p b { font-weight: 700; }
.copy p i { font-style: italic; }
.copy p u { text-decoration: underline; }
.copy p s { text-decoration: line-through; }

.links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 40%;
  overflow: auto;
  padding: 8px 20px 20px;
}

.links a {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 8px;
  background: #1c1915;
  color: #fffdf8;
  text-align: center;
  text-decoration: none;
}

.close {
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #1c1915;
  font-size: 1.5rem;
  cursor: pointer;
}

@media (min-width: 760px) {
  .card.has-media {
    grid-template-columns: minmax(0, min(var(--media-w, 460px), 52%)) minmax(260px, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .card.has-media .media-pane {
    width: 100%;
    max-width: var(--media-w, 460px);
    max-height: min(var(--media-h, 560px), 100%);
    aspect-ratio: var(--media-aspect, 0.8);
    height: auto;
    align-self: center;
    justify-self: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .disc { animation: none; }
}
