@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Neutrals + accents: Gruvbox's dark palette — a well-known "warm,
     retro" dark theme (its whole premise is warm grays instead of the
     cool blue-grays most dark UIs default to), so the base of the page
     is dark and warm-toned from the start, not white with a few warm
     accents sprinkled on. */
  --bg: #1d2021;         /* gruvbox bg0_h — page background */
  --surface: #282828;    /* gruvbox bg0 — cards, header */
  --text: #ebdbb2;       /* gruvbox fg1 */
  --text-muted: #a89984; /* gruvbox fg4 */
  --checkbox-bg: #d5c4a1; /* gruvbox fg2 — light brown/tan */
  --border: #3c3836;     /* gruvbox bg1 */
  --border-strong: #504945; /* gruvbox bg2 */

  /* Today: gruvbox's bright green/olive — the one "go/now" signal. */
  --today: #b8bb26;
  --today-text: #1d2021; /* dark text on the light badge */
  --today-row-bg: #494532; /* bg1 tinted toward gruvbox's neutral green */

  /* Tomorrow: gruvbox's bright yellow — one step down from TODAY, same
     "solid badge + shine" treatment, distinct hue. Only its date cell
     is colored; the rest of the row stays at its normal day tier. */
  --tomorrow: #fabd2f;
  --tomorrow-text: #1d2021;

  /* Day-of-week gradient: one warm hue (gruvbox's orange), tinted into
     the base surface at increasing strength — the same "surface tint"
     technique Material Design 3 uses for dark-theme elevation, so the
     row background stays dark throughout instead of getting lighter
     and washed out at the "darkest" (most saturated) end. */
  --day-weekday-bg: #3c3836; /* = --border, i.e. barely there */
  --day-frisun-bg: #4e382e;
  --day-sat-bg: #5e3927;

  /* Accent: gruvbox's bright blue for links, bright purple reserved
     for the "next month" marker — two distinct cool hues against the
     warm base, each meaning one specific thing. */
  --link: #83a598;
  --link-hover: #99b5ab;
  --next-month: #d3869b;

  --danger: #fb4934;
}

* { box-sizing: border-box; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 400;
  margin: 0;
  padding: 2rem clamp(1rem, 4vw, 3rem);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 1.1rem;
  letter-spacing: -0.015em;
}
h1 #targetLabel { color: var(--text-muted); font-weight: 500; }

.controls {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
  align-items: center;
}
.controls label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}
input {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
input#search { min-width: 240px; padding-right: 2.1rem; }
input::placeholder { color: var(--checkbox-bg); opacity: 1; }
input:focus {
  outline: 2px solid var(--link);
  outline-offset: -1px;
}
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

input[type="checkbox"] {
  /* accent-color alone doesn't work here: once a browser themes a
     checkbox via accent-color it draws the unchecked box itself and
     ignores our background/border, so it stays the native glaring
     white box. appearance: none hands the whole box to us instead. */
  appearance: none;
  -webkit-appearance: none;
  background: var(--checkbox-bg); /* gruvbox fg2 — light brown, not a glaring white box */
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  width: 1rem;
  height: 1rem;
  padding: 0;
  margin: 0;
  cursor: pointer;
  position: relative;
}
input[type="checkbox"]:checked {
  background: var(--link);
  border-color: var(--link);
}
input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 0px;
  width: 4px;
  height: 8px;
  border: solid var(--surface);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.search-wrap { position: relative; display: flex; }
.search-clear {
  position: absolute;
  top: 50%;
  right: 0.6rem;
  transform: translateY(-50%);
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}
.search-clear:hover { color: var(--danger); }

.count { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; margin-bottom: 0.6rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.3rem 0.3rem 0.3rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--border);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.chip-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}
.chip-remove:hover { color: var(--danger); background: rgba(255, 255, 255, 0.08); }

/* Venue / neighborhood filter: a button that opens a checklist panel */
.filter-dropdown { position: relative; display: flex; align-items: stretch; }
.filter-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-width: 15.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  text-align: left;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.filter-toggle:hover { border-color: var(--text-muted); }
.filter-toggle:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: -1px;
}
.filter-toggle span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-toggle::after {
  content: "▾";
  color: var(--text-muted);
  font-size: 0.75rem;
  flex: none;
}
.filter-clear {
  position: absolute;
  top: 50%;
  right: 1.85rem;
  transform: translateY(-50%);
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}
.filter-clear:hover { color: var(--danger); }
.filter-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 10;
  min-width: 12rem;
  max-height: 16rem;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  padding: 0.4rem;
}
.filter-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
}
.filter-option:hover { background: var(--bg); }
.filter-group-label {
  padding: 0.3rem 0.5rem 0.15rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.filter-separator {
  margin: 0.3rem 0.2rem;
  border-top: 1px solid var(--border);
}

/* Themed scrollbar for the filter panel (Firefox + WebKit/Chromium) */
.filter-panel {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) var(--surface);
}
.filter-panel::-webkit-scrollbar { width: 10px; }
.filter-panel::-webkit-scrollbar-track { background: var(--surface); }
.filter-panel::-webkit-scrollbar-thumb {
  background-color: var(--border-strong);
  border-radius: 999px;
  border: 2px solid var(--surface);
}
.filter-panel::-webkit-scrollbar-thumb:hover { background-color: var(--text-muted); }

