/* ============================================================
   CULTURILY — COMPONENT LIBRARY
   Reusable UI components shared across every page.
   Requires global.css to be loaded first.
   ============================================================ */

/* ─────────────────────────────────────────────────────────── */
/* BUTTONS                                                      */
/* ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  border: none;
  transition:
    background-color var(--t-fast) var(--ease),
    color            var(--t-fast) var(--ease),
    border-color     var(--t-fast) var(--ease),
    transform        var(--t-fast) var(--ease),
    box-shadow       var(--t-fast) var(--ease),
    opacity          var(--t-fast) var(--ease);
  user-select: none;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

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

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary — lime fill, dark text */
.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--shadow-accent);
}

/* Culture primary — uses the current culture's accent */
.btn-culture {
  background: var(--culture-accent);
  color: var(--culture-accent-text);
  box-shadow: var(--shadow-sm);
}
.btn-culture:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: var(--shadow-culture);
}

/* Secondary — outline */
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

/* Ghost — text only, no border */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text-primary);
}

/* Danger */
.btn-danger {
  background: var(--error-dim);
  color: var(--error);
  border: 1.5px solid transparent;
}
.btn-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.20);
  border-color: rgba(248, 113, 113, 0.35);
}

/* Surface — raised card-like button */
.btn-surface {
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-surface:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

/* Size modifiers */
.btn-sm {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  border-radius: var(--r-sm);
}

.btn-lg {
  padding: var(--sp-4) var(--sp-8);
  font-size: var(--text-lg);
  border-radius: var(--r-lg);
}

/* Full width */
.btn-full {
  width: 100%;
}

/* Loading spinner inside button */
.btn .btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────── */
/* CARDS                                                        */
/* ─────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  position: relative;
}

.card-md {
  padding: var(--sp-5);
  border-radius: var(--r-xl);
}

.card-lg {
  padding: var(--sp-6);
  border-radius: var(--r-xl);
}

/* Interactive card — hover lift */
.card-hover {
  transition:
    border-color var(--t-base) var(--ease),
    box-shadow   var(--t-base) var(--ease),
    transform    var(--t-base) var(--ease);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.card-hover:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-hover:active {
  transform: translateY(0) scale(0.99);
  box-shadow: var(--shadow-sm);
}

/* Culture-accented card — thin coloured top border */
.card-culture {
  border-top: 2px solid var(--culture-accent);
}

/* Accent card — lime for global UI elements */
.card-accent {
  border-top: 2px solid var(--accent);
}

/* Selected state */
.card-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-accent);
}

.card-selected-culture {
  border-color: var(--culture-accent);
  box-shadow: 0 0 0 1px var(--culture-accent), var(--shadow-culture);
}

/* ─────────────────────────────────────────────────────────── */
/* FORM FIELDS                                                  */
/* ─────────────────────────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  transition:
    border-color var(--t-fast) var(--ease),
    background   var(--t-fast) var(--ease),
    box-shadow   var(--t-fast) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-disabled);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background: var(--surface-3);
}

.form-input.input-error,
.form-select.input-error,
.form-textarea.input-error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px var(--error-dim);
}

.form-input.input-success,
.form-select.input-success {
  border-color: var(--success);
  box-shadow: 0 0 0 3px var(--success-dim);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-subtle);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--error);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.form-textarea {
  resize: vertical;
  min-height: 96px;
}

/* Custom select arrow */
.form-select {
  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='rgba(248,248,248,0.45)' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
  padding-right: var(--sp-8);
  cursor: pointer;
}

.form-select option {
  background: var(--surface-3);
  color: var(--text-primary);
}

/* ── Password input with show/hide toggle ─────────────────── */
.input-password-wrap {
  position: relative;
}
.input-password-wrap .form-input {
  padding-right: var(--sp-10);
}
.input-password-toggle {
  position: absolute;
  right: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--sp-1);
  border-radius: var(--r-sm);
  transition: color var(--t-fast) var(--ease);
}
.input-password-toggle:hover {
  color: var(--text-primary);
}

