/**
 * Pathway Staircase widget stylesheet.
 *
 * Loaded only when the widget appears on a page (via get_style_depends()).
 * Covers both variants (`homepage` bar-chart and `pathway-page` diagonal staircase)
 * plus mobile fallbacks.
 *
 * Class naming follows BEM: .esls-pathway-staircase__<elt>--<modifier>.
 *
 * @package esls-institutional-content
 * @version 0.1.7
 */

/* =====================================================================
   SHARED
   ===================================================================== */

.esls-pathway-staircase {
  font-family: 'Source Sans 3', system-ui, sans-serif;
  color: var(--esls-text-primary);
}

.esls-pathway-staircase__card {
  background: var(--esls-cream-primary);
  border: 1px solid var(--esls-border-warm);
  border-top-width: 4px;
  padding: 16px 16px 20px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  transition: transform 300ms var(--ease-out);
}

.esls-pathway-staircase__tier:hover .esls-pathway-staircase__card,
.esls-pathway-staircase__pp-tier:hover .esls-pathway-staircase__pp-card {
  transform: translateY(-8px);
}

.esls-pathway-staircase__title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--esls-blue-900);
  margin: 0 0 8px 0;
  white-space: pre-line;
}

.esls-pathway-staircase__entry {
  font-size: 13px;
  line-height: 1.4;
  color: var(--esls-text-secondary);
  margin: 0 0 6px 0;
}

.esls-pathway-staircase__entry-label {
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--esls-orange-600);
  display: inline-block;
  margin-right: 4px;
}

.esls-pathway-staircase__meta {
  font-size: 12px;
  color: var(--esls-text-tertiary);
  margin: 0;
}

/* =====================================================================
   HOMEPAGE VARIANT — bar chart
   ===================================================================== */

.esls-pathway-staircase--homepage .esls-pathway-staircase__desktop {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  min-height: 480px;
  position: relative;
  padding: 0 8%;
}

.esls-pathway-staircase--homepage .esls-pathway-staircase__baseline {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 2px;
  height: 2px;
  background: var(--esls-orange-400);
  z-index: 0;
  border-radius: 2px;
}

.esls-pathway-staircase--homepage .esls-pathway-staircase__tier {
  flex: 1 1 0;
  max-width: 20%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  position: relative;
  z-index: 1;
}

.esls-pathway-staircase--homepage .esls-pathway-staircase__card {
  margin-bottom: 8px;
}

.esls-pathway-staircase--homepage .esls-pathway-staircase__bar {
  width: 85%;
  margin: 0 auto;
  border-radius: 12px 12px 0 0;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
  position: relative;
}

.esls-pathway-staircase--homepage .esls-pathway-staircase__bar--bba {
  outline: 4px solid var(--esls-orange-400);
  outline-offset: -4px;
  border-radius: 12px 12px 0 0;
}

/* Callout above BBA bar */
.esls-pathway-staircase--homepage .esls-pathway-staircase__callout {
  position: absolute;
  top: -86px;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  background: #FFFFFF;
  border: 1px solid var(--esls-border-warm);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: var(--shadow-md);
  z-index: var(--z-floats);
}

.esls-pathway-staircase--homepage .esls-pathway-staircase__callout-eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--esls-orange-600);
}

.esls-pathway-staircase--homepage .esls-pathway-staircase__callout-body {
  font-size: 12px;
  line-height: 1.45;
  color: var(--esls-text-secondary);
  margin: 0;
}

.esls-pathway-staircase--homepage .esls-pathway-staircase__callout-arrow {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #FFFFFF;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.06));
}

/* --- Homepage mobile -------------------------------------------------- */

.esls-pathway-staircase--homepage .esls-pathway-staircase__mobile {
  position: relative;
  padding: 16px 0 16px 36px;
}

.esls-pathway-staircase--homepage .esls-pathway-staircase__mobile-rail {
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--esls-orange-400), var(--esls-blue-200));
  border-radius: 2px;
}

