/* fx.css · layout/expanding-panels, tall photo panels widen under the pointer or focus · owner: Lizzy East · all rights reserved */

/* No width ever animates. Each panel is a link that keeps its own equal slot (that slot
   is what the pointer and the keyboard land on), while its photograph is a layer the
   size of the whole row, cut to a slice with clip-path. Pointing at or focusing a
   panel moves every slice's edges: the open one takes --fx-open of the row, the rest
   share what is left, and each photo slides to stay centred in its slice. Pure CSS,
   so it works without script; with motion off it changes at once; without :has() the
   panels simply stay equal. On phones the slices are horizontal bands. */
[data-fx~="layout/expanding-panels"] {
  --fx-a: 0;
  --fx-on: 0;
  --fx-r: calc((1 - var(--fx-open, 0.4)) / (var(--fx-panels, 5) - 1));
  position: relative;
  display: flex;
  height: var(--fx-panels-height, 36rem);
}
[data-fx~="layout/expanding-panels"] > :nth-child(1) { --fx-n: 0; }
[data-fx~="layout/expanding-panels"] > :nth-child(2) { --fx-n: 1; }
[data-fx~="layout/expanding-panels"] > :nth-child(3) { --fx-n: 2; }
[data-fx~="layout/expanding-panels"] > :nth-child(4) { --fx-n: 3; }
[data-fx~="layout/expanding-panels"] > :nth-child(5) { --fx-n: 4; }
[data-fx~="layout/expanding-panels"] > :nth-child(6) { --fx-n: 5; }
[data-fx~="layout/expanding-panels"] > :nth-child(7) { --fx-n: 6; }
[data-fx~="layout/expanding-panels"] > :nth-child(8) { --fx-n: 7; }

/* Which panel is open: keyboard focus, then (on a fine pointer) the pointer. */
[data-fx~="layout/expanding-panels"]:has(> :nth-child(1):focus-within) { --fx-on: 1; --fx-a: 0; }
[data-fx~="layout/expanding-panels"]:has(> :nth-child(2):focus-within) { --fx-on: 1; --fx-a: 1; }
[data-fx~="layout/expanding-panels"]:has(> :nth-child(3):focus-within) { --fx-on: 1; --fx-a: 2; }
[data-fx~="layout/expanding-panels"]:has(> :nth-child(4):focus-within) { --fx-on: 1; --fx-a: 3; }
[data-fx~="layout/expanding-panels"]:has(> :nth-child(5):focus-within) { --fx-on: 1; --fx-a: 4; }
[data-fx~="layout/expanding-panels"]:has(> :nth-child(6):focus-within) { --fx-on: 1; --fx-a: 5; }
[data-fx~="layout/expanding-panels"]:has(> :nth-child(7):focus-within) { --fx-on: 1; --fx-a: 6; }
[data-fx~="layout/expanding-panels"]:has(> :nth-child(8):focus-within) { --fx-on: 1; --fx-a: 7; }
@media (hover: hover) and (pointer: fine) {
  [data-fx~="layout/expanding-panels"]:has(> :nth-child(1):hover) { --fx-on: 1; --fx-a: 0; }
  [data-fx~="layout/expanding-panels"]:has(> :nth-child(2):hover) { --fx-on: 1; --fx-a: 1; }
  [data-fx~="layout/expanding-panels"]:has(> :nth-child(3):hover) { --fx-on: 1; --fx-a: 2; }
  [data-fx~="layout/expanding-panels"]:has(> :nth-child(4):hover) { --fx-on: 1; --fx-a: 3; }
  [data-fx~="layout/expanding-panels"]:has(> :nth-child(5):hover) { --fx-on: 1; --fx-a: 4; }
  [data-fx~="layout/expanding-panels"]:has(> :nth-child(6):hover) { --fx-on: 1; --fx-a: 5; }
  [data-fx~="layout/expanding-panels"]:has(> :nth-child(7):hover) { --fx-on: 1; --fx-a: 6; }
  [data-fx~="layout/expanding-panels"]:has(> :nth-child(8):hover) { --fx-on: 1; --fx-a: 7; }
}

