/* ============================================
   Librapp - Design System (Festa Theme)
   ============================================ */

/* === Theme Variables === */
:root {
  --blue: #0077b6;
  --blue-light: #00a8e8;
  --green: #00c853;
  --green-light: #69f0ae;
  --purple: #6b46c1;
  --purple-light: #b39ddb;
  --orange: #ff6b35;
  --orange-light: #ff9a56;
  --pink: #ff3366;
  --pink-light: #ff6b8a;
  --yellow: #ffd600;
  --red: #ef4444;

  --grad-festa: linear-gradient(135deg, var(--orange) 0%, var(--pink) 100%);
  --grad-festa-subtle: linear-gradient(135deg, rgba(255,107,53,0.08) 0%, rgba(255,51,102,0.08) 100%);
  --grad-blue: linear-gradient(135deg, var(--blue) 0%, var(--blue-light) 100%);
  --grad-green: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
  --grad-purple: linear-gradient(135deg, var(--purple) 0%, var(--purple-light) 100%);
}

/* Light Theme (default) */
[data-theme="light"],
:root {
  --bg: #fff8f5;
  --bg-card: #ffffff;
  --bg-elevated: #fff0eb;
  --surface: #ffffff;
  --surface-hover: #fff5f0;
  --border: #ffe0d4;
  --border-strong: #ffc8b8;
  --fg: #2d1b14;
  --fg-soft: #5c4036;
  --muted: #9e7a6e;
  --muted-dark: #7a5e54;
  --shadow-sm: 0 1px 3px rgba(255,107,53,0.1);
  --shadow-md: 0 4px 16px rgba(255,107,53,0.12);
  --shadow-lg: 0 8px 32px rgba(255,107,53,0.15);
  --shadow-card: 0 6px 24px rgba(255,107,53,0.12);
  --overlay: rgba(45,27,20,0.5);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg: #0f0a08;
  --bg-card: #1a1210;
  --bg-elevated: #241814;
  --surface: #1a1210;
  --surface-hover: #2a1c16;
  --border: #3d2a22;
  --border-strong: #5a3d32;
  --fg: #f5e8e2;
  --fg-soft: #cbb5ab;
  --muted: #8a7064;
  --muted-dark: #6b554a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
  --shadow-card: 0 6px 24px rgba(0,0,0,0.5);
  --overlay: rgba(0,0,0,0.7);
}

/* === Typography === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;600;700;800&display=swap');

:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", monospace;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 999px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 200ms;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

a {
  color: var(--blue);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}

a:hover {
  color: var(--orange);
}

img {
  max-width: 100%;
  height: auto;
}

/* === Header === */
.header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.logo {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.logo b {
  background: var(--grad-festa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header-nav {
  margin-left: auto;
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.header-nav a {
  color: var(--muted);
  font-size: 0.85rem;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: all var(--duration) var(--ease);
}

.header-nav a:hover {
  color: var(--fg);
  background: var(--surface-hover);
}

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted);
  transition: all var(--duration) var(--ease);
}

.theme-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--orange);
  color: var(--orange);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  text-decoration: none;
  line-height: 1.2;
}

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

.btn-primary {
  background: var(--grad-festa);
  color: #fff;
  box-shadow: 0 4px 14px rgba(255,107,53,0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255,107,53,0.4);
}

.btn-secondary {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-accent {
  background: var(--green);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0,200,83,0.3);
}

.btn-accent:hover {
  background: #00b84a;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,200,83,0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  color: var(--fg);
  background: var(--surface-hover);
  border-color: var(--border);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: 1.15rem;
  border-radius: var(--radius-lg);
}

.btn-xl {
  padding: var(--space-lg) var(--space-2xl);
  font-size: 1.3rem;
  border-radius: var(--radius-xl);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

/* === Card Component === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--duration) var(--ease);
  box-shadow: var(--shadow-sm);
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.card-flat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

/* === Badges === */
.badge {
  font-family: var(--display);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  border-radius: var(--radius-full);
  padding: 4px 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-orange {
  background: rgba(255,107,53,0.12);
  color: var(--orange);
}

.badge-blue {
  background: rgba(0,119,182,0.12);
  color: var(--blue);
}

.badge-green {
  background: rgba(0,200,83,0.12);
  color: var(--green);
}

.badge-purple {
  background: rgba(107,70,193,0.12);
  color: var(--purple);
}

/* === Grid === */
.grid {
  display: grid;
  gap: var(--space-md);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* === Container === */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.container-sm {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* === Phase Indicator (shared) === */
.phase-indicator {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.phase-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
  transition: all var(--duration) var(--ease);
}

.phase-dot.active {
  background: var(--orange);
  box-shadow: 0 0 8px rgba(255,107,53,0.5);
}

.phase-dot.completed {
  background: var(--green);
}

/* === Animations === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

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

.fade-in {
  animation: fadeIn 0.4s var(--ease);
}

.slide-up {
  animation: slideUp 0.5s var(--ease);
}

/* === Form Elements === */
.editor-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border-color var(--duration) var(--ease);
}

.editor-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,119,182,0.15);
}

.editor-textarea {
  resize: vertical;
  min-height: 80px;
}

/* === Util === */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--orange); }
.text-blue { color: var(--blue); }
.text-green { color: var(--green); }
.text-purple { color: var(--purple); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.hidden { display: none !important; }
.visible { display: flex !important; }

/* === Icons === */
.icon-lg {
  font-size: 2rem;
}

/* === Print === */
@media print {
  .header, .game-controls, .no-print {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
  }

  .card-flat, .game-card, .phase-panel {
    break-inside: avoid;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }
}

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

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