/* =========================
   Core tokens + globals
   ========================= */

:root {
  --bg: #0a0f1a;
  --card: #0f1625;
  --soft: #0c1423;
  --ink: #e5e7eb;
  --muted: #94a3b8;
  --border: #0b2a55;
  --radius: 22px;
  --shadow: 0 10px 30px rgba(2, 6, 23, .45);

  --cta: #3b82f6;
  --cta-shadow: #1e40af;
  --cta-grad-start: #2563eb;
  --cta-grad-end: #1e40af;

  --chip-bg: rgba(30, 58, 138, .25);
  --chip-ink: #e2e8f0;

  --fx-blue: #60a5fa;
  --fx-blue-soft: #3b82f6;
  --fx-grid-stroke: rgba(96, 165, 250, .35);
  --fx-trace-grad-1: #93c5fd;
  --fx-trace-grad-2: #3b82f6;
}

* {
  box-sizing: border-box;
  transition-property: opacity, transform, box-shadow, border-color, background, color;
  transition-duration: .4s;
  transition-timing-function: ease;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--ink);
}

/* =========================
   Layout shell
   ========================= */

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 14px 56px;
  position: relative;
  z-index: 2;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(120%) blur(6px);
  transition: box-shadow .25s, background .25s;
}

.container,
header,
.card {
  position: relative;
  z-index: 2;
}

img {
  max-width: 100%;
  height: auto;
}


/* =========================
   Hero section
   ========================= */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 24px;
  align-items: start;
  margin-top: 28px;
}

.hero-left h1 {
  font-size: clamp(32px, 6vw, 48px);
  margin: 0 0 12px;
}

.hero-left p,
.hero-left li {
  color: var(--muted);
}

.hero-figure {
  --img-w: 260px;
  --img-w-lg: 360px;
  --img-pad: 12px;
  --img-radius: 22px;
  --img-rotate: 0deg;
  --img-shadow: 0 12px 32px rgba(0, 0, 0, .3);
  --img-bg: none;

  display: inline-block;
  padding: var(--img-pad);
  border-radius: var(--img-radius);
  background: var(--img-bg);
  box-shadow: var(--img-shadow);
}

.hero-img {
  width: var(--img-w);
  height: auto;
  display: block;
  transform: rotate(var(--img-rotate));
  border-radius: calc(var(--img-radius) - 6px);
}

@media (min-width: 900px) {
  .hero-img {
    width: var(--img-w-lg);
  }
}

.library-page .hero-figure {
  --img-w: 240px;
  --img-w-lg: 330px;
  --img-bg: radial-gradient(
    120% 120% at 20% 10%,
    #1a2b4a 0%,
    #0f1a2e 60%,
    transparent 100%
  );
  --img-rotate: -2deg;
}

/* =========================
   Controls row
   ========================= */

#controls {
  display: grid;
  grid-template-columns: 1.2fr 0.6fr 0.8fr;
  gap: 10px;
  margin: 24px 0;
}

#controls input,
#controls select {
  width: 100%;
  background: rgb(12, 20, 35);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  font-size: 16px;
  outline: none;
}

/* =========================
   Grid + cards
   ========================= */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 14px;
  animation: fadeUp .6s ease-out 0s 1 both;
  transition: transform .18s, box-shadow .18s, border-color .18s;
  will-change: transform;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.card,
.pill,
.btn {
  opacity: 1;
  transform: none;
}

@keyframes fadeUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================
   Pills / difficulty chips
   ========================= */

.pill {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .7rem;
  font: 700 11px / 1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  letter-spacing: .2px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 22, 37, .75);
  color: rgb(207, 224, 255);
  box-shadow:
    inset 0 6px 18px rgba(2, 6, 23, .25),
    0 0 0 rgba(0, 0, 0, 0);
  transition: transform .15s, box-shadow .2s, border-color .2s;
}

.pill.level-easy {
  background: rgba(34, 197, 94, .15);
  border-color: rgba(34, 197, 94, .35);
  color: rgb(187, 247, 208);
}

.pill.level-medium {
  background: rgba(59, 130, 246, .15);
  border-color: rgba(59, 130, 246, .35);
  color: rgb(191, 219, 254);
}

.pill.level-hard {
  background: rgba(245, 158, 11, .15);
  border-color: rgba(245, 158, 11, .35);
  color: rgb(253, 230, 138);
}

/* =========================
   Prompt vars + form
   ========================= */

.vars {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}

.chip {
  background: rgb(12, 20, 35);
  border: 1px dashed var(--border);
  padding: 2px 6px;
  border-radius: 8px;
  color: rgb(203, 213, 225);
}

