/* =====================================================================
   iRead design system — "licurici" (firefly) evening reading theme.
   Hand-written CSS, no build step. Mobile-first. Dark mode via
   prefers-color-scheme. All colors live in the token blocks below.
   ===================================================================== */

/* ---------- Self-hosted font (copied by scripts/copy-vendor.mjs) ---------- */
@font-face {
  font-family: "Nunito Variable";
  src: url("/fonts/nunito-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: "Nunito Variable";
  src: url("/fonts/nunito-latin-ext-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Cross-document view transitions are disabled: an aborted transition (a
   redirect landing while the previous transition is still running) leaves the
   page painted blank in Chrome. See public/js/app.js for the htmx side. */

/* ---------- Tokens: light (warm cream day) ---------- */
:root {
  color-scheme: light;

  --bg: #fff8ec;
  --surface: #ffffff;
  --surface-2: #fdf1da;
  --ink: #1e1b4b;
  --muted: #6b6790;
  --line: #eae1cb;

  --brand: #4338ca;
  --on-brand: #ffffff;
  --brand-ink: #4338ca;
  --brand-soft: color-mix(in srgb, #4338ca 9%, transparent);

  --glow: #f5b301;
  --on-glow: #1e1b4b;
  --glow-soft: color-mix(in srgb, #f5b301 18%, transparent);

  --success: #16a34a;
  --success-ink: #15803d;
  --danger: #dc2626;
  --danger-ink: #b91c1c;

  /* Age categories: Începători, Licurici 1, Licurici 2, Exploratori 1, Exploratori 2 */
  --cat-1: #e11d48;
  --cat-1-ink: #be123c;
  --cat-2: #f59e0b;
  --cat-2-ink: #b45309;
  --cat-3: #14b8a6;
  --cat-3-ink: #0f766e;
  --cat-4: #2563eb;
  --cat-4-ink: #1d4ed8;
  --cat-5: #7c3aed;
  --cat-5-ink: #6d28d9;

  --font: "Nunito Variable", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;

  --text-xs: 0.75rem;
  --text-s: 0.875rem;
  --text-m: 1rem;
  --text-l: 1.25rem;
  --text-xl: 1.5rem;

  --radius-s: 12px;
  --radius-m: 16px;
  --radius-l: 20px;

  --shadow-1: 0 1px 2px rgb(30 27 75 / 0.07), 0 4px 14px rgb(30 27 75 / 0.08);
  --shadow-2: 0 10px 30px rgb(30 27 75 / 0.18);

  --tap: 44px; /* minimum touch target */
  --dur: 200ms;

  --field-bg: var(--surface);
  --scrim: rgb(30 27 75 / 0.45);
}

/* ---------- Tokens: dark (night sky, amber glow) ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #100e24;
    --surface: #1b1838;
    --surface-2: #242050;
    --ink: #efecff;
    --muted: #a7a3c9;
    --line: #2e2a55;

    --brand: #8e98fa;
    --on-brand: #17143a;
    --brand-ink: #b9c0ff;
    --brand-soft: color-mix(in srgb, #8e98fa 16%, transparent);

    --glow: #f5b301;
    --on-glow: #1e1b4b;
    --glow-soft: color-mix(in srgb, #f5b301 22%, transparent);

    --success: #4ade80;
    --success-ink: #4ade80;
    --danger: #f87171;
    --danger-ink: #f87171;

    --cat-1: #fb7185;
    --cat-1-ink: #fda4af;
    --cat-2: #fbbf24;
    --cat-2-ink: #fcd34d;
    --cat-3: #2dd4bf;
    --cat-3-ink: #5eead4;
    --cat-4: #60a5fa;
    --cat-4-ink: #93c5fd;
    --cat-5: #a78bfa;
    --cat-5-ink: #c4b5fd;

    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 14px rgb(0 0 0 / 0.35);
    --shadow-2: 0 10px 30px rgb(0 0 0 / 0.55);

    --field-bg: #242050;
    --scrim: rgb(5 4 18 / 0.6);
  }
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text-m);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

input,
button,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  font-weight: 800;
  overflow-wrap: anywhere;
}

h1 {
  font-size: clamp(1.5rem, 4.5vw, 2rem);
}

h2 {
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-l);
}

h4 {
  font-size: var(--text-m);
}

p {
  overflow-wrap: anywhere;
}

a {
  color: var(--brand-ink);
}

::selection {
  background: var(--glow-soft);
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Typography helpers ---------- */
.lede {
  font-size: var(--text-l);
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

/* ---------- Layout utilities ---------- */
.stack > * + * {
  margin-top: var(--gap, 1rem);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap, 0.5rem);
}

.grid {
  display: grid;
  gap: var(--gap, 1rem);
  grid-template-columns: repeat(auto-fill, minmax(min(var(--min, 15rem), 100%), 1fr));
}

.center {
  max-width: 720px;
  margin-inline: auto;
}

/* ---------- Button ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--tap);
  padding: 0.5rem 1.25rem;
  border: 2px solid transparent;
  border-radius: 999px;
  font-weight: 800;
  font-size: var(--text-m);
  text-decoration: none;
  transition: transform var(--dur) ease, background-color var(--dur) ease, color var(--dur) ease,
    border-color var(--dur) ease, box-shadow var(--dur) ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: var(--shadow-1);
}

.btn--primary:hover:not([disabled]) {
  background: color-mix(in srgb, var(--brand) 85%, var(--ink));
}

.btn--secondary {
  border-color: var(--brand);
  color: var(--brand-ink);
  background: transparent;
}

.btn--secondary:hover:not([disabled]) {
  background: var(--brand-soft);
}

.btn--ghost {
  background: transparent;
  color: var(--brand-ink);
}

.btn--ghost:hover:not([disabled]) {
  background: var(--brand-soft);
}

.btn--danger {
  background: var(--danger);
  color: #fff;
}

.btn--glow {
  background: var(--glow);
  color: var(--on-glow);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--glow) 45%, transparent);
}

.btn--icon {
  width: var(--tap);
  padding: 0;
  border-radius: 50%;
}

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-1);
}

/* ---------- Form field ---------- */
.field {
  display: grid;
  gap: 0.375rem;
}

.field__label {
  font-size: var(--text-s);
  font-weight: 800;
}

.field__hint {
  font-size: var(--text-s);
  color: var(--muted);
}

.field__error {
  font-size: var(--text-s);
  font-weight: 700;
  color: var(--danger-ink);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.5rem 0.875rem;
  background: var(--field-bg);
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: var(--radius-s);
  transition: border-color var(--dur) ease;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted);
}

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: var(--brand);
}

.field--error .input,
.field--error .select,
.field--error .textarea {
  border-color: var(--danger);
}

.textarea {
  min-height: 6rem;
  resize: vertical;
}

.select {
  appearance: none;
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6790' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
}

/* ---------- Segmented toggle ---------- */
.seg {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--ink) 7%, var(--surface));
}

