.slideout-trigger {
  background-color: var(--color-blue-100);
  color: var(--color-white);
  padding: 10px 25px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.3s ease;
  white-space: nowrap;
  position: static;
  transform: none;
  writing-mode: unset;
  text-orientation: unset;
  /* It is a <button>, so drop the UA styling and keep the inherited type. */
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  border: 0;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
}

.slideout-trigger:hover {
  background-color: var(--color-blue-200);
}

.slideout-overlay {
  position: fixed;
  inset: 0;
  background: rgba(var(--color-blue-200--rgb), 0.6);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
  touch-action: none;
}

.slideout-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.slideout-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  width: 90%;
  max-width: 600px;
  background-color: var(--color-bg-primary);
  z-index: 9999;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.7s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0.5s;
  will-change: transform;
  overflow-y: auto;
  /* Keeps a flick at the end of the list from scrolling the page behind it. */
  overscroll-behavior: contain;
  box-shadow: -10px 0 40px rgba(0,0,0,0.15);
}

.slideout-panel.is-open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.7s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0s;
}

.slideout-panel-content {
  padding: max(25px, env(safe-area-inset-top)) max(25px, env(safe-area-inset-right)) max(25px, env(safe-area-inset-bottom)) max(25px, env(safe-area-inset-left));
  /* Lifts the whole list above the watermark below. */
  position: relative;
  z-index: 1;
}

/* One shield for the whole panel, not an ornament on every heading: the list
   scrolls over it. The panel is transformed, which makes it the containing
   block for this fixed pseudo-element, so the mark stays centred in the panel
   instead of travelling with the content. */
.slideout-panel::before {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(75%, 440px);
  aspect-ratio: 740 / 830;
  transform: translate(-50%, -50%);
  background-color: var(--color-text-heading);
  mask-image: url("../../../media/general/nuzp-gerb.svg");
  -webkit-mask-image: url("../../../media/general/nuzp-gerb.svg");
  mask-size: contain;
  -webkit-mask-size: contain;
  mask-position: center;
  -webkit-mask-position: center;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  opacity: 0.06;
  z-index: 0;
  pointer-events: none;
}

