/* ========== GLOBAL STYLES ========== */
body {
  background-color: #111;
  color: white;
  font-family: 'Segoe UI', sans-serif;
  margin: 0;
  padding: 0;
}

html {
  overflow-y: scroll;
}

a {
  color: #e0611f;
  font-weight: bold;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ========== HEADER ========== */
header {
  background-color: #6b1f00;
  padding: 20px 10px 40px 10px;
  text-align: center;
  position: relative;
}

.logo {
  width: 180px;
  height: 160px;
  display: block;
  margin: 0 auto 10px auto;
}

/* ========== SEARCH BAR ========== */
.search-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 0 auto;
  max-width: 600px;
  flex-wrap: wrap;
}

.search-container select,
.search-container input[type="text"] {
  padding: 10px;
  font-size: 14px;
  border: none;
  border-radius: 6px;
  outline: none;
  box-sizing: border-box;
  background-color: #1a1a1a;
  color: white;
  border: 1px solid #444;
  flex-grow: 1;
  min-width: 150px;
}

#searchInput { color: #e0611f; }

#categorySelect {
  color: #e0611f;
  background-color: #1a1a1a;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 10px;
  font-size: 14px;
  font-family: 'Segoe UI', sans-serif;
  cursor: pointer;
}

#searchbutton,
.search-container button {
  background-color: #e0611f;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

#searchbutton:hover,
.search-container button:hover {
  background-color: #c9501d;
  box-shadow: 0 0 10px #c9501d;
}

.search-container input[type="text"]:.focus,
.search-container input[type="text"]:focus {
  background-color: #1a1a1a !important;
  color: white !important;
  border: 1px solid #e0611f;
  outline: none;
}

/* Prevent Chrome autofill yellow background */
input:-webkit-autofill,
input:-webkit-autofill:focus,
input:-webkit-autofill:hover {
  -webkit-box-shadow: 0 0 0px 1000px #1a1a1a inset !important;
  -webkit-text-fill-color: white !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* ========== FEATURED WRAPPER ========== */
#featuredWrapper {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto 40px auto;
  padding: 60px 0;
  min-height: 480px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  box-sizing: border-box;
  z-index: 2;
  overflow: visible;
}

#featuredWrapper::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-image: url('../images/banner.webp');
  background-size: 300px auto;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.08;
  filter: grayscale(80%) brightness(180%);
  width: 300px;
  height: 300px;
  pointer-events: none;
  z-index: 0;
}

/* ========== FEATURED MOD ========== */
#featuredMod {
  position: relative;
  margin: 40px auto 30px auto;
  padding-top: 30px;
  width: 90%;
  max-width: 720px;
  background-color: #1b1b1b;
  border-radius: 8px;
  box-shadow: 0 0 15px #c9501d;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  transition: box-shadow 0.3s ease;
  opacity: 1;
  visibility: visible;
  box-sizing: border-box;
  z-index: 2;
}
#featuredMod:hover { box-shadow: 0 0 25px #e0611f; }
#featuredMod.is-swapping { transition: box-shadow 0.3s ease, opacity 0.5s ease-in-out; }

@media (prefers-reduced-motion: reduce) {
  #featuredMod, #featuredMod.is-swapping { transition: box-shadow 0.3s ease; }
}

#featuredMod a {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
#featuredMod img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  display: block;
  max-width: 640px;
  margin: 0 auto;
}
#featuredMod .featured-text {
  width: 100%;
  max-width: 640px;
  text-align: center;
  margin-top: 10px;
}
#featuredMod .title { font-size: 1.2rem; font-weight: bold; margin-bottom: 4px; color: white; }
#featuredMod .category { font-size: 0.9rem; color: #aaa; }
#featuredMod.preloading {
  min-height: 400px;
  background-color: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}
#featuredMod.preloading::before {
  content: "Loading Featured Mod...";
  color: #666;
  font-size: 1rem;
  font-style: italic;
}

