/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
  --color-primary: #1a3a5c;
  --color-primary-hover: #0f2540;
  --color-accent: #c8963e;
  --color-accent-hover: #a87830;
  --color-teal: #366057;
  --color-bg: #e8e8e7;
  --color-surface: #ffffff;
  --color-surface-alt: #f0efed;
  --color-border: #d8d4cd;
  --color-text: #1a1a1a;
  --color-text-muted: #6b6560;
  --color-text-light: #9b948e;
  --color-badge-free: #2d7a4f;
  --color-badge-free-bg: #e8f5ee;
  --color-badge-family: #6b3fa0;
  --color-badge-family-bg: #f0eafa;
  --color-toggle-on: #2d7a4f;
  --color-error: #c0392b;
  --color-error-bg: #fdf0ee;

  --font-heading: 'IBM Plex Sans', Arial, Helvetica, sans-serif;
  --font-body: 'IBM Plex Sans', Arial, Helvetica, sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-card: 0 2px 8px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 6px 20px rgba(0,0,0,0.11), 0 2px 6px rgba(0,0,0,0.05);
  --transition: 0.18s ease;

  --header-height: 90px;
  --sidebar-width: 260px;
  --max-width: 1200px;
  --gap: 24px;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ============================================================
   Header — white background matching PAA Wix site
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #ffffff;
  height: var(--header-height);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.header-inner {
  padding: 0 32px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}
.header-logo {
  height: 76px;
  width: auto;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  color: #366057;
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 400;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.nav-link:hover { background: var(--color-bg); color: #2a4d45; }
.nav-link--current { color: #366057; font-weight: 600; border-bottom: 2px solid #366057; border-radius: 0; }

/* Mobile hamburger (hidden on desktop) */
.mobile-nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
  background: none;
  border: none;
  cursor: pointer;
}
.mobile-nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: all var(--transition);
}

/* ============================================================
   Main & Views
   ============================================================ */
#main-content { flex: 1; }
.view[hidden] { display: none !important; }

/* ============================================================
   Loading
   ============================================================ */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 24px;
  color: var(--color-text-muted);
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Error / 404
   ============================================================ */
.error-container, .not-found-container {
  max-width: 480px;
  margin: 80px auto;
  padding: 40px 32px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  text-align: center;
  border: 1px solid var(--color-border);
}
.error-container h2, .not-found-container h2 {
  font-family: var(--font-heading);
  color: var(--color-teal);
  margin-bottom: 12px;
}
.error-container p, .not-found-container p {
  color: var(--color-text-muted);
  margin-bottom: 24px;
}

/* ============================================================
   Listing Hero
   ============================================================ */
.listing-hero {
  background: #f5f0eb;
  color: var(--color-text);
  padding: 40px 24px 36px;
  text-align: center;
}
.listing-hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  color: #366057;
  margin-bottom: 10px;
}
.listing-subtitle {
  font-size: 1rem;
  color: var(--color-text-muted);
  max-width: 600px;
  margin: 0 auto;
}

/* ============================================================
   Listing Layout
   ============================================================ */
.listing-layout {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: var(--gap);
  align-items: start;
}

/* ============================================================
   Filters Panel
   ============================================================ */
.filters-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: sticky;
  top: calc(var(--header-height) + 16px);
}

.filters-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.filters-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.filters-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-teal);
}

.filter-group { margin-bottom: 16px; }
.filter-group:last-child { margin-bottom: 0; }

.filter-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.filter-input, .filter-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.filter-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6560' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.filter-input:focus, .filter-select:focus {
  outline: none;
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px rgba(54,96,87,0.12);
}

.date-range-fieldset { border: none; }
.date-range-inputs { display: flex; flex-direction: column; gap: 8px; }
.date-input-wrap { display: flex; flex-direction: column; gap: 4px; }
.date-label { font-size: 0.78rem; color: var(--color-text-muted); }
.filter-input--date { padding: 7px 10px; }

