/* The Bye Calendar
   Palette: midnight (ground), indigo and plum (sky), apricot (dawn),
   window (lit windows, the one warm accent), paper (text). */

:root {
  --midnight: #070919;
  --indigo: #141a4a;
  --plum: #7a4279;
  --apricot: #f4a06e;
  --window: #ffd58a;
  --paper: #f6ecdd;
  --ink: #2a1f3d;

  /* Set by the script: the sky gets lighter as byes are said. */
  --sky-top: #060818;
  --sky-mid: #10163f;
  --sky-low: #27245f;
  --stars: 1;

  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --text: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--midnight);
  color: var(--paper);
  font-family: var(--text);
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body.is-intro { overflow: hidden; }

h1, h2, p, ol, blockquote { margin: 0; }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--window);
  outline-offset: 4px;
  border-radius: 4px;
}

/* ---------- Sky ---------- */

.sky {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: hidden;
  padding-top: max(1.5rem, env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 58%, var(--sky-low) 100%);
}

.stars {
  position: absolute;
  inset: 0 0 30% 0;
  opacity: var(--stars);
  pointer-events: none;
}

.stars i {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--paper);
  animation: twinkle var(--d, 4s) ease-in-out var(--w, 0s) infinite;
}

.stars i.big { width: 3px; height: 3px; }

@keyframes twinkle {
  0%, 100% { opacity: .25; }
  50% { opacity: 1; }
}

.sky__name {
  position: relative;
  font-family: var(--display);
  font-style: italic;
  font-size: 1.125rem;
  letter-spacing: .01em;
  opacity: .85;
}

.count {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1.5rem 1.25rem 0;
}

.count__line {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--display);
  font-weight: 300;
}

.count__num {
  font-size: clamp(8rem, min(40vw, 32vh), 20rem);
  line-height: .82;
  letter-spacing: -.04em;
  font-variant-numeric: lining-nums;
  font-variation-settings: "opsz" 144;
  text-shadow: 0 0 80px rgba(255, 213, 138, .28);
}

.count__unit {
  margin-top: .35em;
  font-size: clamp(2rem, 8vw, 3.75rem);
  font-style: italic;
  line-height: 1;
}

.count__after {
  margin-top: 1rem;
  max-width: 24ch;
  font-family: var(--display);
  font-size: clamp(1.125rem, 4.2vw, 1.5rem);
  line-height: 1.3;
  opacity: .9;
}

.count__timer {
  margin-top: 1.5rem;
  max-width: 30ch;
  font-size: .9375rem;
  font-variant-numeric: tabular-nums;
  color: var(--window);
}

.scene {
  position: relative;
  width: 100%;
  line-height: 0;
  margin-bottom: -1px;
}

.scene svg { display: block; width: 100%; height: auto; }

.scene .lit { filter: drop-shadow(0 0 6px rgba(255, 207, 122, .9)); }

.scene text {
  font-family: var(--text);
  font-size: 12px;
  fill: var(--paper);
  opacity: .7;
}

.scene .smoke circle {
  fill: var(--paper);
  opacity: 0;
  animation: smoke 5s ease-out infinite;
}
.scene .smoke circle:nth-child(2) { animation-delay: 1.6s; }
.scene .smoke circle:nth-child(3) { animation-delay: 3.2s; }

@keyframes smoke {
  0% { opacity: 0; transform: translate(0, 0) scale(.6); }
  20% { opacity: .5; }
  100% { opacity: 0; transform: translate(14px, -46px) scale(1.8); }
}

/* ---------- Ground: tonight and the calendar ---------- */

.ground {
  max-width: 60rem;
  margin: 0 auto;
  padding: 3rem 1.25rem max(4rem, env(safe-area-inset-bottom));
}

.tonight {
  max-width: 30ch;
  font-family: var(--display);
  font-size: clamp(1.5rem, 5.5vw, 2.25rem);
  line-height: 1.2;
  font-weight: 400;
}

.ground__title {
  margin-top: 4.5rem;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.25rem;
}

.ground__hint {
  margin-top: .25rem;
  font-size: .9375rem;
  opacity: .65;
}

.byes {
  list-style: none;
  padding: 0;
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.75rem 1.5rem;
}

