/* =========================================================
   ADA Chess Club — advanced effects (second motion layer)
   Works together with motion.css. All decorative; turned
   off for visitors who ask for reduced motion.
   ========================================================= */

/* ---------- Flashlight lens on the home banner ---------- */
.hero-lens {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 2;
  clip-path: circle(0px at var(--lx, 50%) var(--ly, 50%));
  transition: clip-path .5s var(--ease-out);
  filter: saturate(1.25) brightness(1.05);
  animation: kenburns 22s ease-in-out infinite alternate; pointer-events: none;
}
.hero.lens-on .hero-lens { clip-path: circle(170px at var(--lx, 50%) var(--ly, 50%)); }
.hero.lens-move .hero-lens { transition: none; }

/* ---------- 3D headline tilt ---------- */
.h1-3d { transition: transform .35s var(--ease-out), text-shadow .35s var(--ease-out); transform-style: preserve-3d; }

/* ---------- Section headings: 3D letter flip ---------- */
h2.chars { perspective: 700px; }
h2.chars .lw { display: inline-block; white-space: nowrap; }
h2.chars .ch { display: inline-block; opacity: 0; transform: translateY(.45em) rotateX(-95deg); transform-origin: 50% 100% -.2em; }
h2.chars.flip-in .ch { animation: ch-flip .85s var(--ease-back) calc(var(--c) * 24ms + 120ms) forwards; }
@keyframes ch-flip { to { opacity: 1; transform: none; } }
h2.chars .ch { transition: color .25s, transform .3s var(--ease-back); }
h2.chars.flip-in .ch:hover { color: var(--yellow-600); }
.section-dark h2.chars.flip-in .ch:hover, .cta-band h2.chars.flip-in .ch:hover { color: var(--yellow); }

/* ---------- Checkerboard tile dissolve on photos ---------- */
.tiles { position: absolute; inset: 0; z-index: 3; display: grid; pointer-events: none; }
.tiles i { background: var(--green); transform: scale(1.02); transition: transform .6s var(--ease-in-out), border-radius .6s; transition-delay: var(--td, 0ms); }
.tiles i.alt { background: var(--green-700); }
.tiles.go i { transform: scale(0) rotate(90deg); border-radius: 30%; }
.js .photo-frame.tiled, .js .reveal.in .photo-frame.tiled { animation: none !important; }
.award-photos { position: relative; }

/* ---------- Cards are dealt onto the table in 3D ---------- */
.js .grid > .reveal.in { animation-name: deal; animation-duration: 1.05s; }
.js .grid > .reveal.in:nth-child(even) { animation-name: deal-r; }
@keyframes deal { from { opacity: 0; transform: perspective(1200px) translate3d(-50px, 110px, -160px) rotateX(32deg) rotateZ(-6deg); } to { opacity: 1; transform: none; } }
@keyframes deal-r { from { opacity: 0; transform: perspective(1200px) translate3d(50px, 110px, -160px) rotateX(32deg) rotateZ(6deg); } to { opacity: 1; transform: none; } }

/* ---------- Split-flap countdown digits ---------- */
.cc-unit b { position: relative; padding: 6px 7px 5px; border-radius: 8px; background: rgba(0, 0, 0, .28); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .25); min-width: 1.5em; text-align: center; transform-origin: 50% 50%; }
.cc-unit b::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(0, 0, 0, .45); }
.cc-unit b.tick { animation: flap .55s var(--ease-out); }
@keyframes flap { 0% { transform: perspective(240px) rotateX(-100deg); filter: brightness(1.6); } 60% { transform: perspective(240px) rotateX(12deg); } 100% { transform: perspective(240px) rotateX(0); filter: none; } }

/* ---------- Ripple board behind the call-to-action bands ---------- */
.cta-band > canvas.field { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; border-radius: inherit; pointer-events: none; }
.cta-band { overflow: hidden; }

/* ---------- Giant photo-filled type (home) ---------- */
.bigtype { background: var(--green-900); padding: clamp(60px, 9vw, 120px) 0; overflow: hidden; position: relative; }
.bigtype::before { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 50% at 50% 50%, rgba(242, 194, 48, .08), transparent 70%); pointer-events: none; }
.bt-row { display: flex; gap: .3em; white-space: nowrap; font-family: var(--font-head); font-weight: 900; text-transform: uppercase; line-height: .9; font-size: clamp(4.2rem, 15vw, 13.5rem); letter-spacing: -.035em; will-change: transform; padding: .04em 0; }
.bt-row + .bt-row { margin-top: .04em; }
.bt-row span { display: inline-block; flex: none; }
.bt-row .o { color: transparent; -webkit-text-stroke: 1.5px rgba(255, 255, 255, .12); }
.bt-row .f { color: transparent; background-size: cover; background-position: 50% 45%; -webkit-background-clip: text; background-clip: text; -webkit-text-stroke: 1px rgba(242, 194, 48, .35); }
.bt-row .g { color: var(--yellow); opacity: .55; font-weight: 400; font-size: .28em; align-self: center; font-family: "Segoe UI Symbol", "Apple Symbols", serif; -webkit-text-stroke: 0; display: inline-block; }
@keyframes spin-slow { to { transform: rotate(360deg); } }
.bt-caption { text-align: center; color: rgba(255, 255, 255, .6); margin-top: 34px; font-size: .95rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; padding: 0 16px; }
.bt-caption b { color: var(--yellow); }

