/* ==========================================================================
   Events List Page — Neo-Brutalist Tile Grid
   ========================================================================== */

@font-face {
  font-family: "Nevis";
  src: url("../fonts/Nevis-Bold.woff") format("woff");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Woliu Maners Demo";
  src: url("../fonts/Woliu-Maners-Demo.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

/* ── Page Shell ────────────────────────────────────────────────────────── */

body:has(#eventsListApp) {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

#eventsListApp {
  --events-burst-origin-x: 50%;
  --events-burst-origin-y: 28px;
  position: relative;
  isolation: isolate;
  min-height: 100vh;
}

#eventsListApp::before,
#eventsListApp::after {
  content: "";
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
}

#eventsListApp::before {
  background: repeating-conic-gradient(
    from -0.06deg at var(--events-burst-origin-x) var(--events-burst-origin-y),
    var(--burst-ray-1) 0deg 0.12deg,
    transparent 0.12deg 3.6deg
  );
  -webkit-mask-image: radial-gradient(
    circle at var(--events-burst-origin-x) var(--events-burst-origin-y),
    transparent 0 56px, #000 60px 72%, transparent 94%
  );
  mask-image: radial-gradient(
    circle at var(--events-burst-origin-x) var(--events-burst-origin-y),
    transparent 0 56px, #000 60px 72%, transparent 94%
  );
}

#eventsListApp::after {
  background: repeating-conic-gradient(
    from 1.74deg at var(--events-burst-origin-x) var(--events-burst-origin-y),
    var(--burst-ray-2) 0deg 0.12deg,
    transparent 0.12deg 3.6deg
  );
  -webkit-mask-image: radial-gradient(
    circle at var(--events-burst-origin-x) var(--events-burst-origin-y),
    transparent 0 56px, #000 60px 43%, transparent 58%
  );
  mask-image: radial-gradient(
    circle at var(--events-burst-origin-x) var(--events-burst-origin-y),
    transparent 0 56px, #000 60px 43%, transparent 58%
  );
}

#eventsListApp > * {
  position: relative;
  z-index: 1;
}

/* ── Page Container ────────────────────────────────────────────────────── */

.events-page-container {
  width: min(var(--calendar-max-width), 100%);
  margin: 0 auto;
  border-left: var(--border-width) solid var(--line);
  border-right: var(--border-width) solid var(--line);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: transparent;
}

/* ── Top Navigation Bar ────────────────────────────────────────────────── */

.events-nav-bar {
  min-height: 68px;
  padding: 10px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  border-bottom: var(--border-width) solid var(--line);
  background: var(--paper);
  gap: 12px;
}

.events-nav-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--paper);
  border: var(--border-width) solid var(--line);
  color: var(--ink);
  text-decoration: none;
  border-radius: 6px;
  transition: transform 0.1s ease, background 0.1s ease, box-shadow 0.1s ease;
}

.events-nav-back:hover {
  background: var(--hover-bar);
  box-shadow: 2px 2px 0 var(--line);
  transform: translateY(-1px);
}

.events-nav-back:active {
  transform: translateY(1px);
  box-shadow: none;
}

.events-nav-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: inherit;
  text-decoration: none;
}

.events-nav-brand:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 4px;
  border-radius: 4px;
}

.events-nav-mark {
  display: block;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
}

.events-nav-wordmark {
  color: var(--brand-wordmark-color);
  font-family: "Nevis", "Trebuchet MS", Arial, sans-serif;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.8px;
  white-space: nowrap;
}

.events-nav-country {
  display: inline-block;
  margin-left: 0.1em;
  color: #1f6f2c;
  font-family: "Woliu Maners Demo", Arial, Helvetica, sans-serif;
  font-size: 0.52em;
  font-weight: 400;
  letter-spacing: 0;
  transform: translateY(-0.75em);
}

.events-nav-actions {
  justify-self: end;
}

.events-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  background: var(--paper);
  border: var(--border-width) solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
  border-radius: 6px;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}

.events-add-btn:hover {
  background: var(--hover-bar);
  transform: translateY(-1px);
  box-shadow: 2px 2px 0 var(--line);
}

.events-add-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* ── Compact Filter Toolbar (Thin Category Row + Expandable Search) ────── */

.events-toolbar {
  padding: 8px 18px;
  background: var(--paper);
  border-bottom: var(--border-width) solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Thin horizontal category pill row */
.events-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0;
  flex: 1;
  min-width: 0;
}

.events-filter-row::-webkit-scrollbar {
  display: none;
}

.events-filter-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border: var(--border-thin) solid var(--line);
  border-radius: 9999px;
  color: var(--ink);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  background: var(--paper);
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.events-filter-pill::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.18;
  pointer-events: none;
  background: repeating-linear-gradient(
    -45deg,
    transparent 0 3px,
    var(--texture-line) 3px 4px
  );
}

