/*
 * Sprint (Daily Challenge) — dark makeover (2026-05-27).
 *
 * Aesthetic mirrors the new KouLi home shell and the Confidence Coach
 * page: dark gradient backdrop, faint grid wash, calm typography,
 * frosted-glass surfaces. The hero AI visual uses the same
 * bottom-origin voice mist as KouLi Coach / Confidence Coach, replacing
 * the legacy concentric pulse rings + breathing circles.
 *
 * All existing element IDs that main.js targets are preserved:
 *   #daily-challenge-page
 *   #daily-challenge-name, #daily-challenge-description
 *   #daily-challenge-status
 *   #daily-challenge-content
 *   #daily-challenge-word-pills, #daily-challenge-word-pills-container
 *   #daily-challenge-suggestions, #daily-challenge-suggestion-pills
 *   #daily-challenge-transcription-box, #daily-challenge-transcription-content
 *   #daily-challenge-pulse-animation, #daily-challenge-breathing-animation
 *     (kept as invisible stubs so main.js's switchTo* toggles continue
 *      to work without modification)
 */

html:has(body.daily-challenge-active) {
  background-color: #050507;
}

body.daily-challenge-active {
  background:
    radial-gradient(circle at 50% 28%, rgba(122, 153, 171, 0.3), rgba(74, 93, 110, 0.14) 30%, transparent 52%),
    linear-gradient(180deg, #08080c 0%, #060609 44%, #040407 100%);
  background-color: #050507;
  color: #fff;
}

body.daily-challenge-active #app-header {
  display: none;
}

body.daily-challenge-active #daily-challenge-page {
  padding: 0;
  min-height: calc(100vh - 78px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 14%);
  color: #fff;
}

/* While the redesigned shell is on screen, hide the legacy profile-header
   wrapper (h1, headphones-notice, info card sub-tree) so only the new
   dc-shell renders. */
body.daily-challenge-active #daily-challenge-page > :not(.dc-shell) {
  display: none !important;
}

/* ── Outer shell ────────────────────────────────────────────────────── */

.dc-shell {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 18px 96px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: #fff;
}

.dc-shell::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.32;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 72%);
}

/* ── Header ─────────────────────────────────────────────────────────── */

.dc-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
}

.dc-wordmark {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 0 22px rgba(255, 255, 255, 0.12);
}

.dc-topbar-back {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  flex: 0 0 auto;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.dc-topbar-back:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
}

.dc-shell .dc-header {
  text-align: left;
  margin-top: 6px;
}

.dc-shell .dc-eyebrow {
  margin: 0 0 8px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(122, 153, 171, 0.92);
}

/* The legacy inline-<style> rules define `.challenge-name` and
   `.challenge-description` with light-mode colours (var(--foreground) /
   var(--muted-foreground)) and equal class-only specificity. We bump
   our specificity to (.dc-shell .dc-title etc.) so the dark colours
   win regardless of CSS source order. */
.dc-shell .dc-title {
  margin: 0;
  font-size: clamp(1.9rem, 7.2vw, 2.6rem);
  line-height: 1.06;
  letter-spacing: -0.04em;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.96);
}

.dc-shell .dc-title:empty::before {
  content: 'Today\2019s challenge';
  color: rgba(255, 255, 255, 0.72);
}

.dc-shell .dc-subtitle {
  margin: 10px 0 0;
  font-size: 0.98rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.7);
  max-width: 38ch;
}

.dc-shell .dc-subtitle:empty {
  display: none;
}

/* ── Voice mist stage (bottom-origin, matches KouLi Coach + Confidence Coach) ── */

.dc-mist-stage {
  position: relative;
  width: min(100%, 440px);
  height: clamp(260px, 44vh, 380px);
  margin: 4px auto -4px;
  isolation: isolate;
}

.dc-mist-stage .daily-challenge-animation {
  position: absolute;
  inset: 0;
  height: auto;
  min-height: 0;
  margin: 0;
  display: block;
  --voice-energy: 0.12;
}

.dc-mist-stage .kouli-coach-stage {
  width: 100%;
  min-height: 100%;
}

/* Legacy pulse/breathing stubs — main.js still toggles .hidden on these
   IDs when challenge state changes. They render nothing in the new shell. */
