/* ==========================================================================
   Mitch's PlayLab - Refined Design System with Smart Navbar & 3-Column Grid
   ========================================================================== */

:root {
  /* LIGHT THEME */
  --bg-main: #ffffff;
  --bg-card: #fcfcfc;
  --bg-card-hover: #ffffff;
  --bg-modal: #ffffff;
  --bg-hud: #f4f4f5;

  --border-subtle: #e4e4e7;
  --border-hover: #a1a1aa;

  --text-main: #09090b;
  --text-muted: #71717a;
  --text-dim: #a1a1aa;

  --accent-blue: #0284c7;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;

  --grad-hero: linear-gradient(135deg, #09090b 0%, #3f3f46 100%);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-card: 0 4px 18px -2px rgba(0, 0, 0, 0.06);
  --shadow-popover: 0 12px 32px -4px rgba(0, 0, 0, 0.12);

  /* Typography */
  --font-heading: 'Outfit', 'Inter', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Geometry & Transitions */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* DARK THEME */
[data-theme="dark"] {
  --bg-main: #09090b;
  --bg-card: #18181b;
  --bg-card-hover: #27272a;
  --bg-modal: #18181b;
  --bg-hud: #27272a;

  --border-subtle: #27272a;
  --border-hover: #52525b;

  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
  --shadow-popover: 0 12px 32px -4px rgba(0, 0, 0, 0.6);
}

/* Base Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-body);
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Smart Sticky Pop-Down Navbar */
.navbar.sticky-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 16px 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background var(--transition-normal);
}

[data-theme="dark"] .navbar.sticky-nav {
  background: rgba(9, 9, 11, 0.88);
}

.navbar.nav-hidden {
  transform: translateY(-100%);
}

.nav-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Brand & Portfolio Link below Title */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--bg-main);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-domain {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  margin-top: 1px;
}

.portfolio-link-subtle {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.portfolio-link-subtle:hover {
  color: var(--text-main);
  text-decoration: underline;
}

.portfolio-link-subtle i {
  font-size: 0.62rem;
}

/* Controls & Badges */
.nav-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Metrics Wrapper & Popover */
.metrics-wrapper {
  position: relative;
}

.metrics-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  font-family: var(--font-mono);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
}

.metrics-badge:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.metrics-badge span {
  color: var(--text-main);
  font-weight: 700;
}

.metrics-badge .divider {
  color: var(--border-subtle);
}

.caret-icon {
  font-size: 0.7rem;
  margin-left: 2px;
  color: var(--text-dim);
  transition: transform var(--transition-fast);
}

.metrics-wrapper:hover .caret-icon {
  transform: rotate(180deg);
}

/* Hover Metrics Popover */
.metrics-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 290px;
  background: var(--bg-modal);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  z-index: 120;
  pointer-events: none;
}

.metrics-wrapper:hover .metrics-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.popover-header {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
}

.sync-timer-tag {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.popover-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.popover-item {
  display: flex;
  flex-direction: column;
}

.popover-label {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-weight: 600;
}

.popover-val {
  font-size: 0.95rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-main);
}

/* Pulse Dot */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-green);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseLive 2s infinite;
}

@keyframes pulseLive {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Icon Buttons */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.badge-counter {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--accent-amber);
  color: #000;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 800;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.badge-counter.active {
  opacity: 1;
}

/* Main Section & 3-Column Grid */
.main-content {
  padding: 40px 24px;
}

.grid-header {
  margin-bottom: 32px;
}

.grid-title {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.grid-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
}

/* 3 Column Grid */
.cards-grid-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

/* Blank Card Container */
.blank-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all var(--transition-normal);
  position: relative;
}

.blank-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.card-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 600;
}

.card-icon-placeholder {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-hud);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.card-middle {
  margin: 16px 0;
}

.card-title-placeholder {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.card-desc-placeholder {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed var(--border-subtle);
  padding-top: 14px;
}

.card-slot-badge {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.btn-card-action {
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-hud);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  cursor: pointer;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.btn-card-action:hover {
  background: var(--text-main);
  color: var(--bg-main);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 1;
  transition: opacity var(--transition-normal);
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.drawer-window {
  max-width: 480px;
  width: 100%;
  background: var(--bg-modal);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  background: var(--bg-hud);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 20px;
}

/* Achievement Progress */
.achievement-progress-bar {
  margin-bottom: 20px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 6px;
}

.progress-track {
  height: 8px;
  background: var(--bg-hud);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-amber);
  transition: width 0.4s ease;
}

.achievements-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
}

.achievement-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.achievement-card.locked {
  opacity: 0.6;
}

.ach-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.95rem;
}

.ach-info {
  flex-grow: 1;
}

.ach-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
}

.ach-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ach-status {
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.status-unlocked {
  color: var(--accent-green);
  font-weight: 700;
}

.status-locked {
  color: var(--text-dim);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1500;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast-notification {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-modal);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-popover);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  transform: translateX(120%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 340px;
}

.toast-notification.show {
  transform: translateX(0);
}

.toast-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
}

.toast-tag {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--accent-amber);
}

.toast-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.92rem;
}

.toast-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.text-amber {
  color: var(--accent-amber);
}

/* Responsive Grid Breakpoints */
@media (max-width: 1024px) {
  .cards-grid-3col {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .cards-grid-3col {
    grid-template-columns: 1fr;
  }
  
  .nav-content {
    flex-direction: column;
    gap: 12px;
  }
}
