/*
 * Young Founders Lab tablet contract.
 * Shared by the main page, About page, and all four programme detail pages.
 */

@media (min-width: 720px) and (max-width: 1180px) and (min-height: 700px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Boundlearn tablet navigation uses the approved compact mobile contract. */
  .bl-tier1.bl-unified-header {
    position: relative !important;
    z-index: 420 !important;
    min-height: 66px !important;
    align-items: center !important;
    padding: 11px 24px !important;
    background: #0b1221 !important;
    font-family: "Manrope", "Helvetica Neue", Arial, sans-serif !important;
  }

  .bl-tier1 .bl-bar-nav {
    display: none !important;
  }

  .bl-tier1 .bl-burger {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    display: inline-flex !important;
    flex: 0 0 44px !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    border: 1px solid rgba(212, 175, 55, 0.32) !important;
    border-radius: 9px !important;
    background: transparent !important;
    color: #e2e8f0 !important;
  }

  #bl-mnav.bl-unified-panel {
    display: none !important;
    position: absolute !important;
    top: calc(100% + 8px) !important;
    right: 24px !important;
    bottom: auto !important;
    left: auto !important;
    width: min(400px, calc(100vw - 48px)) !important;
    max-height: calc(100svh - 86px) !important;
    flex-direction: column !important;
    gap: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    padding: 16px 20px 20px !important;
    border: 1px solid rgba(212, 175, 55, 0.2) !important;
    border-top: 0 !important;
    border-radius: 0 0 14px 14px !important;
    background: #0b1221 !important;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.38) !important;
    color: #f5f5f7 !important;
    font-family: "Cinzel", Georgia, serif !important;
    text-align: left !important;
    z-index: 300 !important;
  }

  #bl-mnav.bl-unified-panel.is-open,
  #bl-toggle:checked ~ #bl-mnav.bl-unified-panel {
    display: flex !important;
  }

  #bl-mnav.bl-unified-panel > a,
  #bl-mnav.bl-unified-panel > details > summary {
    min-height: 50px !important;
    align-items: center !important;
    padding: 13px 4px !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(212, 175, 55, 0.16) !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: #f5f5f7 !important;
    font-family: "Cinzel", Georgia, serif !important;
    font-size: 18px !important;
    font-weight: 500 !important;
    line-height: 1.25 !important;
    letter-spacing: 0 !important;
    text-align: left !important;
  }

  #bl-mnav.bl-unified-panel > details a {
    min-height: 38px !important;
    padding: 8px 4px 8px 14px !important;
    color: #c7d0e0 !important;
    font-family: "Cinzel", Georgia, serif !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    line-height: 1.35 !important;
  }

  #bl-mnav.bl-unified-panel a:is([href*="Application"], [href^="/application-form"]) {
    min-height: 50px !important;
    justify-content: center !important;
    margin-top: 10px !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: #d4af37 !important;
    color: #0b1221 !important;
    font-family: "Manrope", "Helvetica Neue", Arial, sans-serif !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    text-align: center !important;
  }

  /* YFL tablet navigation remains a second, separate compact header. */
  .site-header {
    position: sticky !important;
    top: 12px !important;
    right: auto !important;
    left: auto !important;
    width: calc(100% - 24px) !important;
    margin: 12px auto 0 !important;
    transform: none !important;
    align-items: center !important;
    z-index: 300 !important;
  }

  .site-header .menu-toggle {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    display: grid !important;
    place-items: center !important;
    padding: 0 !important;
    border: 1px solid var(--line) !important;
    border-radius: 12px !important;
    background: transparent !important;
    color: var(--ink) !important;
  }

  .site-header .menu-toggle[aria-expanded="true"] svg {
    display: none !important;
  }

  .site-header .menu-toggle[aria-expanded="true"]::before {
    content: "\00d7";
    font: 400 29px/1 Arial, sans-serif;
    color: currentColor;
  }

  .site-header > .primary-nav {
    display: none !important;
  }

  .site-header > .primary-nav.open {
    position: absolute !important;
    top: calc(100% - 1px) !important;
    right: -1px !important;
    bottom: auto !important;
    left: -1px !important;
    width: calc(100% + 2px) !important;
    max-height: calc(100svh - 100px) !important;
    display: flex !important;
    height: auto !important;
    min-height: 0 !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    padding: 14px 18px 20px !important;
    border: 1px solid var(--line) !important;
    border-radius: 0 0 16px 16px !important;
    background: var(--paper) !important;
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.16) !important;
    text-align: left !important;
    z-index: 300 !important;
  }

  .site-header > .primary-nav.open > a,
  .site-header > .primary-nav.open > .nav-drop > a {
    min-height: 48px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 12px 4px !important;
    border-bottom: 1px solid var(--line) !important;
    border-radius: 0 !important;
    color: var(--ink) !important;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif !important;
    font-size: 16px !important;
    font-weight: 650 !important;
    text-align: left !important;
  }

  .site-header > .primary-nav.open > .nav-drop {
    display: block !important;
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    width: 100% !important;
  }

  .site-header > .primary-nav.open .nav-menu {
    display: none !important;
    position: static !important;
    width: 100% !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transform: none !important;
    transition: max-height 180ms ease, opacity 180ms ease !important;
  }

  .site-header > .primary-nav.open .nav-drop.programs-open .nav-menu {
    display: block !important;
    height: auto !important;
    max-height: 360px !important;
    padding: 0 !important;
    margin: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .site-header > .primary-nav.open .nav-menu-inner {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    margin: 0 !important;
  }

  .site-header > .primary-nav.open .nav-menu-inner a {
    min-height: 48px !important;
    padding: 9px 10px !important;
    border: 1px solid var(--line) !important;
    border-radius: 10px !important;
    background: rgba(122, 72, 245, 0.035) !important;
  }

  .site-header > .primary-nav.open .nav-menu-inner strong {
    font-size: 13px !important;
    white-space: normal !important;
  }

  .site-header > .primary-nav.open .nav-menu-inner small {
    display: none !important;
  }

  .site-header > .primary-nav.open .mobile-menu-brand {
    display: none !important;
    align-items: center !important;
    margin: 0 0 6px !important;
    padding: 4px 0 10px !important;
    border-bottom: 1px solid var(--line) !important;
  }

  .site-header > .primary-nav.open .mobile-menu-brand img {
    width: auto !important;
    height: 36px !important;
    max-width: 142px !important;
    object-fit: contain !important;
  }

  .site-header > .primary-nav.open .mobile-nav-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 10px !important;
    margin-top: 14px !important;
  }

  .site-header > .primary-nav.open .mobile-nav-actions a {
    min-height: 48px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 12px 14px !important;
    border-radius: 10px !important;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    text-align: center !important;
  }

  .site-header > .primary-nav.open .mobile-nav-actions .nav-cta {
    background: var(--lime) !important;
    color: var(--ink) !important;
  }

  .site-header > .primary-nav.open .mobile-nav-actions .nav-contact {
    border: 1px solid var(--line) !important;
    background: transparent !important;
    color: var(--ink) !important;
  }

  .yfl-step-title-desktop {
    display: inline !important;
  }

  .yfl-step-title-mobile {
    display: none !important;
  }

  /* Keep repeated alumni/testimonial and footer systems identical on every YFL page. */
  .outcomes-grid {
    grid-template-columns: 0.92fr 1.08fr !important;
    gap: 28px !important;
    align-items: stretch !important;
  }

  .testi-wrap {
    height: 100% !important;
  }

  .testi-carousel {
    min-height: 360px !important;
  }

  .testi-slide {
    padding: 38px !important;
  }

  .testi-navbar {
    width: 100% !important;
    justify-content: center !important;
  }

  .testi-navbtns {
    display: none !important;
  }

  .testi-dots {
    margin-right: auto !important;
    margin-left: auto !important;
  }

  .date-mobile-label {
    display: none !important;
  }

  .yfl-footer {
    padding: 44px 34px 28px !important;
  }

  .yfl-footer-grid {
    gap: 20px 18px !important;
    padding-bottom: 26px !important;
  }

  .yfl-footer-grid .yfl-footer-links {
    gap: 0 !important;
  }

  .yfl-footer-grid .yfl-footer-links a {
    min-height: 25px !important;
    padding: 2px 0 !important;
    line-height: 1.25 !important;
  }

  .yfl-footer-grid h3 {
    margin-bottom: 8px !important;
  }
}

