/* ==========================================================================
   Kheema Bisht Inter College: Dusk, home page light and motion (theme-c-home-fx.css)
   Loaded on index.html only, after theme-c-fx.css. Works with dusk/core.js
   (the engine attributes) and dusk/home.js (swipe, buttons, the NEW tag).

   THE FALLBACK RULE holds for every rule here: the resting CSS is the finished
   state. A start state exists only inside prefers-reduced-motion: no-preference
   and only on an element the engine has armed (.kb-arm, below the first screen)
   or under html.kb-on for scroll-driven rules, which need no script to finish.

   Photos are never tinted or blurred: they are cropped (clip) or lit from beside.
   ========================================================================== */

/* ---------- Hero: the opening shot ends in stars ----------
   The stars live in a layer that covers the sky only. It ends above the roofs,
   so no star, pointer light or tap ring is ever drawn over the school. */
.hero-sky {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 1;
  height: 0;
  pointer-events: none;
}
@supports (width: 1cqw) {
  /* The highest roof (the left wing, at the left edge) stands 27% down the photo frame
     (1456 x 1080), the hills 32.4%. The layer ends a little above that roof at every width.
     Phone and tablet layout: the frame covers the media box and is centred in it. */
  .hero-sky { height: calc(50cqh - 0.245 * max(74.18cqw, 100cqh)); }
  @media (min-width: 960px) {
    /* wide layout: the hills sit --sky below the top of the hero (or 24.04cqw, if that is less),
       the highest roof 4cqw above them */
    .hero-sky { height: calc(min(var(--sky), 24.04cqw) - 4.8cqw); }
  }
}

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    /* leaving the hero: a slow push-in as the shot ends */
    html.kb-on .hero { view-timeline: --home-hero block; }
    html.kb-on .hero-frame {
      animation: home-push linear both;
      animation-timeline: --home-hero;
      animation-range: exit 0% exit 100%;
    }

    /* the golden-hour photo enters as a tall arched window and opens to full bleed
       (the photo is only cropped; the heading and the paper ridge are not clipped) */
    html.kb-on .why-panorama { view-timeline: --home-why block; background: var(--paper); }
    html.kb-on .why-panorama > img, html.kb-on .why-panorama > :where(.kb-pic) > img,
    html.kb-on .why-panorama::before {
      animation: home-arch linear both;
      animation-timeline: --home-why;
      animation-range: entry 0% entry 80%;
    }
  }
}
/* the photo is never dimmed: only the slow push-in */
@keyframes home-push { to { scale: 1.06; } }
@keyframes home-arch {
  from { clip-path: inset(8% 7% 0 7% round 999px 999px 0 0); }
  to { clip-path: inset(0 0 0 0 round 0 0 0 0); }
}
@media (max-width: 719px) {
  @keyframes home-arch {
    from { clip-path: inset(6% 3.5% 0 3.5% round 999px 999px 0 0); }
    to { clip-path: inset(0 0 0 0 round 0 0 0 0); }
  }
}

/* ---------- Nursery ---------- */
/* a sideways swipe changes the slide (home.js), an up or down drag still scrolls the page */
.nursery-slider { touch-action: pan-y; }
/* the rule beside the quote is a drawn line, so it can draw top to bottom */
.nursery-safe[data-kb-rule] { position: relative; border-left-color: transparent; }
.nursery-safe[data-kb-rule]::before {
  content: "";
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--maroon);
}

/* ---------- Hall of fame: lamps along the corridor ----------
   Each arch carries a dusk veil that lifts when the card is lit (.is-lit, hover
   or focus). The veil is a layer over the arch, so the photo pixels are never
   filtered, and it exists only on a card the engine has armed. */
.fame .topper-card { position: relative; }
.fame .topper-card[data-kb-lit] { box-shadow: none; }
/* the tilt glare (a layer tilt.js adds over the whole card) is cut to the arch: it
   lights the portrait only, never a box around the arch and the name below it */