textarea.prompt {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  border: 1px solid var(--border);
  background: rgb(12, 20, 35);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.vars-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 8px 0;
}

.vars-form label {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.vars-form input {
  border: 1px solid var(--border);
  background: rgb(12, 20, 35);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px;
}

/* =========================
   Buttons / actions
   ========================= */


.btn {
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgb(12, 20, 35);
  color: rgb(203, 213, 225);
}

.btn.copy {
  background: var(--cta);
  color: #fff;
  border-color: var(--cta-shadow);
  box-shadow: 0 3px 0 var(--cta-shadow);
}

.btn.btn-primary {
  background: linear-gradient(135deg, var(--cta-grad-start), var(--cta-grad-end));
  color: rgb(230, 240, 255);
  border: 1px solid var(--cta-shadow);
  box-shadow:
    0 8px 18px rgba(0, 0, 0, .28),
    0 0 12px rgba(59, 130, 246, .35);
  transition: transform .12s, box-shadow .2s, background .2s;
}

.btn.btn-ghost {
  background: transparent;
  color: rgb(191, 219, 254);
  border: 1px solid rgba(59, 130, 246, .35);
  text-decoration: none;
}



/* =========================
   Level picker
   ========================= */

.level-picker {
  margin: 18px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.level-btn {
  background: rgba(59, 130, 246, .15);
  border: 1px solid rgba(59, 130, 246, .35);
  color: rgb(191, 219, 254);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
}

.level-btn[data-level="easy"] {
  background: rgba(34, 197, 94, .15);
  border-color: rgba(34, 197, 94, .35);
  color: rgb(187, 247, 208);
}

.level-btn[data-level="hard"] {
  background: rgba(245, 158, 11, .15);
  border-color: rgba(245, 158, 11, .35);
  color: rgb(253, 230, 138);
}

/* =========================
   Footer
   ========================= */

footer {
  margin-top: 18px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

footer a {
  color: rgb(250, 250, 255) !important;
  text-decoration-color: rgba(250, 250, 255, .7);
}

/* =========================
   Tech background layers
   ========================= */

.tech-bg,
.tech-hex,
.tech-map,
.tech-traces,
.tech-glow,
.tech-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.tech-hex {
  right: -40vw;
  top: 0;
  width: 200vw;
  height: 120vh;
  opacity: .2;
  animation: tech-drift 120s linear infinite;
}

.tech-map {
  opacity: .18;
}

.tech-traces {
  inset-inline: 0;
  bottom: 0;
  height: 55vh;
}

.tech-glow {
  left: 50%;
  top: 33%;
  transform: translate(-50%, -50%);
  width: 60vmin;
  height: 60vmin;
  border-radius: 9999px;
  filter: blur(28px);
  background: radial-gradient(
    circle,
    rgba(59, 130, 246, .25),
    rgba(59, 130, 246, .08) 45%,
    transparent 60%
  );
}



/* =========================
   Animations
   ========================= */

@keyframes wiggle {
  0% {
    transform: rotate(0deg) translateY(0);
  }
  25% {
    transform: rotate(-5deg) translateY(-1px);
  }
  50% {
    transform: rotate(0deg) translateY(0);
  }
  75% {
    transform: rotate(5deg) translateY(-1px);
  }
  100% {
    transform: rotate(0deg) translateY(0);
  }
}

@keyframes drift {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes tech-drift {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-10%);
  }
}

@keyframes tech-floatY {
  0%,
  100% {
    transform: translateY(-2px);
  }
  50% {
    transform: translateY(2px);
  }
}

@keyframes tech-twinkle {
  0%,
  100% {
    opacity: .45;
  }
  50% {
    opacity: 1;
  }
}

@keyframes fadeSlide {
  0% {
    opacity: 0;
    transform: translateY(14px);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes soup-steam {
  0% {
    transform: translate(-50%, 0) scale(.6);
    opacity: .6;
  }
  100% {
    transform: translate(-50%, -100px) scale(1.4);
    opacity: 0;
  }
}

@keyframes soup-bub {
  0% {
    transform: translateY(20px) scale(.4);
    opacity: 0;
  }
  30% {
    opacity: .9;
  }
  100% {
    transform: translateY(-60px) scale(1);
    opacity: 0;
  }
}

@keyframes soup-pop {
  0% {
    transform: scale(.9);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes soup-shake {
  10%,
  90% {
    transform: translateX(-1px);
  }
  20%,
  80% {
    transform: translateX(2px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-4px);
  }
  40%,
  60% {
    transform: translateX(4px);
  }
}

@keyframes sidebarPulse {
  0%,
  100% {
    box-shadow:
      0 3px 0 var(--cta-shadow),
      0 0 12px rgba(59, 130, 246, .3);
  }
  50% {
    box-shadow:
      0 4px 0 var(--cta-shadow),
      0 0 20px rgba(59, 130, 246, .55),
      inset 0 0 30px rgba(104, 181, 255, .25);
  }
}

@keyframes debug-pulse {
  0% {
    transform: translateY(0);
    box-shadow: 0 8px 24px rgba(59, 130, 246, .28);
  }
  50% {
    transform: translateY(-2px);
    box-shadow: 0 14px 40px rgba(59, 130, 246, .45);
  }
  100% {
    transform: translateY(0);
    box-shadow: 0 8px 24px rgba(59, 130, 246, .28);
  }
}

/* =========================
   A11y + reduced motion
   ========================= */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 1px 1px);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* Page-scoped a11y for library links */
.library-page a {
  color: #fcfcff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.library-page a:visited {
  color: #eaeaff;
}

.library-page a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* =========================
   Form elements
   ========================= */

select,
textarea {
  width: 100%;
  background: rgb(12, 20, 35);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
  appearance: none;
}

select {
  background-image:
    linear-gradient(45deg, transparent 50%, rgb(147, 197, 253) 50%),
    linear-gradient(135deg, rgb(147, 197, 253) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 3px),
    calc(100% - 11px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

option {
  background: rgb(12, 20, 35);
  color: var(--ink);
}

/* =========================
   Library page spacing
   ========================= */

body.library-page {
  padding-top: 56px;
}

.lib-notice {
  margin-top: 16px;
  margin-bottom: 24px;
}

/* Below-the-fold performance */
.defer-chunk {
  content-visibility: auto;
  contain-intrinsic-size: 800px 1px;
}


/* =========================
   Techy title
   ========================= */

.techy-title {
  color: var(--fx-blue);
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.12;
  text-shadow:
    0 0 12px rgba(77, 166, 255, .35),
    0 0 24px rgba(77, 166, 255, .2);
}

/* =========================
   Login toast
   ========================= */

.login-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 99999;
  transform: translate(-50%, -40%) scale(.92);
  opacity: 0;
  visibility: hidden;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--card, #020617) 80%, var(--cta, #38bdf8) 20%);
  border: 1px solid color-mix(in srgb, var(--border, #1f2937) 60%, var(--cta, #38bdf8) 40%);
  color: var(--ink, #e5e7eb);
  box-shadow:
    0 0 0 1px rgba(56, 189, 248, .25),
    0 18px 45px rgba(15, 23, 42, .65),
    0 0 36px rgba(56, 189, 248, .45);
  font-size: 1.05rem;
  letter-spacing: .02em;
  pointer-events: none;
  transition: opacity .35s ease-out,
    transform .35s cubic-bezier(.18, .89, .32, 1.28);
}

.login-toast.is-visible {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

/* =========================
   Misc
   ========================= */

.muted {
  color: var(--muted);
}

html,
body {
  overflow-x: hidden;
}

/* Responsive tweaks */

@media (max-width: 980px) {
  header {
    backdrop-filter: none;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 18px;
  }

  #controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .level-btn {
    flex: 1 1 auto;
  }

 

  main {
    padding-top: 40px;
  }

  .techy-title {
    margin-top: 1.25rem;
    margin-bottom: .75rem;
    font-size: 1.75rem;
    line-height: 1.2;
    text-align: center;
    text-shadow: 0 0 18px rgba(80, 140, 255, .25);
  }

  .card {
    width: 100%;
    margin: 12px 0;
    padding: 16px;
    border-radius: 18px;
    overflow-wrap: anywhere;
  }

  .hero {
    padding-top: 0px;
    padding-bottom: 20px;
  }

  .btn,
  button,
  .chip {
    min-height: 42px;
    padding: 10px 14px;
  }

  body {
    font-size: 1rem;
    line-height: 1.6;
  }

 
.tech-bg,
.tech-map,
.tech-hex,
.tech-glow,
.tech-particles {
  position: fixed !important;
  inset: 0 !important;
  z-index: -9999 !important;   /* FORCE behind everything */
  pointer-events: none !important;
}

/* FORCE toast above EVERYTHING */
#login-toast,
#logout-toast {
  position: fixed !important;
  z-index: 999999999 !important; /* nine 9s */
}
}
.btn.btn-primary {
    background: rgb(0, 7, 19) !important;
    color: rgb(250, 250, 255) !important;
    border-color: rgb(0, 24, 51) !important;
}

.btn.btn-ghost {
    background: transparent !important;
    color: rgb(191, 219, 254) !important;
    border: 1px solid rgba(59, 130, 246, 0.35)!important;
    text-decoration: none !important;
}

/* Cookie banner styles */

  .cookie-banner {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    max-width: 600px;
    width: 90%;
    background: #1f2937;
    color: #f9fafb;
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid #4b5563;
    font-size: 0.9rem;
    z-index: 9999;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  }
  .cookie-banner button {
    margin-right: 0.5rem;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
  }
  #acceptCookies { background: #22c55e; color: #022c22; font-weight: 600; }
  #rejectCookies { background: #4b5563; color: #f3f4f6; }

  /* Streak toast styles */

.toast.streak-toast {
  position: fixed;
  right: 1.25rem;
  bottom: 5.5rem;
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
  color: var(--ink);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
  z-index: 1200;
}
.toast.streak-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Global streak badge – top-left under nav */
.streak-badge {
  position: fixed;
  left: 1rem;
  top: 4.25rem; /* sits just under your navbar */
  z-index: 1100;

  display: inline-flex;
  align-items: center;
  gap: 0.4rem;

  padding: 0.35rem 0.75rem;
  border-radius: 999px;

  background: rgba(15, 22, 37, 0.95); /* var(--card) vibe */
  border: 1px solid var(--border);
  box-shadow: var(--shadow);

  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 600;

  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition:
    opacity 160ms ease-out,
    transform 160ms ease-out;
}

.streak-badge.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.streak-badge .streak-emoji {
  font-size: 1rem;
}

.streak-badge .streak-text {
  white-space: nowrap;
}

/* Slightly nudge position on big screens if you want */
@media (min-width: 1024px) {
  .streak-badge {
    left: 1.5rem;
    top: 4.5rem;
  }
}

/* Utility */
.hidden {
  display: none !important;
}
.streak-badge.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.streak-badge.hidden {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}
/* Streak toast styles */

.toast.streak-toast {
  position: fixed;
  right: 1.25rem;
  bottom: 5.5rem;
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
  color: var(--ink);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
  z-index: 1200;
}
.toast.streak-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Global streak badge – top-left under nav */
/* Global Streak + XP container – fixed under nav */
#streak-container {
  position: fixed;
  top: 4.25rem;   /* just under your navbar */
  left: 1rem;
  z-index: 1100;

  display: flex;
  align-items: center;
  gap: 0.5rem;    /* space between streak + XP */
}

/* Streak badge pill */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;

  padding: 0.35rem 0.75rem;
  border-radius: 999px;

  background: rgba(15, 22, 37, 0.95); /* var(--card) vibe */
  border: 1px solid var(--border);
  box-shadow: var(--shadow);

  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 600;

  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition:
    opacity 160ms ease-out,
    transform 160ms ease-out;
}

.streak-badge.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.streak-badge .streak-emoji {
  font-size: 1rem;
}

.streak-badge .streak-text {
  white-space: nowrap;
}

/* Utility hidden */
.hidden {
  display: none !important;
}

/* Slightly nudge position on big screens if you want */
@media (min-width: 1024px) {
  .streak-badge {
    left: 1.5rem;
    top: 4.5rem;
  }
}

/* Utility */
.hidden {
  display: none !important;
}
.streak-badge.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.streak-badge.hidden {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}
/* Global Streak + XP container – fixed under nav, top-right */
#streak-container {
  position: fixed;
  top: 4.25rem;      /* just under navbar */
  right: 1rem;       /* move to right side */
  left: auto;
  z-index: 1100;

  display: flex;
  align-items: center;
  gap: 0.5rem;       /* space between streak + XP */
}
/* Global Streak + XP container – full row under nav */
#streak-container {
  position: fixed;
  top: 4.6rem;           /* just under navbar */
  left: 0;
  right: 0;
  z-index: 950;          /* below nav (1000), above content */

  display: flex;
  align-items: center;
  justify-content: space-between;  /* streak left, XP right */
  padding: 0 1.25rem;   /* match page padding */
}
/* Desktop: keep streak + XP aligned with main content width */
@media (min-width: 980px) {
  #streak-container {
    max-width: 1120px;        /* match your site shell width */
    margin: 0 auto;           /* center it */
    padding-left: 1.25rem;    /* same as your SiteShell left padding */
    padding-right: 1.25rem;   /* same as your SiteShell right padding */
  }
}


@media (max-width: 640px) {
  #streak-container {
    top: 4.1rem;
    padding: 0 0.9rem;
  }
  

  .streak-badge {
    max-width: 70%;
  }

  #xp-total-pill {
    flex-shrink: 0;
  }
}
/* XP pill specific styling */
#xp-total-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 0.35rem 0.75rem;
  border-radius: 999px;

  background: rgba(15, 22, 37, 0.95);   /* match streak badge / card vibe */
  border: 1px solid var(--border);
  box-shadow: var(--shadow);

  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
