:root {
  --bg: #f7e8d6;
  --paper: #fff8ed;
  --paper-deep: #efd3b8;
  --ink: #241615;
  --ink-soft: #60413d;
  --gold: #f1bf55;
  --gold-deep: #9e6418;
  --ruby: #a6202b;
  --ruby-deep: #691522;
  --blue: #496176;
  --blue-deep: #223342;
  --cream: #fff3d8;
  --shadow:
    0 18px 50px rgba(73, 37, 20, 0.22),
    0 3px 0 rgba(36, 22, 21, 0.9);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(180deg, #7e1f2c 0, #d8904c 38%, var(--bg) 100%);
  color: var(--ink);
  font-family: "Newsreader", Georgia, serif;
  font-size: 20px;
  line-height: 1.5;
}

body {
  overflow-x: hidden;
}

button,
a {
  font: inherit;
}

a {
  color: inherit;
}

.sacred-shell {
  position: relative;
  min-height: 100svh;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(73, 97, 118, 0.22), transparent 24% 76%, rgba(73, 97, 118, 0.22)),
    linear-gradient(180deg, rgba(255, 248, 237, 0.2), rgba(255, 248, 237, 0.78));
}

.sacred-topbar {
  position: relative;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto 14px;
}

.brand-pill,
.topbar-links a,
.small-button,
.primary-action,
.secondary-action {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ink);
  border-radius: 999px;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 3px 0 var(--ink);
}

.brand-pill {
  gap: 9px;
  padding: 8px 14px 8px 10px;
  background: var(--paper);
}

.brand-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background:
    radial-gradient(circle at 50% 36%, #fff5b8 0 19%, transparent 20%),
    linear-gradient(180deg, #e43842, #8e1420);
}

.topbar-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topbar-links a {
  padding: 8px 14px;
  background: rgba(255, 248, 237, 0.88);
  color: var(--ink);
}

.storybook {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 18px;
  align-items: stretch;
}

.story-copy {
  align-self: center;
  padding: 34px 28px;
  color: var(--cream);
  text-shadow: 0 2px 18px rgba(36, 22, 21, 0.35);
}

.kicker {
  margin: 0 0 10px;
  font-family: "Caveat", cursive;
  font-size: 28px;
  font-weight: 700;
  color: #ffeab0;
  letter-spacing: 0;
}

h1,
h2,
.beat-title {
  margin: 0;
  font-family: "Sentient", "Newsreader", Georgia, serif;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  max-width: 10ch;
  font-size: 64px;
  line-height: 0.96;
}

.lede {
  max-width: 27ch;
  margin: 18px 0 0;
  color: #fff4df;
  font-size: 23px;
}

.beat-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 24px;
}

.beat-meta span {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 2px solid rgba(255, 248, 237, 0.65);
  border-radius: 999px;
  background: rgba(36, 22, 21, 0.22);
  color: var(--cream);
  font-size: 16px;
  font-weight: 800;
}

.scene-stage {
  position: relative;
  min-height: 690px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  overflow: hidden;
  background: var(--blue-deep);
  box-shadow: var(--shadow);
}

.scene-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition:
    opacity 220ms ease,
    transform 520ms ease;
}

.scene-image.is-switching {
  opacity: 0.2;
  transform: scale(1.015);
}

.scene-vignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(20, 15, 18, 0.03) 0 48%, rgba(20, 15, 18, 0.68) 100%),
    linear-gradient(90deg, rgba(26, 19, 27, 0.3), transparent 28% 72%, rgba(26, 19, 27, 0.24));
  pointer-events: none;
}

.heart-sprite,
.prayer-medallion {
  background-image: url("../images/catholic-kids/sacred-heart/sacred-heart-medallion-pulse-v1.webp");
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 100% 400%;
  animation: heartPulse 1.2s steps(4) infinite;
  filter: drop-shadow(0 12px 24px rgba(76, 17, 17, 0.34));
}