.share-link {
  padding: 0.5rem 0.25rem;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--link);
  cursor: pointer;
}
.share-link:hover { color: var(--link-hover); text-decoration: underline; }
.share-link:disabled { cursor: default; opacity: 0.75; text-decoration: none; }

.table-card {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  overflow: hidden;
  box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.6);
}

table { border-collapse: collapse; width: 100%; }

th, td { text-align: left; padding: 0.6rem 0.85rem; vertical-align: top; }
td { border-bottom: 1px solid var(--border); }

th {
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 2;
}
th[data-key] { cursor: pointer; user-select: none; }
th[data-key]:hover { color: var(--text); }

img.thumb { width: 150px; height: 112px; object-fit: cover; border-radius: 8px; background: var(--border); display: block; }

/* Row states */
tr.cancelled { opacity: 0.55; }
tr.cancelled .title::after { content: " (cancelled)"; color: var(--danger); font-weight: 600; }

/* Full-row color by day tier — see the --day-* palette above. Text
   stays --text throughout; all three tiers are dark enough that it
   never needs to change per tier. TODAY outranks the day tier
   entirely (handled by td.gutter.gutter-today below, which is
   specific enough to win over these). */
tr.row-weekday > td { background: var(--day-weekday-bg); }
tr.row-frisun > td { background: var(--day-frisun-bg); }
tr.row-sat > td { background: var(--day-sat-bg); }
tr.row-today > td { background: var(--today-row-bg); }

tbody tr:hover > td { filter: brightness(1.08); }

tr.day-start > td { border-top: 2px solid var(--border-strong); }

a.title { color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.03em; letter-spacing: -0.005em; }
a.title:hover { color: var(--link); text-decoration: underline; }
a.venue { color: var(--link); text-decoration: none; font-weight: 600; }

/* Narrow view: Organizer and Venue (below) are hidden below this width
   and folded into extra lines under the title instead — using their
   own existing markup/formatting as-is — while Date and Image stay
   their own columns unchanged. See the matching .title-meta rule. */
.title-meta {
  display: none;
  font-size: 0.85rem;
}
.title-meta > div + div { margin-top: 0.15rem; }
a.venue:hover { color: var(--link-hover); text-decoration: underline; }

/* Date / gutter column — sortable, carries weekday + day + time, each
   on its own line like a calendar entry. */
.gutter {
  width: 5.25rem;
  min-width: 5.25rem;
  padding: 0.55rem 0.5rem;
  text-align: center;
  border-right: 1px solid var(--border);
}
/* A block child of a table cell resolves height:100% against the
   cell's real (row-determined) height reliably — putting display:flex
   directly on the <td> itself does not, in some browsers. */
.gutter-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.gutter-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}
.gutter-day {
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  color: var(--text);
}
/* Next month: same digit, just darker/dimmer than the bright default —
   it recedes a little, signaling "later" without any extra decoration. */
