/* Sound Match: a night scene, blurred while you listen, and the owls as
   OBDK stickers on frosted cards. Its own file, like FOOT ID's. */

.lab--sm { padding: 0; background: none; border: 0; box-shadow: none; }

.sm {
  --display: "Fredoka", var(--display-font, "Space Grotesk"), sans-serif;
  --read: "Andika", var(--sans, sans-serif);
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 560px; border-radius: 24px;
  scroll-margin-top: 76px;
  color: #fff; font-family: var(--display); text-align: center;
  background: #0d1730;
}

/* --- The scene: two pictures that cross-fade, blurred until the answer ---- */
.sm__scene { position: absolute; inset: 0; z-index: -1; }
.sm__bg {
  position: absolute; inset: -30px; width: calc(100% + 60px); height: calc(100% + 60px);
  max-width: none; object-fit: cover; opacity: 0;
  filter: blur(14px) brightness(0.62) saturate(1.1);
  transition: opacity 0.9s ease, filter 1.1s ease;
}
.sm__bg.is-on { opacity: 1; }
.sm.is-sharp .sm__bg { filter: blur(0) brightness(0.8); }
.sm__scene::after { /* darker at the bottom, where the reading is */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgb(8 14 34 / 0.1), rgb(8 14 34 / 0.55) 75%);
}

.sm__screen {
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  padding: clamp(1rem, 3vw, 1.8rem);
}
.sm p { margin: 0; }
.sm__screen.is-in, .sm__screen { animation: sm-in 0.45s ease both; }
@keyframes sm-in { from { opacity: 0; translate: 0 10px; } }

.sm__lead {
  max-width: 32em; font: 500 clamp(1.05rem, 2.4vw, 1.35rem)/1.4 var(--display);
  text-shadow: 0 2px 8px rgb(0 0 0 / 0.6);
}