/* ─────────────────────────────────────────────────────────── */
/* MODAL                                                        */
/* ─────────────────────────────────────────────────────────── */

/* Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--sp-4);
  animation: fadeIn var(--t-base) var(--ease-out) both;
}

/* On larger screens, centre the modal */
@media (min-width: 480px) {
  .modal-overlay {
    align-items: center;
  }
}

/* Sheet */
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-2xl) var(--r-2xl) var(--r-md) var(--r-md);
  width: 100%;
  max-width: var(--app-width);
  max-height: 88dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn var(--t-slow) var(--ease-spring) both;
}

@media (min-width: 480px) {
  .modal {
    border-radius: var(--r-2xl);
    max-height: 80dvh;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-5) 0;
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  border-radius: var(--r-full);
  color: var(--text-subtle);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.modal-close:hover {
  background: var(--surface-4);
  color: var(--text-primary);
}
.modal-close svg {
  width: 16px;
  height: 16px;
}

.modal-body {
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  color: var(--text-muted);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
}

.modal-footer {
  padding: 0 var(--sp-5) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* Close modal by adding .is-closing class before removing from DOM */
.modal.is-closing {
  animation: fadeOut var(--t-base) var(--ease-in) both;
}

/* ─────────────────────────────────────────────────────────── */
/* TOAST NOTIFICATIONS                                          */
/* ─────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: calc(var(--top-bar-h) + var(--sp-3));
  right: var(--sp-4);
  left: var(--sp-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
  align-items: flex-end;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  max-width: min(360px, 100%);
  animation: toastIn 220ms var(--ease-spring) both;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.toast.is-dismissing {
  animation: toastOut 200ms var(--ease-in) both;
}

.toast-icon {
  font-size: var(--text-lg);
  flex-shrink: 0;
  line-height: 1;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--error); }
.toast-info    { border-left: 3px solid var(--info); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-accent  { border-left: 3px solid var(--accent); }

/* ─────────────────────────────────────────────────────────── */
/* PROGRESS BAR                                                 */
/* ─────────────────────────────────────────────────────────── */

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: width 400ms var(--ease-out);
  min-width: 4px;
}

/* Culture-coloured progress */
.progress-fill-culture {
  background: var(--culture-accent);
}

/* XP bar variant — thinner */
.progress-track-sm {
  height: 5px;
}

/* Lesson progress bar — shown at top of quiz */
.lesson-progress-track {
  height: 10px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
  box-shadow: var(--shadow-inset);
}

.lesson-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-radius: var(--r-full);
  transition: width 300ms var(--ease-out);
}

/* ─────────────────────────────────────────────────────────── */
/* AVATAR                                                       */
/* ─────────────────────────────────────────────────────────── */
/*
 * Usage:
 *   <div class="avatar avatar--md"
 *        data-initials="JD"
 *        style="--avatar-color: #CCFF00;">
 *   </div>
 *
 * Drop-in illustrated avatar: add <img src="..." alt=""> inside the div.
 * The image covers the initials automatically — no JS or CSS change needed.
 */

.avatar {
  position: relative;
  border-radius: 50%;
  overflow: hidden;
  background-color: var(--avatar-color, var(--surface-3));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
  border: 2px solid var(--border);
}

/* Show initials from data attribute */
.avatar::after {
  content: attr(data-initials);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: calc(var(--avatar-size, 40px) * 0.36);
  color: #0e0e0e;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  z-index: 1;
}

/* When an <img> is present it covers the initials */
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}