/* Category checkboxes */
.category-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.category-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--color-text);
  user-select: none;
}
.category-checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--color-border);
  border-radius: 3px;
  accent-color: var(--color-teal);
  cursor: pointer;
  flex-shrink: 0;
}

/* Toggle switches */
.filter-group--toggles { display: flex; flex-direction: column; gap: 10px; }
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 36px;
  height: 20px;
  background: var(--color-border);
  border-radius: 10px;
  flex-shrink: 0;
  position: relative;
  transition: background var(--transition);
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-input:checked ~ .toggle-track { background: var(--color-toggle-on); }
.toggle-input:checked ~ .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle-input:focus-visible ~ .toggle-track { box-shadow: 0 0 0 3px rgba(45,122,79,0.25); }
.toggle-text { font-size: 0.875rem; color: var(--color-text); }

/* Desktop: show the toggle in results header, hide mobile one */
.filters-toggle-btn-desktop { font-size: 0.8125rem; }
.btn.filters-toggle-btn-mobile { display: none; }
.btn.filters-hide-btn-mobile { display: none; }

/* When filter panel is forcibly hidden on desktop (narrow window), show toggle */
.filters-panel.is-hidden { display: none !important; }
.filters-panel.is-hidden + .events-column { grid-column: 1 / -1; }

/* ============================================================
   Events Column
   ============================================================ */
.events-column { min-width: 0; }
.events-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
#results-count { font-size: 0.875rem; color: var(--color-text-muted); }

.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.events-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--color-text-muted);
}
.events-empty p { margin-bottom: 16px; }

/* ============================================================
   Event Card
   ============================================================ */
.event-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}
.event-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
  border-color: var(--color-teal);
}
.event-card:focus-visible {
  outline: 3px solid var(--color-teal);
  outline-offset: 2px;
}

.event-card__header {
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.event-card__org-logo {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: white;
  padding: 2px;
  border: 1px solid rgba(0,0,0,0.08);
}
.event-card__org-logo-placeholder {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  background: var(--color-teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
  flex-shrink: 0;
}
.event-card__org-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-card__body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; gap: 7px; }
.event-card__title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-teal);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.event-card__date {
  font-size: 0.83rem;
  color: var(--color-accent);
  font-weight: 500;
}
.event-card__location {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: flex-start;
  gap: 4px;
}
.event-card__location::before { content: "📍"; font-size: 0.73rem; flex-shrink: 0; margin-top: 2px; }

.event-card__badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge--free { background: var(--color-badge-free-bg); color: var(--color-badge-free); }
.badge--donations { background: #e0f2f1; color: #00695c; }
.badge--family { background: var(--color-badge-family-bg); color: var(--color-badge-family); }
.badge--category { background: var(--color-surface-alt); color: var(--color-text-muted); border: 1px solid var(--color-border); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  cursor: pointer;
  border: none;
  box-sizing: border-box;
  -webkit-appearance: none;
}
.btn--primary { background: var(--color-teal); color: white; }
.btn--primary:hover { background: #2b4d46; }
.btn--ghost { background: transparent; color: var(--color-text-muted); border: 1px solid var(--color-border); }
.btn--ghost:hover { background: var(--color-surface-alt); color: var(--color-text); }
.btn--share { background: #2e6da4; color: white; }
.btn--share:hover { background: #245a8a; }
.btn--sm { padding: 6px 12px; font-size: 0.8rem; }

/* ============================================================
   Event Detail Page
   ============================================================ */
.detail-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 24px;
  transition: color var(--transition);
}
.detail-back:hover { color: var(--color-teal); }
.detail-back::before { content: "←"; }

.detail-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.detail-title {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  color: var(--color-teal);
  line-height: 1.25;
  margin-bottom: 20px;
}

.detail-meta {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}
.detail-meta-row { display: flex; align-items: flex-start; gap: 12px; }
.detail-meta-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; width: 20px; text-align: center; }
.detail-meta-content { flex: 1; min-width: 0; }
.detail-meta-label {
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}
.detail-meta-value { font-size: 0.95rem; color: var(--color-text); }

.detail-org-link { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--color-text); }
.detail-org-link:hover .detail-org-name { color: var(--color-teal); text-decoration: underline; }
.detail-org-logo {
  width: 36px; height: 36px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: white;
  padding: 3px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.detail-description {
  font-size: 0.975rem;
  line-height: 1.75;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}

.share-wrapper { position: relative; display: inline-block; }

.share-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card-hover);
  min-width: 180px;
  z-index: 100;
  overflow: hidden;
}

