/* =================================================================
   Design tokens — shared with lesson.html (keep in sync).
   ================================================================= */
:root {
  --purple:       #7B4DFF;
  --purple-light: #AA8AFF;
  --purple-dark:  #5A2EE0;
  --orange:       #F5A623;
  --orange-light: #FFCC66;
  --blue:         #3B82F6;
  --magenta:      #9C2C6B;
  --coral:        #FF4B5C;
  --green:        #10B981;
  --green-light:  #34D399;

  --world-color:        #7B4DFF;
  --world-color-light:  #AA8AFF;
  --world-color-rgb:        123, 77, 255;
  --world-tint-strong: 0.20;
  --world-tint-soft:   0.10;

  --font-h: 'Nunito', sans-serif;
  --font-b: 'Space Grotesk', sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --radius-2xl: 20px;

  --easing: cubic-bezier(.4, 0, .2, 1);
}

/* Dark theme tokens — only theme supported for now. */
:root {
  --bg:           #0B0820;
  --bg-top:       #0D0826;
  --bg-bottom:    #07122E;
  --surface:      #120E2A;
  --surface-lift: #1A1440;

  --text:         #FFFFFF;
  --text-soft:    rgba(255,255,255,0.88);
  --text-muted:   #CEC9E3;
  --text-dim:     #B8B0D0;

  --card-fill:        rgba(255,255,255,0.04);
  --card-fill-strong: rgba(255,255,255,0.08);
  --card-border:      rgba(255,255,255,0.10);
  --card-border-hover:rgba(255,255,255,0.22);
  --card-hover:       rgba(255,255,255,0.06);

  --nav-bg:   rgba(13,8,38,0.88);
  --nav-bg-2: rgba(13,8,38,0.95);
  --crumb:    rgba(255,255,255,0.60);
  --chip-bg:  rgba(123,77,255,0.18);

  --scrollbar:    rgba(255,255,255,0.10);

  --hero-gradient: linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 50%, var(--bg-bottom) 100%);
  --world-tint-strong: 0.22;
  --world-tint-soft:   0.12;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  background: var(--bg);
  scroll-behavior: smooth;
  max-width: 100%;
  overflow-x: clip;
  font-size: 17px;
}
body {
  font-family: var(--font-b);
  color: var(--text);
  font-size: 17px;
  background: transparent;
  background-image: var(--hero-gradient);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 55% at 50% 0%,
      rgba(var(--world-color-rgb), var(--world-tint-strong)) 0%,
      transparent 60%),
    radial-gradient(ellipse 70% 45% at 50% 100%,
      rgba(var(--world-color-rgb), var(--world-tint-soft)) 0%,
      transparent 70%);
  transition: background 400ms var(--easing);
}

button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }

/* =================================================================
   Cosmic starfield — global, fixed, viewport-sized canvas
   -----------------------------------------------------------------
   Rendered as a sibling of `.app` (see base.html). Sits at z-index:0
   in body's stacking context — above `body::before`'s world tint
   (also z-index:0, but earlier in DOM order) and below `.app`
   (z-index:2) so page content always reads on top. The animation
   logic lives in base.html so every page extending base.html shares
   the same "space theme" as the marketing site (getxplain.ai).
   ================================================================= */
#starfield {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

/* =================================================================
   Knowledge-fuel meter — global, fixed, viewport-pinned slider
   -----------------------------------------------------------------
   A tall vertical orange "fuel tube" pinned to the right gutter on
   every page so Xplorer's mission progress is always in view as
   visitors navigate worlds/categories/lessons. Hidden below 1200 px
   where the gutter is too tight to host it without overlapping
   content. Pointer events are off — purely decorative.
   ================================================================= */
.fuel-rail {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  display: none;
}
@media (min-width: 1200px) {
  .fuel-rail { display: block; }
}

.fuel-rail__side {
  position: fixed;
  top: 112px;             /* clears the sticky site-bar */
  bottom: 40px;
  right: 24px;
  width: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  pointer-events: none;
}
@media (min-width: 1440px) {
  .fuel-rail__side { width: 76px; right: 36px; }
}