.esls-pathway-staircase--homepage .esls-pathway-staircase__mobile-tier {
  background: var(--esls-cream-primary);
  border: 1px solid var(--esls-border-warm);
  border-left: 4px solid var(--esls-blue-200);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.esls-pathway-staircase--homepage .esls-pathway-staircase__mobile-beyond {
  display: inline-block;
  padding: 4px 10px;
  background: var(--esls-blue-900);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: 9999px;
  margin-bottom: 10px;
}

.esls-pathway-staircase--homepage .esls-pathway-staircase__mobile-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--esls-blue-900);
  margin: 0 0 8px 0;
  white-space: pre-line;
}

.esls-pathway-staircase--homepage .esls-pathway-staircase__mobile-entry {
  font-size: 13px;
  color: var(--esls-text-secondary);
  margin: 0 0 6px 0;
}

.esls-pathway-staircase--homepage .esls-pathway-staircase__mobile-meta {
  font-size: 12px;
  color: var(--esls-text-tertiary);
  margin: 0;
}

/* =====================================================================
   PATHWAY-PAGE VARIANT — diagonal staircase
   ===================================================================== */

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-desktop {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 550px;
  position: relative;
  padding: 100px 40px 80px;
  gap: 32px;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-path {
  position: absolute;
  inset: 100px 40px 80px 40px;
  z-index: 0;
  pointer-events: none;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-path svg {
  width: 100%;
  height: 100%;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-beyond {
  position: absolute;
  top: 0;
  right: 40px;
  max-width: 280px;
  background: var(--esls-blue-900);
  border: none;
  border-radius: var(--radius-md);
  padding: 16px;
  z-index: var(--z-floats);
  box-shadow: none;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-beyond-eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--esls-orange-300);
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-beyond p {
  font-size: 13px;
  line-height: 1.4;
  color: #FFFFFF;
  opacity: 0.9;
  margin: 0;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-tier {
  flex: 1 1 0;
  max-width: 240px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  width: 100%;
  position: relative;
  color: #FFFFFF;
  transition: transform 300ms var(--ease-out);
  /* v0.1.7: header row to match React (number badge beside eyebrow/title) */
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: start;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-card h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
  color: #FFFFFF;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 18px;
  grid-column: 1;
  grid-row: 1;
  flex: 0 0 auto;
  margin-bottom: 0;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-titleblock {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  margin-bottom: 0;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 4px;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-meta {
  grid-column: 1 / -1;
  grid-row: 2;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  margin: 8px 0 0 0;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-desc {
  grid-column: 1 / -1;
  grid-row: 3;
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.9);
  margin: 4px 0 0 0;
}

/* Tier 5 BBA — orange ring badge */
.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-tier--bba .esls-pathway-staircase__pp-bba-badge {
  position: absolute;
  top: -12px;
  right: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid var(--esls-orange-400);
  background: var(--esls-blue-900);
  z-index: 2;
}

/* Entry-requirement card hanging below */
.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-entry {
  background: var(--esls-cream-primary);
  border: 1px solid var(--esls-border-warm);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-card);
  width: 90%;
  align-self: center;
  margin-top: 12px;
  position: relative;
}
.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-entry::before {
  content: "";
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 24px;
  background: linear-gradient(to bottom, var(--esls-border-warm), transparent);
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-entry .esls-eyebrow {
  display: block;
  margin-bottom: 4px;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-entry p {
  font-size: 12px;
  line-height: 1.4;
  color: var(--esls-text-secondary);
  margin: 0;
}

/* --- Pathway-page mobile -------------------------------------------- */

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-mobile {
  position: relative;
  padding: 16px 0 16px 56px;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-mobile-rail {
  position: absolute;
  left: 39px;
  top: 0;
  bottom: 0;
  border-left: 2px dashed var(--esls-orange-400);
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-mobile-tier {
  margin-bottom: 24px;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-mobile-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  color: #FFFFFF;
  box-shadow: var(--shadow-md);
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-mobile-card h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: #FFFFFF;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-mobile-entry {
  background: var(--esls-cream-primary);
  border: 1px solid var(--esls-border-warm);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: -10px;
  margin-left: 16px;
  margin-right: 16px;
  box-shadow: var(--shadow-card);
  position: relative;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-mobile-entry .esls-eyebrow {
  display: block;
  margin-bottom: 4px;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-mobile-entry p {
  font-size: 12px;
  line-height: 1.4;
  color: var(--esls-text-secondary);
  margin: 0;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-mobile-beyond {
  margin-top: 12px;
  background: var(--esls-blue-900);
  color: var(--esls-text-on-dark);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-mobile-beyond p {
  font-size: 13px;
  line-height: 1.4;
  margin: 0;
}

.esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-mobile-beyond .esls-pathway-staircase__pp-beyond-eyebrow {
  color: var(--esls-orange-300);
}

/* =====================================================================
   RESPONSIVE — show/hide desktop vs mobile per variant
   ===================================================================== */

@media (max-width: 767px) {
  .esls-pathway-staircase__desktop,
  .esls-pathway-staircase__pp-desktop {
    display: none !important;
  }
}

@media (min-width: 768px) {
  .esls-pathway-staircase--homepage .esls-pathway-staircase__mobile {
    display: none;
  }
}

@media (min-width: 1024px) {
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-mobile {
    display: none;
  }
}

@media (max-width: 1023px) {
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-desktop {
    display: none;
  }
}

/* =====================================================================
   BBA TRACK BRACKET  (v0.1.9)
   Groups CertHE / DipHE / BBA so they read as one degree rather than
   three unrelated certificates.

   Contract: every element in this block is absolutely positioned inside a
   tier that is already `position: relative`. Nothing here participates in
   flow, so bars, cap cards, entry cards and the "And beyond" callout render
   byte-identically to v0.1.8. The only reserved space is the padding added
   to the widget root under `--has-track`.

   `--bba` modifiers remain terminal-tier only. `--in-track` is the new
   membership modifier.
   ===================================================================== */

.esls-pathway-staircase__track-frame {
  position: absolute;
  pointer-events: none;
  z-index: 3;
}

.esls-pathway-staircase__track-rail {
  position: absolute;
  inset: 0;
  border: 0 solid var(--esls-blue-400);
}

.esls-pathway-staircase__track-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--esls-blue-600);
}

/* --- Homepage desktop: bracket hangs below the baseline --------------- */

@media (min-width: 768px) {
  .esls-pathway-staircase--homepage.esls-pathway-staircase--has-track {
    padding-bottom: 64px;
  }

  .esls-pathway-staircase--homepage .esls-pathway-staircase__tier .esls-pathway-staircase__track-frame {
    bottom: -52px;
    height: 34px;
  }

  .esls-pathway-staircase--homepage .esls-pathway-staircase__track-frame--start { left: 0;    right: -8px; }
  .esls-pathway-staircase--homepage .esls-pathway-staircase__track-frame--mid   { left: -8px; right: -8px; }
  .esls-pathway-staircase--homepage .esls-pathway-staircase__track-frame--end   { left: -8px; right: 0;    }

  /* Rail along the bottom, uprights rising towards the bars. */
  .esls-pathway-staircase--homepage .esls-pathway-staircase__track-frame .esls-pathway-staircase__track-rail {
    border-bottom-width: 2px;
  }
  .esls-pathway-staircase--homepage .esls-pathway-staircase__track-frame--start .esls-pathway-staircase__track-rail {
    border-left-width: 2px;
    border-bottom-left-radius: 6px;
  }
  .esls-pathway-staircase--homepage .esls-pathway-staircase__track-frame--end .esls-pathway-staircase__track-rail {
    border-right-width: 2px;
    border-bottom-right-radius: 6px;
  }
}

/* --- Homepage mobile: vertical bracket down the right edge ------------ */

@media (max-width: 767px) {
  /* The bracket lives in the 20px of free gutter that already exists between
     the timeline rail (x 14-16) and the tier border box (x 36). No padding is
     added to `__mobile`: that would narrow every tier and re-wrap the copy. */
  .esls-pathway-staircase--homepage .esls-pathway-staircase__mobile-tier--in-track {
    position: relative;
  }

  .esls-pathway-staircase--homepage .esls-pathway-staircase__mobile-tier .esls-pathway-staircase__track-frame {
    left: -22px;
    width: 16px;
  }

  /* Tiers are 16px apart edge to edge, but these offsets are measured from the
     padding box and the tier carries a 1px border, so each open end bridges 9px
     to close the gap exactly. */
  .esls-pathway-staircase--homepage .esls-pathway-staircase__track-frame--start { top: 0;    bottom: -9px; }
  .esls-pathway-staircase--homepage .esls-pathway-staircase__track-frame--mid   { top: -9px; bottom: -9px; }
  .esls-pathway-staircase--homepage .esls-pathway-staircase__track-frame--end   { top: -9px; bottom: 0;    }

  .esls-pathway-staircase--homepage .esls-pathway-staircase__track-frame .esls-pathway-staircase__track-rail {
    border-left-width: 2px;
  }
  .esls-pathway-staircase--homepage .esls-pathway-staircase__track-frame--start .esls-pathway-staircase__track-rail {
    border-top-width: 2px;
    border-top-left-radius: 6px;
  }
  .esls-pathway-staircase--homepage .esls-pathway-staircase__track-frame--end .esls-pathway-staircase__track-rail {
    border-bottom-width: 2px;
    border-bottom-left-radius: 6px;
  }

  .esls-pathway-staircase--homepage .esls-pathway-staircase__track-label {
    writing-mode: vertical-rl;
    font-size: 10px;
    letter-spacing: 0.10em;
  }
}

/* --- Pathway page desktop: stepped bracket hugging the cards ---------- */

@media (min-width: 1024px) {
  /* The bracket sits BELOW the tiers, not above. Above the cards it collided
     with the "AND BEYOND" aside, which is pinned at top:0 directly over the
     terminal tier (measured overlap: 214 x 16px). Below the tiers the run is
     clear, and `__pp-desktop` already reserves 80px of bottom padding. */
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-tier .esls-pathway-staircase__track-frame {
    bottom: -34px;
    height: 22px;
  }

  /* Tiers are 32px apart; bridge half the gap at each open end. */
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-frame--start { left: 0;     right: -16px; }
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-frame--mid   { left: -16px; right: -16px; }
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-frame--end   { left: -16px; right: 0;     }

  /* Rail along the bottom, uprights rising towards the tiers. */
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-frame .esls-pathway-staircase__track-rail {
    border-bottom-width: 2px;
  }
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-frame--start .esls-pathway-staircase__track-rail {
    border-left-width: 2px;
    border-bottom-left-radius: 6px;
  }
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-frame--end .esls-pathway-staircase__track-rail {
    border-right-width: 2px;
    border-bottom-right-radius: 6px;
  }

  /* Riser bridging one staircase step up to the next tier's rail.
     Height is --esls-pp-step, written by PHP from self::PP_STEP_PX, so the
     riser and the translateY can never drift apart. */
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-frame--start::after,
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-frame--mid::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    width: 2px;
    height: var(--esls-pp-step, 50px);
    background: var(--esls-blue-400);
  }

  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-label {
    font-size: 10px;
    color: var(--esls-blue-600);
  }
}

/* --- Pathway page mobile: vertical bracket down the right edge -------- */

@media (max-width: 1023px) {
  /* Same reasoning as the homepage: use the free gutter between the timeline
     rail (x 39-41) and the tier (x 56) rather than adding container padding. */
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-mobile-tier--in-track {
    position: relative;
  }

  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__pp-mobile-tier .esls-pathway-staircase__track-frame {
    left: -14px;
    width: 12px;
  }

  /* Tiers are 24px apart; bridge half the gap at each open end. */
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-frame--start { top: 0;     bottom: -12px; }
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-frame--mid   { top: -12px; bottom: -12px; }
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-frame--end   { top: -12px; bottom: 0;     }

  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-frame .esls-pathway-staircase__track-rail {
    border-left-width: 2px;
  }
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-frame--start .esls-pathway-staircase__track-rail {
    border-top-width: 2px;
    border-top-left-radius: 6px;
  }
  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-frame--end .esls-pathway-staircase__track-rail {
    border-bottom-width: 2px;
    border-bottom-left-radius: 6px;
  }

  .esls-pathway-staircase--pathway-page .esls-pathway-staircase__track-label {
    writing-mode: vertical-rl;
    font-size: 10px;
    letter-spacing: 0.10em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .esls-pathway-staircase__track-frame { transition: none !important; }
}
