/* Bit2Beat · Story page, Bitty the space pup and the guided tour. */

/* ---------------------------------------------------------------- Bitty */
.bitty {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.bitty .bt-tail {
  transform-origin: 112px 105px;
  animation: bt-wag 1.6s ease-in-out infinite;
}
.bitty .bt-ear-l {
  transform-origin: 44px 46px;
  animation: bt-ear 4.8s ease-in-out infinite;
}
.bitty .bt-ear-r {
  transform-origin: 109px 46px;
  animation: bt-ear 4.8s ease-in-out infinite 0.4s;
}
.bitty .bt-tilt {
  transform-origin: 77px 70px;
  transform: rotate(-7deg);
}
.bitty .bt-eyes {
  transform-origin: 77px 58px;
  animation: bt-blink 5.5s infinite;
}
@keyframes bt-wag {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(10deg); }
}
@keyframes bt-ear {
  0%, 86%, 100% { transform: rotate(0); }
  92% { transform: rotate(-8deg); }
}
@keyframes bt-blink {
  0%, 95%, 100% { transform: scaleY(1); }
  97% { transform: scaleY(0.1); }
}
.bt-hop {
  animation: bt-hop 0.55s ease;
}
@keyframes bt-hop {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-9px); }
  70% { transform: translateY(2px); }
}
.reduce-motion .bitty *,
.reduce-motion .bt-hop,
.bt-still .bitty * {
  animation: none !important;
}

/* ---------------------------------------------------------------- Story page */
.story {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 24px 132px;
}
.story:focus {
  outline: none;
}
.story-hero {
  position: relative;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 28px;
  align-items: center;
  padding: 28px 32px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 12% 30%, rgba(232, 163, 61, 0.22), transparent 38%),
    radial-gradient(1.2px 1.2px at 30% 20%, rgba(246, 241, 231, 0.7), transparent 2px),
    radial-gradient(1px 1px at 70% 30%, rgba(246, 241, 231, 0.6), transparent 2px),
    radial-gradient(1.4px 1.4px at 86% 72%, rgba(246, 241, 231, 0.6), transparent 2px),
    radial-gradient(1px 1px at 55% 85%, rgba(246, 241, 231, 0.5), transparent 2px),
    var(--navy);
  color: var(--cream);
  overflow: hidden;
}
.story-hero-dog {
  width: 200px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #f6f1e7 0 58%, rgba(246, 241, 231, 0.12) 59% 64%, transparent 65%);
  display: grid;
  place-items: center;
  animation: bt-float 6s ease-in-out infinite;
}
.story-hero-dog .bitty {
  width: 78%;
}
@keyframes bt-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.reduce-motion .story-hero-dog {
  animation: none;
}
.story-kicker,
.chapter-kicker {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--amber);
}
.chapter-kicker {
  color: var(--amber-ink);
}
.story-hero h1 {
  font-size: clamp(1.7rem, 3.2vw, 2.4rem);
  line-height: 1.15;
  margin: 4px 0 10px;
  color: var(--cream);
}
.story-hero .lead {
  max-width: 68ch;
  color: rgba(246, 241, 231, 0.86);
  font-size: 1rem;
  line-height: 1.55;
}
.story-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 18px;
}
.story-hero .btn:not(.btn-primary) {
  background: transparent;
  color: var(--cream);
  border-color: rgba(246, 241, 231, 0.35);
}
.story-hero .btn:not(.btn-primary):hover {
  border-color: var(--cream);
}
.story-hero .btn[aria-pressed='true'] {
  background: var(--cream);
  border-color: var(--cream);
  color: var(--navy);
}
.check-inline {
  align-items: center;
}
.check-inline input {
  margin-top: 0;
}
.story-hero .check input {
  accent-color: var(--amber);
}
.story-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  font-size: 0.85rem;
  color: rgba(246, 241, 231, 0.8);
}
.story-dots {
  display: inline-flex;
  gap: 4px;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.story-dots i {
  font-style: normal;
  min-width: 1.6em;
  text-align: center;
  padding: 1px 3px;
  border-radius: 4px;
  border: 1px solid rgba(246, 241, 231, 0.3);
  color: rgba(246, 241, 231, 0.75);
}
.story-dots i.on {
  border-color: var(--amber);
  color: var(--cream);
}
.story-dots i.now {
  border-color: var(--cream);
  font-weight: 700;
}

/* chapters: a timeline */
.story-chapters {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  position: relative;
}
.story-chapters::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 12px;
  bottom: 12px;
  border-left: 2px dashed var(--line);
}
.chapter {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
.chapter-node {
  position: relative;
  z-index: 1;
  width: 28px;
  height: 28px;
  margin-top: 22px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--navy);
}
.chapter.is-heard .chapter-node {
  background: var(--amber);
  border-color: var(--amber);
}
.chapter.is-heard .chapter-node::after {
  content: '✓';
}
.chapter.is-current .chapter-node {
  border-color: var(--text);
}
.chapter[data-state='playing'] .chapter-node::after {
  content: '▶';
  font-size: 0.7rem;
}
.reduce-motion .chapter-node {
  animation: none !important;
}
.chapter-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chapter.is-current .chapter-card {
  border-color: var(--amber);
  box-shadow: 0 6px 24px rgba(20, 33, 61, 0.1);
}
.chapter-card header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 14px;
}
.chapter-card header .chapter-kicker {
  flex-basis: 100%;
}
.chapter-card h2 {
  font-size: 1.35rem;
  margin: 2px 0 12px;
}
.chapter-heard {
  display: none;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--amber-ink);
}
.chapter.is-heard .chapter-heard {
  display: inline-block;
}
.chapter-body {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.chapter-say {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  align-items: start;
}
.chapter-dog {
  width: 76px;
}
.chapter-bubble {
  position: relative;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 12px 14px;
  line-height: 1.55;
  font-size: 0.95rem;
}
.chapter-bubble::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 22px;
  border: 8px solid transparent;
  border-left: 0;
  border-right-color: var(--surface-2);
}
.chapter-side {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.chapter-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 150px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--navy);
}
.chapter-spark {
  width: 100%;
  height: 72px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--grid);
}
.chapter-listen {
  font-size: 0.88rem;
  border-left: 3px solid var(--amber);
  padding: 2px 0 2px 10px;
}
.chapter-side h3 {
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  color: var(--muted);
  margin-top: 4px;
}
.chapter-facts {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
}
.chapter-facts li {
  position: relative;
  padding-left: 16px;
}
.chapter-facts li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 0.55em;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--amber);
}
.chapter-origin {
  font-size: 0.75rem;
  color: var(--muted);
}
.chapter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--grid);
}
.chapter-play {
  min-width: 128px;
}
.chapter-play-icon {
  width: 0;
  height: 0;
  border-left: 10px solid currentColor;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}
