/* =========================================================
   Interest Area Cards Module
   ========================================================= */

.interest-area-cards-section {
  max-width: 1236px;
  margin: 0 auto;
  width: 100%;
}

/* Grid */
.interest-area-cards-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2em;
}

/* =========================================================
   Individual Card
   ========================================================= */

.interest-area-card {
  position: relative;
  width: calc(50% - 1em);
  aspect-ratio: 7 / 8;
  overflow: hidden;
  box-shadow: 0 10px 20px 0 rgba(0, 0, 0, 0.3);
}

/* Allow full focus ring (outline + offset) while keyboard focus; default overflow clips it */
.interest-area-card:has(:focus-visible) {
  overflow: visible;
  z-index: 2;
}

/* Accent bar sits above all child overlays via z-index */
.interest-area-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 18px;
  background: var(--tertiary-color);
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

@media (hover: hover) {
  .interest-area-card:hover::after,
  .interest-area-card:focus-within::after {
    opacity: 1;
  }
}

/* Responsive: single column on mobile */
@media (max-width: 767px) {
  .interest-area-card {
    width: 100%;
    max-width: 375px;
  }
}

/* =========================================================
   Background Image
   ========================================================= */

.card-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.card-bg--no-image {
  background-color: #333;
}

/* =========================================================
   Overlays
   ========================================================= */

/* Permanent gradient: white (0% opacity) → black (70% opacity) */
.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(0, 0, 0, 0.7) 100%);
  pointer-events: none;
}

/* Dark overlay on interaction */
.card-hover-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 0.3s ease;
  pointer-events: none;
}

/* Mobile: only JS-toggled .is-expanded drives the overlay */
.interest-area-card.is-expanded .card-hover-overlay {
  background: rgba(0, 0, 0, 0.3);
}

/* Desktop: also trigger on CSS hover/focus-within */
@media (hover: hover) {
  .interest-area-card:hover .card-hover-overlay,
  .interest-area-card:focus-within .card-hover-overlay {
    background: rgba(0, 0, 0, 0.3);
  }
}

/* =========================================================
   Card Panel
   Anchored to card bottom; grows upward as grant list expands,
   raising the label and revealing the list below it.
   ========================================================= */

.card-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2.5em 1.5em;
}

/* =========================================================
   Card Label Row + Label
   ========================================================= */

.card-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75em;
  min-height: 44px;
}

.card-label {
  color: #ffffff;
  font-size: 1.75rem; /* 28px */
  font-weight: 600;
  text-decoration: none;
  line-height: 1.2;
  flex: 1;
  cursor: pointer;
}

@media (min-width: 768px) and (max-width: 980px) {
  .card-label {
    font-size: 1.5rem; /* 24px */
  }
}

/* Mid-range: 981px–1200px */
@media (min-width: 981px) and (max-width: 1200px) {
  .card-label {
    font-size: 1.625rem; /* 26px */
  }
}

/* Mobile */
@media (max-width: 767px) {
  .card-label {
    font-size: 1.25rem; /* 20px */
    color: var(--tertiary-color);
  }
}

.card-label:focus-visible {
  outline: 2px solid var(--tertiary-color);
  outline-offset: 2px;
}

/* =========================================================
   Arrow Button
   Uses Divi's ETmodules font; \21 renders the arrow glyph.
   ========================================================= */

.card-arrow-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: #ffffff;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
}

.card-arrow-btn:focus-visible {
  outline: 2px solid var(--tertiary-color);
  outline-offset: 2px;
  border-radius: 2px;
}

.card-arrow-icon {
  font-family: var(--font-etmodules);
  font-style: normal;
  font-weight: 700;
  font-variant: normal;
  text-transform: none;
  line-height: 1;
  display: inline-block;
  font-size: 2em;
  transition: transform 0.3s ease;
}

/* Mobile: arrow is always yellow */
@media (max-width: 767px) {
  .card-arrow-icon {
    color: var(--tertiary-color);
  }
}

/* Focus/active: yellow on the icon */
.card-arrow-btn:focus .card-arrow-icon,
.card-arrow-btn:active .card-arrow-icon {
  color: var(--tertiary-color);
}

/* Desktop hover: rotate arrow + turn label and arrow yellow */
@media (hover: hover) {
  .interest-area-card:hover .card-arrow-icon,
  .interest-area-card:focus-within .card-arrow-icon {
    transform: rotate(180deg);
    color: var(--tertiary-color);
  }
  .interest-area-card:hover .card-label,
  .interest-area-card:focus-within .card-label {
    color: var(--tertiary-color);
  }
}

/* JS-expanded: rotate arrow (mobile toggle) */
.interest-area-card.is-expanded .card-arrow-icon {
  transform: rotate(180deg);
}

/* =========================================================
   Grant Areas List
   Revealed below the label row on hover / expand.
   ========================================================= */

.card-grant-areas {
  list-style: none;
  margin: 0.5em 0 0;
  padding: 0 !important;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition:
    max-height 0.4s ease,
    opacity 0.3s ease;
}

.card-grant-areas:has(:focus-visible) {
  overflow: visible;
}

/* Desktop: reveal on CSS hover */
@media (hover: hover) {
  .interest-area-card:hover .card-grant-areas,
  .interest-area-card:focus-within .card-grant-areas {
    max-height: 500px;
    opacity: 1;
  }
}

/* Mobile & JS-driven: reveal via .is-expanded */
.interest-area-card.is-expanded .card-grant-areas {
  max-height: 500px;
  opacity: 1;
}

.card-grant-areas li {
  margin: 0;
  padding: 0;
}

.card-grant-areas li + li {
  margin-top: 0.35em;
}

.card-grant-areas a {
  color: #ffffff;
  font-size: 1.625rem; /* 26px */
  font-weight: 400;
  text-decoration: none;
  line-height: 1.7;
  display: block;
  cursor: pointer;
  transition: color 0.2s ease;
}

@media (min-width: 768px) and (max-width: 980px) {
  .card-grant-areas a {
    font-size: 1rem; /* 18px */
    line-height: 1.3;
  }
}

/* Mid-range: 768px–1200px */
@media (min-width: 981px) and (max-width: 1200px) {
  .card-grant-areas a {
    font-size: 1.375rem; /* 22px */
    line-height: 1.3;
  }
}

/* Mobile */
@media (max-width: 767px) {
  .card-grant-areas a {
    font-size: 1rem; /* 16px */
  }
}

/* Desktop: colour change on hover */
@media (hover: hover) {
  .card-grant-areas a:hover {
    color: var(--tertiary-color);
    text-decoration: none;
  }
}

.card-grant-areas a:focus-visible {
  outline: 2px solid var(--tertiary-color);
  outline-offset: 2px;
  text-decoration: none;
}

/* =========================================================
   Reduced Motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .interest-area-card::after,
  .card-hover-overlay,
  .card-grant-areas,
  .card-arrow-icon,
  .card-grant-areas a {
    transition: none;
  }
}
