/* Shorts of the Year - Main Stylesheet */

:root {
  --black: #000000;
  --white: #ffffff;
  --gray: #333333;
  --light-gray: #666666;
  --nav-height: 70px;
  --logo-size-desktop: 54px;
  --logo-size-desktop-top: 72px;
  --logo-size-mobile: 40px;
  --logo-size-mobile-top: 52px;
  --logo-top-headroom-desktop: 8px;
  --logo-top-headroom-mobile: 8px;
  --logo-progress: 1;
  --brand-progress: 1;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Prevent any overscroll revealing background above/below page */
html {
  overscroll-behavior: none;
  background-color: #000;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--black);
  color: var(--white);
  line-height: 1.6;
  overscroll-behavior: none;
  min-height: 100%;
}

/* =============================================
   NAVBAR
   - Default: transparent overlay (homepage)
   - .navbar--solid: opaque black (inner pages + after scroll)
   ============================================= */

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  z-index: 1000;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 30px;
  /* Use none not transparent — avoids iOS Safari initial black paint flash */
  background: none;
  /* Force GPU layer so iOS doesn't composite with black background */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Solid state — applied by JS on scroll, or hardcoded on inner pages */
.navbar--solid {
  background: var(--black) !important;
  box-shadow: 0 1px 0 var(--gray);
}

/* Overlay state — explicitly no background at all */
.navbar[data-overlay="true"]:not(.navbar--solid),
.navbar[data-overlay="true"]:not(.navbar--solid)[style] {
  background: none !important;
  background-color: transparent !important;
  box-shadow: none !important;
}

/* Hard override: on homepage while at top, force transparent even if solid class exists */
.navbar[data-overlay="true"].navbar--at-top {
  background: none !important;
  background-color: transparent !important;
  box-shadow: none !important;
}

/* Source of truth for overlay pages: JS sets data-at-top true/false */
.navbar[data-overlay="true"][data-at-top="true"] {
  background: none !important;
  background-color: transparent !important;
  box-shadow: none !important;
}

.navbar[data-overlay="true"][data-at-top="false"] {
  background: var(--black) !important;
  box-shadow: 0 1px 0 var(--gray) !important;
}

/* Compressed desktop/tablet width: keep homepage nav solid black at top */
@media (min-width: 769px) and (max-width: 1200px) {
  .navbar[data-overlay="true"] {
    background: var(--black) !important;
    box-shadow: 0 1px 0 var(--gray) !important;
  }

  /* In this range, place hero below the black nav bar */
  .navbar[data-overlay="true"] + .masthead {
    margin-top: var(--nav-height);
    height: 100vh;
  }

  /* Keep logo at normal nav size when nav is black in compressed desktop */
  .navbar[data-overlay="true"] .logo-svg {
    width: var(--logo-size-desktop) !important;
    transform: none !important;
  }

  .navbar[data-overlay="true"] .brand-accent {
    color: var(--white) !important;
    transform: none !important;
    font-weight: 700;
  }
}

.nav-col {
  display: flex;
  align-items: center;
}

.nav-left  { justify-content: flex-start; }
.nav-center { justify-content: center; align-items: center; }
.nav-right { justify-content: flex-end; gap: 30px; }

/* Brand text (left) */
.brand {
  font-size: 23px;
  font-weight: 700;
  color: var(--white);
  text-decoration: none;
  letter-spacing: -0.5px;
  white-space: nowrap;
  display: inline-block;
  line-height: 1;
  gap: 0;
}

.brand-accent {
  display: inline;
  font-weight: 700;
  color: var(--white);
}

.navbar[data-overlay="true"] .brand-accent {
  font-weight: 800;
}

/* Homepage-only brand morph: "Shorts of the Year" -> "Softy" */
.brand-home {
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
  gap: 0;
}

.brand-softy {
  display: inline-block;
  font-weight: 700;
  color: var(--white);
  line-height: 1;
  vertical-align: baseline;
  transform: none;
}

.brand-drop {
  display: inline-block;
  overflow: hidden;
  white-space: pre;
  line-height: 1;
  vertical-align: baseline;
  transform: none;
}

.navbar[data-overlay="true"] .brand-drop {
  width: calc(var(--w, 0ch) * (1 - var(--brand-progress)));
  opacity: calc(1 - var(--brand-progress));
}

/* Center logo */
.nav-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  line-height: 0;
  padding-top: 0;
  transition: opacity 0.2s;
}
.nav-logo:hover { opacity: 0.75; }

