/* «Hekayə» (spec docs/story-tech.md): the month as stories over the whole screen — on a phone the slide is the screen,
   on a computer it stands in the middle on the theme's dark, blurred with the brand. The slide itself is a canvas
   (js/story/draw.js); here are its frame, the bars, the taps and the buttons. */
body.story-open { overflow: hidden; }
.story {
  position: fixed; inset: 0; z-index: calc(var(--z-toast) - 1);
  display: grid; grid-template-rows: 1fr auto; justify-items: center; align-items: center;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  background:
    radial-gradient(70% 55% at 85% 10%, color-mix(in srgb, var(--accent) 45%, transparent), transparent 70%),
    radial-gradient(60% 50% at 10% 95%, color-mix(in srgb, var(--signal) 30%, transparent), transparent 70%),
    var(--hero-bg, #141218);
  color: #fff;
}
.story__stage {
  position: relative; overflow: hidden;
  height: min(100%, calc(100vw * 16 / 9)); aspect-ratio: 9 / 16; max-width: 100vw;
  border-radius: 0; background: #000;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
@media (min-width: 640px) {
  .story { padding: 24px 0 12px; }
  .story__stage { height: min(calc(100dvh - 120px), 900px); border-radius: 22px; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .06); }
}
.story__canvas { display: block; width: 100%; height: 100%; }

/* the bars: one a slide; the running one fills over the slide's time, paused with the story */
.story__bars { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 3; display: flex; gap: 4px; pointer-events: none; }
.story__bar { flex: 1; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .32); overflow: hidden; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.story__bar i { display: block; width: 0; height: 100%; background: #fff; }
.story__bar.is-done i { width: 100%; }
.story__bar.is-current i { animation: story-fill var(--dur, 6500ms) linear forwards; }
.story.is-paused .story__bar.is-current i { animation-play-state: paused; }
@keyframes story-fill { to { width: 100%; } }

.story__top { position: absolute; top: 20px; left: 8px; right: 8px; z-index: 3; display: flex; align-items: center; justify-content: flex-end; gap: 8px; pointer-events: none; }
.story__top > * { pointer-events: auto; }
.story__month { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 2px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 99px; background: rgba(255, 255, 255, .08); font-size: 13px; font-weight: 600; }
.story__month span { padding: 0 4px; white-space: nowrap; }
.story__icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 99px; background: transparent; color: #fff; cursor: pointer; }
.story__top > .story__icon { background: rgba(0, 0, 0, .28); backdrop-filter: blur(8px); }
.story__icon:disabled { opacity: .35; cursor: default; }
.story__icon:focus-visible, .story__btn:focus-visible, .story__tap:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }

/* the taps: the left third back, the rest forward; the top's buttons stay above them */
.story__tap { position: absolute; top: 70px; bottom: 0; z-index: 2; border: 0; padding: 0; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.story__tap--prev { left: 0; width: 32%; }
.story__tap--next { right: 0; width: 68%; }

/* the loyal client's slide: a card for her, made from here */
.story__cta { position: absolute; left: 0; right: 0; bottom: 7%; z-index: 4; display: flex; justify-content: center; }
.story__cta .btn { box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .55); }

.story__empty { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 32px; text-align: center; color: rgba(255, 255, 255, .78); background: var(--hero-bg, #141218); }
.story__empty .ic { width: 40px; height: 40px; color: var(--signal); }
.story__empty-title { font: var(--display-weight) 22px/1.25 var(--font-display); color: #fff; }

.story__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding: 10px 12px 12px; }
.story__btns { display: flex; gap: 8px; }
.story__btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 99px; background: rgba(255, 255, 255, .08); color: #fff; font: 600 14px/1 var(--font-body); cursor: pointer; text-decoration: none; }
.story__btn:hover { background: rgba(255, 255, 255, .16); }
.story__btn--main { background: #fff; border-color: #fff; color: #111; }
.story__btn--main:hover { background: #f0f0f0; }
@media (max-width: 639px) {
  .story { grid-template-rows: 1fr; }
  .story__stage { height: 100%; width: 100%; aspect-ratio: auto; background: linear-gradient(var(--story-top, #000) 50%, var(--story-bottom, #000) 50%); }
  .story__canvas { object-fit: contain; }
  .story__actions { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 6px); z-index: 4; justify-content: center; padding: 0 12px; }
  .story__btn, .story__month { background: rgba(0, 0, 0, .35); backdrop-filter: blur(10px); }
  .story__actions { flex-direction: column; }
  .story__btn--main { background: #fff; }
  .story__cta { bottom: calc(env(safe-area-inset-bottom) + 124px); }
}
@media (prefers-reduced-motion: reduce) { .story__bar.is-current i { animation-duration: var(--dur, 6500ms); } }

/* the entrances to the story: the dashboard's card in the month's first days, the reports' line */
.story-entry { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 0; color: #fff; text-decoration: none;
  background: radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--signal) 55%, transparent), transparent 60%), var(--hero-bg, #141218); }
.story-entry__icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 14px; background: rgba(255, 255, 255, .14); color: #fff; }
.story-entry b { display: block; font: var(--display-weight) 17px/1.25 var(--font-display); }
.story-entry small { display: block; margin-top: 2px; color: rgba(255, 255, 255, .72); font-size: 13px; }
.story-entry > .ic:last-child { margin-left: auto; opacity: .7; }

/* a client's card (templates in index.html): the picture as a phone shows it, its period and look */
.story-card { max-width: 520px; }
.story-card__body { display: grid; gap: 12px; justify-items: center; }
.story-card__phone { width: min(280px, 64vw); aspect-ratio: 9 / 16; padding: 8px; border-radius: 34px; background: #0f0f10; box-shadow: var(--shadow-2), 0 30px 60px -30px rgba(0, 0, 0, .55); }
.story-card__phone img { width: 100%; height: 100%; border-radius: 27px; object-fit: cover; background: var(--surface); }
.story-card__seg { width: 100%; }
