/* ============================================
   MASTERLAB — Interface System
   Dark × Borders + color accents × Gold brand
   ============================================ */

/* ---- TOKENS ---- */
:root {
  /* Surfaces — warmer, slightly lifted from void */
  --bg:        #0c0c10;
  --surface-1: #141419;
  --surface-2: #1b1b22;
  --surface-3: #222229;
  --surface-4: #2a2a32;

  /* Text — four-level hierarchy */
  --text:          #f5f5f4;
  --text-secondary: #a8a8b3;
  --text-tertiary:  #76768a;
  --text-muted:     #45454f;

  /* Borders — slightly stronger for visibility */
  --border:        rgba(255, 255, 255, 0.08);
  --border-strong:  rgba(255, 255, 255, 0.13);
  --border-subtle:  rgba(255, 255, 255, 0.04);

  /* Brand — Gringotts Gold (warmer, more present) */
  --gold:        #d4a843;
  --gold-hover:  #c09838;
  --gold-muted:  rgba(212, 168, 67, 0.12);
  --gold-border: rgba(212, 168, 67, 0.25);
  --gold-glow:   rgba(212, 168, 67, 0.06);

  /* Semantic — vivid, full-body */
  --success:        #34d399;
  --success-muted:  rgba(52, 211, 153, 0.12);
  --success-border: rgba(52, 211, 153, 0.22);

  --warning:        #fbbf24;
  --warning-muted:  rgba(251, 191, 36, 0.12);
  --warning-border: rgba(251, 191, 36, 0.22);

  --danger:        #fb7185;
  --danger-muted:  rgba(251, 113, 133, 0.12);
  --danger-border: rgba(251, 113, 133, 0.22);

  --info:        #60a5fa;
  --info-muted:  rgba(96, 165, 250, 0.10);
  --info-border: rgba(96, 165, 250, 0.20);

  /* Activity colors — one per type */
  --calls:    #60a5fa;
  --dms:      #a78bfa;
  --videos:   #f472b6;
  --lives:    #fb923c;

  /* Controls */
  --control-bg:     var(--surface-2);
  --control-border: rgba(255, 255, 255, 0.10);
  --control-focus:  rgba(212, 168, 67, 0.25);

  /* Radius — consistent scale */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;

  /* Transitions — fast, functional */
  --speed-fast: 100ms;
  --speed:      150ms;
  --ease:       ease;
}

/* ---- BASE ---- */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

/* ---- GREAT HALL ATMOSPHERE ---- */
/* Enchanted ceiling — warm ambient glow from above */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    /* Warm ceiling haze */
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(212, 168, 67, 0.07) 0%, transparent 100%),
    /* Center warm glow */
    radial-gradient(circle 300px at 50% 35%, rgba(255, 160, 40, 0.04) 0%, transparent 100%),
    /* Vignette */
    radial-gradient(ellipse 70% 60% at 50% 45%, transparent 40%, rgba(0, 0, 0, 0.25) 100%);
}

/* Second warm pool layer */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle 220px at 40% 30%, rgba(255, 180, 50, 0.035) 0%, transparent 100%);
}

::selection {
  background: rgba(212, 168, 67, 0.25);
  color: var(--text);
}

/* ---- TYPOGRAPHY ---- */
h1, .font-display {
  font-family: 'Cormorant Garamond', Georgia, serif;
}

/* ---- CARDS ---- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--speed) var(--ease);
  position: relative;
  z-index: 2;
}

.card-interactive:hover {
  border-color: var(--border-strong);
}

/* Accent-top cards — colored stripe at top */
.card-accent-gold {
  border-top: 2px solid var(--gold);
}
.card-accent-success {
  border-top: 2px solid var(--success);
}
.card-accent-warning {
  border-top: 2px solid var(--warning);
}
.card-accent-danger {
  border-top: 2px solid var(--danger);
}
.card-accent-info {
  border-top: 2px solid var(--info);
}

/* Flush variant — for tables/lists that go edge-to-edge */
.card-flush {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* ---- SIDEBAR ---- */
.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  z-index: 30;
}

.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}

/* Main content — sits above floating candles & atmosphere */
.main-content {
  position: relative !important;
  z-index: 10 !important;
}

/* Inner wrapper gets its own stacking context */
.main-content > div {
  position: relative;
  z-index: 1;
}

