/* ═══════════════════════════════════════════════════════════
   GodotVerse Academy — main.css
   Sistema de diseño global: tokens, reset, tipografía, layout
   ═══════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────── */
:root {
  /* Colors */
  --bg-base:        #080e0a;
  --bg-surface:     #0e1810;
  --bg-raised:      #131f16;
  --bg-hover:       #192818;
  --bg-card:        #111a14;
  --bg-editor:      #0d1610;

  --border-subtle:  #1a2e1e;
  --border-normal:  #243d28;
  --border-accent:  #3a6640;

  --clr-primary:    #6fcf3b;
  --clr-primary-d:  #55a82c;
  --clr-primary-l:  #a0e060;
  --clr-primary-glow: rgba(111,207,59,0.18);

  --clr-yellow:     #ffd166;
  --clr-yellow-d:   #e5b84a;
  --clr-yellow-glow: rgba(255,209,102,0.15);

  --clr-blue:       #56ccf2;
  --clr-blue-d:     #3aabcf;
  --clr-blue-glow:  rgba(86,204,242,0.15);

  --clr-pink:       #f886c2;
  --clr-purple:     #bb86fc;

  --clr-success:    #6fcf3b;
  --clr-error:      #ff6b6b;
  --clr-warning:    #ffd166;
  --clr-info:       #56ccf2;

  --txt-primary:    #e8f5e9;
  --txt-secondary:  #9dc49e;
  --txt-muted:      #5c7c5e;
  --txt-disabled:   #3a4e3b;

  /* Typography */
  --font-ui:        'Outfit', system-ui, sans-serif;
  --font-code:      'JetBrains Mono', 'Fira Code', monospace;

  --text-xs:   0.72rem;
  --text-sm:   0.85rem;
  --text-base: 1rem;
  --text-md:   1.1rem;
  --text-lg:   1.25rem;
  --text-xl:   1.5rem;
  --text-2xl:  1.875rem;
  --text-3xl:  2.25rem;
  --text-4xl:  3rem;

  --weight-light:   300;
  --weight-normal:  400;
  --weight-medium:  500;
  --weight-semi:    600;
  --weight-bold:    700;
  --weight-black:   800;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Radius */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg:   0 8px 24px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 20px var(--clr-primary-glow);
  --shadow-yellow-glow: 0 0 20px var(--clr-yellow-glow);

  /* Layout */
  --sidebar-width:    280px;
  --header-height:    60px;

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow:   400ms ease;
  --transition-bounce: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

body {
  font-family: var(--font-ui);
  background-color: var(--bg-base);
  color: var(--txt-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

img, video, svg { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea { font-family: inherit; }
a { color: var(--clr-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border-accent); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--clr-primary-d); }

/* ── Utility ───────────────────────────────────────────── */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.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; }

.accent { color: var(--clr-primary); }
.muted  { color: var(--txt-muted); }
.yellow { color: var(--clr-yellow); }
.blue   { color: var(--clr-blue); }
.error  { color: var(--clr-error); }
.success { color: var(--clr-success); }

.text-center { text-align: center; }
.text-right  { text-align: right; }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

/* ── Typography ────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-bold);
  line-height: 1.2;
  color: var(--txt-primary);
}
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md); }
h6 { font-size: var(--text-base); }

p { color: var(--txt-secondary); line-height: 1.75; }

code {
  font-family: var(--font-code);
  font-size: 0.88em;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.4em;
  color: var(--clr-primary-l);
}

pre {
  font-family: var(--font-code);
  background: var(--bg-editor);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--txt-primary);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 1em;
  color: inherit;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-weight: var(--weight-semi);
  font-size: var(--text-sm);
  letter-spacing: 0.01em;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  user-select: none;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.06);
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.btn:hover::before { opacity: 1; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--clr-primary);
  color: #0a1a0a;
  box-shadow: 0 0 0 0 var(--clr-primary-glow);
}
.btn-primary:hover {
  background: var(--clr-primary-l);
  box-shadow: 0 0 16px var(--clr-primary-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-raised);
  color: var(--txt-primary);
  border: 1px solid var(--border-normal);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-accent);
}

.btn-yellow {
  background: var(--clr-yellow);
  color: #1a1000;
}
.btn-yellow:hover {
  background: #ffe08a;
  box-shadow: 0 0 16px var(--clr-yellow-glow);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--txt-secondary);
  border: 1px solid var(--border-subtle);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--txt-primary);
  border-color: var(--border-normal);
}

.btn-danger {
  background: rgba(255,107,107,0.15);
  color: var(--clr-error);
  border: 1px solid rgba(255,107,107,0.3);
}
.btn-danger:hover {
  background: rgba(255,107,107,0.25);
}

.btn-sm { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--space-4) var(--space-8); font-size: var(--text-md); border-radius: var(--radius-lg); }

.btn-icon { font-size: 1.1em; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--txt-secondary);
  transition: all var(--transition-fast);
  background: transparent;
  border: 1px solid transparent;
}
.icon-btn:hover {
  background: var(--bg-raised);
  color: var(--txt-primary);
  border-color: var(--border-subtle);
}
.icon-btn svg { width: 18px; height: 18px; }

/* ── Layout ────────────────────────────────────────────── */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  z-index: 100;
  backdrop-filter: blur(12px);
  gap: var(--space-4);
}

#app-body {
  display: flex;
  height: calc(100vh - var(--header-height));
  margin-top: var(--header-height);
  overflow: hidden;
}

/* ── Header parts ─────────────────────────────────────── */
.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
}
.header-right { justify-content: flex-end; }

