/* ============================================================
   Featured reference projects – zigzag portfolio
   Sits between the interactive map and the clients logos
   ============================================================ */

.ref-featured {
  position: relative;
  z-index: 3;
  padding: 48px 0 56px;
  background: linear-gradient(180deg, #f4f8fb 0%, #ffffff 100%);
  color: var(--color-font);
  font-family: var(--font-stack);
}

/* Project-wide typography adds padding: 0.67em 0 to every <p> and
   <h1>-<h6> (see assets/scss/base/_typography.scss). That inherited
   padding would silently stretch client/name/location into 2x their
   real height here. Reset only padding (not margin - our component
   styles use margin for spacing). Use :where() so this reset has zero
   specificity and never beats a .ref-featured__* rule below. */
.ref-featured :where(p, h2, h3) {
  width: auto;
  padding: 0;
}

/* No local .container override - fall back to the project's base
   .container (max-width 1920, padding 0 2vw) so this section is as wide
   as the rest of the page instead of being boxed in a narrow 1360px frame. */

/* ---------- Section header ---------- */

/* Left-aligned header to match the rest of the site. Title + short green
   accent bar + lead paragraph, all flush left. */
.ref-featured__head {
  max-width: none;
  margin: 0 0 48px;
  text-align: left;
}

.ref-featured__title {
  margin: 0;
  color: var(--color-black);
  font-size: 3.8rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.ref-featured__divider {
  display: block;
  width: 56px;
  height: 3px;
  margin: 18px 0;
  background: var(--color-green-3);
  border-radius: 2px;
}

.ref-featured__lead {
  max-width: 820px;
  margin: 0;
  color: var(--color-gray-6);
  font-size: 1.65rem;
  line-height: 1.55;
}

/* ---------- Zigzag list ---------- */

.ref-featured__list {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

/* Equal 1fr : 1fr columns on both normal and flipped cards. This keeps the
   photo <-> text split exactly on the card's midline so when you scan the
   page vertically the left photo (card 1) ends at the same X where the
   right photo (card 2) begins - no optical shift between rows. */
.ref-featured__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 48px;
  align-items: stretch;
}

.ref-featured__item--flip {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

/* Reset intrinsic sizing of grid children so an image's natural width
   cannot push its column wider than the fr track allocates. */
.ref-featured__media,
.ref-featured__body {
  min-width: 0;
  min-height: 0;
}

.ref-featured__item--flip .ref-featured__media {
  order: 2;
}

.ref-featured__item--flip .ref-featured__body {
  order: 1;
}

/* ---------- Media (hero image, click-to-open) ---------- */

.ref-featured__media {
  position: relative;
  display: block;
  overflow: hidden;
  width: 100%;
  height: 100%;
  min-height: 300px;
  /* Grayscale fallback for the inline background-image (shown briefly
     before the <img.ref-featured__hero> finishes decoding). Keeps the
     B/W preview consistent even during image load. */
  background-color: #e4ebf0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  background-blend-mode: luminosity;
  border-radius: 10px;
  box-shadow: 0 20px 48px -24px rgba(23, 50, 65, 0.38);
  text-decoration: none;
  outline: none;
}

.ref-featured__hero {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.02);
  /* Editorial B/W preview — full color is reserved for the Fancybox detail
     (which lives in a separate overlay and is not affected by this filter). */
  filter: grayscale(100%);
  transition: transform 0.6s cubic-bezier(0.2, 0.6, 0.2, 1), filter 0.4s ease;
  will-change: transform, filter;
}

.ref-featured__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(170deg, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.35) 100%);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.ref-featured__media:hover .ref-featured__hero,
.ref-featured__media:focus-visible .ref-featured__hero {
  transform: scale(1.06);
  filter: grayscale(100%) brightness(1.05);
}

.ref-featured__media:focus-visible {
  outline: 3px solid var(--color-green-3);
  outline-offset: 3px;
}

/* Country / scope badge on the hero */

.ref-featured__badge {
  position: absolute;
  top: 16px;
  left: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(4px);
  border-radius: 999px;
  color: var(--color-black);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  z-index: 2;
}

.ref-featured__badge-flags {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ref-featured__badge svg {
  width: 22px;
  height: 15px;
  display: block;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.ref-featured__zoom {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--color-white);
  border-radius: 50%;
  color: var(--color-green-5);
  box-shadow: 0 10px 20px -8px rgba(0, 0, 0, 0.35);
  z-index: 2;
  transform: translateY(6px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease, background 0.2s ease, color 0.2s ease;
}

.ref-featured__zoom svg {
  width: 20px;
  height: 20px;
}

.ref-featured__media:hover .ref-featured__zoom,
.ref-featured__media:focus-visible .ref-featured__zoom {
  transform: translateY(0);
  opacity: 1;
}

.ref-featured__media:hover .ref-featured__zoom {
  background: var(--color-green-3);
  color: var(--color-white);
}

/* ---------- Body (text column) ---------- */

.ref-featured__body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 0;
}

/* Compact text stack with small breathing room. Project size tokens:
   client → name: var(--size-5) = 5px
   name   → loc : var(--size-5) = 5px
   loc    → desc: var(--size-20) = 20px (bigger because desc is a new block) */
.ref-featured__client {
  margin: 0 0 var(--size-5);
  color: var(--color-green-5);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1;
}

.ref-featured__name {
  margin: 0 0 var(--size-5);
  color: var(--color-black);
  font-size: 2.3rem;
  font-weight: 700;
  line-height: 1.15;
}

.ref-featured__loc {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 var(--size-20);
  color: var(--color-gray-6);
  font-size: 1.4rem;
  line-height: 1.2;
}

.ref-featured__pin {
  width: 14px;
  height: 14px;
  color: var(--color-green-4);
  flex-shrink: 0;
}

/* .ref-featured__tags removed - cluttered the card, hero image + title +
   description already convey the project scope. */

.ref-featured__desc {
  margin: 0 0 18px;
  color: var(--color-font);
  font-size: 1.6rem;
  line-height: 1.6;
}

/* ---------- Mini thumbnail row ---------- */

.ref-featured__thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 6px;
  margin: 0 0 16px;
}

.ref-featured__thumb {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  background: #e4ebf0 center / cover no-repeat;
  border-radius: 6px;
  overflow: hidden;
  outline: none;
  /* Editorial B/W preview (same as hero). Fancybox detail stays in colour. */
  filter: grayscale(100%);
  transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.3s ease;
}

.ref-featured__thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(23, 120, 114, 0);
  transition: background 0.25s ease;
}

