/* =========================================================
   ForGrowth Academy — modulegrid.css
   ISOLATED. Every selector is scoped to #build-flow / .module-grid.
   No global rule, no redefinition of an existing selector.
   Tokens are read from styles.css so the section stays on-brand.
   ========================================================= */

.module-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.module-grid .mg-item {
  min-width: 0;              /* lets cards shrink — no horizontal overflow */
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------
   CARD
   --------------------------------------------------------- */
.module-grid .mg-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 20px 20px;

  /* Sits on the dark section, so the card is a light-on-dark plate. */
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;        /* deliberately not heavily rounded */
  cursor: pointer;

  transition:
    background-color 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    border-color 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.module-grid .mg-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(217, 64, 11, 0.5);
  transform: translateY(-2px);
}

.module-grid .mg-card:focus-visible {
  outline: 2px solid var(--accent, #D9400B);
  outline-offset: 2px;
}

/* Active state — orange accent, brighter plate, stronger title. */
.module-grid .mg-item.is-active .mg-card {
  background: rgba(217, 64, 11, 0.10);
  border-color: var(--accent, #D9400B);
}

.module-grid .mg-num {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--accent, #D9400B);
  line-height: 1;
}

.module-grid .mg-title {
  font-family: var(--font-display, sans-serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  color: rgba(248, 246, 241, 0.86);
  transition: color 0.35s ease, font-weight 0.2s ease;
  min-width: 0;
}

.module-grid .mg-card:hover .mg-title,
.module-grid .mg-item.is-active .mg-title {
  color: #fff;
  font-weight: 700;
}

/* Small plus that rotates to a minus when open. */
.module-grid .mg-plus {
  position: relative;
  width: 11px;
  height: 11px;
  flex: none;
  color: var(--accent, #D9400B);
  opacity: 0.65;
  transition: opacity 0.3s ease;
}
.module-grid .mg-plus::before,
.module-grid .mg-plus::after {
  content: "";
  position: absolute;
  background: currentColor;
}
.module-grid .mg-plus::before {
  left: 0; top: 50%;
  width: 100%; height: 1.5px;
  transform: translateY(-50%);
}
.module-grid .mg-plus::after {
  top: 0; left: 50%;
  height: 100%; width: 1.5px;
  transform: translateX(-50%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}
.module-grid .mg-item.is-active .mg-plus { opacity: 1; }
.module-grid .mg-item.is-active .mg-plus::after {
  transform: translateX(-50%) rotate(90deg);
  opacity: 0;
}

/* ---------------------------------------------------------
   DEFINITION
   Collapsed with grid-template-rows so the height animates
   without needing a hard-coded pixel value.
   --------------------------------------------------------- */
.module-grid .mg-def {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.module-grid .mg-item.is-active .mg-def {
  grid-template-rows: 1fr;
}

.module-grid .mg-def > .mg-def-inner {
  overflow: hidden;
  min-height: 0;
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1) 0.05s,
    transform 0.35s cubic-bezier(0.16, 1, 0.3, 1) 0.05s,
    padding 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0 20px;
  border-left: 1px solid rgba(217, 64, 11, 0.45);
  margin-top: 0;
}

.module-grid .mg-item.is-active .mg-def > .mg-def-inner {
  opacity: 1;
  transform: none;
  padding: 16px 20px 18px;
  margin-top: 8px;
}

.module-grid .mg-def-title {
  font-family: var(--font-display, sans-serif);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  margin: 0 0 7px;
}

.module-grid .mg-def-inner p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(248, 246, 241, 0.72);
}

/* ---------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------- */
@media (max-width: 980px) {
  .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .module-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .module-grid .mg-card { padding: 16px 16px; gap: 12px; }
  .module-grid .mg-title { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .module-grid .mg-card,
  .module-grid .mg-def,
  .module-grid .mg-def > .mg-def-inner,
  .module-grid .mg-plus::after {
    transition: none;
  }
  .module-grid .mg-card:hover { transform: none; }
}