/* Size variants */
.avatar--2xs { --avatar-size: 20px; width: 20px; height: 20px; border-width: 1px; }
.avatar--xs  { --avatar-size: 28px; width: 28px; height: 28px; border-width: 1px; }
.avatar--sm  { --avatar-size: 36px; width: 36px; height: 36px; }
.avatar--md  { --avatar-size: 44px; width: 44px; height: 44px; }
.avatar--lg  { --avatar-size: 60px; width: 60px; height: 60px; border-width: 3px; }
.avatar--xl  { --avatar-size: 84px; width: 84px; height: 84px; border-width: 3px; }
.avatar--2xl { --avatar-size: 112px; width: 112px; height: 112px; border-width: 4px; }

/* Culture border on avatar */
.avatar-culture { border-color: var(--culture-accent); }
.avatar-accent  { border-color: var(--accent); }

/* Online dot indicator */
.avatar-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}
.avatar-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  background: var(--success);
}

/* ─────────────────────────────────────────────────────────── */
/* GAME UI CHIPS                                               */
/* Hearts · Gems · XP · Streak                                 */
/* ─────────────────────────────────────────────────────────── */

.game-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--text-sm);
  line-height: 1;
  white-space: nowrap;
}

.game-chip-icon {
  font-size: var(--text-base);
  line-height: 1;
}

/* Heart chip — red */
.hearts-chip { color: #ff6b6b; }
.hearts-chip .game-chip-icon { color: #ff6b6b; }

/* Gem chip — teal/cyan */
.gems-chip   { color: #34d4f0; }
.gems-chip .game-chip-icon { color: #34d4f0; }

/* XP chip — lime accent */
.xp-chip     { color: var(--accent); }
.xp-chip .game-chip-icon { color: var(--accent); }

/* Streak chip — orange-red fire */
.streak-chip { color: #ff8c42; }
.streak-chip.is-active .game-chip-icon {
  animation: pulse 1.4s ease-in-out infinite;
  display: inline-block;
}

/* Empty heart */
.heart-empty { opacity: 0.30; }

/* Hearts display row (5 hearts) */
.hearts-row {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

/* ─────────────────────────────────────────────────────────── */
/* STAR RATING                                                  */
/* ─────────────────────────────────────────────────────────── */

.stars-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.star {
  font-size: var(--text-lg);
  line-height: 1;
  color: var(--surface-4);
  transition: color var(--t-base) var(--ease);
}

.star.is-earned {
  color: #fbbf24;
}

/* Lesson card star indicator */
.lesson-stars {
  display: flex;
  gap: 2px;
}
.lesson-star {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface-4);
  transition: background var(--t-base) var(--ease);
}
.lesson-star.is-earned {
  background: #fbbf24;
}

/* ─────────────────────────────────────────────────────────── */
/* BADGE / ACHIEVEMENT CHIP                                     */
/* ─────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px var(--sp-2);
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.badge-accent {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(204, 255, 0, 0.25);
}

.badge-culture {
  background: var(--culture-accent-dim);
  color: var(--culture-accent);
  border: 1px solid color-mix(in srgb, var(--culture-accent) 30%, transparent);
}

.badge-super {
  background: linear-gradient(135deg, rgba(204,255,0,0.15), rgba(96,165,250,0.15));
  color: var(--accent);
  border: 1px solid rgba(204, 255, 0, 0.35);
}

.badge-muted {
  background: var(--surface-3);
  color: var(--text-subtle);
  border: 1px solid var(--border);
}

/* Achievement tile — shown in profile grid */
.achievement-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--surface-2);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  text-align: center;
  transition: border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}

.achievement-tile.is-earned {
  border-color: rgba(251, 191, 36, 0.35);
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.12);
}

.achievement-tile.is-locked {
  opacity: 0.45;
  filter: grayscale(1);
}

.achievement-icon {
  font-size: var(--text-2xl);
  line-height: 1;
}

.achievement-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  line-height: var(--leading-snug);
}

/* ─────────────────────────────────────────────────────────── */
/* SKELETON LOADING                                             */
/* ─────────────────────────────────────────────────────────── */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 50%,
    var(--surface-2) 75%
  );
  background-size: 600px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}

