/**
 * Family Business Programme page (page-family-business-programme.php).
 *
 * Page-specific folds: hero, premise, audience, paradoxes, calendar.
 * Shared folds are styled in programme-components.css.
 * Desktop values follow Figma node 6714:105503 at 1440 px.
 */

/* ---------- Hero ---------- */

/*
 * The theme only measures the header when the utility bar is shown; with the
 * logo-only header its 90px fallback is 10px short, so the hero slid under the
 * header. Same pattern as the theme's own `:root:has(.header-main--utility)` rule,
 * which (being more specific) still wins if the full navigation is switched back on.
 */
@media (min-width: 768px) {
  html:has(.fbp-hero) {
    --header-height: 100px;
  }
}

/*
 * On phones the logo-only header is 67.81px (logo proportions) but the theme's
 * fallback is 69px, leaving a 1px white line. Tuck the hero 2px under the fixed
 * header (z-index 100), which hides it, so no rounding can show a gap.
 */
@media (max-width: 767.98px) {
  .fbp-hero {
    margin-top: -2px;
  }

  /* Tighter gap between the form's Submit button and the next section on phones. */
  .fbp-hero__form {
    padding-bottom: 0;
  }

  .fbp-hero + .fbp-premise {
    padding-top: 8px;
  }
}

/*
 * Layout: the background, the title and the form share one grid cell on desktop,
 * so the photo always spans the title and the whole form (whichever is taller).
 * Below 992px the form drops to its own row on white and the photo stays behind
 * the title only.
 */
.fbp-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background-color: #fff;
}

.fbp-hero__bg {
  position: relative;
  grid-row: 1;
  grid-column: 1;
  background-color: var(--programme-dark);
  background-image: var(--fbp-hero-bg-sm, none);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

/* 30% dark overlay keeps the white title readable on any photo (Figma). */
.fbp-hero__bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.3);
}

.fbp-hero__bg--empty::after {
  content: none;
}

.fbp-hero__content-wrap {
  position: relative;
  z-index: 1;
  grid-row: 1;
  grid-column: 1;
}

.fbp-hero__content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 80px 0 48px;
  color: #fff;
}

.fbp-hero__title {
  margin: 0;
  font-size: calc(1.575rem + 3.12vw);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: #fff;
  overflow-wrap: break-word;
}

.fbp-hero__meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fbp-hero__subtitle {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

.fbp-hero__partner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.fbp-hero__partner-label {
  margin: 0;
  font-size: 11.8px;
  line-height: 1.4;
}

.fbp-hero__partner-logo {
  width: 198px;
  padding: 10px;
  background-color: #fff;
}

.fbp-hero__partner-image {
  display: block;
  width: 100%;
  height: auto;
}

.fbp-hero__form-wrap {
  position: relative;
  z-index: 2;
  grid-row: 2;
  grid-column: 1;
}

.fbp-hero__form {
  padding: 20px 4px 4px;
  background-color: #fff;
}

/* Tally sets the iframe height itself (dynamicHeight); keep it full width. */
.fbp-hero__widget iframe {
  display: block;
  width: 100%;
  border: 0;
}

@media (min-width: 768px) {
  .fbp-hero__bg {
    background-image: var(--fbp-hero-bg, none);
  }
}

@media (min-width: 992px) {
  .fbp-hero {
    min-height: 645px;
  }

  .fbp-hero__bg,
  .fbp-hero__form-wrap {
    grid-row: 1;
  }

  .fbp-hero__content-wrap {
    align-self: center;
  }

  .fbp-hero__content {
    max-width: 680px;
    padding: 50px 0;
  }

  .fbp-hero--with-form .fbp-hero__content {
    /* Keep the title clear of the form card (which hugs the screen edge) on narrower desktops. */
    max-width: min(680px, calc(100vw - var(--fbp-hero-form-width) - 48px - (100vw - 100%) / 2));
  }

  /* The form card sits on the photo, flush with the right screen edge, 50px from top and bottom. */
  .fbp-hero {
    --fbp-hero-form-width: min(464px, 46vw);
  }

  .fbp-hero__form-wrap {
    pointer-events: none;
  }

  .fbp-hero__form-wrap > .container {
    max-width: none;
    padding: 0;
  }

  .fbp-hero__form {
    width: var(--fbp-hero-form-width);
    margin: 50px 0 50px auto;
    padding: 20px 20px 8px;
    pointer-events: auto;
  }
}

@media (min-width: 1300px) {
  .fbp-hero__title {
    font-size: 72px;
  }
}

@media (max-width: 767.98px) {
  .fbp-hero__content {
    padding: 48px 0 40px;
  }
}

/* ---------- Premise ---------- */

.fbp-premise {
  padding-top: var(--programme-section-gap);
}

.fbp-premise__body {
  font-family: "Manrope", sans-serif;
  font-size: calc(1.1rem + 0.5vw);
  line-height: 1.4;
  letter-spacing: -0.02em;
  color: var(--programme-ink);
}

.fbp-premise__body p {
  margin: 0 0 20px;
}

.fbp-premise__body > :last-child {
  margin-bottom: 0;
}

@media (min-width: 1300px) {
  .fbp-premise__body {
    font-size: 24px;
  }
}

/* ---------- Audience ---------- */

.fbp-audience {
  margin-top: var(--programme-section-gap);
  padding: var(--programme-band-padding) 0;
  background-color: var(--programme-grey);
}

.fbp-audience__panel {
  padding: 24px;
  background-color: var(--programme-dark);
}

.fbp-audience__cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fbp-audience__card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 28px;
  background-color: var(--programme-yellow);
  color: var(--programme-ink);
  font-size: 14px;
}

