/*
 * Shorts feed (themes/<theme>/views/shorts.ejs, public/shorts.js). One sheet for every theme: the feed is
 * dark like the video it shows, and takes its accent from the theme (--accent). Mobile first: on a phone the
 * feed is the whole screen, from 768px the site header stays and the feed is a 9:16 column under it.
 */

body.shorts-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* the visible height while mobile browser bars slide in and out */
  overflow: hidden;
  background: #000;
}
body.shorts-page .site-top,
body.shorts-page .pills,
body.shorts-page .site-footer { display: none; }
body.shorts-page main.container {
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.shorts {
  position: relative;
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
  background: #000;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}
.shorts [hidden] { display: none !important; }
.shorts-heading {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* One clip per screen: every swipe stops at the next slide. */
.shorts-track {
  height: 100%;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior-y: contain; /* no pull-to-refresh and no page scroll behind the feed */
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  outline: none;
}
.shorts-track::-webkit-scrollbar { display: none; }

.short {
  position: relative;
  height: 100%;
  overflow: hidden;
  background: #000;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.short-media { position: absolute; inset: 0; }
.short-poster,
.short-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* a clip much squarer than the screen is shown whole instead of losing its sides */
.short--contain .short-media video { object-fit: contain; }
.short-media video { opacity: 0; transition: opacity 0.15s; background: transparent; }
.short.is-playing .short-media video { opacity: 1; }
.short.is-playing.short--contain .short-poster { visibility: hidden; }

.short::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 45%;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  pointer-events: none;
}

.short-info {
  position: absolute;
  inset-inline: 12px 72px;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  z-index: 2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.short-title {
  display: -webkit-box;
  margin: 0 0 4px;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.short-meta { margin: 0 0 8px; font-size: 13px; opacity: 0.9; }
.short-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 44px; /* one row: a long translation must not push the title off the video */
  margin: 0;
  overflow: hidden;
}
.short-tags a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 13px;
  text-shadow: none;
  white-space: nowrap;
}
.short-tags a:hover { background: rgba(255, 255, 255, 0.3); color: #fff; }

/* states of the active slide */
.short-wait,
.short-paused {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: none;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.short.is-waiting .short-wait { display: block; }
.short.is-paused .short-paused {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
}
.short-error {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 24px 96px;
  background: rgba(0, 0, 0, 0.72);
  text-align: center;
}
.short-error p { margin: 0; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.short-error .short-error-hint { font-size: 13px; opacity: 0.8; }
.short-retry,
.shorts-status button {
  min-width: 120px;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 22px;
  background: var(--accent, #f90);
  color: #111;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* offer slide (ads.json popup.shortsEvery): the whole slide is the button */
.short--offer::after { display: none; }
.short-offer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  padding: 72px 24px;
  border: 0;
  background: radial-gradient(120% 80% at 50% 20%, #2b2b2b, #000);
  color: #fff;
  font: inherit;
  text-align: center;
  cursor: pointer;
}
.short-offer-label {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top, 0px));
  inset-inline-end: 14px;
  padding: 3px 10px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 12px;
}
.short-offer-title { font-size: 26px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.short-offer-sub { max-width: 30em; font-size: 15px; line-height: 1.4; opacity: 0.9; overflow-wrap: anywhere; }
.short-offer-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  margin-top: 8px;
  padding: 0 28px;
  border-radius: 26px;
  background: var(--accent, #f90);
  color: #111;
  font-size: 17px;
  font-weight: 700;
}

/* controls that stay in place while slides move under them */
.shorts-back {
  position: absolute;
  top: calc(6px + env(safe-area-inset-top, 0px));
  inset-inline-start: 4px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding-inline: 6px 14px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.shorts-back:hover { color: #fff; }
[dir='rtl'] .shorts-back svg { transform: scaleX(-1); }

.shorts-actions {
  position: absolute;
  inset-inline-end: 8px;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.shorts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  cursor: pointer;
}
.shorts-btn:hover,
.shorts-btn:focus-visible { background: rgba(0, 0, 0, 0.7); color: var(--accent, #f90); outline: none; }
#shortsMute .ic-sound-on,
#shortsMute.is-on .ic-sound-off { display: none; }
#shortsMute.is-on .ic-sound-on { display: block; }

.shorts-arrows { display: none; }

/* a 20px strip to hit, a 3px line to see */
.shorts-progress {
  position: absolute;
  inset: auto 0 env(safe-area-inset-bottom, 0px);
  z-index: 6;
  height: 20px;
  cursor: pointer;
  touch-action: none;
  outline: none;
}
.shorts-progress::before,
.shorts-progress-fill {
  content: '';
  position: absolute;
  inset: auto auto 0;
  inset-inline-start: 0;
  height: 3px;
}
.shorts-progress::before { width: 100%; background: rgba(255, 255, 255, 0.3); }
.shorts-progress-fill { width: 0; background: var(--accent, #f90); }
.shorts-progress:focus-visible::before { background: rgba(255, 255, 255, 0.6); }

.shorts.is-offer .shorts-actions,
.shorts.is-offer .shorts-progress { display: none; }

.shorts-status {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: #000;
  font-size: 15px;
  text-align: center;
}
.shorts-spinner,
.short-wait {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: shorts-spin 0.8s linear infinite;
}
.short-wait { margin: -18px 0 0 -18px; transform: none; }
@keyframes shorts-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .shorts-spinner,
  .short-wait { animation-duration: 2.4s; }
  .short-media video { transition: none; }
}

/* above the middle: the title, the tags and the buttons stay readable under it */
.shorts-toast {
  position: absolute;
  left: 50%;
  top: 30%;
  z-index: 7;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 10px 16px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.78);
  font-size: 14px;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

@media (min-width: 768px) {
  body.shorts-page .site-top { display: block; flex: none; }
  .shorts {
    width: auto;
    max-width: 100%;
    aspect-ratio: 9 / 16;
    overflow: visible; /* the arrows stand next to the column */
  }
  .shorts-track { border-radius: 12px; }
  .shorts-back { display: none; }
  .shorts-arrows {
    position: absolute;
    top: 50%;
    inset-inline-start: calc(100% + 16px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transform: translateY(-50%);
  }
  .shorts-arrows .shorts-btn { background: rgba(255, 255, 255, 0.14); }
}
