/* ============================================
   BOMAtlas Profile Pages - Shared CSS
   Mobile-first, accessible, unified design
   ============================================ */

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

:root {
  --bg: #0c0c0c;
  --bg-elevated: #141414;
  --bg-card: #1a1a1a;
  --bg-card-hover: #222;
  --text: #fff;
  --text-secondary: #a1a1a1;
  --text-muted: #808080; /* WCAG AA compliant on #0c0c0c (5:1) */
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #22c55e;
  --orange: #d4a012;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---- Skip Link (Accessibility) ---- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--accent);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  z-index: 10000;
  text-decoration: none;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 12px;
}

/* ---- Container & Layout ---- */
.profile-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 80px 16px 100px; /* mobile-first: bottom padding for sticky CTA */
}

/* ---- Breadcrumb ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--text-muted);
  flex-wrap: wrap;
  min-height: 44px; /* touch target */
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 4px; /* expand touch target */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

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

.breadcrumb a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- School Type Badge ---- */
.school-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* ---- Profile Header ---- */
.profile-header {
  margin-bottom: 32px;
}

.school-name {
  font-size: clamp(26px, 5vw, 42px);
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.school-location {
  font-size: 18px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.school-summary {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 700px;
}

/* ---- Early CTA (above the fold on mobile) ---- */
.early-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.early-cta .cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  min-height: 44px;
  transition: background 0.2s;
}

.early-cta .cta-btn:hover {
  background: var(--accent-hover);
}

.early-cta .cta-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.early-cta .cta-btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.early-cta .cta-btn-secondary:hover {
  border-color: var(--border-hover);
  background: var(--bg-elevated);
}

/* ---- Quick Stats ---- */
.quick-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.stat-item {
  text-align: center;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 80px;
  flex: 1;
  max-width: 140px;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-icon {
  font-size: 20px;
}

/* ---- Programs (grid layout, matches hydration output) ---- */
.programs-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.program-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.program-icon {
  font-size: 24px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border-radius: 10px;
  flex-shrink: 0;
}

.program-name {
  font-weight: 500;
  color: var(--text);
  font-size: 14px;
  margin: 0;
}

.program-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Legacy programs list (generated by crawler script) */
.programs-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.program-item {
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.program-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.program-title {
  flex: 1;
  min-width: 0;
}

.program-credential {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}

.program-duration {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

.program-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 10px;
  line-height: 1.5;
}

/* ---- Certifications, Equipment, Accreditations ---- */
.certs-grid,
.certs-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.cert-card {
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.cert-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.cert-check {
  color: var(--green);
  font-weight: 700;
  font-size: 16px;
}

.cert-name {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.cert-org {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 4px;
}

.cert-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.cert-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.cert-badge::before {
  content: '\2713';
  color: var(--green);
  font-weight: 700;
}

.equipment-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.equipment-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 14px;
  color: var(--text);
}

.equipment-item::before {
  content: '\2699\FE0F';
}

.accred-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.accred-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* ---- Contact Grid (matches hydration output) ---- */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.contact-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.contact-icon {
  flex-shrink: 0;
  font-size: 20px;
  margin-top: 2px;
}

/* SVG icons in contact items */
.contact-icon svg,
svg.contact-icon {
  width: 20px;
  height: 20px;
  fill: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}

.contact-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.contact-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  word-break: break-all;
}

.contact-link:hover {
  text-decoration: underline;
}

.contact-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.contact-value {
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
}

/* Legacy detail-item layout (from regeneration script) */
.detail-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  min-height: 44px; /* touch target */
}

.detail-item:last-child {
  border-bottom: none;
}

.detail-icon {
  font-size: 18px;
  color: var(--text-muted);
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

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

.detail-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.detail-value {
  font-size: 14px;
  color: var(--text);
}

.detail-value a {
  color: var(--accent);
  text-decoration: none;
}

.detail-value a:hover {
  text-decoration: underline;
}

.detail-value a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---- Location Map ---- */
#map,
.map-container {
  height: 300px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

/* Dark map controls */
.leaflet-control-attribution {
  background: var(--bg-card) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
}

.leaflet-control-attribution a {
  color: var(--text-secondary) !important;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.leaflet-popup-content {
  margin: 12px;
  font-family: inherit;
}

.leaflet-popup-tip {
  background: var(--bg-card);
}

/* ---- Nearby Schools ---- */
.nearby-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.nearby-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  min-height: 44px;
}

.nearby-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nearby-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 4px;
}

.nearby-name {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  flex: 1;
}

.nearby-distance {
  font-size: 12px;
  color: var(--orange);
  font-weight: 500;
  white-space: nowrap;
  padding: 2px 8px;
  background: rgba(212, 160, 18, 0.1);
  border-radius: 100px;
}

.nearby-location {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 6px;
}

.nearby-programs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nearby-program-tag {
  font-size: 11px;
  padding: 3px 8px;
  background: var(--bg-card);
  border-radius: 100px;
  color: var(--text-muted);
}

/* ---- Actions Row ---- */
.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  min-height: 44px;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.action-btn:hover {
  background: var(--accent-hover);
}

.action-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.action-btn.secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.action-btn.secondary:hover {
  border-color: var(--border-hover);
  background: var(--bg-elevated);
}

/* ---- CTA Section (bottom of page) ---- */
.cta-section {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(59, 130, 246, 0.04) 100%);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  margin-top: 32px;
}

.cta-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 10px;
}

.cta-text {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 15px;
}

.cta-btn-large {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  min-height: 48px;
  font-size: 15px;
  transition: background 0.2s;
}

.cta-btn-large:hover {
  background: var(--accent-hover);
}

.cta-btn-large:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Sticky Mobile CTA ---- */
.sticky-cta {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: rgba(20, 20, 20, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

.sticky-cta-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
}

.sticky-cta .cta-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  min-height: 48px;
  border: none;
  cursor: pointer;
}

.sticky-cta .cta-btn-primary {
  background: var(--accent);
  color: #fff;
}

.sticky-cta .cta-btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  flex: 0 0 auto;
}