/* ---- NAV ---- */
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 450;
  color: var(--text-tertiary);
  transition: color var(--speed) var(--ease), background var(--speed) var(--ease);
  position: relative;
}

.nav-item:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: var(--text);
  background: var(--gold-glow);
  border: 1px solid rgba(212, 168, 67, 0.10);
}

.nav-item.active svg {
  color: var(--gold);
}

/* ---- INPUTS ---- */
.input {
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
  width: 100%;
}

.input::placeholder {
  color: var(--text-muted);
}

.input:focus {
  border-color: var(--gold-border);
  box-shadow: 0 0 0 2px var(--control-focus);
}

.input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

textarea.input {
  resize: vertical;
  min-height: 60px;
}

/* ---- SELECTS ---- */
select {
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--speed) var(--ease);
}

select:focus {
  border-color: var(--gold-border);
}

/* ---- DATE/MONTH INPUTS ---- */
input[type="date"],
input[type="month"] {
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
  color-scheme: dark;
  transition: border-color var(--speed) var(--ease);
}

input[type="date"]:focus,
input[type="month"]:focus {
  border-color: var(--gold-border);
}

/* ---- CHECKBOX ---- */
input[type="checkbox"] {
  accent-color: var(--gold);
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all var(--speed) var(--ease);
  white-space: nowrap;
}

.btn-primary {
  background: var(--gold);
  color: #0c0c10;
  box-shadow: 0 0 12px rgba(212, 168, 67, 0.15);
}

.btn-primary:hover {
  background: var(--gold-hover);
  box-shadow: 0 0 20px rgba(212, 168, 67, 0.25);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---- STATUS BADGES — vivid ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.badge-sorcier {
  background: var(--success-muted);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.badge-leger {
  background: var(--warning-muted);
  border: 1px solid var(--warning-border);
  color: var(--warning);
}

.badge-moldu {
  background: var(--danger-muted);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

/* ---- TABLES ---- */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.table tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-secondary);
}

.table tbody tr {
  transition: background var(--speed-fast) var(--ease);
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* ---- PROGRESS — thicker for visibility ---- */
.progress {
  height: 4px;
  background: var(--surface-3);
  border-radius: 100px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 100px;
  transition: width 0.8s ease-out;
}

/* ---- AVATAR — colored variants ---- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 12px;
  background: var(--gold-muted);
  color: var(--gold);
  flex-shrink: 0;
  border: 1px solid rgba(212, 168, 67, 0.15);
}

/* ---- RANK — more vivid ---- */
.rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.rank-1 {
  background: var(--gold-muted);
  border: 1px solid var(--gold-border);
  color: var(--gold);
}

.rank-2 {
  background: rgba(161, 161, 170, 0.10);
  border: 1px solid rgba(161, 161, 170, 0.15);
  color: #b0b0ba;
}

.rank-3 {
  background: rgba(194, 140, 80, 0.10);
  border: 1px solid rgba(194, 140, 80, 0.15);
  color: #c8956a;
}

/* ---- DIVIDER ---- */
.divider {
  height: 1px;
  background: var(--border);
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.06); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.12); }

/* ---- ANIMATIONS ---- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeIn 0.25s ease forwards;
}

.slide-in {
  animation: slideUp 0.3s ease forwards;
}

.stagger > * {
  opacity: 0;
  animation: slideUp 0.3s ease forwards;
}
.stagger > *:nth-child(1) { animation-delay: 0s; }
.stagger > *:nth-child(2) { animation-delay: 40ms; }
.stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(6) { animation-delay: 200ms; }
.stagger > *:nth-child(7) { animation-delay: 240ms; }
.stagger > *:nth-child(8) { animation-delay: 280ms; }

/* ---- DATA DISPLAY ---- */
.tabular {
  font-variant-numeric: tabular-nums;
}

.metric {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ---- INSET PANEL ---- */
.inset {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

/* ---- SECTION LABEL ---- */
.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ---- CHIP ---- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
}

/* Colored dots — type indicators */
.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-calls   { background: var(--calls); }
.dot-dms     { background: var(--dms); }
.dot-videos  { background: var(--videos); }
.dot-lives   { background: var(--lives); }
.dot-gold    { background: var(--gold); }
.dot-success { background: var(--success); }
.dot-warning { background: var(--warning); }
.dot-danger  { background: var(--danger); }

/* ---- SORTING HAT (Choixpeau) ---- */
.sorting-hat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  animation: hatFloat 3s ease-in-out infinite;
  cursor: pointer;
}

