/* The fanzine reader. Pages are images; the links sit invisibly on top of them. */

.fanzine {
  --page-ratio: 0.7048;          /* page width / height, set from pages.json */
  --arrows: 112px;                /* room for the two arrow buttons */
  container-type: size;
  min-height: 0;
  flex: 1;
  --ph: min(100cqh - 8px, (100cqw - var(--arrows)) / (2 * var(--page-ratio)));
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 0 var(--gutter);
  position: relative;
}

.fz-stage {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.fz-stage:active { cursor: grabbing; }
.is-single.fanzine { --ph: min(100cqh - 8px, (100cqw - var(--arrows)) / var(--page-ratio)); }

/* ── the book ───────────────────────────────────────── */
.fz-book {
  --n: 2;
  position: relative;
  height: var(--ph);
  width: calc(var(--ph) * var(--page-ratio) * var(--n));
  perspective: calc(var(--ph) * 3.2);
  transition: opacity 0.35s;
}
.is-jumping .fz-book { opacity: 0; transition: none; }

.fz-slot {
  position: absolute;
  top: 0;
  height: 100%;
  width: calc(100% / var(--n));
  transition: transform 0.45s cubic-bezier(.2, .7, .2, 1), box-shadow 0.45s;
}
.fz-slot--l, .fz-slot--solo { left: 0; }
.fz-slot--r { left: 50%; }
.fz-slot--solo { width: 100%; }

/* the fold between two pages */
.fz-slot--l::after, .fz-slot--r::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 7%;
  pointer-events: none;
  z-index: 1;
}
.fz-slot--l::after { right: 0; background: linear-gradient(to left, rgba(0, 0, 0, 0.28), transparent); }
.fz-slot--r::after { left: 0; background: linear-gradient(to right, rgba(0, 0, 0, 0.22), transparent); }

/* hover a page edge: the corner lifts */
.peek-next .fz-slot--r { transform: rotateY(-14deg); transform-origin: left center; box-shadow: -18px 0 40px -20px rgba(0, 0, 0, 0.7); }
.peek-prev .fz-slot--l { transform: rotateY(14deg); transform-origin: right center; box-shadow: 18px 0 40px -20px rgba(0, 0, 0, 0.7); }
.peek-next .fz-slot--solo { transform: rotateY(-10deg); transform-origin: left center; }

.fz-cast {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 2;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.1) 60%, transparent);
}
.fz-slot--l .fz-cast { background: linear-gradient(to left, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.1) 60%, transparent); }

.fz-page { position: relative; width: 100%; height: 100%; margin: 0; background: #1a1a1a; }
.fz-page img { width: 100%; height: 100%; display: block; object-fit: cover; pointer-events: none; }
.fz-page--blank { background: #111; }   /* back of a single page while it turns: dark, so nothing flashes white */
.fz-page--none { background: transparent; }
.fz-slot:has(.fz-page--none)::after { display: none; }

/* the turning page: a front and a back on one hinge */
.fz-leaf { position: absolute; top: 0; height: 100%; z-index: 4; transform-style: preserve-3d; will-change: transform; }
.fz-leaf--r { left: 50%; width: 50%; transform-origin: left center; }
.fz-leaf--l { left: 0; width: 50%; transform-origin: right center; }
.fz-leaf--solo { left: 0; width: 100%; transform-origin: left center; }
.fz-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.fz-face--back { transform: rotateY(180deg); }
.fz-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.15) 45%, rgba(255, 255, 255, 0.08));
}
.fz-leaf--l .fz-face--front .fz-shade,
.fz-leaf--r .fz-face--back .fz-shade { background: linear-gradient(to left, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.15) 45%, rgba(255, 255, 255, 0.08)); }

/* page edges: hover to peek, click to turn (links above stay clickable) */
.fz-edge { position: absolute; top: 0; bottom: 0; width: 7%; z-index: 3; border: 0; padding: 0; background: none; cursor: pointer; }
.fz-edge--next { right: 0; }
.fz-edge--prev { left: 0; }