.dc-mist-stage .pulse-animation,
.dc-mist-stage .breathing-animation {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.dc-mist-stage .pulse-animation > *,
.dc-mist-stage .breathing-animation > * {
  display: none !important;
}

/* ── Status pill inside the mist ────────────────────────────────────── */

.dc-mist-stage .challenge-status {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: 18px;
  background: rgba(8, 8, 18, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.92);
  text-align: center;
  max-width: 80%;
}

.dc-mist-stage .challenge-status p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.86);
}

.dc-mist-stage .challenge-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  margin: 0 auto;
  animation: dc-spin 0.9s linear infinite;
}

@keyframes dc-spin {
  to { transform: rotate(360deg); }
}

/* ── Challenge content (pills) ──────────────────────────────────────── */

.dc-shell .challenge-content {
  margin-top: 0;
}

.dc-shell .challenge-word-pills,
.dc-shell .challenge-suggestions {
  margin: 0;
  padding: 14px 14px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
}

.dc-shell .challenge-word-pills.hidden,
.dc-shell .challenge-suggestions.hidden {
  display: none;
}

.dc-shell .suggestions-header {
  margin: 0 0 8px;
  text-align: left;
}

/* Legacy inline-<style> rules `.challenge-word-pills .suggestions-label`
   and `.challenge-suggestions .suggestions-label` both have (0,2,0)
   specificity AND load after this file, so our previous `.dc-shell
   .suggestions-label` (0,2,0) was being beaten on tie-break by source
   order — the dynamic label ("Forbidden letter(s):", "Nonsense
   sentence:", "Compliment this:", etc.) kept rendering in the legacy
   dark blue (--foreground). Bumping our selectors to (0,3,0) so they
   win on specificity regardless of source order. */
.dc-shell .challenge-word-pills .suggestions-label,
.dc-shell .challenge-suggestions .suggestions-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-start;
}

.dc-shell .suggestion-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

/* Override the loud legacy purple gradient pill style for suggestion pills
   inside the new shell — match the calm frosted-glass look used by
   Confidence Coach. Word pills (Bridge Builder) keep a slightly stronger
   accent so the player can spot them at a glance. */
