/* Activity previews are optional controls layered over the existing photos. */
.activity-photo[data-activity] {
  position: relative;
}

.activity-launch {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.activity-launch-label {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid #ffffff52;
  border-radius: 100px;
  background: #0c0d0fe8;
  color: #fff6ef;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: 0 4px 18px #0003;
  transition: background 160ms ease, color 160ms ease;
}

.activity-launch:hover .activity-launch-label,
.activity-launch:focus-visible .activity-launch-label {
  border-color: #ff9a6c;
  background: #ff9a6c;
  color: #241209;
}

.activity-launch:focus-visible {
  outline: 3px solid var(--focus, var(--accent-text));
  outline-offset: -5px;
}

/* The native dialog supplies the modal focus boundary. */
.activity-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--card-border);
  border-radius: 28px;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 32px 120px #0008;
}

.activity-dialog::backdrop {
  background: #050609c9;
  backdrop-filter: blur(7px);
}

.activity-dialog [hidden] {
  display: none !important;
}

.activity-dialog-shell {
  padding: 26px;
}

.activity-dialog-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  padding: 0 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.activity-dialog-top > div {
  min-width: 0;
}

.activity-dialog-top .eyebrow {
  font-size: 10px;
  letter-spacing: .16em;
}

.activity-dialog-top h2 {
  margin: 8px 0 0;
  font-size: clamp(25px, 3.5vw, 36px);
  line-height: 1.15;
}

.activity-close {
  display: grid;
  flex: 0 0 44px;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--control-border, var(--card-border));
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.activity-dialog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .85fr);
  align-items: start;
  gap: 28px;
}

.activity-stage {
  --tag-x: 46%;
  --tag-y: 66%;
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  width: 100%;
  min-width: 0;
  aspect-ratio: 600 / 460;
  overflow: hidden;
  border: 1px solid #ffffff26;
  border-radius: 22px;
  background: radial-gradient(ellipse at 52% 35%, #3b2c20, #111113 75%);
  box-shadow: inset 0 0 50px #0003;
}

.activity-stage::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  box-shadow: inset 0 -42px 40px -28px #0009;
  content: "";
  pointer-events: none;
}

.activity-scene-art,
.activity-scene-art > svg {
  display: block;
  width: 100%;
  height: 100%;
}

.activity-scene-art {
  position: absolute;
  inset: 0;
}

.activity-dialog .scene-book-object {
  transform-box: fill-box;
  transform-origin: 48% 50%;
}

.activity-dialog[data-activity="reading"][data-state="choose"] .scene-book-object {
  animation: flint-book-open 700ms cubic-bezier(.2, .75, .25, 1) both;
}

.activity-dialog .scene-breath {
  transform-box: fill-box;
  transform-origin: center;
}

.activity-dialog[data-activity="meditation"][data-state="active"] .scene-breath {
  animation: flint-breath 5s ease-in-out infinite;
}

.activity-hotspot,
.activity-sticker,
.activity-scan-ring,
.activity-phone {
  position: absolute;
  left: var(--tag-x);
  top: var(--tag-y);
}

.activity-hotspot {
  z-index: 5;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 2px dashed #ffd2b7;
  border-radius: 50%;
  background: #492614d9;
  color: #fff1e7;
  box-shadow: 0 0 0 6px #ff9a6c1f, 0 5px 20px #0005;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background 160ms ease, box-shadow 160ms ease;
}

.activity-hotspot:hover {
  background: #67391fe8;
  box-shadow: 0 0 0 8px #ff9a6c2e, 0 5px 20px #0005;
}

.activity-sticker {
  z-index: 3;
  display: grid;
  place-items: center;
  width: clamp(18px, 6.7cqw, 40px);
  height: clamp(18px, 6.7cqw, 40px);
  transform: translate(-50%, -50%);
  border: 1px solid #fff;
  border-radius: 50%;
  background: #fff8ee;
  box-shadow: 0 2px 3px #0006, inset 0 0 0 3px #eae3d6;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.activity-sticker img {
  display: block;
  width: 70%;
  height: 70%;
  object-fit: contain;
}

.activity-dialog:not([data-state="choose"]) .activity-sticker {
  opacity: 1;
  visibility: visible;
}