/* Each panel's slice: where it starts (--fx-s) and how wide it is (--fx-w), as shares
   of the row. At rest every slice is 1/--fx-panels. --fx-eq is 1 for the open one. */
[data-fx~="layout/expanding-panels"] > [data-fx-panel] {
  --fx-gt: clamp(0, var(--fx-n) - var(--fx-a), 1);
  --fx-eq: calc(var(--fx-on) * (1 - var(--fx-gt) - clamp(0, var(--fx-a) - var(--fx-n), 1)));
  --fx-s: calc((1 - var(--fx-on)) * var(--fx-n) / var(--fx-panels, 5) + var(--fx-on) * (var(--fx-r) * var(--fx-n) + (var(--fx-open, 0.4) - var(--fx-r)) * var(--fx-gt)));
  --fx-w: calc((1 - var(--fx-on)) / var(--fx-panels, 5) + var(--fx-r) * var(--fx-on) + (var(--fx-open, 0.4) - var(--fx-r)) * var(--fx-eq));
  --fx-edge: 0px;
  display: block;
  flex: 1 1 0;
  min-width: 0;
  color: var(--fx-panels-ink, #ffffff);
  text-decoration: none;
}
/* The keyboard's ring: a frame of --fx-panels-focus round the open slice. */
[data-fx~="layout/expanding-panels"] > [data-fx-panel]::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--fx-panels-radius, 4px);
  background: var(--fx-panels-focus, #2340ff);
  clip-path: inset(0 calc((1 - var(--fx-s) - var(--fx-w)) * 100% + var(--fx-panels-gap, 4px)) 0 calc(var(--fx-s) * 100% + var(--fx-panels-gap, 4px)) round var(--fx-panels-radius, 4px));
  opacity: 0;
  pointer-events: none;
}
[data-fx~="layout/expanding-panels"] > [data-fx-panel]:focus-visible { --fx-edge: 5px; outline: none; color: var(--fx-panels-focus-ink, #cfff3e); }
[data-fx~="layout/expanding-panels"] > [data-fx-panel]:focus-visible::before { opacity: 1; }

[data-fx~="layout/expanding-panels"] [data-fx-photo] {
  position: absolute;
  inset: 0;
  overflow: clip;
  pointer-events: none;
  background: var(--fx-panels-bg, #111117);
  clip-path: inset(var(--fx-edge) calc((1 - var(--fx-s) - var(--fx-w)) * 100% + var(--fx-panels-gap, 4px) + var(--fx-edge)) var(--fx-edge) calc(var(--fx-s) * 100% + var(--fx-panels-gap, 4px) + var(--fx-edge)) round var(--fx-panels-radius, 4px));
}
/* A scrim, so the caption reads on any photograph. */
[data-fx~="layout/expanding-panels"] [data-fx-photo]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgb(17 17 23 / 0.72), rgb(17 17 23 / 0) 55%);
}
/* The photo is as wide as the open slice and slides to stay centred in its own. */
[data-fx~="layout/expanding-panels"] [data-fx-photo] img {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--fx-open, 0.4) * 100%);
  max-width: none;
  height: 100%;
  object-fit: cover;
  translate: calc((var(--fx-s) + var(--fx-w) / 2 - var(--fx-open, 0.4) / 2) / var(--fx-open, 0.4) * 100%) 0;
  scale: calc(1 + (var(--fx-panels-zoom, 1.08) - 1) * var(--fx-eq));
}
/* The caption sits in the narrowest a slice ever gets, at the slice's left edge. */
[data-fx~="layout/expanding-panels"] [data-fx-caption] {
  position: absolute;
  left: 0;
  bottom: 0;
  display: grid;
  gap: 0.35rem;
  width: calc(var(--fx-r) * 100%);
  padding: 1.25rem calc(var(--fx-panels-gap, 4px) + 1rem);
  translate: calc(var(--fx-s) / var(--fx-r) * 100%) 0;
  pointer-events: none;
}
[data-fx~="layout/expanding-panels"] [data-fx-caption] > * { margin: 0; }
[data-fx~="layout/expanding-panels"] [data-fx-caption] > [aria-hidden="true"] {
  opacity: var(--fx-eq);
  translate: calc((1 - var(--fx-eq)) * -0.6rem) 0;
}