.slideout-close {
  background: none;
  border: none;
  color: var(--color-text-secondary, #64748b);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s ease;
  flex-shrink: 0;
  border-radius: 4px;
}
.slideout-close:hover {
  color: var(--color-red, #ef4444);
  background-color: var(--color-bg-secondary, #f8fafc);
}
.slideout-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* The divider belongs to the group, not to the heading: that way every row is
   split by exactly one hairline whether it is open or closed, and the list does
   not end on a line hanging under the last heading. */
.slideout-year-group {
  border-top: 1px solid var(--color-border, #e2e8f0);
}

.slideout-year-group:last-child {
  border-bottom: 1px solid var(--color-border, #e2e8f0);
}

.slideout-year-heading {
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
}

.slideout-year-title {
  /* A <button> inside the heading: reset the UA styling, keep the look. */
  width: 100%;
  background: none;
  border: 0;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--color-text-heading);
  /* Equal padding top and bottom, so every closed row is the same height. */
  padding: 16px 0;
  font-family: "Roboto", sans-serif;
  cursor: pointer;
  user-select: none;
  transition: color 0.25s ease;
}

.slideout-year-title:hover {
  color: var(--color-accent);
}

.slideout-year-title:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -4px;
}

.slideout-year-title svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
  color: var(--color-text-secondary, #94a3b8);
  transition: transform 0.3s ease, color 0.25s ease;
  flex-shrink: 0;
}

.slideout-year-title:hover svg,
.slideout-year-group._active .slideout-year-title svg {
  color: inherit;
}

.slideout-year-group._active .slideout-year-title svg {
  transform: rotate(180deg);
}

.slideout-grid-wrapper {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.slideout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  /* The padding is constant and inside the clipped wrapper: animating it, or
     switching it on with ._active, changed the height the accordion had just
     measured, which is what made it jitter and then snap. */
  padding: 4px 0 24px;
  overflow: hidden;
  min-height: 0;
}

.event-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: var(--color-surface-card);
  overflow: hidden;
  text-decoration: none;
  height: 100%;
  border: 1px solid var(--color-border, #e2e8f0);
  opacity: 0;
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
  will-change: transform, opacity;
  -webkit-tap-highlight-color: transparent;
}

.slideout-panel.is-open .event-tile {
  animation: fadeSlideUp 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) both;
}

@keyframes fadeSlideUp {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

.slideout-panel.is-open .event-tile:nth-child(1) { animation-delay: 0.05s; }
.slideout-panel.is-open .event-tile:nth-child(2) { animation-delay: 0.1s; }
.slideout-panel.is-open .event-tile:nth-child(3) { animation-delay: 0.15s; }
.slideout-panel.is-open .event-tile:nth-child(4) { animation-delay: 0.2s; }
.slideout-panel.is-open .event-tile:nth-child(5) { animation-delay: 0.25s; }
.slideout-panel.is-open .event-tile:nth-child(6) { animation-delay: 0.3s; }
.slideout-panel.is-open .event-tile:nth-child(7) { animation-delay: 0.35s; }
.slideout-panel.is-open .event-tile:nth-child(8) { animation-delay: 0.4s; }
.slideout-panel.is-open .event-tile:nth-child(9) { animation-delay: 0.45s; }
.slideout-panel.is-open .event-tile:nth-child(10) { animation-delay: 0.5s; }
.slideout-panel.is-open .event-tile:nth-child(11) { animation-delay: 0.55s; }
.slideout-panel.is-open .event-tile:nth-child(12) { animation-delay: 0.6s; }
.slideout-panel.is-open .event-tile:nth-child(13) { animation-delay: 0.65s; }
.slideout-panel.is-open .event-tile:nth-child(14) { animation-delay: 0.7s; }
.slideout-panel.is-open .event-tile:nth-child(15) { animation-delay: 0.75s; }
.slideout-panel.is-open .event-tile:nth-child(16) { animation-delay: 0.8s; }
.slideout-panel.is-open .event-tile:nth-child(17) { animation-delay: 0.85s; }
.slideout-panel.is-open .event-tile:nth-child(18) { animation-delay: 0.9s; }
.slideout-panel.is-open .event-tile:nth-child(19) { animation-delay: 0.95s; }
.slideout-panel.is-open .event-tile:nth-child(20) { animation-delay: 1.0s; }

@media (hover: hover) {
  .slideout-panel.is-open .event-tile:hover {
    transform: translateY(-3px) !important;
    border-color: var(--color-border-strong);
    box-shadow: 0 10px 24px rgba(var(--color-blue-200--rgb), 0.1);
  }
}

/* A tinted plate of a fixed height, the same one the placeholder uses, so every
   card has the same picture area whether it carries a logo or not. The plate
   stays light in the dark theme on purpose: some event logos are transparent
   SVGs with black artwork and would disappear on a dark card. */
.event-tile-image {
  width: 100%;
  height: 150px;
  position: relative;
  overflow: hidden;
  background-color: var(--color-grey-010);
}

.event-tile-image img {
  width: 100%;
  height: 100%;
  /* contain plus padding: the logo is shown whole and centred on the plate.
     Nothing here may scale or crop it - several of these are wordmarks that
     turn to mush the moment a pixel is cut off. */
  object-fit: contain;
  object-position: center;
  display: block;
  padding: 16px;
}

.event-tile-content {
  padding: 16px 18px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--color-surface-card);
  border-top: 1px solid rgba(var(--color-ink--rgb), 0.05);
}

.event-tile-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--color-text-primary);
  transition: color 0.3s ease;
}

.event-tile:hover .event-tile-title {
  color: var(--color-link);
}

.pinned-icon-badge {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background-color: rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.pinned-icon-badge svg {
  width: 20px;
  height: 20px;
  display: block;
  transform: rotate(45deg);
}

.pinned-icon-badge svg path {
  fill: var(--color-white);
}

@media (max-width: 768px) {
  .slideout-panel {
    width: 100%;
    max-width: none;
  }
  .slideout-panel-content {
    padding: max(20px, env(safe-area-inset-top)) max(15px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(15px, env(safe-area-inset-left));
  }
  #slideout-title {
    font-size: 1.5rem;
  }
}

@media (max-width: 576px) {
  .slideout-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .event-tile {
    flex-direction: row;
  }

  .event-tile-image {
    width: 110px;
    height: 100px;
    flex-shrink: 0;
    align-self: center;
  }

  .event-tile-image img {
    padding: 12px;
    object-position: center;
  }

  .event-tile-content {
    padding: 12px 15px;
    border-top: none;
    border-left: 1px solid rgba(var(--color-ink--rgb), 0.05);
    justify-content: center;
  }

  .event-tile-title {
    font-size: 0.95rem;
  }
}

/* --- UI/UX Enhancements for Slideout Panel --- */
.slideout-panel::-webkit-scrollbar {
  width: 6px;
}
.slideout-panel::-webkit-scrollbar-track {
  background: transparent;
}
.slideout-panel::-webkit-scrollbar-thumb {
  background: rgba(var(--color-ink--rgb), 0.15);
  border-radius: 10px;
}
.slideout-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--color-ink--rgb), 0.3);
}