/* Charging cap — golden circular badge sitting above the pipe. */
.fuel-rail__cap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F5A623, #FFD700);
  color: #2A1700;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow:
    0 0 0 5px rgba(245, 166, 35, 0.10),
    0 0 28px rgba(245, 166, 35, 0.55),
    inset 0 -3px 8px rgba(0, 0, 0, 0.12);
}
.fuel-rail__cap i { width: 20px; height: 20px; }

.fuel-rail__label {
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.25;
  white-space: nowrap;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.35);
}
.fuel-rail__label--top    { color: #FFB74D; }
.fuel-rail__label--bottom { color: var(--text-muted); }

/* The pipe — a chunky vertical tube with a static orange fuel fill. */
.fuel-rail__pipe {
  position: relative;
  width: 30px;
  flex: 1 1 auto;
  min-height: 180px;
  border-radius: 999px;
  background:
    linear-gradient(180deg,
      rgba(12, 4, 30, 0.55) 0%,
      rgba(12, 4, 30, 0.35) 100%);
  border: 2px solid rgba(255, 255, 255, 0.10);
  overflow: hidden;
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.55),
    inset 0 -2px 8px rgba(255, 255, 255, 0.04),
    0 0 30px rgba(245, 166, 35, 0.12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Static fuel fill — warm orange filling the bottom 74% of the tube. */
.fuel-rail__pipe::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 74%;
  background:
    linear-gradient(180deg,
      rgba(245, 166, 35, 0.35) 0%,
      rgba(245, 166, 35, 0.85) 45%,
      rgba(255, 183, 77, 1)    100%);
  box-shadow:
    inset 0 0 24px rgba(245, 166, 35, 0.65),
    0 -6px 22px rgba(245, 166, 35, 0.55);
}

/* =================================================================
   Layout shell
   ================================================================= */
.app {
  position: relative;
  z-index: 2;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px 96px;
}

/* =================================================================
   Top bar (site-bar) — matches lesson.html for brand consistency.
   ================================================================= */
.site-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 32px 28px;
  margin: 0 -32px 8px;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: border-color .25s var(--easing), box-shadow .25s var(--easing);
  isolation: isolate;
}
.site-bar::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  z-index: -1;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg) 88%, transparent) 0%,
    color-mix(in srgb, var(--bg) 78%, transparent) 55%,
    color-mix(in srgb, var(--bg) 0%,  transparent) 100%
  );
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 60%, transparent 100%);
          mask-image: linear-gradient(180deg, #000 0%, #000 60%, transparent 100%);
  pointer-events: none;
}
.site-bar.is-stuck::before {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg) 94%, transparent) 0%,
    color-mix(in srgb, var(--bg) 84%, transparent) 60%,
    color-mix(in srgb, var(--bg) 0%,  transparent) 100%
  );
}
.site-bar.is-stuck {
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-h);
  font-weight: 900;
  font-size: clamp(30px, 3.2vw, 40px);
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
}
.brand .brand-icon {
  width: clamp(40px, 4.2vw, 52px);
  height: clamp(40px, 4.2vw, 52px);
  object-fit: contain;
  display: block;
}
.brand .brand-text { display: inline-flex; align-items: baseline; }
.brand .b-get, .brand .b-plain { color: var(--text); }
.brand .b-x {
  background: linear-gradient(180deg, #7B4DFF 0%, #AA8AFF 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding: 0 1px;
}
.brand .b-dot { color: #F5A623; }
.brand .b-ai {
  background: linear-gradient(180deg, #F5A623 0%, #FFD700 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.site-nav {
  margin-left: auto;
  display: none;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: 16px;
  color: var(--text-muted);
}
@media (min-width: 900px) { .site-nav { display: inline-flex; } }
.site-nav a { padding: 10px 14px; border-radius: 999px; transition: color .15s, background .15s; }
@media (hover: hover) { .site-nav a:hover { color: var(--text); background: var(--card-hover); } }
.site-nav a.active { color: var(--text); background: var(--card-fill-strong); }

.site-bar-tail { display: inline-flex; align-items: center; gap: 10px; }
@media (min-width: 900px) { .site-bar-tail { margin-left: 8px; } }
@media (max-width: 899px) { .site-bar-tail { margin-left: auto; } }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card-fill);
  transition: background .15s, border-color .15s, transform .15s;
}
@media (hover: hover) { .icon-btn:hover { background: var(--card-hover); border-color: var(--card-border-hover); transform: translateY(-1px); } }
.icon-btn i { width: 18px; height: 18px; color: var(--text); }

/* =================================================================
   Breadcrumbs
   -----------------------------------------------------------------
   Markup is produced by `_breadcrumbs.html`'s `render_breadcrumbs`
   macro (and mirrored verbatim by the lesson viewer's JS), so the
   styling here is the single visual source of truth for every
   page's path trail:

     <nav class="crumbs">
       <a class="crumb" href="..."><i data-lucide="..."></i>
         <span class="crumb-label">…</span></a>
       <i class="crumb-sep" data-lucide="chevron-right"></i>
       <span class="crumb is-current" aria-current="page">…</span>
     </nav>
   ================================================================= */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 14px 0 36px;
  font-family: var(--font-h);
  line-height: 1.2;
  min-width: 0;
}
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  text-decoration: none;
  background: transparent;
  border: 0;
  border-radius: 6px;
  max-width: 22ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.18s ease;
}
@media (hover: hover) { .crumb:hover { color: var(--text); } }
@media (hover: hover) { .crumb:hover .crumb-label {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
} }
.crumb:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 3px;
  color: var(--text);
}
.crumb i { width: 13px; height: 13px; flex: 0 0 auto; color: var(--purple-light); opacity: 0.85; }