.seg__item {
  flex: 1;
  display: flex;
}

.seg__item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg__item span {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  padding: 0 0.75rem;
  border-radius: calc(var(--radius-s) - 4px);
  font-weight: 800;
  color: var(--muted);
  transition: background-color var(--dur) ease, color var(--dur) ease, box-shadow var(--dur) ease;
}

.seg__item input:checked + span {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

.seg__item input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent);
  outline-offset: 1px;
}

/* ---------- Chips (selectable) ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  position: relative;
  display: inline-flex;
}

.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip span {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 1rem;
  border: 2px solid var(--line);
  border-radius: 999px;
  font-weight: 800;
  background: var(--surface);
  transition: background-color var(--dur) ease, color var(--dur) ease, border-color var(--dur) ease;
}

.chip input:checked + span {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}

.chip input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent);
  outline-offset: 2px;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: thin;
}

.tabs__tab {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 1rem;
  border-radius: 999px;
  font-weight: 800;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur) ease, color var(--dur) ease;
}

.tabs__tab:hover {
  background: var(--brand-soft);
}

.tabs__tab[aria-selected="true"],
.tabs__tab[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

/* ---------- List row ---------- */
.rows {
  display: grid;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.25rem;
  border-bottom: 1px solid var(--line);
}

.rows .row:last-child {
  border-bottom: 0;
}

.row__main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 0.125rem;
}

