/* MotorHub homepage — hero carousel + category rails + short latest (variant A) */

/* Showcase: full-width primary (GP no-sidebar + belt-and-suspenders). */
body.mh-home.mh-home--showcase #right-sidebar,
body.mh-home.mh-home--showcase #left-sidebar,
body.mh-home.mh-home--showcase .sidebar {
  display: none !important;
}

body.mh-home.mh-home--showcase #primary {
  width: 100%;
  max-width: 100%;
}

/* —— Category rails —— */
.mh-home-rails {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  margin: 0 0 1.75rem;
  width: 100%;
}

.mh-home-rail__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 0.85rem;
}

.mh-home-rail__heading {
  margin: 0;
  font-size: clamp(1.15rem, 2.2vw, 1.35rem);
  font-weight: 700;
  line-height: 1.25;
}

.mh-home-rail__more {
  flex-shrink: 0;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--mh-accent, #f87800);
}

.mh-home-rail__more:hover,
.mh-home-rail__more:focus-visible {
  text-decoration: underline;
}

.mh-home-rail__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.mh-home-rail__card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mh-home-rail__media {
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(127, 127, 127, 0.12);
  margin-bottom: 0.55rem;
}

.mh-home-rail__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mh-home-rail__img--empty {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(127, 127, 127, 0.18), rgba(127, 127, 127, 0.06));
}

.mh-home-rail__img--fallback {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1a1a;
}

.mh-home-rail__img--fallback .mh-featured-fallback__plate {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.mh-home-rail__img--fallback .mh-featured-fallback__img {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: cover !important;
}

.mh-page-hero__media .mh-featured-fallback--hero {
  position: absolute;
  inset: 0;
  display: block;
  aspect-ratio: auto;
  max-height: none;
  border-radius: 0;
  contain: strict;
}

.mh-page-hero__media .mh-featured-fallback--hero .mh-featured-fallback__img {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: cover !important;
}

.mh-home-rail__title {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
}

.mh-home-rail__title a {
  text-decoration: none;
  color: inherit;
}

.mh-home-rail__title a:hover,
.mh-home-rail__title a:focus-visible {
  color: var(--mh-accent, #f87800);
}

.mh-home-rail__date {
  font-size: 0.8rem;
  opacity: 0.72;
}

.mh-home-latest__head {
  margin: 0 0 1rem;
}

.mh-home-latest__heading {
  margin: 0;
  font-size: clamp(1.15rem, 2.2vw, 1.35rem);
  font-weight: 700;
}

.mh-home-latest__more {
  margin: 1.5rem 0 0.5rem;
  text-align: center;
}

.mh-home-latest__more-btn.button {
  display: inline-block;
  padding: 0.65rem 1.35rem;
  font-weight: 600;
  text-decoration: none;
}

@media (max-width: 960px) {
  .mh-home-rail__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .mh-home-rail__grid {
    grid-template-columns: 1fr;
  }

  .mh-home-rail__head {
    flex-wrap: wrap;
  }
}

/* MotorHub homepage — category Page Hero carousel (below nav, above feed) */

.mh-hero-carousel {
  position: relative;
  margin: 0 0 1.75rem;
}

/*
 * Inside #content.site-content (already in #page.grid-container ~1200px).
 * Full row above primary+sidebar so the sidebar aligns with the first post.
 */
body.mh-home .site-content {
  flex-wrap: wrap;
  /* Flex items default min-width:auto can force horizontal page overflow on iOS. */
  min-width: 0;
}

body.mh-home .site-content > * {
  min-width: 0;
  max-width: 100%;
}

body.mh-home .mh-hero-carousel--above-feed {
  flex: 0 0 100%;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0 0 1.25rem;
  order: -1;
}

.mh-hero-carousel__viewport {
  position: relative;
  /* Fixed frame — slide image/title length must not resize the carousel. */
  height: clamp(20rem, 48vh, 34rem);
  border-radius: 10px;
  overflow: hidden;
}

.mh-hero-carousel__track {
  position: relative;
  height: 100%;
}

.mh-page-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  height: 100%;
  min-height: 0;
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  background: color-mix(in srgb, currentColor 8%, transparent);
  color: #fff;
}

.mh-hero-carousel .mh-page-hero {
  border-radius: 0;
}

/* Stacked slides — soft crossfade (not display:none hard cuts). */
.mh-hero-carousel .mh-hero-carousel__slide {
  display: flex;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 0;
  transition:
    opacity 0.48s ease,
    visibility 0.48s ease;
}

.mh-hero-carousel .mh-hero-carousel__slide.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 1;
}

