/*
 * SAH Archipedia — Homepage styles.
 */

/* =============================================
   Hero — Featured content grid
   ============================================= */

.sah-front__hero {
  padding: 0.5rem 0 1rem;
}

.sah-front__hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

/* Tablet and up: 2-column hero grid */
@media (min-width: 768px) {
  .sah-front__hero-grid {
    grid-template-columns: 2fr 1fr;
    min-height: 400px;
  }
}

.sah-front__hero-big,
.sah-front__hero-small {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  
  background-size: cover;
  background-position: center;
  color: #fff;
  text-decoration: none;
  height: 450px;
}

.sah-front__hero-big {
  /* Placeholder — will be set dynamically or via inline style */
  background-image: url('https://placehold.co/800x400/014360/5acaeb?text=Featured+Entry');
}

/* Mobile: shorter cards */
@media (max-width: 767px) {
  .sah-front__hero-big,
  .sah-front__hero-small {
    height: 280px;
  }
}

/* Tablet: mid-height cards */
@media (min-width: 768px) and (max-width: 1023px) {
  .sah-front__hero-big,
  .sah-front__hero-small {
    height: 400px;
  }
}

.sah-front__hero-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sah-front__hero-small {
  flex: 1;
  min-height: 150px;
}

.sah-front__hero-small:nth-child(1) {
  background-image: url('https://placehold.co/400x300/238fb5/fff?text=Featured+Essay');
}

.sah-front__hero-small:nth-child(2) {
  background-image: url('https://placehold.co/400x300/137b9a/fff?text=Regional+Essay');
}

/* Scrim, ported from the legacy site's `.featured .entry::before`.
   It's a pseudo-element behind the text rather than a wrapper around it, so
   the opacity transition darkens only the band — never the label or title.
   top:60% + height:50% deliberately overruns the panel; `overflow: hidden`
   on the panel clips it, which keeps the band flush to the bottom edge. */
.sah-front__hero-big::before,
.sah-front__hero-small::before {
  content: "";
  display: block;
  position: absolute;
  top: 60%;
  left: 0;
  width: 100%;
  height: 50%;
  background-color: #151515;
  opacity: 0.5;
  transition: opacity 0.4s ease-in-out;
  z-index: 1;
}

.sah-front__hero-big:hover::before,
.sah-front__hero-small:hover::before {
  opacity: 0.8;
}

.sah-front__hero-big:hover,
.sah-front__hero-small:hover {
  /* Keep title legible: Olivero's a:hover (0,1,1) would otherwise
     override the link's #fff with --color--primary-50 (a mid-blue)
     against the dark image overlay. This selector (0,2,0) wins. */
  color: #fff;
}

.sah-front__hero-big:focus-visible,
.sah-front__hero-small:focus-visible {
  outline: 3px solid #5acaeb;
  outline-offset: 2px;
}

.sah-front__hero-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

/* Text layer. Carries no background of its own — the scrim above does that —
   so it just positions the label and title over the band.
   Lengths are px because the legacy site sets a 10px root (`font-size: 62.5%`),
   making its rem values effectively px; our root is 16px. They're also scaled
   ~0.8 from that site's values, because our panel is 450px where its was 564px
   — at full size the label rides up out of the band on a two-line title. */
.sah-front__hero-overlay {
  position: absolute;
  left: 0;
  bottom: 20px;
  width: 100%;
  box-sizing: border-box;
  padding: 0 20% 0 48px;
  z-index: 2;
}

.sah-front__hero-label {
  display: inline-block;
  background-color: #106182;
  color: #fff;
  padding: 0 12px;
  font-size: 11px;
  line-height: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 16px;
}

.sah-front__hero-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 28px;
  font-weight: 400;
  line-height: 1.333;
  text-transform: uppercase;
  margin-bottom: 22px;
}

.sah-front__hero-small .sah-front__hero-overlay {
  bottom: 18px;
  padding: 0 10% 0 24px;
}

.sah-front__hero-small .sah-front__hero-label {
  font-size: 10px;
  line-height: 17px;
  margin-bottom: 10px;
}

.sah-front__hero-small .sah-front__hero-title {
  font-size: 16px;
  margin-bottom: 9px;
}

/* Tablet: panel drops to 400px, so the text scales again to stay in the band. */
@media (min-width: 768px) and (max-width: 1023px) {
  .sah-front__hero-overlay {
    padding: 0 10% 0 42px;
  }

  .sah-front__hero-label {
    line-height: 18px;
    margin-bottom: 14px;
  }

  .sah-front__hero-title {
    font-size: 25px;
    margin-bottom: 20px;
  }
}

/* Mobile: 280px panels — tighter gutters and the smallest text step. */
@media (max-width: 767px) {
  .sah-front__hero-overlay,
  .sah-front__hero-small .sah-front__hero-overlay {
    bottom: 16px;
    padding: 0 24px;
  }

  .sah-front__hero-label,
  .sah-front__hero-small .sah-front__hero-label {
    font-size: 10px;
    line-height: 17px;
    margin-bottom: 10px;
  }

  .sah-front__hero-title,
  .sah-front__hero-small .sah-front__hero-title {
    color: #fff;
    font-size: 18px;
    margin-bottom: 10px;
    -webkit-line-clamp: 2;
  }
}

/* =============================================
   Search bar
   ============================================= */

.sah-front__search {
  padding: 0 0 1.5rem;
}

/* Border lives on the input, not on a wrapper, to match the search page bar.
   No overflow: hidden here — the wrapper has nothing left to clip, and its
   absence lets the button's focus ring sit outside the control (see below). */
.sah-front__search-form {
  display: flex;
}