.logo-small {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--weight-bold);
  font-size: var(--text-md);
  color: var(--txt-primary);
}
.logo-icon { font-size: 1.3em; }
.logo-text .accent { font-weight: var(--weight-black); }

.phase-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--txt-muted);
  font-weight: var(--weight-medium);
}
.breadcrumb-sep { color: var(--border-accent); }
#breadcrumb-phase { color: var(--txt-secondary); }

.xp-display {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--clr-yellow);
}
.xp-icon { font-size: 0.9em; }

.level-badge {
  display: flex;
  align-items: center;
  gap: 2px;
  background: linear-gradient(135deg, var(--clr-primary-d), var(--clr-primary));
  color: #0a1a0a;
  font-weight: var(--weight-black);
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
}

.player-name-display {
  font-weight: var(--weight-semi);
  font-size: var(--text-sm);
  color: var(--txt-secondary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Progress bar ─────────────────────────────────────── */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--bg-raised);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--clr-primary-d), var(--clr-primary-l));
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
  box-shadow: 0 0 8px var(--clr-primary-glow);
}

/* ── Sidebar ───────────────────────────────────────────── */
#phase-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-normal), min-width var(--transition-normal);
}

#phase-sidebar.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.prog-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--txt-muted);
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-2);
}

#sidebar-progress-pct { color: var(--clr-primary); font-weight: var(--weight-bold); }

.bells-display {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--clr-yellow);
  font-weight: var(--weight-semi);
}

.sidebar-phase-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

.sidebar-block-header {
  padding: var(--space-3) var(--space-4) var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--txt-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sidebar-block-header .block-icon { font-size: 1.1em; }

.sidebar-phase-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
  position: relative;
}

.sidebar-phase-item:hover {
  background: var(--bg-hover);
  color: var(--txt-primary);
}

.sidebar-phase-item.active {
  background: var(--clr-primary-glow);
  border-left-color: var(--clr-primary);
  color: var(--clr-primary);
}

.sidebar-phase-item.completed .phase-item-icon { color: var(--clr-success); }
.sidebar-phase-item.locked { opacity: 0.4; cursor: not-allowed; }

.phase-item-num {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--txt-muted);
  min-width: 20px;
  font-family: var(--font-code);
}
.sidebar-phase-item.active .phase-item-num { color: var(--clr-primary); }

.phase-item-info { flex: 1; overflow: hidden; }
.phase-item-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--txt-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-phase-item.active .phase-item-title { color: var(--clr-primary); }
.sidebar-phase-item.completed .phase-item-title { color: var(--txt-primary); }

.phase-item-stars {
  font-size: 0.65em;
  letter-spacing: -1px;
  color: var(--clr-yellow);
}

.phase-item-icon {
  font-size: 0.9em;
  color: var(--txt-muted);
}

/* Badges section */
.sidebar-badges {
  padding: var(--space-4);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.sidebar-section-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--txt-muted);
  margin-bottom: var(--space-3);
}
.badges-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-1);
}
.badge-item {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1em;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-normal);
  cursor: default;
}
.badge-item.unlocked {
  background: var(--clr-yellow-glow);
  border-color: var(--clr-yellow-d);
  box-shadow: 0 0 8px var(--clr-yellow-glow);
  animation: badge-glow 2s ease-in-out infinite alternate;
}
.badge-item.locked { filter: grayscale(1) opacity(0.3); }

@keyframes badge-glow {
  from { box-shadow: 0 0 6px var(--clr-yellow-glow); }
  to   { box-shadow: 0 0 16px var(--clr-yellow-glow); }
}

/* ── Main content area ─────────────────────────────────── */
#phase-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-base);
  position: relative;
}

/* ── Toast notifications ──────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
  z-index: 9999;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-raised);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  max-width: 360px;
  pointer-events: all;
  animation: toast-in 0.3s var(--transition-bounce);
}

.toast.toast-success { border-color: var(--clr-success); }
.toast.toast-error   { border-color: var(--clr-error); }
.toast.toast-warning { border-color: var(--clr-warning); }
.toast.toast-info    { border-color: var(--clr-info); }
.toast.toast-out     { animation: toast-out 0.25s ease forwards; }

.toast-icon { font-size: 1.3em; flex-shrink: 0; }
.toast-msg  { font-size: var(--text-sm); color: var(--txt-primary); font-weight: var(--weight-medium); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

/* ── XP Popup ─────────────────────────────────────────── */
#xp-popup {
  position: fixed;
  bottom: 80px;
  right: 24px;
  background: var(--clr-yellow);
  color: #1a1000;
  font-weight: var(--weight-black);
  font-size: var(--text-lg);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  z-index: 10000;
  pointer-events: none;
  animation: xp-fly 1.8s ease forwards;
}

@keyframes xp-fly {
  0%   { opacity: 0; transform: translateY(0) scale(0.7); }
  15%  { opacity: 1; transform: translateY(-10px) scale(1.1); }
  70%  { opacity: 1; transform: translateY(-40px) scale(1); }
  100% { opacity: 0; transform: translateY(-70px) scale(0.8); }
}

/* ── Modal ────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fade-in 0.2s ease;
}

#modal-box {
  background: var(--bg-raised);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  max-width: 560px;
  width: 100%;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.3s var(--transition-bounce);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close-btn {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  font-size: 1.1em;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-width: 100vw; }
  #phase-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: 200;
    width: var(--sidebar-width);
  }
  #phase-sidebar.collapsed { width: 0; }
  .player-name-display { display: none; }
}