.sorting-hat:hover {
  animation: hatFloat 3s ease-in-out infinite, hatWiggle 0.4s ease-in-out;
}

.sorting-hat svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  overflow: visible;
}

.sorting-hat:hover svg {
  filter: drop-shadow(0 0 8px rgba(212, 168, 67, 0.35));
}

/* Mouth talking — handled by SMIL <animate> in SVG for max compat */

/* Subtle golden sparkles around the hat */
.sorting-hat::before,
.sorting-hat::after {
  content: '';
  position: absolute;
  width: 3px;
  height: 3px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.sorting-hat::before {
  top: 2px;
  right: -2px;
  animation: sparkle 3s ease-in-out infinite 0.5s;
}

.sorting-hat::after {
  bottom: 6px;
  left: -1px;
  animation: sparkle 3s ease-in-out infinite 1.8s;
}

/* Eyebrow fold animation */
.hat-brow {
  animation: hatBrow 4s ease-in-out infinite;
  transform-origin: 50% 100%;
}

@keyframes hatFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-1.5px) rotate(0.5deg); }
  75% { transform: translateY(1px) rotate(-0.5deg); }
}

@keyframes hatWiggle {
  0%   { transform: rotate(0deg); }
  20%  { transform: rotate(-8deg); }
  40%  { transform: rotate(6deg); }
  60%  { transform: rotate(-4deg); }
  80%  { transform: rotate(2deg); }
  100% { transform: rotate(0deg); }
}

@keyframes hatBrow {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.92); }
}

@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0); }
  50% { opacity: 0.7; transform: scale(1); }
  70% { opacity: 0; transform: scale(0.5); }
}

/* Small variant for sidebar */
.sorting-hat-sm {
  width: 26px;
  height: 26px;
}

/* ---- FLOATING CANDLES (Perf-optimized) ---- */
.candle {
  position: absolute;
  z-index: 0;
  will-change: transform;
  contain: layout style;
}

/* Wax Body */
.candle-body {
  width: 5px;
  height: var(--h, 36px);
  background: linear-gradient(90deg, #f5e6c8 0%, #e0cc9a 40%, #c4a870 100%);
  border-radius: 1.5px;
  position: relative;
}

/* Wax pool top */
.candle-body::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -1px;
  right: -1px;
  height: 5px;
  background: #f5e6c8;
  border-radius: 50%;
}

/* Wick */
.candle-wick {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 1.5px;
  height: 5px;
  background: #2a2a2a;
  border-radius: 1px;
}

/* Flame — single element, no blur, no filter */
.candle-flame {
  position: absolute;
  top: -20px;
  left: 50%;
  width: 10px;
  height: 16px;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  animation: flameFlicker 0.8s ease-in-out infinite alternate;
}

/* Flame teardrop shape */
.candle-flame::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 75%,
    #fff 0%,
    #ffe082 25%,
    #ffab00 50%,
    rgba(255, 87, 34, 0) 100%
  );
  border-radius: 50% 50% 20% 20%;
  clip-path: polygon(50% 0%, 95% 55%, 75% 100%, 25% 100%, 5% 55%);
}

/* Tiny blue base — no blur */
.candle-flame::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: rgba(100, 180, 255, 0.5);
  border-radius: 50%;
}

/* Glow Halo — simple radial, no animation */
.candle-halo {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 100px;
  background: radial-gradient(circle, rgba(255, 180, 50, 0.18) 0%, transparent 60%);
  border-radius: 50%;
  pointer-events: none;
}

/* --- Candle animations (GPU-friendly, transform-only) --- */
@keyframes candleFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes floatLevitate {
  0%, 100% { transform: translateY(0) scale(var(--s, 1)); }
  50% { transform: translateY(-12px) scale(var(--s, 1)); }
}

/* Slower flicker = fewer repaints, transform-only = GPU composited */
@keyframes flameFlicker {
  0%   { transform: translateX(-50%) scaleX(1) scaleY(1); }
  50%  { transform: translateX(-50%) scaleX(0.92) scaleY(1.06); }
  100% { transform: translateX(-50%) scaleX(1.06) scaleY(0.94); }
}


/* ---- RESET SVG ---- */
svg:not(.sorting-hat svg) {
  filter: none;
}