/* The current page — gradient text + brighter icon. Keep both
   `.is-current` (canonical) and the legacy `.current` selector
   alive so older JS-generated markup still styles correctly. */
.crumb.is-current,
.crumb.current {
  color: var(--text);
  font-weight: 800;
  max-width: 60ch;
  background: linear-gradient(135deg, #7B4DFF 0%, #3B82F6 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}
.crumb.is-current i,
.crumb.current i { color: #F5A623; opacity: 1; }
@media (hover: hover) { .crumb.is-current:hover .crumb-label,
.crumb.current:hover .crumb-label {
  background-image: linear-gradient(135deg, #7B4DFF 0%, #3B82F6 100%);
  background-size: 100% 1px;
} }

/* Separator chevron — lucide icon between crumbs. Falls back
   gracefully for any template that still emits a text "›" by
   sizing as a small inline glyph. */
.crumb-sep {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  opacity: 0.4;
  color: var(--text-muted);
  flex: 0 0 auto;
  margin: 0 -1px;
  font-size: 12px;
  line-height: 1;
}

@media (max-width: 720px) {
  .crumbs {
    flex-wrap: nowrap;
    gap: 4px 6px;
    margin: 12px 0 22px;
  }
  .crumb {
    font-size: 12.5px;
    padding: 2px;
    max-width: none;
    min-width: 0;
    flex: 0 1 auto;
  }
  .crumb i { width: 12px; height: 12px; }
  .crumb-sep { width: 11px; height: 11px; }
}

/* =================================================================
   Section heads + titles
   ================================================================= */
.page-head { margin: 8px 0 28px; }
.page-title {
  font-family: var(--font-h);
  font-weight: 800;
  font-size: clamp(32px, 3.8vw, 48px);
  line-height: 1.1;
  margin: 0 0 10px;
  color: var(--text);
}
.page-subtitle {
  font-size: 17px;
  color: var(--text-muted);
  margin: 0;
  max-width: 720px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 36px 0 16px;
}
.section-title {
  font-family: var(--font-h);
  font-weight: 800;
  font-size: clamp(22px, 2.4vw, 28px);
  line-height: 1.2;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.section-title i { width: 26px; height: 26px; color: var(--world-color, var(--purple)); }

/* =================================================================
   Card grids — categories, worlds, lessons
   ================================================================= */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 640px)  { .grid-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px)  { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }

.card {
  background: var(--card-fill);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  transition: transform .15s var(--easing), border-color .2s, background .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}
@media (hover: hover) { .card:hover {
  transform: translateY(-2px);
  border-color: var(--card-border-hover);
  background: var(--card-hover);
  box-shadow: 0 14px 36px rgba(123,77,255,.12);
} }
.card:focus-visible {
  outline: 2px solid var(--world-color, var(--purple));
  outline-offset: 3px;
}

/* Colored left-accent tied to the world/category colour */
.card.accent::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--world-color, var(--purple));
  border-radius: 4px 0 0 4px;
}

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(var(--world-color-rgb), 0.18);
  color: var(--world-color, var(--purple));
}
.card-icon i { width: 24px; height: 24px; }
.card-title {
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 19px;
  line-height: 1.25;
  color: var(--text);
  margin: 4px 0 2px;
}
.card-meta {
  font-size: 14px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.card-meta .dot { opacity: 0.55; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--world-color, var(--purple));
  font-weight: 600;
  font-size: 13px;
}
.pill i { width: 14px; height: 14px; }

/* =================================================================
   Category block (on /worlds index: category title with its worlds)
   ================================================================= */
.cat-block { margin: 0 0 48px; }
.cat-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 18px;
}
.cat-head .cat-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: rgba(var(--world-color-rgb), 0.18);
  color: var(--world-color);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cat-head .cat-icon i { width: 28px; height: 28px; }