.skeleton-text {
  height: 14px;
  border-radius: var(--r-full);
}

.skeleton-text-sm {
  height: 12px;
  border-radius: var(--r-full);
}

.skeleton-title {
  height: 22px;
  border-radius: var(--r-full);
}

.skeleton-avatar {
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-card {
  border-radius: var(--r-lg);
}

/* ─────────────────────────────────────────────────────────── */
/* LOADING SPINNER                                              */
/* ─────────────────────────────────────────────────────────── */

.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  flex-shrink: 0;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

.spinner-culture {
  border-top-color: var(--culture-accent);
}

/* Full-page loading state */
.page-loading {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--sp-4);
  color: var(--text-subtle);
  font-size: var(--text-sm);
}

/* ─────────────────────────────────────────────────────────── */
/* APP TOP BAR                                                  */
/* ─────────────────────────────────────────────────────────── */

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-bar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  padding-inline: var(--sp-4);
  gap: var(--sp-3);
}

/* Constrain inner content to app width */
.top-bar-inner {
  width: 100%;
  max-width: var(--app-width);
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.top-bar-culture {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  flex-shrink: 0;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  transition: background var(--t-fast) var(--ease);
}
.top-bar-culture:hover {
  background: var(--surface-2);
}

.top-bar-flag {
  font-size: var(--text-xl);
  line-height: 1;
}

.top-bar-culture-name {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

/* Game HUD row — hearts · streak · gems · XP */
.top-bar-hud {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex: 1;
  justify-content: flex-end;
}

/* XP bar below hud (optional alternate layout) */
.top-bar-xp {
  width: 100%;
  max-width: var(--app-width);
  margin-inline: auto;
  padding: 0 var(--sp-4) var(--sp-2);
}

/* ─────────────────────────────────────────────────────────── */
/* BOTTOM NAVIGATION                                            */
/* ─────────────────────────────────────────────────────────── */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-bottom-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: var(--z-sticky);
  display: flex;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-inner {
  display: flex;
  width: 100%;
  max-width: var(--app-width);
  margin-inline: auto;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-subtle);
  transition: color var(--t-fast) var(--ease);
  border: none;
  background: none;
  padding: var(--sp-1) 0;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.bottom-nav-item:hover {
  color: var(--text-muted);
}

.bottom-nav-item.is-active {
  color: var(--accent);
}

.bottom-nav-icon {
  font-size: 22px;
  line-height: 1;
  transition: transform var(--t-spring) var(--ease-spring);
}

.bottom-nav-item.is-active .bottom-nav-icon {
  transform: scale(1.12);
}

.bottom-nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1;
}

/* Active dot indicator */
.bottom-nav-item.is-active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--accent);
  border-radius: var(--r-full);
}

/* Daily challenge badge — notification dot */
.bottom-nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 16px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
  border: 1.5px solid var(--surface);
}

/* ─────────────────────────────────────────────────────────── */
/* EMPTY STATE                                                  */
/* ─────────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  gap: var(--sp-3);
}

.empty-state-icon {
  font-size: 48px;
  line-height: 1;
  animation: float 3s ease-in-out infinite;
}

.empty-state-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
}

.empty-state-body {
  font-size: var(--text-sm);
  color: var(--text-subtle);
  max-width: 260px;
  line-height: var(--leading-relaxed);
}

/* ─────────────────────────────────────────────────────────── */
/* TABS                                                         */
/* ─────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--r-full);
  padding: 3px;
  gap: 2px;
}

.tab-item {
  flex: 1;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-full);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-subtle);
  cursor: pointer;
  text-align: center;
  transition:
    background  var(--t-fast) var(--ease),
    color       var(--t-fast) var(--ease),
    box-shadow  var(--t-fast) var(--ease);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.tab-item:hover:not(.is-active) {
  color: var(--text-muted);
  background: var(--surface-3);
}

.tab-item.is-active {
  background: var(--surface-4);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Scrollable tabs (for more than 3 items) */
