/* Rockville Science Day — Mobile-first CSS */
/* Brand: Primary #5B9BD5, Secondary #8EA838, Accent #E88A2D, Dark #3B3B3B */

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

:root {
  --primary: #5B9BD5;
  --primary-dark: #3d7ab5;
  --secondary: #8EA838;
  --accent: #E88A2D;
  --dark: #3B3B3B;
  --white: #FFFFFF;
  --gray-50: #F8F9FA;
  --gray-100: #F1F3F5;
  --gray-200: #E9ECEF;
  --gray-400: #9CA3AF;
  --gray-600: #6B7280;
  --gray-800: #374151;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --tab-height: 60px;
  --header-height: 56px;
  --search-height: 52px;
  --chips-height: 48px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--dark);
  min-height: 100vh;
  padding-bottom: var(--tab-height);
  -webkit-font-smoothing: antialiased;
}

/* ── Header ───────────────────────────────────────────── */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  box-shadow: var(--shadow-md);
}

#app-header img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  flex-shrink: 0;
}

#app-header h1 {
  color: var(--white);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

/* ── Announcement Banner ─────────────────────────────── */
#announcement-banner {
  background: var(--accent);
  color: var(--white);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
  display: none;
}

#announcement-banner.visible { display: block; }

/* ── Tab Bar ─────────────────────────────────────────── */
#tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: var(--tab-height);
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 4px;
  color: var(--gray-400);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tab-btn .tab-icon {
  font-size: 22px;
  line-height: 1;
}

.tab-btn.active { color: var(--primary); }
.tab-btn.active .tab-icon { transform: scale(1.05); }

/* ── Views ───────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Explore View ────────────────────────────────────── */
#view-explore {
  display: flex;
  flex-direction: column;
}

/* Search */
#search-wrapper {
  position: sticky;
  top: var(--header-height);
  z-index: 90;
  background: var(--white);
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--gray-200);
}

#search-input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 38px;
  border: 1.5px solid var(--gray-200);
  border-radius: 20px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--dark);
  background: var(--gray-50);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  -webkit-appearance: none;
}

#search-input:focus {
  border-color: var(--primary);
  background: var(--white);
}

#search-input::placeholder { color: var(--gray-400); }

.search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--gray-400);
  pointer-events: none;
}

#search-row { position: relative; }

/* Filter Chips */
#filter-chips-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 8px 12px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}

#filter-chips-wrapper::-webkit-scrollbar { display: none; }

.chip-group-sep {
  width: 1px;
  height: 20px;
  background: var(--gray-200);
  flex-shrink: 0;
}

.filter-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 15px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-600);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
}

.filter-chip:active { transform: scale(0.96); }

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.filter-chip.venue-chip.active {
  color: var(--white);
}

/* Count */
#exhibitor-count {
  padding: 8px 16px 4px;
  font-size: 12px;
  color: var(--gray-600);
  font-weight: 500;
}

/* Cards */
#exhibitor-list {
  padding: 4px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exhibitor-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  border: 1px solid transparent;
}

.exhibitor-card:active { box-shadow: var(--shadow-md); }
.exhibitor-card.expanded { border-color: var(--primary); }

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 10px;
}

.card-emoji {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}

.card-main { flex: 1; min-width: 0; }

.card-org {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.3;
  margin-bottom: 2px;
}

.card-title {
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.3;
  margin-bottom: 6px;
}

.card-description {
  font-size: 13px;
  color: var(--gray-800);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-description.expanded {
  display: block;
  -webkit-line-clamp: unset;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 12px 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.badge-venue {
  color: var(--white);
}

.badge-age {
  background: var(--gray-100);
  color: var(--gray-600);
}

.badge-type {
  background: rgba(91,155,213,0.12);
  color: var(--primary-dark);
}

/* Card expand detail */
.card-detail {
  display: none;
  padding: 0 12px 12px;
  border-top: 1px solid var(--gray-100);
  margin-top: 4px;
}

.card-detail.visible { display: block; }

.card-detail-row {
  display: flex;
  gap: 6px;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--gray-100);
  align-items: flex-start;
}

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

.detail-label {
  font-weight: 600;
  color: var(--gray-600);
  min-width: 100px;
  flex-shrink: 0;
}

.detail-value { color: var(--dark); line-height: 1.5; }

/* Empty State */
#empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--gray-400);
}

