/* =====================================================================
   Video - Chaptered Player (prefix: .afcp, pop-up: .afcp-modal)
   A video box on the navy grid with a chapter list beside it. Pressing play, the poster, a
   chapter or the bar opens a full-screen pop-up player at that point; module.js loads YouTube
   only then, fills both bars as it plays and highlights the current chapter on the page and in
   the pop-up. The pop-up is moved to the end of <body>, so its rules do not sit under .afcp.
   Options (classes on the section):
     afcp--gradient | afcp--navy                 background
     afcp--grid                                  44px grid lines
     afcp--video-left | --video-right            which side the video sits on (desktop)
     afcp--tall | afcp--wide                     video box about 30% taller than 16:9, or 16:9
     afcp--play-center | afcp--play-corner       play button position
     afcp--focus-center | --focus-left | --focus-right   which part of the poster stays in view
   State (set by module.js): .is-open, .is-loading, .is-fallback on .afcp-modal;
     html.afcp-lock while the pop-up is open
   Uses the theme's CSS variables with AirFreight.com values as fallbacks.
   Assumes the theme's html { font-size: 62.5% } (1rem = 10px).
   Square corners, no drop shadows.
   ===================================================================== */
.afcp, .afcp-modal {
  --afcp-blue: var(--primary-color, #0092D6);
  --afcp-blue-2: var(--secondary-color, #006EB8);
  --afcp-ice: #01B0FF;
  --afcp-sky: #8CD8FF;
  --afcp-navy: #00305A;
  --afcp-text: #DCEBF6;
  --afcp-line: rgba(255, 255, 255, .18);
  --afcp-display: var(--secondary-font-family, 'Jost', sans-serif);
  --afcp-body: var(--primary-font-family, 'Raleway', sans-serif);
  --afcp-gridlines: linear-gradient(rgba(255,255,255,.055) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.055) 1px, transparent 1px);
}
.afcp {
  --afcp-c: min(var(--container-width, 1180px), 100% - 40px);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  overflow: clip;
  /* never wider than the screen: HubSpot's flex rows let a module's minimum width push the column open */
  min-width: 0;
  max-width: 100vw;
  padding: 9rem 0;
  color: var(--afcp-text);
  font-family: var(--afcp-body);
  font-weight: 500;
  background-color: var(--afcp-navy);
}
.afcp--gradient { background-image: linear-gradient(115deg, #00305A 0%, #00518F 42.5%, var(--afcp-blue-2) 100%); }
.afcp--gradient.afcp--grid {
  background-image: var(--afcp-gridlines), linear-gradient(115deg, #00305A 0%, #00518F 42.5%, var(--afcp-blue-2) 100%);
  background-size: 44px 44px, 44px 44px, 100% 100%;
}
.afcp--navy.afcp--grid { background-image: var(--afcp-gridlines); background-size: 44px 44px, 44px 44px; }

.afcp *, .afcp *::before, .afcp *::after,
.afcp-modal, .afcp-modal *, .afcp-modal *::before, .afcp-modal *::after { box-sizing: border-box; }
.afcp p, .afcp-modal p { margin: 0; }
.afcp__wrap { position: relative; width: var(--afcp-c); margin-inline: auto; }

/* theme button styles are reset so the play button, chapters and close button start clean */
.afcp button, .afcp-modal button {
  -webkit-appearance: none; appearance: none;
  margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; text-shadow: none;
  background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: none;
  line-height: inherit; width: auto; height: auto; min-width: 0; min-height: 0; cursor: pointer;
}
.afcp button:focus-visible, .afcp a:focus-visible, .afcp-modal button:focus-visible { outline: 2px solid var(--afcp-ice); outline-offset: 2px; }
.afcp__sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- Layout: video on one side, heading and chapters on the other, centred as a group ------ */
.afcp__grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  grid-template-rows: 1fr auto auto 1fr;
  grid-template-areas: "media ." "media head" "media list" "media .";
  column-gap: clamp(3.6rem, 4.4vw, 6.4rem);
}
.afcp--video-right .afcp__grid {
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-areas: ". media" "head media" "list media" ". media";
}
.afcp__head { grid-area: head; min-width: 0; }
.afcp__media { grid-area: media; align-self: center; min-width: 0; }
.afcp__list { grid-area: list; min-width: 0; margin-top: 3rem; }

/* ---- Heading ------------------------------------------------------------------------------- */
.afcp .afcp__eyebrow { display: flex; align-items: center; gap: 1.44rem; margin: 0 0 1.6rem; font-family: var(--afcp-display); font-weight: 700; font-size: 1.5rem; line-height: 1.4; letter-spacing: 3px; text-transform: uppercase; color: #fff; }
.afcp__eyebrow::before { content: ""; flex: none; width: 1.98rem; height: 3px; background: currentColor; }
.afcp .afcp__title { margin: 0; font-family: var(--afcp-display); font-weight: 600; font-size: clamp(3.2rem, 3.6vw, 4.4rem); line-height: 1.12; letter-spacing: 0; text-transform: none; color: #fff; text-wrap: balance; }
.afcp__title em { font-style: normal; color: var(--afcp-sky); }
.afcp .afcp__lede { margin-top: 1.6rem; font-size: 1.8rem; line-height: 1.7; color: var(--afcp-text); }

/* ---- Video box on the page ----------------------------------------------------------------- */
.afcp__media { position: relative; }
.afcp__frame { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #00243F; cursor: pointer; }
.afcp--tall .afcp__frame { aspect-ratio: 16 / 11.7; } /* about 30% taller than 16:9 */
.afcp .afcp__poster { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; margin: 0; object-fit: cover; object-position: center; transition: transform .7s cubic-bezier(.2, .8, .2, 1); }
.afcp--focus-left .afcp__poster { object-position: left center; }
.afcp--focus-right .afcp__poster { object-position: right center; }
.afcp__frame::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(0deg, rgba(0,48,90,.78) 0%, rgba(0,48,90,0) 55%); }
.afcp__frame:hover .afcp__poster { transform: scale(1.03); }

.afcp .afcp__play { position: absolute; left: 50%; top: 50%; z-index: 2; width: 84px; height: 84px; transform: translate(-50%, -50%); display: grid; place-items: center; background: var(--afcp-blue); color: #fff; transition: background .2s; }
.afcp--play-corner .afcp__play { left: 18px; top: auto; bottom: 44px; transform: none; }
.afcp__play::before { content: ""; margin-left: 6px; border-left: 22px solid #fff; border-top: 14px solid transparent; border-bottom: 14px solid transparent; }
.afcp .afcp__play:hover, .afcp__frame:hover .afcp__play { background: var(--afcp-blue-2); }
.afcp .afcp__play:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* ---- Rail: time and chapter bar (over the poster, and under the video in the pop-up) -------- */
.afcp__rail { position: absolute; left: 18px; right: 18px; bottom: 18px; z-index: 2; display: flex; flex-direction: column; align-items: flex-end; gap: 9px; pointer-events: none; }
.afcp__time { font-family: var(--afcp-display); font-weight: 500; font-size: 1.3rem; line-height: 1; letter-spacing: .08em; color: #fff; font-variant-numeric: tabular-nums; white-space: nowrap; }
.afcp__bar { position: relative; display: block; align-self: stretch; height: 4px; background: rgba(255, 255, 255, .25); pointer-events: auto; cursor: pointer; }
.afcp__bar::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; bottom: -10px; } /* bigger click target */
.afcp__fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: var(--afcp-ice); }
.afcp-modal.is-open .afcp__fill { transition: width .25s linear; }
.afcp__tick { position: absolute; top: -4px; width: 2px; height: 12px; margin-left: -1px; background: #fff; pointer-events: none; }
.is-empty .afcp__total { display: none; }

/* ---- Chapter list on the page -------------------------------------------------------------- */
.afcp .afcp__chapters, .afcp-modal .afcp-modal__chapters { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.afcp .afcp__chapters { border-top: 1px solid var(--afcp-line); }
.afcp .afcp__chapters li, .afcp-modal .afcp-modal__chapters li { margin: 0; padding: 0; list-style: none; }
.afcp .afcp__chapters li::before, .afcp .afcp__chapters li::marker,
.afcp-modal .afcp-modal__chapters li::before, .afcp-modal .afcp-modal__chapters li::marker { content: none; display: none; }
.afcp .afcp__chapter {
  position: relative; display: grid; grid-template-columns: 7rem minmax(0, 1fr) 2rem; gap: 1.2rem; align-items: center;
  width: 100%; padding: 1.4rem 1.2rem 1.4rem 1.6rem; border-bottom: 1px solid var(--afcp-line); text-align: left;
  font-family: var(--afcp-body); font-weight: 600; font-size: 1.6rem; line-height: 1.4; color: #fff;
  transition: background .2s, box-shadow .2s;
}
.afcp__chap-time { font-family: var(--afcp-display); font-weight: 500; font-size: 1.5rem; letter-spacing: .06em; color: var(--afcp-sky); font-variant-numeric: tabular-nums; white-space: nowrap; }
.afcp__chap-title { min-width: 0; overflow-wrap: anywhere; }
.afcp__chap-go { justify-self: end; display: block; width: 8px; height: 13px; color: rgba(255, 255, 255, .5); transition: transform .2s, color .2s; }
.afcp .afcp__chapter:hover { background: rgba(255, 255, 255, .05); }
.afcp .afcp__chapter:hover .afcp__chap-go { color: #fff; transform: translateX(3px); }
.afcp .afcp__chapter:focus-visible { outline-offset: -2px; }
.afcp .afcp__chapter[aria-current="true"] { background: rgba(255, 255, 255, .07); box-shadow: inset 3px 0 0 var(--afcp-ice); }
.afcp .afcp__chapter[aria-current="true"] .afcp__chap-go { color: var(--afcp-ice); }

.afcp .afcp__link { display: inline-flex; align-items: center; gap: .6em; margin-top: 2.4rem; font-family: var(--afcp-display); font-weight: 600; font-size: 1.3rem; line-height: 1.4; letter-spacing: .1em; text-transform: uppercase; text-decoration: none; color: var(--afcp-sky); transition: color .2s; }
.afcp .afcp__link:hover { color: #fff; text-decoration: none; }
.afcp__link span { transition: transform .2s; }
.afcp .afcp__link:hover span { transform: translateX(3px); }

/* ---- Pop-up player ------------------------------------------------------------------------- */
html.afcp-lock, html.afcp-lock body { overflow: hidden; }
.afcp-modal {
  position: fixed; inset: 0; z-index: 2147483000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 32px; overflow-y: auto; overscroll-behavior: contain;
  color: var(--afcp-text); font-family: var(--afcp-body); font-weight: 500;
  opacity: 0; transition: opacity .25s ease;
}
.afcp-modal[hidden] { display: none; }
.afcp-modal.is-open { opacity: 1; }
.afcp-modal__backdrop {
  position: fixed; inset: 0; cursor: pointer;
  background-color: rgba(0, 22, 42, .985);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 44px 44px;
}
.afcp-modal__dialog {
  position: relative; margin: auto;
  /* as wide as the screen allows while the video, top bar, rail and chapter strip still fit its height */
  width: min(1320px, 100%, (100vh - 250px) * 16 / 9);
  transform: translateY(14px); transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}
@supports (height: 100dvh) { .afcp-modal__dialog { width: min(1320px, 100%, (100dvh - 250px) * 16 / 9); } }
.afcp-modal.is-open .afcp-modal__dialog { transform: none; }

.afcp-modal__top { display: flex; align-items: center; justify-content: space-between; gap: 2rem; margin-bottom: 14px; }
.afcp-modal .afcp-modal__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--afcp-display); font-weight: 600; font-size: 1.5rem; line-height: 1.3; letter-spacing: .1em; text-transform: uppercase; color: #fff; }
.afcp-modal .afcp-modal__close { flex: none; width: 44px; height: 44px; display: grid; place-items: center; background: #fff; color: var(--afcp-blue-2); transition: background .2s, color .2s; }
.afcp-modal .afcp-modal__close:hover { background: var(--afcp-blue); color: #fff; }
.afcp-modal .afcp-modal__close:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.afcp-modal__close svg { display: block; }

.afcp-modal__stage { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #000; }
.afcp-modal__stage iframe { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border: 0; }
/* loading: a short ice bar runs along the bottom of the video */
.afcp-modal__stage::after { content: ""; position: absolute; left: 0; bottom: 0; width: 30%; height: 4px; background: var(--afcp-ice); opacity: 0; pointer-events: none; }
.afcp-modal.is-loading .afcp-modal__stage::after { opacity: 1; animation: afcp-load 1.1s cubic-bezier(.4, 0, .2, 1) infinite; }
@keyframes afcp-load { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

.afcp-modal__rail { display: flex; align-items: center; gap: 18px; margin-top: 18px; }
.afcp-modal__rail .afcp__bar { flex: 1 1 auto; }
.afcp-modal .afcp__time { color: var(--afcp-text); }
.afcp-modal.is-fallback .afcp-modal__rail { display: none; }

.afcp-modal .afcp-modal__chapters { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(17rem, 1fr); margin-top: 18px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.3) transparent; }
.afcp-modal .afcp-modal__chapter {
  display: flex; flex-direction: column; gap: 4px; width: 100%; height: 100%;
  padding: 12px 16px 14px 0; border-top: 3px solid rgba(255, 255, 255, .18); text-align: left;
  font-family: var(--afcp-body); font-weight: 600; font-size: 1.45rem; line-height: 1.35; color: rgba(255, 255, 255, .8);
  transition: border-color .2s, color .2s;
}
.afcp-modal .afcp-modal__chapter:hover { border-top-color: rgba(255, 255, 255, .55); color: #fff; }
.afcp-modal .afcp-modal__chapter:focus-visible { outline-offset: -2px; }
.afcp-modal .afcp-modal__chapter[aria-current="true"] { border-top-color: var(--afcp-ice); color: #fff; }
.afcp-modal__chapter .afcp__chap-time { font-size: 1.3rem; }
.afcp-modal__chapter .afcp__chap-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .afcp .afcp__poster, .afcp__chap-go, .afcp__link span, .afcp-modal.is-open .afcp__fill, .afcp-modal, .afcp-modal__dialog { transition: none; }
  .afcp__frame:hover .afcp__poster { transform: none; }
  .afcp-modal__dialog { transform: none; }
  .afcp-modal.is-loading .afcp-modal__stage::after { animation: none; left: 35%; }
}

/* ---- Tablet and phone: heading, then the video, then the chapters --------------------------- */
@media (max-width: 900px) {
  .afcp { padding: 6rem 0; }
  .afcp__grid, .afcp--video-right .afcp__grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "head" "media" "list";
  }
  .afcp__media { margin-top: 3rem; }
  .afcp__list { margin-top: 2.4rem; }
}
@media (max-width: 767px) {
  .afcp { padding: 40px 0; }
  .afcp .afcp__lede { font-size: 1.6rem; }
  .afcp .afcp__play { width: 64px; height: 64px; }
  .afcp--play-corner .afcp__play { left: 12px; bottom: 34px; }
  .afcp__play::before { margin-left: 5px; border-left-width: 18px; border-top-width: 11px; border-bottom-width: 11px; }
  .afcp__rail { left: 12px; right: 12px; bottom: 12px; gap: 7px; }
  .afcp__time { font-size: 1.2rem; }
  .afcp .afcp__chapter { grid-template-columns: 6.2rem minmax(0, 1fr) 1.6rem; gap: 1rem; padding: 1.3rem 1rem 1.3rem 1.2rem; font-size: 1.5rem; }
  .afcp__chap-time { font-size: 1.4rem; }
}

/* Pop-up on phones and portrait tablets: chapters as a list under the video */
@media (max-width: 640px), (max-width: 900px) and (orientation: portrait) {
  .afcp-modal .afcp-modal__chapters { grid-auto-flow: row; grid-auto-columns: auto; overflow: visible; border-top: 1px solid var(--afcp-line); }
  .afcp-modal .afcp-modal__chapter { display: grid; grid-template-columns: 6.2rem minmax(0, 1fr); gap: 1rem; align-items: center; padding: 1.3rem 1rem 1.3rem 1.2rem; border-top: 0; border-bottom: 1px solid var(--afcp-line); font-size: 1.5rem; color: #fff; }
  .afcp-modal .afcp-modal__chapter:hover { background: rgba(255, 255, 255, .05); }
  .afcp-modal .afcp-modal__chapter[aria-current="true"] { background: rgba(255, 255, 255, .07); box-shadow: inset 3px 0 0 var(--afcp-ice); }
  .afcp-modal__chapter .afcp__chap-time { font-size: 1.4rem; }
}
/* Pop-up on phones (portrait): edge-to-edge video */
@media (max-width: 640px) {
  .afcp-modal { padding: 0; align-items: stretch; }
  .afcp-modal__dialog { width: 100%; min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 12px 0 24px; }
  .afcp-modal__top { margin: 0 0 12px; padding: 0 12px 0 16px; }
  .afcp-modal .afcp-modal__title { font-size: 1.3rem; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .afcp-modal__rail { margin: 16px 16px 0; gap: 14px; }
  .afcp-modal .afcp-modal__chapters { margin: 16px 16px 0; }
}
/* Pop-up on short screens (phones held sideways): the video uses the height, the rest scrolls */
@media (max-height: 560px) and (min-width: 641px) {
  .afcp-modal { align-items: flex-start; padding: 12px 24px; }
  .afcp-modal__dialog { width: min(1320px, 100%, (100vh - 76px) * 16 / 9); }
  @supports (height: 100dvh) { .afcp-modal__dialog { width: min(1320px, 100%, (100dvh - 76px) * 16 / 9); } }
  .afcp-modal__top { margin-bottom: 8px; }
}

/* ---- Hosted video file (data-source="file") ------------------------------------------------ */
.afcp video.afcp__poster { background: var(--afcp-navy); pointer-events: none; }
.afcp-modal__stage video.afcp-modal__video { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; margin: 0; border: 0; background: #000; object-fit: contain; }
