/*
 * PDF flipbook pop-up (assets/js/flipbook.js). Opened from the "View" link of a PDF on
 * Resources and Downloads, Country strategies and Careers. Colours come from the theme's
 * variables in style.css (--theme-color1 lime, --theme-color2 dark green, --theme-color3 green).
 */
html.flipbook-lock-ssg, html.flipbook-lock-ssg body { overflow: hidden !important; }

.flipbook-ssg { position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center; justify-content: center; padding: 2vh 2vw; }
.flipbook-ssg[hidden] { display: none; }
.flipbook-ssg__backdrop { position: absolute; inset: 0; background: rgba(var(--theme-color2-rgb, 12, 47, 37), .88); touch-action: none; }
.flipbook-ssg__panel {
  position: relative; display: flex; flex-direction: column; width: 100%; max-width: 1500px; height: 100%;
  border-radius: 18px; overflow: hidden; background: #eef1ea; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  outline: none; overscroll-behavior: contain; touch-action: none;
}

.flipbook-ssg__head {
  display: flex; align-items: center; gap: 12px 20px; padding: 12px 14px 12px 22px;
  background: var(--theme-color2, #0C2F25); color: #fff;
}
.flipbook-ssg__titles { flex: 1 1 auto; min-width: 0; }
.flipbook-ssg__title {
  margin: 0; font-size: 18px; line-height: 1.3; font-weight: 600; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.flipbook-ssg__label { display: block; font-size: 13px; color: var(--theme-color1, #C7DC49); }
.flipbook-ssg__label:empty { display: none; }
.flipbook-ssg__tools { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.flipbook-ssg__tool, .flipbook-ssg__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; min-height: 44px;
  padding: 0 14px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .1);
  color: #fff; font-size: 14px; font-weight: 500; line-height: 1; text-decoration: none; cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}
.flipbook-ssg__tool:hover, .flipbook-ssg__tool:focus-visible,
.flipbook-ssg__btn:hover:not(:disabled), .flipbook-ssg__btn:focus-visible {
  background: var(--theme-color1, #C7DC49); color: var(--theme-color2, #0C2F25);
}
.flipbook-ssg :focus-visible { outline: 3px solid var(--theme-color1, #C7DC49); outline-offset: 2px; }
.flipbook-ssg__close { padding: 0; font-size: 20px; }

.flipbook-ssg__note { margin: 0; padding: 6px 22px; font-size: 13px; line-height: 1.4; color: #3d4a44; background: rgba(var(--theme-color1-rgb, 199, 220, 73), .22); }

.flipbook-ssg__stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 18px; overflow: hidden; }
.flipbook-ssg__sizer { position: relative; flex: 0 0 auto; }
.flipbook-ssg__sizer.is-hidden { visibility: hidden; }
.flipbook-ssg__page { background: #fff; overflow: hidden; }
.flipbook-ssg__page canvas { display: block; object-fit: contain; background: #fff; }
.flipbook-ssg__sizer .stf__parent { box-shadow: none; }

/* Zoomed page: a larger copy of the current page in a scrollable area. */
.flipbook-ssg__zoom {
  position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y pinch-zoom; padding: 18px; text-align: center;
}
.flipbook-ssg__zoom[hidden] { display: none; }
.flipbook-ssg__zoom canvas { display: inline-block; max-width: none; background: #fff; box-shadow: 0 4px 20px rgba(0, 0, 0, .15); }

.flipbook-ssg__status, .flipbook-ssg__error {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px; text-align: center; color: var(--theme-color2, #0C2F25); font-size: 16px; background: #eef1ea;
}
.flipbook-ssg__status[hidden], .flipbook-ssg__error[hidden] { display: none; }
.flipbook-ssg__error p { max-width: 460px; margin: 0; }
.flipbook-ssg__error a { display: inline-flex; align-items: center; gap: 8px; padding: 12px 22px; border-radius: 999px; background: var(--theme-color2, #0C2F25); color: #fff; font-weight: 500; text-decoration: none; }
.flipbook-ssg__error a:hover, .flipbook-ssg__error a:focus-visible { background: var(--theme-color3, #10551F); color: #fff; }

/* Loading progress: "Loading the document… 45%" and a bar (moving stripe while the size is unknown). */
.flipbook-ssg__status-text { display: block; }
.flipbook-ssg__percent { font-variant-numeric: tabular-nums; }
.flipbook-ssg__progress { position: relative; display: block; width: min(240px, 70%); height: 6px; border-radius: 999px; overflow: hidden; background: rgba(var(--theme-color2-rgb, 12, 47, 37), .15); }
.flipbook-ssg__progress span { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: var(--theme-color3, #10551F); transition: width .2s linear; }
.flipbook-ssg__progress.is-indeterminate span { width: 35%; animation: flipbook-progress-ssg 1.3s ease-in-out infinite; }
@keyframes flipbook-progress-ssg { 0% { left: -35%; } 100% { left: 100%; } }

/* Page 1's cover picture, shown where the first page will be until that page is drawn. */
.flipbook-ssg__cover { position: absolute; top: 0; z-index: 5; display: block; max-width: none; object-fit: fill; background: #fff; box-shadow: 0 4px 20px rgba(0, 0, 0, .12); }
/* With the cover on screen, the loading message is a small panel at the bottom instead of covering the stage. */
.flipbook-ssg__stage.has-cover .flipbook-ssg__status {
  inset: auto 50% 26px auto; transform: translateX(50%); z-index: 6; flex-direction: column; gap: 8px; width: max-content; max-width: calc(100% - 36px);
  padding: 10px 18px 12px; border-radius: 14px; background: rgba(255, 255, 255, .94); box-shadow: 0 4px 18px rgba(0, 0, 0, .18); font-size: 14px;
}
.flipbook-ssg__stage.has-cover .flipbook-ssg__spinner { display: none; }
.flipbook-ssg__stage.has-cover .flipbook-ssg__progress { width: 200px; max-width: 100%; }

/* Loading: the wheat stalks of the site's own loading screen. */
.flipbook-ssg__spinner {
  width: 60px; height: 80px; background: url(../images/icons/wheat-ssg.svg) center / contain no-repeat;
  animation: flipbook-pulse-ssg 1.2s ease-in-out infinite;
}
@keyframes flipbook-pulse-ssg { 0%, 100% { opacity: .35; transform: scale(.92); } 50% { opacity: 1; transform: scale(1); } }

.flipbook-ssg__foot {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px 14px; padding: 10px 14px;
  background: #fff; border-top: 1px solid rgba(var(--theme-color2-rgb, 12, 47, 37), .1);
}
.flipbook-ssg__foot .flipbook-ssg__btn { background: var(--theme-color2, #0C2F25); }
.flipbook-ssg__foot .flipbook-ssg__btn:disabled { opacity: .35; cursor: default; }
.flipbook-ssg__count { min-width: 140px; text-align: center; font-size: 15px; font-weight: 500; color: var(--theme-color2, #0C2F25); }
.flipbook-ssg__zoom-tools { display: inline-flex; gap: 8px; padding-left: 14px; border-left: 1px solid rgba(var(--theme-color2-rgb, 12, 47, 37), .15); }
.flipbook-ssg__zoom-tools[hidden] { display: none; }

@media (max-width: 767px) {
  .flipbook-ssg { padding: 0; }
  .flipbook-ssg__panel { border-radius: 0; }
  .flipbook-ssg__head { padding: 8px 8px 8px 14px; gap: 8px; }
  .flipbook-ssg__title { font-size: 16px; }
  .flipbook-ssg__tool { padding: 0; }
  .flipbook-ssg__tool span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .flipbook-ssg__note { padding: 5px 14px; font-size: 12px; }
  .flipbook-ssg__stage, .flipbook-ssg__zoom { padding: 10px; }
  .flipbook-ssg__count { min-width: 110px; font-size: 14px; }
  .flipbook-ssg__zoom-tools { padding-left: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .flipbook-ssg__spinner { animation: none; }
  .flipbook-ssg__progress span { transition: none; }
  .flipbook-ssg__progress.is-indeterminate span { left: 0; width: 100%; opacity: .45; animation: none; }
  .flipbook-ssg__tool, .flipbook-ssg__btn { transition: none; }
}
