/* rundex-web — Night Sprint redesign. */

:root {
  --bg:           #0f0e0c;
  --surface:      #1b1917;
  --surface-hi:   #242220;
  --border:       #2e2c28;
  --border-hi:    #3e3c38;

  --accent:       oklch(62% 0.22 38);
  --accent-dim:   oklch(55% 0.22 38);
  --accent-faint: oklch(62% 0.22 38 / 0.14);
  --accent-ink:   oklch(99% 0.008 38);

  --ink:          #f0ebe3;
  --ink-soft:     #857f77;
  --ink-faint:    #46433f;

  --free:         oklch(70% 0.17 145);
  --free-bg:      oklch(35% 0.14 145 / 0.18);
  --free-border:  oklch(58% 0.18 145 / 0.30);

  --mono: 'Overpass Mono', 'Courier New', monospace;
  --cond: 'Barlow Condensed', sans-serif;
  --body: 'Barlow', system-ui, sans-serif;

  --radius:   8px;
  --topbar-h: 54px;
}

* { box-sizing: border-box; }
/* Ensure the hidden attribute always works inside grid/flex containers. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  /* Very subtle diagonal stripe texture — like a track surface. */
  background-image: repeating-linear-gradient(
    -55deg,
    transparent,
    transparent 48px,
    oklch(100% 0 0 / 0.013) 48px,
    oklch(100% 0 0 / 0.013) 49px
  );
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  font-kerning: normal;
}

/* --- skip link ------------------------------------------------------------- */

.skip-link {
  position: absolute;
  top: -100%;
  left: 12px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 0 0 var(--radius) var(--radius);
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  z-index: 200;
  padding: 6px 16px;
  transition: top 0.1s ease-out;
}
.skip-link:focus-visible { top: 0; outline: none; }

/* --- topbar ----------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: oklch(10% 0.006 38 / 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 1;
  min-width: 0;
}

.topbar-logo {
  font-family: var(--cond);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
}

.topbar-city {
  margin: 0;
  font-family: var(--cond);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  text-transform: uppercase;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: stretch;
  gap: 14px;
}


/* --- sidebar ---------------------------------------------------------------- */

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  scrollbar-width: none;
  padding: 24px 24px 24px 16px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.sidebar::-webkit-scrollbar { display: none; }

.filterbar-search-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filterbar-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
}

.filterbar-search-icon {
  position: absolute;
  left: 9px;
  color: var(--ink-faint);
  pointer-events: none;
  flex-shrink: 0;
}

.filterbar-search {
  width: 100%;
  padding: 5px 10px 5px 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 0.82rem;
  line-height: 1.4;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.filterbar-search::placeholder { color: var(--ink-faint); }

.filterbar-search::-webkit-search-decoration,
.filterbar-search::-webkit-search-cancel-button { -webkit-appearance: none; }

.filterbar-search:focus {
  border-color: var(--accent);
  background: var(--surface-hi);
}

.filter-count {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  white-space: nowrap;
  flex-shrink: 0;
}

.filterbar-chips {
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.filterbar-chips::-webkit-scrollbar { display: none; }

.sidebar .filterbar-chips {
  flex-direction: column;
  overflow-x: hidden;
  gap: 5px;
  align-items: flex-start;
}

.sidebar .filter-chip {
  white-space: nowrap;
  width: auto;
}

.filter-chip {
  padding: 4px 10px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.69rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: 1px solid var(--border-hi);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.filter-chip:hover {
  background: var(--surface-hi);
  color: var(--ink);
  border-color: var(--border-hi);
}

.filter-chip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.filter-chip--free {
  color: var(--free);
  border-color: var(--free-border);
}

.filter-chip--free:hover {
  background: var(--free-bg);
  border-color: var(--free-border);
  color: var(--free);
}

.filter-chip--free[aria-pressed="true"] {
  background: var(--free-bg);
  border-color: var(--free-border);
  color: var(--free);
}

/* --- layout ----------------------------------------------------------------- */

.wrap {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 72px;
}

.wrap:has(.layout) { max-width: none; padding: 0; }

.layout {
  display: grid;
  grid-template-columns:
    max(160px, calc((100% - 1280px) / 2))
    minmax(0, 1280px)
    max(160px, calc((100% - 1280px) / 2));
  column-gap: 0;
  align-items: start;
}

.events-col {
  min-width: 0;
  padding: 24px 32px 72px 24px;
}

/* --- month section ---------------------------------------------------------- */

.month {
  margin-bottom: 40px;
}

.month-header {
  position: sticky;
  top: var(--topbar-h);
  z-index: 10;
  margin: 0 0 20px;
  padding: 12px 0 10px;
  font-family: var(--cond);
  font-size: clamp(1.7rem, 3.5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--bg);
  background-image: repeating-linear-gradient(
    -55deg,
    transparent,
    transparent 48px,
    oklch(100% 0 0 / 0.013) 48px,
    oklch(100% 0 0 / 0.013) 49px
  );
  border-bottom: 2px solid var(--accent);
  display: flex;
  align-items: center;
  gap: 14px;
}

.month-header::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* --- week group ------------------------------------------------------------- */

.week-group {
  margin-bottom: 36px;
}

.week-group + .week-group {
  padding-top: 24px;
}

.week-header {
  margin: 0 0 18px;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: oklch(60% 0.006 38);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Accent dash prefix — echoes the month bullet */
.week-header::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 2px;
  background: var(--accent);
  flex-shrink: 0;
}

/* Rule that extends to the right edge — makes the label clearly readable as a divider */
.week-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-hi);
}

/* --- cards grid ------------------------------------------------------------- */

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 10px;
}

