/*
 * Slidestory gallery: a dark, full-screen room for reading the options of a slide one at a time or side by side.
 */

/* ---------- gallery popup (always dark, whatever the page theme) ---------- */
.gal {
  --paper: #0A0F24; --surface: #121936; --sunk: #0D1330; --ink: #EEF1FC; --ink-2: #C9D1EE; --muted: #98A4CC;
  --line: #252E57; --line-2: #36417A; --accent: #8AA0FF; --accent-ink: #0A0F24; --accent-soft: #1B2552; --mark-soft: #3B3411;
  --ok-bg: #12372A; --ok-fg: #A9E8C6; --tune-bg: #41310F; --tune-fg: #F4D99A; --na-bg: #1C2448; --na-fg: #B8C2E4;
  --g-panel: rgba(255, 255, 255, .055);
  border: 0; padding: 0; margin: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; overflow: hidden; background: transparent; color: var(--ink);
}
.gal::backdrop { background: rgba(5, 8, 22, .88); -webkit-backdrop-filter: blur(16px) saturate(1.2); backdrop-filter: blur(16px) saturate(1.2); animation: fadeIn .3s both; }
.gal[open] .gal-in { animation: galIn .35s var(--ease) both; }
@keyframes galIn { from { opacity: 0; } }
.gal-in:focus { outline: none; }
.gal-in { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: clamp(10px, 1.6vw, 18px); padding: clamp(10px, 2vw, 22px) clamp(12px, 2.6vw, 32px) clamp(10px, 1.6vw, 20px); }
.gal-top { display: flex; align-items: center; justify-content: space-between; gap: 14px 20px; flex-wrap: wrap; }
.gal-head { display: grid; gap: 2px; min-width: 0; flex: 1 1 320px; }
.gal-k { font-size: 13px; font-weight: 600; color: var(--muted); }
.gal-t { font: 700 clamp(18px, 2.2vw, 26px)/1.15 var(--display); letter-spacing: -.02em; text-wrap: balance; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gal-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gal-seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--g-panel); border: 1px solid var(--line); }
.gal-seg button { border: 0; background: transparent; color: var(--ink-2); font: 600 13.5px/1 var(--sans); padding: 8px 14px; border-radius: 999px; cursor: pointer; transition: background .25s var(--ease), color .2s; }
.gal-seg button[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.gal-nav { display: inline-flex; align-items: center; gap: 4px; }
.gal-pos { min-width: 52px; text-align: center; font-size: 13.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.gib { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line-2); background: transparent; color: var(--ink); cursor: pointer; transition: background .2s, border-color .2s, transform .2s var(--ease); }
.gib:hover { background: var(--g-panel); border-color: var(--ink); }
.gib:active { transform: scale(.92); }
.gib svg { width: 18px; height: 18px; }
.gib.up svg { transform: rotate(90deg); } .gib.down svg { transform: rotate(90deg); }

.gal-main { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(280px, 28vw, 360px); gap: clamp(12px, 2vw, 24px); }
.gal-center { min-height: 0; min-width: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto auto; gap: 12px; }
.gal-stage { position: relative; min-height: 0; display: grid; place-items: center; container-type: size; }
.gal-art { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden; background: #fff; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 255, 255, .08); }
@supports (width: 1cqw) { .gal-art { width: min(100cqw, 100cqh * 16 / 9); } }
.gal-art svg { display: block; width: 100%; height: 100%; }
.cv-new.swap { animation: galArt .5s var(--ease) both; }
.cv-new.swap[data-dir="next"] { --fx: 44px; --fy: 0px; } .cv-new.swap[data-dir="prev"] { --fx: -44px; --fy: 0px; }
.cv-new.swap[data-dir="down"] { --fx: 0px; --fy: 38px; } .cv-new.swap[data-dir="up"] { --fx: 0px; --fy: -38px; }
.cv-new.swap[data-dir="none"] { --fx: 0px; --fy: 0px; }
@keyframes galArt { from { opacity: 0; transform: translate(var(--fx, 0), var(--fy, 0)) scale(.985); } }
.gnav { position: absolute; top: 50%; width: 46px; height: 46px; margin-top: -23px; display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .22); background: rgba(10, 15, 36, .62); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: #fff; cursor: pointer; transition: background .2s, transform .25s var(--ease); }
.gnav.l { left: 8px; } .gnav.r { right: 8px; }
.gnav:hover { background: rgba(10, 15, 36, .9); transform: scale(1.08); }
.gnav svg { width: 20px; height: 20px; }

.gal-strip { display: flex; justify-content: center; gap: 10px; overflow-x: auto; padding: 6px 4px; scrollbar-width: thin; }
.gs { position: relative; flex: 0 0 auto; width: clamp(104px, 11vw, 148px); display: grid; gap: 6px; padding: 5px 5px 7px; text-align: left; border: 1.5px solid var(--line); border-radius: 13px; background: var(--g-panel); cursor: pointer; transition: transform .3s var(--ease), border-color .2s, background .2s; animation: rise .5s var(--ease) both; animation-delay: calc(var(--i) * 60ms); }
.gs:hover { transform: translateY(-3px); border-color: var(--line-2); }
.gs[data-on="1"] { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-3px); }
.gs-thumb { display: block; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #fff; }
.gs-thumb svg { display: block; width: 100%; height: 100%; }
.gs-name { font-size: 12.5px; font-weight: 700; padding: 0 2px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gal-hint { text-align: center; font-size: 12.5px; color: var(--muted); }
.gal-hint kbd { display: inline-block; min-width: 22px; margin: 0 3px 0 8px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--g-panel); font: 600 12px/1.3 var(--sans); color: var(--ink-2); text-align: center; }
@media (hover: none) { .gal-hint { display: none; } }

.gal-side { min-height: 0; overflow-y: auto; display: grid; gap: 16px; align-content: start; padding: clamp(14px, 1.8vw, 22px); border-radius: 22px; background: var(--g-panel); border: 1px solid var(--line); scrollbar-width: thin; }
.gs-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.gs-why { font: 600 clamp(18px, 1.8vw, 22px)/1.3 var(--display); letter-spacing: -.012em; text-wrap: pretty; }
.gs-block { display: grid; gap: 7px; padding-top: 14px; border-top: 1px solid var(--line); }
.gs-l { font-size: 13px; font-weight: 700; color: var(--muted); }
.gs-block .tchip { justify-self: start; }
.gs-check { font-size: 14.5px; color: var(--ink-2); text-wrap: pretty; }
.gs-data summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink); width: fit-content; }
.gs-data .datatable { color: var(--ink-2); }
.gs-orig .gthumb { border-radius: 8px; overflow: hidden; background: #fff; }
.gs-orig .gthumb img, .gs-orig .gthumb svg { display: block; width: 100%; height: auto; }
.gs-block .facts-chips { margin-top: 4px; }
.gs-block .facts-chips li { background: var(--accent-soft); color: var(--ink); }
.gs-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-top: 4px; }
.gs-acts .ghost { color: var(--ink); border-color: var(--line-2); }