.row__title {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.row__sub {
  font-size: var(--text-s);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.row__end {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ---------- Stat tile ---------- */
.stat {
  display: grid;
  gap: 0.25rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}

.stat__value {
  font-size: var(--text-xl);
  font-weight: 800;
  line-height: 1.2;
}

.stat__label {
  font-size: var(--text-s);
  font-weight: 700;
  color: var(--muted);
}

/* ---------- Progress bar ---------- */
.progress {
  height: 0.625rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 10%, var(--surface));
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  width: calc(var(--value, 0) * 1%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--glow));
  transition: width var(--dur) ease;
}

/* ---------- Badge ---------- */
.badge {
  --badge-bg: var(--brand-soft);
  --badge-fg: var(--brand-ink);
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 1.75rem;
  padding: 0.125rem 0.625rem;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 800;
  background: var(--badge-bg);
  color: var(--badge-fg);
}

.badge__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}

.badge--cat-1 {
  --badge-bg: color-mix(in srgb, var(--cat-1) 14%, var(--surface));
  --badge-fg: var(--cat-1-ink);
}

.badge--cat-2 {
  --badge-bg: color-mix(in srgb, var(--cat-2) 16%, var(--surface));
  --badge-fg: var(--cat-2-ink);
}

.badge--cat-3 {
  --badge-bg: color-mix(in srgb, var(--cat-3) 14%, var(--surface));
  --badge-fg: var(--cat-3-ink);
}

.badge--cat-4 {
  --badge-bg: color-mix(in srgb, var(--cat-4) 14%, var(--surface));
  --badge-fg: var(--cat-4-ink);
}

.badge--cat-5 {
  --badge-bg: color-mix(in srgb, var(--cat-5) 14%, var(--surface));
  --badge-fg: var(--cat-5-ink);
}

.badge--success {
  --badge-bg: color-mix(in srgb, var(--success) 15%, var(--surface));
  --badge-fg: var(--success-ink);
}

.badge--danger {
  --badge-bg: color-mix(in srgb, var(--danger) 13%, var(--surface));
  --badge-fg: var(--danger-ink);
}

.badge--glow {
  --badge-bg: var(--glow-soft);
  --badge-fg: var(--on-glow);
  background: var(--glow);
}

/* ---------- Avatar (initials) ---------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 800;
  font-size: var(--text-s);
}

.avatar--sm {
  width: 2rem;
  height: 2rem;
  font-size: var(--text-xs);
}

.avatar--lg {
  width: 3.5rem;
  height: 3.5rem;
  font-size: var(--text-l);
}

/* ---------- Toast ---------- */
.toast-region {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(5.5rem + env(safe-area-inset-bottom));
  z-index: 80;
  width: min(92vw, 26rem);
  display: grid;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-2);
  border-inline-start: 4px solid var(--muted);
  pointer-events: auto;
  animation: toast-in var(--dur) ease;
}

.toast--success {
  border-inline-start-color: var(--success);
}

.toast--danger {
  border-inline-start-color: var(--danger);
}

