/* Isolated layout for the dedicated Reel viewer. */
#videos-section.ihuza-reels-page {
  --ihuza-reel-height: min(calc(var(--app-viewport-height, 100vh) - 32px), 711.11px);
  --ihuza-reel-width: min(400px, calc(var(--ihuza-reel-height) * 9 / 16));
  height: var(--app-viewport-height, 100vh);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg, #000);
}

#videos-section.ihuza-reels-page > .ihuza-reel-shell {
  display: block;
  width: 100%;
  max-width: none;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  padding: 0;
  background: var(--bg, #000);
}

#videos-section .ihuza-reel-feed {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
  padding: 12px 24px;
}

#videos-section .ihuza-reel-card {
  box-sizing: border-box;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--ihuza-reel-width) 52px minmax(0, 1fr);
  align-items: stretch;
  column-gap: 12px;
  width: min(100%, 1160px);
  height: var(--ihuza-reel-height);
  min-width: 0;
  min-height: 0;
  max-height: calc(var(--app-viewport-height, 100vh) - 8px);
  margin: 0 auto 12px;
  overflow: visible;
  scroll-snap-align: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  isolation: isolate;
}

#videos-section .ihuza-reel-details {
  grid-column: 1;
  grid-row: 1;
  align-self: end;
  justify-self: end;
  display: grid;
  width: min(100%, 320px);
  min-width: 0;
  gap: 10px;
  margin: 0 8px 26px 0;
  color: #fff;
}

#videos-section .ihuza-reel-author {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: #fff;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

#videos-section .ihuza-reel-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid rgb(255 255 255 / 45%);
  border-radius: 50%;
  object-fit: cover;
}

#videos-section .ihuza-reel-identity {
  display: grid;
  min-width: 0;
  gap: 3px;
}

#videos-section .ihuza-reel-identity strong,
#videos-section .ihuza-reel-identity small {
  overflow: hidden;
  color: #fff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#videos-section .ihuza-reel-identity strong { font-size: 14px; font-weight: 650; }
#videos-section .ihuza-reel-identity small { color: rgb(255 255 255 / 75%); font-size: 12px; }

#videos-section .ihuza-reel-follow {
  justify-self: start;
  min-height: 32px;
  border: 1px solid rgb(255 255 255 / 48%);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  padding: 4px 12px;
  font: inherit;
  font-size: 12px;
}

#videos-section .ihuza-reel-caption {
  max-width: 320px;
  margin: 0;
  color: #f4f4f5;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

#videos-section .ihuza-reel-frame {
  box-sizing: border-box;
  position: relative;
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  width: var(--ihuza-reel-width);
  height: var(--ihuza-reel-height);
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 14%);
  border-radius: 12px;
  background: #000;
  box-shadow: 0 18px 48px rgb(0 0 0 / 35%);
}

#videos-section .ihuza-reel-video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  object-fit: contain;
  background: #000;
}

#videos-section .ihuza-reel-gradient {
  position: absolute;
  z-index: 1;
  inset: 0;
  background: linear-gradient(180deg, rgb(0 0 0 / 14%), transparent 34%, rgb(0 0 0 / 42%));
  pointer-events: none;
}

#videos-section .ihuza-reel-play,
#videos-section .ihuza-reel-sound {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 30%);
  border-radius: 50%;
  background: rgb(24 24 27 / 82%);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

#videos-section .ihuza-reel-play {
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  transform: translate(-50%, -50%);
  opacity: .92;
}

#videos-section .ihuza-reel-play.is-playing { opacity: 0; }
#videos-section .ihuza-reel-frame:hover .ihuza-reel-play.is-playing,
#videos-section .ihuza-reel-frame:focus-within .ihuza-reel-play.is-playing { opacity: .92; }

#videos-section .ihuza-reel-sound {
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
}

#videos-section .ihuza-reel-play .icon { width: 22px; height: 22px; }
#videos-section .ihuza-reel-sound .icon { width: 19px; height: 19px; }

