/* QPal LET video-guide launcher and lazy in-app player. */

.qpal-let-video-guide-launcher {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  box-sizing: border-box;
  margin: 0 0 10px;
  padding: 0;
}

.qpal-let-video-guide-launcher[hidden] {
  display: none !important;
}

.qpal-let-video-guide-pill {
  min-width: 0;
  max-width: min(100%, 330px);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 11px 8px 9px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-elevated) 92%, var(--accent-soft));
  color: var(--text-primary);
  box-shadow: var(--shadow-control), var(--inner-highlight);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.qpal-let-video-guide-pill:hover {
  transform: translateY(-1px);
  border-color: var(--accent-border);
  background: color-mix(in srgb, var(--surface-hover) 88%, var(--accent-soft));
}

.qpal-let-video-guide-pill:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 44%, transparent);
  outline-offset: 3px;
}

.qpal-let-video-pill-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent-border);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.qpal-let-video-pill-icon svg {
  width: 18px;
  height: 18px;
}

.qpal-let-video-pill-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.qpal-let-video-pill-copy strong {
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.qpal-let-video-pill-copy small {
  overflow-wrap: anywhere;
  color: var(--text-secondary);
  font-size: 9px;
  font-weight: 650;
  line-height: 1.3;
}

.qpal-let-video-pill-chevron {
  color: var(--text-secondary);
  font-size: 23px;
  line-height: 1;
}

body.qpal-let-video-guide-open {
  overflow: hidden;
}

.qpal-let-video-guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 11200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  background: var(--overlay-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.qpal-let-video-guide-panel,
.qpal-let-video-guide-panel.qpal-popup-height-limited {
  width: min(780px, calc(100vw - 32px));
  max-height: min(920px, calc(100dvh - 32px)) !important;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  background: var(--surface-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-dialog), var(--inner-highlight);
}

.qpal-let-video-guide-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: start;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.qpal-let-video-guide-heading {
  min-width: 0;
  display: grid;
  gap: var(--qpal-popup-heading-gap, 1.8px);
}

.qpal-let-video-guide-heading > * {
  margin: 0;
}

.qpal-let-video-guide-heading > span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.qpal-let-video-guide-heading h2 {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.qpal-let-video-guide-heading p {
  max-width: 64ch;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}

.qpal-let-video-guide-close {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.qpal-let-video-guide-close:hover,
.qpal-let-video-guide-close:focus-visible {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.qpal-let-video-guide-close:focus-visible,
.qpal-let-video-preview:focus-visible,
.qpal-let-video-completion:focus-visible,
.qpal-let-video-thumbnail-fallback:focus-visible,
.qpal-let-video-player-fallback a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 44%, transparent);
  outline-offset: 3px;
}

.qpal-let-video-guide-progress {
  display: grid;
  gap: 8px;
  padding: 13px 22px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-muted);
}

.qpal-let-video-guide-progress strong {
  font-size: 11px;
  font-weight: 800;
  line-height: 1.3;
}

.qpal-let-video-progress-bar {
  --qpal-let-video-progress: 0%;
  position: relative;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-secondary) 14%, transparent);
}

.qpal-let-video-progress-bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--qpal-let-video-progress);
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.qpal-let-video-list {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 22px calc(22px + env(safe-area-inset-bottom));
}

.qpal-let-video-card {
  min-width: 0;
  align-self: start;
  display: grid;
  gap: 11px;
  padding: 13px;
  border: 1px solid var(--border-subtle);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--inner-highlight);
}

.qpal-let-video-card-heading {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.qpal-let-video-card-heading > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.qpal-let-video-card-heading > div > span {
  color: var(--accent);
  font-size: 9px;
  font-weight: 850;
  line-height: 1.2;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.qpal-let-video-card-heading h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.28;
}

.qpal-let-video-status {
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 8px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

.qpal-let-video-status.is-completed {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(52, 211, 153, 0.1);
  color: #16845b;
}

.dark-mode .qpal-let-video-status.is-completed {
  color: #6ee7b7;
}

.qpal-let-video-preview,
.qpal-let-video-player-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: #111;
}

.qpal-let-video-preview {
  display: grid;
  place-items: center;
  padding: 0;
  color: #fff;
  cursor: pointer;
}

.qpal-let-video-preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 160ms ease;
}

.qpal-let-video-card.is-thumbnail-ready .qpal-let-video-preview img {
  opacity: 0.82;
}

