/* ============================================
   MadBoulder Design System
   Foundation tokens and reusable components
   ============================================ */

/* --- Color Tokens --- */
:root {
  /* Brand */
  --color-primary: #ffc800;
  --color-primary-hover: #e6b400;
  --color-primary-light: #fff8e1;
  --color-primary-dark: #cca000;

  /* Text */
  --color-text: #1a1a1a;
  --color-text-secondary: #6b7280;
  --color-text-muted: #9ca3af;
  --color-text-inverse: #f9fafb;

  /* Backgrounds */
  --color-bg: #ffffff;
  --color-bg-subtle: #f8f9fa;
  --color-bg-muted: #f1f3f5;
  --color-surface: #ffffff;

  /* Borders */
  --color-border: #e5e7eb;
  --color-border-strong: #d1d5db;

  /* Navbar */
  --color-navbar: #111111;
  --color-navbar-text: #f9fafb;

  /* Semantic */
  --color-success: #16a34a;
  --color-error: #dc2626;
  --color-warning: #f59e0b;
  --color-info: #2563eb;

  /* Accent glow (cyberpunk touch) */
  --glow-primary: 0 0 12px rgba(255, 200, 0, 0.3);
  --glow-primary-strong: 0 0 20px rgba(255, 200, 0, 0.5);
  --color-accent-line: linear-gradient(90deg, transparent, var(--color-primary), transparent);

  /* --- Typography --- */
  --font-family: 'Raleway', sans-serif;
  --font-xs: 0.75rem;     /* 12px */
  --font-sm: 0.875rem;    /* 14px */
  --font-base: 1rem;      /* 16px */
  --font-md: 1.125rem;    /* 18px */
  --font-lg: 1.25rem;     /* 20px */
  --font-xl: 1.5rem;      /* 24px */
  --font-2xl: 2rem;       /* 32px */
  --font-3xl: 2.5rem;     /* 40px */

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

  /* --- Spacing (8px base) --- */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.5rem;    /* 24px */
  --space-6: 2rem;      /* 32px */
  --space-7: 3rem;      /* 48px */
  --space-8: 4rem;      /* 64px */

  /* --- Border Radius --- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* --- Shadows --- */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10);

  /* --- Transitions --- */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}


/* ============================================
   Base Element Styles
   ============================================ */

body {
  color: var(--color-text);
  font-family: var(--font-family);
  line-height: var(--line-height-normal);
}

h1, h2, h3, h4, h5, h6 {
  color: var(--color-text);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
}


/* ============================================
   Component: Card (.mb-card)
   ============================================ */

.mb-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.mb-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.mb-card-body {
  padding: var(--space-4);
}

.mb-card-img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  display: block;
}

.mb-card-title {
  font-size: var(--font-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin: 0;
  text-align: center;
}

.mb-card-subtitle {
  font-size: var(--font-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
  text-align: center;
}


/* ============================================
   Component: Breadcrumb (.mb-breadcrumb)
   ============================================ */

.mb-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  list-style: none;
  padding: var(--space-3) 0;
  margin: 0;
  font-size: var(--font-base);
  gap: var(--space-1);
}

.mb-breadcrumb li {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.mb-breadcrumb li + li::before {
  content: "/";
  font-size: var(--font-base);
  color: var(--color-text-muted);
  margin-right: var(--space-2);
}

.mb-breadcrumb a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  transition: color var(--transition-fast);
  padding: var(--space-1) 0;
}

.mb-breadcrumb a:hover {
  color: var(--color-primary);
}

.mb-breadcrumb .active {
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
}


/* ============================================
   Component: Section Header (.mb-section-header)
   ============================================ */

.mb-section-header {
  background-color: var(--color-bg);
  border-bottom: none;
  padding: var(--space-3) 0;
  margin-bottom: var(--space-5);
  position: relative;
}

.mb-section-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-accent-line);
}

.mb-section-header .container {
  padding-top: 0;
  padding-bottom: 0;
}

.mb-section-header-title {
  color: var(--color-text);
  text-align: center;
  margin-bottom: 0;
  font-size: var(--font-2xl);
  font-weight: var(--font-weight-bold);
}

@media (max-width: 768px) {
  .mb-section-header-title {
    font-size: var(--font-xl);
  }
}


/* ============================================
   Component: Tabs (.mb-tabs)
   ============================================ */

/* Tabs wrapper with scroll fade indicators on mobile */
.mb-tabs-wrapper {
  position: relative;
}

.mb-tabs-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(to right, transparent, var(--color-bg, #fff));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.mb-tabs-wrapper.has-scroll-right::after {
  opacity: 1;
}

.mb-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  justify-content: center;
}

.mb-tabs::-webkit-scrollbar {
  display: none;
}

