/*
 * style.css - AI Entertainment Video Feed
 * Minimal, immersive 9:16 vertical video feed. Dark background.
 */

/* Reset & base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

button,
input,
textarea,
select,
a {
  font: inherit;
}

:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 3px;
}

html {
  text-size-adjust: 100%;
}

body {
  height: 100vh;
  height: 100dvh;
  width: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.app-name {
  position: absolute;
  top: 16px;
  left: 20px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
  z-index: 45;
}

/* ---------- Vertical video feed ---------- */
.video-feed {
  flex: 1;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  background: #000;
}

.video-feed::-webkit-scrollbar {
  display: none;
}

.catalogue-error {
  max-width: 520px;
  margin: 24px auto;
  padding: 18px;
  color: #fecaca;
  line-height: 1.5;
}

/* ---------- 9:16 locked video frame ---------- */
.video-card {
  scroll-snap-align: start;
  scroll-snap-stop: always;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #000;
}

.video-frame {
  position: relative;
  width: min(100%, 420px, 56.25vh);
  width: min(100%, 420px, 56.25dvh);
  max-width: 420px;
  aspect-ratio: 9 / 16;
  max-height: 100vh;
  max-height: 100dvh;
  background: #000;
  overflow: hidden;
}

.video-card video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

/* ---------- Subtle bottom gradient for text readability ---------- */
.video-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.82) 0%,
    rgba(0, 0, 0, 0.55) 20%,
    rgba(0, 0, 0, 0.12) 48%,
    transparent 100%
  );
  pointer-events: none;
  padding: 18px 78px calc(74px + env(safe-area-inset-bottom, 0px)) 18px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  z-index: 10;
}

.video-sound-toggle {
  position: absolute;
  top: max(16px, env(safe-area-inset-top, 0px));
  right: 16px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  z-index: 12;
}

.video-sound-toggle svg {
  width: 22px;
  height: 22px;
}

.video-sound-toggle .sound-on {
  display: none;
}

.video-sound-toggle[aria-pressed="true"] .sound-on {
  display: block;
}

.video-sound-toggle[aria-pressed="true"] .sound-off {
  display: none;
}

.sound-start-prompt {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 20;
  display: none;
  min-height: 52px;
  padding: 14px 20px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
  white-space: nowrap;
}

.video-card.sound-start-pending .sound-start-prompt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.video-info {
  pointer-events: auto;
  max-width: 100%;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95);
}

.video-category {
  max-width: 100%;
  overflow: hidden;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e5e7eb;
  margin-bottom: 3px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: clamp(0.95rem, 3.5vw, 1.12rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 2px;
  color: #fff;
  overflow-wrap: anywhere;
}

.quality-feedback {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
  font-size: 0.68rem;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.9);
}

.feedback-btn,
.report-menu summary {
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 4px;
  min-height: 28px;
  padding: 3px 7px;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
  font-size: inherit;
  line-height: 1.1;
  list-style: none;
}

.report-menu summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.feedback-btn:hover,
.report-menu summary:hover,
.feedback-btn.selected {
  background: rgba(37, 99, 235, 0.9);
  border-color: #93c5fd;
}

.report-menu {
  position: relative;
}

.report-menu summary::-webkit-details-marker {
  display: none;
}

.report-reasons {
  position: absolute;
  z-index: 40;
  bottom: calc(100% + 6px);
  right: 0;
  display: grid;
  gap: 4px;
  min-width: 130px;
  padding: 6px;
  border: 1px solid #4b5563;
  border-radius: 6px;
  background: #111827;
}

/* ---------- Engagement panel ---------- */
.engagement-panel {
  position: absolute;
  right: 12px;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  width: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  z-index: 35;
  pointer-events: auto;
}

.video-card.comments-open .engagement-panel {
  visibility: hidden;
  pointer-events: none;
}

.eng-btn {
  width: 52px;
  min-height: 44px;
  padding: 2px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.9);
  transition: color 0.2s ease, transform 0.1s ease;
  pointer-events: auto;
}