.qpal-let-video-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0, 0, 0, 0.35));
}

.qpal-let-video-play {
  position: relative;
  z-index: 2;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.58);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  transition: transform 150ms ease, background 150ms ease;
}

.qpal-let-video-preview:hover .qpal-let-video-play {
  transform: scale(1.04);
  background: rgba(0, 0, 0, 0.72);
}

.qpal-let-video-play svg {
  width: 28px;
  height: 28px;
}

.qpal-let-video-thumbnail-status {
  position: absolute;
  z-index: 2;
  inset: auto 10px 8px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 9px;
  font-weight: 700;
  text-align: left;
}

.qpal-let-video-card.is-thumbnail-ready .qpal-let-video-thumbnail-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.qpal-let-video-preview-unavailable {
  display: none;
  position: relative;
  z-index: 2;
  font-size: 12px;
  font-weight: 800;
}

.qpal-let-video-card.is-thumbnail-unavailable .qpal-let-video-play,
.qpal-let-video-card.is-thumbnail-unavailable .qpal-let-video-preview img {
  display: none;
}

.qpal-let-video-card.is-thumbnail-unavailable .qpal-let-video-preview-unavailable {
  display: block;
}

.qpal-let-video-thumbnail-fallback {
  justify-self: start;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  text-decoration: none;
}

.qpal-let-video-player-shell iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
}

.qpal-let-video-player-fallback {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  color: var(--text-secondary);
  font-size: 9px;
}

.qpal-let-video-player-fallback a {
  color: var(--accent);
  font-weight: 800;
}

.qpal-let-video-completion {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text-primary);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.qpal-let-video-completion:hover {
  background: var(--surface-hover);
}

.qpal-let-video-completion.is-completed {
  border-color: rgba(52, 211, 153, 0.42);
  background: rgba(52, 211, 153, 0.1);
  color: #16845b;
}

.dark-mode .qpal-let-video-completion.is-completed {
  color: #6ee7b7;
}

.qpal-let-video-completion small {
  color: inherit;
  font-size: 9px;
  font-weight: 700;
  opacity: 0.78;
}

.qpal-let-video-empty {
  grid-column: 1 / -1;
  min-height: 270px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 30px;
  border: 1px dashed var(--border-subtle);
  border-radius: 15px;
  background: var(--surface-muted);
  text-align: center;
}

.qpal-let-video-empty-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent-border);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.qpal-let-video-empty-icon svg {
  width: 24px;
  height: 24px;
}

.qpal-let-video-empty h3,
.qpal-let-video-empty p {
  margin: 0;
}

.qpal-let-video-empty h3 {
  font-size: 17px;
  font-weight: 800;
}

.qpal-let-video-empty p {
  max-width: 43ch;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 700px) {
  .qpal-let-video-guide-overlay {
    align-items: stretch;
    padding: 0;
  }

  .qpal-let-video-guide-panel,
  .qpal-let-video-guide-panel.qpal-popup-height-limited {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh !important;
    border: 0;
    border-radius: 0;
  }

  .qpal-let-video-guide-header {
    padding: max(16px, env(safe-area-inset-top)) 16px 14px;
  }

  .qpal-let-video-guide-progress {
    padding-inline: 16px;
  }

  .qpal-let-video-list {
    grid-template-columns: minmax(0, 1fr);
    padding: 15px 16px calc(20px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .qpal-let-video-guide-launcher {
    margin-bottom: 8px;
  }

  .qpal-let-video-guide-pill {
    max-width: min(100%, 300px);
    grid-template-columns: 31px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 7px 10px 7px 8px;
  }

  .qpal-let-video-pill-icon {
    width: 31px;
    height: 31px;
  }

  .qpal-let-video-guide-heading h2 {
    font-size: 20px;
  }

  .qpal-let-video-guide-heading p {
    font-size: 12px;
  }

  .qpal-let-video-guide-header {
    grid-template-columns: minmax(0, 1fr) 38px;
    gap: 10px;
  }

  .qpal-let-video-guide-close {
    width: 36px;
    height: 36px;
  }

  .qpal-let-video-card-heading {
    display: grid;
  }

  .qpal-let-video-status {
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .qpal-let-video-guide-pill,
  .qpal-let-video-play,
  .qpal-let-video-progress-bar::after {
    transition: none;
  }
}
