/*
 * AnomaliPedia UI layer
 * Loaded after News Portal's responsive stylesheet.
 * Version follows the parent theme version for reliable cache busting.
 */

:root {
  --ap-accent: #e21f26;
  --ap-header: #029fb2;
  --ap-text: #202124;
  --ap-muted: #858585;
  --ap-line: #e9e9e9;
}

html,
body,
#page {
  overflow-x: clip;
}

/* Header: logo is part of the sticky navigation, not a separate white row. */
#masthead .np-logo-section-wrapper {
  display: none !important;
}

#masthead .np-header-menu-wrapper,
#masthead .np-header-menu-wrapper .mt-container {
  min-height: 50px;
}

#masthead .np-header-menu-wrapper .site-branding {
  position: absolute;
  z-index: 110;
  top: 6px;
  left: 50%;
  float: none;
  width: auto;
  height: 38px;
  margin: 0;
  padding: 0;
  transform: translateX(-50%);
}

#masthead .np-header-menu-wrapper .custom-logo-link {
  display: flex;
  align-items: center;
  height: 38px;
}

#masthead .np-header-menu-wrapper img.custom-logo {
  display: block;
  width: auto !important;
  height: auto !important;
  max-width: 160px !important;
  max-height: 38px !important;
  object-fit: contain;
}

#masthead .np-header-menu-wrapper .site-title {
  margin: 0;
  font-size: 20px;
  line-height: 38px;
  white-space: nowrap;
}

#masthead .np-header-menu-wrapper .site-title a {
  color: #fff;
}

#masthead .np-home-icon a,
#masthead #site-navigation > div > ul > li,
#masthead #site-navigation > ul > li,
#masthead .search-main {
  line-height: 50px;
}

#masthead .np-icon-elements {
  margin-top: 15px;
  margin-bottom: 15px;
}

/* Homepage frame */
body.home #content {
  margin-top: 18px;
}

body.home main#primary.np-news-home {
  float: none !important;
  width: 100% !important;
}

body.home .np-news-home article {
  float: none;
  width: auto;
  margin: 0;
  padding: 0;
  border: 0 !important;
  box-shadow: none;
}

body.home .np-news-home a {
  text-decoration: none;
}

/*
 * 1. Hero News
 * Desktop uses a capped editorial width and viewport-aware height so the
 * hero does not consume an entire laptop screen. Mobile switches to a
 * symmetrical full-bleed calculation based on News Portal's 4% gutters.
 */
body.home .np-hero-card {
  overflow: visible;
}

body.home .np-hero-content {
  padding: 0 0 16px;
}

body.home .np-hero-title {
  max-width: 980px;
  margin: 0 0 8px;
  color: var(--ap-text);
  font-size: clamp(30px, 3vw, 42px);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.02em;
  text-transform: none;
}

body.home .np-hero-title a,
body.home .np-featured-title a,
body.home .np-home-latest-title a {
  color: var(--ap-text);
}

body.home .np-news-time {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--ap-muted);
  font-size: 11px;
  line-height: 1.5;
}

body.home .np-hero-image-wrap {
  position: relative;
  left: auto;
  width: 100%;
  max-width: 1100px;
  margin-right: auto;
  margin-left: auto;
  background: #eceff1;
}

body.home .np-hero-image {
  display: block;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: min(62vh, 620px);
}

