/* The families: two lamps, one light (after Sheesh Mahal's).

   The courtyard's Lahori brick wall (assets/families/wall.webp, tiled), in the cool morning
   shade, with two hanging lamps of pierced, glazed kashi tile-work on a brass rail, one for each
   family, their names beneath. Each lamp is a button; lit (.is-lit on its side, set by
   js/families.js), its flame shines out through its star-shaped openings, its glow warms the
   brick around it back to its full colour (.fm-glow: the wall again, unshaded, around the lamp),
   and the family's names come up in ivory. 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.

   The words are ivory and brass here: cobalt glaze would be lost on the brick.

   Phones, upright tablets and the laptop column: the lamps side by side, the couple below.
   Sideways tablets: the couple between the lamps. */

.families {
  /* the lamps are tall (more than twice as tall as wide, their chain included), so they are
     sized by the screen's height too */
  --lamp-w: min(34cqi, 150px, 17svh);
  --gap: clamp(30px, 10cqi, 96px);
  --wall-w: 470px;                       /* a brick about 70px long */
  --fm-ivory: #f4e9d2;
  --fm-brass: #dcb46a;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: calc(var(--seam-h) * .5 + 30px) 16px calc(var(--seam-h) * .5 + 34px);
  overflow: hidden;
  background: url(../assets/families/wall.webp) center top / var(--wall-w) auto repeat, #5a2a1c;
  color: var(--fm-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(24cqi, 190px, 17svh); --wall-w: 540px; }

@media (max-aspect-ratio: 5/8) {
  html:not(.is-tablet) .card .families { --lamp-w: min(34cqi, 150px, 17svh); --wall-w: 470px; }
}

/* The wall in the cool shade of the morning: dim, a little cool, darkest at the edges. */
.families::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 95% 70% at 50% 42%, rgba(16, 12, 22, .44), rgba(10, 8, 16, .8)),
    linear-gradient(180deg, rgba(30, 44, 80, .18), rgba(30, 44, 80, .06));
  pointer-events: none;
}

/* A lamp's light on the brick: the wall again, unshaded and warmed, around the lamp
   (--gx, --gy: its middle, set by js/families.js). */