/* ---------- Scroll-driven 3D chessboard (home) ---------- */
.scene { position: relative; background: radial-gradient(70% 60% at 70% 50%, #24493a 0%, var(--green-900) 70%); color: var(--white); }
.scene-pin { padding: 90px 20px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: center; gap: 24px; max-width: var(--max); margin: 0 auto; }
.scene.ready { height: 300vh; }
.scene.ready .scene-pin { position: sticky; top: 0; height: 100vh; overflow: hidden; max-width: none; padding: 0 max(20px, calc((100vw - var(--max)) / 2 + 20px)); }
.scene:not(.ready) .scene-stage, .scene:not(.ready) .scene-hint, .scene:not(.ready) .scene-count { display: none; }
.scene-text .eyebrow { color: var(--yellow); }
.scene-line { font-family: var(--font-head); font-weight: 900; font-size: clamp(2.2rem, 4.6vw, 3.8rem); line-height: 1.05; margin: 0 0 22px; letter-spacing: -.02em; }
.scene-line > span { display: block; }
.scene.ready .scene-line > span { opacity: .16; transform: translateX(-14px); transition: opacity .6s, transform .8s var(--ease-out), color .6s; }
.scene.ready .scene-line > span.lit { opacity: 1; transform: none; }
.scene-line > span:last-child { color: var(--yellow); }
.scene.ready .scene-line > span:last-child:not(.lit) { color: inherit; }
.scene-sub { color: rgba(255, 255, 255, .7); max-width: 420px; margin: 0 0 18px; }
.scene-count { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: .9rem; color: var(--green-900); background: var(--yellow); padding: 7px 14px; border-radius: 999px; font-variant-numeric: tabular-nums; min-width: 9ch; justify-content: center; }
.scene-note { margin-top: 16px; font-size: .9rem; color: var(--sage); }
.scene.ready .scene-note { opacity: 0; transform: translateY(10px); transition: opacity .5s, transform .6s var(--ease-out); }
.scene.ready .scene-note.on { opacity: 1; transform: none; }
.scene-hint { position: absolute; left: 50%; bottom: 26px; translate: -50% 0; font-size: .75rem; letter-spacing: .18em; text-transform: uppercase; color: rgba(255, 255, 255, .55); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.scene-hint::after { content: ""; width: 2px; height: 26px; background: linear-gradient(var(--yellow), transparent); animation: hint 1.6s var(--ease-in-out) infinite; transform-origin: top; }
@keyframes hint { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); } 100% { transform: scaleY(1); opacity: 0; } }
.scene-stage { perspective: 1500px; perspective-origin: 50% 30%; display: grid; place-items: center; height: 100%; }
.scene-board { position: relative; width: min(62vmin, 540px); aspect-ratio: 1; transform-style: preserve-3d; }
/* the 64 squares are a single background (one element instead of 64) */
.sb-squares { position: absolute; inset: 0; border-radius: 6px;
  background: conic-gradient(#3f6b52 25%, #e9dfc4 0 50%, #3f6b52 0 75%, #e9dfc4 0) 0 0 / 25% 25%;
  box-shadow: 0 0 0 10px #2c4d3a, 0 0 0 13px rgba(242, 194, 48, .7), 0 70px 90px -30px rgba(0, 0, 0, .75); }
/* pieces: js/fx.js writes each transform directly (and only when it changes) */
.sp { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; transform-style: preserve-3d; opacity: 0; }
.sp .sh { position: absolute; left: 18%; top: 18%; width: 64%; height: 64%; border-radius: 50%; background: radial-gradient(rgba(0, 0, 0, .5), transparent 70%); opacity: 0; }
.sp i {
  position: absolute; left: 0; right: 0; bottom: 50%; text-align: center; font-style: normal; line-height: 1;
  font-size: calc(var(--cell, 60px) * .95); transform-origin: 50% 100%;
  font-family: "Segoe UI Symbol", "Apple Symbols", "DejaVu Sans", serif;
}
.sp.w i { color: #fff; text-shadow: 0 0 1px #000, 0 0 1px #000, 0 3px 4px rgba(0, 0, 0, .45); }
.sp.b i { color: #121212; text-shadow: 0 0 1px rgba(255, 255, 255, .55), 0 3px 4px rgba(0, 0, 0, .4); }
/* phones and low-power devices: same look, cheaper shadows */
.scene.lite .sb-squares { box-shadow: 0 0 0 8px #2c4d3a, 0 0 0 10px rgba(242, 194, 48, .7), 0 34px 40px -22px rgba(0, 0, 0, .7); }
.scene.lite .sp.w i { text-shadow: 0 0 1px #000, 0 2px 2px rgba(0, 0, 0, .45); }
.scene.lite .sp.b i { text-shadow: 0 0 1px rgba(255, 255, 255, .55), 0 2px 2px rgba(0, 0, 0, .35); }
.scene.lite .sp .sh { display: none; } /* 32 fewer layers for the GPU to sort */
/* reduced motion: the finished position as a still picture, no scroll-pinning */
.scene.static:not(.ready) .scene-stage { display: grid; height: auto; padding: 30px 0; }
.scene.static .scene-hint { display: none; }
.scene.static:not(.ready) .scene-count { display: inline-flex; }
@media (max-width: 860px) {
  .scene.ready { height: 260vh; }
  .scene.ready .scene-pin { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-content: center; padding-top: 80px; gap: 0; }
  .scene-line { font-size: clamp(1.8rem, 8vw, 2.4rem); margin-bottom: 12px; }
  .scene-sub { display: none; }
  .scene-board { width: min(70vw, 42vh); }
  .scene-hint { bottom: 14px; }
}

/* ---------- Footer revealed from underneath ---------- */
html.footer-reveal main, html.footer-reveal .checker-strip { position: relative; z-index: 1; }
html.footer-reveal main { background: var(--cream); box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .45); }
html.footer-reveal .site-footer { position: sticky; bottom: 0; z-index: 0; }
html.footer-reveal .site-footer .container { transform-origin: 50% 100%; will-change: transform, opacity; }

/* ---------- Lightbox: drag to swipe + slow zoom ---------- */
.lb-stage img { touch-action: none; user-select: none; -webkit-user-drag: none; cursor: grab; transition: opacity .25s, translate .35s var(--ease-out), rotate .35s var(--ease-out); }
.lb-stage img.dragging { cursor: grabbing; transition: none; }
.lb-stage img.a-zoom { animation: lb-zoom .55s var(--ease-out), kb 9s ease-out .55s forwards; }
.lb-stage img.a-next { animation: lb-next .5s var(--ease-out), kb 9s ease-out .5s forwards; }
.lb-stage img.a-prev { animation: lb-prev .5s var(--ease-out), kb 9s ease-out .5s forwards; }
@keyframes kb { from { scale: 1; } to { scale: 1.06; } }

/* ---------- Piece burst particles ---------- */
.burst { position: fixed; inset: 0; z-index: 9996; pointer-events: none; overflow: hidden; }
.burst span { position: absolute; left: 0; top: 0; font-size: 22px; line-height: 1; will-change: transform, opacity; font-family: "Segoe UI Symbol", "Apple Symbols", serif; text-shadow: 0 2px 6px rgba(0, 0, 0, .3); }

/* ---------- Odometer numbers ---------- */
.odo { display: inline-block; height: 1em; overflow: hidden; vertical-align: top; line-height: 1; }
.odo-col { display: flex; flex-direction: column; transition: transform 2.2s var(--ease-out); transition-delay: var(--od, 0ms); }
.odo-col span { display: block; height: 1em; text-align: center; }
.stat b.odo-wrap { display: flex; justify-content: center; }

/* ---------- Sliding nav pill (desktop) ---------- */
.nav-pill { display: none; }
@media (min-width: 861px) {
  .nav-links { position: relative; }
  .nav-pill { display: block; position: absolute; top: 50%; left: 0; height: 38px; translate: 0 -50%; border-radius: 999px; background: rgba(255, 255, 255, .1); pointer-events: none; opacity: 0; z-index: 0;
    transition: transform .45s var(--ease-out), width .45s var(--ease-out), opacity .3s; }
  .nav-pill.on { opacity: 1; }
  .nav-links li { position: relative; z-index: 1; }
  .nav-links .nav-pill { position: absolute; z-index: 0; }
  .nav-links.has-pill a:not(.btn):hover { background: transparent; }
}

/* ---------- Timeline: reached events ---------- */
.timeline .past-event.reached::before { background: var(--yellow); box-shadow: 0 0 0 4px var(--cream), 0 0 0 9px rgba(242, 194, 48, .35); }
.tl-knight.hop { animation: knight-land .5s var(--ease-back); }
@keyframes knight-land { 0% { scale: 1.35; } 100% { scale: 1; } }
.timeline .year-label { will-change: transform; }

/* ---------- Scroll-velocity skew ---------- */
.mosaic { transform: skewY(var(--skew, 0deg)); transition: transform .4s var(--ease-out); }

/* ---------- Scramble text ---------- */
.scrambling { font-variant-numeric: tabular-nums; }
.nav-links a:not(.btn), .site-footer ul a { display: inline-block; }

@media (prefers-reduced-motion: reduce) {
  .hero-lens, .tiles, .burst, canvas.field, .nav-pill { display: none !important; }
  .bt-row { transform: none !important; }
  .mosaic { transform: none !important; }
}
/* reduced motion on phones: text above, still board below */
@media (max-width: 860px) {
  .scene.static .scene-pin { grid-template-columns: minmax(0, 1fr); padding: 64px 16px; gap: 8px; }
  .scene.static .scene-line { font-size: clamp(1.8rem, 8vw, 2.4rem); }
  .scene.static .scene-board { width: min(62vw, 320px); }
}