/* Olivero's own tokens rather than the literal #8196a2 / 3px: the search page
   input gets this border from Olivero's form-text.css (its [type="search"]
   rule outranks search.css on load order), so referencing the same variables
   keeps the two bars in step if the base theme's grey ever shifts. */
.sah-front__search-input {
  flex: 1;
  border: 1px solid var(--color--gray-60);
  border-radius: var(--border-radius);
  padding: 1.5rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: #333;
}

.sah-front__search-input:focus {
  outline: 3px solid #238fb5;
  outline-offset: -3px;
}

/* #888 measured 3.54:1 on white, under the 4.5:1 floor. #5a6b73 is 5.55:1 and
   matches the placeholder colour on the search page. */
.sah-front__search-input::placeholder {
  color: #5a6b73;
}

.sah-front__search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #014360;
  color: #fff;
  border: none;
  padding: 0 1.5rem;
  cursor: pointer;
  transition: background-color 0.15s;
}

.sah-front__search-btn:hover {
  background-color: #238fb5;
}

/* Same outside-the-control ring as the search page buttons. It was previously
   an inset #5acaeb ring only because the form's overflow: hidden would have
   clipped anything drawn outside; that wrapper is gone now. #014360 on the
   page background is 10.6:1, against 5.62:1 for the old inset ring. */
.sah-front__search-btn:focus-visible {
  outline: 3px solid #014360;
  outline-offset: 2px;
  position: relative;
  z-index: 1;
}

/* =============================================
   Section headings
   ============================================= */

.sah-front__section-heading {
  font-weight: 500;
  font-size: 2rem;
  color: #014360;
  text-align: center;
  margin-bottom: 1.25rem;
  letter-spacing: 0.03em;
  margin-top: 0;
}

/* =============================================
   Browse category tiles
   ============================================= */

.sah-front__browse {
  margin-bottom: 25px;
}

.sah-front__browse-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

/* Large mobile: 3 browse columns */
@media (min-width: 576px) {
  .sah-front__browse-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Desktop: all 6 browse columns in one row */
@media (min-width: 992px) {
  .sah-front__browse-grid {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  }
}

.sah-front__browse-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 0.75rem;
  border-radius: 4px;
  background-color: #014360;
  color: #fff;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

/* (0,2,0) beats Olivero's a:hover (0,1,1), which would otherwise swap the
   white label for --color--primary-50. */
.sah-front__browse-tile:hover {
  background-color: #014360;
  color: #fff;
}

.sah-front__browse-tile:focus-visible {
  outline: 3px solid #238fb5;
  outline-offset: 2px;
}

.sah-front__browse-icon {
  margin-bottom: 0.5rem;
  color: inherit;
}

.sah-front__browse-label {
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Desktop only: drop the tinted box and divide the row with hairline rules.
   This is gated to the 6-across breakpoint on purpose — at 2 and 3 columns the
   left rules land mid-grid and the tap targets lose their edges, so the tinted
   tiles above stay in force there. Must follow the base rules to win on source
   order; media queries carry no extra specificity. */
@media (min-width: 992px) {
  .sah-front__browse-grid {
    gap: 0;
  }

  .sah-front__browse-tile {
    /* Transparent, not #fff — the row sits on the page ground, and an actual
       white fill would read as the box this treatment is removing. */
    background-color: transparent;
    color: #014360;
    border-radius: 0;
    border-left: 1px solid #d6e3ea;
    transition: color 0.15s, background-color 0.15s;
  }

  .sah-front__browse-tile:first-child {
    border-left: 0;
  }

  .sah-front__browse-tile:hover {
    background-color: #014360;
    color: #fff;
  }

  .sah-front__browse-label {
    border-bottom: 2px solid transparent;
    padding-bottom: 2px;
    transition: border-color 0.15s;
  }

  .sah-front__browse-tile:hover .sah-front__browse-label {
    border-bottom-color: transparent;
  }
}

/* =============================================
   Highlights — entry cards
   ============================================= */

.sah-front__highlights {
  padding: 2rem 0;
}

/* Mobile: tighter highlights spacing */
@media (max-width: 767px) {
  .sah-front__highlights {
    padding: 1.25rem 0;
  }

  .sah-front__section-heading {
    font-size: 1.65rem;
    margin-bottom: 1.25rem;
  }
}

.sah-front__highlights-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

/* Large mobile: 2 highlight columns */
@media (min-width: 576px) {
  .sah-front__highlights-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Tablet: 3 highlight columns */
@media (min-width: 768px) and (max-width: 1023px) {
  .sah-front__highlights-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Desktop: full 4 highlight columns */
@media (min-width: 1024px) {
  .sah-front__highlights-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.sah-front__card {
  display: block;
  text-decoration: none;
  background: #014360;
  border-radius: 4px;
  overflow: hidden;
  transition: box-shadow 0.15s;
}

.sah-front__card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.sah-front__card:focus-visible {
  outline: 3px solid #238fb5;
  outline-offset: 2px;
}

.sah-front__card-image {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background-color: #e8f4f8;
}

.sah-front__card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}

.sah-front__card:hover .sah-front__card-image img {
  transform: scale(1.03);
}

.sah-front__card-body {
  padding: 1rem;
  background: #014360;
}

.sah-front__card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 0.35rem;
  line-height: 1.3;
}

.sah-front__card-teaser {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #fff;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* =============================================
   About blurb
   ============================================= */

.sah-front__about {
  padding: 1.5rem 0 2rem;
  text-align: center;
}

.sah-front__about p {
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.7;
  color: #333;
  font-size: 0.95rem;
}