/* ---- Footer ---- */
.profile-footer {
  margin-top: 48px;
  padding: 32px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.profile-footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.profile-footer a:hover {
  color: var(--accent);
}

/* ============================================
   Responsive: Tablet (2-column grids)
   ============================================ */
@media (min-width: 640px) {
  .profile-container {
    padding: 80px 24px 100px;
  }

  .programs-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .certs-grid,
  .certs-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .contact-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .nearby-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  #map,
  .map-container {
    height: 350px;
  }
}

/* ============================================
   Responsive: Desktop (wider layout)
   ============================================ */
@media (min-width: 1024px) {
  .profile-container {
    padding: 100px 24px 80px;
  }

  .card {
    padding: 28px;
  }

  .programs-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  #map,
  .map-container {
    height: 400px;
  }

  .cta-section {
    padding: 40px;
  }
}

/* ============================================
   Mobile-specific: show sticky CTA
   ============================================ */
@media (max-width: 639px) {
  .sticky-cta {
    display: block;
  }
}

/* ============================================
   Hover-only states (no touch jank)
   ============================================ */
@media (hover: hover) {
  .card:hover {
    border-color: var(--border-hover);
  }

  .program-card:hover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
  }

  .program-item:hover {
    border-color: var(--border-hover);
  }

  .contact-item:hover {
    border-color: var(--border-hover);
  }

  .nearby-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    transition: all 0.2s;
  }

  .cert-card:hover {
    border-color: var(--green);
    background: rgba(34, 197, 94, 0.05);
  }

  .cert-badge:hover {
    border-color: var(--green);
    background: rgba(34, 197, 94, 0.1);
  }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
  .bomatlas-header,
  .sticky-cta,
  .actions,
  .cta-section,
  #map,
  .map-container {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .card {
    border: 1px solid #ddd;
    break-inside: avoid;
  }

  .profile-container {
    padding: 0;
    max-width: 100%;
  }
}
