/* The families: two lamps, one light.

   An emerald wall of tiny mirrors (assets/families/wall.webp, tiled) with two
   mirror-work lanterns hanging from a gold rail, one for each family, their
   names beneath. Each lantern is a button; lit (.is-lit on its side, set by
   js/families.js), its glow comes up, the family's names turn gold, and the
   wall's mirrors around it catch the light (.fm-glow, the wall's mirrors as a
   mask). With both lit (.is-joined, then .is-united), threads of light run
   from the lamps and meet, and the couple's names and the dua come.

   Phones and upright tablets: the lamps side by side, the couple below.
   Sideways tablets: the couple between the lamps. */

.families {
  /* the lanterns are tall (three times as tall as wide), so they are sized by
     the screen's height too */
  --lamp-w: min(30cqi, 150px, 13svh);
  --gap: clamp(30px, 9cqi, 90px);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 58px 16px 52px;
  overflow: hidden;
  background: url(../assets/families/wall.webp) center top / var(--wall-w) var(--wall-h) repeat, var(--emerald-deep);
  color: var(--ivory);
  text-align: center;
  container-type: inline-size;
  -webkit-tap-highlight-color: transparent;
}

html.is-tablet .families,
html:not(.is-tablet) .card .families { --lamp-w: min(22cqi, 190px, 13svh); }

/* The wall is dim: lit only where the lamps are. */
.families::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 90% 70% at 50% 45%, rgba(3, 23, 15, .45), rgba(3, 23, 15, .86));
  pointer-events: none;
}

/* The lamps' light on the wall's mirrors (--ax, --ay: where the lamp is). */
.fm-glow {
  position: absolute;
  inset: 0;
  -webkit-mask: url(../assets/families/wall-mirrors.webp) center top / var(--wall-w) var(--wall-h) repeat;
          mask: url(../assets/families/wall-mirrors.webp) center top / var(--wall-w) var(--wall-h) repeat;
  background: radial-gradient(circle calc(var(--lamp-w) * 2.3) at var(--gx, 25%) var(--gy, 40%),
    rgba(255, 238, 200, .95), rgba(255, 214, 150, .45) 35%, rgba(255, 200, 130, .1) 70%, transparent);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
}

.families > :not(.fm-glow, .fm-threads, .fm-bloom) { position: relative; }

/* ------------------------------------------------------------ heading */

.fm-head > * { margin: 0; }

.fm-kicker {
  font: 600 clamp(11px, 3cqi, 14px)/1.3 "Cormorant Garamond", Georgia, serif;
  letter-spacing: .28em;
  padding-left: .28em;
  text-transform: uppercase;
  color: var(--gold);
}

.fm-title {
  font: 400 clamp(40px, 11cqi, 64px)/1.15 "Alex Brush", cursive;
  padding: 0 .3em .06em;
  background: url(../assets/hero/gold.webp) 0 0 / 4em 4em;
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  filter: drop-shadow(0 .03em .03em rgba(0, 0, 0, .6));
}

/* ------------------------------------------------------------ the lamps */

.fm-lamps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas: "a b" "u u";
  column-gap: var(--gap);
  width: 100%;
  max-width: 760px;
  margin-top: 16px;
}

.fm-side-a { grid-area: a; }
.fm-side-b { grid-area: b; }
.fm-union { grid-area: u; }

/* the gold rail they hang from, from one lamp to the other and a little past */
.fm-rail {
  position: absolute;
  top: 0;
  left: calc((100% - var(--gap)) / 4 - 34px);
  right: calc((100% - var(--gap)) / 4 - 34px);
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, #f3dc9c, #b88d3f 55%, #6f5020);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .5);
}

