/* ============================================================
   Pioneer Valley Events — Stylesheet
   ============================================================ */

:root {
  --bg:           #F5F1EB;
  --surface:      #FFFFFF;
  --surface-alt:  #FAF8F4;
  --border:       #E2DDD5;
  --text:         #1C1917;
  --text-muted:   #78716C;
  --text-light:   #A8A29E;
  --primary:      #2D6A4F;
  --primary-dark: #1B4332;
  --primary-light:#52B788;
  --accent:       #E76F51;

  /* category colors */
  --c-music:      #7C3AED;
  --c-arts:       #BE185D;
  --c-film:       #0369A1;
  --c-comedy:     #D97706;
  --c-community:  #15803D;
  --c-academia:   #B45309;
  --c-family:     #0891B2;
  --c-food:       #C2410C;
  --c-outdoor:    #16A34A;
  --c-festival:   #9333EA;

  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 1px 3px rgba(0,0,0,0.07), 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.10);
  --transition:   0.15s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select { font-family: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
img { max-width: 100%; display: block; }

/* ---- Header ---- */
header {
  background: var(--primary-dark);
  color: #fff;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 64px;
}
.brand h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.brand .tagline { font-size: 0.72rem; color: rgba(255,255,255,0.6); margin-top: 1px; }

/* View switcher */
.view-switcher {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.12);
  padding: 4px;
  border-radius: var(--radius-sm);
}
.view-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  transition: background var(--transition), color var(--transition);
}
.view-btn:hover { color: #fff; background: rgba(255,255,255,0.15); }
.view-btn.active { background: #fff; color: var(--primary-dark); }
@media (max-width: 480px) {
  .view-btn span, .view-btn { padding: 6px 8px; }
  .view-btn { font-size: 0; }
  .view-btn svg { margin: 0; }
}

/* ---- Filters Bar ---- */
.filters-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 64px;
  z-index: 90;
}
.filters-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

/* Search */
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}
#search {
  width: 100%;
  padding: 7px 10px 7px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  background: var(--surface-alt);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
#search:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(82,183,136,0.15); }

/* Date inputs */
.filter-group { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.date-sep { font-size: 0.8rem; color: var(--text-muted); }
input[type="date"],
select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--surface-alt);
  color: var(--text);
  transition: border-color var(--transition);
}
input[type="date"]:focus,
select:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(82,183,136,0.15); }
select { padding-right: 28px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2378716C'%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 6px center;
  background-size: 16px;
}
.clear-btn {
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  transition: color var(--transition), border-color var(--transition);
}
.clear-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---- Results Bar ---- */
.results-bar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.6rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---- Main Content ---- */
#main-content {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 0 1.5rem 3rem;
}

/* ---- Category Badges ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-music    { background: rgba(124,58,237,0.1); color: var(--c-music); }
.badge-arts     { background: rgba(190,24,93,0.1);  color: var(--c-arts); }
.badge-film     { background: rgba(3,105,161,0.1);  color: var(--c-film); }
.badge-comedy   { background: rgba(217,119,6,0.1);  color: var(--c-comedy); }
.badge-community{ background: rgba(21,128,61,0.1);  color: var(--c-community); }
.badge-academia { background: rgba(180,83,9,0.1);   color: var(--c-academia); }
.badge-family   { background: rgba(8,145,178,0.1);  color: var(--c-family); }
.badge-food     { background: rgba(194,65,12,0.1);  color: var(--c-food); }
.badge-outdoor  { background: rgba(22,163,74,0.1);  color: var(--c-outdoor); }
.badge-festival { background: rgba(147,51,234,0.1); color: var(--c-festival); }

/* ============================================================
   LIST VIEW
   ============================================================ */
.list-view { display: flex; flex-direction: column; gap: 2rem; padding-top: 1.5rem; }