/* side by side */
.gal-grid { display: none; min-height: 0; }
.gal[data-mode="grid"] .gal-stage, .gal[data-mode="grid"] .gal-reel, .gal[data-mode="grid"] .gal-hint, .gal[data-mode="grid"] .gal-side { display: none; }
.gal[data-mode="grid"] .gal-main { grid-template-columns: minmax(0, 1fr); }
.gal[data-mode="grid"] .gal-center { grid-template-rows: minmax(0, 1fr); }
.gal[data-mode="grid"] .gal-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(12px, 1.6vw, 20px); align-content: flex-start; overflow-y: auto; padding: 4px 4px 16px; }
.gal-grid.swap { animation: galArt .5s var(--ease) both; --fx: 0px; --fy: 30px; }
.gal-hd { display: grid; gap: clamp(8px, 1.2vw, 12px); }
.gg { position: relative; flex: 1 1 340px; max-width: 440px; display: grid; align-content: start; border-radius: 18px; overflow: hidden; background: var(--surface); border: 1.5px solid var(--line); animation: ggIn .55s var(--ease) both; animation-delay: calc(var(--i) * 80ms); transition: border-color .2s, box-shadow .3s; }
@keyframes ggIn { from { opacity: 0; transform: translateY(26px) scale(.96); } }
.gg[data-picked="1"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.gg-art { display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0; background: #fff; cursor: zoom-in; }
.gg-art svg { display: block; width: 100%; height: 100%; }
.gg-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px 14px; }
.gg-foot .pick { margin-left: auto; }

@media (max-width: 900px) {
  .gal { overflow-y: auto; }
  .gal-in { height: auto; min-height: 100%; }
  .gal-main { grid-template-columns: minmax(0, 1fr); }
  .gal-stage { container-type: normal; }
  .gal-art, .gal-art { width: 100%; }
  .gal-side { overflow: visible; }
  .gal-strip { justify-content: flex-start; }
  .gnav { width: 40px; height: 40px; margin-top: -20px; }
  .gal-tools { width: 100%; justify-content: space-between; }
  .gal[data-mode="grid"] .gal-grid { overflow: visible; }
}
