/* The viewer: the art on a deep ink backdrop (so glossy colours glow), the words on paper beside
   it (below it on phones). */
.ss-viewer {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--color-ink);
  background:
    radial-gradient(ellipse 60% 50% at 30% 20%, rgba(242, 170, 182, 0.16), transparent 70%),
    radial-gradient(ellipse 50% 50% at 80% 90%, rgba(79, 196, 198, 0.12), transparent 70%),
    rgba(28, 24, 31, 0.96);
  overflow: hidden;
  overscroll-behavior: contain;
}
.ss-viewer::backdrop { background: rgba(28, 24, 31, 0.6); }
.ss-viewer[open] { animation: v-in 0.3s ease-out; }
.ss-viewer.closing { animation: v-out 0.24s ease-in forwards; }
@keyframes v-in { from { opacity: 0; } }
@keyframes v-out { to { opacity: 0; } }

.v-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(400px, 36vw);
  align-items: center;
  gap: clamp(20px, 3vw, 40px);
  width: min(1200px, 100%);
  height: 100%;
  margin: 0 auto;
  padding: 64px clamp(56px, 7vw, 96px) 40px;
}

/* ---------- the art ---------- */
.v-art {
  position: relative;
  justify-self: center;
  width: min(100%, calc((100dvh - 120px) * 0.8));
  aspect-ratio: 4 / 5;
  margin: 0;
  overflow: hidden;
  border-radius: 22px;
  background: var(--color-paper);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.7);
  animation: v-art 0.45s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes v-art { from { opacity: 0; translate: calc(var(--dir, 0) * 40px) 0; scale: calc(1 - (var(--dir, 0) * var(--dir, 0) * 0.02 + 0.02)); } }
.v-art .framed { width: 100%; height: 100%; }
.v-art .cover-caption { font-size: 9cqi; }
.v-tap { position: absolute; top: 0; bottom: 0; width: 33%; z-index: 1; }
.v-tap-prev { left: 0; }
.v-tap-next { right: 0; }

/* ---------- the words ---------- */
.v-info {
  align-self: center;
  max-height: calc(100dvh - 120px);
  overflow-y: auto;
  padding: clamp(22px, 2.6vw, 32px);
  border-radius: 26px;
  background: var(--color-paper);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.6);
  animation: v-art 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) 0.05s both;
}
.v-title {
  margin: 0;
  font: 700 clamp(34px, 3.4vw, 44px)/1 var(--font-hand);
  overflow-wrap: anywhere;
}
.v-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 0;
  font: italic 600 16px/1.2 var(--font-serif);
  color: var(--color-name);
}
.v-count { font-style: normal; font-family: var(--font-ui); font-size: 12px; font-weight: 600; opacity: 0.7; }
.v-text {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1.5px dashed rgba(36, 31, 38, 0.14);
  font: 500 18px/1.55 var(--font-serif);
  color: rgba(36, 31, 38, 0.86);
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.v-text a { color: var(--color-leaf-shade); }
.v-more {
  margin-top: 4px;
  padding: 2px 0;
  border: 0;
  background: none;
  font: 600 14px/1 var(--font-ui);
  color: var(--color-leaf-shade);
  cursor: pointer;
}
.v-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.v-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 99px;
  font: 600 14px/1 var(--font-ui);
  color: #fff;
  text-decoration: none;
  border: 2px solid var(--color-ink);
  box-shadow: 0 3px 0 var(--color-ink);
  transition: translate 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.v-link svg { width: 18px; }
.v-link:hover { translate: 0 -2px; }
.v-link.ig { background: linear-gradient(135deg, #f2a65a, #e0607e 55%, #9d5ac9); }
.v-link.yt { background: #e0403f; }

/* ---------- controls ---------- */
.v-close, .v-nav {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  transition: background 0.2s ease;
}
.v-close:hover, .v-nav:hover:not(:disabled) { background: rgba(255, 255, 255, 0.24); }
.v-close { top: 16px; right: 16px; width: 46px; height: 46px; }
.v-close svg { width: 22px; }
.v-nav { top: 50%; width: 50px; height: 50px; translate: 0 -50%; font: 400 34px/1 var(--font-ui); padding-bottom: 4px; }
.v-prev { left: 16px; }
.v-next { right: 16px; }
.v-nav:disabled { opacity: 0.2; cursor: default; }
:is(.v-close, .v-nav, .v-link, .v-more):focus-visible { outline: 2.5px solid var(--color-leaf-light); outline-offset: 3px; }

/* story progress */
.v-bars { position: absolute; top: 12px; left: 16px; right: 74px; z-index: 3; display: flex; gap: 4px; }
.v-bar { flex: 1; height: 3px; overflow: hidden; border-radius: 99px; background: rgba(255, 255, 255, 0.25); }
.v-bar i { display: block; width: 0; height: 100%; background: #fff; }
.story .v-nav { display: none; }

/* ---------- phones: art on top, the words underneath (description folded to 4 lines) ---------- */
@media (max-width: 760px) {
  .v-stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-content: start;
    align-items: start;
    gap: 14px;
    height: 100%;
    padding: 58px 14px 20px;
    overflow-y: auto;
  }
  .v-art { width: min(100%, calc((100dvh - 260px) * 0.8)); border-radius: 18px; }
  .v-info { max-height: none; overflow: visible; padding: 18px 18px 20px; border-radius: 20px; }
  .v-title { font-size: 34px; }
  .v-text { font-size: 17px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
  .v-text.open { display: block; -webkit-line-clamp: unset; }
  .v-nav { display: none; }
  /* gallery mode keeps small ‹ › buttons, top left (stories step by tapping the edges) */
  .gallery .v-nav { display: grid; top: 10px; translate: none; width: 40px; height: 40px; font-size: 28px; }
  .gallery .v-prev { left: 10px; }
  .gallery .v-next { left: 58px; right: auto; }
  .v-stage { touch-action: pan-y; }
  .v-close { top: 10px; right: 10px; width: 40px; height: 40px; }
  .v-bars { top: 22px; right: 62px; }
}

@media (prefers-reduced-motion: reduce) {
  .ss-viewer[open], .ss-viewer.closing, .v-art, .v-info { animation: none; }
}