.fame .topper-card > .kbfx-layer {
  inset: 0 0 auto !important;
  aspect-ratio: 4 / 5;
  border-radius: 999px 999px var(--radius) var(--radius) !important;
  contain: layout paint !important;
  -webkit-clip-path: inset(0 round 999px 999px var(--radius) var(--radius));
  clip-path: inset(0 round 999px 999px var(--radius) var(--radius));
}
.fame .topper-card::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  aspect-ratio: 4 / 5;
  border-radius: 999px 999px var(--radius) var(--radius);
  background: linear-gradient(180deg, #10172f, #1b1f40);
  opacity: 0;
  pointer-events: none;
}
/* the arch rim warms to brass, a little stronger as night comes */
.fame .topper-card img { outline-color: rgba(235, 203, 138, calc(0.2 + 0.3 * var(--lamp, 0.55))); }
/* block toppers: a thin bus-yellow rim inside the outline, the window light */
.fame .topper-card.is-block-topper img {
  outline-color: #b4495b;
  box-shadow: 0 0 0 1.5px rgba(255, 199, 44, calc(0.5 + 0.4 * var(--lamp, 0.55)));
}
@media (prefers-reduced-motion: no-preference) {
  .fame .topper-card::after { transition: opacity 900ms var(--ease) calc(var(--i, 0) * 70ms); }
  .fame .topper-card.kb-arm:not(.is-lit, :hover, :focus-within)::after { opacity: 0.5; }
  .fame .topper-card.kb-arm:not(.is-lit, :hover, :focus-within) img { outline-color: rgba(235, 203, 138, 0.12); }
  .fame .topper-card.is-block-topper.kb-arm:not(.is-lit, :hover, :focus-within) img { outline-color: rgba(180, 73, 91, 0.35); box-shadow: 0 0 0 1.5px rgba(255, 199, 44, 0); }
  .fame .topper-card:is(:hover, :focus-within)::after { transition-delay: 0ms; transition-duration: 300ms; }
  /* the rim warms with the lifting veil. It is an animation, played once: the rim also follows the
     evening light (--lamp), and a transition would start again on every arch at every step of it */
  .fame .topper-card.kb-arm.is-lit img { animation: home-rim 900ms var(--ease) calc(var(--i, 0) * 70ms) backwards; }
  .fame .topper-card.is-block-topper.kb-arm.is-lit img { animation-name: home-rim-bt; }

  /* phones have no tilt: a brass glare crosses each arch once as it lights */
  html.kb-touch .fame .topper-card::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    z-index: 1;
    aspect-ratio: 4 / 5;
    border-radius: 999px 999px var(--radius) var(--radius);
    background: linear-gradient(105deg, rgba(243, 197, 107, 0) 42%, rgba(243, 197, 107, 0.42) 50%, rgba(243, 197, 107, 0) 58%) no-repeat 180% 0 / 300% 100%;
    pointer-events: none;
  }
  html.kb-touch .fame .topper-card.kb-arm.is-lit::before {
    animation: home-glare 1000ms var(--ease) calc(var(--i, 0) * 70ms + 350ms) both;
  }
}
@keyframes home-glare { from { background-position: 180% 0; } to { background-position: -80% 0; } }
@keyframes home-rim { from { outline-color: rgba(235, 203, 138, 0.12); } }
@keyframes home-rim-bt { from { outline-color: rgba(180, 73, 91, 0.35); box-shadow: 0 0 0 1.5px rgba(255, 199, 44, 0); } }

/* the fact chips roll their numbers: the theme styles every span in a chip as its
   label, so the rolling digits (spans the odometer adds for a moment) are set back */
.fact strong span { display: inline; margin: 0; font: inherit; letter-spacing: inherit; color: inherit; }
.fact strong .kbfx-col { display: inline-block; }
.fact strong .kbfx-strip, .fact strong .kbfx-strip > span { display: block; }

/* the NEW tag: one sheen pass after it enters view (home.js adds .is-sheen) */
.new-tag.is-sheen {
  background-image: linear-gradient(105deg, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0.8) 50%, rgba(255, 255, 255, 0) 62%);
  background-repeat: no-repeat;
  background-size: 300% 100%;
  background-position: 160% 0;
  animation: home-sheen 900ms var(--ease) 1200ms 1 both;
}
@keyframes home-sheen { from { background-position: 160% 0; } to { background-position: -60% 0; } }

