/* ============================================================
   Xoodle — base.css
   Global design tokens, resets, utilities, animations
   ============================================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

/* ============================================================
   CSS Custom Properties (Design Tokens)
   ============================================================ */
:root {
  --bg: #fef9f0;
  --bg-card: #ffffff;
  --bg-input: #fafafa;
  --primary: #f472b6;
  --primary-dark: #db2777;
  --secondary: #38bdf8;
  --tertiary: #34d399;
  --accent: #a78bfa;
  --warning: #fbbf24;
  --text: #1e1b2e;
  --text-muted: #9ca3af;
  --border: #f0e6ff;
  --shadow: 0 4px 24px rgba(167, 139, 250, 0.12);
  --shadow-lg: 0 8px 40px rgba(167, 139, 250, 0.18);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;

  --font: 'Nunito', sans-serif;
  --transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-fast: all 0.15s ease;
}

/* ============================================================
   CSS Reset
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  font-family: var(--font);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

input, button, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* ============================================================
   Typography Utilities
   ============================================================ */
.text-primary   { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-accent    { color: var(--accent); }
.text-muted     { color: var(--text-muted); }
.text-center    { text-align: center; }
.text-sm        { font-size: 0.875rem; }
.text-xs        { font-size: 0.75rem; }
.text-lg        { font-size: 1.125rem; }
.text-xl        { font-size: 1.25rem; }
.text-2xl       { font-size: 1.5rem; }
.text-3xl       { font-size: 1.875rem; }
.text-4xl       { font-size: 2.25rem; }
.font-bold      { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.font-black     { font-weight: 900; }

/* ============================================================
   Spacing Utilities
   ============================================================ */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* ============================================================
   Flex / Grid Utilities
   ============================================================ */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-1       { flex: 1; }
.grid         { display: grid; }
.hidden       { display: none !important; }
.w-full       { width: 100%; }

/* ============================================================
   Button Styles
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.9375rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  white-space: nowrap;
  user-select: none;
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
}

.btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

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

/* Ripple effect */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.2);
  opacity: 0;
  border-radius: inherit;
  transition: opacity 0.2s;
}

.btn:hover::after {
  opacity: 1;
}

/* Primary Button */
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(244, 114, 182, 0.4);
}

.btn-primary:hover {
  transform: scale(1.03) translateY(-1px);
  box-shadow: 0 6px 20px rgba(244, 114, 182, 0.55);
}

.btn-primary:active {
  transform: scale(0.98) translateY(0);
  box-shadow: 0 2px 10px rgba(244, 114, 182, 0.3);
}

/* Secondary Button */
.btn-secondary {
  background: var(--bg-card);
  color: var(--primary);
  border: 2px solid var(--primary);
  box-shadow: none;
}

.btn-secondary:hover {
  background: rgba(244, 114, 182, 0.08);
  transform: scale(1.02) translateY(-1px);
  box-shadow: 0 4px 12px rgba(244, 114, 182, 0.2);
}

/* Ghost Button */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  box-shadow: none;
}

.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

/* Icon Button */
.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
}

/* Large Button */
.btn-lg {
  font-size: 1.0625rem;
  padding: 13px 28px;
  border-radius: var(--radius);
}

/* Small Button */
.btn-sm {
  font-size: 0.8125rem;
  padding: 6px 14px;
  border-radius: 8px;
}

/* Danger Button */
.btn-danger {
  background: linear-gradient(135deg, #f87171, #ef4444);
  color: #fff;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.35);
}

.btn-danger:hover {
  transform: scale(1.03) translateY(-1px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}

/* Success Button */
.btn-success {
  background: linear-gradient(135deg, var(--tertiary), #10b981);
  color: #fff;
  box-shadow: 0 4px 15px rgba(52, 211, 153, 0.4);
}

.btn-success:hover {
  transform: scale(1.03) translateY(-1px);
  box-shadow: 0 6px 20px rgba(52, 211, 153, 0.55);
}

/* ============================================================
   Card
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 1.5px solid var(--border);
}

.card-sm {
  padding: 16px;
}

.card-lg {
  padding: 36px;
}

/* ============================================================
   Input Styles
   ============================================================ */
.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(244, 114, 182, 0.15);
  background: #fff;
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

/* Textarea */
textarea.input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* Range Input */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(244, 114, 182, 0.5);
  transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(244, 114, 182, 0.5);
}

/* Toggle / Checkbox */
.toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--border);
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

input:checked ~ .toggle-knob {
  transform: translateX(20px);
}

.toggle:has(input:checked) {
  background: var(--primary);
}

/* Select */
select.input {
  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='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

/* ============================================================
   Scrollbar Styling
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(244, 114, 182, 0.35);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(244, 114, 182, 0.35) transparent;
}

/* ============================================================
   Keyframe Animations
   ============================================================ */

/* Bounce In */
@keyframes bounceIn {
  0%   { opacity: 0; transform: scale(0.4) translateY(20px); }
  60%  { opacity: 1; transform: scale(1.1) translateY(-5px); }
  80%  { transform: scale(0.95) translateY(2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Fade In */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Slide Up */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Slide Down */
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Pulse */
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.06); opacity: 0.85; }
}

/* Wiggle */
@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  15%       { transform: rotate(-6deg); }
  30%       { transform: rotate(6deg); }
  45%       { transform: rotate(-4deg); }
  60%       { transform: rotate(4deg); }
  75%       { transform: rotate(-2deg); }
}

/* Float */
@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  33%       { transform: translateY(-18px) rotate(4deg); }
  66%       { transform: translateY(-8px) rotate(-3deg); }
}