.share-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-family: var(--font-body);
  color: var(--color-text);
  background: none;
  border: none;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
}
.share-menu__item:hover { background: var(--color-surface-alt); }
.share-icon { width: 18px; height: 18px; flex-shrink: 0; }

.share-success {
  font-size: 0.85rem;
  color: var(--color-badge-free);
  font-weight: 500;
  align-self: center;
  display: none;
}
.share-success.visible { display: inline; }

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  background: var(--color-primary);
  color: rgba(255,255,255,0.7);
  padding: 20px 24px;
  margin-top: auto;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.85rem;
}
.footer-link { color: rgba(255,255,255,0.7); text-decoration: none; transition: color var(--transition); }
.footer-link:hover { color: white; }

/* ============================================================
   Responsive — Tablet
   ============================================================ */
@media (max-width: 960px) {
  .listing-layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
  }
  .filters-panel {
    position: static;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    display: none;
    padding: 20px 24px;
  }
  .filters-panel.is-open { display: block; }
  .btn.filters-toggle-btn-desktop { display: none; }
  .btn.filters-toggle-btn-mobile { display: inline-flex; }
  .btn.filters-hide-btn-mobile { display: inline-flex; }
  .events-column { padding: 20px 24px; }
}

/* ============================================================
   Responsive — Mobile
   ============================================================ */
@media (max-width: 700px) {
  :root { --header-height: 70px; }

  .header-inner { padding: 0 16px; }

  /* Collapse nav on mobile */
  .header-nav {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: white;
    flex-direction: column;
    padding: 12px 16px 20px;
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    gap: 2px;
    align-items: flex-start;
  }
  .header-nav.is-open { display: flex; }
  .nav-link { width: 100%; padding: 10px 12px; }

  .mobile-nav-toggle { display: flex; }

  .listing-hero { padding: 28px 16px 24px; }

  .events-grid { grid-template-columns: 1fr; }

  .detail-page { padding: 20px 16px 48px; }
  .detail-meta { padding: 16px; }
  .detail-actions { flex-direction: column; }
  .detail-actions .btn { width: 100%; }

  .footer-inner { flex-direction: column; gap: 6px; text-align: center; }
}

/* ============================================================
   Organization Color Bars — full header background
   ============================================================ */
.event-card__header[data-org="strings-music-festival"] { background: #b2dfdb; }
.event-card__header[data-org="perry-mansfield"] { background: #ffccbc; }
.event-card__header[data-org="steamboat-dance-theatre"] { background: #d1c4e9; }
.event-card__header[data-org="opera-steamboat"] { background: #fff9c4; }
.event-card__header[data-org="steamboat-symphony"] { background: #bbdefb; }
.event-card__header[data-org="wildhorse-arts"] { background: #f8bbd0; }
.event-card__header[data-org="steamboat-creates"] { background: #c8e6c9; }
.event-card__header[data-org="colorado-new-play-festival"] { background: #ffe0b2; }
.event-card__header[data-org="tread-of-pioneers"] { background: #c5cae9; }
.event-card__header[data-org="steamboat-art-museum"] { background: #fce4ec; }
.event-card__header[data-org="yampa-river-botanic-park"] { background: #dcedc8; }
.event-card__header[data-org="seminars-at-steamboat"] { background: #b2ebf2; }
.event-card__header[data-org="bud-werner-memorial-library"] { background: #ffecb3; }
.event-card__header[data-org="off-the-beaten-path"] { background: #e1bee7; }
.event-card__header[data-org="steamboat-summer-concert-series"] { background: #b3e5fc; }
.event-card__header[data-org="winterwondergrass"] { background: #d7ccc8; }
