/* =========================================================
   Learning Rewired Lab — The Lab · Challenges
   File: /the-lab/app/assets/css/challenges.css
   Personal, non-competitive Challenges. Pairs with challenges.js.
   ========================================================= */

.ch-content { max-width: none; margin: 0; padding: 0; }

/* This page reuses The Bench's .tb-layout/.tb-rail grid shell but does
   not load the-bench.css — define the structural bits it needs here. */
.ch-content.tb-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 320px);
  gap: 24px;
  align-items: start;
}
.ch-content .tb-rail { display: grid; gap: 16px; }
@media (max-width: 1180px) {
  .ch-content.tb-layout { grid-template-columns: 1fr; }
}

/* Space between the library grid and the history card below it */
#ch-library-section { margin-bottom: 20px; }

/* Rail cards on this page reuse the shared .tb-rail/.lab-card shell —
   give them the same breathing room as The Bench's rail. */
.tb-rail .lab-card { padding: 20px; }
.tb-rail .lab-card h4 { line-height: 1.25; }
.tb-rail .lab-card p { line-height: 1.55; }

/* "Your history" card: same shell, needs its own padding since it's not
   inside .tb-rail. */
.ch-content > div > section.lab-card { padding: 22px 24px 10px; }

/* How Challenges work — numbered steps */
.ch-steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.ch-steps li { display: flex; align-items: flex-start; gap: 10px; font-size: 12.5px; line-height: 1.5; color: #5b6b78; }
.ch-steps .ch-step-n {
  flex: none; width: 20px; height: 20px; border-radius: 7px; display: grid; place-items: center;
  font-size: 11px; font-weight: 900; color: #4338ca; background: rgba(67,56,202,.1);
  margin-top: 1px;
}

/* ---------------------------------------------------------
   HERO
   --------------------------------------------------------- */

.ch-hero {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  padding: 30px 34px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 22px;
  background:
    radial-gradient(120% 160% at 8% 0%, rgba(99, 91, 255, .14), transparent 55%),
    radial-gradient(100% 120% at 100% 100%, rgba(20, 184, 166, .08), transparent 50%),
    #ffffff;
  border: 1px solid rgba(79, 70, 229, .2);
  box-shadow: 0 16px 38px rgba(15, 23, 42, .06);
}

.ch-hero__ic {
  width: 76px;
  height: 76px;
  border-radius: 20px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 32px;
  color: #fff;
  background: linear-gradient(150deg, #7048e8, #4338ca);
  box-shadow: 0 14px 28px rgba(67, 56, 202, .28);
  position: relative;
  transform-origin: center;
  animation: chIconBreathe 3.6s ease-in-out infinite;
  transition: transform .35s cubic-bezier(.34,1.56,.64,1);
}
.ch-hero__ic::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 26px;
  background: radial-gradient(circle, rgba(112,72,232,.35), transparent 70%);
  opacity: 0;
  animation: chIconGlow 3.6s ease-in-out infinite;
  z-index: -1;
}
.ch-hero:hover .ch-hero__ic { transform: rotate(-8deg) scale(1.08); }

@keyframes chIconBreathe {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.05) rotate(3deg); }
}
@keyframes chIconGlow {
  0%, 100% { opacity: .25; }
  50% { opacity: .55; }
}
@media (prefers-reduced-motion: reduce) {
  .ch-hero__ic, .ch-hero__ic::after { animation: none; }
}