.cat-head .cat-text { display: flex; flex-direction: column; gap: 4px; }
.cat-head .cat-text .cat-name {
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 24px;
  color: var(--text);
}
.cat-head .cat-text .cat-sub {
  color: var(--text-muted);
  font-size: 14px;
}
.cat-head .cat-link {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card-fill);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  transition: background .15s, border-color .15s, color .15s;
}
@media (hover: hover) { .cat-head .cat-link:hover { color: var(--text); background: var(--card-hover); border-color: var(--card-border-hover); } }
.cat-head .cat-link i { width: 14px; height: 14px; }

/* =================================================================
   World tile — subtle color-tinted card (matches mobile app)
   Used on /worlds and /worlds/<category>
   ================================================================= */
.world-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
@media (min-width: 640px) {
  .world-grid { gap: 16px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
@media (min-width: 1100px) {
  .world-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}

.world-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  display: block;
  text-decoration: none;
  color: inherit;
  background: rgba(var(--world-color-rgb), 0.08);
  border: 1px solid rgba(var(--world-color-rgb), 0.18);
  border-radius: 14px;
  overflow: hidden;
  isolation: isolate;
  transition: transform .15s var(--easing), background .2s, border-color .2s;
}
@media (hover: hover) { .world-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--world-color-rgb), 0.42);
} }
.world-tile:focus-visible {
  outline: 2px solid var(--world-color);
  outline-offset: 2px;
}

/* Hero layer — random lesson image when available, color-tinted gradient
   otherwise. A bottom-anchored dark gradient keeps the body text readable
   regardless of the image. */
.world-tile-hero {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(
      to top,
      rgba(11, 8, 32, 0.92) 0%,
      rgba(11, 8, 32, 0.72) 35%,
      rgba(11, 8, 32, 0.30) 65%,
      rgba(11, 8, 32, 0.10) 100%
    ),
    radial-gradient(120% 80% at 50% 0%,
      rgba(var(--world-color-rgb), 0.30) 0%,
      rgba(var(--world-color-rgb), 0.05) 60%,
      transparent 100%
    );
  background-size: 100% 100%, 100% 100%;
  transition: transform .25s var(--easing), filter .25s;
}
.world-tile.has-hero .world-tile-hero {
  background:
    linear-gradient(
      to top,
      rgba(11, 8, 32, 0.30) 0%,
      rgba(11, 8, 32, 0.05) 50%,
      transparent 100%
    ),
    var(--world-hero) center / cover no-repeat;
}
@media (hover: hover) { .world-tile:hover .world-tile-hero {
  transform: scale(1.04);
} }