.chapter[data-state='playing'] .chapter-play-icon {
  width: 10px;
  height: 12px;
  border: 0;
  border-left: 3px solid currentColor;
  border-right: 3px solid currentColor;
}
.chapter[data-state='loading'] .chapter-play-icon {
  border: 2px solid currentColor;
  border-right-color: transparent;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  animation: bt-spin 0.8s linear infinite;
}
@keyframes bt-spin {
  to { transform: rotate(360deg); }
}
.chapter-status {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: auto;
}

/* epilogue */
.story-finale {
  display: grid;
  grid-template-columns: 150px 1fr 150px;
  gap: 24px;
  align-items: center;
  margin: 8px 0 0 44px;
  padding: 24px 28px;
  border-radius: 16px;
  background: var(--navy);
  color: var(--cream);
}
.story-finale h2 {
  font-size: 1.6rem;
  margin: 2px 0 8px;
  color: var(--cream);
}
.story-finale p:not(.chapter-kicker) {
  color: rgba(246, 241, 231, 0.86);
  line-height: 1.55;
  max-width: 62ch;
}
.story-finale .chapter-kicker {
  color: var(--amber);
}
.story-finale .btn-row {
  margin-top: 14px;
}
.story-finale .btn:not(.btn-primary) {
  background: transparent;
  color: var(--cream);
  border-color: rgba(246, 241, 231, 0.35);
}
.finale-dog {
  background: var(--cream);
  border-radius: 50%;
  padding: 18px;
}
.bt-badge {
  width: 100%;
  height: auto;
  display: block;
}
.bt-badge.is-locked {
  filter: grayscale(1);
  opacity: 0.45;
}
.finale-badge p {
  margin-top: 8px;
  font-size: 0.78rem;
  text-align: center;
  color: rgba(246, 241, 231, 0.75);
}