/* The big orange button. */
.sm__go {
  display: inline-flex; align-items: center; gap: 0.5em;
  padding: 0.7em 1.5em; border: 0; border-radius: 99px; cursor: pointer;
  background: #f6a623; color: #1f2d33;
  box-shadow: 0 5px 0 #a8650b, 0 12px 24px rgb(0 0 0 / 0.4);
  font: 700 clamp(1.1rem, 2.6vw, 1.4rem)/1 var(--display);
}
.sm__go:hover { translate: 0 -1px; }
.sm__go:active { translate: 0 4px; box-shadow: 0 1px 0 #a8650b; }

/* Sound on and off, top left (the Full screen button is top right). */
.sm__mute {
  position: absolute; left: 0.9rem; top: 0.9rem; z-index: 3;
  width: 2.6rem; height: 2.6rem; border: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center;
  background: rgb(255 250 240 / 0.95); color: #1f2d33; box-shadow: 0 4px 12px rgb(0 0 0 / 0.35);
}
.sm__mute svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.sm__mute .sm-spk-off { display: none; }
.sm__mute.is-off .sm-spk-on { display: none; }
.sm__mute.is-off .sm-spk-off { display: inline; }
.sm__mute.is-off { color: #8a969a; }

/* --- The start screen: a fan of the owls -------------------------------- */
.sm__screen--open { justify-content: center; min-height: 560px; gap: 1.4rem; }
/* All the owls in one oak. Owl height follows --s (Great Gray = 1) and the
   oak's width (cqw), so sizes stay right at any screen width. */
.sm-tree {
  position: relative; width: min(100%, 600px); aspect-ratio: 1024 / 820;
  container-type: inline-size; margin-top: 0.4rem;
}
.sm-tree__oak {
  position: absolute; inset: 0; width: 100%; height: 100%;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14%, #000 78%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 14%, #000 78%, transparent 100%);
  filter: drop-shadow(0 12px 24px rgb(0 0 0 / 0.35)) saturate(0.9) brightness(0.92);
}
.sm-tree__owl {
  position: absolute; left: var(--x); top: var(--y);
  height: calc(var(--s, 1) * 24cqw); width: auto; max-width: none;
  translate: -50% -100%; scale: var(--f, 1) 1;
  filter: drop-shadow(0 6px 8px rgb(0 0 0 / 0.45));
  animation: sm-perch 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) both;
  animation-delay: calc(0.15s + var(--i) * 0.07s);
}
@keyframes sm-perch { from { translate: -50% -70%; opacity: 0; } }

/* --- A round ---------------------------------------------------------------- */
.sm__top {
  display: flex; align-items: center; justify-content: center; gap: 0.9rem; flex-wrap: wrap;
  align-self: stretch; min-height: 2.6rem; padding-inline: 3.4rem 8.5rem;
}
.sm__count { font: 700 1.15rem/1 var(--display); text-shadow: 0 2px 6px rgb(0 0 0 / 0.6); }
.sm__dots { display: flex; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.sm__dots li { width: 0.8rem; height: 0.8rem; border-radius: 50%; background: rgb(255 255 255 / 0.35); box-shadow: 0 1px 3px rgb(0 0 0 / 0.4); }
.sm__dots .is-now { background: #f6a623; }
.sm__dots .is-right { background: #3fc1a9; }
.sm__dots .is-missed { background: #e4572e; }

.sm__ear { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.sm__listen {
  position: relative; width: clamp(120px, 20vw, 150px); aspect-ratio: 1; border-radius: 50%;
  border: 0; cursor: pointer; display: grid; place-content: center; justify-items: center; gap: 0.2rem;
  background: radial-gradient(circle at 35% 30%, #ffd27a, #f6a623 60%, #d9830f);
  color: #1f2d33; box-shadow: 0 6px 0 #a8650b, 0 16px 34px rgb(0 0 0 / 0.5);
}
.sm__listen:active { translate: 0 4px; box-shadow: 0 2px 0 #a8650b, 0 10px 20px rgb(0 0 0 / 0.4); }
.sm__icon { width: 44%; height: auto; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sm__label { font: 700 1rem/1 var(--display); }
.sm__listen.is-stuck .sm__label { font-size: 0.8rem; max-width: 7em; }
/* Rings that spread while the call plays, and a gentle pulse before. */
.sm__rings, .sm__rings i { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.sm__rings i { border: 3px solid #ffd27a; opacity: 0; }
.sm__listen:not(.is-playing):not(.is-stuck) { animation: sm-breathe 2s ease-in-out infinite; }
@keyframes sm-breathe { 50% { scale: 1.05; } }
.sm__listen.is-playing .sm__rings i { animation: sm-ring 1.6s ease-out infinite; }
.sm__listen.is-playing .sm__rings i:nth-child(2) { animation-delay: 0.53s; }
.sm__listen.is-playing .sm__rings i:nth-child(3) { animation-delay: 1.06s; }
@keyframes sm-ring { from { scale: 1; opacity: 0.9; } to { scale: 1.9; opacity: 0; } }

.sm__bars { display: flex; align-items: center; gap: 4px; height: 44px; }
.sm__bars i {
  width: 6px; height: 100%; border-radius: 99px; background: #ffd27a;
  scale: 1 0.12; transition: scale 0.08s linear;
  box-shadow: 0 0 8px rgb(255 210 122 / 0.5);
}

.sm__ask { font: 700 clamp(1.2rem, 2.8vw, 1.6rem)/1.2 var(--display); text-shadow: 0 2px 8px rgb(0 0 0 / 0.6); }

/* The owls: stickers on frosted glass, with their names. */
.sm__cards {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(0.6rem, 1.6vw, 1.1rem);
  width: min(100%, 860px); margin: 0; padding: 0; list-style: none;
}
.sm-card {
  position: relative; width: 100%; height: 100%; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  padding: 0.8rem 0.5rem 0.7rem; border-radius: 20px;
  border: 2px solid rgb(255 255 255 / 0.35);
  background: rgb(255 244 220 / 0.14);
  -webkit-backdrop-filter: blur(10px) saturate(1.2); backdrop-filter: blur(10px) saturate(1.2);
  box-shadow: 0 10px 24px rgb(0 0 0 / 0.3), inset 0 0 30px rgb(255 255 255 / 0.06);
  color: #fff; font: inherit;
  transition: translate 0.2s ease, border-color 0.2s ease, opacity 0.4s ease, filter 0.4s ease;
  animation: sm-card-in 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.sm__cards li:nth-child(2) .sm-card { animation-delay: 0.07s; }
.sm__cards li:nth-child(3) .sm-card { animation-delay: 0.14s; }
.sm__cards li:nth-child(4) .sm-card { animation-delay: 0.21s; }
@keyframes sm-card-in { from { scale: 0.8; opacity: 0; } }
.sm-card:hover:not(:disabled) { translate: 0 -5px; border-color: #ffd27a; }
.sm-card:hover:not(:disabled) .sm-card__st img { rotate: -3deg; }
.sm-card:focus-visible { outline: 3px solid #ffd27a; outline-offset: 3px; }
.sm-card__st { --h: clamp(130px, 19vw, 190px); display: grid; place-items: end center; height: var(--h); max-width: 100%; }
.sm-card__st img {
  height: calc(var(--h) * var(--s, 1)); width: auto; scale: var(--f, 1) 1; max-width: 100%; object-fit: contain;
  filter: drop-shadow(0 8px 10px rgb(0 0 0 / 0.4));
  transition: rotate 0.25s ease;
}
.sm-card__name {
  padding: 0.3rem 0.75rem; border-radius: 99px;
  background: #fffaf0; color: #1f2d33;
  font: 700 clamp(0.85rem, 1.6vw, 1rem)/1.15 var(--display);
}
.sm-card:disabled { cursor: default; }
.sm-card.is-right {
  border-color: #3fc1a9; background: rgb(63 193 169 / 0.28);
  box-shadow: 0 0 0 4px rgb(63 193 169 / 0.5), 0 0 40px rgb(63 193 169 / 0.6);
  animation: sm-hop 0.7s ease;
}
.sm-card.is-right .sm-card__name { background: #3fc1a9; color: #fff; }
.sm-card.is-right .sm-card__name::before { content: "✓ "; }
@keyframes sm-hop { 30% { translate: 0 -14px; scale: 1.06; } 60% { translate: 0 0; } }
.sm-card.is-wrong { animation: sm-shake 0.45s ease; border-color: #e4572e; opacity: 0.7; }
.sm-card.is-wrong .sm-card__st img { filter: grayscale(0.7) drop-shadow(0 8px 10px rgb(0 0 0 / 0.4)); }
@keyframes sm-shake { 20% { translate: -8px 0; rotate: -2deg; } 50% { translate: 8px 0; rotate: 2deg; } 80% { translate: -4px 0; } }
.sm-card.is-out { opacity: 0.4; filter: grayscale(0.6); }

/* What to listen for: the lesson, after every answer. */
.sm__said {
  position: relative; width: min(100%, 680px);
  padding: 1rem 1.2rem 1.1rem; border-radius: 20px;
  background: #fffaf0; color: #1f2d33; text-align: left;
  box-shadow: 0 12px 28px rgb(0 0 0 / 0.4);
  display: grid; gap: 0.45rem; justify-items: start;
  animation: sm-in 0.4s ease both;
}
.sm__said.is-right { border-top: 6px solid #3fc1a9; }
.sm__said.is-wrong { border-top: 6px solid #f6a623; }
.sm__verdict { font: 600 clamp(1.15rem, 2.6vw, 1.45rem)/1.25 var(--display); }
.sm__tell, .sm__home { font: 400 clamp(1rem, 2vw, 1.15rem)/1.4 var(--read); }
.sm__tell b, .sm__home b { font-family: var(--display); font-weight: 600; color: #155f56; }
.sm__fun { font: 400 clamp(1rem, 2vw, 1.15rem)/1.4 var(--read); }
.sm__fun b { font-family: var(--display); font-weight: 600; color: #c97a06; }
.sm__credit { font: 400 0.8rem/1.3 var(--read); color: #5d6b70; }
.sm__thanks { max-width: 36em; font: 400 0.85rem/1.35 var(--read); color: #dfe8ef; text-shadow: 0 1px 4px rgb(0 0 0 / 0.7); }
.sm__thanks a { color: #ffd27a; }

/* An owl still waiting for its sticker: an outline in the same white edge. */
.sm-ph {
  height: 100%; width: auto; max-width: 100%;
  fill: rgb(255 255 255 / 0.16); stroke: #fff; stroke-width: 4; stroke-linejoin: round;
  filter: drop-shadow(0 6px 8px rgb(0 0 0 / 0.35));
}
.sm-ph circle { fill: rgb(255 255 255 / 0.5); stroke: none; }
.sm-ph path:last-child { fill: none; stroke-width: 5; stroke-linecap: round; }
.sm-card__st .sm-ph { height: var(--h); }
.sm__shelf .sm-ph { height: 120px; }
.sm__shelf .is-missed .sm-ph { opacity: 0.45; }
.sm__credit a { color: inherit; }
.sm__said .sm__go { justify-self: end; margin-top: 0.3rem; font-size: 1.1rem; }

/* --- The end: the owls you met ---------------------------------------- */
.sm__screen--end { justify-content: center; min-height: 560px; }
.sm__score {
  font: 700 clamp(3rem, 9vw, 5rem)/1 var(--display); color: #f6a623;
  text-shadow: 0 4px 0 #8a4b0f, 0 10px 24px rgb(0 0 0 / 0.5);
}
.sm__score span { font-size: 0.45em; color: #fff; text-shadow: 0 2px 8px rgb(0 0 0 / 0.6); }
.sm__shelf {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem 0.6rem;
  margin: 0.4rem 0; padding: 0; list-style: none;
}
.sm__shelf li { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 0.35rem; width: 84px; }
.sm__shelf img { height: calc(120px * var(--s, 1)); width: auto; scale: var(--f, 1) 1; filter: drop-shadow(0 6px 8px rgb(0 0 0 / 0.45)); animation: sm-card-in 0.5s ease both; }
.sm__shelf span { font: 600 0.78rem/1.15 var(--display); text-shadow: 0 1px 4px rgb(0 0 0 / 0.8); }
.sm__shelf .is-right span { color: #7fe3cf; }
.sm__shelf .is-missed img { filter: grayscale(1) brightness(0.8) drop-shadow(0 6px 8px rgb(0 0 0 / 0.45)); opacity: 0.75; }

/* --- Timmy -----------------------------------------------------------------
   On the start and end screens he stands in the middle with a big speech
   bubble. In a round he flies beside the Listen button and talks to his
   right, away from the button and the cards. */
.timmy--sm .timmy__bubble { font-family: var(--display); font-weight: 600; }
.sm__timmy--inline { width: min(100%, 640px); }
.sm__timmy--inline .timmy--sm { display: flex; align-items: center; gap: 1.1rem; }
.sm__timmy--inline .timmy__body { flex: none; width: clamp(92px, 15vw, 130px); }
.sm__timmy--inline .timmy__bubble {
  position: relative; left: auto; top: auto; flex: 1 1 auto;
  width: auto; max-width: none; padding: 0.8rem 1.1rem; border-radius: 20px;
  font-size: clamp(1rem, 2.2vw, 1.2rem); line-height: 1.35;
}
.sm__timmy--inline .timmy__bubble::after { top: 50%; translate: 0 -50%; }

.sm__ear { position: relative; }
.sm__timmy--round {
  position: absolute; z-index: 4; top: -0.4rem;
  left: calc(50% + clamp(78px, 11vw, 100px));
  width: clamp(92px, 12vw, 124px);
}
.sm__timmy--round .timmy__bubble { left: 92%; top: 6%; max-width: min(250px, 26vw); }

@media (max-width: 640px) {
  .sm__timmy--inline .timmy--sm { gap: 0.7rem; }
  .sm__timmy--inline .timmy__body { width: 78px; }
  .sm__timmy--round { left: calc(50% + 62px); width: 70px; top: 0; }
  /* No room to his right on a phone, and the Listen button must stay clear:
     the bubble goes under the sound bars, over the "Who is calling?" line. */
  .sm__ear { padding-bottom: 0.2rem; }
  .sm__timmy--round .timmy__bubble {
    left: auto; right: -0.4rem; top: 168px; max-width: min(290px, 78vw); font-size: 0.9rem;
  }
  .sm__timmy--round .timmy__bubble::after { display: none; }
}

/* Confetti for a right answer. */
.sm-bit {
  position: absolute; z-index: 5; top: -12px; left: var(--x); width: 10px; height: 14px;
  background: var(--c); border-radius: 2px; pointer-events: none;
  animation: sm-fall 2.2s ease-in var(--d) both;
}
@keyframes sm-fall { to { transform: translateY(800px) rotate(var(--r)); opacity: 0.2; } }

/* --- Full screen ------------------------------------------------------- */
.lab--sm.is-full { background: #0d1730; }
.lab--sm.is-full .sm { min-height: 100%; height: 100%; border-radius: 0; overflow-y: auto; }
.lab--sm.is-full .sm__screen { min-height: 100%; justify-content: safe center; }

/* --- Phones ---------------------------------------------------------------- */
@media (max-width: 640px) {
  .sm, .sm__screen--open, .sm__screen--end { min-height: 480px; }
  .sm__cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm-card__st { --h: 120px; }
  .sm__top { padding-inline: 3.2rem 0.5rem; justify-content: flex-start; padding-top: 3rem; }
  .sm__shelf li { width: 84px; }
  .sm__shelf img { height: calc(96px * var(--s, 1)); }
}

@media (prefers-reduced-motion: reduce) {
  .sm *, .sm__screen { animation: none !important; transition: none !important; }
}
