/* BootGhost cartoon site: the effects layer. It adds motion on top of cartoon.css and changes no layout.
   Remove this file and fx.js, and the site looks and works as before.
   Parts: channel change between pages, TV knobs, static, depth on the glass, scroll reveals, ticket and bill feedback. */

:root {
  --fx-out: cubic-bezier(.23, 1, .32, 1);      /* strong ease-out: entrances and feedback */
  --fx-spring: cubic-bezier(.3, 1.5, .5, 1);   /* rubber-hose overshoot: things that pop */
  --glove: url(assets/glove-point.png) 13 1, pointer;
}

/* ---------- a white glove for a pointer ---------- */
a, button, summary, select, label[for], .lineup label, input[type=range], .rig { cursor: var(--glove); }
a:active, button:active, summary:active, label[for]:active { cursor: url(assets/glove-fist.png) 14 6, pointer; }

/* ---------- the marquee bulbs chase ---------- */
.marquee::after { animation: fx-bulbs 1s steps(1) infinite; }
@keyframes fx-bulbs { 50% { background-position: 11px 0; } }

/* ---------- the two dials on the set are real ---------- */
.knob {
  position: absolute; z-index: 2; bottom: clamp(12px, 1.6vw, 20px); right: clamp(12px, 2.2vw, 28px);
  width: clamp(28px, 3.6vw, 44px); aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%; background: none;
  transition: scale .12s var(--fx-out);
}
.knob--bw { right: calc(clamp(12px, 2.2vw, 28px) + clamp(40px, 5vw, 60px)); }
.knob::before { content: ""; position: absolute; inset: -8px; border-radius: 50%; } /* a bigger target for thumbs */
/* only the notch turns: a turned button box would reach past the edge of a phone screen */
.knob::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: linear-gradient(var(--ink) 0 0) 50% 9% / 3px 27% no-repeat; rotate: var(--turn, -35deg); transition: rotate .4s var(--fx-spring); }
.knob:active { scale: .94; }
.knob[aria-pressed=true] { --turn: 55deg; }
.knob.hint::after { animation: fx-hint 1.1s var(--fx-out) 2; }
@keyframes fx-hint { 30% { rotate: -5deg; } 60% { rotate: -55deg; } }

/* black and white picture: the left dial */
html.bw .notice, html.bw .marquee, html.bw main, html.bw footer { filter: grayscale(1) sepia(.22) contrast(1.06); }

/* static and a vertical roll when a dial turns */
.snow {
  position: absolute; inset: 0; z-index: 6; pointer-events: none; border-radius: inherit; opacity: 0;
  background: #161b18 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .92 0 0 0 0 .96 0 0 0 0 .9 0 0 0 7 -3.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E") 0 0 / 220px 220px;
}
.screen.static .snow { animation: fx-snow .44s steps(7) both, fx-snow-move .09s steps(1) infinite; }
.screen.static > .wrap, .screen.static > .chorus { animation: fx-vhold .44s steps(6) both; }
@keyframes fx-snow { 0% { opacity: .96; } 60% { opacity: .75; } 100% { opacity: 0; } }
@keyframes fx-snow-move { 0% { background-position: 0 0; } 33% { background-position: -70px 40px; } 66% { background-position: 50px -90px; } }
@keyframes fx-vhold { 0% { transform: translateY(-34%) skewX(3deg); } 35% { transform: translateY(20%) skewX(-2deg); } 65% { transform: translateY(-7%); } 100% { transform: none; } }

/* a reflection on the glass that moves against the pointer */
.glare { position: absolute; inset: -25%; z-index: 5; pointer-events: none; background: radial-gradient(ellipse 26% 20% at 62% 30%, rgb(255 255 255 / .12), transparent 70%); }

/* ---------- channel change: the tube switches off and on when you go to another page ---------- */
@view-transition { navigation: auto; }
.screen { view-transition-name: tube; }
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .2s; }
  ::view-transition-group(tube) { background: #0c100e; border-radius: 40px; overflow: clip; }
  ::view-transition-old(tube) { animation: fx-crt-off .22s var(--fx-out) both; }
  ::view-transition-new(tube) { animation: fx-crt-on .4s var(--fx-out) .2s both; }
}
@keyframes fx-crt-off { 60% { transform: scale(1, .006); filter: brightness(3); opacity: 1; } 100% { transform: scale(.02, .006); filter: brightness(6); opacity: 0; } }
@keyframes fx-crt-on { 0% { transform: scale(1, .006); filter: brightness(4); opacity: 1; } 35% { transform: scale(1, .006); filter: brightness(3); } 100% { transform: none; filter: none; } }