/* Match the approved Delta landscape shell: the program bar belongs to the
   hero surface instead of reserving a separate strip above it. */
@media (orientation: landscape) and (min-width: 601px) and (max-width: 950px) and (max-height: 500px) {
  body.yfl-page .bl-tier1.bl-unified-header {
    box-sizing: border-box !important;
    height: 57px !important;
    min-height: 57px !important;
    padding: 6px 16px !important;
  }

  body.yfl-page .bl-tier1.bl-unified-header:has(#bl-toggle:checked),
  body.yfl-page .bl-tier1.bl-unified-header:has(.bl-unified-trigger[aria-expanded="true"]) {
    z-index: 1200 !important;
  }

  body.yfl-page .site-header {
    position: sticky !important;
    top: 12px !important;
    right: auto !important;
    left: auto !important;
    width: calc(100% - 40px) !important;
    margin: 20px auto -82px !important;
    z-index: 1100 !important;
  }

  body.yfl-page .site-header.yfl-mobile-fixed {
    position: fixed !important;
    top: 12px !important;
    right: 20px !important;
    left: 20px !important;
    width: auto !important;
    margin: 0 !important;
    transform: none !important;
  }

  body.yfl-main-page .hero-home .hero-card {
    padding-top: 50px !important;
  }
}

@media (min-width: 720px) and (max-width: 900px) and (min-height: 700px) and (orientation: portrait) {
  .mentor-front img {
    width: 100% !important;
    height: clamp(192px, 25vw, 205px) !important;
    object-fit: cover !important;
  }

  .mentor-front img[src$="/yfl-assets/kevin.webp"] {
    object-position: 50% 8% !important;
  }

  .mentor-front img[src$="/yfl-assets/michael.webp"] {
    object-position: 50% 2% !important;
  }

  .mentor-front img[src$="/yfl-assets/luke.webp"] {
    object-position: 50% 32% !important;
  }

  .mentor-front img.mentor-cc-photo,
  .mentor-front img[src$="/yfl-assets/cc-salzman.webp"] {
    object-position: 50% 30% !important;
  }

  .phases-section .yfl-tablet-title-line {
    display: block;
  }

  .phase-track {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .phase-track > .phase-card:last-child:nth-child(odd) {
    width: calc((100% - 18px) / 2) !important;
    grid-column: 1 / -1 !important;
    justify-self: center !important;
  }

  .steps-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .steps-grid > .step-card:last-child:nth-child(odd) {
    width: calc((100% - 14px) / 2) !important;
    grid-column: 1 / -1 !important;
    justify-self: center !important;
  }

  .outcomes-head h2 {
    width: 100% !important;
    max-width: none !important;
    margin-right: auto !important;
    margin-left: auto !important;
    font-size: clamp(36px, 5.2vw, 42px) !important;
    line-height: 0.98 !important;
    text-align: center !important;
    text-wrap: balance;
  }

  .outcomes-head h2 > span {
    display: block !important;
  }

  .outcomes-grid {
    grid-template-columns: minmax(290px, 0.92fr) minmax(0, 1.08fr) !important;
  }

  .alumni-cell {
    display: grid !important;
    grid-template-columns: 46px minmax(0, 1fr) 138px !important;
    gap: 10px !important;
    padding: 0 !important;
  }

  .alumni-name {
    min-width: 0 !important;
  }

  .alumni-count {
    width: 138px !important;
    margin-left: 0 !important;
    display: grid !important;
    grid-template-columns: 48px minmax(0, 1fr) !important;
    align-items: baseline !important;
    gap: 8px !important;
  }

  .alumni-count b {
    text-align: right !important;
  }

  .alumni-count em {
    white-space: nowrap !important;
  }

  /* About page: stable 2x2 stats and centered section introductions. */
  .yfl-about-page .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 16px !important;
  }

  .yfl-about-page .stats-grid > .stat-card {
    min-height: 136px !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    text-align: center !important;
  }

  .yfl-about-page .story-section {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 24px !important;
    text-align: center !important;
  }

  .yfl-about-page .story-section > div,
  .yfl-about-page .story-section h2,
  .yfl-about-page .story-section p {
    margin-right: auto !important;
    margin-left: auto !important;
    text-align: center !important;
  }

  .yfl-about-page .different-section > .different-kicker,
  .yfl-about-page .different-section > h2,
  .yfl-about-page .different-section > .different-lead {
    margin-right: auto !important;
    margin-left: auto !important;
    text-align: center !important;
  }

  /* Portrait footer: centered brand, then three equal link columns. */
  .yfl-footer-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 20px 18px !important;
  }

  .yfl-footer-grid > .yfl-footer-brand {
    grid-column: 1 / -1 !important;
    text-align: center !important;
  }

  .yfl-footer-brand > img {
    margin-right: auto !important;
    margin-left: auto !important;
  }

  .yfl-footer-brand > p {
    margin-right: auto !important;
    margin-left: auto !important;
    text-align: center !important;
  }

  .yfl-footer-brand > div,
  .yfl-footer-brand > div > span {
    justify-content: center !important;
  }

  .yfl-footer-grid > .yfl-footer-boundlearn,
  .yfl-footer-grid > .yfl-footer-yfl,
  .yfl-footer-grid > .yfl-footer-programs {
    grid-column: auto !important;
    min-width: 0 !important;
  }

  .yfl-footer-grid .yfl-footer-links {
    gap: 0 !important;
  }

  .yfl-footer-grid .yfl-footer-links a {
    min-height: 25px !important;
    display: flex !important;
    align-items: center !important;
    font-size: 12.5px !important;
    line-height: 1.25 !important;
  }

  /* Pitch Prep mastery cards use a balanced 2 + 2 + 1 composition. */
  .yfl-pitch-page .yfl-mastery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 14px !important;
  }

  .yfl-pitch-page .yfl-mastery-card:last-child:nth-child(odd) {
    width: calc((100% - 14px) / 2) !important;
    grid-column: 1 / -1 !important;
    justify-self: center !important;
  }
}

