/* AM730 Video page — 內容區（header/footer 用 am730 base.css） */

:root {
  --am730-green: #00a040;
  --am730-green-dark: #008a36;
  --text: #222;
  --text-muted: #666;
  --border: #e8e8e8;
  --card-bg: #fff;
}

.video-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 0 2rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1.25rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.back-link:hover {
  color: var(--am730-green);
}

/* ── Video grid (list page) ── */

.video-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem 1rem;
}

.video-card {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.video-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.video-card__thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #ddd;
  overflow: hidden;
}

.video-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-card__duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.video-card__body {
  padding: 0.75rem 0.85rem 1rem;
  display: flex;
  gap: 0.75rem;
}

.video-card__avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.video-card__meta {
  min-width: 0;
}

.video-card__title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}

.video-card__stats {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.video-card__channel {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.15rem 0 0;
}

/* ── Detail page ── */

.video-card--compact {
  flex-direction: row;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.video-card--compact:hover {
  box-shadow: none;
  opacity: 0.85;
}

.video-card--compact .video-card__thumb {
  width: 168px;
  flex-shrink: 0;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
}

.video-card--compact .video-card__body {
  padding: 0;
  align-items: flex-start;
}

.video-card--compact .video-card__avatar {
  display: none;
}

.video-card--compact .video-card__title {
  font-size: 0.875rem;
  -webkit-line-clamp: 2;
}

.video-card--compact .video-card__stats {
  font-size: 0.75rem;
}

.video-card--rail {
  flex: 0 0 auto;
  width: 240px;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.video-card--rail:hover {
  box-shadow: none;
  opacity: 0.85;
}

.video-card--rail .video-card__thumb {
  border-radius: 8px;
}

.video-card--rail .video-card__body {
  padding: 0.5rem 0 0;
  flex-direction: column;
  gap: 0;
}

.video-card--rail .video-card__avatar {
  display: none;
}

.video-card--rail .video-card__title {
  font-size: 0.875rem;
  -webkit-line-clamp: 2;
}

.video-card--rail .video-card__stats {
  font-size: 0.8125rem;
  margin-top: 0.35rem;
}

.video-card--rail .video-card__channel {
  display: none;
}

/* Related videos (horizontal rail) */

.video-related {
  margin-bottom: 1.5rem;
}

.video-related__title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
}

.video-related__list {
  --rail-gap: 0.75rem;
  --rail-visible: 4.3;
  display: flex;
  flex-direction: row;
  gap: var(--rail-gap);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 0.25rem;
}

.video-related__list .video-card--rail {
  scroll-snap-align: start;
}

.video-detail__player {
  aspect-ratio: 16 / 9;
  width: 100%;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.video-detail__player iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.video-detail__title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  line-height: 1.4;
}

/* ── YouTube-style owner row (channel + engagement) ── */

.yt-owner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.yt-owner-row__left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1;
  min-width: 0;
}

.yt-owner-row__right {
  flex-shrink: 0;
  max-width: 100%;
}

.yt-channel {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.yt-channel:hover .yt-channel__name {
  color: var(--text);
}

.yt-channel__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.yt-channel__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.yt-channel__name {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.yt-channel__subs {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.yt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
}

.yt-btn--subscribe {
  background: #0f0f0f;
  color: #fff;
}

.yt-btn--subscribe:hover {
  background: #272727;
  color: #fff;
}

.yt-btn--join {
  background: rgba(0, 0, 0, 0.05);
  color: #065fd4;
}

.yt-btn--join:hover {
  background: rgba(6, 95, 212, 0.12);
  color: #065fd4;
}

.yt-engagement {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.yt-engagement__group {
  display: inline-flex;
  align-items: stretch;
  height: 36px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 999px;
  overflow: hidden;
}

.yt-engagement__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 36px;
  padding: 0 0.85rem;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.yt-engagement__group .yt-engagement__btn {
  border-radius: 0;
  background: transparent;
}

.yt-engagement__btn:hover,
.yt-engagement__group:hover {
  background: rgba(0, 0, 0, 0.1);
}

.yt-engagement__group .yt-engagement__btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.yt-engagement__btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}

.yt-engagement__btn--icon {
  padding: 0 0.75rem;
}

.yt-engagement__divider {
  width: 1px;
  align-self: stretch;
  margin: 0.45rem 0;
  background: rgba(0, 0, 0, 0.1);
}

.yt-share-wrap {
  position: relative;
}

.yt-share-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 20;
  min-width: 180px;
  padding: 0.5rem 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.yt-share-menu__title {
  margin: 0;
  padding: 0.35rem 1rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.yt-share-menu__item {
  display: block;
  width: 100%;
  padding: 0.55rem 1rem;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.yt-share-menu__item:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* YouTube-style description box */

.yt-desc-box {
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 12px;
}

.yt-desc-box__stats {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.yt-desc-box__text {
  font-size: 0.875rem;
  white-space: pre-wrap;
  color: var(--text);
  margin: 0;
  line-height: 1.65;
  word-break: break-word;
}

.yt-desc-box__link {
  color: #065fd4;
  text-decoration: none;
}

.yt-desc-box__link:hover {
  text-decoration: underline;
}

.yt-desc-box__text.is-collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
}

.yt-desc-box__toggle {
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.35rem 0 0;
  font-family: inherit;
}

.yt-desc-box__toggle:hover {
  color: var(--am730-green);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

/* Chapters */

.video-chapters {
  margin-bottom: 1.5rem;
}

.video-chapters__title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
}

.video-chapters__list {
  list-style: none;
  margin: 0;
  padding: 0 0 0.25rem;
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.video-chapters__item {
  flex: 0 0 auto;
  width: 168px;
  scroll-snap-align: start;
}

.video-chapters__btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  padding: 0;
  border: none;
  border-radius: 0;
  font-size: 0.9rem;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}

.video-chapters__btn:hover .video-chapters__thumb {
  box-shadow: 0 0 0 2px var(--am730-green);
}

.video-chapters__btn:hover .video-chapters__label {
  color: var(--text);
}

.video-chapters__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #e5e5e5;
  transition: box-shadow 0.15s ease;
}

.video-chapters__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-chapters__time {
  position: absolute;
  right: 4px;
  bottom: 4px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.02em;
}

.video-chapters__label {
  min-width: 0;
  line-height: 1.35;
  font-size: 0.8125rem;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Channel linked accounts */

.channel-links {
  margin-bottom: 1.5rem;
}

.channel-links__title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
}

.channel-links__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.channel-links__item {
  font-size: 0.875rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
}

.channel-links__item:hover {
  border-color: var(--am730-green);
  color: var(--am730-green);
}

.video-detail__footer-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}

.btn--outline {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--outline:hover {
  border-color: var(--am730-green);
  color: var(--am730-green);
}

/* Loading / empty */

.video-loading,
.video-empty,
.video-grid__load-more {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.video-grid__load-more {
  padding: 1.5rem 1rem 2.5rem;
  font-size: 0.9rem;
}

.video-card {
  color: inherit;
  text-decoration: none;
}

.video-card img {
  max-width: 100%;
  display: block;
}

@media (max-width: 900px) {
  .video-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 0.75rem;
  }
}

@media (max-width: 640px) {
  /* List：YouTube mobile 單欄大圖，垂直 scroll */
  .video-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .video-page .page-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }

  .video-grid .video-card {
    border-radius: 0;
    box-shadow: none;
  }

  .video-grid .video-card__thumb {
    border-radius: 0;
  }

  .video-grid .video-card__body {
    padding: 0.65rem 0 0.25rem;
    flex-direction: row;
    gap: 0.75rem;
  }

  .video-grid .video-card__avatar {
    display: block;
    width: 36px;
    height: 36px;
  }

  .video-grid .video-card__title {
    font-size: 0.9375rem;
    line-height: 1.35;
    margin-bottom: 0.35rem;
  }

  .video-grid .video-card__stats {
    font-size: 0.8125rem;
    line-height: 1.35;
  }

  .video-grid .video-card__channel {
    display: block;
    font-size: 0.8125rem;
  }

  /* 詳情頁推薦：同上，改垂直列表 */
  .video-related__list {
    flex-direction: column;
    overflow-x: visible;
    scroll-snap-type: none;
    gap: 1rem;
    padding-bottom: 0;
  }

  .video-related__list .video-card--rail {
    width: 100%;
    flex-basis: auto;
  }

  .video-related__list .video-card--rail .video-card__thumb {
    border-radius: 0;
  }

  .video-related__list .video-card--rail .video-card__body {
    padding: 0.65rem 0 0.25rem;
    flex-direction: row;
    gap: 0.75rem;
  }

  .video-related__list .video-card--rail .video-card__avatar {
    display: block;
    width: 36px;
    height: 36px;
  }

  .video-related__list .video-card--rail .video-card__title {
    font-size: 0.9375rem;
  }

  .video-related__list .video-card--rail .video-card__stats {
    font-size: 0.8125rem;
    margin-top: 0;
  }

  .video-related__list .video-card--rail .video-card__channel {
    display: block;
    font-size: 0.8125rem;
  }

  .yt-owner-row {
    flex-direction: column;
    align-items: stretch;
  }

  .yt-owner-row__left {
    flex-wrap: wrap;
  }

  .yt-owner-row__right {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .yt-owner-row__right::-webkit-scrollbar {
    display: none;
  }

  .yt-engagement {
    padding-bottom: 0.15rem;
  }

  .yt-channel__name {
    max-width: 140px;
  }

  .video-card--compact .video-card__thumb {
    width: 140px;
  }

  .video-chapters__item {
    width: 120px;
  }
}