.mh-hero-carousel .mh-hero-carousel__slide .mh-page-hero__inner {
  opacity: 0;
  transform: translateY(0.55rem);
  transition:
    opacity 0.45s ease 0.08s,
    transform 0.5s ease 0.08s;
}

.mh-hero-carousel .mh-hero-carousel__slide.is-active .mh-page-hero__inner {
  opacity: 1;
  transform: translateY(0);
}

/* Clickable full-bleed banner (archive card photo pattern). */
.mh-page-hero__banner-link {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.mh-page-hero__media {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transform: scale(1.02);
  transition: none;
}

.mh-page-hero__media picture {
  position: absolute;
  inset: 0;
  display: block;
}

.mh-page-hero__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  /* Avoid layout shift while decoding */
  background: #12151a;
}

.mh-hero-carousel__slide.is-active .mh-page-hero__media {
  transform: scale(1.06);
  transition: transform 6.5s ease-out;
}

.mh-page-hero__overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(
      180deg,
      rgba(8, 10, 14, 0.15) 0%,
      rgba(8, 10, 14, 0.45) 42%,
      rgba(8, 10, 14, 0.88) 100%
    );
}

.mh-page-hero__inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 42rem;
  max-height: 100%;
  padding: clamp(1.25rem, 3vw, 2.25rem);
  padding-bottom: clamp(2.75rem, 5vw, 3.25rem); /* room for overlaid controls */
  box-sizing: border-box;
  overflow: hidden;
  /* Let banner link receive clicks in empty hero chrome; keep title/CTA clickable. */
  pointer-events: none;
}

.mh-page-hero__inner a {
  pointer-events: auto;
}

.mh-hero-carousel--above-feed .mh-page-hero__inner {
  max-width: min(42rem, 100%);
}

.mh-page-hero__eyebrow {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.85;
}