/* World icon chip overlaid on the hero, top-left */
.world-tile-icon {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(var(--world-color-rgb), 0.92);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}
.world-tile-icon i {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

/* Bottom-anchored content stack: name, count, peek title.
   Sits in a solid frosted band so the text is always readable, regardless
   of how busy the hero image behind it is. */
.world-tile-body {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 12px 12px;
  min-width: 0;
  background: linear-gradient(
    to bottom,
    rgba(11, 8, 32, 0.78) 0%,
    rgba(11, 8, 32, 0.94) 100%
  );
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid rgba(var(--world-color-rgb), 0.35);
  box-shadow: 0 -8px 16px -8px rgba(0, 0, 0, 0.45);
}
.world-tile-name {
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 15px;
  line-height: 1.15;
  color: #fff;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.world-tile-meta {
  font-family: var(--font-h);
  font-weight: 700;
  font-size: 11px;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.82);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.world-tile-meta.is-empty {
  color: rgba(255, 255, 255, 0.55);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}

.world-tile-peek {
  margin-top: 4px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-family: var(--font-h);
  font-weight: 600;
  font-size: 11px;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.92);
  min-width: 0;
}
.world-tile-peek i {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--world-color);
  stroke-width: 2.25;
  filter: drop-shadow(0 0 6px rgba(var(--world-color-rgb), 0.45));
}
.world-tile-peek-text {
  min-width: 0;
  flex: 1;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Empty-state tile — no lessons yet, no hero image. The icon takes over the
   whole tile so the empty card still looks intentional and inviting. */
.world-tile.is-empty .world-tile-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% - 22px));
  width: 96px;
  height: 96px;
  border-radius: 22px;
  background: rgba(var(--world-color-rgb), 0.18);
  color: var(--world-color);
  box-shadow:
    0 8px 30px rgba(var(--world-color-rgb), 0.30),
    inset 0 0 0 1px rgba(var(--world-color-rgb), 0.35);
  transition: transform .25s var(--easing), background .25s, box-shadow .25s;
}
@media (hover: hover) { .world-tile.is-empty:hover .world-tile-icon {
  transform: translate(-50%, calc(-50% - 22px)) scale(1.04);
  background: rgba(var(--world-color-rgb), 0.26);
} }
.world-tile.is-empty .world-tile-icon i {
  width: 56px;
  height: 56px;
  stroke-width: 1.6;
}
@media (min-width: 1100px) {
  .world-tile.is-empty .world-tile-icon {
    width: 112px;
    height: 112px;
    border-radius: 26px;
    transform: translate(-50%, calc(-50% - 24px));
  }
  @media (hover: hover) { .world-tile.is-empty:hover .world-tile-icon {
    transform: translate(-50%, calc(-50% - 24px)) scale(1.04);
  } }
  .world-tile.is-empty .world-tile-icon i {
    width: 64px;
    height: 64px;
  }
}

/* =================================================================
   Lesson card — image on top, meta below
   ================================================================= */
.lesson-card {
  background: var(--card-fill);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
  transition: transform .15s var(--easing), border-color .2s, background .2s, box-shadow .2s;
}
@media (hover: hover) { .lesson-card:hover {
  transform: translateY(-2px);
  border-color: var(--card-border-hover);
  background: var(--card-hover);
  box-shadow: 0 14px 36px rgba(123,77,255,.12);
} }
.lesson-card:focus-visible {
  outline: 2px solid var(--world-color, var(--purple));
  outline-offset: 3px;
}
.lesson-card .lc-image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--card-hover);
  overflow: hidden;
}
.lesson-card .lc-image img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .35s var(--easing);
}
@media (hover: hover) { .lesson-card:hover .lc-image img { transform: scale(1.04); } }
.lesson-card .lc-image .lc-image-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}
.lesson-card .lc-body { padding: 20px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.lesson-card .lc-world {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-h);
  font-weight: 700;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(var(--world-color-rgb), 0.18);
  color: var(--world-color);
  align-self: flex-start;
}
.lesson-card .lc-world i { width: 14px; height: 14px; }
.lesson-card .lc-title {
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 18px;
  line-height: 1.3;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lesson-card .lc-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: auto;
}
.lesson-card .lc-meta i { width: 14px; height: 14px; }