.toast__msg {
  flex: 1;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.toast__undo {
  border: 0;
  background: transparent;
  color: var(--glow);
  font-weight: 800;
  padding: 0.5rem;
  border-radius: var(--radius-s);
  min-height: var(--tap);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

/* ---------- Bottom sheet (native <dialog>) ---------- */
dialog.sheet {
  width: 100%;
  max-width: 34rem;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}

dialog.sheet::backdrop {
  background: var(--scrim);
  backdrop-filter: blur(2px);
}

.sheet__panel {
  max-height: min(85dvh, 40rem);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  padding: 0.5rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
  animation: sheet-up var(--dur) ease;
}

.sheet__grab {
  width: 2.5rem;
  height: 0.25rem;
  margin: 0.375rem auto 0.5rem;
  border-radius: 999px;
  background: var(--line);
}

.sheet__head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.25rem 0 0.75rem;
  background: var(--surface);
}

.sheet__title {
  font-size: var(--text-l);
}

@keyframes sheet-up {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
}

/* ---------- App shell: top bar + bottom nav ---------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.5rem;
  padding: 0.5rem 1rem;
  padding-top: calc(0.5rem + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar__title {
  font-size: var(--text-l);
  font-weight: 800;
}

.topbar__end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app__main {
  flex: 1;
  width: min(100% - 2rem, 720px);
  margin-inline: auto;
  padding: 1rem 0 6.5rem;
}

.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  padding: 0.25rem 0.5rem calc(0.25rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}

.bottomnav__item {
  display: grid;
  justify-items: center;
  gap: 0.125rem;
  min-height: var(--tap);
  padding: 0.25rem 0.25rem 0.375rem;
  border-radius: var(--radius-s);
  color: var(--muted);
  text-decoration: none;
  font-size: var(--text-xs);
  font-weight: 800;
  transition: color var(--dur) ease;
}

.bottomnav__item svg {
  width: 1.5rem;
  height: 1.5rem;
}

.bottomnav__item[aria-current="page"] {
  color: var(--brand-ink);
}

.bottomnav__fab {
  justify-self: center;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--brand) 45%, transparent);
  transform: translateY(-1.25rem);
  transition: transform var(--dur) ease;
}

.bottomnav__fab:hover {
  transform: translateY(calc(-1.25rem - 2px));
}

.bottomnav__fab svg {
  width: 1.75rem;
  height: 1.75rem;
}

.bottomnav__fab-label {
  display: none;
}

/* Desktop: nav moves to the top under the top bar; FAB becomes a labeled button */
@media (min-width: 900px) {
  .bottomnav {
    position: static;
    order: 1;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-top: 0;
    border-bottom: 1px solid var(--line);
  }

  .app__main {
    order: 2;
    padding-bottom: 2rem;
  }

  .bottomnav__item {
    grid-auto-flow: column;
    grid-template-columns: none;
    align-items: center;
    display: inline-grid;
    gap: 0.5rem;
    padding: 0.25rem 1rem;
  }

  .bottomnav__item svg {
    width: 1.25rem;
    height: 1.25rem;
  }

  .bottomnav__fab {
    width: auto;
    height: 2.75rem;
    margin: 0 0.5rem;
    gap: 0.5rem;
    padding: 0 1.25rem;
    border-radius: 999px;
    transform: none;
  }

  .bottomnav__fab:hover {
    transform: translateY(-2px);
  }

  .bottomnav__fab svg {
    width: 1.25rem;
    height: 1.25rem;
  }

  .bottomnav__fab-label {
    display: inline;
  }
}

/* ---------- Empty state ---------- */
.empty {
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  padding: 2.5rem 1rem;
  text-align: center;
}

.empty__art {
  display: grid;
  place-items: center;
  width: 6rem;
  height: 6rem;
  margin-bottom: 0.5rem;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 32%, var(--glow) 0 9%, transparent 10%),
    radial-gradient(circle at 68% 22%, color-mix(in srgb, var(--glow) 70%, white) 0 6%, transparent 7%),
    radial-gradient(circle at 72% 68%, var(--glow) 0 7%, transparent 8%),
    radial-gradient(circle at 50% 50%, var(--glow-soft), transparent 70%),
    var(--brand-soft);
}

.empty__art svg {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--brand-ink);
}

.empty__title {
  font-size: var(--text-l);
  font-weight: 800;
}

.empty__text {
  max-width: 36ch;
  color: var(--muted);
}

/* ---------- Skeleton shimmer ---------- */
.skeleton {
  min-height: 1rem;
  border-radius: var(--radius-s);
  background: linear-gradient(
    100deg,
    color-mix(in srgb, var(--ink) 6%, var(--surface)) 40%,
    color-mix(in srgb, var(--ink) 12%, var(--surface)) 50%,
    color-mix(in srgb, var(--ink) 6%, var(--surface)) 60%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---------- Landing page ---------- */
.landing {
  display: grid;
  gap: 3.5rem;
  padding: 0 1rem 3rem;
}

.landing section {
  width: min(100%, 720px);
  margin-inline: auto;
}

.hero {
  position: relative;
  overflow: hidden;
  margin-top: 1rem;
  padding: clamp(2rem, 6vw, 3.5rem) clamp(1.25rem, 5vw, 2.5rem);
  border-radius: var(--radius-l);
  color: #fff8ec;
  background:
    radial-gradient(1.5rem 1.5rem at 78% 24%, rgb(245 179 1 / 0.9) 0 18%, transparent 19%),
    radial-gradient(0.9rem 0.9rem at 88% 60%, rgb(245 179 1 / 0.55) 0 28%, transparent 29%),
    radial-gradient(0.6rem 0.6rem at 66% 74%, rgb(245 179 1 / 0.4) 0 40%, transparent 41%),
    radial-gradient(0.5rem 0.5rem at 18% 30%, rgb(255 255 255 / 0.35) 0 45%, transparent 46%),
    radial-gradient(0.35rem 0.35rem at 30% 68%, rgb(255 255 255 / 0.28) 0 50%, transparent 51%),
    radial-gradient(0.4rem 0.4rem at 52% 18%, rgb(255 255 255 / 0.3) 0 50%, transparent 51%),
    linear-gradient(160deg, #1e1b4b 0%, #2a1e5c 45%, #100e24 100%);
}

/* asset: hero */
.hero__art {
  position: absolute;
  inset: auto -20% -30% auto;
  width: 16rem;
  height: 16rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(245 179 1 / 0.22), transparent 65%);
  pointer-events: none;
}

.hero__title {
  max-width: 22ch;
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  line-height: 1.15;
}

.hero__sub {
  max-width: 34ch;
  margin-top: 0.75rem;
  font-size: var(--text-l);
  color: #d9d4f7;
}

.hero__cta {
  margin-top: 1.5rem;
}

/* Secondary button needs light chrome on the dark hero panel */
.hero .btn--secondary {
  border-color: rgb(255 248 236 / 0.55);
  color: #fff8ec;
}

.hero .btn--secondary:hover {
  background: rgb(255 248 236 / 0.14);
}

.step {
  display: grid;
  gap: 0.5rem;
}

.step__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 800;
}

.cat-card {
  display: grid;
  gap: 0.5rem;
  border-top: 6px solid var(--cat);
  padding-top: 1rem;
}

.rule-card {
  display: grid;
  gap: 0.25rem;
  text-align: center;
  justify-items: center;
  padding: 1.5rem 1rem;
}

.rule-card__value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--brand-ink);
}

