/* Global Innovation Labs Directory — makerspace.z2m.org */

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #232d3f;
  --border: #2d3a4d;
  --text: #e6edf3;
  --text-secondary: #8b9eb0;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --link: #7dd3fc;
  --link-hover: #bae6fd;
  --c-success: #238636;
  --c-purple: #8957e5;
  --c-mit-red: #A31F34;
  /* MIT Red requested in previous context */
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, .35);
  --font-main: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  font-size: 1rem;
  overflow-x: hidden;
}

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

@media (max-width: 640px) {
  .container {
    padding: 0 1rem;
  }
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

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

.btn-outline:hover {
  border-color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.btn-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  background-color: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  border-radius: 50px;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(88, 166, 255, 0.4);
}

.btn-cta:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(88, 166, 255, 0.6);
}

/* --- Header --- */
.site-header {
  background: rgba(26, 35, 50, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.logo-img {
  height: 36px;
  width: auto;
}

.logo-text {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.site-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  margin-left: 1.5rem;
  font-weight: 500;
  transition: color 0.2s;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--accent);
}

/* --- Hero Section --- */
.hero-section {
  position: relative;
  padding: 4rem 0 5rem;
  background: linear-gradient(to bottom, rgba(15, 20, 25, 0.8), var(--bg)), url('images/hero_innovation_lab.png') center/cover no-repeat;
  text-align: center;
  overflow: hidden;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 800px;
  margin: 0 auto;
}

.hero-title {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.hero-search-wrap {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

.hero-search-input {
  width: 100%;
  padding: 1rem 1.5rem 1rem 3rem;
  font-size: 1.1rem;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: rgba(26, 35, 50, 0.8);
  backdrop-filter: blur(8px);
  color: var(--text);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  transition: all 0.2s;
}

.hero-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(88, 166, 255, 0.15);
  background: var(--surface);
}

.hero-search-icon {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}


/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
  margin-top: -3rem;
  margin-bottom: 4rem;
  position: relative;
  z-index: 5;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
}

.stat-value {
  display: block;
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* --- Filter & Tabs --- */
.region-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 2.5rem;
}

/* Cleaned up old filter styles if any remained */

.filters select {
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  min-width: 180px;
  outline: none;
  transition: all 0.2s;
  /* Fix for dark mode selects */
  color-scheme: dark;
  -webkit-appearance: none;
  /* Remove default arrow for Webkit */
  -moz-appearance: none;
  /* Remove default arrow for Firefox */
  appearance: none;
  /* Remove default arrow for modern browsers */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%238b9eb0'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
  /* Make space for the custom arrow */
}

.filters input {
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  min-width: 180px;
  outline: none;
  transition: all 0.2s;
}

.filters select:focus,
.filters input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.filters input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

.filters button {
  padding: 0.75rem 1.5rem;
  margin-top: auto;
  align-self: flex-end;
  height: 46px;
  /* Match input height */
}

.region-tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.6rem 1.25rem;
  border-radius: 50px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
}

.region-tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.region-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

main.container {
  padding-top: 1.25rem;
  padding-bottom: 0.5rem;
}

/* Reduced from 2rem */
@media (min-width: 640px) {
  main.container {
    padding-top: 1.5rem;
  }
}

/* --- Country Grid --- */
.country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.country-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text);
  position: relative;
  overflow: hidden;
}

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

.country-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.country-flag {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.country-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.country-count {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.country-count::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--c-success);
  border-radius: 50%;
}

.no-results {
  text-align: center;
  grid-column: 1 / -1;
  padding: 4rem 1rem;
  color: var(--text-secondary);
  font-size: 1.1rem;
}


/* --- Footer & About --- */
.about-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
  margin-bottom: 0;
  /* Removed completely */
}

@media(min-width: 800px) {
  .about-section {
    grid-template-columns: 1fr 1fr;
  }
}

.about-content h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

.about-text {
  color: var(--text-secondary);
  font-size: 1.05rem;
}

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.75rem 0;
  /* Minimal padding */
  text-align: center;
  color: #94a3b8;
  margin-top: auto;
  font-size: 0.8rem;
}

.site-footer p {
  margin: 0.15rem 0;
}

.home-explore-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.home-explore-links a {
  display: inline-block;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.4rem 0.8rem;
  border-radius: 50px;
  transition: all 0.2s;
}

.home-explore-links a:hover {
  text-decoration: none;
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-1px);
}

.home-explore-sep {
  display: none;
}

/* Fix for potential hidden margins in home.php structure */
.home-section,
.home-region-links {
  margin-top: 1.5rem !important;
  /* Force reduce */
  margin-bottom: 1.5rem !important;
}

/* --- Utilities --- */
.hidden {
  display: none !important;
}

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

/* Mobile Tweaks */
@media (max-width: 640px) {
  .hero-title {
    font-size: 2.25rem;
  }

  .stat-value {
    font-size: 2rem;
  }

  .region-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    padding-bottom: 0.5rem;
  }

  .region-tab {
    white-space: nowrap;
  }
}

/* --- Country & Lab Pages --- */

/* Page Header */
.page-header {
  padding: 3rem 0 2rem;
  background: linear-gradient(to bottom, rgba(15, 20, 25, 0.8), var(--bg));
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.page-title {
  font-size: 2.5rem;
  font-weight: 800;
  margin: 0;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}


/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  /* Reduced from 2rem */
}

/* ... */

/* Lab Grid & Cards */
.lab-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  /* Reduced from 3rem */
}

.lab-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: all 0.2s;
  height: 100%;
  /* Ensure equal height */
}

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

.lab-card h3 {
  font-size: 1.15rem;
  margin: 0.75rem 0 0.5rem;
  line-height: 1.4;
  height: 3.4rem;
  /* Fixed height for ~2 lines */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  /* Standard property */
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
}

/* ... */

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  /* Reduced from 3rem */
  margin-bottom: 0.5rem;
}

.lab-card .meta {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge.atl {
  background: rgba(88, 166, 255, 0.15);
  color: #58a6ff;
  border: 1px solid rgba(88, 166, 255, 0.3);
}

.badge.makerspace {
  background: rgba(210, 168, 255, 0.15);
  color: #bc8cff;
  border: 1px solid rgba(210, 168, 255, 0.3);
}

/* Lab Detail Page */
.lab-detail-header {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2rem;
}

.location-line {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
}

@media(min-width: 900px) {
  .detail-grid {
    grid-template-columns: 350px 1fr;
    align-items: start;
  }
}

.detail-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.detail-list dt {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 1rem;
}

.detail-list dt:first-child {
  margin-top: 0;
}

.detail-list dd {
  font-size: 1rem;
  margin: 0.25rem 0 0;
  word-break: break-word;
}

.detail-main h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.map-container {
  width: 100%;
  height: 400px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-top: 1rem;
}

.map-container iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  /* Reduced from 3rem */
  margin-bottom: 0.5rem;
}

.pagination a,
.pagination .current,
.pagination .disabled {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}

.pagination a:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.pagination .current {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pagination .disabled {
  opacity: 0.5;
  pointer-events: none;
}