html.contacts-pending body { visibility: hidden; }

body.home {
  background: #000610;
}
.home > .page {
  position: relative;
  isolation: isolate;
}
.home > .page::before {
  position: absolute;
  z-index: -1;
  inset: 0 calc(50% - 50vw);
  background: var(--background) center / cover no-repeat;
  content: "";
}
.home { overflow-x: clip; }
.portfolio {
  height: 100svh;
  min-height: 320px;
  background: #041a35 url("/assets/portfolio-background.png") center / 100% 100% no-repeat;
  padding: clamp(12px, 3svh, 38px) max(16px, 5vw);
}
@media (max-width: 600px) {
  .portfolio { background-image: url("/assets/portfolio-background-mobile.png"); }
}
.portfolio-inner {
  height: 100%;
  max-width: 1260px;
  margin-inline: auto;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: clamp(10px, 2svh, 22px);
}
.gallery {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  overflow-anchor: none;
  padding: clamp(10px, 2.2vw, 24px);
  border: 1px solid #80ddff38;
  border-radius: 18px;
  background: #0714259c;
  box-shadow: 0 18px 55px #00081459;
}
.gallery [hidden] { display: none; }
.event-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(9px, 1.6vw, 18px);
  list-style: none;
  padding: 5px 10px 5px 5px;
  margin: 0;
  min-height: 0;
  min-width: 0;
  align-content: start;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #72b9de #0a1b2c;
}
.event-card {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  padding: 0;
  border: 1px solid #7397b13f;
  border-radius: 10px;
  background: #0c2035;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.event-card:is(:hover, :focus-visible) {
  border-color: var(--accent);
  color: var(--accent);
}
.event-card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #112f4b;
}
.event-card span {
  padding: clamp(8px, 1.1vw, 14px);
  font-size: clamp(.94rem, 1.4vw, 1.12rem);
  line-height: 1.35;
}
.gallery > .event-list,
.event-view { grid-area: 1 / 1; }
.gallery > .event-list,
.event-view {
  transition: opacity 280ms ease, transform 320ms cubic-bezier(.22, .75, .24, 1), visibility 280ms;
}
.gallery.is-open > .event-list {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.event-view {
  display: grid;
  min-height: 0;
  min-width: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(9px) scale(.99);
}
.gallery.is-open .event-view {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}
.event-view {
  grid-template-rows: minmax(0, 1fr) auto;
}
.event-detail {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  justify-items: center;
  gap: clamp(5px, 1.1svh, 12px);
}
.event-slides { display: flex; gap: 4px; }
.event-slides button {
  min-height: 40px;
  padding: 4px 9px;
  border: 1px solid #7397b190;
  border-radius: 8px;
  color: var(--text);
  background: #0a2137;
  font: inherit;
  cursor: pointer;
}
.event-slides button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}
.close-detail, .slide-arrow {
  min-height: 44px;
  padding: 6px 14px;
  border: 1px solid #7397b190;
  border-radius: 8px;
  background: #0a2137;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.close-detail:hover, .slide-arrow:hover { color: var(--accent); }
.event-feature {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) clamp(68px, 13svh, 102px);
  align-items: stretch;
  text-align: center;
  gap: clamp(10px, 2vw, 26px);
  width: min(100%, 1040px);
  min-height: 0;
}
.event-feature img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 12px;
  object-fit: contain;
}
.event-copy {
  max-height: 100%;
  overflow-y: auto;
  overflow-wrap: anywhere;
  padding: 5px 6px;
}
.event-feature h3, .expanded-caption h3 {
  margin: 0;
  font-size: clamp(1.125rem, 2.2vw, 1.85rem);
  font-weight: 400;
  line-height: 1.2;
}
.event-description {
  white-space: pre-line;
  margin: .65em 0 0;
  color: #c2d6e6;
  font-size: clamp(.9rem, 1.35vw, 1.1rem);
  line-height: 1.4;
}
@media (max-height: 480px) {
  .event-view { grid-template-rows: minmax(0, 1fr) auto; }
}