/* Float variant */
@keyframes floatAlt {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  33%       { transform: translateY(-12px) rotate(-5deg); }
  66%       { transform: translateY(-22px) rotate(3deg); }
}

/* Spin slow */
@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Count Down */
@keyframes countDown {
  0%   { transform: scale(0.5); opacity: 0; }
  30%  { transform: scale(1.3); opacity: 1; }
  70%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.8); opacity: 0; }
}

/* Score Pop */
@keyframes scorePop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25); }
  70%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}

/* Shake */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}

/* Confetti drop */
@keyframes confettiFall {
  0%   { transform: translateY(-30px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Glow pulse */
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(244, 114, 182, 0.3); }
  50%       { box-shadow: 0 0 25px rgba(244, 114, 182, 0.7), 0 0 50px rgba(244, 114, 182, 0.3); }
}

/* Gradient shift */
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ============================================================
   Animation Utility Classes
   ============================================================ */
.animate-bounceIn   { animation: bounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.animate-fadeIn     { animation: fadeIn 0.3s ease both; }
.animate-slideUp    { animation: slideUp 0.35s ease both; }
.animate-slideDown  { animation: slideDown 0.3s ease both; }
.animate-pulse      { animation: pulse 1.5s ease-in-out infinite; }
.animate-wiggle     { animation: wiggle 0.5s ease; }
.animate-float      { animation: float 6s ease-in-out infinite; }
.animate-floatAlt   { animation: floatAlt 7s ease-in-out infinite; }
.animate-shake      { animation: shake 0.4s ease; }
.animate-scorePop   { animation: scorePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* ============================================================
   Toast System
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: slideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  max-width: 320px;
  min-width: 200px;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: rgba(255,255,255,0.4);
  animation: toastProgress linear forwards;
}

@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}

.toast-exit {
  animation: toastExit 0.3s ease forwards;
}

@keyframes toastExit {
  to { opacity: 0; transform: translateX(110%); }
}

.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.toast-error   { background: linear-gradient(135deg, #f87171, #ef4444); }
.toast-success { background: linear-gradient(135deg, var(--tertiary), #10b981); }
.toast-warning { background: linear-gradient(135deg, var(--warning), #f59e0b); color: var(--text); }
.toast-info    { background: linear-gradient(135deg, var(--accent), #7c3aed); }
.toast-close-guess { background: linear-gradient(135deg, #fb923c, #f97316); }

/* ============================================================
   Badge
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.badge-primary { background: rgba(244, 114, 182, 0.12); color: var(--primary-dark); }
.badge-success { background: rgba(52, 211, 153, 0.12); color: #059669; }
.badge-warning { background: rgba(251, 191, 36, 0.15); color: #b45309; }
.badge-info    { background: rgba(56, 189, 248, 0.12); color: #0369a1; }
.badge-purple  { background: rgba(167, 139, 250, 0.15); color: #6d28d9; }

/* ============================================================
   Avatar
   ============================================================ */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  user-select: none;
}

.avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-lg { width: 52px; height: 52px; font-size: 1.1rem; }
.avatar-xl { width: 72px; height: 72px; font-size: 1.4rem; }

/* Avatar colors */
.avatar-0  { background: linear-gradient(135deg, #f472b6, #db2777); }
.avatar-1  { background: linear-gradient(135deg, #38bdf8, #0284c7); }
.avatar-2  { background: linear-gradient(135deg, #34d399, #059669); }
.avatar-3  { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.avatar-4  { background: linear-gradient(135deg, #fbbf24, #d97706); }
.avatar-5  { background: linear-gradient(135deg, #fb923c, #ea580c); }
.avatar-6  { background: linear-gradient(135deg, #f87171, #dc2626); }
.avatar-7  { background: linear-gradient(135deg, #4ade80, #16a34a); }
.avatar-8  { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.avatar-9  { background: linear-gradient(135deg, #e879f9, #a21caf); }

/* ============================================================
   Overlay / Modal Base
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 27, 46, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.overlay-content {
  width: 100%;
  max-width: 480px;
  animation: bounceIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ============================================================
   Divider
   ============================================================ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  margin: 16px 0;
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================================
   Loading Spinner
   ============================================================ */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spinSlow 0.8s linear infinite;
}

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

/* ============================================================
   Focus Visible Utilities
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Remove default focus on non-keyboard interactions */
:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================================
   Print Reset
   ============================================================ */
@media print {
  body { background: white; }
  .toast, .overlay { display: none !important; }
}