#videos-section .ihuza-reel-loading,
#videos-section .ihuza-reel-empty {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  color: #fff;
  background: rgb(0 0 0 / 70%);
  padding: 24px;
  text-align: center;
}

#videos-section .ihuza-reel-loading[hidden] { display: none; }

#videos-section .ihuza-reel-retry {
  justify-self: center;
  min-height: 36px;
  border: 1px solid rgb(255 255 255 / 45%);
  border-radius: 999px;
  background: #27272a;
  color: #fff;
  padding: 4px 14px;
  cursor: pointer;
}

#videos-section .ihuza-reel-actions {
  grid-column: 3;
  grid-row: 1;
  align-self: end;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin: 0 0 20px;
  padding: 0;
}

#videos-section .ihuza-reel-actions button {
  display: flex;
  min-width: 44px;
  min-height: 44px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #f4f4f5;
  padding: 2px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

#videos-section .ihuza-reel-actions button:hover,
#videos-section .ihuza-reel-actions button.active { color: #ff4056; }
#videos-section .ihuza-reel-actions button:disabled { opacity: .45; cursor: not-allowed; }
#videos-section .ihuza-reel-actions .icon { width: 24px; height: 24px; color: currentColor; }

#videos-section .ihuza-reel-navigation {
  position: absolute;
  top: 50%;
  right: 0;
  display: grid;
  gap: 14px;
  transform: translateY(-50%);
}

#videos-section .ihuza-reel-navigation button {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #202126;
  color: #fff;
  cursor: pointer;
}

#videos-section .ihuza-reel-navigation button:disabled { opacity: .35; cursor: default; }
#videos-section .ihuza-reel-navigation .icon { width: 24px; height: 24px; }

#videos-section .ihuza-reel-follow,
#videos-section .ihuza-reel-actions button,
#videos-section .ihuza-reel-navigation button,
#videos-section .ihuza-reel-retry {
  transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), transform var(--motion-fast);
}

#videos-section .ihuza-reel-follow:hover:not(:disabled),
#videos-section .ihuza-reel-retry:hover:not(:disabled) {
  border-color: var(--brand-primary);
  background: color-mix(in srgb, var(--brand-primary) 18%, #111);
}

#videos-section :where(button, a, video):focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 3px;
}

#videos-section .ihuza-reel-caption { overflow-wrap: anywhere; }
#videos-section .ihuza-reels-exit { display: none; }

@media (prefers-reduced-motion: reduce) {
  #videos-section .ihuza-reel-follow,
  #videos-section .ihuza-reel-actions button,
  #videos-section .ihuza-reel-navigation button,
  #videos-section .ihuza-reel-retry { transition: none; }
}

@media (max-width: 900px) {
  #videos-section.ihuza-reels-page {
    position: relative;
    height: var(--app-viewport-height, 100vh);
    --ihuza-reel-height: min(calc(var(--app-viewport-height, 100vh) - 32px), 680px);
    --ihuza-reel-width: min(400px, calc(var(--ihuza-reel-height) * 9 / 16));
  }

  #videos-section .ihuza-reel-feed { padding: 8px 10px; }
  #videos-section .ihuza-reel-card {
    grid-template-columns: minmax(0, 1fr) 44px;
    column-gap: 8px;
    width: 100%;
    height: auto;
    min-height: var(--ihuza-reel-height);
    max-height: none;
  }
  #videos-section .ihuza-reel-frame {
    grid-column: 1;
    grid-row: 1;
    width: min(100%, var(--ihuza-reel-width));
    height: auto;
    max-height: var(--ihuza-reel-height);
    justify-self: end;
  }
  #videos-section .ihuza-reel-details {
    position: absolute;
    z-index: 2;
    right: 62px;
    bottom: 12px;
    left: 12px;
    width: auto;
    margin: 0;
    text-shadow: 0 1px 4px rgb(0 0 0 / 80%);
  }
  #videos-section .ihuza-reel-caption { font-size: 13px; }
  #videos-section .ihuza-reel-actions {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    gap: 10px;
    margin: 0 0 12px;
  }
  #videos-section .ihuza-reel-navigation { display: none; }
}