.fm-rail::before,
.fm-rail::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  translate: 0 -50%;
  background: radial-gradient(circle at 35% 30%, #fff1c4, #c9a45c 45%, #6f5020);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}

.fm-rail::before { left: -6px; }
.fm-rail::after { right: -6px; }

.fm-side {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* chain and lantern swing a little, from the rail */
.fm-hang {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: 50% 0;
  animation: fm-sway 5.4s ease-in-out infinite alternate;
}

.fm-side-b .fm-hang { animation-duration: 6.1s; animation-delay: -2.2s; }

@keyframes fm-sway {
  from { rotate: -1.3deg; }
  to { rotate: 1.3deg; }
}

.fm-chain {
  display: block;
  width: calc(var(--lamp-w) * .07);
  min-width: 6px;
  height: clamp(26px, 8cqi, 64px);
  background: url(../assets/families/chain.webp) center top / 100% auto repeat-y;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .5));
  margin-bottom: -2px;
}

.fm-lamp {
  position: relative;
  display: block;
  width: var(--lamp-w);
  aspect-ratio: var(--lantern-r);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 40px;
  -webkit-tap-highlight-color: transparent;
}

.fm-lamp:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 6px; }
.is-lit .fm-lamp { cursor: default; }

.fm-lantern {
  position: absolute;
  inset: 0;
  background: center / 100% 100% no-repeat;
  pointer-events: none;
}

.fm-unlit { background-image: url(../assets/families/lantern-unlit.webp); filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .55)); }
.fm-lit { background-image: url(../assets/families/lantern-lit.webp); opacity: 0; }

/* the flame's flicker: its light, brightened a little and dimmed a little */
.fm-flicker {
  background: none;
  -webkit-mask: url(../assets/families/lantern-glow.webp) center / 100% 100% no-repeat;
          mask: url(../assets/families/lantern-glow.webp) center / 100% 100% no-repeat;
  background-color: rgba(255, 196, 110, .55);
  mix-blend-mode: screen;
  opacity: 0;
}

.is-lit .fm-flicker { animation: fm-flicker 2.3s steps(1, end) infinite; }

@keyframes fm-flicker {
  0% { opacity: .35; } 9% { opacity: .5; } 17% { opacity: .28; } 26% { opacity: .45; }
  38% { opacity: .32; } 47% { opacity: .55; } 58% { opacity: .3; } 66% { opacity: .42; }
  78% { opacity: .26; } 87% { opacity: .5; } 94% { opacity: .36; } 100% { opacity: .35; }
}

/* its glow in the air around it */
.fm-halo {
  position: absolute;
  left: 50%;
  top: 48%;
  width: calc(var(--lamp-w) * 2.6);
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 206, 130, .42), rgba(255, 180, 90, .14) 50%, transparent);
  opacity: 0;
  pointer-events: none;
}

/* lit (the lighting itself is animated by js/families.js) */
.is-lit .fm-lit,
.is-lit .fm-halo,
.families.lit-a .fm-glow-a,
.families.lit-b .fm-glow-b { opacity: 1; }

/* arriving: the lamps come down into place on their chains */
.fm-side,
.fm-rail,
.fm-head {
  transition: opacity 1s ease, translate 1.4s cubic-bezier(.2, .7, .2, 1);
}

.fm-side-b { transition-delay: .12s; }

.families:not(.is-seen) .fm-side { opacity: 0; translate: 0 -28px; }
.families:not(.is-seen) .fm-rail,
.families:not(.is-seen) .fm-head { opacity: 0; }

/* ------------------------------------------------------------ the names */

.fm-names {
  margin-top: 14px;
  max-width: 100%;
  transition: opacity .9s ease .25s, color .9s ease .25s, text-shadow .9s ease .25s;
  opacity: .28;
}

.fm-names > * { margin: 0; }

.fm-label {
  font: 600 clamp(10px, 2.7cqi, 13px)/1.3 "Cormorant Garamond", Georgia, serif;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px !important;
}

.fm-parents {
  font: 500 clamp(17px, 5cqi, 24px)/1.3 "Cormorant Garamond", Georgia, serif;
  color: var(--ivory);
  text-wrap: balance;
}

.is-lit .fm-names { opacity: 1; }
.is-lit .fm-parents { color: var(--gold-soft); text-shadow: 0 0 14px rgba(255, 200, 120, .45), 0 1px 2px rgba(0, 0, 0, .6); }