.fm-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle calc(var(--lamp-w) * 1.4) at var(--gx, 25%) var(--gy, 40%), rgba(255, 190, 110, .34), rgba(255, 170, 90, .1) 55%, transparent),
    url(../assets/families/wall.webp) center top / var(--wall-w) auto repeat;
  -webkit-mask: radial-gradient(circle calc(var(--lamp-w) * 1.6) at var(--gx, 25%) var(--gy, 40%), #000, rgba(0, 0, 0, .55) 38%, rgba(0, 0, 0, .15) 70%, transparent);
          mask: radial-gradient(circle calc(var(--lamp-w) * 1.6) at var(--gx, 25%) var(--gy, 40%), #000, rgba(0, 0, 0, .55) 38%, rgba(0, 0, 0, .15) 70%, transparent);
  opacity: 0;
  pointer-events: none;
}

.families > :not(.fm-glow, .fm-threads, .fm-bloom) { position: relative; }

/* ------------------------------------------------------------ heading */

.fm-head > * { margin: 0; }

.fm-kicker {
  font: 700 clamp(11px, 3cqi, 14px)/1.3 "Cormorant Garamond", Georgia, serif;
  letter-spacing: .26em;
  padding-left: .26em;
  text-transform: uppercase;
  color: var(--fm-brass);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

/* The title in ivory glaze: glossy, a highlight from the upper left, a warmer foot. */
.fm-title {
  font: 400 clamp(44px, 12cqi, 70px)/1.15 "Great Vibes", cursive;
}

.fm-title span,
.fm-couple {
  display: inline-block;
  padding: 0 .28em .08em;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 38%, rgba(0, 0, 0, 0) 62%, rgba(120, 70, 20, .35)),
    linear-gradient(90deg, #f6ecd6, #e9d6b0 30%, #fbf3e2 55%, #e2cda4 82%, #f6ecd6);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  filter: drop-shadow(0 .03em .02em rgba(20, 8, 4, .75)) drop-shadow(0 0 .25em rgba(0, 0, 0, .35));
}

/* ------------------------------------------------------------ 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: 18px;
}

.fm-side-a { grid-area: a; }
.fm-side-b { grid-area: b; }
.fm-union { grid-area: u; }

/* the brass 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 - 40px);
  right: calc((100% - var(--gap)) / 4 - 40px);
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(180deg, #f1d79a, #b8883c 55%, #6a4718);
  box-shadow: 0 3px 5px rgba(0, 0, 0, .55);
  z-index: 1;
}

.fm-rail::before,
.fm-rail::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  translate: 0 -50%;
  background: radial-gradient(circle at 35% 30%, #fff0c2, #c99e52 45%, #6a4718);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .55);
}

.fm-rail::before { left: -7px; }
.fm-rail::after { right: -7px; }

.fm-side {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* The lamp, its chain up to the rail, swinging a little from where it hangs. */
.fm-lamp {
  position: relative;
  display: block;
  width: var(--lamp-w);
  aspect-ratio: var(--lamp-r);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 40px;
  transform-origin: calc(var(--chain-x) * 100%) 0;
  animation: fm-sway 5.4s ease-in-out infinite alternate;
  -webkit-tap-highlight-color: transparent;
}

.fm-side-b .fm-lamp { animation-duration: 6.1s; animation-delay: -2.2s; }

@keyframes fm-sway {
  from { rotate: -1.2deg; }
  to { rotate: 1.2deg; }
}

.fm-lamp:focus-visible { outline: 2px solid var(--fm-brass); outline-offset: 6px; }
.is-lit .fm-lamp { cursor: default; }

.fm-pic {
  position: absolute;
  inset: 0;
  background: center / 100% 100% no-repeat;
  pointer-events: none;
}

.fm-unlit { background-image: url(../assets/families/lamp-unlit.webp); filter: drop-shadow(4px 8px 10px rgba(0, 0, 0, .55)); }
.fm-lit { background-image: url(../assets/families/lamp-lit.webp); opacity: 0; }

/* the flame's flicker: its light, brightened a little and dimmed a little */
.fm-flicker {
  -webkit-mask: url(../assets/families/lamp-glow.webp) center / 100% 100% no-repeat;
          mask: url(../assets/families/lamp-glow.webp) center / 100% 100% no-repeat;
  background-color: rgba(255, 200, 120, .6);
  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 its body */
.fm-halo {
  position: absolute;
  left: 50%;
  top: 62%;
  width: calc(var(--lamp-w) * 2.1);
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 204, 130, .42), rgba(255, 176, 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: 12px;
  max-width: 100%;
  transition: opacity .9s ease .25s;
  opacity: .34;
}

.fm-names > * { margin: 0; }

.fm-label {
  font: 700 clamp(10px, 2.7cqi, 13px)/1.3 "Cormorant Garamond", Georgia, serif;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--fm-brass);
  margin-bottom: 6px !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

.fm-parents {
  font: 600 clamp(17px, 5cqi, 24px)/1.3 "Cormorant Garamond", Georgia, serif;
  color: var(--fm-ivory);
  text-wrap: balance;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .7);
  transition: text-shadow .9s ease .25s;
}

.is-lit .fm-names { opacity: 1; }
.is-lit .fm-parents { text-shadow: 0 0 14px rgba(255, 196, 120, .5), 0 1px 2px rgba(0, 0, 0, .7); }

/* ------------------------------------------------------------ the couple, and the dua */

.fm-union {
  margin-top: clamp(24px, 7cqi, 44px);
  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 "Great Vibes", cursive;
  filter: drop-shadow(0 0 .22em rgba(255, 196, 120, .4)) drop-shadow(0 .03em .02em rgba(20, 8, 4, .75));
}

.fm-couple i { font-style: normal; font-size: .62em; }

.fm-dua {
  margin-top: 10px !important;
  font: 400 clamp(20px, 6.2cqi, 30px)/1.9 "Amiri", serif;
  color: #f1d9a4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .7);
}

.fm-dua-en {
  font: italic 500 clamp(15px, 4.4cqi, 20px)/1.4 "Cormorant Garamond", Georgia, serif;
  color: rgba(246, 238, 222, .92);
  max-width: 30em;
  margin-inline: auto !important;
  text-wrap: balance;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .7);
}

.fm-dua-ref {
  margin-top: 6px !important;
  font: 700 clamp(10px, 2.6cqi, 12px)/1.3 "Cormorant Garamond", Georgia, serif;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--fm-brass);
}

.fm-hint {
  margin: 20px 0 0;
  font: italic 500 clamp(15px, 4.4cqi, 19px)/1.3 "Cormorant Garamond", Georgia, serif;
  color: var(--fm-brass);
  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, 204, 130, .7); stroke-width: 7; filter: url(#fmBlur); }
.fm-thread-core { stroke: #fff3d4; 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, 250, 232, .95), rgba(255, 220, 156, .45) 35%, rgba(255, 196, 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(13cqi, 170px, 19svh); --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 - 34px);
    right: calc((100% - 2 * var(--gap)) / 7 - 34px);
  }
}

/* ------------------------------------------------------------ calm */

@media (prefers-reduced-motion: reduce) {
  .fm-side,
  .fm-rail,
  .fm-head { transition: none; }
  .fm-lamp,
  .fm-hint,
  .is-lit .fm-flicker { animation: none; }
  .is-lit .fm-flicker { opacity: .35; }
}