.events-filter-pill:hover {
  transform: translateY(-1px);
  box-shadow: 1.5px 1.5px 0 var(--line);
}

.events-filter-pill.active {
  border: var(--border-width) solid var(--line);
  box-shadow: 2px 2px 0 var(--line);
  transform: translateY(-1px);
}

/* Right side: Theme toggle + Expandable round search + count badge */
.events-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Theme toggle round icon button */
.theme-toggle-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 9999px;
  background: var(--paper);
  border: var(--border-width) solid var(--line);
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}

.theme-toggle-btn:hover {
  transform: translateY(-1px);
  box-shadow: 2.5px 2.5px 0 var(--line);
  background: var(--hover-bar);
}

.theme-toggle-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* Round search button that expands when clicked */
.events-search-expandable {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--paper);
  border: var(--border-width) solid var(--line);
  border-radius: 9999px;
  height: 32px;
  width: 32px;
  box-shadow: 2px 2px 0 var(--line);
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s ease;
  overflow: hidden;
}

.events-search-expandable:hover {
  box-shadow: 2.5px 2.5px 0 var(--line);
}

.events-search-expandable.is-open {
  width: 220px;
  box-shadow: 3px 3px 0 var(--line);
}

.search-toggle-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--ink);
}

.search-toggle-btn svg {
  width: 14px;
  height: 14px;
}

.search-expand-input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  padding: 0 10px 0 2px;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.events-search-expandable.is-open .search-expand-input {
  opacity: 1;
}

.search-expand-input::placeholder {
  color: #999;
  font-weight: 600;
}

/* Category pill colors */
.events-filter-pill[data-category="ALL"] { background: var(--bg-muted); }
.events-filter-pill[data-category="CTF"] { background: var(--ctf); }
.events-filter-pill[data-category="Hackathon"] { background: var(--hackathon); }
.events-filter-pill[data-category="Datathon"] { background: var(--datathon); }
.events-filter-pill[data-category="CP"] { background: var(--cp); }
.events-filter-pill[data-category="Business Case"] { background: var(--business-case); }
.events-filter-pill[data-category="Fest"] { background: var(--fest); }
.events-filter-pill[data-category="Others"] { background: var(--other); }

/* ── Date Group Headers ────────────────────────────────────────────────── */

.events-feed {
  padding: 0 24px 40px;
  background: transparent;
}

.events-date-group {
  margin-top: 28px;
}

.events-date-group:first-child {
  margin-top: 24px;
}

.date-group-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 10px 0;
  margin-bottom: 16px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg-page) 85%, transparent);
}

.date-group-label {
  margin: 0;
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.date-group-line {
  flex: 1;
  height: 1.5px;
  background: var(--line);
  opacity: 0.5;
}

.date-group-count {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
}

/* ── Card Tile Grid ────────────────────────────────────────────────────── */

.events-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 16px;
}

/* ── Individual Event Card Tile (Strict 16:9 Aspect Ratio) ─────────────── */

.event-tile {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: var(--border-width) solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  aspect-ratio: 16 / 9;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.event-tile:hover {
  transform: translateY(-2px);
  box-shadow: 4px 4px 0 var(--line);
}

.event-tile:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* Card hatched texture overlay (matching EventifyBD style) */
.event-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.12;
  pointer-events: none;
  border-radius: 8px;
  background: repeating-linear-gradient(
    -45deg,
    transparent 0 3px,
    var(--texture-line) 3px 4px
  );
}

/* Category tinted backgrounds */
.event-tile.ctf { background: var(--ctf); }
.event-tile.hackathon { background: var(--hackathon); }
.event-tile.datathon { background: var(--datathon); }
.event-tile.cp { background: var(--cp); }
.event-tile.business-case { background: var(--business-case); }
.event-tile.fest { background: var(--fest); }
.event-tile.other { background: var(--other); }

/* ── Cover Image Card (full-bleed bg + gradient scrim, 16:9) ───────────── */

.event-tile.has-cover {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  text-decoration: none;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

/* Dark gradient scrim — bottom-heavy for text legibility */
.event-tile.has-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.2) 0%,
    rgba(0, 0, 0, 0.05) 30%,
    rgba(0, 0, 0, 0.5) 60%,
    rgba(0, 0, 0, 0.88) 100%
  );
  border-radius: 8px;
  pointer-events: none;
}

/* Disable the hatched texture on image cards */
.event-tile.has-cover::after {
  display: none;
}

/* Override category bg — image IS the background */
.event-tile.has-cover.ctf,
.event-tile.has-cover.hackathon,
.event-tile.has-cover.datathon,
.event-tile.has-cover.cp,
.event-tile.has-cover.business-case,
.event-tile.has-cover.fest,
.event-tile.has-cover.other {
  background-color: transparent;
}

.tile-cover-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px 12px;
  position: relative;
  z-index: 2;
}

