/**
 * FixTman Homepage V2 — scoped overrides only.
 * Depends on child theme style.css (wavy-child-css) for base .fh-* rules.
 * Must not affect V1 (#fh-home) or other templates.
 */

/* Full-width layout for V2 template only (mirrors V1 page-home rules). */
body.page-template-page-home-v2 .sidebar,
body.page-template-page-home-v2 aside,
body.page-template-page-home-v2 #sidebar {
  display: none !important;
}

body.page-template-page-home-v2 #content,
body.page-template-page-home-v2 .content-area,
body.page-template-page-home-v2 .grid-posts {
  width: 100% !important;
  max-width: 100% !important;
  float: none !important;
}

#fh-home-v2 {
  font-family: var(--font-family);
  color: var(--color-text-primary);
}

/*
 * P0 CLS: carousel geometry must be stable before JS.
 * --fh-hero-slides is set inline on the track from PHP.
 * Critical CSS in the template mirrors this for deferred-CSS cases.
 */
#fh-home-v2 .fh-hero__track-wrap {
  overflow: hidden;
  width: 100%;
}

#fh-home-v2 .fh-hero__track {
  display: flex;
  width: calc(var(--fh-hero-slides, 1) * 100%);
  align-items: flex-start;
}

#fh-home-v2 .fh-hero__slide {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  flex: 0 0 calc(100% / var(--fh-hero-slides, 1));
  width: calc(100% / var(--fh-hero-slides, 1));
  min-width: 0;
  max-width: calc(100% / var(--fh-hero-slides, 1));
}

/* Match V1 fixed img-wrap heights — stable CLS, all slides keep full geometry for carousel + lazy load */
#fh-home-v2 .fh-hero__img-wrap {
  position: relative;
  display: block;
  height: 434px !important;
  width: calc(100% - 40px);
  max-width: 1160px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: var(--card-radius);
  text-decoration: none;
}

/*
 * IMPORTANT: use a direct-child selector only.
 * A descendant `img` selector also matched the author avatar and
 * overrode V1 `.fh-hero__author-badge > img` (52×52) via higher specificity.
 */
#fh-home-v2 .fh-hero__img-wrap > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Reinforce V1 author badge sizing so avatar never flex-shrinks */
#fh-home-v2 .fh-hero__author-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 48px);
}

#fh-home-v2 .fh-hero__author-badge > img {
  width: 52px;
  height: 52px;
  max-width: 52px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 50%;
}

#fh-home-v2 .fh-hero__author-badge > div {
  flex: 0 1 auto;
  min-width: 0;
}

#fh-home-v2 .fh-hero__author-name,
#fh-home-v2 .fh-hero__author-date {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
  overflow-wrap: normal;
}

/* Match H1 / non-H1 hero titles to existing .fh-hero__title look */
#fh-home-v2 h1.fh-hero__title,
#fh-home-v2 p.fh-hero__title {
  font-size: clamp(26px, 3.2vw, 42px);
  font-weight: 800;
  line-height: 1.18;
  color: var(--color-primary);
  margin: 0;
  /* Cap title height so font-swap / long titles don't change track height (pushes .fh-cats). */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  min-height: calc(1.18em * 2);
}

/* Reserve final dots row height before V2 stylesheet finishes applying */
#fh-home-v2 .fh-hero__dots {
  min-height: 44px;
  box-sizing: content-box;
}

/* CTA icon box matches CSS; HTML attrs may be 150 — lock paint size */
#fh-home-v2 .fh-cta__icon {
  width: 52px !important;
  height: 52px !important;
  max-width: 52px;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  flex-shrink: 0;
}

/*
 * Category tags — brand fonts restored (self-hosted Lato / Be Vietnam Pro).
 * Keep nowrap + horizontal scroll so metric differences don't wrap rows
 * and push Popular Articles (CLS).
 */
#fh-home-v2 .fh-cats__tags {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 4px;
}

#fh-home-v2 .fh-cats__tag {
  flex-shrink: 0;
  white-space: nowrap;
  font-family: var(--font-family, "Lato", "Be Vietnam Pro", sans-serif);
  font-size: 14px;
  line-height: 1.35;
  padding: 7px 14px;
  box-sizing: border-box;
  min-height: 2.35em;
}

#fh-home-v2 .fh-cats__title {
  min-height: 1.3em;
  line-height: 1.3;
}

/* Popular grid: reserve card image boxes before images/fonts settle */
#fh-home-v2 .fh-home-v2__popular .fh-card__img-link {
  aspect-ratio: 16 / 10;
  background: var(--color-bg-pale, #f3f4f6);
}

#fh-home-v2 .fh-home-v2__popular .fh-section__title {
  min-height: 1.3em;
  line-height: 1.3;
}

/* Footer logo sits outside #fh-home-v2 — scope via template body class */
body.page-template-page-home-v2 .fh-footer__logo-row img {
  width: 144px;
  height: 47px;
  max-width: 144px;
  aspect-ratio: 144 / 47;
  object-fit: contain;
  display: block;
}