/* ========== MOD GRID ========== */
#modGrid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;         /* ← prevent stretch to tallest card */
  gap: 20px;
  margin: 20px auto 60px auto;
  max-width: 1200px;
}

.mod-card {
  background-color: #1a1a1a;
  width: 200px;
  border-radius: 8px;
  overflow: hidden;
  text-align: center;
  padding: 8px 8px 4px;
  transition: transform 0.2s, box-shadow 0.3s ease;
  min-height: 0;                   /* ← remove big forced height */
}

.mod-card:hover {
  transform: scale(1.08);
  box-shadow: 0 0 12px #c9501d;
}

/* --- CLS FIX: reserve image space and fill it --- */
.thumb-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #222;
  border-radius: 6px;
  overflow: hidden;
}
.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Remove the old fixed img height rule (kept harmlessly overridden)
.mod-card img { height: 180px; }
*/

.mod-card h3 {
  font-size: 0.95rem;
  margin-top: 8px;
  margin-bottom: 0;
  color: white;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;        /* clamp long titles */
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.4em;            /* reserve two lines to prevent shift */
}

/* ========== DOWNLOAD BUTTONS ========== */
.download-button {
  background-color: #c9501d;
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  text-decoration: none;
  margin: 10px 10px 0 0;
  display: inline-block;
  transition: background-color 0.3s ease;
}
.download-button:hover { background-color: #e0611f; }

/* ========== PAGINATION ========== */
#paginationControls {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px 0;
  gap: 10px;
  color: #c9501d;
  font-weight: bold;
}
#paginationControls span {
  color: #c9501d;
  user-select: none;
  font-size: 1rem;
}

/* ========== FOOTER ========== */
footer { height: 50px; min-height: 50px; }

/* ========== RESPONSIVE ========== */
@media (max-width: 600px) {
  #modGrid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding-left: 8px;
    padding-right: 8px;
    margin-left: 0;
    margin-right: 0;
  }
  .mod-card {
    width: 100% !important;
    box-sizing: border-box;
    border: none !important;
    min-height: 0; /* keep the same fix on mobile */
  }
}

@media (max-width: 768px) {
  #featuredWrapper img.background-logo {
    width: 150px;
    opacity: 0.1;
  }
}