/* ---------------------------------------------------------------- guided tour */
.bt-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}
.bt-dim {
  position: fixed;
  background: rgba(10, 16, 32, 0.58);
  pointer-events: auto;
}
.bt-ring {
  position: fixed;
  border: 3px solid var(--amber);
  border-radius: 12px;
  pointer-events: auto; /* the highlighted area is for looking, unless the step asks you to use it */
  transition: left 0.25s, top 0.25s, width 0.25s, height 0.25s;
}
.bt-ring.bt-live {
  pointer-events: none;
  border-style: dashed;
}
.bt-still .bt-ring,
.bt-still .bt-bubble {
  transition: none;
  animation: none;
}
.bt-away {
  visibility: hidden;
}
.bt-bubble {
  position: fixed;
  width: min(390px, calc(100vw - 24px));
  pointer-events: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px 12px;
  box-shadow: 0 18px 50px rgba(10, 16, 32, 0.35);
  transition: left 0.25s, top 0.25s;
}
.bt-bubble:focus {
  outline: none;
}
.bt-bubble:focus-visible {
  box-shadow: var(--focus), 0 18px 50px rgba(10, 16, 32, 0.35);
}
.bt-bubble.bt-hero {
  width: min(460px, calc(100vw - 24px));
  text-align: center;
}
.bt-bubble::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  transform: rotate(45deg);
  display: none;
}
.bt-bubble[data-placement='bottom']::before {
  display: block;
  top: -8px;
  left: calc(var(--caret-x, 50%) - 7px);
  border-right: 0;
  border-bottom: 0;
}
.bt-bubble[data-placement='top']::before {
  display: block;
  bottom: -8px;
  left: calc(var(--caret-x, 50%) - 7px);
  border-left: 0;
  border-top: 0;
}
.bt-bubble[data-placement='right']::before {
  display: block;
  left: -8px;
  top: calc(var(--caret-y, 50%) - 7px);
  border-right: 0;
  border-top: 0;
}
.bt-bubble[data-placement='left']::before {
  display: block;
  right: -8px;
  top: calc(var(--caret-y, 50%) - 7px);
  border-left: 0;
  border-bottom: 0;
}
.bt-head {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.bt-dog {
  width: 64px;
}
.bt-hero .bt-head {
  justify-content: center;
}
.bt-hero .bt-dog {
  width: 112px;
}
.bt-count {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.bt-x {
  margin-left: auto;
  align-self: flex-start;
  background: none;
  border: 0;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.bt-hero .bt-x {
  position: absolute;
  right: 10px;
  top: 10px;
}
.bt-x:hover {
  color: var(--text);
  background: var(--surface-2);
}
.bt-badge-wrap {
  width: 92px;
  margin: 8px auto 0;
}
.bt-title {
  font-size: 1.15rem;
  margin: 8px 0 4px;
}
.bt-text {
  font-size: 0.92rem;
  line-height: 1.5;
}
.bt-done {
  margin-top: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--amber-ink);
}
.bt-progress {
  display: flex;
  gap: 4px;
  margin: 12px 0 0;
}
.bt-progress i {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--grid);
}
.bt-progress i.on {
  background: var(--amber);
}
.bt-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.bt-hero .bt-foot {
  justify-content: center;
}
.bt-spacer {
  flex: 1;
}
.bt-hero .bt-spacer {
  display: none;
}
.bt-hero .bt-skip {
  order: 3;
  flex-basis: 100%;
}
.bt-attn::after {
  content: ' →';
}
.help-bitty {
  margin-top: 14px;
}
.bitty-head > span {
  white-space: nowrap;
}

/* ---------------------------------------------------------------- dark theme and small screens */
:root[data-theme='dark'] .story-hero,
:root[data-theme='dark'] .story-finale {
  background-color: #0a1222;
  border: 1px solid var(--line);
}
:root[data-theme='dark'] .chapter-node {
  color: var(--navy);
}
:root[data-theme='dark'] .chapter.is-current .chapter-card {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

@media (max-width: 900px) {
  .chapter-body {
    grid-template-columns: 1fr;
  }
  .story-finale {
    grid-template-columns: 110px 1fr;
    margin-left: 0;
  }
  .finale-badge {
    grid-column: 1;
    grid-row: 2;
  }
}
@media (max-width: 640px) {
  .story {
    padding: 14px 12px 150px;
  }
  .story-hero {
    grid-template-columns: 1fr;
    padding: 20px 18px;
    text-align: left;
  }
  .story-hero-dog {
    width: 120px;
  }
  .story-chapters::before {
    left: 9px;
  }
  .chapter {
    grid-template-columns: 20px 1fr;
    gap: 10px;
  }
  .chapter-node {
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
  }
  .chapter-card {
    padding: 14px;
  }
  .chapter-say {
    grid-template-columns: 52px 1fr;
  }
  .chapter-dog {
    width: 52px;
  }
  .chapter-status {
    margin-left: 0;
    flex-basis: 100%;
  }
  .story-finale {
    grid-template-columns: 1fr;
    text-align: left;
  }
  .finale-dog {
    width: 110px;
  }
  .finale-badge {
    width: 110px;
    grid-row: auto;
  }
  .bt-dog {
    width: 52px;
  }
  .bt-foot .btn {
    flex: 1 1 auto;
  }
  .bt-spacer {
    display: none;
  }
  .bt-skip {
    order: 3;
    flex-basis: 100%;
  }
}

/* ---------------------------------------------------------------- Guide button, tips, menu */
.guide-btn {
  border-color: rgba(232, 163, 61, 0.7);
  padding: 2px 12px 2px 6px;
}
.guide-btn:hover {
  border-color: var(--amber);
  background: rgba(232, 163, 61, 0.12);
}
.guide-btn .guide-face {
  display: block !important;
  width: 30px;
}
.btn-small {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 0.82rem;
}
.bitty-tip {
  margin: 6px 0 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border-left: 3px solid var(--amber);
  font-size: 0.84rem;
  color: var(--text) !important;
}
.bitty-tip-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.bt-menu {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.bt-has-menu .bt-menu {
  display: grid;
  gap: 6px;
  justify-items: stretch;
}
.bt-has-menu .bt-menu .btn {
  justify-content: flex-start;
  text-align: left;
}
.bt-has-menu {
  text-align: left;
}
.bt-has-menu .bt-title,
.bt-has-menu .bt-text {
  text-align: center;
}
.bt-menu[hidden],
.bt-foot[hidden] {
  display: none;
}
.bt-note {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------------------------------------------------------------- reading-aloud bar */
.speech-bar {
  position: fixed;
  z-index: 90;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 10px;
  border-radius: 14px;
  background: var(--navy);
  color: var(--cream);
  border: 1px solid rgba(232, 163, 61, 0.55);
  box-shadow: 0 10px 30px rgba(10, 16, 32, 0.3);
}
.speech-bar[hidden] {
  display: none;
}
.speech-face {
  width: 38px;
  flex: none;
  background: var(--cream);
  border-radius: 50%;
  padding: 3px;
}
.speech-text {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.speech-text span {
  color: rgba(246, 241, 231, 0.7);
}
.speech-actions {
  display: flex;
  gap: 6px;
  flex: none;
}
.speech-bar .btn:not(.btn-primary) {
  background: transparent;
  color: var(--cream);
  border-color: rgba(246, 241, 231, 0.35);
}
.speech-bar .btn[aria-pressed='true'] {
  background: var(--cream);
  color: var(--navy);
}
:root[data-theme='dark'] .speech-bar {
  background: #0a1222;
}
@media (max-width: 640px) {
  .speech-bar {
    top: auto;
    bottom: 150px;
    flex-wrap: wrap;
  }
  .speech-text {
    flex-basis: calc(100% - 52px);
  }
  .speech-actions {
    width: 100%;
  }
  .speech-actions .btn {
    flex: 1;
  }
}