.rule-card__label {
  color: var(--muted);
  font-weight: 700;
}

.footer {
  padding: 2rem 1rem calc(2rem + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--muted);
  font-size: var(--text-s);
  border-top: 1px solid var(--line);
}

/* ---------- Styleguide helpers ---------- */
.sg-section {
  display: grid;
  gap: 1rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
}

.sg-section__title {
  font-size: var(--text-s);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
  gap: 0.75rem;
}

.swatch {
  display: grid;
  gap: 0.25rem;
  font-size: var(--text-xs);
}

.swatch__color {
  height: 3rem;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Admin ---------- */
.admin__main {
  width: min(100% - 2rem, 1100px);
  margin-inline: auto;
  padding: 1rem 0 2rem;
}

.admin__nav {
  margin: 0 0 1.25rem;
  scrollbar-width: none;
}

.admin__nav::-webkit-scrollbar {
  display: none;
}

.admin__season {
  max-width: 22rem;
  margin-bottom: 1rem;
}

.admin__stats,
.admin__categories {
  --min: 8rem;
}

.admin__tops {
  --min: 16rem;
}

.admin__search {
  max-width: 38rem;
}

/* Mobile: avatar + details stacked, actions on their own wrapping line below */
.admin__user-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.5rem 0.75rem;
  align-items: start;
}

.admin__user-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.admin__user-actions form {
  display: inline-flex;
}

/* >= 700px: table-like row, actions to the right */
@media (min-width: 700px) {
  .admin__user-row {
    display: flex;
    align-items: flex-start;
  }

  .admin__user-actions {
    margin-left: auto;
    padding-top: 0;
    border-top: 0;
    justify-content: flex-end;
  }
}

@media (min-width: 900px) {
  .admin__main {
    padding-top: 2rem;
  }
}

/* =====================================================================
   Task 04 — child screens: book cards, leaderboard, profile, auth pages
   ===================================================================== */

/* htmx indicators + remove-fade */
.htmx-indicator {
  opacity: 0;
  transition: opacity var(--dur) ease;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

.htmx-swapping {
  opacity: 0;
  transition: opacity 150ms ease;
}

/* Live points preview */
.points-preview {
  min-height: 1.5rem;
  font-weight: 800;
  color: var(--brand-ink);
}

/* Quick-value chips (chapter shortcuts) */
.chip-btn {
  min-height: 2.25rem;
  min-width: 2.75rem;
  padding: 0 0.75rem;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 800;
  transition: background-color var(--dur) ease, color var(--dur) ease, border-color var(--dur) ease;
}

.chip-btn:hover:not([disabled]) {
  border-color: var(--brand);
  color: var(--brand-ink);
}

.chip-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Category fieldset around the chips */
.chips-field {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

/* Greeting block on Acasă */
.greeting h1 {
  font-size: var(--text-xl);
}

/* Recent books mini-list on Acasă */
.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.375rem;
}

.recent-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
}

.recent-list__title {
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
}

.recent-list__item .badge {
  flex-shrink: 0;
}