.tabs-scroll {
  display: flex;
  gap: var(--sp-1);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: var(--sp-1);
}
.tabs-scroll::-webkit-scrollbar { display: none; }

.tab-pill {
  flex-shrink: 0;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-full);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-subtle);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--t-fast) var(--ease);
  white-space: nowrap;
}
.tab-pill:hover { color: var(--text-muted); }
.tab-pill.is-active {
  color: var(--accent);
  border-color: var(--border-accent);
  background: var(--accent-dim);
}

/* ─────────────────────────────────────────────────────────── */
/* LEADERBOARD ROW                                              */
/* ─────────────────────────────────────────────────────────── */

.lb-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  transition: background var(--t-fast) var(--ease);
}

.lb-row:hover {
  background: var(--surface-2);
}

/* Current user row — always highlighted */
.lb-row.is-self {
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
}

.lb-rank {
  width: 28px;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-subtle);
  text-align: center;
  flex-shrink: 0;
}

/* Top 3 ranks get colour treatment */
.lb-rank-1 { color: #fbbf24; }
.lb-rank-2 { color: #94a3b8; }
.lb-rank-3 { color: #c4793a; }

.lb-name {
  flex: 1;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  min-width: 0;
}

.lb-xp {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--accent);
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────── */
/* STAT TILE                                                    */
/* ─────────────────────────────────────────────────────────── */

.stat-tile {
  background: var(--surface-2);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: var(--leading-tight);
}

.stat-value-sm {
  font-size: var(--text-xl);
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-subtle);
}

/* ─────────────────────────────────────────────────────────── */
/* LEVEL BADGE                                                  */
/* ─────────────────────────────────────────────────────────── */

.level-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  background: var(--surface-3);
  border-radius: var(--r-full);
  border: 1px solid var(--border-strong);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
}

.level-badge .level-number {
  color: var(--accent);
}

/* ─────────────────────────────────────────────────────────── */
/* TOOLTIP                                                      */
/* ─────────────────────────────────────────────────────────── */

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-4);
  color: var(--text-primary);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
  z-index: var(--z-dropdown);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
}

/* ─────────────────────────────────────────────────────────── */
/* CONFIRM DIALOG (simple yes/no modal)                         */
/* ─────────────────────────────────────────────────────────── */

.confirm-dialog .modal-body {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.confirm-dialog .modal-footer {
  flex-direction: row;
  gap: var(--sp-2);
}

.confirm-dialog .modal-footer .btn {
  flex: 1;
}

/* ─────────────────────────────────────────────────────────── */
/* CULTURE CARD (culture select screen)                         */
/* ─────────────────────────────────────────────────────────── */

.culture-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    border-color var(--t-base) var(--ease),
    box-shadow   var(--t-base) var(--ease),
    transform    var(--t-base) var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.culture-card:hover:not(.is-locked) {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.culture-card.is-active {
  border-color: var(--culture-accent);
  box-shadow: 0 0 0 1px var(--culture-accent), var(--shadow-culture);
}

.culture-card.is-locked {
  opacity: 0.55;
  cursor: default;
}

.culture-card-flag {
  font-size: 40px;
  line-height: 1;
  margin-bottom: var(--sp-3);
}

.culture-card-name {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
}

.culture-card-desc {
  font-size: var(--text-sm);
  color: var(--text-subtle);
  line-height: var(--leading-snug);
}

.culture-card-status {
  margin-top: var(--sp-4);
}

/* Accent bar at bottom of culture card */
.culture-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--culture-accent, var(--border));
  opacity: 0;
  transition: opacity var(--t-base) var(--ease);
}
.culture-card.is-active::after,
.culture-card:hover:not(.is-locked)::after {
  opacity: 1;
}