.slideout-header-wrapper {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.slideout-header-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
#slideout-title {
  font-size: 1.8rem;
  margin: 0;
  font-family: "Roboto", sans-serif;
  line-height: 116%;
  font-weight: 500;
  color: var(--color-text-heading);
  padding-right: 0;
}
@media (max-width: 576px) {
  #slideout-title {
    font-size: 1.35rem;
  }
}
.slideout-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.slideout-search-icon {
  position: absolute;
  left: 12px;
  color: var(--color-text-secondary, #64748b);
  pointer-events: none;
}
#slideout-search {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 0;
  font-size: 0.95rem;
  line-height: 1.2;
  font-family: inherit;
  transition: border-color 0.3s, box-shadow 0.3s;
  background-color: var(--color-bg-secondary, #f8fafc);
  color: var(--color-text-primary, #1e293b);
  -webkit-appearance: none;
  appearance: none;
}
#slideout-search:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.slideout-action-btn {
  background: none;
  border: none;
  color: var(--color-link);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  transition: color 0.3s;
  flex-shrink: 0;
  min-width: 105px;
  text-align: right;
}
.slideout-action-btn:hover {
  color: var(--color-text-heading);
  text-decoration: underline;
}

.slideout-year-text {
  flex-grow: 1;
}
.slideout-year-count {
  color: var(--color-text-secondary, #94a3b8);
  font-size: 0.8rem;
  font-weight: 400;
  /* Digits of the same width keep the counts in a straight column. */
  font-variant-numeric: tabular-nums;
}

.event-tile.is-current {
  border-color: var(--color-accent);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.15);
}
.event-tile.is-current .event-tile-title {
  color: var(--color-accent);
}

.event-tile-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* No logo to protect here, so the placeholder follows the theme and does not
     leave a light slab on a dark card. */
  background-color: var(--color-bg-secondary);
  color: var(--color-border, #cbd5e1);
  transition: color 0.3s ease;
}
.event-tile:hover .event-tile-placeholder {
  /* Colour only: the plate is clipped, so scaling would shave the shield. */
  color: var(--color-text-secondary, #94a3b8);
}

.event-tile-content {
  position: relative;
  padding-right: 45px; 
}
.event-tile-arrow {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-border, #cbd5e1);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease, color 0.3s ease;
}
.event-tile:hover .event-tile-arrow {
  opacity: 1;
  transform: translate(5px, -50%);
  color: var(--color-accent);
}

@media (max-width: 576px) {
  .event-tile-content {
    padding-right: 15px;
  }
  .event-tile-arrow {
    display: none;
  }
}

/* iOS Safari zooms the whole page in when a focused field is under 16px.
   The panel and the events search are the two fields on this page. */
@media (max-width: 767.98px) {
  #slideout-search {
    font-size: 16px;
  }
  .events-search-input {
    /* the size is set inline on the element, so it has to be beaten here */
    font-size: 16px !important;
  }
}

/* The tiles start at opacity 0 and are revealed by the open animation, so they
   need a way to show up when animations are off. */
@media (prefers-reduced-motion: reduce) {
  .slideout-panel.is-open .event-tile {
    animation: none;
    opacity: 1;
  }
  .slideout-panel,
  .slideout-overlay,
  .slideout-grid-wrapper {
    transition-duration: 0.01ms;
  }
}

/* While the panel holds the page still there is no scrollbar, so its width is
   kept as padding - otherwise the content and the fixed header jump sideways
   by however wide the scrollbar was. */
body._slideout-locked {
  padding-right: var(--slideout-gutter, 0px);
}

body._slideout-locked .header {
  padding-right: var(--slideout-gutter, 0px);
}