@media (min-width: 901px) and (max-width: 1180px) and (min-height: 700px) and (orientation: landscape) {
  .bl-tier1.bl-unified-header {
    padding-right: 30px !important;
    padding-left: 30px !important;
  }

  #bl-mnav.bl-unified-panel {
    right: 30px !important;
  }

  .site-header {
    position: sticky !important;
    top: 12px !important;
    right: auto !important;
    left: auto !important;
    width: calc(100% - 24px) !important;
    margin: 12px auto 0 !important;
    transform: none !important;
    padding-right: 18px !important;
    padding-left: 18px !important;
  }

  .page-shell {
    padding-top: 8px !important;
  }

  .hero-grid,
  .program-hero,
  .subhero {
    margin-top: 8px !important;
  }

  .mentor-intro h2 {
    max-width: 940px !important;
    font-size: clamp(38px, 4.4vw, 50px) !important;
  }

  .yfl-heading-default,
  .yfl-mentor-heading-desktop {
    display: none !important;
  }

  .yfl-heading-landscape,
  .yfl-mentor-heading-landscape {
    display: block !important;
  }

  .yfl-heading-landscape > span,
  .yfl-mentor-heading-landscape > span {
    display: block !important;
  }

  .mentor-large {
    min-height: 380px !important;
  }

  .mentor-front img {
    height: 250px !important;
    object-fit: cover !important;
  }

  .mentor-front img[src$="/yfl-assets/kevin.webp"],
  .mentor-front img[src$="/yfl-assets/michael.webp"] {
    object-position: 50% 8% !important;
  }

  .mentor-front img.mentor-cc-photo,
  .mentor-front img[src$="/yfl-assets/cc-salzman.webp"] {
    object-position: 50% 28% !important;
  }

  .phase-track {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .phase-track > .phase-card:last-child:nth-child(odd) {
    width: calc((100% - 18px) / 2) !important;
    grid-column: 1 / -1 !important;
    justify-self: center !important;
  }

  .steps-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .steps-grid > .step-card:last-child:nth-child(odd) {
    width: calc((100% - 14px) / 2) !important;
    grid-column: 1 / -1 !important;
    justify-self: center !important;
  }

  .programs-section > .section-heading {
    margin-right: auto !important;
    margin-left: auto !important;
    text-align: center !important;
  }

  .yfl-about-page .story-section {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 24px !important;
    text-align: center !important;
  }

  .yfl-about-page .story-section > div,
  .yfl-about-page .story-section h2,
  .yfl-about-page .story-section p,
  .yfl-about-page .different-section > .different-kicker,
  .yfl-about-page .different-section > h2,
  .yfl-about-page .different-section > .different-lead {
    margin-right: auto !important;
    margin-left: auto !important;
    text-align: center !important;
  }

  .outcomes {
    padding: 34px !important;
  }

  .outcomes-grid {
    grid-template-columns: 0.92fr 1.08fr !important;
    gap: 24px !important;
  }

  .testi-carousel {
    min-height: 340px !important;
  }

  .testi-slide {
    padding: 34px !important;
  }

  .yfl-pitch-page .yfl-mastery-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 14px !important;
  }

  .yfl-pitch-page .yfl-mastery-card {
    grid-column: span 2 !important;
  }

  .yfl-pitch-page .yfl-mastery-card:nth-child(4) {
    grid-column: 2 / span 2 !important;
  }

  .yfl-pitch-page .yfl-mastery-card:nth-child(5) {
    grid-column: 4 / span 2 !important;
  }
}