.date-group-header {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.list-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}
.list-item:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.list-item-time {
  min-width: 70px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-top: 2px;
}
.list-item-body { flex: 1; min-width: 0; }
.list-item-title {
  font-size: 0.97rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.list-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.list-item-meta .dot::before { content: "·"; margin-right: 0.5rem; }

/* ============================================================
   CARDS VIEW
   ============================================================ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  padding-top: 1.5rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
}
.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
  transform: translateY(-2px);
}
.card-placeholder {
  height: 130px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.4);
}
.card-placeholder svg { width: 40px; height: 40px; }
.card-img { height: 130px; overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 0.9rem 1rem 1rem; flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }
.card-title { font-size: 0.97rem; font-weight: 700; line-height: 1.3; color: var(--text); }
.card-datetime { font-size: 0.8rem; font-weight: 600; color: var(--primary); }
.card-venue { font-size: 0.78rem; color: var(--text-muted); }
.card-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.45; margin-top: 0.25rem; flex: 1; }

/* ============================================================
   CALENDAR VIEW
   ============================================================ */
.calendar-view { padding-top: 1.5rem; }
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.cal-nav-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  font-size: 1rem;
  font-weight: 600;
}
.cal-nav-btn:hover { background: var(--bg); }
.cal-month-label { font-size: 1.2rem; font-weight: 700; flex: 1; }
.cal-today-btn {
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  transition: color var(--transition), border-color var(--transition);
}
.cal-today-btn:hover { color: var(--primary); border-color: var(--primary-light); }
.calendar-grid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-day-names {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.cal-day-name {
  text-align: center;
  padding: 8px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-day {
  min-height: 90px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  vertical-align: top;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day:nth-last-child(-n+7) { border-bottom: none; }
.cal-day:hover { background: var(--surface-alt); }
.cal-day.other-month { background: var(--bg); opacity: 0.5; }
.cal-day.today .cal-day-num {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-day.selected { background: rgba(82,183,136,0.08); }
.cal-day-num { font-size: 0.8rem; font-weight: 600; margin-bottom: 4px; color: var(--text); width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; }
.cal-events { display: flex; flex-direction: column; gap: 2px; }
.cal-pill {
  font-size: 0.68rem;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(45,106,79,0.12);
  color: var(--primary-dark);
  line-height: 1.5;
}
.cal-more {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-style: italic;
  padding-left: 2px;
}

/* Category-colored pills */
.cal-pill.pill-music    { background: rgba(124,58,237,0.12); color: var(--c-music); }
.cal-pill.pill-arts     { background: rgba(190,24,93,0.12);  color: var(--c-arts); }
.cal-pill.pill-film     { background: rgba(3,105,161,0.12);  color: var(--c-film); }
.cal-pill.pill-comedy   { background: rgba(217,119,6,0.12);  color: var(--c-comedy); }
.cal-pill.pill-community{ background: rgba(21,128,61,0.12);  color: var(--c-community); }
.cal-pill.pill-academia { background: rgba(180,83,9,0.12);   color: var(--c-academia); }
.cal-pill.pill-family   { background: rgba(8,145,178,0.12);  color: var(--c-family); }
.cal-pill.pill-food     { background: rgba(194,65,12,0.12);  color: var(--c-food); }
.cal-pill.pill-outdoor  { background: rgba(22,163,74,0.12);  color: var(--c-outdoor); }
.cal-pill.pill-festival { background: rgba(147,51,234,0.12); color: var(--c-festival); }

.cal-day-detail {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.cal-day-detail h3 { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; color: var(--text); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}
.empty-state svg { opacity: 0.25; margin: 0 auto 1rem; }
.empty-state p { font-size: 0.9rem; }

/* ============================================================
   EVENT DETAIL MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  max-width: 540px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  padding: 1.75rem;
}
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition);
}
.modal-close:hover { background: var(--border); }
.modal-category { margin-bottom: 0.75rem; }
.modal-title { font-size: 1.4rem; font-weight: 700; line-height: 1.25; margin-bottom: 0.25rem; }
.modal-source { font-size: 0.75rem; color: var(--text-light); margin-bottom: 1rem; }
.modal-meta { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.modal-meta-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.modal-meta-row svg { flex-shrink: 0; margin-top: 1px; color: var(--primary-light); }
.modal-meta-row strong { color: var(--text); }
.modal-divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.modal-description { font-size: 0.88rem; line-height: 1.65; color: var(--text); margin-bottom: 1.25rem; }
.modal-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 9px 18px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background var(--transition);
  text-decoration: none;
}
.modal-link:hover { background: var(--primary-dark); text-decoration: none; }

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-sub { margin-top: 0.25rem; font-size: 0.75rem; color: var(--text-light); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 700px) {
  .header-inner { height: 56px; }
  header { padding: 0 1rem; }
  .filters-bar { padding: 0.6rem 1rem; top: 56px; }
  .filters-inner { gap: 0.5rem; }
  .filter-group { width: 100%; }
  #main-content { padding: 0 1rem 2rem; }
  .cal-day { min-height: 60px; padding: 4px; }
  .cal-pill { display: none; }
  .cal-day.has-events::after {
    content: '';
    display: block;
    width: 5px;
    height: 5px;
    background: var(--primary);
    border-radius: 50%;
    margin: 2px auto 0;
  }
  .modal { padding: 1.25rem; }
}