.dc-shell .suggestion-pill {
  background: rgba(74, 93, 110, 0.24);
  color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(122, 153, 171, 0.3);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.005em;
  cursor: default;
  max-width: 100%;
  white-space: normal;
  text-align: left;
  line-height: 1.3;
  box-shadow: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.dc-shell #daily-challenge-word-pills-container .suggestion-pill {
  background: linear-gradient(
    180deg,
    rgba(74, 93, 110, 0.42) 0%,
    rgba(46, 64, 79, 0.42) 100%
  );
  border-color: rgba(122, 153, 171, 0.4);
  color: rgba(255, 255, 255, 0.96);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Transcription box ──────────────────────────────────────────────── */

.dc-shell .challenge-transcription-box {
  margin: 0;
  padding: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.dc-shell .challenge-transcription-box.hidden {
  display: none;
}

.dc-shell .challenge-transcription-box.visible {
  opacity: 1;
  transform: translateY(0);
}

.dc-shell .challenge-transcription-box .transcription-header {
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dc-shell .challenge-transcription-box .transcription-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
}

.dc-shell .challenge-transcription-box .transcription-content {
  font-size: 0.92rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.86);
  height: 260px;
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 12px;
  background: rgba(4, 4, 10, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.dc-shell .challenge-transcription-box .transcription-content::-webkit-scrollbar {
  width: 6px;
}

.dc-shell .challenge-transcription-box .transcription-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 6px;
}

/* Adjust the legacy annotated-transcript word styles to read on dark. */
.dc-shell .transcript-word {
  padding: 1px 4px;
  border-radius: 4px;
}

.dc-shell .transcript-word.challenge-word-1 {
  background: rgba(167, 139, 250, 0.22);
  color: #d8c8ff;
}

.dc-shell .transcript-word.challenge-word-2 {
  background: rgba(96, 165, 250, 0.22);
  color: #bfdbfe;
}

.dc-shell .transcript-word.transition-word {
  background: rgba(45, 212, 191, 0.18);
  color: #99f6e4;
}

.dc-shell .transcript-word.banned-word,
.dc-shell .transcript-word.filler-word,
.dc-shell .transcript-word.adjective-word,
.dc-shell .transcript-word.forbidden-letter {
  background: rgba(248, 113, 113, 0.2);
  color: #fecaca;
}

/* ── Meta / headphones tip ──────────────────────────────────────────── */

.dc-meta {
  margin: 12px 0 0;
  font-size: 0.98rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.72);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px 14px;
}

/* ── Mobile tightening ──────────────────────────────────────────────── */

@media (max-width: 380px) {
  .dc-shell {
    gap: 14px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .dc-mist-stage {
    height: 230px;
  }

  .dc-title {
    font-size: 1.7rem;
  }

  .dc-shell .challenge-transcription-box .transcription-content {
    height: 220px;
    max-height: 220px;
    font-size: 0.86rem;
  }
}

@media (min-width: 760px) {
  .dc-shell {
    padding-top: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dc-shell .challenge-transcription-box {
    transition: none !important;
  }

  .dc-mist-stage .challenge-spinner {
    animation: none !important;
  }
}

/* ====================================================================== */
/* Quick Reps — games list page                                           */
/* Reuses the dark Quick Reps backdrop. Grey/blue canvas throughout; the  */
/* only "lift" is a transient teal-tinted border on the hovered/focused   */
/* card (one at a time, like a focus ring), per the KouLi colour contract.*/
/* ====================================================================== */

html:has(body.quick-reps-list-active) {
  background-color: #050507;
}

body.quick-reps-list-active {
  background:
    radial-gradient(circle at 50% 28%, rgba(122, 153, 171, 0.3), rgba(74, 93, 110, 0.14) 30%, transparent 52%),
    linear-gradient(180deg, #08080c 0%, #060609 44%, #040407 100%);
  background-color: #050507;
  color: #fff;
}

body.quick-reps-list-active #app-header {
  display: none;
}

.qr-list-shell {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 18px 110px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: #fff;
}

.qr-list-header {
  text-align: left;
  margin-top: 6px;
}

.qr-list-title {
  margin: 8px 0 0;
  font-size: clamp(1.7rem, 6.4vw, 2.3rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.96);
}

.qr-list-subtitle {
  margin: 8px 0 0;
  font-size: 0.96rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.62);
  max-width: 40ch;
}

/* Grouped single-column list. Full-width rows, comfortable thumb targets,
   one-line descriptions. Neutral grey/blue canvas; the only accent is the
   hairline + chevron that lift teal on the hovered/focused row (one at a
   time, like a focus ring) per the KouLi colour contract. */
.qr-game-list {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: 2px;
}

.qr-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qr-group-label {
  margin: 0 0 1px 2px;
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.46);
}

/* The rows in a group share one rounded "card" with hairline dividers,
   the way native mobile settings lists group related items. */
.qr-rows {
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018));
  overflow: hidden;
}

.qr-row {
  appearance: none;
  -webkit-appearance: none;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  padding: 12px 14px;
  background: transparent;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  color: #fff;
  transition: background-color 0.16s ease;
}

.qr-row:first-child {
  border-top: 0;
}

.qr-row:hover,
.qr-row:focus-visible {
  background: rgba(0, 229, 192, 0.07);
  outline: none;
}

.qr-row:active {
  background: rgba(0, 229, 192, 0.11);
}

.qr-row-text {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.qr-row-name {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.95);
}

.qr-row-desc {
  font-size: 0.82rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.56);
  /* Keep it to a single line so rows stay tidy; ellipsis when it overflows. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qr-row-chev {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.34);
  transition: color 0.16s ease, transform 0.16s ease;
}

.qr-row:hover .qr-row-chev,
.qr-row:focus-visible .qr-row-chev {
  color: rgba(0, 229, 192, 0.9);
  transform: translateX(2px);
}

@media (max-width: 380px) {
  .qr-list-shell {
    padding-left: 14px;
    padding-right: 14px;
  }
  .qr-game-list {
    gap: 18px;
  }
  .qr-row {
    min-height: 58px;
    padding: 11px 13px;
  }
}

@media (min-width: 760px) {
  .qr-list-shell {
    padding-top: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .qr-row,
  .qr-row-chev {
    transition: none;
  }
  .qr-row:hover .qr-row-chev,
  .qr-row:focus-visible .qr-row-chev {
    transform: none;
  }
}

/* ── Per-game footer actions (Back to games / Try again) ─────────────── */

.dc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.dc-actions .dc-action-btn {
  appearance: none;
  -webkit-appearance: none;
  flex: 1 1 0;
  min-width: 120px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 12px 16px;
  border-radius: 14px;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.dc-actions .dc-action-btn:hover,
.dc-actions .dc-action-btn:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.24);
  outline: none;
}
