/* =========================================
   Flow – School Category Block
   ========================================= */

.flow-school-category {
  padding: 0;
  gap: 1.125rem;
}

/* === Layout Wrapper === */
.flow-school-category .content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* === Mobile-first: title above image === */
.category-content-block {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "title"
    "image"
    "text";
  gap: 1.5rem;
}

/* --- Category Title --- */
.category-title {
  grid-area: title;
  font-size: 2rem; /* ~h3 size */
  font-weight: 700;
  color: var(--almost-black);
  margin: 0;
}

/* --- Category Text --- */
.category-text {
  grid-area: text;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
}

.category-description {
  line-height: 1.6;
  color: var(--text-color);
  margin: 0 0 0.5rem;
}

.category-description p {
  margin-bottom: 1rem;
}

.category-text .btn {
  align-self: start;
}

/* --- Mobile Image (16:9) --- */
.category-image-mobile {
  grid-area: image;
  overflow: hidden;
}

.category-image-mobile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0 2.25rem;
  aspect-ratio: 4 / 3;
}

/* --- Desktop Image (hidden by default) --- */
.category-image-desktop {
  display: none;
}

.category-image-desktop img {
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 4rem 0;
  display: block;
  aspect-ratio: 1 / 1;
}

/* === Topics Grid === */
.category-topics {
  margin-top: 0.5rem;
  margin-bottom: 3rem;
}

.topics-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

/* --- Topic Card --- */
.topic-card {
  background-color: var(--bg-color);
  border-radius: 0.5rem;
  border: 2px solid var(--border-color);
  transition:
    box-shadow 0.3s ease,
    transform 0.2s ease;
}
.topic-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}
.topic-card:hover .topic-title {
  color: var(--deep-blue);
}

.topic-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  gap: 1rem;
  max-height: 94px;
  border-radius: 0.5rem;
  overflow: hidden;
  transition: all 0.2s ease;
}

.topic-link:focus-visible {
  outline: 3px solid var(--pink);
  outline-offset: 5px;
  background-color: transparent;
  border-radius: 0.2rem;
}

/* --- Topic Image --- */
.topic-img {
  flex-shrink: 0;
  width: 94px;
  height: 94px;
  overflow: hidden;
  transition: transform 0.3s ease;
}
.topic-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
  transition: transform 0.3s ease;
}
.topic-card:hover .topic-img img {
  transform: scale(1.05);
}

/* --- Topic Text --- */
.topic-title {
  font-size: 1.125rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  height: 100%;
  margin: 0;
  line-height: 1.3;
  transition: color 0.2s ease;
}
.topic-text {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
  height: 100%;
}
.topic-text i {
  font-size: 1.25rem;
  color: var(--deep-blue);
  flex-shrink: 0;
}

h3.topics-label {
  margin: 0 0 1rem 0;
}

/* === Mobile order fix (Title → Image → Text → Topics) === */
@media (max-width: 63.9375rem) {
  .flow-school-category {
    display: flex;
    flex-direction: column;
  }

  /* Explicitly order children for clarity */
  .flow-school-category .category-title {
    order: 1;
  }

  .flow-school-category .category-image-mobile {
    order: 2;
    /* margin: 1.25rem auto; */
  }

  .flow-school-category .category-content-block {
    order: 3;
  }

  .flow-school-category .category-topics {
    order: 4;
  }

  /* Remove any grid behaviour on mobile */
  .category-content-block {
    display: block;
  }
}

/* === Desktop baseline === */
@media (min-width: 64rem) {
  .flow-school-category {
    padding: 0 0 4rem 0;
    border-bottom: 4px dotted var(--border-light);
    margin-bottom: 4rem;
  }

  .category-content-block {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
  }

  .category-text {
    flex: 3;
  }

  .category-image-desktop {
    flex: 1;
    display: block;
    min-width: 320px;
    width: 100%;
  }

  .category-image-mobile {
    display: none;
  }

  .category-title {
    font-size: 2.25rem;
    margin-bottom: 0.75rem;
  }

  h3.topics-label {
    font-size: 1.6rem;
    margin: 1.75rem 0 1rem;
  }

  .category-description p {
    margin-bottom: 1.875rem;
  }

  .topics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
  }

  .topic-card {
    height: 100%;
    max-width: 312px;
  }

  .category-topics {
    margin-top: 0;
    margin-bottom: 0;
  }

  .topic-link {
    flex-direction: row;
    align-items: flex-start;
    height: 100%;
  }

  .topic-text {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0 1rem 0 0;
  }

  .topic-text i {
    display: none;
  }
}

/* === Medium desktop (769–1439px): 2-column topic grid === */
@media (min-width: 48.0625rem) and (max-width: 89.9375rem) {
  .topic-card {
    height: 100%;
    max-width: 100%;
  }
  .topics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

/* === Large desktop (≥1440px): 3-column topic grid === */
@media (min-width: 90rem) {
  .topics-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