.activity-dialog[data-state="placing"] .activity-sticker {
  animation: flint-sticker-place 700ms cubic-bezier(.2, .75, .25, 1) both;
}

.activity-dialog[data-state="ready"] .activity-sticker {
  box-shadow: 0 0 0 5px #ff9a6c33, 0 2px 3px #0006, inset 0 0 0 3px #eae3d6;
}

.activity-phone {
  z-index: 4;
  width: clamp(38px, 14%, 84px);
  aspect-ratio: 7 / 13;
  padding: 4px;
  transform: translate(-50%, -12%) rotate(-7deg);
  border: 2px solid #76797e;
  border-radius: 15px;
  background: #0b0c0e;
  box-shadow: 8px 12px 24px #0008, inset 0 0 0 1px #000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 350ms ease, opacity 250ms ease;
}

.activity-phone::before {
  position: absolute;
  top: 7px;
  left: 50%;
  z-index: 1;
  width: 32%;
  height: 5px;
  transform: translateX(-50%);
  border-radius: 5px;
  background: #050608;
  content: "";
}

.activity-phone-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 14px 3px 8px;
  border: 1px solid #ffffff14;
  border-radius: 9px;
  background: radial-gradient(circle at 50% 35%, #4c2d1b, #19191d 75%);
  color: #ffeadd;
}