/* =================================================================
   Pagination
   ================================================================= */
.pager {
  margin: 40px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pager a, .pager span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--card-fill);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
@media (hover: hover) { .pager a:hover { color: var(--text); background: var(--card-hover); border-color: var(--card-border-hover); } }
.pager .current {
  color: var(--text);
  background: var(--world-color, var(--purple));
  border-color: var(--world-color, var(--purple));
  color: #fff;
}
.pager .disabled {
  opacity: 0.4;
  pointer-events: none;
}
.pager .ellipsis {
  border: 0;
  background: transparent;
  color: var(--text-dim);
}

/* =================================================================
   Empty state
   ================================================================= */
.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-xl);
  background: var(--card-fill);
}
.empty i { width: 36px; height: 36px; color: var(--text-dim); margin: 0 auto 10px; display: block; }
.empty .empty-title {
  font-family: var(--font-h);
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  margin: 0 0 6px;
}

/* =================================================================
   Empty-world invitation modal — fired from .world-tile.is-empty
   ================================================================= */
html.modal-open,
body.modal-open { overflow: hidden; }

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-root[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 60% at 50% 30%, rgba(var(--world-color-rgb), 0.30) 0%, rgba(11, 8, 32, 0.10) 60%, transparent 100%),
    rgba(11, 8, 32, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: modal-backdrop-in .2s var(--easing) both;
}
@keyframes modal-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(26, 20, 64, 0.94) 0%, rgba(11, 8, 32, 0.98) 100%);
  border: 1px solid rgba(var(--world-color-rgb), 0.45);
  border-radius: 24px;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 60px rgba(var(--world-color-rgb), 0.30);
  color: #fff;
  animation: modal-card-in .28s var(--easing) both;
}
@keyframes modal-card-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  z-index: 2;
  transition: background .15s, color .15s, transform .15s var(--easing);
}
@media (hover: hover) { .modal-close:hover {
  background: rgba(var(--world-color-rgb), 0.30);
  color: #fff;
  transform: rotate(90deg);
} }
.modal-close i { width: 18px; height: 18px; stroke-width: 2.25; }

/* Hero strip — mascot + glowing world icon side-by-side */
.modal-hero {
  position: relative;
  padding: 32px 28px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.modal-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 80% at 50% 0%, rgba(var(--world-color-rgb), 0.28) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.modal-mascot {
  position: relative;
  z-index: 1;
  width: 110px;
  height: 110px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 10px 30px rgba(var(--world-color-rgb), 0.45));
  animation: modal-mascot-float 4s ease-in-out infinite;
}
.modal-mascot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
@keyframes modal-mascot-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.modal-world-icon {
  position: relative;
  z-index: 1;
  width: 72px;
  height: 72px;
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--world-color-rgb), 0.20);
  color: var(--world-color);
  border: 1px solid rgba(var(--world-color-rgb), 0.45);
  box-shadow: 0 10px 30px rgba(var(--world-color-rgb), 0.30);
}
.modal-world-icon i {
  width: 38px;
  height: 38px;
  stroke-width: 1.75;
}

.modal-body {
  position: relative;
  z-index: 1;
  padding: 18px 28px 28px;
  text-align: center;
}

.modal-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(var(--world-color-rgb), 0.16);
  border: 1px solid rgba(var(--world-color-rgb), 0.32);
  color: var(--world-color);
  font-family: var(--font-h);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.modal-eyebrow i { width: 13px; height: 13px; stroke-width: 2.25; }

