/* 2. hero: airplane window. 200x300 box at both widths; the element is padded
   30/20 to 260x340 so the soft halo (~10-15px, baked into window.png) has room,
   and negative margins keep the 200x300 layout footprint.
   Layers (all in the box): sky + drifting clouds, front frame image (solid frame
   x12-187 y25-261, soft halo baked in, glass opening transparent), pull-down shade, drag button. */
.folio-window {
  --shade: 0; /* 0 open .. 1 closed, driven by hero.js */
  position: relative;
  z-index: 6; /* paints above the bottom veil */
  flex: none;
  box-sizing: content-box;
  width: 200px;
  height: 300px;
  padding: 20px 30px;
  margin: -20px -30px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.fw-box { position: relative; width: 200px; height: 300px; }
.fw-box > * { position: absolute; }
.fw-box > picture { left: 0; top: 0; }

/* 1. the view: sits under the frame, a little larger than the opening (x38.3-161, y58.7-218.3).
   Layers from site/assets/hero/ (Google Flow, made by the lead):
   - sky-loop: 2508x700 seamless strip [A | mirrored A], drawn at .3 (752.4 x 210).
     Its horizon (warm sunset band, image y~330) lands at box y~120.
   - air: the same strip held still, so the sky and the sunset glow do not slide.
   - deck far / near: the strip again, masked to the cloud deck, drifting rightward
     (towards the tail) endlessly; the far band slower than the near clouds for depth.
   - wing: cut-out wing, fixed in the lower part with a tiny turbulence bob.
   - glass: a faint reflection and a soft inner shadow at the edge of the pane. */
.fw-sky {
  --sky: url("../assets/hero/sky-loop.jpg");
  --p: 752.4px; /* one full loop of the strip */
  left: 30px;
  top: 50px;
  width: 140px;
  height: 178px;
  overflow: hidden;
  background: #cfd6de;
}
.fw-sky > * { position: absolute; }
.fw-air, .fw-deck {
  top: -29px;
  height: 210px;
  background-image: var(--sky);
  background-image: image-set(url("../assets/hero/sky-loop.webp") type("image/webp"), url("../assets/hero/sky-loop.jpg") type("image/jpeg"));
  background-size: var(--p) 210px;
  background-repeat: repeat-x;
}
/* the glow of the sunset (image x 1254) held a little right of centre */
.fw-air { left: 0; width: 100%; background-position: -300px 0; }
/* deepen the upper sky towards the reference blue; the sunset stays at the horizon */
.fw-air::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(84, 164, 246, .78) 29px, rgba(104, 176, 248, .55) 62px, rgba(140, 196, 248, .16) 86px, rgba(160, 205, 248, 0) 98px);
}
.fw-deck {
  left: 0;
  width: calc(var(--p) * 2);
  will-change: transform;
  animation: fw-cruise var(--t) linear infinite;
}
/* far deck: just under the horizon, slow */
.fw-deck--far {
  --t: 380s; /* owner 2026-11-02: "the flying is fast, make it slower" (was 150s) */
  -webkit-mask-image: linear-gradient(transparent 99px, #000 107px);
  mask-image: linear-gradient(transparent 99px, #000 107px);
  animation-delay: -40s;
}
/* near deck: the big clouds below, cruising past */
.fw-deck--near {
  --t: 140s; /* owner 2026-11-02: slower cruise (was 54s) */
  -webkit-mask-image: linear-gradient(transparent 112px, #000 132px);
  mask-image: linear-gradient(transparent 112px, #000 132px);
  animation-delay: -21s;
}
@keyframes fw-cruise {
  from { transform: translate3d(calc(var(--p) * -1), 0, 0); }
  to { transform: translate3d(0, 0, 0); }
}

/* sun: a little more sunset (owner 2026-11-02). Held still over the drifting decks:
   a warm sun glow sitting on the horizon (sky y~73) right of centre, a peach band
   along the horizon and a faint rose wash on the nearer cloud tops. Pure CSS. */
.fw-sun {
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(34px 14px at 66% 73px, rgba(255, 236, 196, .85), rgba(255, 196, 128, .45) 45%, rgba(255, 170, 110, 0) 100%),
    radial-gradient(90px 34px at 66% 74px, rgba(255, 178, 112, .42), rgba(255, 160, 110, 0) 100%),
    linear-gradient(rgba(255, 170, 120, 0) 44px, rgba(255, 176, 120, .26) 68px, rgba(255, 160, 128, .22) 80px, rgba(236, 150, 150, .10) 108px, rgba(236, 150, 150, 0) 150px);
}

/* wing: 1200x700 cut-out at .1067 (128 x 74.7); root hidden under the frame on the
   left, winglet tip inside the pane at ~x149 y150 */
.fw-wing {
  left: -4px;
  top: 100px;
  width: 128px;
  height: 74.7px;
  background: url("../assets/hero/wing.png") 0 0 / 100% 100% no-repeat;
  background-image: image-set(url("../assets/hero/wing.webp") type("image/webp"), url("../assets/hero/wing.png") type("image/png"));
  transform-origin: 0 100%;
  will-change: transform;
  animation: fw-bob 9s ease-in-out infinite;
}
@keyframes fw-bob {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  22% { transform: translate3d(0, -.7px, 0) rotate(-.12deg); }
  41% { transform: translate3d(0, .25px, 0) rotate(.05deg); }
  63% { transform: translate3d(0, -.45px, 0) rotate(-.08deg); }
  81% { transform: translate3d(0, .35px, 0) rotate(.06deg); }
}

/* glass: soft inner shadow at the pane edge and a faint diagonal reflection */
.fw-glass {
  left: 8.3px;
  top: 8.7px;
  width: 122.7px;
  height: 159.6px;
  border-radius: 50.7px;
  box-shadow: inset 0 0 6px rgba(40, 52, 70, .22);
  background: linear-gradient(118deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, .10) 42%, rgba(255, 255, 255, 0) 56%);
}

/* 2. front frame: 780x1020 image at 3x (box + 30/20 halo margin) */
.fw-frame {
  position: absolute;
  left: -30px;
  top: -20px;
  width: 260px;
  height: 340px;
  max-width: none;
  pointer-events: none;
  -webkit-user-drag: none;
  filter: brightness(calc(1 - var(--shade) * .84));
}

/* 3. shade: clipped to the inner aperture, pulled up when open */
.fw-shade-clip {
  left: 37px;
  top: 41px;
  width: 126px;
  height: 200px;
  overflow: hidden;
  clip-path: inset(0 round 63px 63px 58px 58px / 34px 34px 58px 58px);
  pointer-events: none;
}
/* crease where the slab tucks under the frame (follows the clip's top arc) */
.fw-shade-clip::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 60px;
  border-radius: 63px 63px 0 0 / 34px 34px 0 0;
  box-shadow: inset 0 4px 3px -1px rgba(60, 45, 30, .38);
  opacity: calc(1 - var(--shade) * .7);
}
/* open: the slab shows y41-70 (face, handle, lip, lit edge); closed: covers the glass */
.fw-shade {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 0 0 50% 50% / 0 0 6px 6px;
  transform: translateY(calc((1 - var(--shade)) * -171px));
  background: linear-gradient(
    rgb(174, 162, 151) 0,
    rgb(172, 160, 149) calc(100% - 13px),
    rgb(160, 149, 138) calc(100% - 12px),
    rgb(186, 177, 170) calc(100% - 10px),
    rgb(192, 182, 175) calc(100% - 7px),
    rgb(194, 184, 172) calc(100% - 3px),
    rgb(232, 226, 220) calc(100% - 1.5px),
    rgb(246, 242, 238) 100%
  );
  filter: brightness(calc(1 - var(--shade) * .8));
  will-change: transform;
}
/* soft inner shadow along the sides; kept off the lit lip */
.fw-shade::before {
  content: "";
  position: absolute;
  inset: 0 0 -14px;
  box-shadow: inset 0 0 11px rgba(28, 25, 22, .42), inset 0 0 3px rgba(28, 25, 22, .3);
  border-radius: inherit;
}
/* the moulded pull handle on the slab: a recessed strip with a dark groove on
   top and a lit ridge along its bottom edge, bowed slightly like the slab lip */
.fw-handle {
  position: absolute;
  left: 50%;
  bottom: 8.5px;
  width: 82px;
  height: 6px;
  margin-left: -41px;
  border-radius: 40% 40% 50% 50% / 30% 30% 100% 100%;
  background: linear-gradient(rgb(144, 134, 123) 0, rgb(156, 146, 135) 1px, rgb(166, 155, 144) 2.5px, rgb(182, 172, 162) 4.5px, rgb(190, 180, 170) 6px);
  box-shadow: 0 1px 0 rgba(236, 229, 222, .95), 0 1.5px 1px rgba(214, 205, 196, .6);
}

/* 4. invisible drag target over the opening */
.fw-grab {
  left: 38px;
  top: 42px;
  width: 124px;
  height: 177px;
  cursor: grab;
  touch-action: none;
  border-radius: 50px;
}
.fw-grab:active, .folio-window.is-dragging .fw-grab { cursor: grabbing; }
.fw-grab:focus-visible { outline-offset: -2px; }

@media (prefers-reduced-motion: reduce) {
  .fw-deck, .fw-wing { animation: none; }
}

/* theme switch veil (fades the old background out over 300ms) */
.fw-veil {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  animation: fw-veil .3s ease forwards;
}
@keyframes fw-veil { to { opacity: 0; } }
