/* Living hero for the Ichetucknee headspring photo on Default.aspx.
   Layered over the static <img>: gently moving water, soft sun beams, a
   swaying limb at the bottom right, leaves along the stone walls and the
   tree line across the spring.
   Only transform and opacity animate, so the work stays on the GPU.
   A pause/play button (WCAG 2.2.2) is wired up in /js/hero-living.js. */

.hero-living {
    --hl-photo: url('/images/headers/TDC-Head-Spring-0068.webp');
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

/* The stage is the exact box the photo covers (object-fit: cover, centered),
   so percentages inside it are percentages of the photo itself. */
.hero-living .hl-stage {
    position: absolute;
    left: 50%;
    top: 50%;
    width: max(100%, calc(var(--hero-height, 620px) * 1350 / 663));
    aspect-ratio: 1350 / 663;
    transform: translate(-50%, -50%);
}

/* Photo copies cut out by a mask. */
.hero-living .hl-cut {
    position: absolute;
    inset: 0;
    background: var(--hl-photo) 0 0 / 100% 100% no-repeat;
    -webkit-mask: var(--hl-mask) 0 0 / 100% 100% no-repeat;
    mask: var(--hl-mask) 0 0 / 100% 100% no-repeat;
}

/* ---------- Swaying ----------
   Each piece rotates a fraction of a degree around where it is rooted. */
.hero-living .hl-sway {
    will-change: transform;
    animation: hl-sway var(--dur) ease-in-out var(--delay, 0s) infinite;
}
/* Trees on the far side of the spring, rooted at the far bank. */
.hero-living .hl-far  { --hl-mask: url('/images/headers/hero-living/leaf-far.webp');  transform-origin: 56% 38%;   --amp: .5deg; --dur: 9.5s; --delay: -3s; }
/* Limb and ferns at the bottom right, pivoting where the limb meets the trunk. */
.hero-living .hl-limb { --hl-mask: url('/images/headers/hero-living/leaf-limb.webp'); transform-origin: 88.4% 76.7%; --amp: 1.3deg; --dur: 7s; --delay: -2s; }

/* Leaves along the stone walls. */
.hero-living .hl-wall-left  { --hl-mask: url('/images/headers/hero-living/leaf-wall-left.webp');  transform-origin: 24.4% 72.4%; --amp: .9deg;  --dur: 7.8s; --delay: -4s; }
.hero-living .hl-wall-top   { --hl-mask: url('/images/headers/hero-living/leaf-wall-top.webp');   transform-origin: 34.8% 37%;   --amp: .75deg;  --dur: 8.5s; --delay: -1s; }
.hero-living .hl-wall-back  { --hl-mask: url('/images/headers/hero-living/leaf-wall-back.webp');  transform-origin: 50.4% 62.7%; --amp: .9deg;  --dur: 6.5s; --delay: -6s; }
.hero-living .hl-wall-right { --hl-mask: url('/images/headers/hero-living/leaf-wall-right.webp'); transform-origin: 73.3% 45.2%; --amp: .75deg;  --dur: 7.2s; --delay: -3s; }

@keyframes hl-sway {
    0%, 100% { transform: rotate(calc(var(--amp) * -1)) translateX(0); }
    35%      { transform: rotate(calc(var(--amp) * .6)) translateX(1px); }
    55%      { transform: rotate(var(--amp)) translateX(.5px); }
    80%      { transform: rotate(calc(var(--amp) * -.3)) translateX(-.5px); }
}

/* ---------- Water ---------- */
.hero-living .hl-water { --hl-mask: url('/images/headers/hero-living/mask-water.webp'); }
/* Two slow light-web layers cross each other to read as gentle ripples. */
.hero-living .hl-caustics {
    position: absolute;
    top: -110px; left: -300px; right: 0; bottom: 0;
    background: url('/images/headers/hero-living/caustics.webp') 0 0 / 300px 110px repeat;
    mix-blend-mode: soft-light;
    opacity: .75;
    will-change: transform;
    animation: hl-drift-a 32s linear infinite;
}
.hero-living .hl-caustics + .hl-caustics {
    background-size: 380px 140px;
    top: -140px; left: 0; right: -380px;
    mix-blend-mode: screen;
    opacity: .14;
    animation: hl-drift-b 44s linear infinite;
}
@keyframes hl-drift-a { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(300px, 110px, 0); } }
@keyframes hl-drift-b { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-380px, 140px, 0); } }

/* ---------- Sun ---------- */
.hero-living .hl-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 50% 70% at 67% -6%, rgba(255, 224, 165, .45), rgba(255, 212, 145, .14) 42%, transparent 70%);
    mix-blend-mode: screen;
    will-change: opacity;
    animation: hl-breathe 12s ease-in-out infinite alternate;
}
@keyframes hl-breathe { from { opacity: .7; } to { opacity: 1; } }

/* Soft shafts of light fan out from the bright patch at the top right, each
   slowly brightening, fading and drifting on its own rhythm. */