.ref-featured__thumb:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px -14px rgba(23, 50, 65, 0.45);
}

.ref-featured__thumb:hover::after {
  background: rgba(23, 120, 114, 0.18);
}

.ref-featured__thumb:focus-visible {
  outline: 2px solid var(--color-green-3);
  outline-offset: 2px;
}

/* ---------- CTA button ----------
   Uses the site-wide .btn.btn--green pattern (see _buttons.scss) so it
   visually matches every other primary CTA on the site (Poptat zakázku,
   Zobrazit kontakty, …). We only add component-local tweaks:
   - align the button to the left of the card body (not stretched)
   - a muted "(N)" count after the label
   - focus-visible ring for keyboard users
   - a modestly smaller label + arrow (the global .btn uses 1.1vw font
     and 0.5vw SVG, which on 1920px screens balloons to ~21px text and
     a ~17px tall chevron — too heavy for a secondary card CTA). */

.ref-featured__cta {
  align-self: flex-start;
  gap: var(--size-5);
  padding: 8px 14px;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
}

.ref-featured__cta svg {
  width: 6px;
  margin-left: 8px;
}

.ref-featured__cta:focus-visible {
  outline: 2px solid var(--color-green-3);
  outline-offset: 3px;
}

.ref-featured__cta-count {
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}

/* Keep the compact sizing on narrow phones too — the global .btn would
   otherwise jump to 3.6vw font / 1.8vw svg below the xxs breakpoint. */
@media (max-width: 420px) {
  .ref-featured__cta {
    font-size: 1.3rem;
    padding: 8px 12px;
  }
  .ref-featured__cta svg {
    width: 6px;
  }
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1100px) {
  .ref-featured { padding: 40px 0 48px; }
  .ref-featured__list { gap: 36px; }
  .ref-featured__item,
  .ref-featured__item--flip {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .ref-featured__item--flip .ref-featured__media,
  .ref-featured__item--flip .ref-featured__body {
    order: initial;
  }
  .ref-featured__body { padding: 0; }
}

@media (max-width: 1100px) {
  /* Stacked layout: give the media an explicit aspect ratio since there
     is no sibling column to borrow its height from any more. */
  .ref-featured__media {
    height: auto;
    min-height: 0;
    aspect-ratio: 4 / 3;
  }
}

@media (max-width: 700px) {
  .ref-featured { padding: 36px 0 44px; }
  .ref-featured__head { margin-bottom: 36px; }
  .ref-featured__title { font-size: 2.6rem; }
  .ref-featured__divider { width: 44px; margin: 16px auto 16px; }
  .ref-featured__lead { font-size: 1.5rem; }
  .ref-featured__name { font-size: 2.1rem; }
  .ref-featured__list { gap: 32px; }
  .ref-featured__thumbs { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
}

@media (max-width: 420px) {
  .ref-featured__badge { font-size: 1.1rem; padding: 5px 10px 5px 7px; }
  .ref-featured__zoom { width: 38px; height: 38px; }
  .ref-featured__zoom svg { width: 18px; height: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .ref-featured__hero,
  .ref-featured__thumb,
  .ref-featured__zoom {
    transition: none;
  }
}