.bye {
  display: grid;
  gap: .3rem;
  padding: .15rem .1rem;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
}

.bye__word {
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(2.5rem, 9vw, 4rem);
  line-height: .95;
  transition: color .2s ease;
}

.bye__date {
  font-size: .8125rem;
  opacity: .6;
  font-variant-numeric: tabular-nums;
}

.bye.is-said .bye__word {
  color: rgba(246, 236, 221, .45);
  text-decoration: line-through;
  text-decoration-color: var(--apricot);
  text-decoration-thickness: .055em;
}

.bye.is-said:hover .bye__word { color: var(--paper); }

.bye.is-tonight .bye__word {
  color: var(--window);
  text-shadow: 0 0 28px rgba(255, 213, 138, .55);
}

.bye.is-tonight .bye__date { color: var(--window); opacity: 1; }

.bye.is-waiting { cursor: default; }

.bye.is-nudged { animation: nudge .35s ease; }

@keyframes nudge {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.bye--home .bye__word {
  font-style: normal;
  font-weight: 500;
  color: var(--apricot);
}

.is-home .bye--home .bye__word {
  color: var(--window);
  text-shadow: 0 0 28px rgba(255, 213, 138, .55);
}

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

.foot {
  margin-top: 6rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(246, 236, 221, .16);
}

.foot__quote {
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  line-height: 1.15;
}

.foot__said {
  margin-top: .5rem;
  font-size: .9375rem;
  opacity: .65;
}

.foot__replay {
  margin-top: 1.5rem;
  padding: 0;
  background: none;
  border: 0;
  font-size: .9375rem;
  color: var(--window);
  text-decoration: underline;
  text-underline-offset: .2em;
  cursor: pointer;
}

/* ---------- Opening ---------- */

.intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2.5rem;
  padding: 2rem 1.5rem;
  background: var(--midnight);
  transition: opacity .9s ease;
}

.intro[hidden] { display: none; }
.intro.is-leaving { opacity: 0; pointer-events: none; }

.intro__lines {
  display: grid;
  gap: 1rem;
  max-width: 40rem;
  width: 100%;
  margin: 0 auto;
}

.intro__lines p {
  font-family: var(--display);
  font-size: clamp(1.625rem, 6.5vw, 2.75rem);
  line-height: 1.15;
  font-weight: 350;
}

.intro__lines p,
.intro__go {
  opacity: 0;
  animation: arrive 1.1s ease forwards;
  animation-delay: var(--at, 0s);
}

.intro__go {
  align-self: flex-start;
  margin-left: max(0px, calc((100% - 40rem) / 2));
}

@keyframes arrive {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.btn {
  padding: .95rem 1.6rem;
  border: 0;
  border-radius: 999px;
  background: var(--window);
  color: #2a1a05;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover { background: #ffe1a8; }

/* ---------- Note ---------- */

.note {
  width: min(28rem, calc(100vw - 2.5rem));
  padding: 2.25rem 2rem 2rem;
  border: 0;
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}

.note[open] { animation: unfold .35s ease; }

@keyframes unfold {
  from { opacity: 0; transform: translateY(14px) rotate(-1.5deg); }
  to { opacity: 1; transform: none; }
}

.note::backdrop {
  background: rgba(7, 9, 25, .72);
  backdrop-filter: blur(4px);
}

.note__close {
  position: absolute;
  top: .5rem;
  right: .5rem;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.note__close:focus-visible { outline-color: var(--plum); }

.note__date { font-size: .875rem; color: var(--plum); }

.note__title {
  margin-top: .25rem;
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.5rem;
  line-height: 1.2;
}

.note__body {
  margin-top: 1.25rem;
  font-family: var(--display);
  font-style: italic;
  font-size: 1.3125rem;
  line-height: 1.45;
}

.note__sign {
  margin-top: 1.25rem;
  text-align: right;
  font-family: var(--display);
  font-size: 1.125rem;
}

.note__sign:empty { display: none; }

/* ---------- Toast and petals ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  z-index: 15;
  width: max-content;
  max-width: calc(100vw - 2.5rem);
  padding: .75rem 1.1rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: .9375rem;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}

.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.petals {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: none;
}

.is-home .petals { display: block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .stars i { opacity: .7; }
}