.ch-hero__eyebrow { font-size: 10px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; color: #4338ca; margin-top: 4px; }
.ch-hero__title { font-weight: 900; font-size: 26px; letter-spacing: -.03em; color: #07111f; margin: 4px 0 0; }
.ch-hero__lede { font-size: 13.5px; color: #5b6b78; margin: 6px 0 0; max-width: 620px; line-height: 1.5; }

.ch-hero__points {
  margin-left: auto;
  flex: none;
  position: relative;
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
}
.ch-hero__points-ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}
.ch-hero__points-ring circle {
  fill: none;
  stroke-width: 6;
}
.ch-hero__points-ring .ch-ring-track { stroke: rgba(67,56,202,.1); }
.ch-hero__points-ring .ch-ring-fill {
  stroke: #6d3fe0;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.1s cubic-bezier(.22,1,.36,1);
}
.ch-hero__points-body { position: relative; text-align: center; }
.ch-hero__points-v { font-weight: 900; font-size: 22px; color: #4338ca; letter-spacing: -.02em; line-height: 1; }
.ch-hero__points-k { font-size: 9.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #6d63d6; margin-top: 3px; }

@media (max-width: 760px) {
  .ch-hero__points { margin-left: 0; }
}

@media (max-width: 760px) {
  .ch-hero { flex-wrap: wrap; }
}

/* ---------------------------------------------------------
   ACTIVE CHALLENGE CARD
   --------------------------------------------------------- */

.ch-active {
  border-radius: 22px;
  padding: 24px 26px;
  margin-bottom: 20px;
  background: linear-gradient(165deg, #f5f4ff, #fff);
  border: 1px solid rgba(67, 56, 202, .18);
  box-shadow: 0 16px 34px rgba(15, 23, 42, .05);
}

.ch-active__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.ch-active__badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase;
  color: #4338ca; background: rgba(67, 56, 202, .1); border: 1px solid rgba(67, 56, 202, .22);
  border-radius: 999px; padding: 5px 12px;
}
.ch-active__title { font-weight: 900; font-size: 19px; letter-spacing: -.02em; color: #07111f; margin: 8px 0 0; }
.ch-active__prompt { font-size: 13.5px; line-height: 1.6; color: #475569; margin: 10px 0 0; max-width: 640px; }

.ch-active__deadline { flex: none; text-align: right; }
.ch-active__deadline-v { font-weight: 900; font-size: 18px; color: #07111f; }
.ch-active__deadline-k { font-size: 11px; font-weight: 700; color: #64748b; margin-top: 2px; }
.ch-active__deadline.is-overdue .ch-active__deadline-v { color: #b91c1c; }

.ch-active__status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 800; color: #0f766e;
  background: rgba(20,184,166,.1); border: 1px solid rgba(20,184,166,.24);
  border-radius: 999px; padding: 5px 12px; margin-top: 14px;
}
.ch-active__status::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: #0f766e;
  animation: chPulseDot 1.6s ease-in-out infinite;
}
@keyframes chPulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(.7); }
}
@media (prefers-reduced-motion: reduce) {
  .ch-active__status::before { animation: none; }
}

.ch-active__form { margin-top: 18px; border-top: 1px solid rgba(67, 56, 202, .14); padding-top: 18px; }
.ch-active__form label { display: block; font-size: 11.5px; font-weight: 800; color: #374151; margin-bottom: 6px; }
.ch-active__form textarea,
.ch-active__form input[type="url"] {
  width: 100%; box-sizing: border-box; font-family: inherit; font-size: 13.5px; color: #07111f;
  border: 1px solid #e2e8f0; border-radius: 12px; padding: 11px 13px; resize: vertical;
}
.ch-active__form textarea { min-height: 90px; margin-bottom: 14px; }
.ch-active__form input[type="url"] { margin-bottom: 16px; }
.ch-active__form textarea:focus,
.ch-active__form input[type="url"]:focus { outline: none; border-color: #4338ca; box-shadow: 0 0 0 3px rgba(67,56,202,.12); }

.ch-active__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.ch-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-weight: 800; font-size: 13px; letter-spacing: -.01em;
  border-radius: 12px; padding: 11px 20px; border: none; cursor: pointer;
  text-decoration: none; transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.ch-btn--primary { color: #fff; background: linear-gradient(150deg, #7048e8, #4338ca); box-shadow: 0 10px 22px rgba(67,56,202,.28); }
.ch-btn--primary:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(67,56,202,.34); }
.ch-btn--ghost { color: #64748b; background: transparent; border: 1px solid #e2e8f0; }
.ch-btn--ghost:hover { color: #07111f; border-color: #cbd5e1; }
.ch-btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ---------------------------------------------------------
   GRADED RESULT (inline on the active card once graded)
   --------------------------------------------------------- */

.ch-graded { display: flex; align-items: center; gap: 16px; margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(67,56,202,.14); position: relative; overflow: visible; }
.ch-graded__score {
  flex: none; width: 58px; height: 58px; border-radius: 16px; display: grid; place-items: center;
  font-weight: 900; font-size: 19px; color: #fff;
  animation: chScorePop .55s cubic-bezier(.34,1.56,.64,1);
}
.ch-graded__score.is-pass { background: linear-gradient(150deg, #34d399, #0f766e); }
.ch-graded__score.is-retry { background: linear-gradient(150deg, #fbbf24, #d97706); }
.ch-graded__body { min-width: 0; }
.ch-graded__title { font-weight: 800; font-size: 13.5px; color: #07111f; margin: 0 0 4px; }
.ch-graded__feedback { font-size: 12.5px; line-height: 1.55; color: #475569; margin: 0; }

@keyframes chScorePop {
  0% { transform: scale(.2); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

.ch-confetti {
  position: absolute;
  left: 29px;
  top: -4px;
  width: 0; height: 0;
  pointer-events: none;
}
.ch-confetti i {
  position: absolute;
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--c, #7048e8);
  animation: chConfettiBurst .9s cubic-bezier(.15,.8,.4,1) forwards;
  animation-delay: var(--d, 0s);
}
@keyframes chConfettiBurst {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--x, 30px), var(--y, -40px)) rotate(var(--r, 180deg)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ch-graded__score { animation: none; }
  .ch-confetti { display: none; }
}

/* ---------------------------------------------------------
   LIBRARY (pick a challenge to start)
   --------------------------------------------------------- */

.ch-library__label { font-size: 11px; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; color: #94a3b8; margin: 0 0 12px; }

.ch-library {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
@media (max-width: 760px) { .ch-library { grid-template-columns: 1fr; } }

.ch-card {
  border-radius: 18px;
  padding: 18px 20px;
  background: #fff;
  border: 1px solid #e9edf1;
  box-shadow: 0 10px 24px rgba(15,23,42,.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform .3s cubic-bezier(.22,1,.36,1), box-shadow .3s ease, border-color .3s ease;
}
.ch-card:hover {
  transform: translateY(-4px);
  border-color: rgba(112,72,232,.28);
  box-shadow: 0 18px 34px rgba(67,56,202,.14);
}
.ch-card:hover .ch-card__meta span:first-child { animation: chTick .5s ease; }
@keyframes chTick {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}
@media (prefers-reduced-motion: reduce) {
  .ch-card, .ch-card:hover { transition: none; transform: none; }
  .ch-card:hover .ch-card__meta span:first-child { animation: none; }
}
.ch-card__title { font-weight: 850; font-size: 14.5px; color: #07111f; letter-spacing: -.01em; }
.ch-card__prompt { font-size: 12.5px; line-height: 1.55; color: #64748b; flex: 1; }
.ch-card__meta { display: flex; align-items: center; gap: 10px; font-size: 11.5px; font-weight: 700; color: #6d63d6; }
.ch-card__meta span { display: inline-flex; align-items: center; gap: 4px; }
.ch-card .ch-btn { align-self: flex-start; padding: 9px 16px; font-size: 12.5px; }

/* ---------------------------------------------------------
   HISTORY
   --------------------------------------------------------- */

.ch-history-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 14px; border: 1px solid #edf1f4;
  margin-bottom: 10px;
}
.ch-history-row:last-child { margin-bottom: 0; }
.ch-history-row__score {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 900; font-size: 14px; color: #fff;
}
.ch-history-row__score.is-pass { background: linear-gradient(150deg, #34d399, #0f766e); }
.ch-history-row__score.is-retry { background: linear-gradient(150deg, #fbbf24, #d97706); }
.ch-history-row__score.is-pending { background: #e2e8f0; color: #64748b; }
.ch-history-row__body { min-width: 0; flex: 1; }
.ch-history-row__title { font-weight: 750; font-size: 13px; color: #07111f; margin: 0 0 2px; }
.ch-history-row__meta { font-size: 11.5px; color: #94a3b8; font-weight: 600; }

.ch-empty { padding: 20px; text-align: center; color: #94a3b8; font-size: 12.5px; font-weight: 600; }

/* ---------------------------------------------------------
   RIGHT RAIL
   --------------------------------------------------------- */

.ch-rail-badge {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: 14px; background: rgba(67,56,202,.06); border: 1px solid rgba(67,56,202,.16);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s ease;
}
.ch-rail-badge.is-locked { background: #f8fafc; border-color: #edf1f4; opacity: .68; }
.ch-rail-badge.is-locked .ch-rail-badge__ic { background: #e2e8f0; color: #94a3b8; }
.ch-rail-badge:not(.is-locked):hover { transform: translateX(2px); box-shadow: 0 8px 18px rgba(67,56,202,.14); }
.ch-rail-badge.just-earned { animation: chBadgeUnlock .6s cubic-bezier(.34,1.56,.64,1); }
@keyframes chBadgeUnlock {
  0% { transform: scale(.85); box-shadow: 0 0 0 0 rgba(112,72,232,.5); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); box-shadow: 0 0 0 12px rgba(112,72,232,0); }
}
.ch-rail-badge__ic { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; color: #fff; background: linear-gradient(150deg, #7048e8, #4338ca); transition: transform .2s ease; }
@media (prefers-reduced-motion: reduce) {
  .ch-rail-badge, .ch-rail-badge__ic { transition: none; }
  .ch-rail-badge.just-earned { animation: none; }
}
.ch-rail-badge__t { font-weight: 800; font-size: 13px; color: #07111f; }
.ch-rail-badge__s { font-size: 11.5px; color: #6d63d6; font-weight: 600; }
.ch-rail-badge.is-locked .ch-rail-badge__s { color: #94a3b8; }
.ch-rail-badge__earned { color: #0f766e; font-weight: 800; font-size: 10.5px; text-transform: uppercase; letter-spacing: .02em; }