.fbp-audience__card-title {
  margin: 0;
  font-family: "Inter", sans-serif;
  font-size: 14px;
}

.fbp-audience__card-text {
  margin: 0;
  line-height: 1.4;
}

@media (min-width: 768px) {
  .fbp-audience__panel {
    padding: 36px 76px;
  }

  .fbp-audience__cards {
    flex-direction: row;
    gap: 36px;
  }

  .fbp-audience__card {
    flex: 1 1 0;
    min-width: 0;
    min-height: 97px;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .fbp-audience__panel {
    padding: 32px;
  }

  .fbp-audience__cards {
    gap: 24px;
  }
}

/* ---------- Paradoxes ---------- */

.fbp-paradoxes {
  margin-top: var(--programme-section-gap);
  padding: var(--programme-band-padding) 0;
  background-color: var(--programme-dark);
  color: #fff;
}

.fbp-paradoxes .programme-heading,
.fbp-paradoxes .programme-subheading {
  color: #fff;
}

.fbp-paradoxes__grid {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  justify-content: space-between;
  gap: 32px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fbp-paradoxes__pair {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100px;
  padding: 3px 0 3px 29px;
}

/* Bracket connector (Figma "Line 9", rotated 90deg). */
.fbp-paradoxes__pair::before {
  content: "";
  position: absolute;
  top: 42.333px;
  left: -19.667px;
  width: 71.333px;
  height: 14.167px;
  background: url("../images/family-business/paradox-connector.svg") no-repeat 0 0 / 71.333px 14.167px;
  transform: rotate(90deg);
  transform-origin: 35.667px 8.167px;
}

.fbp-paradoxes__term {
  font-family: "Manrope", sans-serif;
  font-size: 20px;
  line-height: 1.4;
  white-space: nowrap;
}

.fbp-paradoxes__term:last-child {
  margin-left: -2px;
}

.fbp-paradoxes__vs {
  position: absolute;
  top: 40px;
  left: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: var(--programme-mint);
  color: var(--programme-dark);
  font-size: 12px;
  line-height: 20px;
  letter-spacing: -0.02em;
  text-align: center;
}

@media (max-width: 575.98px) {
  .fbp-paradoxes__term {
    font-size: 18px;
  }
}

@media (min-width: 768px) {
  .fbp-paradoxes__grid {
    grid-template-columns: repeat(3, max-content);
    row-gap: 48px;
  }
}

/* ---------- Calendar ---------- */

.fbp-calendar {
  padding-top: var(--programme-section-gap);
}

.fbp-calendar__panel {
  padding: 24px 16px;
  background-color: var(--programme-grey);
}

.fbp-calendar__scroll {
  overflow-x: auto;
  border: 1px solid rgba(46, 45, 44, 0.4);
  padding: 15px 16px 14px 14px;
}

.fbp-calendar__scroll:focus-visible {
  outline: 2px solid var(--programme-teal);
  outline-offset: 2px;
}

.fbp-calendar__table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  color: var(--programme-ink);
}

.fbp-calendar__table th,
.fbp-calendar__table td {
  padding: 14px 16px 16.5px 23px;
  vertical-align: top;
  text-align: left;
}

.fbp-calendar__table th:first-child,
.fbp-calendar__table td:first-child {
  width: 26.8%;
  padding-left: 9px;
}

.fbp-calendar__table th:nth-child(2),
.fbp-calendar__table td:nth-child(2),
.fbp-calendar__table th:nth-child(3),
.fbp-calendar__table td:nth-child(3) {
  width: 23.2%;
}

.fbp-calendar__table th + th,
.fbp-calendar__table td,
.fbp-calendar__table tbody th + td {
  border-left: 1px solid rgba(46, 45, 44, 0.4);
}

.fbp-calendar__table tbody tr {
  border-top: 1px solid rgba(46, 45, 44, 0.4);
}

.fbp-calendar__table thead th {
  padding-top: 9.7px;
  padding-bottom: 22px;
  font-family: "Manrope", sans-serif;
  font-size: 24px;
  line-height: 1.2;
}

.fbp-calendar__table tbody tr:last-child > * {
  padding-bottom: 24.5px;
}

.fbp-calendar__table tbody th {
  font-weight: inherit;
}

.fbp-calendar__value,
.fbp-calendar__note {
  display: block;
}

.fbp-calendar__value {
  font-family: "Manrope", sans-serif;
  font-size: 20px;
  line-height: 1.4;
}

.fbp-calendar__note {
  margin-top: 2px;
  font-size: 11.8px;
  line-height: 1.4;
}

@media (min-width: 768px) {
  .fbp-calendar__panel {
    padding: 40px 32px;
  }
}

@media (min-width: 992px) {
  .fbp-calendar__panel {
    padding: 65px 65.4px 65px 64px;
  }
}

/* Phones: each residency becomes a labelled block. */
@media (max-width: 767.98px) {
  .fbp-calendar__scroll {
    padding: 0 16px;
  }

  .fbp-calendar__table,
  .fbp-calendar__table tbody,
  .fbp-calendar__table tr,
  .fbp-calendar__table th,
  .fbp-calendar__table td {
    display: block;
    width: auto !important;
  }

  .fbp-calendar__table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .fbp-calendar__table tbody tr {
    padding: 16px 0;
  }

  .fbp-calendar__table tbody tr:first-child {
    border-top: 0;
  }

  .fbp-calendar__table th,
  .fbp-calendar__table td,
  .fbp-calendar__table tbody tr:last-child > * {
    display: grid;
    grid-template-columns: 96px 1fr;
    column-gap: 12px;
    padding: 4px 0;
    border-left: 0;
  }

  .fbp-calendar__table [data-label]::before {
    content: attr(data-label);
    grid-row: span 2;
    font-family: "Manrope", sans-serif;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.75;
  }

  /* The residency name is the block's heading, so it needs no label. */
  .fbp-calendar__table tbody th,
  .fbp-calendar__table tbody tr:last-child > th {
    display: block;
    padding-bottom: 8px;
  }

  .fbp-calendar__table tbody th::before {
    content: none !important;
  }

  /* Out-rank the desktop column rules (first-child padding, column borders). */
  .fbp-calendar .fbp-calendar__table tbody tr > :nth-child(n) {
    padding-left: 0;
    border-left: 0;
  }

  .fbp-calendar__table tbody th .fbp-calendar__value {
    font-weight: 700;
  }

  .fbp-calendar__value {
    font-size: 18px;
  }
}