/* Book card (list on Cărțile mele + profil copil) */
.book-card__row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.book-card__open {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  color: inherit;
  text-decoration: none;
}

a.book-card__open:hover .book-card__title {
  color: var(--brand-ink);
}

.book-card__title {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.book-card__date {
  font-size: var(--text-s);
  color: var(--muted);
}

.book-card__end {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

.book-card__end form {
  display: inline-flex;
}

.book-card__end .btn--icon {
  color: var(--muted);
}

.book-card__end .btn--icon:hover {
  color: var(--danger);
}

.book-card__review,
blockquote.book-card__review {
  margin: 0.625rem 0 0;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--ink) 4%, var(--surface));
  font-size: var(--text-s);
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Leaderboard */
.lb {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.375rem;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}

.lb-row--me {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.lb-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: 50%;
  font-weight: 800;
  background: color-mix(in srgb, var(--ink) 7%, var(--surface));
  color: var(--muted);
}

.lb-rank--1 {
  background: var(--glow);
  color: var(--on-glow);
}

.lb-rank--2 {
  background: #b9b5d6;
  color: var(--ink);
}

.lb-rank--3 {
  background: #d98a4a;
  color: #fff;
}

.lb-row__link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: inherit;
  text-decoration: none;
}

.lb-row__text {
  min-width: 0;
  display: grid;
}

.lb-row__name {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.lb-row__church {
  font-size: var(--text-xs);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.lb-row__points {
  flex-shrink: 0;
  font-weight: 800;
  font-size: var(--text-l);
}

/* Sticky "Tu: locul X" bar, under the top bar */
.lb-me {
  position: sticky;
  top: calc(3.5rem + env(safe-area-inset-top));
  z-index: 30;
  margin: 0 0 0.625rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-m);
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  box-shadow: var(--shadow-1);
}

.lb-me strong {
  color: var(--glow);
}

/* Centered card page for auth/onboarding screens */
.auth-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem;
}

.auth-page > .card {
  width: min(100%, 28rem);
}

/* =====================================================================
   Task 06 — illustrations, PWA, celebration
   ===================================================================== */

/* Mascot images: subtle amber glow so transparent WebPs read well on the
   night background (stronger in dark mode). */
.mascot {
  display: block;
}

@media (prefers-color-scheme: dark) {
  .mascot {
    filter: drop-shadow(0 0 14px rgb(245 179 1 / 0.3));
  }
}

/* Category badge images (sizes come from width/height attributes) */
.cat-badge {
  display: inline-block;
  flex-shrink: 0;
}

/* Hero mascot sits in flow at the top of the hero panel */
.hero__mascot {
  width: clamp(6rem, 22vw, 8.5rem);
  height: auto;
  margin-bottom: 0.75rem;
}

/* Step 1 mascot waves from the card corner */
.step {
  position: relative;
}

.step__mascot {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  width: 56px;
  height: 56px;
}

/* Tabs carry a small badge before the name */
.tabs__tab {
  gap: 0.375rem;
}

/* Leaderboard header: tabs + small trophy mascot */
.clasament__head {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.clasament__head .tabs {
  flex: 1;
  min-width: 0;
}

.clasament__trophy {
  flex-shrink: 0;
  margin-top: 0.5rem;
}

/* Category picker as badge tiles (onboarding, inscription, profile) */
.chip--cat input + span {
  flex-direction: column;
  min-height: 0;
  padding: 0.625rem 0.875rem 0.5rem;
  border-radius: var(--radius-m);
  gap: 0.375rem;
}

.chip--cat__inner {
  display: grid;
  justify-items: center;
  gap: 0.375rem;
}

.chip--cat__name {
  font-size: var(--text-s);
  text-align: center;
}

.chip--cat .cat-badge {
  transition: transform var(--dur) ease;
}

.chip--cat input:checked + span .cat-badge {
  transform: scale(1.1);
}

/* Toast mascot */
.toast__mascot {
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
}

/* One-time top-3 celebration card */
.celebrate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  border: 2px solid var(--glow);
  border-radius: var(--radius-l);
  background: linear-gradient(135deg, var(--glow-soft), transparent 70%);
  box-shadow: var(--shadow-1);
  animation: celebrate-in 250ms ease;
}

.celebrate__mascot {
  flex-shrink: 0;
}

.celebrate__text {
  flex: 1;
  min-width: 12rem;
}

.celebrate__text h2 {
  font-size: var(--text-l);
}

@keyframes celebrate-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
}