/* ------------------------------------------------------------ the couple, and the dua */

.fm-union {
  margin-top: clamp(26px, 8cqi, 48px);
  opacity: 0;
  translate: 0 10px;
  transition: opacity 1.1s ease, translate 1.2s cubic-bezier(.2, .7, .2, 1);
}

.fm-union > * { margin: 0; }

.families.is-united .fm-union { opacity: 1; translate: none; }

.fm-couple {
  font: 400 clamp(40px, 12cqi, 66px)/1.1 "Alex Brush", cursive;
  padding: 0 .3em .08em;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 250, 230, .55), transparent 55%),
    url(../assets/hero/gold.webp) 0 0 / 4em 4em;
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 .2em rgba(255, 200, 120, .35)) drop-shadow(0 .03em .03em rgba(0, 0, 0, .6));
}

.fm-couple i { font-style: normal; font-size: .62em; }

.fm-dua {
  margin-top: 12px !important;
  font: 400 clamp(20px, 6.2cqi, 30px)/1.9 "Amiri", serif;
  color: var(--gold-soft);
}

.fm-dua-en {
  font: italic 500 clamp(15px, 4.4cqi, 20px)/1.4 "Cormorant Garamond", Georgia, serif;
  color: rgba(245, 239, 226, .88);
  max-width: 30em;
  margin-inline: auto !important;
  text-wrap: balance;
}

.fm-dua-ref {
  margin-top: 6px !important;
  font: 600 clamp(10px, 2.6cqi, 12px)/1.3 "Cormorant Garamond", Georgia, serif;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
}

.fm-hint {
  margin: 20px 0 0;
  font: italic 500 clamp(15px, 4.4cqi, 19px)/1.3 "Cormorant Garamond", Georgia, serif;
  color: var(--gold-soft);
  animation: fm-hint 2.8s ease-in-out infinite;
  transition: opacity .6s;
}

.families.is-joined .fm-hint { opacity: 0 !important; animation: none; }

@keyframes fm-hint {
  0%, 100% { opacity: .5; }
  50% { opacity: 1; }
}

/* ------------------------------------------------------------ the light between them */

.fm-threads {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
}

.fm-threads path { fill: none; stroke-linecap: round; opacity: 0; }
.fm-thread-glow { stroke: rgba(255, 206, 130, .7); stroke-width: 7; filter: url(#fmBlur); }
.fm-thread-core { stroke: #fff4d6; stroke-width: 1.6; }

.fm-bloom {
  position: absolute;
  left: 0;
  top: 0;
  width: 150px;
  height: 150px;
  margin: -75px 0 0 -75px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 252, 236, .95), rgba(255, 222, 160, .45) 35%, rgba(255, 200, 120, .12) 65%, transparent);
  opacity: 0;
  pointer-events: none;
}

/* ------------------------------------------------------------ sideways tablets */

/* The couple between the two lamps, level with their light. */
@media (min-aspect-ratio: 6/5) {
  html.is-tablet .families { --lamp-w: min(12cqi, 160px, 15svh); --gap: clamp(20px, 3cqi, 44px); }
  html.is-tablet .fm-lamps {
    grid-template-columns: 1fr minmax(0, 1.5fr) 1fr;
    grid-template-areas: "a u b";
    max-width: 1080px;
    align-items: start;
  }
  html.is-tablet .fm-union {
    margin-top: 0;
    align-self: center;
  }
  html.is-tablet .fm-rail {
    left: calc((100% - 2 * var(--gap)) / 7 - 30px);
    right: calc((100% - 2 * var(--gap)) / 7 - 30px);
  }
}

/* ------------------------------------------------------------ calm */

@media (prefers-reduced-motion: reduce) {
  .fm-side,
  .fm-rail,
  .fm-head { transition: none; }
  .fm-hang,
  .fm-hint,
  .is-lit .fm-flicker { animation: none; }
  .is-lit .fm-flicker { opacity: .35; }
}
