/* Kahnec motion system. One vocabulary for the whole page:
   rise (text arrives), settle (work lands), wipe (media is revealed), spring (things let go).
   Everything spatial sits inside prefers-reduced-motion:no-preference, so the reduced-motion page is static.
   Only transform-family properties, opacity and clip-path move. */
:root{
  --ease-out:cubic-bezier(.16,1,.3,1);
  --ease-in-out:cubic-bezier(.65,0,.35,1);
  --ease-spring:cubic-bezier(.34,1.4,.64,1);
  --dur-micro:.18s;
  --dur-swap:.28s;
  --dur-enter:.7s;
  --stagger:70ms;
}
@supports (transition-timing-function:linear(0,1)){
  :root{--ease-spring:linear(0,.051 3%,.176 6%,.336 9%,.504 12%,.709 16%,.871 20%,.982 24%,1.048 28%,1.078 32%,1.082 36%,1.072 40%,1.049 45%,1.027 50%,1.007 56%,.996 62%,.993 70%,.995 80%,.999 90%,1)}
}

/* Gallery depth. Nearer work travels further when the pointer or a drag moves the table. */
.project-3{--depth:1.3;--order:0;--from-y:46px}
.project-0{--depth:.85;--order:1;--from-x:-34px;--from-y:26px;--from-r:-3deg}
.project-6{--depth:.8;--order:2;--from-y:26px;--from-r:-2deg}
.project-1{--depth:.6;--order:2;--from-x:38px;--from-y:22px;--from-r:4deg}
.project-2{--depth:1.1;--order:3;--from-x:-40px;--from-y:34px;--from-r:-4deg}
.project-4{--depth:.95;--order:4;--from-x:-22px;--from-y:48px;--from-r:3deg}
.project-5{--depth:.7;--order:5;--from-x:30px;--from-y:48px;--from-r:-3deg}
.gallery .project:hover,.gallery .project:focus-visible{z-index:2}