.activity-phone-mark {
  color: #ff9a6c;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.activity-phone-label {
  max-width: 100%;
  color: #fff0e6;
  font-size: 8px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

.activity-dialog:is([data-state="scanning"], [data-state="active"], [data-state="finishing"], [data-state="earned"]) .activity-phone {
  opacity: 1;
  visibility: visible;
}

.activity-dialog[data-state="scanning"] .activity-phone {
  animation: flint-phone-scan 1400ms cubic-bezier(.2, .7, .2, 1) both;
}

.activity-dialog[data-state="active"] .activity-phone {
  transform: translate(38%, -25%) rotate(8deg);
  opacity: .78;
}

.activity-dialog[data-state="finishing"] .activity-phone {
  animation: flint-phone-rescan 1400ms cubic-bezier(.2, .7, .2, 1) both;
}

.activity-dialog[data-state="earned"] .activity-phone {
  transform: translate(38%, -25%) rotate(8deg);
}

.activity-dialog[data-state="earned"] .activity-phone-screen {
  background: radial-gradient(circle at 50% 35%, #783e1d, #241b16 80%);
}

.activity-dialog[data-state="earned"] .activity-phone-label {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.activity-scan-ring {
  z-index: 2;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
  border: 2px solid #ffb485;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.activity-dialog:is([data-state="scanning"], [data-state="finishing"]) .activity-scan-ring {
  animation: flint-scan-pulse 1400ms ease-out both;
}

.activity-scene-caption {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 6;
  max-width: calc(100% - 28px);
  padding: 8px 11px;
  border: 1px solid #ffffff29;
  border-radius: 9px;
  background: #0d1012dc;
  color: #f2e6dc;
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
}

.activity-instructions {
  min-width: 0;
}

.activity-instructions > p:first-child {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
}

.activity-progress {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
  margin: 24px 0;
  padding: 0;
  list-style: none;
  counter-reset: activity-step;
}

.activity-progress li {
  position: relative;
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
  counter-increment: activity-step;
}

.activity-progress li::before {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  margin: 0 auto 8px;
  border: 1px solid var(--control-border, var(--muted));
  border-radius: 50%;
  background: var(--bg);
  font-size: 11px;
  font-weight: 700;
  content: counter(activity-step);
}

.activity-progress li:not(:last-child)::after {
  position: absolute;
  top: 12px;
  left: calc(50% + 17px);
  width: calc(100% - 31px);
  height: 1px;
  background: var(--card-border);
  content: "";
}

.activity-progress li[aria-current="step"] {
  color: var(--text);
  font-weight: 600;
}

.activity-progress li[aria-current="step"]::before {
  border-color: var(--accent-text);
  background: var(--accent-text);
  color: var(--bg);
}

.activity-progress li.is-done::before {
  border-color: var(--accent-text);
  color: var(--accent-text);
  content: "✓";
}

.activity-progress li.is-done::after {
  background: var(--accent-text);
}

.activity-status {
  min-height: 145px;
}

.activity-status h3 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 25px;
  line-height: 1.2;
}

.activity-status .activity-description {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.activity-placements {
  min-width: 0;
  margin: 8px 0 18px;
  padding: 0;
  border: 0;
}

.activity-placements legend {
  margin-bottom: 10px;
  padding: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.activity-placement-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.activity-placement-options button {
  min-height: 44px;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--control-border, var(--card-border));
  border-radius: 11px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.activity-placement-options button[aria-pressed="true"] {
  border-color: var(--accent-text);
  color: var(--accent-text);
  box-shadow: inset 0 0 0 1px var(--accent-text);
}

.activity-action {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
}

.activity-action:disabled,
.activity-action[aria-disabled="true"] {
  transform: none;
  opacity: .65;
  cursor: wait;
}

.activity-reset {
  display: block;
  min-height: 44px;
  margin: 8px auto 0;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.activity-reset:hover {
  color: var(--text);
}

.activity-demo-note {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.activity-dialog button:focus-visible {
  outline: 3px solid var(--focus, var(--accent-text));
  outline-offset: 4px;
}

.activity-dialog .activity-hotspot:focus-visible {
  outline-color: #fff0e6;
}

@keyframes flint-sticker-place {
  0% { opacity: 0; transform: translate(-50%, -50%) translate(65px, -65px) rotate(-25deg) scale(1.25); }
  65% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  82% { transform: translate(-50%, -50%) scale(.93); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes flint-phone-scan {
  0% { opacity: 0; transform: translate(300px, -100px) rotate(18deg); }
  28% { opacity: 1; }
  50%, 100% { opacity: 1; transform: translate(-50%, -12%) rotate(-7deg); }
}

@keyframes flint-phone-rescan {
  0% { opacity: .78; transform: translate(38%, -25%) rotate(8deg); }
  45%, 100% { opacity: 1; transform: translate(-50%, -12%) rotate(-7deg); }
}

@keyframes flint-scan-pulse {
  0%, 30% { opacity: 0; transform: translate(-50%, -50%) scale(.8); }
  45% { opacity: .9; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(2.4); }
}

@keyframes flint-book-open {
  0% { opacity: .65; transform: scaleX(.3) rotate(-3deg); }
  100% { opacity: 1; transform: scaleX(1) rotate(0); }
}

@keyframes flint-breath {
  0%, 100% { opacity: .55; transform: scale(.94); }
  50% { opacity: 1; transform: scale(1.08); }
}

@container (max-width: 360px) {
  .activity-phone {
    padding: 3px;
    border-radius: 11px;
  }

  .activity-phone::before {
    top: 5px;
    height: 4px;
  }

  .activity-phone-screen {
    gap: 4px;
    padding: 9px 1px 4px;
    border-radius: 7px;
  }

  .activity-phone-mark {
    font-size: 16px;
  }

  .activity-phone-label {
    font-size: 6px;
  }

  .activity-dialog[data-state="earned"] .activity-phone-label {
    font-size: 8px;
  }
}

@media (max-width: 700px) {
  .activity-dialog {
    width: calc(100vw - 24px);
    border-radius: 22px;
  }

  .activity-dialog-shell {
    padding: 18px;
  }

  .activity-dialog-top {
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 16px;
  }

  .activity-dialog-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .activity-stage {
    max-width: 470px;
    justify-self: center;
    border-radius: 17px;
  }

  .activity-status {
    min-height: 0;
    margin-bottom: 22px;
  }

  .activity-progress {
    margin: 22px 0;
  }

  .activity-progress li {
    font-size: 11px;
  }

  .activity-placements {
    margin-top: 0;
  }

  .activity-scene-caption {
    bottom: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
    padding: 7px 9px;
    font-size: 10px;
  }
}

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

  .activity-dialog:is([data-state="scanning"], [data-state="finishing"]) .activity-scan-ring {
    opacity: .7;
  }
}

@media (forced-colors: active) {
  .activity-launch-label,
  .activity-close,
  .activity-placement-options button,
  .activity-progress li::before {
    border-color: ButtonText;
  }

  .activity-placement-options button[aria-pressed="true"],
  .activity-progress li[aria-current="step"]::before {
    border: 2px solid Highlight;
  }
}
