/* Koda: course path, course switcher, and mascot personality. Loaded after style.css; uses its :root tokens. */

/* ================= Course path layout & header ================= */
.page.learn {
  --sway-step: clamp(3rem, 12vw, 5rem);
  max-width: 38rem !important;
  padding-bottom: 6.5rem;
}

.page.learn .map-layout {
  display: grid;
  gap: 0;
  min-width: 0;
}

.page.learn .map-aside,
.page.learn .map-units {
  min-width: 0;
}

.page.learn .map-aside .quests {
  max-width: none;
}

@media (min-width: 1200px) {
  .page.learn {
    max-width: 64rem !important;
  }

  .page.learn .map-layout {
    grid-template-columns: minmax(0, 37rem) minmax(15rem, 20rem);
    grid-template-areas: "head aside" "units aside";
    justify-content: center;
    column-gap: 2rem;
  }

  .page.learn .map-head { grid-area: head; }
  .page.learn .map-units { grid-area: units; }
  .page.learn .map-aside {
    grid-area: aside;
    align-self: start;
    position: sticky;
    top: 1rem;
  }
}

.page.learn .map-head {
  display: grid;
  gap: 0.75rem;
  max-width: none !important;
  padding: 8px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  margin-bottom: 0.5rem;
}

.page.learn .map-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
}