/* invisible links; a quiet hint on hover / keyboard focus */
.fz-hot { position: absolute; display: block; border: 0; padding: 0; background: transparent; cursor: pointer; }
.fz-credit { z-index: 2; }
.fz-figure { z-index: 1; }
.fz-credit:hover, .fz-credit:focus-visible { background: var(--volt); mix-blend-mode: multiply; outline: none; }
.fz-figure:focus-visible { outline: 1px dashed #fff; outline-offset: 4px; }
.fz-figure::after {
  content: "Shop this look";
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -8px);
  white-space: nowrap;
  font: 700 11px/1 var(--sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--volt);
  color: var(--ink);
  padding: 7px 9px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.fz-figure:hover::after, .fz-figure:focus-visible::after { opacity: 1; }
@media (hover: none) { .fz-figure::after { display: none; } }

/* arrows */
.fz-nav { width: 48px; height: 48px; display: grid; place-items: center; border: 0; background: none; color: var(--volt); cursor: pointer; }
.fz-nav svg { width: 22px; height: 22px; }
.fz-nav:disabled { opacity: 0.2; cursor: default; }
.fz-nav:not(:disabled):hover { color: var(--paper); }

/* ── strip of spreads: jump anywhere ────────────────── */
.fz-strip { display: flex; gap: 4px; align-items: flex-end; flex: 1; margin: 0 clamp(16px, 4vw, 48px); height: 24px; }
.fz-tick {
  position: relative;
  flex: 1;
  height: 8px;
  min-width: 4px;
  border: 0;
  padding: 0;
  background: rgba(222, 255, 0, 0.25);
  cursor: pointer;
  transition: height 0.2s, background 0.2s;
}
.fz-tick:hover { height: 18px; background: rgba(222, 255, 0, 0.6); }
.fz-tick[aria-current="true"] { height: 18px; background: var(--volt); }
.fz-tick__thumb {
  --n: 2;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  translate: -50% 0;
  display: flex;
  height: 120px;
  aspect-ratio: calc(0.7048 * var(--n));
  background: var(--ink);
  border: var(--rule) solid var(--volt);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 6;
}
.fz-tick__thumb img { height: 100%; width: calc(100% / var(--n)); object-fit: cover; display: block; }
.fz-tick::after {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 140px);
  left: 50%;
  translate: -50% 0;
  white-space: nowrap;
  font: 700 11px/1 var(--sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--volt);
  color: var(--ink);
  padding: 6px 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.fz-tick:first-child .fz-tick__thumb, .fz-tick:first-child::after { left: 0; translate: 0 0; }
.fz-tick:last-child .fz-tick__thumb, .fz-tick:last-child::after { left: auto; right: 0; translate: 0 0; }
.fz-tick:hover .fz-tick__thumb, .fz-tick:hover::after,
.fz-tick:focus-visible .fz-tick__thumb, .fz-tick:focus-visible::after { opacity: 1; }
@media (hover: none) { .fz-tick__thumb, .fz-tick::after { display: none; } }

/* ── the list of pieces when you click a figure ─────── */
.fz-pop {
  position: absolute;
  z-index: 7;
  width: 300px;
  max-width: calc(100% - 16px);
  background: var(--volt);
  color: var(--ink);
  border: var(--rule) solid var(--ink);
  padding: 12px 14px 8px;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 500;
}
.fz-pop[hidden] { display: none; }
.fz-pop__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 8px;
  border-bottom: var(--rule) solid var(--ink);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.fz-pop__close {
  font: 500 12px var(--sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.55);
  background: none;
  border: 0;
  cursor: pointer;
  min-height: 32px;
  padding: 0 0 0 12px;
}
.fz-pop__close:hover { color: var(--ink); }
.fz-pop ul { list-style: none; }
.fz-pop li + li { border-top: 1px solid rgba(0, 0, 0, 0.25); }
.fz-pop a, .fz-pop__row {
  display: grid;
  grid-template-columns: 1fr auto 12px;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  color: inherit;
  text-decoration: none;
}
.fz-pop__row { grid-template-columns: 1fr auto; color: rgba(0, 0, 0, 0.55); }
.fz-pop a:hover { background: var(--ink); color: var(--volt); margin: 0 -14px; padding: 0 14px; }
.fz-pop a:hover .fz-pop__item { color: var(--volt); }
.fz-pop__item { color: rgba(0, 0, 0, 0.6); }
.fz-pop__brand { text-align: right; font-weight: 700; }
.fz-pop .arrow { width: 9px; height: 9px; }

/* phones: one page, arrows tucked in */
@media (max-width: 760px) {
  .fanzine { --arrows: 72px; padding: 0 4px; }
  .fz-nav { width: 36px; }
  .fz-nav svg { width: 18px; height: 18px; }
  .fz-strip { margin: 0 12px; }
  .fz-tick { height: 6px; }
  .fz-tick[aria-current="true"] { height: 12px; }
}

/* "Start flipping": beside the closed book, gone once the cover turns */
.fz-start {
  position: absolute;
  z-index: 5;
  left: calc(50% + var(--ph) * var(--page-ratio) / 2 + clamp(16px, 3vw, 40px));
  top: 50%;
  translate: 0 -50%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 18px;
  border: var(--rule) solid var(--volt);
  background: var(--volt);
  color: var(--ink);
  font: 700 18px/1 var(--sans);
  letter-spacing: -0.01em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.3s, background 0.15s, color 0.15s;
}
.fz-start svg { width: 22px; height: 22px; animation: nudge 1.4s ease-in-out infinite; }
.fz-start:hover, .fz-start:focus-visible { background: var(--ink); color: var(--volt); outline: none; }
.fz-start.is-gone { opacity: 0; pointer-events: none; }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(6px); } }
@media (max-width: 760px) {
  .fz-start { left: 50%; top: auto; bottom: 8px; translate: -50% 0; min-height: 48px; font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .fz-slot, .fz-book { transition: none; }
  .fz-start svg { animation: none; }
}

/* touch screens: no tap highlight or focus box on the page edges, and no "lifted corner" left behind */
.fz-edge, .fz-hot, .fz-nav, .fz-tick, .fz-start { -webkit-tap-highlight-color: transparent; }
.fz-edge:focus { outline: none; }
@media (hover: none) {
  .peek-next .fz-slot--r, .peek-prev .fz-slot--l, .peek-next .fz-slot--solo { transform: none; box-shadow: none; }
}

/* ── touch hints ────────────────────────────────────── */
/* flash (optional, data-hint="flash"): credits light up when a page lands */
.is-flashing .fz-credit { animation: fz-flash 1.4s ease-out both; }
.is-flashing .fz-credit:nth-of-type(2) { animation-delay: 0.08s; }
.is-flashing .fz-credit:nth-of-type(3) { animation-delay: 0.16s; }
.is-flashing .fz-credit:nth-of-type(n+4) { animation-delay: 0.24s; }
@keyframes fz-flash { 25% { background: var(--volt); mix-blend-mode: multiply; } }

/* coach: the one-time "tap to shop" explainer */
.fz-coach { position: absolute; inset: 0; z-index: 8; cursor: pointer; animation: fz-fade 0.35s ease-out both; }
.fz-coach.no-spot { background: rgba(0, 0, 0, 0.72); }
.fz-coach.is-out { opacity: 0; transition: opacity 0.3s; }
@keyframes fz-fade { from { opacity: 0; } }

.fz-coach__spot {
  position: absolute;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.74);      /* dims everything but the credit line */
  pointer-events: none;
}
.fz-coach__mark {                                    /* a yellow underline swipes in under the line */
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: -3px;
  height: 3px;
  background: var(--volt);
  transform-origin: left center;
  animation: fz-swipe 0.55s cubic-bezier(.6, 0, .2, 1) 0.35s both;
}
@keyframes fz-swipe { from { transform: scaleX(0); } }