.heart-sprite {
  position: absolute;
  right: 24px;
  top: 24px;
  width: 126px;
  height: 126px;
  opacity: 0;
  transform: translateY(-8px) scale(0.92);
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.heart-sprite.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

@keyframes heartPulse {
  to {
    background-position: 0 100%;
  }
}

.line-card {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: rgba(255, 248, 237, 0.94);
  box-shadow: 0 3px 0 var(--ink);
}

.beat-title {
  color: var(--ruby-deep);
  font-size: 26px;
  line-height: 1.05;
}

.beat-line {
  margin: 0;
  max-width: 42ch;
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1.35;
}

.line-actions,
.prayer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.small-button,
.primary-action,
.secondary-action {
  min-width: 120px;
  padding: 8px 14px;
  cursor: pointer;
}

.small-button,
.secondary-action {
  background: var(--paper);
  color: var(--ink);
}

.primary-action {
  background: linear-gradient(135deg, var(--ruby), #e7534f);
  color: #fff8ed;
}

.small-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.gold-button {
  position: absolute;
  right: 24px;
  bottom: 160px;
  width: 72px;
  height: 72px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, #fff8c7 0 14%, transparent 15%),
    radial-gradient(circle, var(--gold) 0 54%, var(--gold-deep) 56% 100%);
  box-shadow:
    0 4px 0 var(--ink),
    0 0 0 8px rgba(255, 239, 179, 0.35),
    0 16px 34px rgba(111, 46, 20, 0.42);
  cursor: pointer;
  display: grid;
  place-items: center;
  animation: goldCue 1.7s ease-in-out infinite;
}

.gold-button span {
  width: 22px;
  height: 22px;
  border-right: 4px solid var(--ink);
  border-bottom: 4px solid var(--ink);
  transform: rotate(-45deg);
  margin-left: -6px;
}

.gold-button:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 var(--ink),
    0 0 0 8px rgba(255, 239, 179, 0.35),
    0 10px 22px rgba(111, 46, 20, 0.34);
}

@keyframes goldCue {
  0%,
  100% {
    outline: 0 solid rgba(255, 237, 171, 0);
  }
  50% {
    outline: 10px solid rgba(255, 237, 171, 0.28);
  }
}

.prayer-card {
  width: min(860px, calc(100% - 28px));
  margin: 22px auto 0;
  display: none;
  padding: 24px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 248, 237, 0.98), rgba(255, 232, 210, 0.98));
  box-shadow: var(--shadow);
  text-align: center;
}

.prayer-card.is-visible {
  display: grid;
  justify-items: center;
  gap: 12px;
  animation: prayerIn 320ms ease both;
}

@keyframes prayerIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.prayer-card .kicker {
  color: var(--ruby);
  margin: 0;
}

.prayer-card h2 {
  color: var(--ruby-deep);
  font-size: 36px;
  line-height: 1.05;
}

.prayer-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 21px;
}

.prayer-medallion {
  width: 118px;
  height: 118px;
}

.heart-explorer {
  width: min(1180px, 100%);
  margin: 24px auto 0;
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 248, 237, 0.98), rgba(255, 226, 197, 0.96)),
    radial-gradient(circle at 24% 16%, rgba(241, 191, 85, 0.32), transparent 38%);
  box-shadow: var(--shadow);
}

.explore-copy {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(280px, 1fr);
  gap: 12px 22px;
  align-items: end;
}

.explore-copy .kicker {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--ruby);
}

.explore-copy h2 {
  color: var(--ruby-deep);
  font-size: 42px;
  line-height: 0.98;
}

.explore-copy p {
  margin: 0;
  max-width: 52ch;
  color: var(--ink-soft);
  font-size: 21px;
  line-height: 1.32;
}

.heart-exhibit {
  position: relative;
  display: grid;
  grid-template-columns: minmax(420px, 1.1fr) minmax(300px, 0.9fr);
  gap: 22px;
  align-items: center;
}

.heart-viewer {
  position: relative;
  z-index: 1;
  min-height: 560px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(36, 22, 21, 0.88);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 225, 142, 0.34), transparent 36%),
    radial-gradient(circle at 50% 48%, rgba(166, 32, 43, 0.18), transparent 52%),
    linear-gradient(180deg, #33495a, #1f2d38);
  box-shadow: inset 0 0 0 2px rgba(255, 248, 237, 0.2);
  touch-action: none;
  user-select: none;
}

.heart-rotator {
  width: min(512px, 88%);
  aspect-ratio: 1;
  background-image: url("../images/catholic-kids/sacred-heart/heart-rotate-6x4-v1.png");
  background-repeat: no-repeat;
  background-size: 600% 400%;
  background-position: 0 0;
  filter: drop-shadow(0 24px 28px rgba(20, 8, 10, 0.32));
  cursor: grab;
}

.heart-viewer.is-dragging .heart-rotator {
  cursor: grabbing;
}

