/*
 * Slay Speech story player, rebuilt for the web.
 * Values mirror the Expo app (my-expo-app-sdk57): SwipeableStepContainer.tsx,
 * VideoStepView.tsx and PracticeStepView.tsx. NativeWind there uses 1rem = 14px,
 * so the Tailwind sizes below are already converted. Every RN size is written
 * as N * var(--pt) on a 402 x 874pt iPhone 17 Pro screen, so the UI scales with the frame.
 */
@font-face {
  font-family: 'Open Runde';
  src: url('/fonts/OpenRunde-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Open Runde';
  src: url('/fonts/OpenRunde-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Open Runde';
  src: url('/fonts/OpenRunde-Semibold.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Open Runde';
  src: url('/fonts/OpenRunde-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  /* Matches the gray figure box the blog wraps this frame in */
  background: #f7f7f7;
  color-scheme: light;
}
body {
  color: #000;
  font-family:
    'Open Runde',
    ui-rounded,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  /* Room for the drop shadow to fade before the iframe edge */
  padding: 8px 40px 32px;
}
button {
  font: inherit;
  cursor: pointer;
  border: 0;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #0079ea;
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Device ---------- */
.device {
  --device-w: min(100%, 352px, calc((100vh - 120px) * 660 / 1349));
  aspect-ratio: 660 / 1349;
  container-type: inline-size;
  margin: 0 auto;
  position: relative;
  width: var(--device-w);
  /* Follows the phone's exact silhouette (frame + screen) */
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.08))
    drop-shadow(0 10px 14px rgba(15, 23, 42, 0.1)) drop-shadow(0 28px 32px rgba(15, 23, 42, 0.16));
}
.device-frame {
  display: block;
  height: 100%;
  inset: 0;
  pointer-events: none;
  position: absolute;
  user-select: none;
  width: 100%;
  z-index: 10;
}
/* Screen cutout in the 660 x 1349 frame: 589 x 1281 at (35, 34). Extended by 2px under the bezel. */
.screen {
  --pt: calc(89.242cqw / 402);
  background: #fff;
  border-radius: calc(62 * var(--pt));
  height: 95.256%;
  left: 5%;
  overflow: hidden;
  position: absolute;
  top: 2.372%;
  width: 89.848%;
  isolation: isolate;
}
.status-bar {
  left: 50%;
  pointer-events: none;
  position: absolute;
  top: calc(23.2 * var(--pt));
  transform: translateX(-50%);
  width: calc(334.7 * var(--pt));
  z-index: 60;
}
.icon {
  display: block;
  fill: none;
  flex: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}
.icon-filled {
  fill: currentColor;
}

.demo-status {
  color: #525252;
  font-size: 13px;
  line-height: 1.5;
  margin: 14px auto 0;
  max-width: 24em;
  min-height: 3em;
  text-align: center;
}

/* ---------- Top nav (SwipeableStepContainer) ---------- */
.koel-app-nav {
  align-items: center;
  display: flex;
  gap: calc(7 * var(--pt));
  justify-content: space-between;
  left: 0;
  padding: 0 calc(28 * var(--pt));
  position: absolute;
  right: 0;
  top: calc(59.5 * var(--pt));
  z-index: 50;
}
.koel-exit {
  align-items: center;
  background: #fee2e2;
  border-radius: 9999px;
  color: red;
  display: inline-flex;
  flex: none;
  padding: calc(8 * var(--pt)) calc(14 * var(--pt));
}
.koel-exit .icon {
  fill: red;
  height: calc(14 * var(--pt));
  stroke-width: 4;
  width: calc(14 * var(--pt));
}
.koel-progress {
  display: flex;
  flex: 1;
  gap: calc(3.5 * var(--pt));
  min-width: 0;
}
.koel-progress span {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 9999px;
  flex: 1;
  height: calc(4 * var(--pt));
  overflow: hidden;
}
.koel-progress i {
  background: #000;
  border-radius: 9999px;
  display: block;
  height: 100%;
  transition: width 200ms linear;
  width: var(--fill, 0%);
}
.koel-progress span.done {
  --fill: 100%;
}
.koel-counter {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 9999px;
  flex: none;
  font-size: calc(14 * var(--pt));
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: calc(19 * var(--pt));
  padding: calc(7 * var(--pt)) calc(12.25 * var(--pt));
}

.koel-view {
  inset: 0;
  position: absolute;
}

/* ---------- Video step (VideoStepView) ---------- */
.koel-video-card {
  background: #00000005;
  border: 1px solid #00000020;
  border-radius: calc(27 * var(--pt));
  bottom: calc(82 * var(--pt));
  left: calc(14 * var(--pt));
  overflow: hidden;
  padding: calc(6 * var(--pt));
  position: absolute;
  right: calc(14 * var(--pt));
  top: calc(100 * var(--pt));
}
.koel-video-frame {
  background: #ececec;
  border: 1px solid #e6e6e6;
  border-radius: calc(20 * var(--pt));
  height: 100%;
  overflow: hidden;
  position: relative;
  transform: translateZ(0); /* clip the video layer to the radius without edge bleed */
  width: 100%;
}
.koel-video-frame video,
.koel-video-frame img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}
.koel-video-controls {
  align-items: center;
  bottom: 0;
  display: flex;
  gap: calc(7 * var(--pt));
  justify-content: space-between;
  left: 0;
  padding: calc(14 * var(--pt)) calc(35 * var(--pt)) calc(34 * var(--pt));
  position: absolute;
  right: 0;
  z-index: 40;
}
.koel-pill-group {
  display: flex;
  gap: calc(7 * var(--pt));
}
.koel-pill {
  align-items: center;
  background: #e5e5e5;
  border-radius: 9999px;
  color: #000;
  display: inline-flex;
  font-size: calc(15.75 * var(--pt));
  font-weight: 600;
  gap: calc(7 * var(--pt));
  letter-spacing: -0.025em;
  line-height: calc(24.5 * var(--pt));
  padding: calc(6 * var(--pt)) calc(14 * var(--pt));
  white-space: nowrap;
}
.koel-pill-play {
  background: #d5ebff;
  color: #0079ea;
  padding-inline: calc(12.25 * var(--pt));
}
.koel-pill-play .icon {
  fill: currentColor;
  height: calc(14 * var(--pt));
  width: calc(14 * var(--pt));
}
.koel-pill-speed {
  font-variant-numeric: tabular-nums;
}

/* ---------- Practice step (PracticeStepView) ---------- */
.koel-practice {
  inset: 0;
  padding: 0 calc(30 * var(--pt));
  position: absolute;
}
.koel-header {
  margin: calc(170 * var(--pt)) 0 calc(28 * var(--pt));
  text-align: center;
}
.koel-step-label {
  font-size: calc(12.25 * var(--pt));
  font-weight: 600;
  letter-spacing: 0.025em;
  line-height: calc(17.5 * var(--pt));
  margin: 0 0 calc(14 * var(--pt));
  text-transform: uppercase;
}
.koel-prompt {
  font-size: calc(21 * var(--pt));
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin: 0;
  text-wrap: balance;
}
.koel-speaking {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: calc(17.5 * var(--pt));
}
.koel-word-row {
  display: flex;
  flex-wrap: wrap;
  gap: calc(7 * var(--pt));
  justify-content: center;
}
.koel-word {
  background: transparent;
  border: 1px dashed #d4d4d4;
  border-radius: calc(17 * var(--pt));
  color: #404040;
  font-size: calc(19 * var(--pt));
  font-weight: 500;
  line-height: calc(25 * var(--pt));
  padding: calc(8.75 * var(--pt)) calc(14 * var(--pt));
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease;
}
.koel-word.live,
.koel-word.scored {
  border-style: solid;
  color: #fff;
}
.koel-word.live {
  background: #0079ea;
  border-color: #0079ea;
}
.koel-word.scored {
  background: var(--score);
  border-color: var(--score);
}
.score-great {
  --score: #019457;
}
.score-good {
  --score: #01bf67;
}
.score-mid {
  --score: #40cf67;
}
.score-yellow {
  --score: #f7c401;
}
.score-ok {
  --score: #fbac27;
}
.score-low {
  --score: #ff9649;
}
.score-poor {
  --score: #ff6420;
}
.score-bad {
  --score: #f1301e;
}
.score-worst {
  --score: #f03221;
}

.koel-reference {
  align-items: center;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: calc(14 * var(--pt));
  color: #404040;
  display: inline-flex;
  font-size: calc(12.25 * var(--pt));
  font-weight: 600;
  gap: calc(7 * var(--pt));
  line-height: calc(17.5 * var(--pt));
  margin-top: calc(7 * var(--pt));
  padding: calc(7 * var(--pt)) calc(10.5 * var(--pt));
}
.koel-reference .icon {
  color: #525252;
  fill: #525252;
  height: calc(10 * var(--pt));
  width: calc(10 * var(--pt));
}
.koel-reference:disabled {
  background: #f5f5f5;
  border-color: #f5f5f5;
  cursor: default;
  opacity: 0.6;
}

/* Footer: playback row + action row, pinned 40pt from the bottom */
.koel-footer {
  bottom: calc(40 * var(--pt));
  left: calc(28 * var(--pt));
  position: absolute;
  right: calc(28 * var(--pt));
  z-index: 30;
}
.koel-footer-actions {
  display: flex;
  gap: calc(10.5 * var(--pt));
}
.koel-action {
  align-items: center;
  background: #d5ebff;
  border-radius: 9999px;
  color: #0079ea;
  display: inline-flex;
  flex: 1;
  font-size: calc(17.5 * var(--pt));
  font-weight: 600;
  gap: calc(10.5 * var(--pt));
  height: calc(56 * var(--pt));
  justify-content: center;
  letter-spacing: -0.025em;
  text-decoration: none;
  transition: transform 120ms ease;
}
.koel-action:active {
  transform: scale(0.97);
}
.koel-action.recording {
  background: #ef4444;
  color: #fff;
}
.koel-action.analyzing {
  background: #fff;
  border: 1px solid #e5e5e5;
  cursor: default;
}
.koel-action.continue {
  background: #d0eddb;
  color: #166534;
  flex: 3;
}
.koel-action.secondary {
  background: #f5f5f5;
  color: #000;
}
.koel-retry {
  align-items: center;
  background: #f5f5f5;
  border-radius: 9999px;
  color: #000;
  display: inline-flex;
  flex: none;
  height: calc(56 * var(--pt));
  justify-content: center;
  width: calc(56 * var(--pt));
}
.koel-retry .icon {
  height: calc(18 * var(--pt));
  stroke-width: 2.5;
  width: calc(18 * var(--pt));
}

/* Live recording bars (iOS: 12 bars, 3.5 wide, gap 3.5, 7-30pt) */
.koel-rec-bars {
  align-items: center;
  display: flex;
  gap: calc(3.5 * var(--pt));
  height: calc(30 * var(--pt));
}
.koel-rec-bars i {
  animation: koel-rec 900ms ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * -137ms);
  background: #fff;
  border-radius: 9999px;
  display: block;
  height: calc(7 * var(--pt));
  width: calc(3.5 * var(--pt));
}
@keyframes koel-rec {
  0% {
    height: calc(7 * var(--pt));
    opacity: 0.65;
  }
  100% {
    height: calc(var(--h) * var(--pt));
    opacity: 1;
  }
}

/* "Analyzing Pronunciation" shimmer */
.koel-shimmer {
  animation: koel-shimmer 1400ms linear infinite;
  background:
    linear-gradient(
        90deg,
        rgba(209, 213, 219, 0) 30%,
        rgba(17, 24, 39, 0.9) 50%,
        rgba(209, 213, 219, 0) 70%
      )
      0 0 / 250% 100%,
    linear-gradient(#a3a3a3, #a3a3a3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 500;
}
@keyframes koel-shimmer {
  from {
    background-position:
      100% 0,
      0 0;
  }
  to {
    background-position:
      -50% 0,
      0 0;
  }
}

/* Recording playback row */
.koel-playback {
  align-items: center;
  background: #f5f5f5;
  border-radius: calc(21 * var(--pt));
  display: flex;
  gap: calc(10.5 * var(--pt));
  height: calc(56 * var(--pt));
  margin-bottom: calc(14 * var(--pt));
  overflow: hidden;
  padding: 0 calc(14 * var(--pt));
  position: relative;
}
.koel-playback-button {
  align-items: center;
  background: transparent;
  border-radius: 9999px;
  color: #525252;
  display: inline-flex;
  flex: none;
  justify-content: center;
  margin-left: calc(-3.5 * var(--pt));
  min-height: calc(35 * var(--pt));
  min-width: calc(35 * var(--pt));
  padding: calc(7 * var(--pt));
}
.koel-playback-button .icon {
  fill: currentColor;
  height: calc(20 * var(--pt));
  width: calc(20 * var(--pt));
}
.koel-wave {
  flex: 1;
  height: 100%;
  min-width: 0;
  position: relative;
}
.koel-wave-bars {
  align-items: center;
  display: flex;
  gap: calc(2 * var(--pt));
  height: 100%;
  inset: 0;
  overflow: hidden;
  position: absolute;
}
.koel-wave-bars i {
  background: #a3a3a3;
  border-radius: 9999px;
  display: block;
  flex: none;
  height: calc(var(--h) * var(--pt));
  width: calc(2 * var(--pt));
}
.koel-wave-bars.played {
  clip-path: inset(0 calc(100% - var(--played, 0%)) 0 0);
}
.koel-wave-bars.played i {
  background: #171717;
}

/* Pronunciation tips stack, pinned 12pt above the footer */
/* Footer top is 166pt from the bottom; leave room for the two peeking cards (20pt) plus a 12pt gap. */
.koel-tips {
  bottom: calc(200 * var(--pt));
  display: flex;
  flex-direction: column;
  gap: calc(14 * var(--pt));
  left: calc(28 * var(--pt));
  position: absolute;
  right: calc(28 * var(--pt));
  z-index: 20;
}
.koel-tips-title {
  align-items: center;
  display: flex;
  font-size: calc(15.75 * var(--pt));
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: calc(24.5 * var(--pt));
  margin: 0;
  overflow: hidden;
}
.koel-tips-title i {
  background: #e5e5e5;
  flex: 1;
  height: 1px;
  margin-left: calc(14 * var(--pt));
}
.koel-tip-stack {
  position: relative;
}
.koel-tip {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: calc(19 * var(--pt));
  min-height: calc(114 * var(--pt));
  padding: calc(14 * var(--pt));
  position: relative;
  touch-action: pan-y;
  transition:
    transform 220ms ease,
    opacity 220ms ease;
}
.koel-tip.behind {
  inset: 0;
  min-height: 0;
  opacity: var(--o);
  pointer-events: none;
  position: absolute;
  transform: translateY(calc(var(--d) * 10 * var(--pt))) scale(calc(1 - var(--d) * 0.04));
  transform-origin: 50% 100%;
  z-index: -1;
}
.koel-tip.behind > * {
  visibility: hidden;
}
.koel-tip-top {
  align-items: flex-start;
  display: flex;
  gap: calc(7 * var(--pt));
}
.koel-tip-icon {
  background: #ffedd5;
  border-radius: calc(10.5 * var(--pt));
  color: #f97316;
  flex: none;
  margin: calc(-3.5 * var(--pt)) 0 0 calc(-3.5 * var(--pt));
  padding: calc(10.5 * var(--pt));
}
.koel-tip-icon.good {
  background: #d3e8dc;
  color: #218c52;
}
.koel-tip-icon .icon {
  height: calc(22 * var(--pt));
  width: calc(22 * var(--pt));
}
.koel-tip h4 {
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  color: #262626;
  display: -webkit-box;
  flex: 1;
  font-size: calc(15.75 * var(--pt));
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: calc(22 * var(--pt));
  margin: calc(-1.75 * var(--pt)) 0 0 calc(1.75 * var(--pt));
  overflow: hidden;
}
.koel-tip-chevron {
  align-items: center;
  background: #f5f5f5;
  border-radius: calc(14 * var(--pt));
  color: #6e6e6e;
  display: inline-flex;
  flex: none;
  height: calc(31.5 * var(--pt));
  justify-content: center;
  width: calc(31.5 * var(--pt));
}
.koel-tip-chevron .icon {
  height: calc(18 * var(--pt));
  stroke-width: 2.5;
  width: calc(18 * var(--pt));
}
.koel-tip-hint {
  color: #a3a3a3;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: calc(10.5 * var(--pt));
  font-style: italic;
  line-height: 1.4;
  margin: calc(14 * var(--pt)) calc(56 * var(--pt)) 0 0;
}
.koel-tip.expanded .koel-tip-hint {
  color: #525252;
  font-size: calc(12.25 * var(--pt));
  font-style: normal;
  margin-right: 0;
  margin-bottom: calc(14 * var(--pt));
}
.koel-tip-count {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 9999px;
  bottom: calc(10.5 * var(--pt));
  color: #a3a3a3;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: calc(10.5 * var(--pt));
  line-height: 1.3;
  padding: calc(3.5 * var(--pt)) calc(7 * var(--pt));
  position: absolute;
  right: calc(10.5 * var(--pt));
}

/* Story complete */
.koel-done-body {
  color: #737373;
  font-size: calc(14 * var(--pt));
  font-weight: 500;
  line-height: 1.5;
  margin: calc(14 * var(--pt)) 0 0;
  text-align: center;
}
.koel-footer.stacked .koel-footer-actions {
  flex-direction: column;
}
.koel-footer.stacked .koel-action {
  flex: none;
}

@media (prefers-reduced-motion: reduce) {
  .koel-rec-bars i,
  .koel-shimmer {
    animation: none;
  }
  .koel-shimmer {
    color: #737373;
    background: none;
  }
}
