/* Shared styles: progressive image, viewer, toast. Designs theme them through --wv-* / --wg-* variables. */

.wg-img {
  position: relative;
  margin: 0;
  overflow: hidden;
  aspect-ratio: var(--ratio);
  background: #ddd;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}
.wg-img > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: var(--wg-fit, cover);
  object-position: var(--wg-pos, 50% 50%);
  user-select: none;
  -webkit-user-drag: none;
}
.wg-img .wg-lq {
  filter: blur(14px);
  transform: scale(1.12);
}
.wg-img .wg-full {
  opacity: 0;
  transition: opacity .5s ease, transform .6s cubic-bezier(.2, .7, .2, 1);
}
.wg-img.is-loaded .wg-full { opacity: 1; }
.wg-img:focus-visible { outline: 2px solid var(--wg-focus, currentColor); outline-offset: 3px; }
@media (hover: hover) {
  .wg-img:hover .wg-full { transform: scale(var(--wg-hover-scale, 1.025)); }
}

/* ---------- viewer ---------- */
html.wv-lock, html.wv-lock body { overflow: hidden; overscroll-behavior: none; }

.wv {
  --wv-bg: #0b0b0c;
  --wv-fg: #f4f1ea;
  --wv-muted: rgba(244, 241, 234, .6);
  --wv-accent: #f4f1ea;
  --wv-font: inherit;
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  color: var(--wv-fg);
  font-family: var(--wv-font);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: contain;
}
.wv.is-open { display: block; }
.wv.is-fading { opacity: 0; transition: opacity .22s; }
.wv-bg { position: absolute; inset: 0; background: var(--wv-bg); }
.wv-stage { position: absolute; inset: 0; overflow: hidden; }
.wv-slide { position: absolute; inset: 0; will-change: transform; }
.wv-box {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: 50% 50%;
  cursor: zoom-in;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
.wv.is-zoomed .wv-box { cursor: grab; box-shadow: none; }
.wv.is-dragging .wv-box { cursor: grabbing; }
.wv.is-dragging .wv-box, .wv.is-animating .wv-box { will-change: transform; }
.wv-box img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.wv-lo { filter: blur(18px); transform: scale(1.05); }
.wv-mid, .wv-hi { opacity: 0; transition: opacity .35s; }
.has-mid .wv-mid { opacity: 1; }
.has-hi .wv-hi { opacity: 1; }

.wv-ui { position: absolute; inset: 0; pointer-events: none; transition: opacity .25s; }
.wv.is-chrome-hidden .wv-ui, .wv.is-dragging .wv-ui, .wv.is-closing .wv-ui { opacity: 0; }
.wv.is-chrome-hidden .wv-ui * { pointer-events: none !important; }
.wv-top, .wv-bottom {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
}
.wv-top {
  top: 0;
  justify-content: space-between;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--wv-bg) 70%, transparent), transparent);
}
.wv-bottom {
  bottom: 0;
  flex-direction: column;
  gap: 4px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, color-mix(in srgb, var(--wv-bg) 70%, transparent), transparent);
  text-align: center;
}
.wv-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.wv-count { font-variant-numeric: tabular-nums; font-size: 13px; letter-spacing: .08em; }
.wv-chapter { font-size: 12px; color: var(--wv-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wv-caption { margin: 0; font-size: 14px; color: var(--wv-fg); }
.wv-caption:empty { display: none; }
.wv-hint { font-size: 11px; letter-spacing: .1em; color: var(--wv-muted); }
@media (hover: hover) and (pointer: fine) { .wv-hint { display: none; } }

.wv-actions { display: flex; gap: 2px; pointer-events: auto; }
.wv-btn, .wv-nav {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
.wv-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  border-radius: 22px;
  text-decoration: none;
}
.wv-btn:hover { background: color-mix(in srgb, var(--wv-fg) 12%, transparent); }
.wv-btn:focus-visible, .wv-nav:focus-visible { outline: 1.5px solid color-mix(in srgb, var(--wv-fg) 55%, transparent); outline-offset: -3px; }
.wv:focus { outline: none; }

/* HD button: drawn badge + file size. The badge outline doubles as the progress bar. */
.wv-hd { grid-auto-flow: column; gap: 7px; padding: 0 12px 0 10px; }
.wv-hd small { color: var(--wv-muted); font: 500 11.5px/1 -apple-system, 'SF Pro Text', 'Helvetica Neue', 'PingFang SC', sans-serif; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.wv-hd-icon .hd-fill { fill: currentColor; stroke: none; opacity: 0; transition: opacity .25s; }
.wv-hd-icon .hd-prog { stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--progress, 0) * 100); opacity: 0; transition: stroke-dashoffset .2s linear; }
.wv-hd.is-loading .hd-base { opacity: .3; }
.wv-hd.is-loading .hd-prog { opacity: 1; }
.wv-hd.is-done .hd-fill, .wv-hd[aria-pressed="true"] .hd-fill { opacity: 1; }
.wv-hd.is-done .hd-glyph, .wv-hd[aria-pressed="true"] .hd-glyph { stroke: var(--wv-bg); }
@media (max-width: 420px) { .wv-hd small { display: none; } }

.wv-nav {
  position: absolute;
  top: 50%;
  width: 56px;
  height: 96px;
  margin-top: -48px;
  display: grid;
  place-items: center;
  opacity: .7;
}
.wv-nav:hover { opacity: 1; }
.wv-nav:disabled { opacity: 0; pointer-events: none; }
.wv-prev { left: max(4px, env(safe-area-inset-left)); }
.wv-next { right: max(4px, env(safe-area-inset-right)); }
@media (hover: none), (max-width: 767px) { .wv-nav { display: none; } }

/* ---------- toast ---------- */
.wg-toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 1100;
  transform: translate(-50%, 20px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(20, 20, 20, .88);
  color: #fff;
  font: 13px/1.3 system-ui, sans-serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  backdrop-filter: blur(8px);
}
.wg-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* WeChat crawls the first sizeable <img> in the body for its share thumbnail. Keep it in the DOM but out of sight. */
.wg-share-thumb { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .wg-img .wg-full, .wv-mid, .wv-hi { transition: none; }
}

/* Language toggle (designs restyle it). */
.wg-lang {
  appearance: none;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font: 500 12px/1 system-ui, -apple-system, 'PingFang SC', sans-serif;
  letter-spacing: .06em;
  padding: 7px 10px;
  border-radius: 999px;
  cursor: pointer;
  opacity: .8;
  -webkit-tap-highlight-color: transparent;
}
.wg-lang:hover { opacity: 1; }

/* Staggered story layout (Wedding.stagger). */
.ws-row { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); column-gap: var(--ws-gap, clamp(10px, 2vw, 32px)); align-items: start; margin-top: var(--ws-row-gap, clamp(28px, 7vw, 120px)); --ws-unit: clamp(10px, 2.4vw, 36px); }
.ws-row:first-child { margin-top: 0; }
.ws-cell { min-width: 0; }
.ws-cell .wg-img { width: 100%; }

/* The Chinese title is one phrase: never break it mid-line (designs size it to fit). */
:lang(zh) [data-i18n="title"] { white-space: nowrap; }
