/* the story: pile, focus and table on one pinned stage, held for about two screens (one and a half on a phone) */
.story { position: relative; height: 300vh; }
.st-stage {
  position: sticky; top: 0; height: 100svh; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); grid-template-rows: auto minmax(0, 1fr);
  gap: 18px clamp(32px, 4vw, 72px); padding: calc(var(--top) + clamp(18px, 3.4vh, 40px)) var(--gutter) clamp(20px, 3vh, 36px);
}
.st-head { grid-column: 1 / -1; grid-row: 1; max-width: 46rem; transition: opacity .2s linear; }
.st-head h2 { margin: 12px 0 0; font-size: var(--s-title); }
.st-head p { margin: 14px 0 0; color: var(--ink-2); font-size: var(--s-lead); max-width: 38rem; }
.st-head .st-hint { font-size: var(--cap-size); color: var(--cap-color); margin-top: 10px; }
.st-h2 { opacity: 0; pointer-events: none; }

/* the pile stays inside its own box, so a landing or spread page never covers the words above it */
.st-pile { grid-column: 1 / -1; grid-row: 2; position: relative; overflow: hidden; cursor: grab; touch-action: pan-y; user-select: none; z-index: 2; }
.st-pile.drag { cursor: grabbing; }
.st-card { position: absolute; left: 0; top: 0; transform-origin: 50% 50%; will-change: transform, opacity; opacity: 0; transition: box-shadow .2s, filter .2s; }
.st-card img { width: 100%; height: auto; display: block; background: #fff; box-shadow: 0 0 0 1px rgba(12, 13, 18, .08), 0 8px 22px rgba(12, 13, 18, .10); pointer-events: none; }
.st-card.lift img { box-shadow: 0 0 0 2px var(--blue), 0 18px 40px rgba(12, 13, 18, .18); }
.st-card.lift { z-index: 50; translate: 0 -10px; }
.st-label { position: absolute; left: 50%; bottom: clamp(18px, 4vh, 40px); transform: translateX(-50%); z-index: 6; background: var(--ink); color: #fff; font-size: var(--s-small);
  padding: 7px 12px; white-space: nowrap; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis; }
.st-label.on { opacity: 1; }

.st-page { grid-column: 1; grid-row: 2; margin: 0; min-height: 0; display: flex; flex-direction: column; opacity: 0; z-index: 3; }
.st-frame { position: relative; align-self: flex-start; max-width: 100%; line-height: 0; background: #fff; box-shadow: 0 0 0 1px var(--grey-2), 0 18px 50px rgba(12, 13, 18, .1); }
.st-frame img { max-height: calc(100svh - var(--top) - 250px); width: auto; max-width: 100%; display: block; }
.st-frame canvas { position: absolute; inset: 0; }
.st-cap { margin-top: 10px; font-size: var(--s-small); color: var(--ink-3); line-height: 1.4; }
.st-cap b { color: var(--ink); font-weight: 500; }
.st-cap a { color: var(--ink-2); }

.st-table { grid-column: 2; grid-row: 2; min-height: 0; display: flex; flex-direction: column; opacity: 0; position: relative; z-index: 3; }
.st-tools { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 12px; }
.st-count { display: flex; align-items: baseline; gap: 10px; color: var(--ink-2); font-size: var(--s-small); }
.st-k { font-size: clamp(2.6rem, 3.6vw, 3.4rem); color: var(--blue); line-height: 1; }
.st-pick select { appearance: none; -webkit-appearance: none; border: 0; border-bottom: 1px solid var(--ink); background: transparent; padding: 6px 26px 6px 0; font-size: 1rem; color: var(--ink); cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--blue) 50%), linear-gradient(135deg, var(--blue) 50%, transparent 50%);
  background-position: calc(100% - 10px) 55%, calc(100% - 5px) 55%; background-size: 5px 5px; background-repeat: no-repeat; max-width: 210px; }
.st-win { border-top: 1px solid var(--ink); }
.st-table table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.st-table th { text-align: left; font-size: var(--label-size); letter-spacing: var(--label-track); text-transform: uppercase; font-weight: var(--label-weight); color: var(--label-color); padding: 9px 10px 9px 0; }
.st-table th:nth-child(1) { width: 34%; } .st-table th:nth-child(2) { width: 30%; } .st-table th:nth-child(3) { width: 18%; } .st-table th:nth-child(4) { width: 18%; }
.st-table td { padding: 0 10px 0 0; height: 33px; border-bottom: 1px solid var(--grey-2); font-size: var(--s-small); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-table .num { text-align: right; padding-right: 0; }
.st-table td.num { color: var(--ink); font-weight: 600; font-size: 1rem; }
.st-table tr.new td { background: var(--blue-3); color: var(--ink); }
.st-table tr.new td.num { color: var(--blue); }
.st-table tr.empty td { border-bottom: 1px dashed var(--grey-2); }
.st-all { margin-top: 14px; align-self: flex-start; font-size: var(--s-small); }
.st-full { position: absolute; left: 0; right: 0; top: 64px; bottom: 34px; background: var(--paper); z-index: 4; border-top: 1px solid var(--ink); }
.st-full-in { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; }
.st-full th { position: sticky; top: 0; background: var(--paper); }
.st-thread { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

@media (max-width: 860px) {
  .story { height: 250vh; }
  .st-stage { grid-template-columns: 1fr; grid-template-rows: auto auto minmax(0, 1fr); gap: 12px; }
  .st-head p { font-size: .95rem; }
  .st-h1 p:not(.st-hint), .st-h2 p { display: none; }
  .st-pile { grid-row: 2 / span 2; }
  .st-page { grid-row: 2; }
  .st-frame img { max-height: 26svh; }
  .st-table { grid-column: 1; grid-row: 3; }
  .st-table td:nth-child(2), .st-table th:nth-child(2) { display: none; }
  .st-table th:nth-child(1) { width: 50%; } .st-table th:nth-child(3) { width: 28%; } .st-table th:nth-child(4) { width: 22%; }
  .st-pick select { max-width: 160px; }
}
@media (prefers-reduced-motion: reduce) { .story { height: auto; } .st-stage { position: relative; height: auto; } .st-pile, .st-h1 { display: none; } .st-h2, .st-page, .st-table { opacity: 1 !important; } }