body.home .np-hero-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body.home .np-news-badge {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 10px;
  display: block;
  padding: 5px 9px;
  background: var(--ap-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

/*
 * 2. Featured News Carousel
 * This section intentionally stays inside the site container. The next card
 * remains partially visible and the track scrolls horizontally.
 */
body.home .np-featured-news {
  width: 100%;
  margin-top: 32px;
}

body.home .np-featured-track {
  display: flex !important;
  flex-flow: row nowrap !important;
  gap: 18px;
  overflow-x: auto !important;
  overflow-y: hidden;
  width: 100%;
  padding: 0 0 12px;
  overscroll-behavior-inline: contain;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

body.home .np-featured-card {
  display: flex !important;
  flex: 0 0 31% !important;
  flex-direction: column;
  min-width: 260px;
  scroll-snap-align: start;
}

body.home .np-featured-image-wrap {
  position: relative;
  width: 100%;
}

body.home .np-featured-image {
  display: block;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #eceff1;
}

body.home .np-featured-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

body.home .np-featured-card:hover .np-featured-image img {
  transform: scale(1.025);
}

body.home .np-featured-title {
  display: -webkit-box;
  overflow: hidden;
  margin: 9px 0 7px;
  color: var(--ap-text);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.35;
  text-transform: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

body.home .np-featured-card > .np-news-time {
  margin-top: auto;
}

/*
 * 3. Latest News List
 * Fixed thumbnail column on the left; title and metadata stay beside it.
 */
body.home .np-home-latest {
  width: 100%;
  max-width: 960px;
  margin-top: 48px;
}

body.home .np-home-section-title {
  position: relative;
  margin: 0 0 24px;
  padding-bottom: 13px;
  color: #171717;
  font-size: 23px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

body.home .np-home-section-title::after {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40px;
  height: 3px;
  background: var(--ap-accent);
  content: "";
}

body.home .np-home-latest-list {
  display: grid !important;
  gap: 18px;
}

body.home .np-home-latest-item {
  display: grid !important;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 17px;
  align-items: start;
  min-height: 135px;
  padding-bottom: 18px !important;
  border-bottom: 1px solid var(--ap-line) !important;
}

body.home .np-home-latest-item:last-child {
  min-height: 0;
  padding-bottom: 0 !important;
  border-bottom: 0 !important;
}

body.home .np-home-latest-item:not(.has-post-thumbnail) .np-home-latest-content {
  grid-column: 1 / -1;
}

body.home .np-home-latest-thumb {
  display: block;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #eceff1;
}

body.home .np-home-latest-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body.home .np-home-latest-content {
  min-width: 0;
}

body.home .np-home-latest-title {
  display: -webkit-box;
  overflow: hidden;
  margin: 0 0 8px;
  color: var(--ap-text);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.35;
  text-transform: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

body.home .np-home-latest-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  color: #999;
  font-size: 11px;
  line-height: 1.5;
}

body.home .np-home-latest-category {
  color: var(--ap-accent);
  font-weight: 700;
  text-transform: uppercase;
}

body.home .np-hero-title a:hover,
body.home .np-featured-title a:hover,
body.home .np-home-latest-title a:hover {
  color: var(--ap-accent);
}

body.home .np-home-latest .pagination {
  margin-top: 36px;
}

/* Dark mode */
.site-mode--dark.home .np-hero-title a,
.site-mode--dark.home .np-featured-title a,
.site-mode--dark.home .np-home-latest-title a,
.site-mode--dark.home .np-home-section-title {
  color: #f1f3f4;
}

.site-mode--dark.home .np-home-latest-item {
  border-bottom-color: rgba(255, 255, 255, 0.12) !important;
}

@media (max-width: 768px) {
  html {
    overflow-y: auto;
    scrollbar-width: none;
  }

  html::-webkit-scrollbar {
    width: 0;
    height: 0;
  }

  #masthead .np-header-menu-wrapper,
  #masthead .np-header-menu-wrapper .mt-container {
    min-height: 40px;
  }

  #masthead .np-header-menu-wrapper .site-branding {
    top: 5px;
    height: 30px;
  }

  #masthead .np-header-menu-wrapper .custom-logo-link {
    height: 30px;
  }

  #masthead .np-header-menu-wrapper img.custom-logo {
    max-width: 115px !important;
    max-height: 30px !important;
  }

  #masthead .np-header-menu-wrapper .site-title {
    font-size: 17px;
    line-height: 30px;
  }

  #masthead .np-home-icon a,
  #masthead .search-main {
    line-height: 40px;
  }

  #masthead .np-icon-elements {
    margin-top: 10px;
    margin-bottom: 10px;
  }

  body.home #content {
    margin-top: 14px;
  }

  body.home .np-hero-content {
    padding-bottom: 14px;
  }

  body.home .np-hero-title {
    margin-bottom: 7px;
    font-size: clamp(24px, 6.5vw, 30px);
    line-height: 1.2;
  }

  /*
   * At this breakpoint .mt-container has 4vw padding on both sides.
   * The content box is therefore 92vw. Expanding it by 8.695652% and
   * shifting by 4.347826% removes both gutters without 100vw rounding.
   */
  body.home .np-hero-image-wrap {
    width: calc(100% + 8.695652%);
    max-width: none;
    margin-right: 0;
    margin-left: -4.347826%;
  }

  body.home .np-hero-image {
    max-height: none;
  }

  body.home .np-featured-news {
    margin-top: 26px;
  }

  body.home .np-featured-track {
    gap: 13px;
    padding-right: 12%;
  }

  body.home .np-featured-card {
    flex-basis: min(76vw, 310px) !important;
    min-width: 0;
  }

  body.home .np-featured-title {
    font-size: 16px;
  }

  body.home .np-home-latest {
    margin-top: 42px;
  }

  body.home .np-home-section-title {
    margin-bottom: 20px;
    font-size: 20px;
  }

  body.home .np-home-latest-list {
    gap: 16px;
  }

  body.home .np-home-latest-item {
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 12px;
    min-height: 81px;
    padding-bottom: 16px !important;
  }

  body.home .np-home-latest-title {
    margin-bottom: 5px;
    font-size: 15px;
    line-height: 1.35;
  }

  body.home .np-home-latest-meta {
    font-size: 9px;
  }
}

@media (max-width: 480px) {
  #masthead .np-home-icon {
    display: none;
  }

  body.home .np-featured-card {
    flex-basis: 76vw !important;
  }

  body.home .np-home-latest-item {
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 11px;
    min-height: 75px;
  }
}

@media (max-width: 360px) {
  body.home .np-featured-card {
    flex-basis: 80vw !important;
  }

  body.home .np-home-latest-item {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  body.home .np-home-latest-meta time:last-of-type,
  body.home .np-home-latest-meta span:last-of-type {
    display: none;
  }
}