/* --- card ------------------------------------------------------------------- */

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  animation: card-in 0.28s ease-out both;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}

.card:hover {
  background: var(--surface-hi);
  border-color: var(--border-hi);
  box-shadow: 0 4px 20px oklch(0% 0 0 / 0.35), 0 0 0 1px var(--border-hi);
  transform: translateY(-2px);
}

/* Stagger first 16 cards per grid container. */
.card:nth-child(1)  { animation-delay: 0.02s; }
.card:nth-child(2)  { animation-delay: 0.05s; }
.card:nth-child(3)  { animation-delay: 0.08s; }
.card:nth-child(4)  { animation-delay: 0.11s; }
.card:nth-child(5)  { animation-delay: 0.14s; }
.card:nth-child(6)  { animation-delay: 0.17s; }
.card:nth-child(7)  { animation-delay: 0.20s; }
.card:nth-child(8)  { animation-delay: 0.23s; }
.card:nth-child(9)  { animation-delay: 0.26s; }
.card:nth-child(10) { animation-delay: 0.29s; }
.card:nth-child(11) { animation-delay: 0.32s; }
.card:nth-child(12) { animation-delay: 0.35s; }
.card:nth-child(13) { animation-delay: 0.38s; }
.card:nth-child(14) { animation-delay: 0.41s; }
.card:nth-child(15) { animation-delay: 0.44s; }
.card:nth-child(16) { animation-delay: 0.47s; }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-date {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.date-rel {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-faint);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.card-name {
  margin: 0;
  font-family: var(--cond);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.22;
  color: var(--ink);
  overflow-wrap: break-word;
}

.card-loc {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  overflow: hidden;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding-top: 4px;
  margin-top: auto;
}

/* --- tags ------------------------------------------------------------------- */

.tag {
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.69rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.tag-distance {
  background: var(--surface-hi);
  color: var(--ink-soft);
  border-color: var(--border);
}

.tag-price {
  background: var(--surface-hi);
  color: var(--ink);
  border-color: var(--border);
  font-variant-numeric: tabular-nums;
}

.tag-free {
  background: var(--free-bg);
  color: var(--free);
  border-color: var(--free-border);
}

/* --- card actions ----------------------------------------------------------- */

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.1s, color 0.1s, border-color 0.1s, transform 0.08s;
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--surface-hi);
  color: var(--ink);
  border-color: var(--border-hi);
}

.btn-icon:active { transform: scale(0.96); }

.btn-icon--accent {
  width: auto;
  height: auto;
  padding: 7px 10px;
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.btn-icon--accent:hover {
  background: var(--accent-dim);
  color: var(--accent-ink);
  border-color: transparent;
}

/* --- buttons ---------------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: 7px 13px;
  border-radius: 6px;
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.8rem;
  text-decoration: none;
  text-align: center;
  border: 1px solid transparent;
  transition: background 0.1s, color 0.1s, transform 0.08s;
  cursor: pointer;
  white-space: nowrap;
}

.btn:active { transform: scale(0.96); }

.btn-subscribe {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 7px 18px;
  font-size: 0.85rem;
}
.btn-subscribe:hover { background: var(--accent-dim); color: var(--accent-ink); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  flex: 1;
}
.btn-primary:hover { background: var(--accent-dim); color: var(--accent-ink); }

.btn-secondary {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--border);
  flex: 1;
}
.btn-secondary:hover {
  background: var(--surface-hi);
  color: var(--ink);
  border-color: var(--border-hi);
}

/* --- misc ------------------------------------------------------------------- */

.empty {
  margin: 80px 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.empty-msg {
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--cond);
  font-size: 1.3rem;
  letter-spacing: 0.06em;
}

.empty-hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  max-width: 36ch;
  line-height: 1.5;
}

.site-footer {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 24px 32px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.73rem;
  color: var(--ink-soft);
}

a { color: var(--accent); }
a:hover { color: var(--accent-dim); }

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* --- sticky subscribe bar (mobile only) ------------------------------------ */

.subscribe-sticky { display: none; }

/* --- responsive ------------------------------------------------------------- */

@media (max-width: 900px) {
  .topbar { padding: 0 16px; }
  .events-col { padding: 20px 16px 72px 16px; }
}

@media (max-width: 768px) {
  .layout {
    display: flex;
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    position: sticky;
    top: var(--topbar-h);
    z-index: 90;
    max-height: none;
    overflow-y: visible;
    padding: 8px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    background: oklch(10% 0.006 38 / 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .sidebar .filterbar-chips {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
  }

  .sidebar .filter-chip {
    width: auto;
    white-space: nowrap;
  }

  .events-col { padding: 16px 0 72px; }

  .month-header { position: static; }
}

@media (max-width: 600px) {
  .topbar { padding: 0 14px; }
  .wrap { padding: 20px 14px calc(48px + 48px); }
  .sidebar { padding: 8px 0; }
  /* Visually hidden but stays in the a11y tree — provides the page h1 for screen readers. */
  .topbar-city {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .events-col { padding: 16px 0 calc(48px + 48px); }
  .cards { grid-template-columns: 1fr; }

  .btn-primary { min-height: 44px; }
  .btn-icon { width: 44px; height: 44px; }

  .subscribe-sticky {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    background: oklch(10% 0.006 38 / 0.97);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 50;
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.22s ease-out, transform 0.22s ease-out;
    pointer-events: none;
  }

  .subscribe-sticky.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .subscribe-sticky .btn-subscribe {
    flex: 1;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    padding: 10px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card             { animation: none; transition: none; }
  .btn              { transition: none; }
  .btn-icon         { transition: none; }
  .skip-link        { transition: none; }
  .subscribe-sticky { transition: none; }
}