#empty-state.visible { display: flex; }

#empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }

#empty-state p {
  font-size: 15px;
  font-weight: 500;
  color: var(--gray-600);
}

/* ── Placeholder views ───────────────────────────────── */
.placeholder-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 32px;
  text-align: center;
  color: var(--gray-400);
}

.placeholder-view .ph-icon { font-size: 56px; margin-bottom: 16px; }

.placeholder-view h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.placeholder-view p { font-size: 14px; line-height: 1.5; }

/* ── Loading ─────────────────────────────────────────── */
#loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  gap: 12px;
  color: var(--gray-600);
  font-size: 14px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Schedule View ───────────────────────────────────── */
.sched-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  gap: 12px;
  color: var(--gray-600);
  font-size: 14px;
}

.timeline {
  padding: 16px 12px 32px;
}

.tl-block {
  display: flex;
  position: relative;
  padding-left: 80px;
  padding-bottom: 16px;
}

/* Vertical connector line between dots */
.tl-block::before {
  content: '';
  position: absolute;
  left: 61px;
  top: 14px;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}

.tl-block:last-child::before { display: none; }

/* Time label */
.tl-time {
  position: absolute;
  left: 0;
  top: 2px;
  width: 54px;
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-600);
  white-space: nowrap;
  line-height: 1.2;
}

/* Dot on the line */
.tl-dot {
  position: absolute;
  left: 56px;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--gray-100);
  z-index: 1;
}

/* Events column */
.tl-events {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Schedule card */
.schedule-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-left: 3px solid var(--primary);
}

.schedule-card.featured {
  border-left: 4px solid var(--accent);
  background: linear-gradient(135deg, rgba(232,138,45,0.06) 0%, var(--white) 60%);
  box-shadow: var(--shadow-md);
}

.sc-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.sc-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.3;
  flex: 1;
}

.schedule-card.featured .sc-title {
  font-size: 16px;
}

.sc-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sc-time,
.sc-location {
  font-size: 12px;
  color: var(--gray-600);
  line-height: 1.4;
}

/* NOW badge */
.now-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px 2px 6px;
  border-radius: 10px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  align-self: flex-start;
}

.now-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: pulse-dot 1.4s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.6); }
}

/* ── Info View ───────────────────────────────────────── */
#view-info {
  padding: 0 0 8px;
}

.info-section {
  background: var(--white);
  margin: 12px 12px 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border: 1px solid var(--gray-200);
}

.info-section-header {
  background: var(--primary);
  color: var(--white);
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.1px;
}

.info-section-body {
  padding: 4px 0 8px;
}

.info-item {
  display: flex;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
  line-height: 1.5;
  align-items: flex-start;
}

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

.info-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
  margin-top: 1px;
}

.info-text { color: var(--dark); flex: 1; }

.info-label {
  font-weight: 700;
  color: var(--gray-600);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}

/* About RSC section body */
.info-section-body .info-about-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--dark);
  padding: 10px 16px 2px;
}

.donate-btn {
  display: block;
  margin: 14px 16px 8px;
  padding: 15px 24px;
  background: var(--accent);
  color: var(--white);
  text-align: center;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.2px;
  box-shadow: 0 4px 12px rgba(232,138,45,0.35);
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.donate-btn:active { opacity: 0.88; }

.info-website-link {
  display: block;
  text-align: center;
  padding: 6px 16px 12px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.info-website-link:active { opacity: 0.7; }

/* ── Map View ─────────────────────────────────────────────── */
#view-map {
  position: relative;
  overflow: hidden;
  background: #3a6b28;
  padding: 0;
}

#map-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}

#map-svg-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  will-change: transform;
}

#map-svg-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Zone interactivity */
[data-zone] {
  cursor: pointer;
}

[data-zone].zone-active {
  stroke: #ffffff !important;
  stroke-width: 3 !important;
  fill-opacity: 1 !important;
}