.mb-tabs .nav-item {
  flex-shrink: 0;
  list-style: none;
}

.mb-tabs .nav-link {
  color: var(--color-text-secondary);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-sm);
  font-weight: var(--font-weight-semibold);
  transition: color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
  margin-bottom: -2px;
}

.mb-tabs .nav-link:hover {
  color: var(--color-text);
  border-bottom-color: var(--color-border-strong);
}

.mb-tabs .nav-link.active {
  color: var(--color-text) !important;
  background: transparent !important;
  border-bottom-color: var(--color-primary) !important;
}

.mb-tabs .nav-link i {
  margin-right: var(--space-1);
  font-size: var(--font-sm);
}

@media (max-width: 576px) {
  .mb-tabs {
    justify-content: flex-start;
    padding-right: 40px; /* space for fade indicator */
  }
  .mb-tabs .nav-link {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-xs);
  }
}


/* ============================================
   Component: Badge (.mb-badge)
   ============================================ */

.mb-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  font-size: var(--font-xs);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-full);
  line-height: 1;
  white-space: nowrap;
}

.mb-badge-primary {
  background-color: var(--color-primary-light);
  color: #92600a;
}

.mb-badge-secondary {
  background-color: var(--color-bg-muted);
  color: var(--color-text-secondary);
}

.mb-badge-info {
  background-color: var(--color-bg-muted);
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-sm);
}

.mb-badge-grade {
  background-color: var(--color-primary);
  color: var(--color-text);
  font-weight: var(--font-weight-bold);
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-sm);
}


/* ============================================
   Component: Comment (.mb-comment)
   ============================================ */

.mb-comment {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border);
}

.mb-comment:last-child {
  border-bottom: none;
}

.mb-comment-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background-color: var(--color-bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-text-secondary);
  font-size: var(--font-sm);
}

.mb-comment-content {
  flex: 1;
  min-width: 0;
}

.mb-comment-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.mb-comment-author {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-sm);
  color: var(--color-text);
}

.mb-comment-date {
  font-size: var(--font-xs);
  color: var(--color-text-muted);
}

.mb-comment-text {
  font-size: var(--font-sm);
  color: var(--color-text);
  line-height: var(--line-height-relaxed);
  word-wrap: break-word;
}

.mb-comment-actions {
  margin-left: auto;
  flex-shrink: 0;
}

.mb-comment-delete {
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--space-1);
  border: none;
  background: none;
  transition: color var(--transition-fast);
}

.mb-comment-delete:hover {
  color: var(--color-error);
}

/* Comment Form */
.mb-comment-form {
  background: var(--color-bg-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
}

.mb-comment-form textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  font-family: var(--font-family);
  font-size: var(--font-sm);
  resize: vertical;
  min-height: 48px;
  transition: border-color var(--transition-fast);
  background: var(--color-bg);
}

.mb-comment-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.mb-comment-form .form-char-count {
  font-size: var(--font-xs);
  color: var(--color-text-muted);
  text-align: right;
  margin-top: var(--space-1);
}


/* ============================================
   Component: Buttons (enhanced)
   ============================================ */

.mb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-family);
  font-size: var(--font-sm);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  line-height: 1.5;
}

.mb-btn-primary {
  background-color: var(--color-primary);
  color: var(--color-text);
  border-color: var(--color-primary);
}

.mb-btn-primary:hover {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.mb-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.mb-btn-secondary {
  background-color: var(--color-bg);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}

.mb-btn-secondary:hover {
  background-color: var(--color-bg-subtle);
  border-color: var(--color-text-secondary);
}

.mb-btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-xs);
}


/* ============================================
   Component: Rating (.mb-rating)
   ============================================ */

.mb-rating {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.mb-rating-value {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-base);
  color: var(--color-text);
}

.mb-rating-count {
  font-size: var(--font-sm);
  color: var(--color-text-secondary);
}