.modal-title {
  font-family: var(--font-h);
  font-weight: 900;
  font-size: clamp(22px, 4vw, 28px);
  line-height: 1.15;
  margin: 4px 0 12px;
  letter-spacing: -0.01em;
  color: #fff;
}
.modal-world-name {
  background: linear-gradient(135deg, var(--world-color), var(--orange));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 24px rgba(var(--world-color-rgb), 0.40));
}

.modal-desc {
  font-family: var(--font-b);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.82);
  margin: 0 0 22px;
}
.modal-desc strong {
  color: #fff;
  font-weight: 700;
}

.modal-stores {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0 0 18px;
}
.modal-store {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 4px;
  transition: transform .15s var(--easing), box-shadow .2s;
}
@media (hover: hover) { .modal-store:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(var(--world-color-rgb), 0.35);
} }
.modal-store:focus-visible {
  outline: 2px solid var(--world-color);
  outline-offset: 3px;
}
.modal-store img {
  display: block;
  height: 48px;
  width: auto;
}

.modal-microcopy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.30);
  color: var(--green-light, #34D399);
  font-family: var(--font-b);
  font-weight: 600;
  font-size: 12px;
}
.modal-microcopy i { width: 14px; height: 14px; stroke-width: 2.25; }
@media (max-width: 480px) {
  .modal-hero { padding: 26px 20px 0; gap: 12px; }
  .modal-mascot { width: 92px; height: 92px; }
  .modal-world-icon { width: 60px; height: 60px; border-radius: 18px; }
  .modal-world-icon i { width: 32px; height: 32px; }
  .modal-body { padding: 16px 20px 22px; }
}

/* =================================================================
   Age switcher partial (`templates/_age_switcher.html`)
   -----------------------------------------------------------------
   Rendered on the worlds-index, category, and world pages so visitors
   can re-tune the active age band without losing their place. Lives
   in base.css (not home.css) because those directory pages don't load
   the landing's stylesheet — without it the pills collapse to flat
   inline text.
   ================================================================= */
.age-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 0;
}
/* Each chip is colour-tinted via inline `--world-color` / `--world-color-rgb`
   set per-band in `_age_switcher.html`, so the same rule paints all bands in
   their signature colour without per-band CSS classes. Mirrors the
   `.home-cat-chip` style used by the world chips on the landing page. */
.age-switcher__chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 8px;
  border-radius: 999px;
  background: rgba(var(--world-color-rgb), 0.14);
  border: 1px solid rgba(var(--world-color-rgb), 0.30);
  color: var(--text);
  font-family: var(--font-h);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .15s, box-shadow .15s;
}
@media (hover: hover) { .age-switcher__chip:hover {
  background: rgba(var(--world-color-rgb), 0.22);
  border-color: rgba(var(--world-color-rgb), 0.50);
  transform: translateY(-1px);
} }
.age-switcher__icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(var(--world-color-rgb), 0.30);
  color: var(--world-color);
  flex-shrink: 0;
}
.age-switcher__icon i { width: 16px; height: 16px; }
.age-switcher__num {
  font-weight: 900;
  letter-spacing: 0.02em;
}
.age-switcher__name {
  font-weight: 600;
  opacity: 0.88;
}
/* Active band pops with a saturated ring + glow + brighter icon chip
   so it reads as the current selection at a glance. */
.age-switcher__chip.is-active {
  background: rgba(var(--world-color-rgb), 0.28);
  border-color: rgba(var(--world-color-rgb), 0.70);
  box-shadow:
    inset 0 0 0 1px rgba(var(--world-color-rgb), 0.40),
    0 10px 24px rgba(var(--world-color-rgb), 0.30);
}
.age-switcher__chip.is-active .age-switcher__icon {
  background: var(--world-color);
  color: #fff;
}
.age-switcher__chip.is-active .age-switcher__name { opacity: 1; }
@media (max-width: 540px) {
  .age-switcher__name { display: none; }
  .age-switcher__chip { padding: 6px 12px 6px 6px; }
  .age-switcher__icon { width: 24px; height: 24px; }
  .age-switcher__icon i { width: 14px; height: 14px; }
}
