/**
 * YouTube Playlist Carousel Styles
 * Version: 2.1.0
 */

.ytpc {
  --ytpc-gap: 20px;
  --ytpc-radius: 18px;
  --ytpc-thumb-radius: 12px;
  --ytpc-card-bg: #ffffff;
  --ytpc-card-border: #e6eaf0;
  --ytpc-text: #111827;
  --ytpc-text-muted: #4b5563;
  --ytpc-views: #6b7280;
  --ytpc-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
  --ytpc-shadow-hover: 0 12px 28px -4px rgba(0, 0, 0, 0.12);

  width: 100%;
  position: relative;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  margin: 0 0 30px 0;
}

.ytpc *,
.ytpc *::before,
.ytpc *::after {
  box-sizing: border-box;
}

/* Header & Arrow Navigation Controls (Top-Right) */
.ytpc-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 16px;
  width: 100%;
}

.ytpc-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.ytpc-arrow {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  border: 1px solid var(--ytpc-card-border);
  background: #ffffff;
  color: var(--ytpc-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  outline: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.ytpc-arrow:hover:not(:disabled) {
  background: #f7f7f8;
  border-color: #d1d5db;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.ytpc-arrow:active:not(:disabled) {
  transform: translateY(0);
}

.ytpc-arrow:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
  box-shadow: none;
}

/* Viewport & Sliding Track */
.ytpc-viewport {
  width: 100%;
  overflow: hidden;
  position: relative;
}

.ytpc-track {
  display: flex;
  gap: var(--ytpc-gap);
  transform: translate3d(0, 0, 0);
  transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
}

/* Card Container */
.ytpc-card {
  flex: 0 0 calc((100% - (var(--ytpc-gap) * 3)) / 4);
  max-width: calc((100% - (var(--ytpc-gap) * 3)) / 4);
  min-width: 0;
  background: var(--ytpc-card-bg);
  border: 1px solid var(--ytpc-card-border);
  border-radius: var(--ytpc-radius);
  padding: 14px;
  box-shadow: var(--ytpc-shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  display: flex;
  flex-direction: column;
}

.ytpc-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--ytpc-shadow-hover);
  border-color: #d1d5db;
}

/* Inner Video Link & Layout */
.ytpc-video {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none !important;
  color: inherit;
  outline: none;
}

/* Video Thumbnail */
.ytpc-thumb {
  display: block;
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--ytpc-thumb-radius);
  background: #111827;
}

.ytpc-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 0.35s ease;
  pointer-events: none;
}

.ytpc-card:hover .ytpc-thumb img {
  transform: scale(1.04);
}

/* Centered YouTube Play Icon */
.ytpc-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ytpc-play span {
  width: 48px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 0, 0, 0.94);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 2px;
  font-size: 15px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, background 0.2s ease;
}

.ytpc-card:hover .ytpc-play span {
  transform: scale(1.1);
  background: #ff0000;
}

/* Card Content: Title, Excerpt, Views */
.ytpc-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  padding-top: 12px;
}

.ytpc-title {
  margin: 0 0 6px 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.38;
  color: var(--ytpc-text);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  min-height: 40px;
  transition: color 0.2s ease;
}

.ytpc-card:hover .ytpc-title {
  color: #1d4ed8;
}

.ytpc-excerpt {
  margin: 0 0 10px 0;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--ytpc-text-muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  min-height: 38px;
}

.ytpc-meta {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.ytpc-views {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ytpc-views);
  letter-spacing: 0.01em;
}

/* Carousel Dots */
.ytpc-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 20px;
}

.ytpc-dot {
  width: 8px;
  height: 8px;
  border: 0;
  border-radius: 50%;
  background: #d4d4d4;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.ytpc-dot.is-active {
  background: #111827;
  transform: scale(1.25);
}

/* Admin Error Box */
.ytpc-admin-error {
  padding: 15px;
  border: 1px solid #e2a0a0;
  background: #fff4f4;
  color: #8a1f1f;
  border-radius: 8px;
  margin: 15px 0;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .ytpc {
    --ytpc-gap: 16px;
  }
  .ytpc-card {
    flex: 0 0 calc((100% - var(--ytpc-gap)) / 2);
    max-width: calc((100% - var(--ytpc-gap)) / 2);
  }
}

@media (max-width: 640px) {
  .ytpc {
    --ytpc-gap: 14px;
  }
  .ytpc-card {
    flex: 0 0 100%;
    max-width: 100%;
  }
  .ytpc-arrow {
    width: 38px;
    height: 38px;
    min-width: 38px;
    font-size: 16px;
  }
  .ytpc-title {
    font-size: 14.5px;
  }
  .ytpc-excerpt {
    font-size: 12.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ytpc-track,
  .ytpc-thumb img,
  .ytpc-card {
    transition: none !important;
  }
}