.mb-rating-card {
  background: var(--color-bg-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.mb-rating-card label {
  font-size: var(--font-sm);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
}


/* ============================================
   Component: Video (.mb-video)
   ============================================ */

.mb-video-wrapper {
  max-width: 860px;
  margin: 0 auto;
}

.mb-video-container {
  position: relative;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
}

.mb-video-container::after {
  content: "";
  display: block;
  padding-bottom: 56.25%;
}

.mb-video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.mb-video-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.mb-video-climber-bar {
  text-align: center;
  padding: var(--space-3) 0 var(--space-2);
}

.mb-video-actions {
  display: flex;
  justify-content: center;
  padding-bottom: var(--space-2);
}

.mb-video-climber {
  font-size: var(--font-sm);
  color: var(--color-text-secondary);
  font-style: italic;
}

.mb-video-climber a {
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
}

.mb-video-climber a:hover {
  text-decoration: underline;
}


/* ============================================
   Component: Map (.mb-map)
   ============================================ */

.mb-map-container {
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  min-height: 300px;
  margin: var(--space-5) 0;
}

.mb-map-header {
  font-size: var(--font-lg);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-3);
  color: var(--color-text);
}


/* ============================================
   Component: Problem Grid Layout
   ============================================ */

.mb-problem-layout {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: var(--space-4);
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.mb-problem-sidebar {
  width: 160px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
}

.mb-problem-main {
  flex: 1;
  min-width: 0;
  max-width: 860px;
}

@media (max-width: 1200px) {
  .mb-problem-sidebar:first-child {
    display: none;
  }
}

@media (max-width: 992px) {
  .mb-problem-sidebar {
    display: none;
  }

  .mb-problem-main {
    max-width: 100%;
  }
}


/* ============================================
   Component: Table improvements
   ============================================ */

.mb-table-search {
  position: relative;
  margin-bottom: var(--space-4);
}

.mb-table-search input {
  width: 100%;
  padding: var(--space-2) var(--space-4);
  padding-left: 2.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-sm);
  font-family: var(--font-family);
  transition: border-color var(--transition-fast);
}

.mb-table-search input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.mb-table-search::before {
  content: "\f002"; /* fa-search */
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-size: var(--font-sm);
  pointer-events: none;
  z-index: 1;
}

/* Video thumbnail in tables */
.mb-thumbnail {
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.mb-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}


/* ============================================
   Component: Stats Card
   ============================================ */

.mb-stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.mb-stat-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--color-primary-light);
  color: #92600a;
  font-size: var(--font-md);
}

.mb-stat-value {
  font-size: var(--font-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  line-height: 1;
}

.mb-stat-label {
  font-size: var(--font-xs);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}


/* ============================================
   Areas Grid
   ============================================ */

.mb-areas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
}

@media (max-width: 576px) {
  .mb-areas-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--space-3);
  }
}


/* ============================================
   Utility classes
   ============================================ */

.mb-text-secondary {
  color: var(--color-text-secondary);
}

.mb-text-muted {
  color: var(--color-text-muted);
}

/* ============================================
   Cyberpunk / Edgy Visual Accents
   ============================================ */

/* Glowing accent line under active tabs */
.mb-tabs .nav-link.active {
  box-shadow: 0 3px 8px rgba(255, 200, 0, 0.25);
}

/* Card hover glow */
.mb-card:hover,
.card-body:hover {
  box-shadow: var(--shadow-md), 0 0 16px rgba(255, 200, 0, 0.12);
}

/* Primary button glow */
.mb-btn-primary:hover,
.btn-primary-madboulder:hover {
  box-shadow: var(--glow-primary);
}

/* Badge grade subtle glow */
.mb-badge-grade {
  box-shadow: inset 0 0 8px rgba(255, 200, 0, 0.2);
}

/* Video container border accent */
.mb-video-container {
  border: 1px solid rgba(255, 200, 0, 0.15);
}

/* Focus glow on inputs */
input:focus,
textarea:focus,
select:focus {
  box-shadow: 0 0 0 3px rgba(255, 200, 0, 0.15) !important;
}

/* Navbar search glow on focus */
.nav-search-input:focus {
  box-shadow: 0 0 12px rgba(255, 200, 0, 0.25) !important;
}

/* Stat card icon glow */
.mb-stat-icon {
  box-shadow: inset 0 0 12px rgba(255, 200, 0, 0.15);
}

/* Map container accent border */
.mb-map-container {
  border: 1px solid rgba(255, 200, 0, 0.1);
}

/* Comment form glow on focus */
.mb-comment-form textarea:focus {
  box-shadow: 0 0 0 3px rgba(255, 200, 0, 0.15), 0 0 12px rgba(255, 200, 0, 0.08);
}

/* Rating card subtle accent */
.mb-rating-card {
  border-left: 3px solid var(--color-primary);
}

/* Link hover with brand color */
a:hover {
  color: var(--color-primary-hover);
}


/* ============================================
   Utility classes
   ============================================ */

.mb-mt-1 { margin-top: var(--space-1); }
.mb-mt-2 { margin-top: var(--space-2); }
.mb-mt-3 { margin-top: var(--space-3); }
.mb-mt-4 { margin-top: var(--space-4); }
.mb-mt-5 { margin-top: var(--space-5); }

.mb-mb-1 { margin-bottom: var(--space-1); }
.mb-mb-2 { margin-bottom: var(--space-2); }
.mb-mb-3 { margin-bottom: var(--space-3); }
.mb-mb-4 { margin-bottom: var(--space-4); }
.mb-mb-5 { margin-bottom: var(--space-5); }