@media (max-width: 600px) {
  .app.reels-immersive > .app-main {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
  }
  .app.reels-immersive > .app-main > .mobile-header,
  .app.reels-immersive > .mobile-nav { display: none; }
  .app.reels-immersive > .app-main > #videos-section:not(.hidden) {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }
  #videos-section.ihuza-reels-page {
    height: var(--app-viewport-height, 100dvh);
    --ihuza-reel-height: var(--app-viewport-height, 100dvh);
    --ihuza-reel-width: 100vw;
  }
  .app.reels-immersive #videos-section .ihuza-reels-exit {
    position: absolute;
    z-index: 5;
    top: calc(12px + env(safe-area-inset-top));
    left: 14px;
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 8px;
    border: 1px solid rgb(255 255 255 / 22%);
    border-radius: 999px;
    background: rgb(0 0 0 / 38%);
    color: #fff;
    padding: 0 12px;
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    backdrop-filter: blur(12px);
  }
  .app.reels-immersive #videos-section .ihuza-reels-exit .icon { width: 18px; height: 18px; }
  #videos-section .ihuza-reel-shell,
  #videos-section .ihuza-reel-feed {
    width: 100%;
    height: 100%;
    min-height: 0;
  }
  #videos-section .ihuza-reel-feed {
    padding: 0;
    scroll-snap-stop: always;
  }
  #videos-section .ihuza-reel-card {
    display: block;
    width: 100%;
    height: var(--ihuza-reel-height);
    min-height: var(--ihuza-reel-height);
    max-height: none;
    margin: 0;
    overflow: hidden;
    scroll-snap-align: start;
  }
  #videos-section .ihuza-reel-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  #videos-section .ihuza-reel-video { object-fit: cover; }
  #videos-section .ihuza-reel-gradient {
    background: linear-gradient(180deg, rgb(0 0 0 / 18%), transparent 22%, transparent 54%, rgb(0 0 0 / 76%));
  }
  #videos-section .ihuza-reel-details {
    right: 78px;
    bottom: calc(22px + env(safe-area-inset-bottom));
    left: 16px;
    width: auto;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 12px;
    text-shadow: 0 1px 5px rgb(0 0 0 / 85%);
  }
  #videos-section .ihuza-reel-author { grid-column: 1; min-height: 44px; }
  #videos-section .ihuza-reel-avatar { width: 42px; height: 42px; flex-basis: 42px; }
  #videos-section .ihuza-reel-identity strong { font-size: 15px; }
  #videos-section .ihuza-reel-follow {
    grid-column: 2;
    min-height: 38px;
    border-color: color-mix(in srgb, var(--brand-primary) 70%, white);
    background: color-mix(in srgb, var(--brand-primary) 88%, transparent);
    padding-inline: 14px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
  }
  #videos-section .ihuza-reel-caption {
    grid-column: 1 / -1;
    display: -webkit-box;
    max-width: 100%;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.4;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }
  #videos-section .ihuza-reel-actions {
    position: absolute;
    z-index: 3;
    right: 10px;
    bottom: calc(86px + env(safe-area-inset-bottom));
    gap: 13px;
    margin: 0;
  }
  #videos-section .ihuza-reel-actions button {
    min-width: 48px;
    min-height: 48px;
    gap: 3px;
    color: #fff;
    font-size: 11px;
    text-shadow: 0 1px 4px rgb(0 0 0 / 80%);
  }
  #videos-section .ihuza-reel-actions button.active { color: #ff4968; }
  #videos-section .ihuza-reel-actions .icon { width: 25px; height: 25px; }
  #videos-section .ihuza-reel-navigation { display: none; }
}

@media (max-width: 420px) {
  #videos-section .ihuza-reel-details { right: 72px; left: 14px; }
  #videos-section .ihuza-reel-actions { right: 7px; gap: 10px; }
  #videos-section .ihuza-reel-actions button { min-width: 46px; min-height: 46px; font-size: 10px; }
  #videos-section .ihuza-reel-actions .icon { width: 23px; height: 23px; }
}