.page.learn .map-title-row h1 {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: clamp(1.35rem, 4.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.page.learn .map-title-row h1 .ico {
  margin-right: 0;
  width: 1.35em;
  height: 1.35em;
}

.page.learn .map-stat {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border: 1px solid #BFDBFE;
  border-radius: 99px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.page.learn .map-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page.learn .map-progress .progress-bar {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: var(--sunken);
  overflow: hidden;
}

.page.learn .map-progress .progress-bar span {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.35s ease;
}

.page.learn .map-progress-label {
  flex: none;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.page.learn .map-head .says {
  margin: 0;
}

.page.learn .map-head .says .mascot { width: 3.5rem; }
.page.learn .map-head .speech {
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  font-weight: 700;
  box-shadow: none;
}

/* ================= Unit cards & structured headers ================= */
.page.learn .unit {
  margin-top: 1.25rem;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
  animation: none;
}

.page.learn .unit.unit-locked {
  background: transparent;
  box-shadow: none;
}

.page.learn .unit.unit-done {
  border-color: #A7F3D0;
}

.page.learn .unit-banner {
  display: block;
  position: relative;
  padding: 16px 20px;
  border: 0;
  border-radius: 18px;
  background: #1D5CE5;
  color: #FFFFFF;
  box-shadow: none;
  scroll-margin-top: 12px;
  animation: none;
}

.page.learn .unit-banner.open,
.page.learn .unit-banner.done {
  background: #17213C;
  color: #FFFFFF;
}

/* Koda's own touch: the unit is a roadside sign, a dark panel with a yellow dashed road line on top and a yellow number plate. */
.page.learn .unit-banner.open::before,
.page.learn .unit-banner.done::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 4px;
  background: repeating-linear-gradient(90deg, #FFD43B 0 14px, transparent 14px 24px);
}

.page.learn .unit-banner.open .label,
.page.learn .unit-banner.done .label {
  padding: 3px 12px;
  border-radius: 6px;
  outline: 2px solid #17213C;
  outline-offset: -4px;
  background: #FFD43B;
  color: #17213C;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
}

.page.learn .unit-banner.locked {
  padding: 15px 20px;
  border: 2px solid var(--line);
  background: #EDF2F8;
  color: var(--ink);
  box-shadow: none;
}

.page.learn .unit-banner.just-unlocked {
  animation: map-banner-unlock 0.36s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.page.learn .unit-banner-main {
  display: grid;
  gap: 0.3rem;
}

.page.learn .unit-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.page.learn .unit-banner .label {
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.page.learn .unit-banner.locked .label {
  color: var(--muted);
}

.page.learn .unit-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.65rem;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  font-size: 0.76rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.page.learn .unit-badge.is-done {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.34);
}

.page.learn .unit-badge.is-locked {
  background: #FFFFFF;
  color: var(--muted);
  border-color: var(--line-strong);
}

.page.learn .unit-badge .ico {
  width: 0.88rem;
  height: 0.88rem;
}

.page.learn .unit-banner h2 {
  margin: 0;
  color: #FFFFFF;
  font-size: 1.22rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.page.learn .unit-banner.locked h2 {
  color: var(--ink);
}

.page.learn .unit-banner p {
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.9rem;
  font-weight: 450;
  line-height: 1.45;
  opacity: 1;
}

.page.learn .unit-banner.locked p {
  color: var(--muted);
}

.page.learn .unit-lock-why {
  margin-top: 0.2rem !important;
  font-size: 0.82rem !important;
  font-weight: 600 !important;
  color: var(--muted);
}

.page.learn .unit-progress {
  height: 6px;
  margin-top: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.24);
  overflow: hidden;
}

.page.learn .unit-progress span {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: #FFFFFF;
  transition: width 0.35s ease;
}

/* ================= Learning path ================= */
.page.learn .ladder {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: 2rem 1rem 1.85rem;
  margin: 0;
  list-style: none;
  background: transparent;
}

.page.learn .unit-locked .ladder {
  background: transparent;
}

.page.learn .ladder::before {
  display: none;
}

.page.learn .road-svg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: visible;
  pointer-events: none;
}

.page.learn .road-svg path {
  fill: none;
  stroke-linecap: round;
}

.page.learn .road-track {
  stroke: #D5DCE8;
  stroke-width: 30;
}

.page.learn .road-lane {
  stroke: #FFFFFF;
  stroke-width: 3;
  stroke-dasharray: 10 12;
}

.page.learn .road-driven {
  stroke: #F5B301;
  stroke-width: 3;
  stroke-dasharray: 10 12;
}

.page.learn .road-car {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  width: 4rem;
  offset-distance: 100%;
  offset-rotate: 0deg;
  offset-anchor: 50% 50%;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(18, 27, 46, 0.14));
}

.page.learn .road-car .mascot {
  width: 100%;
}

.page.learn .has-road-car .rung-car {
  visibility: hidden;
}

@media (max-width: 420px) {
  .page.learn .road-car {
    width: 3.35rem;
  }
}

/* ================= Route stops, clean checkmarks & single focal highlight ================= */
.page.learn .rung {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  transform: translateX(calc(var(--sway, 0) * var(--sway-step)));
  animation: none;
}

.page.learn .rung.open {
  z-index: 8;
}

.page.learn .rung.project {
  margin-top: 0.35rem;
}

.page.learn button.node-link {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  width: auto;
  min-width: 8rem;
  max-width: 12.5rem;
  min-height: var(--tap);
  padding: 0.2rem;
  border: 0;
  border-radius: 16px;
  background: transparent;
  box-shadow: none;
  text-align: center;
  white-space: normal;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.page.learn button.node-link:hover {
  background: transparent;
  transform: translateY(-1px);
}

.page.learn button.node-link:active {
  transform: translateY(2px);
}

.page.learn button.node-link:focus-visible {
  outline: none;
}

.page.learn button.node-link:focus-visible .node-circle {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

/* Base skill medallion (available / non-current open) */
.page.learn .node-circle {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin: 0;
  border: 2px solid #2563EB;
  border-radius: 50%;
  background: #FFFFFF;
  color: #1D5CE5;
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: 0 5px 0 #BFDBFE;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.15s ease;
}

.page.learn .node-circle::after {
  display: none !important;
  animation: none !important;
}

.page.learn .node-circle::before {
  display: none;
  animation: none;
}

.page.learn .node-circle .ico {
  width: 1.55rem;
  height: 1.55rem;
  color: currentColor;
}

.page.learn button.node-link:hover .node-circle {
  filter: none;
  background: #EFF6FF;
}

.page.learn button.node-link:active .node-circle {
  transform: translateY(2px);
  box-shadow: none;
}

/* Current active stop */
.page.learn .rung.current .node-circle {
  width: 76px;
  height: 76px;
  margin: 0;
  border: 0;
  border-radius: 50%;
  background: #1D5CE5;
  color: #FFFFFF;
  box-shadow: 0 6px 0 #143EA8;
}

.page.learn .rung.current .node-circle::before {
  display: none;
}

.page.learn .rung.current button.node-link:focus-visible .node-circle {
  outline-offset: 11px;
}

.page.learn .rung.current .node-circle .ico {
  width: 1.75rem;
  height: 1.75rem;
  color: #FFFFFF;
}

.page.learn .rung.current button.node-link:hover .node-circle {
  background: #1548BD;
  box-shadow: 0 4px 0 #143EA8;
}

.page.learn .rung.current button.node-link:active .node-circle {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #143EA8;
}

/* Completed stop: calm mint badge with crisp emerald rim & precision checkmark */
.page.learn .rung.done .node-circle {
  width: 68px;
  height: 68px;
  border: 2px solid #059669;
  border-radius: 50%;
  background: #ECFDF5;
  color: #047857;
  box-shadow: 0 5px 0 #A7F3D0;
}

.page.learn .rung.done .node-circle .ico {
  width: 1.4rem;
  height: 1.4rem;
  color: #047857;
}

.page.learn .rung.done button.node-link:hover .node-circle {
  background: #D1FAE5;
}

.page.learn .rung.done button.node-link:active .node-circle {
  box-shadow: none;
}

/* Locked stop: understated slate outline badge */
.page.learn .rung.locked .node-circle {
  width: 64px;
  height: 64px;
  border: 1.5px solid #CBD5E1;
  border-radius: 50%;
  background: #E2E8F0;
  color: #526077;
  box-shadow: 0 5px 0 #CBD5E1;
}

.page.learn .rung.locked .node-circle .ico {
  width: 1.3rem;
  height: 1.3rem;
  color: #526077;
}

.page.learn .rung.locked button.node-link:hover {
  transform: none;
}

.page.learn .rung.locked button.node-link:hover .node-circle {
  background: #F1F5F9;
}

/* Unboxed clean typography masked cleanly over the thin route line */
.page.learn .node-name {
  display: inline-block;
  padding: 2px 8px;
  border: 0;
  border-radius: 6px;
  background: var(--bg);
  color: #1E293B;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0;
  box-shadow: none;
  overflow-wrap: anywhere;
}

.page.learn .unit-locked .node-name {
  background: var(--bg);
}

.page.learn .rung.current .node-name {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
}

.page.learn .rung.done .node-name {
  color: #1E293B;
  font-weight: 800;
}

.page.learn .rung.locked .node-name {
  color: #526077;
  font-weight: 700;
}

/* Sleek dark-ink pointer callout above the active stop */
.page.learn .start-flag {
  position: relative;
  margin: 0 0 12px;
  padding: 4px 11px;
  border: 0;
  border-radius: 8px;
  background: #121B2E;
  color: #FFFFFF;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: none;
  box-shadow: 0 3px 10px rgba(18, 27, 46, 0.16);
  animation: map-flag-in 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.page.learn .start-flag::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 8px;
  height: 8px;
  background: #121B2E;
  border: 0;
  transform: translateX(-50%) rotate(45deg);
}

/* Koda's Ekran car parked toward the inner side of the card so it never crowds phone edges */
.page.learn .rung-car {
  position: absolute;
  top: 24px;
  left: calc(50% + 54px);
  right: auto;
  width: 4rem;
  z-index: 4;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(18, 27, 46, 0.14));
}

.page.learn .rung[style*="--sway:0."] .rung-car {
  left: auto;
  right: calc(50% + 54px);
}

.page.learn .rung-car .mascot {
  width: 100%;
}

@media (max-width: 420px) {
  .page.learn .rung-car {
    left: calc(50% + 54px);
    width: 3.35rem;
    top: 26px;
  }

  .page.learn .rung[style*="--sway:0."] .rung-car {
    left: auto;
    right: calc(50% + 54px);
  }
}

/* Short unlock celebration for newly opened steps */
.page.learn .rung.just-unlocked .node-circle {
  animation: map-unlock-pop 0.36s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.page.learn .unlock-ring {
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid var(--accent);
  pointer-events: none;
  opacity: 0;
  animation: map-unlock-ring 0.42s ease-out both;
}

/* ================= Roadside Treasure Chests (crisp, never faded greyscale ghosts) ================= */
.page.learn .chest-rung .chest-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  padding: 0;
  border: 2px solid #D97706;
  border-radius: 50%;
  background: #FFFBEB;
  box-shadow: 0 3px 0 #F59E0B;
  opacity: 1 !important;
  filter: none !important;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.15s ease;
}

.page.learn .chest-rung:not(.opened) .ico {
  animation: none;
}

.page.learn .chest-rung .chest-button:hover:not(:disabled) {
  background: #FEF3C7;
  transform: translateY(-1px);
}

.page.learn .chest-rung .chest-button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #F59E0B;
}

.page.learn .chest-rung .chest-button:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.page.learn .chest-rung .chest-art {
  display: grid;
  place-items: center;
}

.page.learn .chest-rung .chest-art .ico {
  width: 1.7rem;
  height: 1.7rem;
}

.page.learn .chest-rung .chest-pill {
  position: absolute;
  top: -8px;
  right: -10px;
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  min-height: 22px;
  padding: 1px 6px;
  border: 1.5px solid #FFFFFF;
  border-radius: 99px;
  background: #B45309;
  color: #FFFFFF;
  font-size: 0.68rem;
  font-weight: 700;
  box-shadow: 0 2px 5px rgba(18, 27, 46, 0.14);
}

.page.learn .chest-rung .chest-pill .ico {
  width: 0.78rem;
  height: 0.78rem;
  color: currentColor;
}

.page.learn .chest-rung.opened .chest-button {
  width: 44px;
  height: 44px;
  border: 1.5px solid #CBD5E1;
  border-radius: 50%;
  background: #F8FAFC;
  box-shadow: none;
  opacity: 1 !important;
  filter: none !important;
  cursor: default;
}

.page.learn .chest-rung.opened .chest-art .ico {
  width: 1.4rem;
  height: 1.4rem;
  opacity: 0.82;
}

.page.learn .chest-rung.opened .chest-pill {
  top: -7px;
  right: -7px;
  min-width: 20px;
  min-height: 20px;
  padding: 2px;
  border: 1.5px solid #059669;
  background: #ECFDF5;
  color: #047857;
  box-shadow: none;
}

/* ================= Unit project milestone ================= */
.page.learn .rung.project button.node-link {
  display: grid;
}

.page.learn .rung.project .node-circle {
  border-color: #B45309;
  background: #FFFBEB;
  color: #92400E;
  box-shadow: 0 5px 0 #FCD34D;
}

.page.learn .rung.project.current .node-circle {
  background: #B45309;
  color: #FFFFFF;
  box-shadow: 0 6px 0 #78350F;
}

.page.learn .rung.project.current button.node-link:hover .node-circle {
  background: #92400E;
  box-shadow: 0 4px 0 #78350F;
}

.page.learn .rung.project.current button.node-link:active .node-circle {
  box-shadow: 0 1px 0 #78350F;
}

.page.learn .rung.project.done .node-circle {
  border-color: #059669;
  background: #ECFDF5;
  color: #047857;
  box-shadow: 0 5px 0 #A7F3D0;
}

.page.learn .rung.project.locked .node-circle {
  border-color: #CBD5E1;
  background: #E2E8F0;
  color: #526077;
  box-shadow: 0 5px 0 #CBD5E1;
}

.page.learn .rung.project.locked .node-circle .ico-trophy {
  filter: grayscale(1);
}

.page.learn .milestone-tag {
  padding: 2px 8px;
  border-radius: 8px;
  background: #FEF3C7;
  color: #78350F;
  font-size: 0.72rem;
  font-weight: 800;
}

.page.learn .rung.project.locked .milestone-tag {
  background: #E2E8F0;
  color: #475569;
}

.page.learn .rung.project .rung-car {
  top: 24px;
}

/* ================= Step action popover ================= */
.page.learn .node-pop {
  position: relative;
  left: auto;
  top: auto;
  translate: calc(var(--sway, 0) * var(--sway-step) * -0.5) 0;
  width: min(18rem, calc(100vw - 4rem));
  margin-top: 8px;
  padding: 14px 16px;
  border: 1.5px solid #93C5FD;
  border-radius: 16px;
  background: #FFFFFF;
  color: var(--ink);
  box-shadow: 0 10px 26px rgba(18, 27, 46, 0.14);
  display: grid;
  gap: 8px;
  text-align: left;
  animation: map-pop-in 0.18s ease-out both;
}

.page.learn .rung.project .node-pop {
  width: min(18rem, calc(100vw - 4rem));
}

.page.learn .node-pop::before {
  display: none;
}

.page.learn .node-pop strong {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
}

.page.learn .node-pop p {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 450;
  line-height: 1.45;
  color: var(--muted);
  opacity: 1;
}

.page.learn .node-pop .button {
  min-height: var(--tap);
  margin-top: 2px;
  justify-content: center;
  background: #1D5CE5;
  border-color: #1548BD;
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 2px 0 #143EA8;
}

.page.learn .node-pop .button:hover {
  background: #1548BD;
}

.page.learn .node-pop .button:active {
  transform: translateY(2px);
  box-shadow: none;
}

.page.learn .node-pop.locked-pop {
  border-color: var(--line-strong);
  background: #F8FAFC;
  color: var(--ink);
}

.page.learn .node-pop.current-pop,
.page.learn .node-pop.project-pop {
  border-color: #1D5CE5;
  background: #1D5CE5;
  color: #FFFFFF;
}

.page.learn .node-pop.current-pop::before,
.page.learn .node-pop.project-pop::before {
  content: '';
  display: block;
  position: absolute;
  top: -6px;
  left: 50%;
  width: 12px;
  height: 12px;
  background: #1D5CE5;
  transform: translateX(-50%) rotate(45deg);
}

.page.learn .node-pop.current-pop strong,
.page.learn .node-pop.current-pop p,
.page.learn .node-pop.project-pop strong,
.page.learn .node-pop.project-pop p {
  color: #FFFFFF;
}

.page.learn .node-pop.current-pop .button,
.page.learn .node-pop.project-pop .button {
  background: #FFFFFF;
  border-color: #DBEAFE;
  color: #1548BD;
  box-shadow: 0 3px 0 #BFDBFE;
}

.page.learn .node-pop.current-pop .button:hover,
.page.learn .node-pop.project-pop .button:hover {
  background: #EFF6FF;
}

.page.learn .node-pop.done-pop {
  border-color: #6EE7B7;
  background: #F0FDF4;
}

.page.learn .node-pop.done-pop .button {
  background: #047857;
  border-color: #065F46;
  box-shadow: 0 2px 0 #064E3B;
}

.page.learn .node-pop.done-pop .button:hover {
  background: #065F46;
}

.page.learn .pop-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.page.learn .pop-status .ico {
  width: 0.92rem;
  height: 0.92rem;
}

/* ================= Jump-to-current button ================= */
.jump-current {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(4.75rem + env(safe-area-inset-bottom));
  z-index: 12;
  min-height: var(--tap);
  padding: 0 1rem;
  border: 1.5px solid #1548BD;
  border-radius: 99px;
  background: #1D5CE5;
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(29, 92, 229, 0.28);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  animation: map-pop-in 0.2s ease both;
}

.jump-current .ico {
  width: 1.05rem;
  height: 1.05rem;
  color: #FFFFFF;
}

button.jump-current:hover {
  background: #1548BD;
}

button.jump-current:active {
  transform: translateY(2px);
  box-shadow: none;
}

@media (min-width: 1000px) {
  .jump-current {
    right: 2rem;
    bottom: 1.75rem;
  }
}

/* ================= Course switcher ================= */
button.course-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: var(--tap);
  padding: 0 0.75rem;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  background: #FFFFFF;
  color: var(--ink);
  box-shadow: 0 2px 0 var(--line);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 600;
}

button.course-button:hover {
  background: var(--sunken);
  border-color: var(--line-strong);
}

button.course-button:active {
  transform: translateY(2px);
  box-shadow: none;
}

.course-caret {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1;
}

.course-list {
  position: fixed;
  inset: calc(env(safe-area-inset-top) + 4.25rem) max(12px, env(safe-area-inset-right)) auto auto;
  width: min(20rem, calc(100vw - 24px));
  max-height: calc(100dvh - 6rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  margin: 0;
  padding: 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: 18px;
  background: #FFFFFF;
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 600;
  box-shadow: 0 12px 28px rgba(18, 27, 46, 0.14);
}

@media (min-width: 1000px) {
  .course-list {
    inset: 4.5rem 2.5rem auto auto;
  }
}

button.course-button:focus-visible,
button.course:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.course-list:popover-open {
  animation: map-pop-in 0.18s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.course-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.course-list h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
}

.course-list ul {
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.course {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 0 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #FFFFFF;
  box-shadow: 0 2px 0 var(--line);
  color: var(--ink);
  text-align: left;
}

button.course:hover {
  background: var(--sunken);
  border-color: var(--line-strong);
}

button.course:active {
  transform: translateY(2px);
  box-shadow: none;
}

button.course[aria-current="true"] {
  border-color: #1D5CE5;
  background: #EFF6FF;
  color: #1548BD;
  box-shadow: 0 2px 0 #1D5CE5;
}

.course-check {
  display: grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  flex: none;
}

.course-check .ico {
  width: 0.85rem;
  height: 0.85rem;
}

.course-sep {
  height: 1px;
  margin: 0.25rem 0;
  background: var(--line);
}

.course.soon {
  border-color: transparent;
  background: var(--sunken);
  box-shadow: none;
  color: var(--muted);
  min-height: 2.75rem;
}

.course.soon .chip {
  background: #FFFFFF;
  color: var(--muted);
}

@media (max-width: 480px) {
  button.course-button {
    padding: 0 0.5rem;
  }

  .course-caret {
    display: none;
  }
}

@media (max-width: 420px) {
  #mypoints button.course-button {
    padding: 0 0.35rem;
    gap: 0.25rem;
  }

  .page.learn .unit-banner {
    padding: 14px 16px;
  }
}

/* ================= Mascot personality & part hooks ================= */
.mascot .part-body {
  transform-box: fill-box;
  transform-origin: center bottom;
}

.mascot .part-wheels {
  transform-box: fill-box;
  transform-origin: center;
}

.mascot .part-screen {
  transform-box: fill-box;
  transform-origin: center;
}

.mascot .part-top {
  transform-box: fill-box;
  transform-origin: center bottom;
}

.mascot .shadow {
  transform-box: fill-box;
  transform-origin: center;
  animation: car-shadow 2.2s ease-in-out infinite;
}

.mascot .eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: car-blink 4.6s ease-in-out infinite;
}

.mascot.mood-welcome .body-car {
  animation: car-welcome 0.55s cubic-bezier(0.34, 1.45, 0.64, 1) 1, car-breathe 2.2s 0.55s ease-in-out infinite;
}

.mascot.mood-sad .body-car {
  animation: car-sad 0.55s ease-out 1, car-breathe 2.8s 0.55s ease-in-out infinite;
}

.mascot.mood-celebrate .body-car {
  animation: car-celebrate 0.65s cubic-bezier(0.3, 1.5, 0.6, 1) 2, car-breathe 2.2s 1.3s ease-in-out infinite;
}

.mascot.mood-proud .body-car {
  animation: car-proud 0.6s cubic-bezier(0.34, 1.45, 0.64, 1) 1, car-breathe 2.2s 0.6s ease-in-out infinite;
}

.mascot.mood-streak .body-car {
  animation: car-streak 0.45s cubic-bezier(0.34, 1.5, 0.64, 1) 2, car-breathe 2.2s 0.9s ease-in-out infinite;
}

.mascot .sparkles path,
.mascot .proud-stars path,
.mascot .confetti-burst > *,
.mascot .streak-flames path,
.mascot .welcome-waves path,
.mascot .kind-heart {
  transform-box: fill-box;
  transform-origin: center;
  animation: mascot-extra-pop 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.mascot .sparkles path:nth-child(2),
.mascot .proud-stars path:nth-child(2),
.mascot .confetti-burst > :nth-child(2n),
.mascot .welcome-waves path:nth-child(2) {
  animation-delay: 0.08s;
}

.mascot .sparkles path:nth-child(3),
.mascot .proud-stars path:nth-child(3),
.mascot .confetti-burst > :nth-child(3n) {
  animation-delay: 0.16s;
}

.mascot .sweat {
  animation: mascot-sweat-once 0.75s ease-out 1 both;
}

.mascot .dots circle {
  transform-box: fill-box;
  transform-origin: center;
  animation: mascot-extra-pop 0.35s ease both;
}

.mascot .dots circle:nth-child(2) {
  animation-delay: 0.1s;
}

.mascot .dots circle:nth-child(3) {
  animation-delay: 0.2s;
}

.who .mascot * {
  animation: none !important;
}

/* ================= Keyframes ================= */
@keyframes map-pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes map-flag-in {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes map-banner-unlock {
  0% {
    opacity: 0.35;
    transform: translateY(8px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes map-unlock-pop {
  0% {
    opacity: 0.35;
    transform: scale(0.76);
  }
  65% {
    opacity: 1;
    transform: scale(1.08);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes map-unlock-ring {
  0% {
    opacity: 0.85;
    transform: scale(0.92);
  }
  100% {
    opacity: 0;
    transform: scale(1.38);
  }
}

@keyframes car-shadow {
  50% {
    transform: scaleX(0.93);
    opacity: 0.08;
  }
}

@keyframes car-blink {
  0%, 90%, 96%, 100% {
    transform: scaleY(1);
  }
  93% {
    transform: scaleY(0.08);
  }
}

@keyframes car-welcome {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  35% {
    transform: translateY(-10px) rotate(-6deg);
  }
  70% {
    transform: translateY(-4px) rotate(5deg);
  }
  100% {
    transform: translateY(0) rotate(0deg);
  }
}

@keyframes car-sad {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  45% {
    transform: translateY(5px) rotate(-3deg);
  }
  100% {
    transform: translateY(0) rotate(0deg);
  }
}

@keyframes car-celebrate {
  0%, 100% {
    transform: translateY(0) scale(1) rotate(0deg);
  }
  20% {
    transform: translateY(2px) scale(1.07, 0.92);
  }
  50% {
    transform: translateY(-24px) scale(0.96, 1.06) rotate(-5deg);
  }
  78% {
    transform: translateY(-2px) scale(1.04, 0.96) rotate(4deg);
  }
}

@keyframes car-proud {
  0% {
    transform: translateY(0) scale(1);
  }
  45% {
    transform: translateY(-14px) scale(1.04);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes car-streak {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  30% {
    transform: translateY(2px) scale(1.08, 0.92);
  }
  65% {
    transform: translateY(-14px) scale(0.97, 1.05);
  }
}

@keyframes mascot-extra-pop {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes mascot-sweat-once {
  0% {
    opacity: 0;
    transform: translateY(-4px);
  }
  35% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 1;
    transform: translateY(4px);
  }
}

/* ================= Reduced motion ================= */
@media (prefers-reduced-motion: reduce) {
  .unit-banner.just-unlocked,
  .rung.just-unlocked .node-circle,
  .unlock-ring,
  .start-flag,
  .node-pop,
  .jump-current,
  .course-list:popover-open,
  .mascot,
  .mascot * {
    animation: none !important;
    transition: none !important;
  }

  .unlock-ring {
    display: none;
  }

  .unit-progress span,
  .map-progress .progress-bar span,
  .node-circle {
    transition: none !important;
  }
}