@media (max-width: 760px) {
  [data-fx~="layout/expanding-panels"] { flex-direction: column; height: var(--fx-panels-height-sm, 34rem); }
  [data-fx~="layout/expanding-panels"] > [data-fx-panel]::before {
    clip-path: inset(calc(var(--fx-s) * 100% + var(--fx-panels-gap, 4px)) 0 calc((1 - var(--fx-s) - var(--fx-w)) * 100% + var(--fx-panels-gap, 4px)) 0 round var(--fx-panels-radius, 4px));
  }
  [data-fx~="layout/expanding-panels"] [data-fx-photo] {
    clip-path: inset(calc(var(--fx-s) * 100% + var(--fx-panels-gap, 4px) + var(--fx-edge)) var(--fx-edge) calc((1 - var(--fx-s) - var(--fx-w)) * 100% + var(--fx-panels-gap, 4px) + var(--fx-edge)) var(--fx-edge) round var(--fx-panels-radius, 4px));
  }
  [data-fx~="layout/expanding-panels"] [data-fx-photo] img {
    width: 100%;
    height: calc(var(--fx-open, 0.4) * 100%);
    translate: 0 calc((var(--fx-s) + var(--fx-w) / 2 - var(--fx-open, 0.4) / 2) / var(--fx-open, 0.4) * 100%);
  }
  [data-fx~="layout/expanding-panels"] [data-fx-caption] {
    top: 0;
    bottom: auto;
    align-content: end;
    width: 100%;
    height: calc(var(--fx-r) * 100%);
    padding: 0.75rem 1rem calc(var(--fx-panels-gap, 4px) + 0.75rem);
    translate: 0 calc(var(--fx-s) / var(--fx-r) * 100%);
    text-shadow: 0 1px 10px rgb(17 17 23 / 0.6);
  }
  /* A band is short: the photo is dimmed evenly, and the decorative arrow line rests. */
  [data-fx~="layout/expanding-panels"] [data-fx-photo]::after { background: rgb(17 17 23 / 0.38); }
  [data-fx~="layout/expanding-panels"] [data-fx-caption] > [aria-hidden="true"] { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  [data-fx~="layout/expanding-panels"] > [data-fx-panel]::before,
  [data-fx~="layout/expanding-panels"] [data-fx-photo] {
    transition: clip-path var(--fx-panels-dur, 700ms) var(--fx-panels-ease, cubic-bezier(0.65, 0, 0.2, 1));
  }
  [data-fx~="layout/expanding-panels"] [data-fx-photo] img,
  [data-fx~="layout/expanding-panels"] [data-fx-caption] {
    transition: translate var(--fx-panels-dur, 700ms) var(--fx-panels-ease, cubic-bezier(0.65, 0, 0.2, 1)), scale var(--fx-panels-dur, 700ms) var(--fx-panels-ease, cubic-bezier(0.65, 0, 0.2, 1));
  }
  [data-fx~="layout/expanding-panels"] [data-fx-caption] > [aria-hidden="true"] {
    transition: opacity 400ms var(--fx-ease), translate 400ms var(--fx-ease);
  }
}

[data-fx~="layout/expanding-panels"] [data-fx-caption] small { font-size: 0.72rem; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; }
[data-fx~="layout/expanding-panels"] [data-fx-caption] strong { font-family: var(--fx-panels-font, inherit); font-size: clamp(1.25rem, 2vw, 1.6rem); font-weight: 400; line-height: 1.05; }
[data-fx~="layout/expanding-panels"] [data-fx-caption] > [aria-hidden="true"] { font-size: 0.85rem; white-space: nowrap; }