/* Keep the opening card attached to the approved YFL bar on portrait/tablet. */
@media (max-width: 1180px) and (min-height: 501px) {
  body.yfl-main-page .site-header + .page-shell {
    padding-top: 8px !important;
  }

  body.yfl-main-page .site-header + .page-shell > .hero-home:first-child {
    margin-top: 8px !important;
  }
}

/* Phone and tablet portrait follow the 24px opening rhythm used by the other YFL pages. */
@media (orientation: portrait) and (max-width: 900px) and (min-height: 501px) {
  body.yfl-main-page .site-header + .page-shell {
    padding-top: 12px !important;
  }

  body.yfl-main-page .site-header + .page-shell > .hero-home:first-child {
    margin-top: 12px !important;
  }
}

/* About retained an obsolete 52px opening gap; use the approved YFL rhythm. */
@media (orientation: portrait) and (max-width: 900px) and (min-height: 501px) {
  body.yfl-about-page .site-header + .page-shell {
    padding-top: 12px !important;
  }

  body.yfl-about-page .site-header + .page-shell > .hero-grid:first-child {
    margin-top: 12px !important;
  }
}

@media (min-width: 720px) and (max-width: 1180px) and (min-height: 700px) {
  .site-header.yfl-mobile-fixed {
    position: fixed !important;
    top: 12px !important;
    right: auto !important;
    left: 12px !important;
    width: calc(100% - 24px) !important;
    margin: 0 !important;
    transform: none !important;
    z-index: 500 !important;
  }

  .yfl-mobile-header-spacer {
    display: block;
    width: 100%;
  }
}

