/* Card stacks (stacks.js): a list marked data-stack becomes a pile of cards held with a strip of masking tape,
   slightly offset and turned, with ‹ 2 / 6 › under it and, on wide screens, an index of the cards beside it.
   Loaded by publishing.html, academic.html and submit.html. Without stacks.js nothing here applies. */

.stack { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 28px 64px; align-items: center; }
.stack-main { min-width: 0; }

/* The pile: every card in the same grid cell, the tallest sets the height */
.stack .stack-pile { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; padding: 22px 14px 30px; touch-action: pan-y; }
.stack .stack-pile > li { grid-area: 1 / 1; min-width: 0; transition: transform .45s var(--ease); transform: var(--pose, none); }
.stack .stack-pile > li[data-depth="0"] { --pose: rotate(-1.2deg); }
.stack .stack-pile > li[data-depth="1"] { --pose: translate(12px, 10px) rotate(2.4deg); }
.stack .stack-pile > li[data-depth="2"] { --pose: translate(-10px, 18px) rotate(-3.2deg); }
.stack .stack-pile > li[data-depth="3"] { --pose: translate(6px, 25px) rotate(1.6deg); }
.stack .stack-pile > li[data-depth="4"] { --pose: translate(0, 28px) rotate(-.6deg); }
.stack .stack-pile > li > * { height: 100%; }
.stack .stack-pile > li:not(.is-top) > * { box-shadow: 0 1px 1px rgba(0,0,0,.35), 0 10px 18px -10px rgba(0,0,0,.6); }
.stack .stack-pile > li.is-top > * { cursor: pointer; }
.stack .stack-pile > li:not(.is-top) .frame-num { visibility: hidden; } /* only the top card's number shows */
/* Cards underneath show only their edges: their words are hidden from sight (screen readers still read the list) */
.stack .stack-pile > li:not(.is-top) > * > * { opacity: 0; }
.stack .stack-pile > li > * > * { transition: opacity .25s; }

/* The tape: one strip across the top of each card, each at its own angle */
.stack .stack-pile > li > *::before {
  content: ""; position: absolute; z-index: 3; left: 50%; top: -17px; width: 120px; height: 38px; margin-left: -60px; pointer-events: none;
  background: url(assets/art/tape.webp) center / 100% 100% no-repeat; filter: drop-shadow(0 1px 1px rgba(60,40,15,.25));
  transform: rotate(-2.5deg); opacity: 1;
}
.stack .stack-pile > li:nth-child(2n) > *::before { transform: rotate(3deg); margin-left: -48px; }
.stack .stack-pile > li:nth-child(3n) > *::before { transform: rotate(-4deg); margin-left: -70px; }
.stack .stack-pile > li:not(.is-top) > *::before { opacity: .85; }

/* ‹ 2 / 6 › */
.stack-bar { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 6px; }
.stack-btn {
  display: inline-grid; place-items: center; width: 48px; height: 48px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 1px solid currentColor; background: transparent; color: inherit; font: 400 30px/1 var(--serif); opacity: .9;
  transition: background-color .2s, color .2s;
}
.stack-btn:hover { background: var(--burgundy); border-color: var(--burgundy); color: #fbefd2; opacity: 1; }
.stack-btn:focus-visible, .stack-index button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.stack-btn span[aria-hidden] { margin-top: -4px; }
.stack-count { margin: 0; min-width: 64px; text-align: center; font: 600 20px var(--serif); font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.stack-hint { margin: 6px 0 0; text-align: center; font-size: 13.5px; opacity: .75; }

/* The index beside the pile (wide screens) */
.stack-index { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; counter-reset: none; }
.stack-index button {
  display: flex; align-items: baseline; gap: 14px; width: 100%; min-height: 44px; padding: 8px 12px; text-align: left; cursor: pointer;
  border: 0; border-bottom: 1px solid currentColor; border-color: color-mix(in srgb, currentColor 22%, transparent); background: none; color: inherit;
  font: italic 500 22px/1.2 var(--serif); transition: background-color .2s, padding .25s var(--ease);
}
.stack-index button b { font: 600 13px var(--sans); font-style: normal; letter-spacing: .12em; opacity: .7; min-width: 18px; }
.stack-index button:hover { background: color-mix(in srgb, currentColor 7%, transparent); }
.stack-index button[aria-current="true"] { padding-left: 22px; color: var(--burgundy); }
.stack-index button[aria-current="true"]::before { content: ""; align-self: center; width: 8px; height: 8px; margin-left: -16px; margin-right: -4px; border-radius: 50%; background: currentColor; }

/* Dark pages (the submissions desk): gold on the night */
.stack--dark .stack-index button[aria-current="true"] { color: var(--gold-hi); }
.stack--dark .stack-btn:hover { background: var(--gold-hi); border-color: var(--gold-hi); color: var(--ink); }

@media (max-width: 900px) {
  .stack { grid-template-columns: minmax(0, 1fr); max-width: 460px; margin: 0 auto; }
  .stack-index { display: none; }
}
@media (hover: hover) and (min-width: 901px) { .stack-hint { display: none; } }

/* The list's own outer margin would push ‹ 2 / 6 › away from the pile: the stack keeps the space below instead */
.stack .stack-pile { margin: 0; }
.stack:has(.routes) { margin-bottom: clamp(56px, 8vw, 96px); }

/* Covers (LitVerse issues): a pile of magazines; the covers underneath stay in sight, only their captions hide */
.stack--covers { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); margin-bottom: 44px; }
.stack--covers .stack-pile > li:not(.is-top) > * > img { opacity: 1; }
.stack--covers .stack-pile > li:not(.is-top) > * { box-shadow: none; }
.stack--covers .stack-pile > li.is-top > * { cursor: zoom-in; }
.stack--covers .stack-pile > li > * { gap: 6px; }
.stack--covers .stack-pile > li > * > b { margin-top: 34px; } /* the caption clears the covers that show below the top one */
.stack--covers .stack-pile > li > *::before { top: -13px; width: 92px; height: 30px; margin-left: -46px; }
.stack--covers .stack-pile > li:nth-child(2n) > *::before { margin-left: -38px; }
.stack--covers .stack-pile > li:nth-child(3n) > *::before { margin-left: -54px; }
.stack--covers .stack-index button { font-size: 19px; }
@media (max-width: 900px) { .stack--covers { max-width: 300px; } }

/* Still pictures and reduced motion: the cards change places without moving */
html.calm .stack .stack-pile > li, html.calm .stack .stack-pile > li > * > *, html.calm .stack-index button { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .stack .stack-pile > li, .stack .stack-pile > li > * > *, .stack-index button { transition: none; }
}
@media print {
  .stack-bar, .stack-hint, .stack-index { display: none; }
  .stack .stack-pile > li { grid-area: auto; transform: none; }
  .stack .stack-pile > li > * > * { opacity: 1 !important; }
}
