@font-face {
  font-family: "Azeret";
  src: url("fonts/Azeret-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Azeret";
  src: url("fonts/Azeret-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* Controls: light theme = white, dark theme = black. Artwork background stays as in the PDF. */
:root {
  --paper: #ffffff;
  --ui-bg: #ffffff;
  --ui-fg: #000000;
  --ui-muted: rgba(0, 0, 0, .55);
  --ui-line: rgba(0, 0, 0, .14);
  --ui-hover: rgba(0, 0, 0, .07);
  --ui-shadow: 0 6px 24px rgba(0, 0, 0, .14);
  --dim: .16;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ui-bg: #000000;
    --ui-fg: #ffffff;
    --ui-muted: rgba(255, 255, 255, .6);
    --ui-line: rgba(255, 255, 255, .2);
    --ui-hover: rgba(255, 255, 255, .12);
    --ui-shadow: 0 6px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  overscroll-behavior: none;
}
body {
  font-family: "Azeret", ui-monospace, monospace;
  color: var(--ui-fg);
  -webkit-tap-highlight-color: transparent;
}

/* ---------- exhibition ---------- */
.viewport {
  position: fixed;
  inset: 0;
  overflow: auto;
  scrollbar-width: none;
  touch-action: pan-x pan-y;          /* browser pinch disabled – we zoom ourselves */
  overscroll-behavior: contain;
  cursor: grab;
}
.viewport::-webkit-scrollbar { display: none; }
.viewport.is-dragging { cursor: grabbing; }
.viewport.is-dragging, .viewport.is-dragging .seg { cursor: grabbing; }

.track {
  position: relative;
  display: flex;
  height: 100%;
  width: max-content;
}
.panel {
  flex: none;
  height: 100%;
  margin-right: -1px;                 /* hide hairline seams between panels */
}
.panel:last-child { margin-right: 0; }
.panel img {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}

/* segment layer: dimming mask + clickable paper shapes */
.segs {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.segs__dim {
  fill: var(--paper);
  fill-opacity: 0;
  transition: fill-opacity .35s ease;
}
.track.has-focus .segs__dim { fill-opacity: .84; }
.seg {
  fill: #000;
  fill-opacity: 0;
  stroke: none;
  pointer-events: fill;
  cursor: pointer;
  outline: none;
  transition: fill-opacity .2s ease;
}
@media (hover: hover) {
  .track:not(.has-focus) .seg:hover { fill-opacity: .045; }
}
.seg:focus-visible {
  stroke: #000;
  stroke-width: 3px;
  stroke-dasharray: 8 6;
  vector-effect: non-scaling-stroke;
}
.track.has-focus .seg.is-focus { cursor: zoom-out; }

/* ---------- progress ---------- */
.progress {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: transparent;
  pointer-events: none;
  z-index: 5;
}
.progress__bar {
  height: 100%;
  width: 0;
  background: #000;
}

/* ---------- controls ---------- */
.controls {
  position: fixed;
  left: 50%;
  bottom: calc(14px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
  max-width: calc(100vw - 32px);
}
.group {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--ui-bg);
  color: var(--ui-fg);
  border: 1px solid var(--ui-line);
  border-radius: 999px;
  box-shadow: var(--ui-shadow);
  padding: 3px;
}
.btn, .label--btn {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
.btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  font-size: 16px;
  transition: background-color .15s;
}
.btn:hover, .label--btn:hover { background: var(--ui-hover); }
.btn:focus-visible, .label--btn:focus-visible { outline: 2px solid var(--ui-fg); outline-offset: 1px; }
.btn:disabled { opacity: .3; cursor: default; background: none; }
.btn--wide {
  width: auto;
  display: inline-flex;
  gap: 8px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  background: var(--ui-bg);
  border: 1px solid var(--ui-line);
  box-shadow: var(--ui-shadow);
}
.btn--wide:hover { background: var(--ui-bg); filter: contrast(.9); }
.btn--wide span { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label {
  min-width: 70px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  padding: 0 4px;
  white-space: nowrap;
}
.label--btn {
  height: 42px;
  border-radius: 999px;
}

/* tooltip */
.tip {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: min(300px, calc(100vw - 32px));
  padding: 10px 8px 10px 14px;
  font-size: 12px;
  line-height: 1.4;
  background: var(--ui-fg);
  color: var(--ui-bg);
  border-radius: 12px;
  box-shadow: var(--ui-shadow);
  animation: tip-in .3s ease both;
}
.tip[hidden] { display: none; }
.tip::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 22px;
  border: 7px solid transparent;
  border-top-color: var(--ui-fg);
}
.tip__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  cursor: pointer;
  opacity: .7;
}
.tip__close:hover { opacity: 1; }
@keyframes tip-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- rotate overlay ---------- */
.rotate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(255, 255, 255, .72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
@media (prefers-color-scheme: dark) { .rotate { background: rgba(0, 0, 0, .6); } }
.rotate[hidden] { display: none; }
.rotate__card {
  width: 100%;
  max-width: 340px;
  padding: 28px 24px 24px;
  text-align: center;
  background: var(--ui-bg);
  color: var(--ui-fg);
  border: 1px solid var(--ui-line);
  border-radius: 20px;
  box-shadow: var(--ui-shadow);
}
.rotate__card h2 { margin: 18px 0 8px; font-size: 18px; }
.rotate__card p { margin: 0 0 20px; font-size: 13px; line-height: 1.5; color: var(--ui-muted); }
.rotate__card .btn--wide { width: 100%; height: 44px; justify-content: center; box-shadow: none; }
.rotate__icon {
  font-size: 46px;
  animation: rotate-hint 2.4s ease-in-out infinite;
}
@keyframes rotate-hint {
  0%, 20% { transform: rotate(0); }
  45%, 75% { transform: rotate(-90deg); }
  100% { transform: rotate(0); }
}

.noscript {
  position: fixed; inset: 0; display: grid; place-items: center;
  margin: 0; font-size: 14px;
}

/* small / short screens */
@media (max-width: 560px), (max-height: 480px) {
  .rotate__card .btn--wide { height: 44px; }
  .controls { gap: 6px; bottom: calc(10px + var(--safe-b)); }
  .btn { width: 36px; height: 36px; font-size: 14px; }
  .label--btn { height: 36px; }
  .label { min-width: 56px; font-size: 12px; }
  .controls .btn--wide span { display: none; }
  .controls .btn--wide { width: 44px; padding: 0; justify-content: center; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .segs__dim, .seg, .tip, .rotate__icon { transition: none; animation: none; }
}