.hero-living .hl-beam {
    position: absolute;
    left: 67%;
    top: -8%;
    width: var(--w);
    height: 130%;
    margin-left: calc(var(--w) / -2);
    background: linear-gradient(to bottom,
        rgba(255, 242, 212, 0) 0%,
        rgba(255, 240, 208, .8) 8%,
        rgba(255, 232, 180, .35) 40%,
        rgba(255, 224, 165, 0) 72%);
    clip-path: polygon(44% 0, 56% 0, 100% 100%, 0 100%);
    filter: blur(var(--blur, 7px));
    mix-blend-mode: screen;
    transform-origin: 50% 0;
    transform: rotate(var(--a));
    opacity: var(--o1);
    will-change: transform, opacity;
    animation: hl-beam var(--dur) ease-in-out var(--delay) infinite;
}
.hero-living .hl-beam:nth-child(1) { --a: 15deg; --w: 130px; --o1: .12; --o2: .48; --swing: 1.4deg;  --dur: 10s; --delay: 0s; }
.hero-living .hl-beam:nth-child(2) { --a: 25deg; --w: 70px;  --o1: .05; --o2: .42; --swing: -1.1deg; --dur: 8.5s; --delay: -4s;  --blur: 5px; }
.hero-living .hl-beam:nth-child(3) { --a: 34deg; --w: 160px; --o1: .1;  --o2: .4;  --swing: 1.6deg;  --dur: 12.5s; --delay: -7s;  --blur: 10px; }
.hero-living .hl-beam:nth-child(4) { --a: 44deg; --w: 80px;  --o1: .04; --o2: .4;  --swing: -1.4deg; --dur: 9.5s; --delay: -2s; }
.hero-living .hl-beam:nth-child(5) { --a: 5deg;  --w: 100px; --o1: .06; --o2: .36; --swing: 1.1deg;  --dur: 11s; --delay: -9s; }
@keyframes hl-beam {
    0%, 100% { opacity: var(--o1); transform: rotate(var(--a)); }
    50%      { opacity: var(--o2); transform: rotate(calc(var(--a) + var(--swing))); }
}

/* A few faint specks of dust drifting through the light. */
.hero-living .hl-motes span {
    position: absolute;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 248, 222, .9), rgba(255, 232, 175, 0) 70%);
    opacity: 0;
    will-change: transform, opacity;
    animation: hl-mote 18s ease-in-out infinite;
}
.hero-living .hl-motes span:nth-child(1) { left: 58%; top: 20%; animation-delay: 0s; }
.hero-living .hl-motes span:nth-child(2) { left: 64%; top: 32%; animation-delay: -6s;  animation-duration: 21s; width: 3px; height: 3px; }
.hero-living .hl-motes span:nth-child(3) { left: 52%; top: 14%; animation-delay: -11s; animation-duration: 16s; }
.hero-living .hl-motes span:nth-child(4) { left: 70%; top: 26%; animation-delay: -3s;  animation-duration: 23s; width: 3px; height: 3px; }
.hero-living .hl-motes span:nth-child(5) { left: 48%; top: 28%; animation-delay: -15s; animation-duration: 19s; }
.hero-living .hl-motes span:nth-child(6) { left: 61%; top: 40%; animation-delay: -9s;  animation-duration: 20s; width: 3px; height: 3px; }
@keyframes hl-mote {
    0%   { opacity: 0;   transform: translate(0, 0); }
    25%  { opacity: .55; }
    50%  { opacity: .35; transform: translate(-14px, 10px); }
    75%  { opacity: .5; }
    100% { opacity: 0;   transform: translate(-26px, 22px); }
}

@media (max-width: 767px) {
    .hero-living .hl-beam:nth-child(n+4) { display: none; }
    .hero-living .hl-motes span:nth-child(n+4) { display: none; }
}

/* Pause / play button (WCAG 2.2.2). Lives outside .hero-living so screen readers can reach it. */
.site-hero .hl-toggle {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 4;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: 50%;
    background: rgba(0, 0, 0, .35);
    color: #fff;
    cursor: pointer;
}
.site-hero .hl-toggle:hover { background: rgba(0, 0, 0, .55); }
.site-hero .hl-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* Pause icon: two bars. */
.site-hero .hl-toggle::before,
.site-hero .hl-toggle::after {
    content: '';
    position: absolute;
    top: 11px;
    width: 4px;
    height: 12px;
    background: currentColor;
    border-radius: 1px;
}
.site-hero .hl-toggle::before { left: 12px; }
.site-hero .hl-toggle::after  { left: 19px; }
/* Play icon: a triangle. */
.site-hero .hl-toggle.is-paused::before {
    left: 13px;
    width: 0;
    height: 0;
    background: none;
    border-style: solid;
    border-width: 7px 0 7px 12px;
    border-color: transparent transparent transparent currentColor;
    border-radius: 0;
}
.site-hero .hl-toggle.is-paused::after { display: none; }

.hero-living.is-paused *, .hero-living.is-paused *::before, .hero-living.is-paused *::after { animation-play-state: paused !important; }