.mh-page-hero__title {
  margin: 0 0 0.65rem;
  font-size: clamp(1.35rem, 2.2vw + 0.7rem, 2.2rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
  font-weight: 750;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

.mh-page-hero__title a {
  color: #fff !important;
  text-decoration: none;
}

.mh-page-hero__title a:hover,
.mh-page-hero__title a:focus-visible {
  color: #ffb35a !important;
  outline: none;
}

.mh-page-hero__excerpt {
  margin: 0 0 1.1rem;
  font-size: 1.05rem;
  line-height: 1.45;
  opacity: 0.92;
  max-width: 36rem;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.mh-page-hero__actions {
  margin: 0;
}

.mh-page-hero__cta.button {
  display: inline-block;
  padding: 0.55rem 1.15rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: color-mix(in srgb, var(--mh-accent, #f87800) 88%, #000);
  color: #fff !important;
  text-decoration: none;
  font-weight: 650;
  font-size: 0.92rem;
}

.mh-page-hero__cta.button:hover,
.mh-page-hero__cta.button:focus-visible {
  background: var(--mh-accent, #f87800);
  border-color: transparent;
  outline: none;
}

/* Controls sit on the hero frame — never jump with slide content. */
.mh-hero-carousel__controls {
  position: absolute;
  left: 50%;
  bottom: 0.7rem;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.25rem 0.45rem;
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.45);
  backdrop-filter: blur(6px);
  margin: 0;
}

.mh-hero-carousel__btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 999px;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.9;
}

/* Optical center for ‹ › glyphs (baseline sits low in the circle). */
.mh-hero-carousel__btn--prev {
  padding-bottom: 0.12em;
}

.mh-hero-carousel__btn--next {
  padding-bottom: 0.12em;
}

.mh-hero-carousel__btn:hover,
.mh-hero-carousel__btn:focus-visible {
  opacity: 1;
  border-color: var(--mh-accent, #f87800);
  outline: none;
}

.mh-hero-carousel__dots {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.mh-hero-carousel__dot {
  appearance: none;
  position: relative;
  overflow: hidden;
  border: 0;
  padding: 0;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: width 0.28s ease, background-color 0.28s ease, box-shadow 0.28s ease;
}

.mh-hero-carousel__dot.is-active {
  width: 1.35rem;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--mh-accent, #f87800) 55%, transparent);
}

/* Progress fill while slide is live (interval from --mh-hero-interval). */
.mh-hero-carousel__dot.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: inherit;
  background: var(--mh-accent, #f87800);
  animation: mh-hero-dot-progress var(--mh-hero-interval, 3.5s) linear forwards;
}

.mh-hero-carousel.is-paused .mh-hero-carousel__dot.is-active::after {
  animation-play-state: paused;
}

@keyframes mh-hero-dot-progress {
  from { width: 0%; }
  to { width: 100%; }
}

@media (max-width: 768px) {
  /*
   * iOS Safari: any child wider than the layout viewport (flex 100% + side
   * margins, 100vw, min-width:auto) makes the page feel “zoomed” / scroll sideways.
   * Prefer padding gutters (border-box) over horizontal margins on flex rows.
   */
  html {
    overflow-x: clip;
  }

  body.mh-home {
    overflow-x: clip;
    width: 100%;
    max-width: 100%;
  }

  body.mh-home #page,
  body.mh-home .site-content,
  body.mh-home #primary,
  body.mh-home #main {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Equal gutters via padding — never width:100% + margin-left/right. */
  body.mh-home.separate-containers .mh-hero-carousel--above-feed {
    flex: 0 0 100%;
    width: 100%;
    max-width: 100%;
    margin: 0 0 1rem;
    padding: 0 12px;
    box-sizing: border-box;
  }

  /* Beat GP `#main { margin-left/right: 0 }` (ID specificity). */
  body.mh-home.separate-containers #main.site-main {
    margin-left: 12px !important;
    margin-right: 12px !important;
    max-width: calc(100% - 24px);
    box-sizing: border-box;
  }

  body.mh-home.separate-containers .inside-right-sidebar,
  body.mh-home.separate-containers .inside-left-sidebar {
    margin-left: 12px;
    margin-right: 12px;
    max-width: calc(100% - 24px);
    box-sizing: border-box;
  }

  /* Proper mobile banner height — readable vs feed titles below. */
  .mh-hero-carousel__viewport {
    height: clamp(18.5rem, 46vh, 26rem);
    border-radius: 10px;
  }

  /* No Ken Burns zoom on mobile (CPU + compositor cost during LCP). */
  .mh-page-hero__media,
  .mh-hero-carousel__slide.is-active .mh-page-hero__media {
    transform: none !important;
    transition: none !important;
  }

  .mh-page-hero__excerpt {
    font-size: 0.95rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .mh-page-hero__title {
    font-size: clamp(1.25rem, 4.6vw, 1.55rem);
    line-height: 1.2;
    /* 2 lines on phone — 3 + CTA collided with dots/arrows */
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .mh-page-hero__inner {
    /* Reserve clear band above absolute .mh-hero-carousel__controls */
    padding: 1rem 1rem 4.25rem;
    max-width: 100%;
  }

  .mh-page-hero__actions {
    margin-bottom: 0.15rem;
  }

  .mh-page-hero__cta.button {
    font-size: 0.9rem;
    padding: 0.5rem 1.05rem;
  }

  .mh-hero-carousel__controls {
    bottom: 0.55rem;
    z-index: 5;
  }
}

html[data-mh-theme="light"] .mh-page-hero:not(.mh-page-hero--has-image) {
  color: inherit;
  background: #eef1f4;
}

html[data-mh-theme="light"] .mh-page-hero:not(.mh-page-hero--has-image) .mh-page-hero__title a {
  color: inherit !important;
}

/* controls already light-on-dark over the photo */

@media (prefers-reduced-motion: reduce) {
  .mh-page-hero__media {
    transition: none;
    transform: none !important;
  }

  .mh-hero-carousel .mh-hero-carousel__slide,
  .mh-hero-carousel .mh-hero-carousel__slide .mh-page-hero__inner,
  .mh-hero-carousel__dot {
    transition: none;
  }

  .mh-hero-carousel .mh-hero-carousel__slide .mh-page-hero__inner {
    opacity: 1;
    transform: none;
  }

  .mh-hero-carousel__dot.is-active {
    background: var(--mh-accent, #f87800);
    box-shadow: none;
  }

  .mh-hero-carousel__dot.is-active::after {
    animation: none;
    width: 100%;
  }
}