/* Reset zoom button */
#map-reset-zoom {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.92);
  color: var(--dark);
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

#map-reset-zoom:active { opacity: 0.75; }

/* Backdrop */
#map-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 300;
}

#map-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Bottom sheet */
#map-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 400;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  padding-bottom: max(env(safe-area-inset-bottom, 0px), var(--tab-height));
}

#map-sheet.open {
  transform: translateY(0);
}

#map-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

#map-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 6px;
  flex-shrink: 0;
  gap: 8px;
}

#map-sheet-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--dark);
  padding-left: 10px;
  border-left: 4px solid var(--primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#map-sheet-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

#map-sheet-close:active { opacity: 0.7; }

#map-sheet-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
  flex-shrink: 0;
}

.sheet-meta-chip {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--gray-100);
  color: var(--gray-600);
  font-weight: 500;
}

#map-sheet-list {
  overflow-y: auto;
  flex: 1;
  padding: 0 16px 8px;
  -webkit-overflow-scrolling: touch;
}

.sheet-exhibitor {
  width: 100%;
  text-align: left;
  padding: 12px 4px;
  border: none;
  border-bottom: 1px solid var(--gray-100);
  background: transparent;
  cursor: pointer;
  display: block;
  -webkit-tap-highlight-color: transparent;
}

.sheet-exhibitor:last-child { border-bottom: none; }
.sheet-exhibitor:active { background: var(--gray-50); }

.sheet-ex-org {
  font-size: 15px;
  font-weight: 600;
  color: var(--dark);
}

.sheet-ex-title {
  font-size: 13px;
  color: var(--gray-600);
  margin-top: 2px;
}

.sheet-empty {
  color: var(--gray-400);
  font-size: 14px;
  text-align: center;
  padding: 28px 0;
}

/* See on map button in Explore cards */
.see-on-map-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: none;
  border: 1.5px solid var(--primary);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  margin-top: 2px;
  -webkit-tap-highlight-color: transparent;
}

.see-on-map-btn:active { opacity: 0.7; }

/* ── Skeleton shimmer loading ────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.skel {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: 4px;
}

.skeleton-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px 12px 10px;
  border: 1px solid transparent;
}

.skel-header {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  align-items: flex-start;
}

.skel-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 2px;
}

.skel-line {
  height: 13px;
  border-radius: 4px;
}

.skel-badges {
  display: flex;
  gap: 6px;
}

.skel-badge {
  height: 22px;
  width: 72px;
  border-radius: 11px;
}

/* ── Offline / error message ─────────────────────────── */
.offline-msg {
  text-align: center;
  padding: 48px 24px;
}

.offline-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.offline-msg p {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.offline-msg .offline-sub {
  font-size: 13px;
  font-weight: 400;
  color: var(--gray-400);
}

/* ── Map spinner overlay ─────────────────────────────── */
#map-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(58, 107, 40, 0.65);
  z-index: 5;
  pointer-events: none;
}

#map-spinner .spinner {
  border-color: rgba(255,255,255,0.3);
  border-top-color: #fff;
  width: 40px;
  height: 40px;
}

/* ── Map view fill height ────────────────────────────── */
#view-map {
  height: calc(100dvh - var(--header-height) - var(--tab-height));
}

/* ── Keyboard-focusable cards ────────────────────────── */
.exhibitor-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Responsive: 320px (iPhone SE) ──────────────────── */
@media (max-width: 360px) {
  #app-header {
    gap: 8px;
    padding: 0 12px;
  }

  #app-header h1 {
    font-size: 15px;
    letter-spacing: -0.2px;
  }

  .tab-btn {
    font-size: 9px;
    padding: 4px 2px;
    gap: 2px;
  }

  .tab-btn .tab-icon {
    font-size: 20px;
  }

  #exhibitor-list {
    padding: 4px 8px 8px;
  }

  #filter-chips-wrapper {
    padding: 6px 8px;
  }

  .filter-chip {
    height: 28px;
    padding: 0 9px;
    font-size: 11px;
  }

  .info-section {
    margin: 8px 8px 0;
  }
}