.gutter-day--next {
  color: var(--text-muted);
}
.gutter-time {
  font-size: 0.78rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.gutter-year {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
}
.gutter-relative {
  /* Pushed to the actual bottom of the cell (inside its padding) via
     the flex column on .gutter, instead of just trailing the time. */
  margin-top: auto;
  padding-top: 0.3rem;
  font-size: 0.6rem;
  font-weight: 600;
  font-style: italic;
  color: var(--text-muted);
}

/* TODAY gets a solid badge on top of the row tint — the two combined
   classes on the same <td> give this more specificity than the plain
   "tr.row-* > td" rules above, so it reliably wins instead of being
   silently overridden by them. */
td.gutter.gutter-today,
td.gutter.gutter-tomorrow {
  position: relative;
  overflow: hidden;
}
td.gutter.gutter-today { background: var(--today); }
td.gutter.gutter-tomorrow { background: var(--tomorrow); }

td.gutter.gutter-today .gutter-label,
td.gutter.gutter-today .gutter-day,
td.gutter.gutter-today .gutter-time,
td.gutter.gutter-today .gutter-relative {
  color: var(--today-text);
}
td.gutter.gutter-tomorrow .gutter-label,
td.gutter.gutter-tomorrow .gutter-day,
td.gutter.gutter-tomorrow .gutter-time,
td.gutter.gutter-tomorrow .gutter-relative {
  color: var(--tomorrow-text);
}
td.gutter.gutter-today .gutter-time,
td.gutter.gutter-today .gutter-relative,
td.gutter.gutter-tomorrow .gutter-time,
td.gutter.gutter-tomorrow .gutter-relative {
  opacity: 0.75;
}

/* A slow, gentle shine sweeping across the TODAY and TOMORROW badges
   every few seconds — a quiet "this one's alive" touch, not a loud
   animation. */
td.gutter.gutter-today::after,
td.gutter.gutter-tomorrow::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 40%,
    rgba(255, 255, 255, 0.4) 50%,
    transparent 60%
  );
  background-size: 250% 100%;
  background-position: 180% 0;
  animation: today-shine 5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes today-shine {
  /* Start/end positions are one full background-tile-period apart
     (250% size over a 100%-wide element → 500/3% period) and centered
     in the fully-off-screen zone, so the loop restart from 100% back
     to 0% lands on an identical, invisible frame instead of jumping. */
  0%, 25% { background-position: 133.33% 0; }
  70%, 100% { background-position: -33.33% 0; }
}
@media (prefers-reduced-motion: reduce) {
  td.gutter.gutter-today::after,
  td.gutter.gutter-tomorrow::after {
    animation: none;
  }
}

/* Month section headers — a plain divider; the only color lives in the
   small tag pill, not the whole row (the row itself carries the
   distinction via the outlined next-month day numbers). */
tr.month-header { cursor: pointer; user-select: none; }
tr.month-header:hover td { background: var(--border); }
tr.month-header:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: -2px;
}
tr.month-header td {
  padding: 0.65rem 0.85rem;
  font-weight: 700;
  background: var(--surface);
  color: var(--text);
  border-bottom: 2px solid var(--border-strong);
  border-top: none;
}
.month-header-chevron {
  display: inline-block;
  width: 1rem;
  margin-right: 0.3rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.month-header-name { font-size: 0.95rem; font-weight: 800; letter-spacing: -0.01em; }
.month-header-count {
  margin-left: 0.6rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}
.month-header-tag {
  margin-left: 0.6rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  vertical-align: middle;
}

/* Narrow view: a real stacked card per event instead of a squeezed
   5-column table row. Sorting only by date is fine here — the column
   headers (where sort clicks live) are hidden entirely, since a
   column-header row doesn't mean anything above a stack of cards. */
@media (max-width: 960px) {
  /* One control per line, each filling the row's full width (instead
     of sitting at its wide-view min-width with dead space beside it). */
  .controls > * { flex: 1 1 100%; }
  input#search { width: 100%; min-width: 0; }
  .filter-toggle { flex: 1 1 auto; min-width: 0; }
  .share-link { text-align: left; }

  thead { display: none; }
  td.col-organizer,
  td.col-venue {
    display: none;
  }
  .title-meta { display: block; }

  /* The table itself no longer draws a single frame around every row —
     each row is about to become its own card with its own border. */
  .table-card {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }
  table, tbody { display: block; width: 100%; }

  /* Date stays a left sidebar spanning the card's full height; Image
     moves on top of Title (freeing it to be far wider than its old
     150px column) instead of squeezed beside it in a third column. */
  tbody tr:not(.month-header) {
    display: grid;
    grid-template-columns: 5.25rem 1fr;
    grid-template-rows: auto auto;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0.75rem;
  }
  /* The card's single background now lives on the row (so it also
     fills the grid gap/seam between Image and Title), not per-cell. */
  tbody tr:not(.month-header) > td {
    background: transparent;
    border-top: none;
    border-bottom: none;
  }
  tr.row-weekday { background: var(--day-weekday-bg); }
  tr.row-frisun { background: var(--day-frisun-bg); }
  tr.row-sat { background: var(--day-sat-bg); }
  tr.row-today { background: var(--today-row-bg); }
  tbody tr:not(.month-header):hover { filter: brightness(1.08); }

  td.gutter { grid-column: 1; grid-row: 1; }
  td:has(> a.title) { grid-column: 2; grid-row: 1; }
  td.col-image { grid-column: 1 / 3; grid-row: 2; padding: 0; }
  img.thumb { width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 0; }

  /* Month headers stay plain full-width dividers, not cards — just a
     little breathing room before the cards below, no heavy rule. */
  tr.month-header { display: block; background: transparent; border: none; margin-bottom: 0.5rem; }
  tr.month-header td { display: block; padding: 0.65rem 0.85rem; border-bottom: none; }
}