.tile-cover-top .tile-category-badge {
  background: rgba(0, 0, 0, 0.55);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 2px 8px;
  font-size: 9.5px;
}

.tile-date-compact {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  padding: 2px 8px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.tile-cover-bottom {
  padding: 8px 12px 10px;
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.event-tile.has-cover .tile-title {
  color: #fff;
  font-size: 14.5px;
  font-weight: 900;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.event-tile.has-cover .tile-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.event-tile.has-cover .tile-detail-row {
  color: rgba(255, 255, 255, 0.9);
  font-size: 11px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.event-tile.has-cover .tile-detail-row svg {
  color: rgba(255, 255, 255, 0.95);
  width: 11px;
  height: 11px;
}

/* ── Date Block (top of card without cover) ────────────────────────────── */

.tile-date-block {
  padding: 8px 12px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.tile-date-info {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.tile-date-day {
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.tile-date-meta {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tile-date-weekday {
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.tile-date-month {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #666;
}

/* ── Category Badge ────────────────────────────────────────────────────── */

.tile-category-badge {
  display: inline-flex;
  align-items: center;
  font-size: 9.5px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  background: var(--paper);
  border: var(--border-thin) solid var(--line);
  border-radius: 9999px;
  color: var(--ink);
  position: relative;
  z-index: 1;
  white-space: nowrap;
}

/* ── Card Body (non-cover tile) ────────────────────────────────────────── */

.tile-body {
  flex: 1;
  min-height: 0;
  padding: 2px 12px 4px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.tile-title {
  margin: 0;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tile-detail-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  line-height: 1.2;
}

.tile-detail-row svg {
  width: 11px;
  height: 11px;
}

.tile-detail-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ── Card Footer / CTA (non-cover tile) ────────────────────────────────── */

.tile-footer {
  padding: 4px 12px 8px;
  border-top: var(--border-thin) solid rgba(0, 0, 0, 0.08);
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
}

.tile-details-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: var(--paper);
  border: var(--border-thin) solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  text-decoration: none;
  font-size: 11px;
  font-weight: 900;
  transition: background 0.1s ease, transform 0.1s ease;
}

.tile-details-link:hover {
  background: var(--hover-bar);
  transform: translateY(-1px);
}

.tile-details-link:active {
  transform: translateY(1px);
}

/* ── Empty / Loading / Error States ────────────────────────────────────── */

.events-loading {
  padding: 60px 24px;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  color: #888;
}

.events-empty {
  padding: 60px 24px;
  text-align: center;
}

.events-empty-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 900;
  color: var(--ink);
}

.events-empty-text {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #888;
}

.events-error {
  padding: 60px 24px;
  text-align: center;
}

.events-error h2 {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 900;
}

.events-error p {
  margin: 0 0 20px;
  font-size: 14px;
  color: #666;
}

.events-retry-btn {
  padding: 10px 18px;
  border: var(--border-width) solid var(--line);
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.events-retry-btn:hover {
  background: #333;
}

/* ── Past Events Toggle ────────────────────────────────────────────────── */

.events-past-toggle {
  display: flex;
  justify-content: center;
  padding: 24px 0 8px;
}

.events-past-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--paper);
  border: var(--border-width) solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.events-past-btn:hover {
  transform: translateY(-1px);
  box-shadow: 3px 3px 0 var(--line);
}

.events-past-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* ── Skeleton shimmer (matches 16:9 tile ratio) ────────────────────────── */

.tile-skeleton {
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  border: var(--border-width) solid var(--line);
  background: linear-gradient(90deg, #eee 25%, #e2e2e2 50%, #eee 75%);
  background-size: 200% 100%;
  animation: events-shimmer 1.5s infinite;
}

@keyframes events-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .events-page-container {
    border-left: 0;
    border-right: 0;
  }

  .events-nav-bar {
    min-height: 56px;
    padding: 8px 12px;
    gap: 8px;
  }

  .events-nav-back {
    width: 32px;
    height: 32px;
  }

  .events-nav-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .events-nav-wordmark {
    font-size: 28px;
  }

  .events-add-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .events-add-btn span {
    display: none;
  }

  .events-add-btn svg {
    width: 14px;
    height: 14px;
  }

  .events-toolbar {
    padding: 6px 12px;
    gap: 8px;
  }

  .events-search-expandable.is-open {
    width: 150px;
  }

  .events-filter-pill {
    padding: 2.5px 8px;
    font-size: 9.5px;
  }

  .events-feed {
    padding: 0 12px 30px;
  }

  .events-tile-grid {
    gap: 12px;
  }

  .tile-date-day {
    font-size: 20px;
  }

  .tile-title {
    font-size: 13.5px;
  }

  .tile-detail-row {
    font-size: 10.5px;
  }

  .date-group-header {
    margin-bottom: 10px;
  }

  .date-group-label {
    font-size: 12.5px;
  }
}