/* ---------- Principal's letter ---------- */
/* the shutter also uncovers the hairline that stands 8px off the arch, so the rim never pops in */
@media (prefers-reduced-motion: no-preference) {
  .principal-portrait.kb-arm[data-kb-shutter].is-in { animation-name: home-shutter-wide; }
}
@keyframes home-shutter-wide { from { clip-path: inset(100% -12px -12px -12px); } to { clip-path: inset(-12px); } }
/* the hairline above the signature is a drawn line, so it can draw from the left */
.signature[data-kb-rule] { position: relative; border-top-color: transparent; }
.signature[data-kb-rule]::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 1px;
  background: var(--hair-light);
}

/* ---------- Voices: the dots are a row of small arched windows, the active one is lit ---------- */
.testimonial-carousel-dot::before {
  width: 8px;
  height: 12px;
  border-radius: 999px 999px 2px 2px;
  /* the glow of the lit window follows the evening light, so it is left out of the transition */
  transition: width 0.3s var(--ease), height 0.3s var(--ease), background-color 0.3s;
}
.testimonial-carousel-dot.is-active::before {
  width: 10px;
  height: 15px;
  background: var(--brass-light);
  box-shadow: 0 0 12px 2px rgba(235, 203, 138, calc(0.6 * var(--lamp, 0.55)));
}

@media print {
  .fame .topper-card::after, .fame .topper-card::before { display: none !important; }
  .hero-frame, .why-panorama > img, .why-panorama > :where(.kb-pic) > img, .why-panorama::before { animation: none !important; clip-path: none !important; scale: none !important; opacity: 1 !important; }
}

/* ---------- Print: black on white, every number final ---------- */
@media print {
  /* a number that has not rolled yet prints as its real text, never as the rolling copy */
  .kbfx-sr.kbfx-sr { position: static !important; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; }
  .kbfx-sr + [aria-hidden="true"] { display: none !important; }
  .dusk-band :is(p, h2, li, a, span, strong), .fame :is(h2, h3, h4, p, strong, span, div), .helpdesk-band :is(h3, p),
  .voices :is(h2, p, strong, span) { color: #000 !important; text-shadow: none !important; }
  .stat-value::after { color: #000; }
  .voices-bg, .voices::before { display: none !important; }
  .bt-tag, .new-tag, .label-badge { background: #fff !important; color: #000 !important; border: 1px solid #999; box-shadow: none !important; }
  .topper-card img { outline-color: #999 !important; box-shadow: none !important; }
}

/* a number that did not roll (it was on the first screen, or motion is off) carries the same glow */
[data-kb-roll]:not([data-kb-odo]) { text-shadow: var(--kb-glow, none); }
/* a number that has rolled: its glow comes up once, as an animation, and no transition stays on it.
   The glow follows the evening light (--lamp), so a transition would start again at every step of it. */
[data-kb-roll][data-kb-odo] { transition: none; }
@media (prefers-reduced-motion: no-preference) {
  [data-kb-roll][data-kb-odo].is-rolled { animation: home-glow-in 400ms ease backwards; }
}
@keyframes home-glow-in { from { text-shadow: 0 0 0 transparent; } }

/* Owner request (30 Nov): the constellations reach down over the whole school photo,
   not only the sky. The star dust layer above stays sky-only. */
.hero-sky.hero-con { height: auto !important; bottom: 0; }

/* Owner request (30 Nov): the same sky (stars, constellations, shooting stars) in the dark
   sections below the hero. Decorative layers sit behind the content and never take clicks. */
.dusk-band, .fame, .helpdesk-band { position: relative; isolation: isolate; }
.kb-sky-layer { position: absolute; inset: 0; z-index: 0; pointer-events: none; display: block; }
.dusk-band > .container, .fame > .container, .helpdesk-band > .container { position: relative; z-index: 1; }

/* Fix (3 Dec): on phones the scroll-linked push-in could leave the home photo unpainted
   before the first scroll. Phones keep a still photo; the push-in stays on wide screens. */
@media (max-width: 959px) {
  html.kb-on .hero-frame { animation: none !important; }
}

/* Owner request (3 Dec): on phones, one constellation lives in the free sky at the top right,
   beside the school name (the extra sky set is boxed into that corner). */
@media (max-width: 699px) {
  .hero-sky.hero-con-sky { left: 64% !important; right: 0 !important; top: 0 !important; height: 26% !important; bottom: auto !important; }
}
