/* css/gallery-reel.css — Recent shots: a looping 35mm film reel (sprocket holes, edge print, grain).
   Without JavaScript it is a plain sideways-scrolling strip; js/gallery-reel.js adds .is-live and drives the motion. */

.gp-recent {
  --fw: 156px;                         /* one frame, edge to edge */
  --pitch: calc(var(--fw) / 8);        /* sprocket spacing: eight holes per frame, so every frame joins the next exactly */
  --win-h: calc(var(--fw) * 2 / 3);    /* the picture window is 3:2, like real 35mm */
  --film: #1b130c;
  --film-hi: #2b1d11;
  --amber: #f0bd68;
}

/* ---------- The reel window: full width, edges fade like film leaving the gate ---------- */
.gp-reel-view {
  position: relative;
  margin: .15rem -2% .1rem;              /* a little room: the tilted strip swings past the edges */
  padding: 8px 0 14px;
  rotate: -.7deg;                        /* draped across the screen rather than ruled straight */
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.gp-reel-view::-webkit-scrollbar { display: none; }
.gp-reel-track { display: flex; width: max-content; }
.gp-film { display: flex; flex: none; margin: 0; padding: 0; list-style: none; }

/* ---------- One frame of film ---------- */
.gp-frame {
  position: relative;
  flex: none;
  width: var(--fw);
  display: flex; flex-direction: column; align-items: center;
  padding: 17px 0;                       /* room for the sprocket row */
  background:
    radial-gradient(70% 46% at 50% 50%, rgba(255, 168, 70, .10), transparent 72%),   /* light bleeding through the base */
    linear-gradient(180deg, var(--film-hi) 0, var(--film) 24%, var(--film) 76%, var(--film-hi) 100%);
  box-shadow: inset 1px 0 0 rgba(0, 0, 0, .55), inset 2px 0 0 rgba(255, 220, 160, .05);   /* the cut between frames */
}
.gp-frame::before,
.gp-frame::after {                       /* sprocket holes, lit from behind */
  content: "";
  position: absolute; left: 0; right: 0;
  height: 17px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 21 17'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23fff9e8'/%3E%3Cstop offset='1' stop-color='%23dcc79b'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect x='4.2' y='4.2' width='12.6' height='8.6' rx='2.6' fill='url(%23g)' stroke='%23090604' stroke-opacity='.55' stroke-width='.8'/%3E%3C/svg%3E") repeat-x 0 0 / var(--pitch) 17px;
}
.gp-frame::before { top: 0; }
.gp-frame::after { bottom: 0; }

.gp-edge {                               /* the printed edge code between the holes and the picture */
  width: calc(100% - 12px);
  height: 13px;
  display: flex; align-items: center; justify-content: space-between; gap: .5em;
  overflow: hidden; white-space: nowrap;
  font: 700 7.5px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--amber);
  opacity: .82;
  text-shadow: 0 0 5px rgba(240, 189, 104, .55);
}

.gp-edge::after {                       /* the keycode barcode, like the real thing */
  content: "";
  order: 1; flex: 1 1 0; min-width: 0; height: 5px;
  background: repeating-linear-gradient(90deg, var(--amber) 0 1px, transparent 1px 3px, var(--amber) 3px 5px, transparent 5px 6px, var(--amber) 6px 7px, transparent 7px 10px);
  opacity: .5;
}
.gp-edge > span:last-child { order: 2; }

.gp-frame .gallery-open {
  width: calc(100% - 12px);
  height: var(--win-h);
  border-radius: 2px;
  background: #000;
  box-shadow: 0 0 0 1px #000, 0 0 0 2px rgba(255, 255, 255, .05);
  transition: transform .35s var(--gp-ease), box-shadow .35s;
}
.gp-frame .gallery-open img {            /* a faint film cast on every print */
  filter: sepia(.16) saturate(1.1) contrast(1.05) brightness(.93);
}
.gp-frame .gallery-open::after {         /* vignette from the lens + an occasional light leak at the edge */
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(125% 110% at 50% 50%, transparent 58%, rgba(0, 0, 0, .42));
}
.gp-frame:nth-child(4n + 2) .gallery-open::after {
  background:
    linear-gradient(95deg, rgba(255, 128, 36, .26), transparent 26%),
    radial-gradient(125% 110% at 50% 50%, transparent 58%, rgba(0, 0, 0, .42));
}
.gp-frame:nth-child(5n + 4) .gallery-open::after {
  background:
    linear-gradient(265deg, rgba(255, 150, 60, .2), transparent 22%),
    radial-gradient(125% 110% at 50% 50%, transparent 58%, rgba(0, 0, 0, .42));
}
.gp-frame .gallery-open:focus-visible { outline: 3px solid var(--gp-gold); outline-offset: 2px; }

