/* =============================================================================
 * SONOYA - nb-video.css
 * -----------------------------------------------------------------------------
 * Composants shorts videos vendeur (D-024) :
 *   - nb-video-card       : card d'un short (rail home + feed page shorts)
 *   - nb-video-rail       : rail horizontal scroll-snap
 *   - nb-video-feed       : feed vertical fullscreen (TikTok-like)
 *   - nb-video-player     : player fullscreen avec controls custom
 *   - nb-video-actions    : boutons like/share/comment sur le player
 *   - nb-video-showcase   : produits lies a la video (sidebar / bottom sheet)
 * ============================================================================= */

@layer components {

  /* ===============================================
   * nb-video-card - Card thumb dans rail/grille
   * =============================================== */
  .nb-video-card {
    position: relative;
    display: block;
    color: var(--nb-color-text);
    text-decoration: none;
    isolation: isolate;
    transition: transform var(--nb-dur-fast) var(--nb-ease-out-quart);
  }
  .nb-video-card:hover {
    transform: translateY(-4px);
    color: var(--nb-color-text);
  }

  .nb-video-card__media {
    position: relative;
    aspect-ratio: 9 / 16;
    background: var(--nb-color-surface-sunk);
    border-radius: var(--nb-radius-lg);
    overflow: hidden;
    margin-bottom: var(--nb-space-2);
    isolation: isolate;
  }
  .nb-video-card__media > img,
  .nb-video-card__media > video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--nb-dur-slow) var(--nb-ease-out-quart);
  }
  .nb-video-card:hover .nb-video-card__media > img { transform: scale(1.06); }
  .nb-video-card__media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 55%, oklch(0% 0 0 / 0.65) 100%);
    pointer-events: none;
    z-index: 1;
  }

  .nb-video-card__duration {
    position: absolute;
    bottom: var(--nb-space-2);
    right: var(--nb-space-2);
    padding: 2px 6px;
    background: oklch(0% 0 0 / 0.78);
    color: white;
    font-size: 0.66rem;
    font-variant-numeric: tabular-nums;
    border-radius: var(--nb-radius-xs);
    z-index: 2;
    backdrop-filter: blur(4px);
  }

  .nb-video-card__promoted {
    position: absolute;
    top: var(--nb-space-2);
    right: var(--nb-space-2);
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 6px;
    background: oklch(60% 0.22 300);
    color: white;
    font-size: 0.58rem;
    font-weight: var(--nb-fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--nb-ls-wider);
    border-radius: var(--nb-radius-xs);
    z-index: 2;
  }

  .nb-video-card__play {
    position: absolute;
    inset: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: oklch(0% 0 0 / 0);
    color: white;
    opacity: 0;
    transition: opacity var(--nb-dur-fast) var(--nb-ease-standard),
                background var(--nb-dur-normal) var(--nb-ease-standard);
    z-index: 2;
  }
  .nb-video-card:hover .nb-video-card__play {
    opacity: 1;
    background: oklch(0% 0 0 / 0.28);
  }
  .nb-video-card__play-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: oklch(100% 0 0 / 0.20);
    border: 2px solid white;
    border-radius: 50%;
    backdrop-filter: blur(10px);
    transform: scale(0.9);
    transition: transform var(--nb-dur-normal) var(--nb-ease-spring);
  }
  .nb-video-card:hover .nb-video-card__play-icon { transform: scale(1); }

  .nb-video-card__quick-stats {
    position: absolute;
    bottom: var(--nb-space-2);
    left: var(--nb-space-2);
    display: inline-flex;
    align-items: center;
    gap: var(--nb-space-2);
    z-index: 2;
    font-size: 0.6rem;
    color: white;
    font-variant-numeric: tabular-nums;
    font-weight: var(--nb-fw-semibold);
    text-shadow: 0 1px 2px oklch(0% 0 0 / 0.6);
  }
  .nb-video-card__quick-stat {
    display: inline-flex;
    align-items: center;
    gap: 2px;
  }

  .nb-video-card__meta {
    padding-inline: var(--nb-space-1);
  }
  .nb-video-card__seller {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: var(--nb-fw-bold);
    color: var(--nb-color-text-strong);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .nb-video-card__seller-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--nb-color-accent);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    font-weight: var(--nb-fw-bold);
    flex-shrink: 0;
  }
  .nb-video-card__title {
    font-size: 0.72rem;
    color: var(--nb-color-text-muted);
    line-height: var(--nb-lh-snug);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 2px;
  }
  .nb-video-card__stats {
    display: inline-flex;
    align-items: center;
    gap: var(--nb-space-2);
    margin-top: var(--nb-space-1);
    font-size: 0.66rem;
    color: var(--nb-color-text-faint);
    font-variant-numeric: tabular-nums;
  }
  .nb-video-card__stat {
    display: inline-flex;
    align-items: center;
    gap: 3px;
  }


  /* ===============================================
   * nb-video-rail - Rail horizontal scroll-snap (home)
   * =============================================== */
  .nb-video-rail {
    display: flex;
    gap: var(--nb-space-3);
    overflow-x: auto;
    overflow-y: hidden;
    padding-block: var(--nb-space-2);
    padding-inline: 2px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-padding-inline: var(--nb-container-pad);
  }
  .nb-video-rail::-webkit-scrollbar { display: none; }
  .nb-video-rail > .nb-video-card {
    flex: 0 0 180px;
    scroll-snap-align: start;
  }
  @media (max-width: 640px) {
    .nb-video-rail > .nb-video-card { flex-basis: 140px; }
  }


  /* ===============================================
   * nb-video-feed - Feed vertical fullscreen (page /shorts)
   * =============================================== */
  .nb-video-feed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: black;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: var(--nb-z-dialog);
  }
  .nb-video-feed__scroll {
    flex: 1;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .nb-video-feed__scroll::-webkit-scrollbar { display: none; }
  .nb-video-feed__item {
    position: relative;
    height: 100dvh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    align-items: center;
    justify-content: center;
    background: black;
    overflow: hidden;
  }
  .nb-video-feed__item > video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-width: 100vw;
  }


  /* ===============================================
   * nb-video-player - Overlay actions (like/share/comment) + info seller
   * =============================================== */
  .nb-video-player__overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
  }
  .nb-video-player__overlay > * { pointer-events: auto; }

  .nb-video-player__info {
    position: absolute;
    bottom: var(--nb-space-16);
    left: var(--nb-space-4);
    right: 80px;
    color: white;
    display: flex;
    flex-direction: column;
    gap: var(--nb-space-2);
    text-shadow: 0 2px 6px oklch(0% 0 0 / 0.65);
  }
  .nb-video-player__seller {
    display: inline-flex;
    align-items: center;
    gap: var(--nb-space-2);
    font-family: var(--nb-font-heading);
    font-size: var(--nb-fs-sm);
    font-weight: var(--nb-fw-bold);
  }
  .nb-video-player__seller-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--nb-color-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: var(--nb-fw-bold);
    border: 2px solid white;
    flex-shrink: 0;
  }
  .nb-video-player__follow-btn {
    margin-inline-start: var(--nb-space-2);
    padding: 4px 12px;
    background: transparent;
    color: white;
    border: 2px solid var(--nb-color-accent);
    border-radius: var(--nb-radius-pill);
    font-size: 0.7rem;
    font-weight: var(--nb-fw-bold);
    text-transform: uppercase;
    letter-spacing: var(--nb-ls-wide);
    cursor: pointer;
    transition: background var(--nb-dur-fast) var(--nb-ease-standard);
  }
  .nb-video-player__follow-btn:hover { background: var(--nb-color-accent); }
  .nb-video-player__follow-btn.is-following { border-color: white; opacity: 0.85; }

  .nb-video-player__title {
    font-size: var(--nb-fs-sm);
    font-weight: var(--nb-fw-semibold);
    line-height: var(--nb-lh-snug);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .nb-video-player__desc {
    font-size: 0.78rem;
    opacity: 0.9;
    line-height: var(--nb-lh-snug);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Actions sidebar (like, comment, share, buy product) */
  .nb-video-player__actions {
    position: absolute;
    right: var(--nb-space-3);
    bottom: var(--nb-space-16);
    display: flex;
    flex-direction: column;
    gap: var(--nb-space-4);
    align-items: center;
  }
  .nb-video-player__action {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: transparent;
    color: white;
    border: 0;
    cursor: pointer;
    padding: 0;
  }
  .nb-video-player__action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: oklch(100% 0 0 / 0.15);
    border-radius: 50%;
    backdrop-filter: blur(10px);
    transition: transform var(--nb-dur-fast) var(--nb-ease-spring),
                background var(--nb-dur-fast) var(--nb-ease-standard);
  }
  .nb-video-player__action:hover .nb-video-player__action-icon {
    transform: scale(1.1);
    background: oklch(100% 0 0 / 0.25);
  }
  .nb-video-player__action:active .nb-video-player__action-icon {
    transform: scale(0.9);
  }
  .nb-video-player__action--liked .nb-video-player__action-icon {
    background: var(--nb-color-danger);
  }
  .nb-video-player__action--liked svg { fill: white; }
  .nb-video-player__action-label {
    font-size: 0.66rem;
    font-weight: var(--nb-fw-bold);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 3px oklch(0% 0 0 / 0.65);
  }
  .nb-video-player__action--product .nb-video-player__action-icon {
    background: var(--nb-color-accent);
    box-shadow: 0 0 20px var(--nb-color-accent-glow);
  }

  /* Instructions swipe (visible au premier chargement) */
  .nb-video-player__hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: var(--nb-space-2);
    padding: var(--nb-space-4) var(--nb-space-6);
    background: oklch(0% 0 0 / 0.55);
    color: white;
    border-radius: var(--nb-radius-lg);
    backdrop-filter: blur(10px);
    animation: nb-video-hint 3s var(--nb-ease-out-expo) forwards;
    pointer-events: none;
  }
  @keyframes nb-video-hint {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    20%, 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(0.95); }
  }

  /* Progress bar en bas */
  .nb-video-player__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: oklch(100% 0 0 / 0.15);
    z-index: 4;
  }
  .nb-video-player__progress-bar {
    height: 100%;
    background: var(--nb-color-accent);
    transform-origin: left;
    transform: scaleX(0);
    transition: transform var(--nb-dur-fast) linear;
  }


  /* ===============================================
   * nb-video-showcase - Sheet produits lies a la video
   * =============================================== */
  .nb-video-showcase {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 60vh;
    background: var(--nb-color-surface);
    border-radius: var(--nb-radius-2xl) var(--nb-radius-2xl) 0 0;
    padding: var(--nb-space-4);
    overflow-y: auto;
    z-index: 5;
    transform: translateY(100%);
    transition: transform var(--nb-dur-slow) var(--nb-ease-out-expo);
  }
  .nb-video-showcase.is-open { transform: translateY(0); }
  .nb-video-showcase__handle {
    display: block;
    width: 40px;
    height: 4px;
    background: var(--nb-color-border-strong);
    border-radius: var(--nb-radius-pill);
    margin: 0 auto var(--nb-space-3);
  }
  .nb-video-showcase__title {
    font-family: var(--nb-font-heading);
    font-size: var(--nb-fs-md);
    font-weight: var(--nb-fw-bold);
    color: var(--nb-color-text-strong);
    margin-bottom: var(--nb-space-3);
  }


  /* ===============================================
   * Responsive
   * =============================================== */
  @media (max-width: 768px) {
    .nb-video-player__actions { bottom: var(--nb-space-24); }
    .nb-video-player__info { bottom: var(--nb-space-20); right: 72px; }
  }
}