/* --- Social icons: center + a11y (override) --- */
header .social-icons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 12px auto 18px;
  max-width: 600px;
}
header .social-icons li { display: inline-flex; }
header .social-icons a { display: inline-flex; align-items: center; justify-content: center; }
header .social-icons img {
  width: 28px; height: 28px; object-fit: contain;
  filter: brightness(0) invert(1);
  transition: transform .2s ease, filter .2s ease;
}
header .social-icons a:hover img {
  transform: translateY(-1px);
  filter: brightness(0) invert(.6) drop-shadow(0 0 4px #e0611f);
}
header .social-icons a:focus-visible {
  outline: 2px solid #e0611f;
  outline-offset: 3px;
  border-radius: 6px;
}

/* ========== MISC ELEMENTS ========== */
back-button-wrapper { display: flex; justify-content: center; margin-top: 20px; }
.back-button {
  margin: 0; font-size: 14px; color: #c9501d; text-decoration: none; cursor: pointer;
  padding: 6px 12px; border-radius: 4px; background-color: #333; transition: background-color 0.3s ease;
}
.back-button:hover { background-color: #e0611f; color: #fff; text-decoration: none; }

h2, h3 { text-align: center; margin-top: 30px; }

.video-container { margin: 30px 0; position: relative; padding-bottom: 56.25%; height: 0; }
.video-container iframe { position: absolute; width: 100%; height: 100%; border: none; }

.contact-container { max-width: 700px; margin: 40px auto; padding: 0 20px; text-align: center; color: #ddd; }
.contact-links { list-style: none; padding: 0; margin: 20px 0; }
.contact-links li { margin: 10px 0; font-size: 16px; }
.contact-links a { color: #e0611f; text-decoration: none; font-weight: bold; }
.contact-links a:hover { text-decoration: underline; }

.image-gallery { display: flex; flex-direction: column; gap: 20px; margin: 20px 0; }
.mod-image { width: 100%; max-width: 800px; margin-bottom: 20px; border-radius: 8px; box-shadow: 0 0 8px #c9501d; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0);
}

.thumb { transition: box-shadow 0.3s ease, transform 0.3s ease; box-shadow: 0 0 6px #222; }
.thumb:hover { box-shadow: 0 0 20px #e0611f; transform: scale(1.1); }

#modContainer p,
#modContainer li,
#modContainer span,
#modContainer div { color: #ddd; }

/* Tighten spacing around featured section */
#featuredWrapper { margin: 20px auto 10px auto !important; padding: 10px 0 !important; }
#featuredWrapper h2 { margin-bottom: 10px !important; font-size: 1.6rem; }

/* Reduce bottom margin on featured mod card */
#featuredMod { margin-bottom: 20px !important; }

/* Optional: tighten spacing above "Recent Mods" heading */
h2#recentHeader { margin-top: 10px !important; margin-bottom: 15px !important; }

/* Make the featured card clip its contents like the mod cards */
#featuredMod { overflow: hidden; }

/* Mobile-only polish so the image sits perfectly inside the rounded box */
@media (max-width: 600px) {
  #featuredMod {
    padding: 12px;            /* even padding all around */
    border-radius: 12px;      /* slightly larger outer radius for a clean glow */
  }
  #featuredMod img {
    border-radius: 8px;       /* inner radius so corners don’t clash */
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
    width: 100%;
    max-width: none;          /* let it fill the card on small screens */
  }
}

/* Featured card should clip and have inner padding like mod cards */
#featuredMod {
  overflow: hidden;           /* clip anything past rounded corners */
  border-radius: 12px;        /* slightly larger to match the glow */
}

#featuredMod a {
  width: 100%;
  display: block;
  padding: 10px;              /* inner padding like .mod-card */
  box-sizing: border-box;
}

#featuredMod img {
  display: block;
  width: 100% !important;     /* fill inner box on mobile */
  max-width: none !important; /* prevent old max-width from limiting it */
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: cover;
  border-radius: 8px;         /* inner radius so corners look clean */
}

/* a little breathing room for the title block */
#featuredMod .featured-text { padding: 8px 6px 12px; }

/* --- tighten spacing around Featured + Recent --- */

/* Desktop: a little tighter */
#featuredWrapper { margin: 12px auto 8px; padding: 8px 0; }
#featuredMod     { margin: 12px auto 14px; }
#modGrid         { margin: 14px auto 40px; }
#featuredMod .featured-text { margin-top: 6px; }

/* If you have a specific id on the Recent header, keep it snug */
h2#recentHeader { margin-top: 8px; margin-bottom: 10px; }

/* Mobile: pull everything up more aggressively */
@media (max-width: 600px) {
  h2 { margin-top: 5px; margin-bottom: 8px; }           /* Featured/Recent titles */
  #featuredWrapper { margin: 8px auto 4px; padding: 4px 0; }
  #featuredMod     { margin: 8px auto 10px; }
  #modGrid         { margin: 8px auto 24px; gap: 12px; }  /* slightly tighter card gaps */
}

.mod-nav .mod-card,
.related-mods .rel-card {
  border: 1px solid rgba(255,255,255,.06) !important; /* subtle base */
  box-shadow: none !important;
  transition: box-shadow .2s ease;
}

.mod-nav .mod-card:hover,
.related-mods .rel-card:hover {
  border-color: rgba(255,255,255,.06) !important; /* keep subtle border */
  box-shadow: 0 0 15px #c9501d !important;        /* the glow */
}