.logo-svg {
  width: var(--logo-size-desktop);
  height: auto;
  display: block;
  filter: brightness(0) invert(1);
  transform-origin: center top;
  transform: none;
  transition: transform 0.08s linear;
}

/* Homepage overlay: logo shrinks smoothly with scroll progress (0 -> 1) */
.navbar[data-overlay="true"] {
  --logo-progress: 0;
  --brand-progress: 0;
}

.navbar[data-overlay="true"] .logo-svg {
  width: var(--logo-size-desktop-top);
  transform: scale(calc(1 - (0.25 * var(--logo-progress))));
}

.navbar[data-overlay="true"] .nav-center {
  align-items: flex-start;
}

.navbar[data-overlay="true"] .nav-logo {
  padding-top: var(--logo-top-headroom-desktop);
}

/* Nav links (right) */
.nav-menu {
  display: flex;
  gap: 30px;
  align-items: center;
}

.nav-link {
  color: var(--white);
  text-decoration: none;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.nav-link:hover { opacity: 0.65; }

/* Search icon button */
.search-btn {
  background: none;
  border: none;
  color: var(--white);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.search-btn:hover { opacity: 1; }
.search-btn svg { display: block; }

/* =============================================
   SEARCH OVERLAY
   ============================================= */
.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.96);
  flex-direction: column;
  align-items: center;
  padding-top: 120px;
}
.search-overlay.search-open {
  display: flex;
}

.search-inner {
  width: 100%;
  max-width: 680px;
  padding: 0 24px;
}

.search-bar {
  display: flex;
  align-items: center;
  border-bottom: 2px solid var(--white);
  padding-bottom: 12px;
  gap: 14px;
  margin-bottom: 36px;
}

.search-bar svg { flex-shrink: 0; opacity: 0.6; }

.search-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--white);
  font-size: 26px;
  outline: none;
  font-family: inherit;
  letter-spacing: 0.5px;
}
.search-input::placeholder { color: rgba(255,255,255,0.3); }

.search-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 28px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.2s;
}
.search-close-btn:hover { color: var(--white); }

.search-results {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--gray);
  text-decoration: none;
  color: var(--white);
  transition: opacity 0.2s;
}
.search-result:hover { opacity: 0.7; }

.search-result-thumb {
  width: 72px;
  height: 48px;
  object-fit: cover;
  background: var(--gray);
  flex-shrink: 0;
}

.search-result-info { flex: 1; }
.search-result-title { font-size: 17px; font-weight: 600; margin-bottom: 3px; }
.search-result-meta  { font-size: 13px; color: rgba(255,255,255,0.55); text-transform: uppercase; letter-spacing: 0.5px; }

.search-no-results {
  color: rgba(255,255,255,0.4);
  font-size: 17px;
  text-align: center;
  padding-top: 20px;
}

mark {
  background: none;
  color: var(--white);
  font-weight: 700;
  text-decoration: underline;
}