.eng-btn:hover {
  color: #e5e7eb;
}

.eng-btn:active {
  transform: scale(0.92);
}

.eng-btn.liked { color: #ff4d4d; }

.eng-btn.saved { color: #4ade80; }

.eng-btn svg {
  width: 25px;
  height: 25px;
  margin-bottom: 4px;
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.75));
}

.eng-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  opacity: 1;
}

.eng-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.9);
}

/* ---------- Comment section ---------- */
.comment-section {
  position: absolute;
  bottom: 72px;
  left: 0;
  right: 0;
  max-height: min(52%, 420px);
  background: rgba(12, 12, 14, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 12px;
  z-index: 36;
  display: none;
  flex-direction: column;
  gap: 8px;
  border-radius: 14px 14px 0 0;
}

.comment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
}

.comment-heading {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}

.comment-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.comment-section textarea {
  width: 100%;
  min-height: 40px;
  max-height: 120px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: #fff;
  padding: 8px 10px;
  font-size: 0.85rem;
  resize: none;
  font-family: inherit;
}

.comment-section textarea::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.comment-section textarea:focus {
  outline: none;
  border-color: #2563eb;
}

.comment-submit {
  width: auto;
  padding: 6px 16px;
  background: #2563eb;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-end;
}

.comment-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.comment-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}

.comment-item .comment-author {
  font-size: 0.75rem;
  font-weight: 700;
  color: #93c5fd;
}

.comment-item .comment-text {
  font-size: 0.8rem;
  color: #e5e7eb;
}

.comment-item .comment-time {
  font-size: 0.68rem;
  color: #6b7280;
}

.comment-delete {
  align-self: flex-end;
  padding: 4px 8px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 6px;
  background: rgba(127, 29, 29, 0.25);
  color: #fca5a5;
  font: inherit;
  font-size: 0.7rem;
  cursor: pointer;
}

.comment-delete:disabled {
  opacity: 0.5;
  cursor: wait;
}

.comment-empty {
  font-size: 0.75rem;
  color: #6b7280;
  text-align: center;
  padding: 8px;
}

/* ---------- Loading spinner ---------- */
.loading-spinner {
  position: absolute;
  inset: 0;
  width: 36px;
  height: 36px;
  margin: auto;
  border: 2.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 25;
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.video-card.loading .loading-spinner {
  display: block;
}

/* ---------- Error state (graceful fallback) ---------- */
.video-error {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-align: center;
  padding: 24px;
  z-index: 36;
}

.video-card.error .video-error {
  display: flex;
}

.video-error p:first-child {
  font-weight: 700;
  margin-bottom: 8px;
}

.video-error p:last-child {
  font-size: 0.85rem;
  color: #888;
}

/* ---------- Bottom navigation (minimal) ---------- */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  z-index: 40;
  padding: 6px 12px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + 6px);
}

.nav-item {
  background: transparent;
  border: none;
  color: #c4c8d0;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  min-width: 72px;
  border-radius: 8px;
  transition: color 0.2s ease, background 0.2s ease;
}

.nav-item:hover {
  color: #999;
}

.nav-item:active {
  transform: scale(0.94);
}

.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.nav-icon {
  font-size: 1.35rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 28px;
  height: 28px;
  display: block;
  flex-shrink: 0;
}

.nav-label {
  font-size: 0.72rem;
  white-space: nowrap;
}

/* ---------- Coming soon overlay ---------- */
.coming-soon {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 15, 15, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 22px 32px;
  color: #fff;
  text-align: center;
  z-index: 50;
  display: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}

.coming-soon.visible {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ---------- Toast notification ---------- */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  color: #000;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 60;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.toast.show {
  display: block;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- Desktop adjustments ---------- */
@media (min-width: 768px) {
  .video-frame {
    width: min(100%, 480px, 56.25vh);
    width: min(100%, 480px, 56.25dvh);
    max-width: 480px;
  }
  .video-title {
    font-size: 1.12rem;
  }
  .bottom-nav {
    gap: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}