/* Colour-only feedback stays on for everyone. */
.primary{transition:background var(--dur-micro),translate .25s var(--ease-out),box-shadow .25s var(--ease-out),scale var(--dur-micro)}
nav a,.text-link,.capability-cta,.capability-footer a,footer a{transition:color var(--dur-micro)}
.open-label,.play,.capability-film>span,.website-open,.ads-media>span{transition:background var(--dur-micro),color var(--dur-micro),translate .25s var(--ease-out)}
.project:hover .open-label,.project:focus-visible .open-label,.film:hover .play,.film:focus-visible .play,.capability-film:hover>span,.capability-film:focus-visible>span,.website-composition:hover .website-open,.website-composition:focus-visible .website-open,.ads-media:hover>span,.ads-media:focus-visible>span{background:var(--ink);color:var(--paper)}
.filters button{transition:color var(--dur-micro),border-color var(--dur-micro)}
.filters button:hover{color:var(--ink)}
.view-switch button{transition:background var(--dur-micro),color var(--dur-micro)}
.view-switch button:hover:not([aria-pressed=true]){background:#ece6f3}
.player-header button{transition:background var(--dur-micro),color var(--dur-micro),border-color var(--dur-micro)}
.player-header button:hover{background:var(--ink);color:var(--paper);border-color:var(--ink)}
.film-image img{transition:transform .5s var(--ease-out),scale 1.3s var(--ease-out)}

@media (prefers-reduced-motion:no-preference){
  /* 1. Hero choreography: the words arrive first, then the work settles onto the table.
     Pure CSS with a backwards fill, so it needs no script and always ends in the normal page. */
  @keyframes rise-in{from{opacity:0;transform:translateY(18px)}}
  @keyframes lift-in{from{transform:translateY(20px)}}
  @keyframes fade-in{from{opacity:0}}
  @keyframes settle-in{from{opacity:0;transform:translate(var(--from-x,0px),var(--from-y,40px)) rotate(var(--from-r,0deg)) scale(.94)}}
  /* The headline is the message and the largest text on the page, so it is painted at once and only lifts into place.
     It is never invisible, which also keeps it as the first large paint. The supporting lines fade up after it. */
  .intro h1{animation:lift-in .7s var(--ease-out) var(--opening,0s) backwards}
  .intro>.eyebrow,.intro-copy,.intro-detail,.intro>.primary,.person{animation:rise-in .64s var(--ease-out) backwards;animation-delay:calc(var(--opening,0s) + var(--order,0)*var(--stagger))}
  .intro-copy{--order:2}.intro-detail{--order:3}.intro>.primary{--order:4}.person{--order:5}
  .work-heading{animation:fade-in .6s ease-out calc(var(--opening,0s) + .26s) backwards}
  .stage > .project {
    --project-entrance: settle-in .76s var(--ease-out) calc(var(--opening,0s) + .3s + var(--order,0)*var(--stagger)) backwards;
    animation: var(--project-entrance);
  }
  .gallery-controls{animation:fade-in .6s ease-out calc(var(--opening,0s) + .85s) backwards}

  /* 2. Living gallery. Pointer follow is eased; a drag tracks directly; release springs home. */
  .project{transition:translate .5s var(--ease-out)}
  .stage.dragging .project{transition:none}
  .stage.settling .project{transition:translate .9s var(--ease-spring)}

  /* The whole card floats, including its caption and hit area. Pointer and drag still own translate. */
  @supports (animation-composition: add) {
    .gallery .stage {
      --float-width: 4.5px;
      --float-height: 9px;
      --float-angle: 1.35deg;
    }
    .gallery .stage > .project {
      --float-x: calc(var(--float-width) * var(--depth, 1) * var(--float-direction, 1));
      --float-y: calc(var(--float-height) * var(--depth, 1));
      --float-duration: calc(3.5s + 1.8s * var(--depth, 1));
      --float-delay: calc(-1.65s * var(--order, 0) - 2s * var(--depth, 1));
      --project-float: project-float var(--float-duration) ease-in-out var(--float-delay) infinite alternate var(--float-state, var(--ambient-state, paused));
      animation: var(--project-entrance), var(--project-float);
      animation-composition: replace, add;
    }
    .gallery .project:nth-child(even) { --float-direction: -1; }
    .gallery :is(.project-0, .project-2, .project-5) {
      --float-tilt: calc(var(--float-angle) * var(--float-direction, 1));
    }
    .gallery .stage:is(.dragging, [data-offscreen]),
    .gallery .project:is(:focus-visible, :active) { --float-state: paused; }
    @media (hover: hover) and (pointer: fine) {
      .gallery .project:hover { --float-state: paused; }
    }
    @media (max-width: 760px) {
      .gallery .stage { --float-width: 1.6px; --float-height: 3.5px; --float-angle: .6deg; }
    }
    @keyframes project-float {
      from { transform: translate(calc(-1 * var(--float-x)), var(--float-y)) rotate(calc(-1 * var(--float-tilt, 0deg))); }
      to { transform: translate(var(--float-x), calc(-1 * var(--float-y))) rotate(var(--float-tilt, 0deg)); }
    }
  }

  /* Scroll displacement adds to the entrance and idle motion on its own timeline. */
  @supports (animation-timeline: view()) and (animation-range: entry) and (animation-composition: add) {
    .gallery .stage {
      view-timeline: --gallery-scroll block;
      --gallery-travel: 72px;
    }
    .gallery .stage > .project {
      animation: var(--project-entrance), var(--project-float), gallery-drift auto linear both;
      animation-timeline: auto, auto, --gallery-scroll;
      animation-range: normal, normal, entry 72% exit 82%;
      animation-composition: replace, add, add;
    }
    @keyframes gallery-drift {
      from { transform: translateY(0); }
      to { transform: translateY(calc((1 - var(--depth, 1)) * var(--gallery-travel))); }
    }
    @media (max-width: 760px) {
      .gallery .stage { --gallery-travel: 18px; }
    }
  }

  /* 5. Details: buttons lift slightly, and press back down. */
  .primary:active{scale:.985;box-shadow:none}
  .film:active .film-image img{transform:scale(1.008)}

  /* 4. Scroll rhythm. The hidden state applies only once the page script has confirmed it can reveal. */
  [data-reveal]{transition:opacity var(--dur-enter) var(--ease-out) var(--reveal-delay,0ms),translate var(--dur-enter) var(--ease-out) var(--reveal-delay,0ms)}
  .motion [data-reveal]:not([data-reveal=media],[data-reveal=rail],.is-in){opacity:0;translate:0 22px}

  /* Media: the picture is wiped in from its lower edge while it eases back to size; the caption follows. */
  [data-reveal=media] .reveal-mask{transition:clip-path .9s var(--ease-in-out) var(--reveal-delay,0ms)}
  [data-reveal=media]>:not(.film,.reveal-mask,figure){transition:opacity .6s var(--ease-out) calc(var(--reveal-delay,0ms) + .28s),translate .6s var(--ease-out) calc(var(--reveal-delay,0ms) + .28s)}
  .motion [data-reveal=media]:not(.is-in) .reveal-mask{clip-path:inset(100% 0 0 0)}
  .motion [data-reveal=media]:not(.is-in) .reveal-mask img{scale:1.14}
  .motion [data-reveal=media]:not(.is-in)>:not(.film,.reveal-mask,figure){opacity:0;translate:0 14px}

  /* Rail: the line is drawn once, and each step arrives along it. */
  [data-reveal=rail]::after{transition:scale 1.1s var(--ease-in-out) .1s}
  [data-reveal=rail]>*{transition:opacity .6s var(--ease-out),translate .6s var(--ease-out)}
  [data-reveal=rail]>:nth-child(2){transition-delay:.12s}[data-reveal=rail]>:nth-child(3){transition-delay:.24s}[data-reveal=rail]>:nth-child(4){transition-delay:.36s}
  .motion [data-reveal=rail]:not(.is-in)::after{scale:0 1}
  .motion [data-reveal=rail]:not(.is-in)>*{opacity:0;translate:0 16px}

  /* The film player opens with a short lift. It closes at once, because the film is unloaded on close. */
  #video-dialog[open]{transition:opacity .26s var(--ease-out),scale .26s var(--ease-out)}
  @starting-style{#video-dialog[open]{opacity:0;scale:.97}}
}

/* Opening: the Kahnec logo on cream, once per session on a plain homepage visit. The mark resolves, the lettering is
   drawn out from it, then the sheet lifts with a violet edge and the hero entrance plays underneath as one movement.
   The page is fully rendered below it. A click, tap or Escape ends it; CSS alone hides it after 1.25s. */
/* When it ends by itself only the overlay is retired; the entrance timing is left alone so nothing jumps. */
.opening-mark,html.intro-play-over .opening-mark{display:none!important}
@media (prefers-reduced-motion:no-preference){
  @keyframes opening-lift{to{translate:0 -100%;visibility:hidden}}
  @keyframes opening-logo{0%{opacity:0;scale:.9;clip-path:inset(0 69% 0 0)}34%{opacity:1;scale:1;clip-path:inset(0 69% 0 0)}82%,100%{opacity:1;scale:1;clip-path:inset(0 0 0 0)}}
  html.intro-play{--opening:.72s}
  html.intro-play:not(.intro-play-over) .opening-mark{display:block!important;position:fixed;inset:0;z-index:20;background:var(--violet);cursor:pointer;animation:opening-lift .42s var(--ease-in-out) .82s forwards}
  html.intro-play .opening-sheet{position:absolute;inset:0;display:grid;place-items:center;background:var(--paper);animation:opening-lift .44s var(--ease-in-out) .7s forwards}
  /* The source file has wide empty margins; the box is trimmed to the artwork itself, with nothing redrawn. */
  html.intro-play .opening-sheet img{width:min(380px,72vw);height:auto;aspect-ratio:10/3;object-fit:cover;object-position:50% 53%;animation:opening-logo .7s var(--ease-out) both}
}

/* Hover movement needs a pointer that can hover, and room for the floating layout. */
@media (prefers-reduced-motion:no-preference) and (hover:hover){
  .primary:hover{translate:0 -2px;box-shadow:0 12px 24px #57408938}
  .film:hover .play,.capability-film:hover>span,.website-composition:hover .website-open,.ads-media:hover>span{translate:0 -2px}
}
@media (prefers-reduced-motion:no-preference) and (hover:hover) and (pointer:fine) and (min-width:761px){
  .gallery .picture{transform:perspective(900px) rotateX(var(--tx,0deg)) rotateY(var(--ty,0deg));transition:rotate .4s var(--ease-out),translate .4s var(--ease-out),scale .4s var(--ease-out),box-shadow .4s var(--ease-out),transform .25s ease-out}
  .gallery .project:hover .picture{rotate:0deg;translate:0 -8px;scale:1.025;box-shadow:0 22px 38px #241e2e26}
}
@media (min-width:761px){
  .gallery .project:focus-visible .picture{rotate:0deg;translate:0 -6px}
}
/* Small screens use a grid: a simple rise, no sideways travel. */
@media (max-width:760px){
  .stage>.project{--from-x:0px;--from-y:22px;--from-r:0deg}
}
@media print{
  .motion [data-reveal],.motion [data-reveal]>*,.motion .reveal-mask,.motion .reveal-mask img{opacity:1!important;translate:none!important;scale:none!important;clip-path:none!important}
}