/* ---------- numbers that change get a short roll ---------- */
#price, #from { display: inline-block; }

/* ---------- the ticket gets punched before it leaves ---------- */
.punch { position: absolute; right: 12px; top: 10px; width: 22px; height: 22px; border-radius: 50%; background: var(--mint); border: var(--line); opacity: 0; pointer-events: none; }
.punch.on { opacity: 1; animation: fx-thump .22s var(--fx-spring) both; }

/* ---------- effects that need motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* scroll reveals: fx.js adds .rv to the targets and .in when one comes on screen */
  .fx .rv:not(.act) { opacity: 0; }
  .fx .rv.in:not(.act) { animation: fx-rise .5s var(--fx-out) calc(var(--i, 0) * 70ms) both; }
  .fx .frame.rv.in { animation: fx-slide .6s var(--fx-out) calc(var(--i, 0) * 90ms) both; }

  /* a cast member takes the stage: the drawing pops, the words rise, the dotted leader runs to the price, the price lands */
  .fx .act.rv:not(.in) > * { opacity: 0; }
  .fx .act.rv .leader::after { clip-path: inset(-6px 100% -6px 0); }
  .fx .act.rv.in .act__img { animation: fx-pop .55s var(--fx-spring) both; }
  .fx .act.rv.in > div { animation: fx-rise .45s var(--fx-out) .08s both; }
  .fx .act.rv.in > .btn { animation: fx-rise .45s var(--fx-out) .18s both; }
  .fx .act.rv.in .leader::after { animation: fx-draw .55s var(--fx-out) .3s both; }
  .fx .act.rv.in .leader b { display: inline-block; animation: fx-thump .32s var(--fx-spring) .72s both; }

  /* section titles arrive word by word, like hand-lettered cards */
  .fx .words .wd { display: inline-block; }
  .fx .words:not(.in) .wd { opacity: 0; }
  .fx .words.in .wd { animation: fx-word .5s var(--fx-spring) calc(var(--i, 0) * 60ms) both; }

  /* the film runs through the gate while the strip crosses the screen */
  @supports (animation-timeline: view()) {
    .fx .film { animation: fx-sprocket linear both; animation-timeline: view(); }
  }

  /* an answer comes up like a silent-film title card */
  .faq details[open] > p { animation: fx-card .36s steps(5) both; }

  /* name search: the names drop onto the board in order, and each answer is stamped */
  .shelf li:has(.chip-s[data-s=checking]) { animation: fx-rise .32s var(--fx-out) both; }
  .shelf li:nth-child(2):has(.chip-s[data-s=checking]) { animation-delay: 40ms; } .shelf li:nth-child(3):has(.chip-s[data-s=checking]) { animation-delay: 80ms; }
  .shelf li:nth-child(4):has(.chip-s[data-s=checking]) { animation-delay: 120ms; } .shelf li:nth-child(5):has(.chip-s[data-s=checking]) { animation-delay: 160ms; }
  .shelf li:nth-child(n+6):has(.chip-s[data-s=checking]) { animation-delay: 200ms; }
  .chip-s[data-s=free], .chip-s[data-s=taken] { animation: fx-thump .24s var(--fx-spring) both; }
  .buy-line { animation: fx-rise .3s var(--fx-out) both; }

  @media (hover: hover) and (pointer: fine) {
    .act:not(.act--row) .act__img { transition: transform .25s var(--fx-spring); transform-origin: 50% 100%; }
    .act:not(.act--row):hover .act__img { transform: scale(1.08) rotate(-3deg); }
    .wordmark img.logo { transition: transform .25s var(--fx-spring); }
    .wordmark:hover img.logo { transform: rotate(-3deg) scale(1.04); }
  }
}
@keyframes fx-rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes fx-slide { from { opacity: 0; transform: translateX(70px) rotate(2.5deg); } }
@keyframes fx-pop { from { opacity: 0; transform: translateY(16%) scale(.8) rotate(-7deg); } }
@keyframes fx-draw { to { clip-path: inset(-6px 0 -6px 0); } }
@keyframes fx-thump { from { opacity: 0; transform: scale(1.7); } }
@keyframes fx-word { from { opacity: 0; transform: translateY(.45em) rotate(-5deg) scale(.9); } }
@keyframes fx-sprocket { to { background-position: -240px 2px, -240px calc(100% - 2px); } }
@keyframes fx-card { 0% { opacity: 0; transform: translateY(6px); } 40% { opacity: .9; } 60% { opacity: .45; } 100% { opacity: 1; transform: none; } }
@media print { .rv, .rv > *, .wd { opacity: 1 !important; } }
