/* Image Comparison Slider, in full: where the ice was. Each pair is two
   photographs of one place, the later laid exactly over the earlier (its
   measured --s, --rot, --tx, --ty) and both cut to the window they share
   (--cx, --cy, --cw, --ch). --x is the divider, 0–100: a native range input sets it. */

@property --x{syntax:'<number>';inherits:true;initial-value:50}

.ice{position:relative;width:100vw;margin-inline:calc(50% - 50vw);border:0;border-radius:0;background:#0C0E0F;color:var(--ink);
  padding-block:clamp(8px,2vh,24px)}
html{scroll-snap-type:y proximity}

.pair{margin:0;min-height:calc(100svh - var(--bar));box-sizing:border-box;display:grid;align-content:center;justify-items:center;
  gap:clamp(14px,2.4vh,24px);padding:clamp(16px,3vh,36px) clamp(20px,5vw,72px);scroll-snap-align:center;
  --x:50;transition:--x 1.8s var(--settle) .15s}
.pair[data-held]{transition:none}
/* before it is seen, the ice is whole; the first sight of it pulls the divider back to the middle */
.ice.armed .pair:not(.seen){--x:100}

/* the frame keeps the pictures' own shape and fits the screen with room for the caption */
.frame{position:relative;container-type:size;aspect-ratio:var(--ar);width:min(100%,calc((100svh - var(--bar) - 170px) * var(--ar)));overflow:clip;
  background:#15181A;box-shadow:0 30px 80px -30px rgb(0 0 0 / .8)}
.layer{position:absolute;inset:0;overflow:clip}
/* the shared window: the full picture, scaled and shifted so the crop fills the frame */
.view{position:absolute;left:calc(var(--cx) / var(--cw) * -100%);top:calc(var(--cy) / var(--ch) * -100%);
  width:calc(100% / var(--cw));height:calc(100% / var(--ch))}
.view img{position:absolute;inset:0;width:100%;height:100%;display:block}
.now img{transform:translate(var(--tx),var(--ty)) rotate(var(--rot)) scale(var(--s))}
.then{clip-path:inset(0 calc(100% - var(--x) * 1%) 0 0)}

/* the divider: a line, a handle, and the two years riding on either side of it */
.divider{position:absolute;inset:0 auto 0 calc(var(--x) * 1%);width:0;pointer-events:none}
.divider::before{content:'';position:absolute;inset:0 auto 0 -.5px;width:1px;background:rgb(242 237 229 / .9);
  box-shadow:0 0 0 .5px rgb(0 0 0 / .25),0 0 18px rgb(0 0 0 / .35)}
/* the handle rides the line but never leaves the frame */
.divider::after{content:'';position:absolute;top:50%;left:calc(clamp(24px,var(--x) * 1cqw,100cqw - 24px) - var(--x) * 1cqw);width:46px;height:46px;translate:-50% -50%;border-radius:50%;
  border:1px solid rgb(242 237 229 / .85);background:rgb(12 14 15 / .28) center/22px no-repeat;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22' fill='none' stroke='%23F2EDE5' stroke-width='1.4'%3E%3Cpath d='M8 6l-5 5 5 5M14 6l5 5-5 5'/%3E%3C/svg%3E");
  -webkit-backdrop-filter:blur(10px) saturate(1.2);backdrop-filter:blur(10px) saturate(1.2);
  transition:scale .35s var(--settle),border-color .35s var(--settle)}
.divider i{position:absolute;top:clamp(12px,2.2vh,20px);font-style:normal;font-family:var(--mono);font-size:10.5px;letter-spacing:.16em;
  color:#F2EDE5;padding:5px 8px;background:rgb(12 14 15 / .45);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);white-space:nowrap}
.divider i:first-child{right:10px}
.divider i:last-child{left:10px}
.pair:has(input:active) .divider::after{scale:.9}
.pair:has(input:focus-visible) .divider::after{border-color:var(--accent);outline:2px solid var(--accent);outline-offset:3px}

/* the real control: a range input over the whole picture, invisible, so dragging anywhere moves the divider */
.frame input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:ew-resize;touch-action:pan-y;
  -webkit-appearance:none;appearance:none}

.pair figcaption{width:min(100%,calc((100svh - var(--bar) - 170px) * var(--ar)));display:grid;
  grid-template-columns:minmax(0,1fr) auto;column-gap:24px;align-items:baseline}
.pair h2{grid-column:1;margin:0;font-family:var(--display);font-weight:400;font-size:clamp(24px,2.6vw,38px);line-height:1;letter-spacing:-.02em}
.pair .where{grid-column:1;margin:6px 0 0;font-size:14px;color:var(--mid)}
.pair .when{grid-column:2;grid-row:1/3;align-self:end;margin:0;display:grid;gap:4px;justify-items:end;
  font-family:var(--mono);font-size:10px;letter-spacing:.1em;text-transform:uppercase;color:var(--dim);text-align:right}
.pair .when b{font-weight:400;color:var(--mid)}
.pair .gap{color:var(--accent)}

@media (max-width:760px){
  .pair{padding-inline:0;min-height:auto;padding-block:28px}
  .frame,.pair figcaption{width:100%}
  .pair figcaption{padding-inline:18px;grid-template-columns:minmax(0,1fr);row-gap:10px}
  .pair .when{grid-column:1;grid-row:auto;justify-items:start;text-align:left}
}
@media (prefers-reduced-motion:reduce){.pair{transition:none}}
