html {
  background: #fff;
  overflow: hidden; /* the backgrounds extend past the window; don't let that scroll */
}

/* iOS Safari tints its status bar with this, so match the shadows of the bed */
html[data-bg="petals"] {
  background: #2a0306;
}

/* The bed of petals is dark, so the text turns light */
html[data-bg="petals"] body,
html[data-bg="petals"] #event-link,
html[data-bg="petals"] #modes button {
  color: #fbeee6;
}

html[data-bg="petals"] main {
  text-shadow: 0 1px 14px rgba(30, 0, 4, 0.6);
}

html[data-bg="petals"] #logo,
html[data-bg="petals"] #menu .socials img {
  filter: invert(1);
}

html, body {
  margin: 0;
  height: 100%;
  color: #000;
  font-family: Georgia, "Times New Roman", Times, serif;
}

/* Backgrounds use the large viewport height so they run under mobile browser bars.
   Absolute rather than fixed: iOS Safari paints solid bars over fixed elements at the edges */
#roses,
#roses-front,
#art {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  /* Reach under Safari's floating bottom toolbar too */
  height: calc(100lvh + env(safe-area-inset-bottom) + 4rem);
  z-index: -1;
  display: none;
}

#roses-front {
  z-index: auto; /* above the text, below the menu */
  pointer-events: none;
}

#art {
  overflow: hidden;
}

/* Oversized so the blur doesn't fade out at the edges; the veil keeps the text readable */
#art::before,
#art::after {
  content: "";
  position: absolute;
  inset: -5%;
}

#art::before {
  background: var(--art) center / cover no-repeat;
  filter: blur(12px) saturate(1.15);
}

#art::after {
  background: rgba(255, 255, 255, 0.25);
}

html[data-bg="artwork"] {
  background: #ddd;
}

html[data-bg="artwork"] #art {
  display: block;
}

/* Flyers that need light text get a darkening veil instead */
html[data-art-scheme="dark"] #art::after {
  background: rgba(0, 0, 0, 0.3);
}

html[data-bg="artwork"] body,
html[data-bg="artwork"] #event-link,
html[data-bg="artwork"] #modes button {
  color: var(--art-text, #000);
}

html[data-bg="artwork"][data-art-scheme="dark"] #logo,
html[data-bg="artwork"][data-art-scheme="dark"] #menu .socials img {
  filter: invert(1);
}

html[data-bg="petals"] #roses,
html[data-bg="petals"] #roses-front {
  display: block;
}

/* Small, top middle, over the petals; the black logo turns white on dark backgrounds */
#logo {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: clamp(110px, 16vw, 160px);
  height: auto;
  pointer-events: none;
}

#modes {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top));
  right: calc(1rem + env(safe-area-inset-right));
  z-index: 1;
  display: flex;
  gap: 0.25rem;
}

#modes button[hidden] {
  display: none;
}

#modes button {
  width: 44px;
  height: 44px;
  padding: 6px;
  border: 0;
  background: none;
  color: #000;
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.3s ease;
}

#modes button:hover,
#modes button[aria-pressed="true"] {
  opacity: 1;
}

#modes svg {
  display: block;
  width: 100%;
  height: 100%;
}

main {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  box-sizing: border-box;
  text-align: center;
}

#countdown {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 3rem);
  line-height: 1.25;
  max-width: 20em;
}

#event-link {
  margin-top: 1em;
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: #000;
}

#menu {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(2rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 0 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#menu.visible {
  opacity: 1;
  pointer-events: auto;
}

#menu .buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

#menu .buttons a {
  color: #000;
  text-decoration: none;
  border: 1px solid #000;
  padding: 0.5em 1em;
  background: #fff;
}

#menu .buttons a:hover {
  background: #000;
  color: #fff;
}

#menu .socials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

#menu .socials img {
  display: block;
  width: 28px;
  height: 28px;
}

#menu .socials a:hover {
  opacity: 0.6;
}

/* Popups from the menu buttons. Fixed, so they sit in the middle of the window
   rather than above the buttons */
.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 32px);
  max-width: 22rem;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 1.25rem;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  text-align: left;
}

.popup[hidden] {
  display: none;
}

.popup h2 {
  margin: 0 1.5rem 0.5rem 0;
  font-size: 1.25rem;
  font-weight: normal;
}

.popup > p {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

#signup label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

#signup input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.75rem;
  padding: 0.5em;
  border: 1px solid #000;
  border-radius: 0;
  font: inherit;
  font-size: 16px; /* stops iOS zooming in on focus */
}

#signup button[type="submit"] {
  width: 100%;
  padding: 0.6em 1em;
  border: 1px solid #000;
  background: #000;
  color: #fff;
  font: inherit;
  cursor: pointer;
}

#signup button[type="submit"]:hover {
  background: #fff;
  color: #000;
}

#signup button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Sticky, so it stays in the corner while a long popup scrolls; the negative margins
   pull it into the padding */
.popup .close {
  position: sticky;
  top: 0.25rem;
  z-index: 1;
  float: right;
  margin: -1rem -1rem 0 0;
  width: 2rem;
  height: 2rem;
  border: 0;
  background: #fff;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

#signup .status {
  margin: 0.75rem 0 0;
}

#signup .status:empty {
  display: none;
}

#past {
  max-width: 40rem;
  height: calc(100% - 32px);
  max-height: 48rem;
}

/* On narrow screens it would run up under the buttons in the top-right corner, so it
   starts below them */
@media (max-width: 42rem) {
  #past {
    top: calc(env(safe-area-inset-top) + 4.5rem);
    bottom: 1rem;
    height: auto;
    max-height: none;
    transform: translateX(-50%);
  }
}

#past .flyers {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

#past .flyers button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

#past .flyers img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: #eee;
  transition: opacity 0.2s ease;
}

#past .flyers button:hover img {
  opacity: 0.8;
}

#past .more {
  color: inherit;
  font-size: 0.9rem;
}