.fz-coach__tap {                                     /* a tap: a dot and two rings rippling out */
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--volt);
  pointer-events: none;
  animation: fz-dot 1.6s ease-in-out 0.9s infinite both;
}
.fz-coach__tap::before, .fz-coach__tap::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid var(--volt);
  animation: fz-ring 1.6s ease-out 0.9s infinite both;
}
.fz-coach__tap::after { animation-delay: 1.15s; }
.fz-coach__tap--late, .fz-coach__tap--late::before { animation-delay: 1.7s; }
.fz-coach__tap--late::after { animation-delay: 1.95s; }
@keyframes fz-dot { 0%, 100% { transform: scale(1); } 12% { transform: scale(0.7); } 24% { transform: scale(1); } }
@keyframes fz-ring { 0% { transform: scale(1); opacity: 0.9; } 70%, 100% { transform: scale(4.2); opacity: 0; } }

.fz-coach__card {
  position: absolute;
  left: 14px;
  right: 14px;
  background: var(--volt);
  color: var(--ink);
  padding: 12px 14px 14px;
  display: grid;
  gap: 8px;
  animation: fz-up 0.5s cubic-bezier(.2, .8, .2, 1) 0.5s both;
}
.fz-coach__card.at-bottom { bottom: 14px; }
.fz-coach__card.at-top { top: 14px; }
@keyframes fz-up { from { transform: translateY(16px); opacity: 0; } }
.fz-coach__kicker { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding-bottom: 8px; border-bottom: var(--rule) solid var(--ink); }
.fz-coach__title { font-weight: 700; font-size: 40px; line-height: 0.9; letter-spacing: -0.05em; text-transform: uppercase; }
.fz-coach__text { font-weight: 500; font-size: 14px; line-height: 1.35; max-width: 24em; }
.fz-coach__ok {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border: var(--rule) solid var(--ink);
  background: var(--ink);
  color: var(--volt);
  font: 700 15px/1 var(--sans);
  text-transform: uppercase;
  cursor: pointer;
}
.fz-coach__ok svg { width: 20px; height: 20px; }
@media (prefers-reduced-motion: reduce) {
  .fz-coach__mark, .fz-coach__tap, .fz-coach__tap::before, .fz-coach__tap::after, .fz-coach__card { animation: none; }
}