.hotspot-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.hotspot-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hotspot-dot {
  position: absolute;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, #fff9c9 0 18%, transparent 19%),
    radial-gradient(circle, #ffe67a 0 42%, #e34b45 43% 68%, #7c1722 69%);
  box-shadow:
    0 3px 0 var(--ink),
    0 0 0 8px rgba(255, 229, 114, 0.24),
    0 0 28px rgba(255, 218, 93, 0.72);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.82);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.hotspot-dot.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.hotspot-dot.is-active {
  background:
    radial-gradient(circle at 35% 28%, #fff9c9 0 18%, transparent 19%),
    radial-gradient(circle, #fff0a1 0 45%, #f1bf55 46% 68%, #7c1722 69%);
}

.hotspot-dot.is-listening,
.hotspot-card .primary-action.is-listening {
  opacity: 0.72;
  transform: translate(-50%, -50%) scale(0.96);
}

.hotspot-card .primary-action.is-listening {
  transform: none;
}

.hotspot-card {
  position: relative;
  z-index: 1;
  min-height: 320px;
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 22px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: rgba(255, 248, 237, 0.96);
  box-shadow: 0 3px 0 var(--ink);
}

.hotspot-kicker {
  margin: 0;
  color: var(--gold-deep);
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
}

.hotspot-card h3 {
  margin: 0;
  color: var(--ruby-deep);
  font-family: "Sentient", "Newsreader", Georgia, serif;
  font-size: 34px;
  line-height: 1;
}

.hotspot-card.is-listening h3 {
  color: var(--gold-deep);
  text-shadow: 0 0 18px rgba(255, 226, 135, 0.8);
}

.hotspot-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 21px;
  line-height: 1.35;
}

.hotspot-card .primary-action {
  width: fit-content;
  min-width: 170px;
}

.sacred-footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 24px auto 4px;
}

.sacred-footer a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 248, 237, 0.9);
  box-shadow: 0 3px 0 var(--ink);
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.audio-caption {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 30;
  max-width: min(520px, calc(100% - 24px));
  padding: 10px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--blue-deep);
  color: #fff8ed;
  box-shadow: 0 3px 0 var(--ink);
  font-weight: 800;
  font-size: 15px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.audio-caption.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

  .story-copy {
    padding: 16px 4px 6px;
  }

  h1 {
    max-width: 13ch;
    font-size: 48px;
  }

  .lede {
    font-size: 21px;
  }

  .scene-stage {
    min-height: 620px;
  }

  .explore-copy,
  .heart-exhibit {
    grid-template-columns: 1fr;
  }

  .heart-viewer {
    min-height: 520px;
  }

  .hotspot-card {
    min-height: 0;
  }
}

@media (max-width: 560px) {
  html,
  body {
    font-size: 18px;
  }

  .sacred-shell {
    padding: 10px;
  }

  .sacred-topbar {
    align-items: stretch;
  }

  .brand-pill {
    flex: 1 1 auto;
  }

  .topbar-links a {
    padding-inline: 10px;
  }

  .story-copy {
    text-align: left;
  }

  .kicker {
    font-size: 25px;
  }

  h1 {
    font-size: 36px;
  }

  .lede {
    font-size: 19px;
  }

  .beat-meta {
    margin-top: 14px;
  }

  .scene-stage {
    min-height: 612px;
  }

  .scene-image {
    object-position: center top;
  }

  .heart-sprite {
    width: 92px;
    height: 92px;
    right: 12px;
    top: 12px;
  }

  .line-card {
    left: 10px;
    right: 10px;
    bottom: 10px;
    padding: 14px;
  }

  .beat-title {
    font-size: 23px;
  }

  .beat-line {
    font-size: 18px;
  }

  .gold-button {
    width: 66px;
    height: 66px;
    right: 16px;
    bottom: 178px;
  }

  .small-button,
  .primary-action,
  .secondary-action {
    flex: 1 1 140px;
  }

  .prayer-card {
    padding: 18px 14px;
  }

  .prayer-card h2 {
    font-size: 29px;
  }

  .heart-explorer {
    padding: 14px;
  }

  .explore-copy h2 {
    font-size: 30px;
  }

  .explore-copy p,
  .hotspot-card p {
    font-size: 18px;
  }

  .heart-viewer {
    min-height: 390px;
  }

  .heart-rotator {
    width: min(340px, 96%);
  }

  .hotspot-dot {
    width: 42px;
    height: 42px;
  }

  .hotspot-card {
    padding: 16px;
  }

  .hotspot-card h3 {
    font-size: 28px;
  }

  .hotspot-card .primary-action {
    width: 100%;
  }
}