/* Match V1 clickable “Read Article” CTA */
#fh-home-v2 .fh-hero__btn {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 11px 28px;
  border-radius: var(--btn-radius);
  text-decoration: none;
  align-self: flex-start;
  transition: background 0.2s;
}

#fh-home-v2 .fh-hero__btn:hover {
  background: var(--color-primary-hover);
  color: #fff;
}

/*
 * Hero dots: large transparent hit target + V1-sized ::after indicator.
 * Do NOT pad the 32×8 box — V1 ::after is width/height 100% of the button,
 * so padding stretched the visible pill into tall ovals.
 */
#fh-home-v2 .fh-hero__dots {
  gap: 4px;
  align-items: center;
}

#fh-home-v2 .fh-hero__dot {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  box-sizing: border-box;
}

/* Visual indicator = V1 32×8 pill, centered inside the 44×44 hit area */
#fh-home-v2 .fh-hero__dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 8px;
  margin-top: -4px;
  margin-left: -16px;
  border-radius: 50px;
  background: var(--color-border);
  transform: scaleX(0.25);
  transform-origin: center;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.2s ease;
}

#fh-home-v2 .fh-hero__dot.active::after {
  transform: scaleX(1);
  background: var(--color-primary);
}

#fh-home-v2 .fh-hero__dot.active.dir-right::after {
  transform-origin: left center;
}

#fh-home-v2 .fh-hero__dot.active.dir-left::after {
  transform-origin: right center;
}

/*
 * Popular dots: same hit-target pattern (do not enlarge the painted indicator).
 * Override V1 width/background on the button itself.
 */
#fh-home-v2 .fh-pop-dot {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  box-sizing: border-box;
}

#fh-home-v2 .fh-pop-dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  margin-left: -4px;
  border-radius: 50%;
  background: #e0e0e0;
  transform: none;
  transition: width 0.3s ease, margin-left 0.3s ease, border-radius 0.3s ease, background 0.3s ease;
}

#fh-home-v2 .fh-pop-dot.active {
  width: 44px;
  background: transparent;
}

#fh-home-v2 .fh-pop-dot.active::after {
  width: 24px;
  margin-left: -12px;
  border-radius: 4px;
  background: var(--color-primary);
}

/* Focus visibility */
#fh-home-v2 a:focus-visible,
#fh-home-v2 button:focus-visible,
#fh-home-v2 .fh-hero__dot:focus-visible,
#fh-home-v2 .fh-pop-dot:focus-visible,
#fh-home-v2 .fh-cats__tag:focus-visible,
#fh-home-v2 .fh-cta__btn:focus-visible,
#fh-home-v2 .fh-section__more-btn:focus-visible,
#fh-home-v2 .fh-newsletter__input:focus-visible,
#fh-home-v2 .fh-newsletter__btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

#fh-home-v2 .fh-newsletter__input:focus {
  outline: none;
}

#fh-home-v2 .fh-newsletter__input:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(255, 130, 80, 0.55);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  #fh-home-v2 .fh-hero__track {
    transition: none;
  }

  #fh-home-v2 .fh-card,
  #fh-home-v2 .fh-card__img-link img,
  #fh-home-v2 .fh-hero__dot::after,
  #fh-home-v2 .fh-pop-dot::after {
    transition: none;
  }

  #fh-home-v2 .fh-card:hover {
    transform: none;
  }

  #fh-home-v2 .fh-card:hover .fh-card__img-link img {
    transform: none;
  }
}

/* Tablet + mobile hero — V1-matching fixed image height */
@media (max-width: 767px) {
  #fh-home-v2 .fh-hero__img-wrap {
    height: 170px !important;
    width: calc(100% - 32px) !important;
    max-width: none;
    margin: 12px 16px 0 !important;
    border-radius: 16px !important;
  }

  #fh-home-v2 .fh-hero__content {
    grid-template-columns: 1fr;
    padding: 42px 16px 12px;
    gap: 0;
  }

  #fh-home-v2 h1.fh-hero__title,
  #fh-home-v2 p.fh-hero__title {
    font-size: clamp(20px, 5.5vw, 22px);
  }

  #fh-home-v2 .fh-hero__right {
    display: none;
  }

  #fh-home-v2 .fh-hero__author-badge {
    bottom: 12px;
    right: 12px;
  }

  #fh-home-v2 .fh-hero__dots {
    padding: 10px 16px 0;
  }
}

/* Long card titles may wrap; do NOT use anywhere on hero (CLS filmstrip cause) */
#fh-home-v2 .fh-card__title a {
  overflow-wrap: break-word;
  word-break: normal;
}

#fh-home-v2 .fh-cta__heading,
#fh-home-v2 .fh-cta__sub {
  overflow-wrap: break-word;
}