/* Hamburger — hidden on desktop */
.menu-button {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

/* =============================================
   MOBILE NAV  (≤ 768px)
   ============================================= */
@media (max-width: 768px) {
  .navbar {
    padding: 0 16px;
  }

  /* Force no background on overlay pages at top */
  .navbar[data-overlay="true"]:not(.navbar--solid),
  .navbar[data-overlay="true"]:not(.navbar--solid)[style] {
    background: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .navbar[data-overlay="true"]:not(.navbar--solid) .nav-col {
    background: transparent !important;
  }

  .navbar[data-overlay="true"].navbar--at-top {
    background: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .navbar[data-overlay="true"][data-at-top="true"] {
    background: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* When solid (scrolled or inner pages), show black */
  .navbar--solid {
    background: var(--black) !important;
  }

  .brand {
    font-size: 16px;
  }

  .logo-svg {
    width: var(--logo-size-mobile);
    transform: none;
  }

  .nav-logo {
    padding-top: 0;
  }

  .navbar[data-overlay="true"] {
    --logo-progress: 0;
    --brand-progress: 0;
  }

  .navbar[data-overlay="true"] .nav-logo {
    padding-top: var(--logo-top-headroom-mobile);
  }

  /* Hide the link row, show hamburger */
  .nav-menu {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--black); /* dropdown always solid black so links are readable */
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    border-top: 1px solid var(--gray);
  }

  /* Open state toggled by JS */
  .nav-menu--open {
    display: flex !important;
  }

  .nav-link {
    display: block;
    padding: 16px 24px;
    font-size: 14px;
    border-bottom: 1px solid var(--gray);
  }

  .menu-button {
    display: block;
  }
}

/* =============================================
   HERO / MASTHEAD
   ============================================= */

/* On homepage the navbar is fixed and transparent —
   masthead must NOT leave a gap at the top */
.masthead {
  position: relative;
  width: 100%;
  height: 100vh;
  min-height: 560px;
  margin-top: 0;
  background-size: cover;
  background-position: center;
  background-color: var(--black);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.masthead::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.04) 0%, rgba(0,0,0,0.22) 45%, rgba(0,0,0,0.7) 100%);
}

/* Full-area clickable link */
.masthead-full-link {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--white);
  z-index: 2;
  transition: opacity 0.25s;
}
.masthead-full-link:hover { opacity: 0.88; }

.masthead-content {
  padding: 20px;
  max-width: 860px;
}

#featuredTitle {
  font-size: 64px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 16px;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.5);
  transition: transform 0.35s ease, text-shadow 0.35s ease;
}

.masthead-meta {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 15px;
  color: rgba(255,255,255,0.88);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.masthead-full-link:hover #featuredTitle {
  transform: translateY(-6px) scale(1.015);
  text-shadow: 0 8px 24px rgba(0,0,0,0.55);
}

@media (max-width: 768px) {
  .masthead { height: 70vh; }
  .masthead::before {
    background: linear-gradient(to bottom, rgba(0,0,0,0.01) 0%, rgba(0,0,0,0.18) 48%, rgba(0,0,0,0.7) 100%);
  }
  .masthead-content { padding: calc(var(--nav-height) + 14px) 16px 20px; }
  #featuredTitle { font-size: 36px; }
  .masthead-meta { font-size: 12px; flex-wrap: wrap; gap: 8px; }
}

/* =============================================
   FILMS GRID
   ============================================= */

.films-grid {
  width: 100%;
  max-width: 1800px;
  margin: 60px auto;
  padding: 0 clamp(8px, 2vw, 40px);
  display: grid;
  /* Cards min 380px, grow to fill — shrinks naturally as viewport shrinks */
  grid-template-columns: repeat(auto-fill, minmax(clamp(200px, 30vw, 500px), 1fr));
  gap: clamp(8px, 1.2vw, 20px);
}

.film-item {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  height: 0;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  overflow: hidden;
  text-decoration: none;
  color: var(--white);
  display: block;
  transition: transform 0.3s, opacity 0.3s;
}
.film-item:hover { transform: scale(1.02); opacity: 0.95; }

.film-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.02) 0%, rgba(0,0,0,0.45) 100%);
}

.film-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  top: 0;
  padding: 20px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.film-item h2 {
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.film-item .meta {
  font-size: clamp(12px, 1.3vw, 14px);
  line-height: 1.35;
  color: rgba(255,255,255,0.8);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 1100px) {
  .film-content { padding: 14px; }
  .film-item h2 { font-size: clamp(16px, 2.8vw, 21px); }
}

/* Load More */
.load-more { text-align: center; margin: 60px 0; }
.load-more h2 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: opacity 0.3s;
}
.load-more h2:hover { opacity: 0.7; }