@media (hover: hover) {
  .gp-frame .gallery-open:hover {
    transform: scale(1.07);
    z-index: 2;
    box-shadow: 0 0 0 1px #000, 0 12px 26px -4px rgba(0, 0, 0, .9), 0 0 26px rgba(240, 189, 104, .35);
  }
  .gp-frame .gallery-open:hover img { filter: none; }
}
.gp-frame .gallery-open:focus-visible img { filter: none; }
@media (hover: hover) {
  .gp-reel-view:has(.gallery-open:hover) .gp-frame:not(:hover) .gallery-open img { filter: sepia(.2) saturate(.9) brightness(.55); }
}
.gp-frame .gallery-open img { transition: filter .35s, opacity .45s ease, transform .6s var(--gp-ease); }

.gp-tag {
  position: absolute; top: 5px; left: 5px; z-index: 1;
  padding: .16rem .45rem;
  border-radius: 999px;
  background: rgba(8, 19, 31, .78);
  color: #fff;
  font-size: .58rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
}
.gp-tag--lead { background: var(--gp-gold); color: #1b1404; }

/* `hidden` must beat the display rules of the shared control styles (the controls only appear once the script runs) */
.gp-strip-nav[hidden], .gp-strip-btn[hidden] { display: none; }

/* ---------- Caption line under the reel ---------- */
.gp-reel-caption {
  display: flex; align-items: baseline; gap: .7rem;
  min-height: 1.5rem; margin: 0;
  font-size: .86rem;
  color: rgba(255, 255, 255, .72);
}
.gp-reel-no { flex: none; font: 700 .8rem ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .1em; color: var(--gp-gold); }
.gp-reel-title { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: #fff; font-weight: 600; }
.gp-reel-sub { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1 1 0; }
.gp-reel-all {
  flex: none; margin-left: auto;
  color: var(--gp-gold); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.gp-reel-all:hover, .gp-reel-all:focus-visible { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.gp-reel-all:focus-visible { outline: 2px solid var(--gp-gold); outline-offset: 3px; border-radius: 4px; }

/* ---------- Live: the reel runs by itself ---------- */
.gp-recent.is-live .gp-reel-view {
  overflow: clip;
  touch-action: pan-y;
  cursor: grab;
}
.gp-recent.is-live .gp-reel-track { will-change: transform; }
.gp-recent.is-live .gp-reel-view.is-dragging { cursor: grabbing; user-select: none; }
.gp-recent.is-live .gp-reel-view.is-dragging .gallery-open { pointer-events: none; }

.gp-recent.is-live .gp-reel-view::before {   /* hairline scratches that jump to a new place now and then */
  content: "";
  position: absolute; inset: 0; z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 22%, rgba(255, 255, 255, .22) 22% calc(22% + 1px), transparent calc(22% + 1px)),
    linear-gradient(90deg, transparent 0 68%, rgba(255, 255, 255, .14) 68% calc(68% + 1px), transparent calc(68% + 1px)),
    linear-gradient(90deg, transparent 0 91%, rgba(255, 255, 255, .1) 91% calc(91% + 1px), transparent calc(91% + 1px));
  animation: gp-scratch 7s steps(1) infinite;
}
@keyframes gp-scratch {
  0%   { translate: 0 0; opacity: 1; }
  18%  { translate: 11% 0; opacity: .5; }
  37%  { translate: -7% 0; opacity: 1; }
  55%  { translate: 19% 0; opacity: 0; }
  70%  { translate: -13% 0; opacity: .8; }
  86%  { translate: 4% 0; opacity: .4; }
}

.gp-recent.is-live .gp-reel-view::after {   /* projector grain, jittering a few times a second */
  content: "";
  position: absolute; inset: -20%;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .11;
  animation: gp-grain .6s steps(1) infinite;
}
@keyframes gp-grain {
  0%   { transform: translate(0, 0); }
  17%  { transform: translate(-5%, 3%); }
  33%  { transform: translate(4%, -4%); }
  50%  { transform: translate(-3%, -2%); }
  67%  { transform: translate(5%, 4%); }
  83%  { transform: translate(-4%, 5%); }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .gp-recent { --fw: 144px; }
}
@media (max-width: 480px) {
  .gp-recent { --fw: 124px; }
  .gp-strip-btn[data-gp-reel-step] { display: none; }   /* swipe on phones; pause stays */
  .gp-reel-sub { display: none; }
  .gp-reel-title { flex: 1 1 0; }
}

@media (prefers-reduced-motion: reduce) {
  .gp-recent.is-live .gp-reel-view::after, .gp-recent.is-live .gp-reel-view::before { animation: none; }
  .gp-frame .gallery-open { transition: none; }
  .gp-frame .gallery-open:hover { transform: none; }
}