/* Approved portrait footer composition shared with CFI, SparkLab, and RISE. */
@media (orientation: portrait) and (min-width: 720px) and (max-width: 900px) and (min-height: 700px) {
  .yfl-footer {
    padding: 52px 32px 34px !important;
  }

  .yfl-footer-grid {
    grid-template-columns: minmax(225px, 1.7fr) repeat(3, minmax(0, 1fr)) !important;
    gap: 24px 22px !important;
    align-items: start !important;
  }

  .yfl-footer-grid > div,
  .yfl-footer-grid > .yfl-footer-brand {
    grid-column: auto !important;
    min-width: 0 !important;
  }

  .yfl-footer-grid > .yfl-footer-brand {
    align-items: flex-start !important;
    text-align: left !important;
  }

  .yfl-footer-brand > img {
    margin-inline: 0 !important;
  }

  .yfl-footer-brand > p {
    max-width: 320px !important;
    margin: 16px 0 0 !important;
    text-align: left !important;
  }

  .yfl-footer-brand > div,
  .yfl-footer-brand > div > span {
    justify-content: flex-start !important;
  }

  .yfl-footer-programs .yfl-footer-links {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
  }

  .yfl-footer-meta {
    align-items: normal !important;
    justify-content: space-between !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    text-align: left !important;
  }
}

/* Keep YFL's palette while matching the approved Delta landscape bar metrics. */
@media (orientation: landscape) and (min-width: 601px) and (max-width: 950px) and (max-height: 500px) {
  body.yfl-page .site-header {
    height: 62px !important;
    min-height: 62px !important;
    padding: 9px 12px 9px 22px !important;
    border-radius: 14px !important;
  }

  body.yfl-page .site-header .menu-toggle {
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    border: 1px solid rgba(122, 72, 245, .24) !important;
    border-radius: 50% !important;
    background: rgba(255, 250, 241, .92) !important;
  }
}
