:root {
  --bg: #faf7f2;
  --ink: #2b2620;
  --muted: #7a7267;
  --accent: #b3502d;
  --line: #e6dfd4;
  --card: #ffffff;
  --music: #7c5cbf;
  --food: #b3502d;
  --community: #3a7d5d;
  --art: #c04f7c;
  --family: #d1882a;
  --market: #5b8c2a;
  --talks: #3c6e9f;
  --fitness: #2a9d8f;
  --other: #8a8177;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

main { max-width: 1080px; margin: 0 auto; padding: 0 1rem 3rem; }
main .event-detail, main .comments-section { max-width: 720px; margin-left: auto; margin-right: auto; }

.site-header {
  text-align: center;
  padding: 2rem 1rem 1rem;
  border-bottom: 3px double var(--line);
  margin-bottom: 1rem;
}
.site-title {
  font-size: 1.9rem;
  font-weight: bold;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.01em;
}
.site-title span { color: var(--accent); font-style: italic; }
.tagline { color: var(--muted); margin: 0.3rem 0 0; font-style: italic; font-size: 0.95rem; }

.site-footer {
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding: 1rem;
  font-size: 0.9rem;
}
.site-footer a { color: var(--muted); }

.cat-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.75rem 0;
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.85rem;
}
.cat-filter a {
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
  background: var(--card);
}
.cat-filter a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.day h2 {
  font-size: 1.1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.3rem;
  margin: 1.6rem 0 0.5rem;
}

/* Event cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.1rem;
  margin: 0.8rem 0 0.4rem;
}
.event-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(43, 38, 32, 0.06);
}
.card-media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--line);
}
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-media.favicon .favicon-blur {
  position: absolute;
  inset: -12%;
  width: 124%;
  height: 124%;
  object-fit: cover;
  filter: blur(24px) saturate(1.1);
  opacity: 0.55;
}
.card-media.favicon .favicon-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 12px;
}
/* Low-res favicons (< 64px intrinsic) get shrunk and softly blurred so the
   upscaling artifacts don't show; flagged client-side from naturalWidth. */
.card-media.favicon .favicon-icon.lowres {
  width: 48px;
  height: 48px;
  filter: blur(1.2px);
}
.card-media.placeholder { display: flex; align-items: center; justify-content: center; }
.placeholder-letter {
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: bold;
}
.cat-bg-music.placeholder { background: var(--music); }
.cat-bg-food-drink.placeholder { background: var(--food); }
.cat-bg-community.placeholder { background: var(--community); }
.cat-bg-art.placeholder { background: var(--art); }
.cat-bg-family.placeholder { background: var(--family); }
.cat-bg-market.placeholder { background: var(--market); }
.cat-bg-talks.placeholder { background: var(--talks); }
.cat-bg-fitness.placeholder { background: var(--fitness); }
.cat-bg-other.placeholder { background: var(--other); }
.cat-bg-music.favicon { background: var(--music); }
.cat-bg-food-drink.favicon { background: var(--food); }
.cat-bg-community.favicon { background: var(--community); }
.cat-bg-art.favicon { background: var(--art); }
.cat-bg-family.favicon { background: var(--family); }
.cat-bg-market.favicon { background: var(--market); }
.cat-bg-talks.favicon { background: var(--talks); }
.cat-bg-fitness.favicon { background: var(--fitness); }
.cat-bg-other.favicon { background: var(--other); }

