/* The jewelled toran at the top of the invitation (built by toran.js).
   Layers, back to front: fine pearl strings, festoons, flower strings, then the gold valance.
   Opening: the valance spreads from the centre, the medallion drops in, the festoons bloom,
   then the strings unroll outward. Afterwards: strings sway at their own pace (long ones barely),
   festoons breathe, a sheen sweeps the gold bar and jewels glint now and then. */

.toran { position: absolute; top: 0; left: 0; right: 0; height: 340px; z-index: 3; pointer-events: none; }
.toran svg { display: block; overflow: visible; }

.toran-valance { position: absolute; top: 0; left: 0; z-index: 4; filter: drop-shadow(0 2px 3px rgba(90, 55, 10, .35)); transform-origin: 50% 0; }
.toran-swags { position: absolute; top: 0; left: 0; z-index: 2; }
.strand { position: absolute; z-index: 3; width: 34px; margin-left: -17px; }
.strand--back { z-index: 1; opacity: .92; }
.strand-sway { display: block; transform-origin: 50% 0; animation: strand-sway var(--dur, 4s) ease-in-out var(--delay, 0s) infinite; }
.strand:not(.strand--back) svg { filter: drop-shadow(0 1.5px 1.5px rgba(80, 40, 10, .28)); }
.toran-thread { stroke: #B8893A; stroke-width: .8; }
.toran-thread--fine { stroke-width: .45; }

@keyframes strand-sway {
  0%, 100% { transform: rotate(calc(var(--swing, 2deg) * -1)); }
  50% { transform: rotate(var(--swing, 2deg)); }
}

/* Festoons breathe a little, like fabric settling */
.swag { transform-box: fill-box; transform-origin: 50% 0; animation: swag-breathe 4.6s ease-in-out calc(var(--sd, 1s) + 1.2s) infinite alternate; }
@keyframes swag-breathe { from { transform: scaleY(1); } to { transform: scaleY(1.1); } }

/* Light sweeping along the gold bar */
.toran-sheen { animation: sheen-sweep 6.5s ease-in-out 3s infinite; }
@keyframes sheen-sweep {
  0% { transform: translateX(0); }
  45%, 100% { transform: translateX(var(--sweep, 500px)); }
}

/* Jewels catch the light now and then */
.glint { opacity: 0; transform-box: fill-box; transform-origin: 50% 50%; animation: glint 4.2s ease-in-out var(--gd, 0s) infinite; }
@keyframes glint {
  0%, 78%, 100% { opacity: 0; transform: scale(.2) rotate(0deg); }
  88% { opacity: 1; transform: scale(1.15) rotate(45deg); }
}

/* ───────── Entrance, only once JS is running ───────── */
.js .toran-valance { transform: scaleX(0); opacity: 0; }
.js.is-open .toran-valance { transform: none; opacity: 1; transition: transform 1.1s cubic-bezier(.45, 0, .2, 1) .5s, opacity .4s ease .5s; }

.toran-crest { transform-box: fill-box; transform-origin: 50% 0; }
.js .toran-crest { opacity: 0; transform: translateY(-26px) scale(.7); }
.js.is-open .toran-crest { opacity: 1; transform: none; transition: opacity .5s ease 1.2s, transform 1.1s cubic-bezier(.34, 1.6, .5, 1) 1.2s; }

.js .swag { opacity: 0; }
.js.is-open .swag { opacity: 1; transition: opacity .9s ease var(--sd, 1.2s); }

.js .strand { clip-path: inset(0 0 100% 0); }
.js.is-open .strand { clip-path: inset(0 0 -24px 0); transition: clip-path 1.7s cubic-bezier(.25, .8, .25, 1) var(--in, 1.5s); }
