/* ============================================================
   Base / reset
   ============================================================ */

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f0f11;
  color: #f2f2f2;
  min-height: 100vh;
  min-height: 100dvh; /* accounts for mobile browser UI chrome */
}

button,
input,
textarea {
  font-family: inherit;
}

/* ============================================================
   Header (logo + search + contact)
   ============================================================ */

.site-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid #232323;
  position: sticky;
  top: 0;
  background: #0f0f11;
  z-index: 50;
}

.logo {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ff5a5f;
  flex-shrink: 0;
}

.search-bar {
  display: flex;
  flex: 1 1 220px;
  min-width: 0; /* prevents flex overflow on small screens */
  gap: 8px;
}

.search-bar input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #2c2c2c;
  background: #1b1b1e;
  color: #f2f2f2;
  font-size: 16px; /* 16px prevents iOS Safari auto-zoom on focus */
}

.search-bar input:focus {
  outline: none;
  border-color: #ff5a5f;
}

.search-btn,
.contact-btn,
.download-btn {
  background: #ff5a5f;
  color: #fff;
  border: none;
  padding: 12px 18px;
  min-height: 44px; /* comfortable touch target */
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.search-btn:hover,
.contact-btn:hover,
.download-btn:hover {
  background: #e14e53;
}

.search-btn:active,
.contact-btn:active,
.download-btn:active {
  transform: scale(0.97);
}

.download-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.contact-btn {
  background: transparent;
  border: 1px solid #ff5a5f;
}

.contact-btn:hover {
  background: rgba(255, 90, 95, 0.12);
}

/* ============================================================
   Video feed on main page
   ============================================================ */

.page-content {
  padding: 16px;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 2-up on phones by default */
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
}

.video-card-btn {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  color: #f2f2f2;
  width: 100%;
}

.video-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
  background-color: #1b1b1e;
  border: 1px solid #262626;
}

.video-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #ff5a5f;
}

.video-card-btn:hover .video-thumb {
  border-color: #ff5a5f;
}

.video-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* ============================================================
   Popup / overlay system
   ============================================================ */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: flex-end; /* bottom sheet feel on mobile */
  justify-content: center;
  padding: 0;
  z-index: 100;
}

.overlay.hidden {
  display: none;
}

.modal {
  position: relative;
  width: 100%;
  background: #17171a;
  border: 1px solid #262626;
  border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.results-modal,
.contact-modal,
.preview-modal {
  max-width: 480px;
}

.preview-modal {
  max-width: 780px;
}

.modal h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.15rem;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  color: #9a9a9a;
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 10px;
  min-width: 44px;
  min-height: 44px;
}

.close-btn:hover {
  color: #fff;
}

/* ============================================================
   Results popup
   ============================================================ */

.results-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-item {
  text-align: left;
  background: #1b1b1e;
  border: 1px solid #2c2c2c;
  color: #f2f2f2;
  padding: 14px;
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}

.result-item:hover {
  border-color: #ff5a5f;
}

.no-results {
  color: #9a9a9a;
  font-size: 0.9rem;
}

/* ============================================================
   Preview popup
   ============================================================ */

.iframe-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.video-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.status {
  font-size: 0.85rem;
  color: #9a9a9a;
  overflow-wrap: anywhere;
}

/* ============================================================
   Contact popup
   ============================================================ */

.contact-text {
  color: #9a9a9a;
  font-size: 0.9rem;
  margin-top: 0;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contact-form input,
.contact-form textarea {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #2c2c2c;
  background: #1b1b1e;
  color: #f2f2f2;
  font-size: 16px; /* prevents iOS auto-zoom */
  resize: vertical;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: #ff5a5f;
}

/* ============================================================
   Breakpoints
   ============================================================ */

/* Small phones */
@media (max-width: 380px) {
  .logo {
    font-size: 1.2rem;
  }

  .video-grid {
    grid-template-columns: 1fr; /* single column on very narrow screens */
  }
}

/* Tablets and up */
@media (min-width: 600px) {
  .site-header {
    padding: 18px 28px;
  }

  .page-content {
    padding: 24px;
  }

  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 18px;
  }

  .overlay {
    align-items: center;
    padding: 20px;
  }

  .modal {
    border-radius: 12px;
    padding: 24px;
    max-height: 85vh;
    max-height: 85dvh;
  }

  .close-btn {
    top: 14px;
    right: 14px;
    font-size: 1.1rem;
  }
}

/* Small laptops / large tablets */
@media (min-width: 900px) {
  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

/* Larger desktop screens */
@media (min-width: 1440px) {
  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 22px;
  }
}

/* Landscape phones (short height) — keep popups usable */
@media (max-height: 480px) and (orientation: landscape) {
  .modal {
    max-height: 96vh;
    max-height: 96dvh;
  }
}

/* Respect users who've asked for reduced motion */
@media (prefers-reduced-motion: reduce) {
  .search-btn,
  .contact-btn,
  .download-btn {
    transition: none;
  }
}