/* =============================================
   FOOTER
   ============================================= */

.footer {
  border-top: 1px solid var(--gray);
  padding: 40px 0;
  margin-top: 80px;
}

.footer .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.copyright { font-size: 14px; color: var(--light-gray); }

.social { display: flex; gap: 20px; }
.social-icon { width: 24px; height: 24px; opacity: 0.7; transition: opacity 0.3s; cursor: pointer; }
.social-icon:hover { opacity: 1; }

@media (max-width: 768px) {
  .footer .container { flex-direction: column; gap: 20px; text-align: center; }
}

/* =============================================
   INDIVIDUAL FILM PAGE
   (has solid nav — add top padding so content
    doesn't hide under the fixed bar)
   ============================================= */

.film-page {
  max-width: 900px;
  margin: 0 auto;
  padding: calc(var(--nav-height) + 40px) 20px 60px;
}

.back-link {
  display: inline-block;
  color: var(--white);
  text-decoration: none;
  font-size: 16px;
  margin-bottom: 30px;
  opacity: 0.8;
  transition: opacity 0.3s;
}
.back-link:hover { opacity: 1; }

.film-header { margin-bottom: 40px; }
.film-header h1 { font-size: 48px; font-weight: 700; margin-bottom: 15px; line-height: 1.2; }
.film-header .meta { font-size: 18px; color: var(--light-gray); margin-bottom: 20px; }
.film-header .logline { font-size: 20px; line-height: 1.6; color: rgba(255,255,255,0.9); font-style: italic; margin-bottom: 30px; }

.video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  margin-bottom: 40px;
  background-color: var(--gray);
}
.video-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.film-review { font-size: 18px; line-height: 1.8; margin-bottom: 40px; color: rgba(255,255,255,0.95); }

.film-info {
  border-top: 1px solid var(--gray);
  padding-top: 30px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.info-item { margin-bottom: 15px; }
.info-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--light-gray); margin-bottom: 5px; }
.info-value { font-size: 16px; color: var(--white); }

@media (max-width: 768px) {
  .film-header h1 { font-size: 32px; }
}

/* =============================================
   SUBMIT PAGE
   ============================================= */

.submit-container {
  max-width: 1040px;
  margin: 0 auto;
  padding: calc(var(--nav-height) + 52px) 20px 60px;
}

.submit-container h1 {
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 24px;
}

.submit-intro {
  max-width: 980px;
  font-size: 19px;
  line-height: 1.75;
  margin: 0 auto 48px;
  color: rgba(255,255,255,0.9);
}

.submit-intro strong {
  font-weight: 700;
  color: var(--white);
}

.submit-form-wrap {
  max-width: 800px;
  margin: 0 auto;
}

.form-embed { width: 100%; min-height: 800px; border: none; }

/* =============================================
   STORE PAGE
   ============================================= */

.store-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(var(--nav-height) + 60px) 20px 60px;
  text-align: center;
}

.store-title { font-size: 48px; font-weight: 700; margin-bottom: 50px; color: white; }

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 40px;
}

.product-card {
  display: flex;
  flex-direction: column;
  background: #0a0a0a;
  padding: 15px;
  border: 1px solid #222;
  transition: transform 0.3s, opacity 0.3s;
  cursor: pointer;
}

.product-card:hover {
  transform: scale(1.02);
  opacity: 0.95;
}

.product-image-wrap {
  width: 100%;
  height: 350px;
  background-color: #111;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.product-image-wrap.placeholder {
  color: var(--light-gray);
  font-size: 16px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

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

.product-name { font-size: 18px; margin-bottom: 5px; color: white; }
.product-price { color: #888; margin-bottom: 15px; }

.sold-out-btn {
  background: transparent;
  border: 1px solid #333;
  color: #555;
  padding: 10px;
  cursor: not-allowed;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 13px;
}

/* meta separator */
.meta-separator { opacity: 0.5; }
