/**
 * @file
 * Event listing: the Agenda / Proceedings / Photo Gallery buttons and the
 * popup one of them opens.
 *
 * Loaded on the Event listing only, from
 * drupal8_zymphonies_theme_preprocess_views_view().
 *
 * The three buttons are one component with one shape, told apart by colour
 * alone: every rule below reads --ea-accent, and the only thing the three
 * modifiers do is set it. Adding a fourth button is therefore a two-line
 * change here, and nothing about the layout has to be repeated.
 */

/* =========================================
   CURRENT / OLD EVENTS SWITCHER
========================================= */

.event-switch {
  display: flex;
  justify-content: center;
  margin: 0 0 18px;
}

/* The track the two tabs sit in. Recessed rather than raised, so the selected
   tab reads as lifted out of it without needing a heavy border. */
.event-switch__inner {
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  border: 1px solid #e0e3dd;
  border-radius: 40px;
  background: #f2f3ef;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .05);
}

.event-switch__tab {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 26px;
  border-radius: 40px;
  color: #4a5551;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: .3px;
  text-decoration: none;
  white-space: nowrap;
  transition: background .24s ease, color .24s ease, box-shadow .24s ease, transform .18s ease;
}

.event-switch__tab .fa {
  font-size: 14px;
  opacity: .85;
}

/* The listing you are already on. A span, not a link -- there is nowhere to go. */
.event-switch__tab.is-current {
  background: linear-gradient(135deg, #1b6b3a 0%, #14512e 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(20, 81, 46, .3);
  cursor: default;
}

.event-switch__tab.is-current .fa { opacity: 1; }

/* The listing you can move to. Lifts on hover so it reads as clickable next
   to a filled tab that deliberately does not. */
a.event-switch__tab:hover,
a.event-switch__tab:focus-visible {
  background: #fff;
  color: #c96b1c;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .12);
  transform: translateY(-1px);
}

a.event-switch__tab:focus-visible {
  outline: 3px solid rgba(20, 81, 46, .4);
  outline-offset: 2px;
}

@media (max-width: 560px) {

  /* Full width, half each, so the pair stays reachable with a thumb. */
  .event-switch__inner { display: flex; width: 100%; }

  .event-switch__tab {
    flex: 1 1 0;
    justify-content: center;
    padding: 10px 12px;
    font-size: 13.5px;
  }

}

@media (prefers-reduced-motion: reduce) {
  .event-switch__tab { transition: none; }
  a.event-switch__tab:hover { transform: none; }
}

@media print {
  .event-switch { display: none; }
}

/* =========================================
   BUTTON ROW
========================================= */

/* The row also carries .traditional-event-buttons, whose existing mobile rule
   stacks its children in a column. These pills are laid out side by side at
   every width instead, so the direction is pinned here at a specificity that
   wins regardless of which stylesheet aggregation puts last. */
.event-actions,
.traditional-event-buttons.event-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

/* Belt and braces: <template> never renders, but the row is a flex container
   and a stray inline-block child would open a gap. */
.event-actions template {
  display: none;
}

/* =========================================
   BUTTON
========================================= */

.event-action {
  --ea-accent: #c96b1c;
  --ea-accent-dark: #a4550f;

  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 20px;
  overflow: hidden;
  border: 2px solid var(--ea-accent);
  border-radius: 40px;
  background: #fff;
  color: var(--ea-accent);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: .3px;
  text-decoration: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: color .28s ease, box-shadow .28s ease, transform .18s ease;
}

/* The fill that wipes up on hover. A pseudo-element rather than a background
   transition so the sweep can be directional, and so the border colour is
   free to stay put underneath it. */
.event-action::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(135deg, var(--ea-accent) 0%, var(--ea-accent-dark) 100%);
  transform: translateY(101%);
  transition: transform .34s cubic-bezier(.22, 1, .36, 1);
}

.event-action > * {
  position: relative;
  z-index: 1;
}

.event-action .fa {
  font-size: 15px;
  opacity: .9;
}

.event-action:hover::before,
.event-action:focus-visible::before {
  transform: translateY(0);
}

.event-action:hover,
.event-action:focus-visible {
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .18);
}

.event-action:focus-visible {
  outline: 3px solid rgba(0, 0, 0, .35);
  outline-offset: 2px;
}

.event-action:active {
  transform: translateY(0);
}

/* --- The three accents ------------------------------------------------- */

.event-action--agenda {
  --ea-accent: #c96b1c;
  --ea-accent-dark: #a4550f;
}

.event-action--proceeding {
  --ea-accent: #1b6b3a;
  --ea-accent-dark: #12522b;
}

.event-action--gallery {
  --ea-accent: #0f5fa6;
  --ea-accent-dark: #0a4680;
}

/* --- Nothing published yet --------------------------------------------- */

.event-action.is-empty {
  border-color: #dcdfe3;
  background: #f4f5f6;
  color: #9aa0a6;
  cursor: not-allowed;
}

.event-action.is-empty::before {
  display: none;
}

.event-action.is-empty:hover {
  transform: none;
  box-shadow: none;
  color: #9aa0a6;
}

/* =========================================
   POPUP
========================================= */

.event-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 18, 22, .62);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .26s ease, visibility .26s ease;
}

/* display:flex above outranks the user agent's [hidden] rule, so the closed
   dialog has to be taken out of the layout explicitly. Without this the
   invisible overlay still sits over the whole page and swallows clicks. */