.date-badge {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  background: #fff;
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  text-align: center;
  line-height: 1.1;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
}
.date-badge strong { font-size: 1.05rem; color: var(--ink); }
.date-badge span { font-size: 0.66rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.card-cat { position: absolute; top: 0.6rem; right: 0.6rem; font-family: -apple-system, "Helvetica Neue", Arial, sans-serif; }

.card-body {
  padding: 0.8rem 0.9rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}
.card-body h3 { margin: 0; font-size: 1.05rem; line-height: 1.3; }
.card-body h3 a { color: var(--ink); text-decoration: none; }
.card-body h3 a:hover { color: var(--accent); }
.card-line {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.82rem;
}
.card-line svg { flex: 0 0 auto; }
.card-button {
  margin-top: auto;
  align-self: flex-start;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.82rem;
  padding: 0.4rem 0.95rem;
  border-radius: 7px;
  margin-top: 0.55rem;
}
.card-button:hover { background: var(--accent); }

.cat {
  padding: 0.06rem 0.5rem;
  border-radius: 999px;
  color: #fff;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
}
.cat-music { background: var(--music); }
.cat-food-drink { background: var(--food); }
.cat-community { background: var(--community); }
.cat-art { background: var(--art); }
.cat-family { background: var(--family); }
.cat-market { background: var(--market); }
.cat-talks { background: var(--talks); }
.cat-fitness { background: var(--fitness); }
.cat-other { background: var(--other); }

.empty { color: var(--muted); font-style: italic; }

.event-detail h1 { margin-bottom: 0.2rem; }
.event-detail .crumb { font-size: 0.85rem; }
.event-detail .crumb a { color: var(--muted); text-decoration: none; }
.event-detail .when { font-size: 1.05rem; margin: 0.2rem 0; }
.event-detail .address, .event-detail .source { font-size: 0.9rem; }
.event-detail a { color: var(--accent); }
.description { background: var(--card); border: 1px solid var(--line); padding: 0.8rem 1rem; border-radius: 8px; }

.comments-section { margin-top: 2.5rem; border-top: 3px double var(--line); padding-top: 1rem; }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-list li { border-bottom: 1px dotted var(--line); padding: 0.6rem 0; }
.comment-list .who { font-weight: bold; }
.comment-list .when { color: var(--muted); font-size: 0.8rem; margin-left: 0.5rem; }
.comment-list p { margin: 0.2rem 0 0; white-space: pre-wrap; }

.comment-form { margin-top: 1.2rem; display: flex; flex-direction: column; gap: 0.7rem; }
.comment-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.comment-form input[type="text"], .comment-form textarea {
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
}
.comment-form button, .admin button {
  align-self: flex-start;
  font: inherit;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1.1rem;
  cursor: pointer;
}
.comment-form .fine-print { color: var(--muted); font-size: 0.78rem; margin: 0; }

/* Honeypot: visually removed, still in the DOM for bots to find. */
.hp-field { position: absolute; left: -9999px; top: -9999px; }

.flash { padding: 0.5rem 0.8rem; border-radius: 6px; font-size: 0.9rem; }
.flash.ok { background: #e5f2e5; color: #275d2b; }
.flash.bad { background: #f7e4e0; color: #8c2f1b; }

.admin table { border-collapse: collapse; width: 100%; font-size: 0.85rem; font-family: -apple-system, Arial, sans-serif; }
.admin th, .admin td { border: 1px solid var(--line); padding: 0.3rem 0.5rem; text-align: left; }
.admin tr.failed td { background: #f7e4e0; }
.admin .err { font-size: 0.75rem; color: #8c2f1b; }
.admin details { margin: 0.5rem 0; }
.admin button.danger { background: #8c2f1b; padding: 0.2rem 0.7rem; font-size: 0.8rem; }
.admin-comments form { display: inline; }

/* Detail-page meta row (category pill + venue) */
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Event detail image: square photo, or blurred-favicon square when that's
   all the event's site offers. */
.event-detail .event-photo {
  display: block;
  width: 280px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  margin: 0.6rem 0 1rem;
}
.event-detail .event-photo.favicon {
  position: relative;
  overflow: hidden;
  background: var(--line);
}
.event-detail .event-photo.favicon .favicon-blur {
  position: absolute;
  inset: -12%;
  width: 124%;
  height: 124%;
  object-fit: cover;
  filter: blur(28px) saturate(1.1);
  opacity: 0.6;
}
.event-detail .event-photo.favicon .favicon-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 96px;
  height: 96px;
  object-fit: contain;
  border-radius: 14px;
}

@media (max-width: 520px) {
  .card-grid { grid-template-columns: 1fr; }
}