@media (max-width: 850px) {
  .event-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 570px) {
  .event-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: no-preference) {
  html:has(.portfolio):not(:has(#contacts:target)) { scroll-behavior: smooth; }
}

.contacts-section {
  background: #000610 var(--background) center / 100% 100% no-repeat;
}
.contact-content {
  padding-block: clamp(26px, 5svh, 84px);
}
.contact-social {
  gap: clamp(24px, 4vw, 55px);
  padding-bottom: max(clamp(20px, 4.4svh, 74px), env(safe-area-inset-bottom));
}
.contact-social > * + * {
  position: relative;
  margin-left: 0;
  padding-left: 0;
  border: 0;
}
.contact-social > :last-child::before {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: calc(-.5 * clamp(24px, 4vw, 55px));
  width: 1px;
  background: var(--text);
  content: "";
}
@media (max-width: 600px) {
  .contacts-section { background-size: auto 100%; }
}
@media (max-height: 800px) {
  .contact-content { padding-block: 18px; }
  .contact-content hr { margin-block: 16px; }
  .contact-content address { margin-top: 18px; }
  .contact-content .action { margin-top: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery > .event-list,
  .event-view { transition: none; }
}

.event-view { position: relative; }
.event-photo { position: relative; min-height: 0; height: 100%; }
.expand-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: zoom-in;
}
.expanded-collage {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  grid-template: minmax(0, 1fr) fit-content(40%) / minmax(0, 1fr);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  border-radius: 12px;
  background: #071425;
  transition: opacity 520ms ease, visibility 520ms;
}
.expanded-caption {
  align-self: stretch;
  pointer-events: auto;
  overscroll-behavior-y: contain;
  margin: 0;
  padding: 5px 8px;
  text-align: center;
  overflow-wrap: anywhere;
  font-size: clamp(1rem, 1.6vw, 1.35rem);
}
.expanded-collage img {
  min-height: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(.9);
  transition: transform 540ms cubic-bezier(.22, .75, .22, 1);
}
.event-view.is-expanded .expanded-collage {
  visibility: visible;
  opacity: 1;
}
.event-view.is-expanded .expanded-collage img { transform: scale(1); }
.event-copy {
  transition: opacity 420ms ease, visibility 420ms;
}
.event-view.is-expanded .event-feature .event-copy {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.collapse-photo {
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 44px;
  padding-inline: 12px;
  border: 1px solid #7397b190;
  border-radius: 8px;
  background: #071425e8;
  color: var(--text);
  font: inherit;
  cursor: zoom-out;
  visibility: hidden;
}
.event-view.is-expanded .expanded-collage:not([inert]) .collapse-photo {
  visibility: visible;
  pointer-events: auto;
}
@media (prefers-reduced-motion: reduce) {
  .expanded-collage, .expanded-collage img, .event-copy {
    transition: none;
  }
}


.event-feature { touch-action: pan-y pinch-zoom; }

@media (orientation: landscape) and (max-height: 560px) {
  .portfolio { padding-block: 8px; }
  .portfolio-inner { gap: 6px; }
  .gallery { padding: 8px; }
  .event-view { grid-template-rows: minmax(0, 1fr) auto; gap: 6px; }
  .event-detail { gap: 5px; }
  .event-feature { gap: 7px; overflow: hidden; }
  .event-feature {
    grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    text-align: left;
  }
  .event-copy {
    min-height: 0;
    overscroll-behavior-y: contain;
    padding-block: 2px;
  }
  .event-feature h3 { font-size: clamp(.95rem, 3.7svh, 1.25rem); }
  .event-description { margin-top: .35em; font-size: .9rem; }
}


.event-stage {
  --photo-height: clamp(200px, 56svh, 680px);
  width: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: clamp(3px, 1vw, 12px);
  align-items: stretch;
}
.event-stage .event-feature { width: 100%; justify-self: center; }
.slide-arrow {
  align-self: center;
  width: clamp(32px, 5vw, 44px);
  padding-inline: 0;
  font-size: 1.25rem;
}
.slide-arrow { transition: opacity 420ms ease, visibility 420ms; }
.event-view.is-expanded .slide-arrow { opacity: 0; visibility: hidden; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .slide-arrow { transition: none; }
}


.event-copy { min-height: 0; }
.event-feature h3, .expanded-caption h3 { font-size: clamp(1rem, 1.6vw, 1.35rem); }
@media (pointer: coarse), (max-width: 600px) {
  .event-stage { grid-template-columns: minmax(0, 1fr); }
  .slide-arrow { display: none; }
}

@media (pointer: coarse), (max-width: 600px) {
  .portfolio { padding: 8px max(10px, env(safe-area-inset-left), env(safe-area-inset-right)); }
  .portfolio-inner, .event-view { gap: 6px; }
  .gallery { padding: 7px; }
  .event-detail, .event-feature { gap: 5px; }
  .event-feature { grid-template-rows: minmax(0, 1fr) fit-content(34%); }
  .event-copy { padding: 2px 4px; }
  .event-description { margin-top: .3em; }


  .expanded-collage, .expanded-collage img { transition: none; }
  .event-view.is-expanded .event-photo img { visibility: hidden; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .event-feature {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) fit-content(40%);
    text-align: center;
  }
}

@media (min-width: 601px) and (pointer: fine) {
  .event-copy {
    max-height: none;
    overflow: visible;
  }
  .event-description {
    font-size: 1rem;
    line-height: 1.45;
    text-align: left;
  }
  .expanded-collage {
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 12px;
    padding-block-end: 8px;
  }
}

.portfolio:has(.gallery.is-open) {
  height: auto;
  min-height: 100svh;
}
.gallery.is-open {
  position: relative;
  grid-template-rows: auto;
}
.gallery.is-open > .event-list {
  position: absolute;
  inset: 0;
}
.event-view {
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
}
.event-detail {
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
}
.event-feature {
  --photo-width: min(100%, calc(var(--photo-height) * 16 / 9));
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  text-align: center;
}
.event-photo {
  height: auto;
  width: var(--photo-width);
  aspect-ratio: 16 / 9;
  justify-self: center;
}
.slide-arrow {
  align-self: start;
  margin-top: calc((var(--photo-height) - 44px) / 2);
}
.event-copy {
  min-width: 0;
  max-height: none;
  overflow: visible;
}
.event-feature > .event-copy {
  width: var(--photo-width);
  justify-self: center;
  padding-inline: 0;
}
.expanded-caption {
  width: 100%;
  padding-inline: 0;
}
.event-slides {
  justify-content: center;
  margin-bottom: 6px;
}
.event-slides button {
  display: grid;
  place-items: center;
  width: 36px;
  min-height: 34px;
  border: 0;
  background: transparent;
}
.event-slides button::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: .42;
}
.event-slides button[aria-pressed="true"]::before { opacity: 1; }
.event-copy .close-detail { margin-top: 14px; }
.expanded-collage {
  grid-template-rows: minmax(0, 1fr) auto;
  padding-bottom: 8px;
}