.event-modal[hidden] {
  display: none;
}

.event-modal.is-open {
  opacity: 1;
  visibility: visible;
}

.event-modal__dialog {
  display: flex;
  flex-direction: column;
  width: min(880px, 100%);
  max-height: min(86vh, 940px);
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .38);
  opacity: 0;
  transform: translateY(20px) scale(.97);
  transition: opacity .3s ease, transform .3s cubic-bezier(.22, 1, .36, 1);
}

.event-modal.is-open .event-modal__dialog {
  opacity: 1;
  transform: none;
}

/* The tricolour rule along the top. Purely decorative, and the only piece of
   the popup that is not tinted by the button that opened it. */
.event-modal__flag {
  flex: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg,
    #ff9933 0 33.33%,
    #f2f2f2 33.33% 66.66%,
    #138808 66.66% 100%);
}

/* --- Header ------------------------------------------------------------ */

.event-modal__header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px 18px;
  border-bottom: 1px solid #ececec;
}

.event-modal__icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--ea-accent, #c96b1c);
  color: #fff;
  font-size: 19px;
}

.event-modal__headings {
  flex: 1 1 auto;
  min-width: 0;
}

.event-modal__title {
  margin: 0 0 3px;
  color: #111;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.25;
}

.event-modal__subtitle {
  margin: 0;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}

.event-modal__when {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 10px;
  border-radius: 20px;
  background: #f3f4f6;
  color: #4b5563;
  font-size: 12.5px;
  font-weight: 600;
}

.event-modal__close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #f3f4f6;
  color: #4b5563;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}

.event-modal__close:hover {
  background: var(--ea-accent, #c96b1c);
  color: #fff;
  transform: rotate(90deg);
}

/* --- Body -------------------------------------------------------------- */

.event-modal__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 22px 26px 26px;
  color: #232323;
  font-size: 16px;
  line-height: 1.75;
  overscroll-behavior: contain;
}

.event-modal__body > *:first-child {
  margin-top: 0;
}

.event-modal__body > *:last-child {
  margin-bottom: 0;
}

.event-modal__body p {
  margin: 0 0 14px;
}

.event-modal__body ul,
.event-modal__body ol {
  margin: 0 0 14px;
  padding-left: 22px;
}

.event-modal__body li {
  margin-bottom: 7px;
}

.event-modal__body a {
  color: var(--ea-accent, #c96b1c);
  text-decoration: underline;
}

.event-modal__body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* Wide content scrolls inside its own box; the dialog itself never does. */
.event-modal__body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.event-modal__body th,
.event-modal__body td {
  padding: 8px 12px;
  border: 1px solid #e2e5e9;
  text-align: left;
}

.event-modal__body th {
  background: #f6f7f8;
  font-weight: 700;
}

/* An uploaded PDF shown in place, rather than dropped on the visitor as a
   download. */
.event-action__pdf {
  display: block;
  width: 100%;
  height: min(62vh, 620px);
  border: 1px solid #e2e5e9;
  border-radius: 10px;
  background: #f8f9fa;
}

.event-action__external {
  display: inline-block;
  margin-top: 12px;
  font-weight: 600;
}

.event-action__image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
}

/* --- Footer ------------------------------------------------------------ */

.event-modal__footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid #ececec;
  background: #fafbfc;
}

.event-modal__dismiss {
  padding: 8px 22px;
  border: 2px solid var(--ea-accent, #c96b1c);
  border-radius: 40px;
  background: var(--ea-accent, #c96b1c);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .22s ease, color .22s ease;
}

.event-modal__dismiss:hover {
  background: #fff;
  color: var(--ea-accent, #c96b1c);
}

/* Stops the page behind the popup from scrolling with it. */
body.event-modal-open {
  overflow: hidden;
}

/* =========================================
   RESPONSIVE
========================================= */

@media (max-width: 767px) {

  .event-actions {
    gap: 8px;
  }

  /* The card's own mobile rules stack every button full width; these are
     pills side by side, which reads better and keeps the card short. */
  .event-action {
    flex: 1 1 auto;
    justify-content: center;
    width: auto;
    padding: 9px 14px;
    font-size: 13px;
  }

  .event-modal {
    padding: 0;
    align-items: flex-end;
  }

  .event-modal__dialog {
    width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(40px);
  }

  .event-modal__header {
    padding: 16px 18px 14px;
    gap: 12px;
  }

  .event-modal__icon {
    width: 40px;
    height: 40px;
    font-size: 17px;
  }

  .event-modal__title {
    font-size: 18px;
  }

  .event-modal__body {
    padding: 18px;
    font-size: 15px;
  }

  .event-action__pdf {
    height: 56vh;
  }

}

@media (max-width: 420px) {

  /* Below this the three labels cannot share a line, so let them wrap to two
     rows rather than shrink the text any further. */
  .event-action {
    flex: 1 1 100%;
  }

}

/* =========================================
   ACCESSIBILITY
========================================= */

@media (prefers-reduced-motion: reduce) {

  .event-action,
  .event-action::before,
  .event-modal,
  .event-modal__dialog,
  .event-modal__close {
    transition: none;
  }

  .event-action:hover {
    transform: none;
  }

  .event-modal__close:hover {
    transform: none;
  }

}

@media print {

  .event-actions,
  .event-modal {
    display: none;
  }

}
