/* ============================================================
   Læringsspil — delt design-token-system og komponenter
   ============================================================
   Alle farver er hentet fra det farvepalette der allerede var spredt
   ud over appen (header-blå, mønt-guld, sparkle-farverne fra spillene)
   i stedet for at opfinde noget nyt — samlet ét sted her.

   Bruges af alle barn-vendte sider (child.php, shop.php, avatar.php,
   farm.php, friends.php) + login.php. Forælder/admin-siderne
   (dashboard.php, admin/index.php) bruger IKKE denne fil bevidst —
   de er hverdags-værktøjer for voksne, ikke en del af "tegneserie"-
   oplevelsen, og beholder deres nuværende enklere stil.
*/

@font-face {
  font-family: 'Fredoka';
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  src: url('/assets/fonts/fredoka-variable.woff2') format('woff2');
}

:root {
  /* --- Brand (fra eksisterende header-farve) --- */
  --brand: #577590;
  --brand-dark: #3f5a72;
  --brand-light: #7c9db5;

  /* --- Belønning (fra eksisterende mønt-farve) --- */
  --gold: #f9c74f;
  --gold-dark: #dba934;

  /* --- Status (fra eksisterende brug på tværs af appen) --- */
  --success: #43aa8b;
  --success-dark: #35876d;
  --danger: #d64550;

  /* --- Fag-accenter (fra spillenes eksisterende sparkle-paletter) --- */
  --subject-dansk: #ff6b6b;
  --subject-matematik: #4cc9f0;
  --subject-engelsk: #06d6a0;

  /* --- Blad-pynt (dæmpet udgave af engelsk-grøn) --- */
  --leaf: #b9d3a8;
  --leaf-soft: #cfe2c2;

  /* --- Neutraler --- */
  --ink: #33272a;
  --ink-soft: #6b5d60;
  --cream: #fef6e4;
  --cream-deep: #fbecc9;
  --paper: #ffffff;
  --line: #efe1c3;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 2px 0 var(--line), 0 8px 20px -10px rgba(51, 39, 42, 0.25);
}

:root[data-theme="dark"] {
  --brand: #6f93ae;
  --brand-dark: #4d6c85;
  --cream: #241f2b;
  --cream-deep: #2c2635;
  --paper: #322b3a;
  --ink: #f4ecec;
  --ink-soft: #c7b9c2;
  --line: #453b4f;
  --leaf: #3f5741;
  --leaf-soft: #33472f;
  --shadow-card: 0 2px 0 var(--line), 0 8px 20px -10px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #6f93ae;
    --brand-dark: #4d6c85;
    --cream: #241f2b;
    --cream-deep: #2c2635;
    --paper: #322b3a;
    --ink: #f4ecec;
    --ink-soft: #c7b9c2;
    --line: #453b4f;
    --leaf: #3f5741;
    --leaf-soft: #33472f;
    --shadow-card: 0 2px 0 var(--line), 0 8px 20px -10px rgba(0, 0, 0, 0.6);
  }
}

.themed-page * { box-sizing: border-box; }

.themed-page {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.themed-page h1, .themed-page h2, .themed-page h3, .themed-page .display {
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 700;
  text-wrap: balance;
  margin: 0;
}

/* ---------- Header: samme komponent på tværs af ALLE barn-sider ---------- */
.app-header {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  padding: calc(0.9rem + env(safe-area-inset-top)) 1.25rem 1.5rem;
  border-radius: 0 0 28px 28px;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.app-header .identity {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 1 1 auto;
  min-width: 0;
}
.app-header .avatar-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.75), 0 2px 6px rgba(0,0,0,0.2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  overflow: hidden;
}
.app-header .greeting {
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1.15;
  color: #fff;
}
.app-header .greeting small {
  display: block;
  font-family: system-ui, sans-serif;
  font-weight: 500;
  font-size: 0.78rem;
  opacity: 0.85;
  margin-top: 0.15rem;
}
.coin-pill {
  background: var(--gold);
  color: var(--ink);
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.4rem 0.9rem 0.4rem 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 1rem;
  box-shadow: 0 2px 0 var(--gold-dark);
  white-space: nowrap;
}
.nav-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  width: 100%;
}
.nav-pill {
  background: rgba(255,255,255,0.16);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-family: system-ui, sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 40px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}
.nav-pill:hover, .nav-pill:focus-visible { background: rgba(255,255,255,0.28); }
.nav-pill:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.nav-pill .badge-count {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--brand-dark);
}

/* ---------- Layout ---------- */
.themed-page main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  position: relative;
  z-index: 1;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.9rem;
}
.section-head h2 { font-size: 1.15rem; }
.section-head .eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- Chunky "pressable" buttons ---------- */
.btn {
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.3rem;
  cursor: pointer;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(3px); }
.btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 0 var(--brand-dark); }
.btn-primary:active { box-shadow: 0 1px 0 var(--brand-dark); }
.btn-success { background: var(--success); color: #fff; box-shadow: 0 4px 0 var(--success-dark); }
.btn-success:active { box-shadow: 0 1px 0 var(--success-dark); }
.btn-gold { background: var(--gold); color: var(--ink); box-shadow: 0 4px 0 var(--gold-dark); }
.btn-gold:active { box-shadow: 0 1px 0 var(--gold-dark); }
.btn-ghost {
  background: var(--paper);
  color: var(--ink-soft);
  box-shadow: 0 2px 0 var(--line);
  font-family: system-ui, sans-serif;
  font-weight: 600;
}
.btn-ghost:active { box-shadow: 0 1px 0 var(--line); }
.btn:disabled { background: var(--line); color: var(--ink-soft); box-shadow: none; cursor: not-allowed; transform: none; }
/* "Udstyret" er en POSITIV tilstand (allerede aktiv), ikke en spærret en —
   skal ikke se ud som et gråt, blokeret køb-forsøg. */
.btn-equipped {
  background: var(--gold);
  color: var(--ink);
  box-shadow: none;
  cursor: default;
}
.btn-block { width: 100%; }
.btn-sm { padding: 0.45rem 0.9rem; min-height: 38px; font-size: 0.88rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem;
}
.subject-card {
  background: var(--paper);
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  transition: transform 0.1s ease;
}
.subject-card:hover { transform: translateY(-2px); }
.subject-card:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.subject-card .accent-bar { height: 8px; background: var(--accent); }
.subject-card .body { padding: 1.1rem 1.1rem 1.25rem; }
.subject-card .icon-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 18%, var(--paper));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 0.7rem;
}
.subject-card .name {
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.08rem;
}
.subject-card .level {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem;
}
.game-card {
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.4rem 1rem;
  text-align: center;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.1s ease;
  border: none;
  font-family: inherit;
  cursor: pointer;
}
.game-card:hover { transform: translateY(-2px); }
.game-card .icon { font-size: 2.3rem; }
.game-card .name { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700; font-size: 1rem; }

.themed-page footer.page-end { display: flex; justify-content: center; margin-top: 2rem; position: relative; z-index: 1; }

/* ---------- Butik/avatar: avatar-preview + kategori-faner + varekort ---------- */
.preview-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.3rem 1.4rem;
  margin-bottom: 1.6rem;
}
.preview-stage {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--cream-deep);
  box-shadow: inset 0 0 0 4px var(--paper), 0 2px 6px rgba(0,0,0,0.12);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  overflow: hidden;
}
.preview-info .name { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700; font-size: 1.15rem; }
.preview-info p { margin: 0.3rem 0 0; color: var(--ink-soft); font-size: 0.9rem; }

.tab-row {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
  margin-bottom: 1.2rem;
  scrollbar-width: thin;
}
.tab {
  flex: 0 0 auto;
  background: var(--paper);
  color: var(--ink-soft);
  border: none;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-family: system-ui, sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--line);
}
.tab.is-active { background: var(--brand); color: #fff; box-shadow: 0 2px 0 var(--brand-dark); }

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 0.85rem;
}
.item-card {
  padding: 1rem 0.85rem 0.9rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}
.item-card .icon-badge {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--cream-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.1rem;
  overflow: hidden;
}
.item-card .icon-badge img { width: 100%; height: 100%; object-fit: contain; }
.item-card .name { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 600; font-size: 0.92rem; }
.item-card .price {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--brand-dark);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.item-card .lock-note { font-size: 0.72rem; color: var(--danger); font-weight: 600; }

/* ---------- Ambient baggrunds-grafik: bladkviste i de nederste hjørner ---------- */
.leaf-decor {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}
.leaf-decor.bottom-left { bottom: 0; left: 0; width: 150px; height: 150px; transform: translate(-22%, 20%) scaleX(-1); }
.leaf-decor.bottom-right { bottom: 0; right: 0; width: 190px; height: 190px; transform: translate(20%, 18%) rotate(180deg); }
.leaf-sprig { transform-origin: 50% 90%; animation: leaf-sway 7s ease-in-out infinite; }
.leaf-sprig.d2 { animation-delay: -2.3s; animation-duration: 8s; }
.leaf-sprig.d3 { animation-delay: -4.6s; animation-duration: 6.4s; }
@keyframes leaf-sway {
  0%, 100% { transform: rotate(-2.5deg); }
  50% { transform: rotate(2.5deg); }
}
@media (prefers-reduced-motion: reduce) {
  .leaf-sprig { animation: none; }
}

@media (max-width: 420px) {
  .app-header { padding: calc(0.8rem + env(safe-area-inset-top)) 1rem 1.25rem; border-radius: 0 0 22px 22px; }
  .app-header .avatar-circle { width: 48px; height: 48px; font-size: 1.4rem; }
  .app-header .greeting { font-size: 1.08rem; }
  .themed-page main { padding: 1.1rem 0.9rem 2.5rem; }
  .subject-card .body { padding: 0.9rem 0.9rem 1rem; }
  .preview-card { flex-direction: column; text-align: center; gap: 0.8rem; }
  .leaf-decor.bottom-left { width: 108px; height: 108px; }
  .leaf-decor.bottom-right { width: 128px; height: 128px; }
}
