/*
Theme Name:     WP Spinnr Child
Theme URI:      
Template:       wp-spinnr
Version:        1.0
*/

/* Custom styles live here, not in spinnr.min.css, which the Spinnr sync overwrites. */

/* ---------- Header ---------- */

/* Full width, side margin comes from the container + navbar padding (~31px) */
#header > .container {
    max-width: none;
}

/* Page title sits just left of the Contents menu instead of centred.
   !important is needed to beat Bootstrap's .mx-auto on the element. */
#header .site-title {
    font-family: "DM Sans", Arial, sans-serif;
    font-weight: 400;
    margin-left: auto !important;
    margin-right: 1.25rem !important;
}

#header #main-nav .nav-link {
    font-family: "Work Sans", sans-serif;
    font-size: 1.25rem; /* 20px, same as the page title */
    font-weight: 800;
}

/* Cancel the link's right padding so the text lines up with the logo's left margin */
@media (min-width: 992px) {
    #header #main-nav {
        margin-right: -1rem;
    }
}

/* Sticky (scrolled) header: Spinnr scales the logo to 60% and shifts it left 30px,
   which leaves it at 28px. -27px puts it back on the same 31px margin as the title/Contents. */
@media only screen and (min-width: 960px) {
    #header.js-is-sticky .navbar-logo {
        left: -27px;
    }
}

/* Keep the Contents tab white while its dropdown is open or the mouse is over the menu
   (Spinnr only styles .nav-link:hover, which is lost when moving down into the menu) */
#header #main-nav .dropdown:hover > .nav-link,
#header #main-nav .dropdown.show > .nav-link {
    background-color: #fff;
    color: #671E75 !important;
}

/* Contents dropdown panel: rounded bottom corners */
#header #main-nav .dropdown-menu {
    border-radius: 0 0 30px 30px;
}

/* Contents dropdown: sentence case (was uppercase), dark plum on hover */
#header #main-nav .dropdown-menu .dropdown-item {
    font-size: 1.125rem; /* 18px */
    text-transform: none;
}

#header #main-nav .dropdown-menu .dropdown-item:hover,
#header #main-nav .dropdown-menu .dropdown-item:focus {
    color: #332336 !important;
}

/* ---------- Buttons ----------
   Build a button from: fb-btn + one colour + (optional) fb-btn--ghost + (optional) fb-btn--icon

     <a class="fb-btn fb-btn--purple fb-btn--icon collapse-btn" href="#">Show more…</a>
     <button type="button" class="fb-btn fb-btn--lightpurple close-btn">Close panel</button>
     <a class="fb-btn fb-btn--lightpurple fb-btn--ghost" href="…">IPSOS Report</a>

   Add collapse-btn / close-btn to use Spinnr's drawer open/close behaviour.
   Spinnr adds .expanded to the collapse-btn while its drawer is open, which turns the icon.

   Each colour sets four variables, so a new colour is one small block.
     --fb-btn-color       solid fill, or ghost border + text
     --fb-btn-text        text on the solid fill
     --fb-btn-hover       fill on hover
     --fb-btn-hover-text  text on hover
*/
.fb-btn {
    --fb-btn-color: #671E75;
    --fb-btn-text: #CDB1F9;
    --fb-btn-hover: #332336;
    --fb-btn-hover-text: #CDB1F9;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    box-sizing: border-box;
    min-height: 46px; /* min, so a long label can wrap to two lines on a phone instead of overflowing */
    min-width: 220px;
    max-width: 100%;
    padding: 0.5rem 1.25rem;
    border: 2px solid var(--fb-btn-color);
    border-radius: 23px;
    background-color: var(--fb-btn-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    color: var(--fb-btn-text);
    font-family: "DM Sans", Arial, sans-serif;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none !important; /* beats Spinnr's a:not(.btn) underline */
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

/* Also applies to ghost buttons, which fill in on hover */
.fb-btn:hover,
.fb-btn:focus {
    border-color: var(--fb-btn-hover);
    background-color: var(--fb-btn-hover);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
    color: var(--fb-btn-hover-text);
    opacity: 1; /* Spinnr fades .close-btn on hover */
}

.fb-btn:focus {
    outline: none;
}

.fb-btn:focus-visible {
    outline: 3px solid #ffa096;
    outline-offset: 3px;
}

/* Colours */
.fb-btn--purple {
    --fb-btn-color: #671E75;
    --fb-btn-text: #CDB1F9;
    --fb-btn-hover: #332336;
    --fb-btn-hover-text: #CDB1F9;
}

.fb-btn--lightpurple {
    --fb-btn-color: #CDB1F9;
    --fb-btn-text: #671E75;
    --fb-btn-hover: #F2F2E2;
    --fb-btn-hover-text: #671E75;
}

/* Ghost: outline only. On hover it fills in to look like the solid version. */
.fb-btn--ghost {
    background-color: transparent;
    box-shadow: none;
    color: var(--fb-btn-color);
}

.fb-btn--ghost:hover,
.fb-btn--ghost:focus {
    border-color: var(--fb-btn-color);
    background-color: var(--fb-btn-color);
    color: var(--fb-btn-text);
}

/* Icon: same Font Awesome play-circle as the old .link buttons; turns 90° while the drawer is open */
.fb-btn--icon {
    justify-content: space-between;
}

.fb-btn--icon::after {
    content: "\f144";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 1.25rem;
    line-height: 1;
    transition: transform 0.35s linear;
}

.fb-btn--icon.expanded::after {
    transform: rotate(90deg);
}

/* ---------- Section cards ----------
   Add fb-card to a section's outer div to make it a rounded card with a 20px white gap around it:

     <div id="foodsecurity" class="section fb-card bg-primary" data-menu="…">

   The drawer (.collapse) sits inside the section, so when it opens it becomes the bottom
   of the card: the join with the main panel is square and the rounded corners move down.
   Vertical margins collapse between siblings, so 20px top + 20px bottom = a 20px gap between cards
   (and 20px under the header / above the footer).
*/
.fb-card {
    margin: 20px 0;
    border-radius: 40px;
    overflow: hidden;   /* clips full-bleed images and the drawer to the corners */
    isolation: isolate; /* keeps Safari clipping to the corners while animated (AOS) content moves */
}

@media (max-width: 767.98px) {
    .fb-card {
        border-radius: 30px;
    }
}

/* ---------- Extra colours ----------
   Light cream used for drawers in the 2026 layouts (lighter than bg-cream #F2F2E2).
   If the same class is added to Spinnr's styles it will also show in the Spinnr editor. */
.bg-cream-light {
    background-color: #F7F7EF;
}

/* ---------- Report typography ----------
   Body text in card sections: 18px on 24px lines, as in the 2026 layouts (site default is 27px). */
.fb-card p,
.fb-card li {
    line-height: 1.35;
}

/* Big section title ("A nation under pressure"): 64px, tight lines. Use on the section's h2.
   .section .fb-title beats Spinnr's .section h2 (44px). */
.section .fb-title {
    font-size: 4rem;
    line-height: 1;
}

@media (max-width: 767.98px) {
    .section .fb-title {
        font-size: 2.75rem;
    }
}

/* Links in body text: purple, bold, underlined (Spinnr removes underlines from all links) */
.fb-card a.fb-link {
    color: #671E75;
    font-weight: 700;
    text-decoration: underline;
}

.fb-card a.fb-link:hover,
.fb-card a.fb-link:focus {
    color: #332336;
}

/* Chart titles: 18px bold (Spinnr's h5 is 20px/600, which wraps the longer titles) */
.section .fb-chart-title {
    font-size: 1.125rem;
    font-weight: 700;
}

/* Smaller Work Sans title, e.g. the people queue heading: 26px on 30px lines */
.section .fb-title-sm {
    font-size: 1.625rem;
    line-height: 1.15;
}

/* Chart footnotes / sources: 11px */
.fb-card .fb-note {
    font-size: 0.6875rem;
    line-height: 1.4;
}

/* ---------- People queue ----------
   A line of people that grows as the reader scrolls, with a counter.
   fb-report.js builds the figures from the sprite in data-sprite (one <symbol> per figure).

     <p class="fb-queue-count text-bacon" aria-hidden="true"><span class="fb-queue-num">3,600,000</span> households</p>
     <div class="fb-queue text-primary" data-sprite="/wp-content/uploads/…/queue-people.svg"
          data-total="3600000" data-people="120" role="img" aria-label="…"></div>

   Figures take their colour from the text colour (text-primary = purple).
   --fb-queue-height is the height of the tallest figure; the others keep their relative sizes. */
.fb-queue {
    --fb-queue-height: 45px;
    position: relative;
    overflow: hidden;
    min-height: var(--fb-queue-height);
    /* fade the right edge to hint that the line keeps going */
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 60px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 60px), transparent);
}

@media (max-width: 767.98px) {
    .fb-queue {
        --fb-queue-height: 34px;
    }
}

.fb-queue-track {
    display: flex;
    align-items: flex-end;
    width: max-content;
    will-change: transform;
    transition: transform 0.2s ease-out;
}

/* --h: figure height as a share of the tallest; --g: gap before it (can be negative, people overlap) */
.fb-queue-item {
    display: block;
    flex: none;
    width: auto;
    height: calc(var(--h, 1) * var(--fb-queue-height));
    margin-left: calc(var(--g, 0) * var(--fb-queue-height));
    fill: currentColor;
    opacity: 0;
    transform: translateY(6px) scale(0.92);
    transform-origin: 50% 100%;
    transition: opacity 0.35s cubic-bezier(0.22, 0.61, 0.36, 1), transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.fb-queue-item.on {
    opacity: 1;
    transform: none;
}

.fb-queue-count {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
    .fb-queue-item {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .fb-queue-track {
        transition: none;
    }
}

/* ---------- Report cover hero ----------
   Add fb-hero to the cover's .hero-banner (inside .report-cover-collapsible):

     <div class="hero-banner fb-hero bg-plum">

   Spinnr fixes the hero at 46rem tall from 768px up, so on narrower screens the photo keeps
   its height, crops in from the left and the faces end up under the text.
   - 1200px and up: height scales with the width (45vw = 720px at 1600px, like the design),
     so the right-anchored photo keeps the faces clear of the text.
   - below 1200px: stack image above text, as Spinnr already does under 768px.
     Give the .hero-banner a background class (e.g. bg-plum) for the text area. */
@media (min-width: 1200px) {
    .report-cover-collapsible > div.hero-banner.fb-hero > div {
        min-height: 45vw;
    }
}

@media (min-width: 768px) and (max-width: 1199.98px) {
    .report-cover-collapsible > div.hero-banner.fb-hero > img {
        position: static;
        height: 24rem;
    }

    .report-cover-collapsible > div.hero-banner.fb-hero > div {
        min-height: 0;
        padding-top: 2.5rem !important;
        padding-bottom: 3rem !important;
    }
}

/* Card drawer animation (opening/closing is handled by fb-report.js)
   The drawer's own padding (py-5) can't shrink, so the drawer jumped 96px on the first frame.
   Move the padding onto the content inside so the height animates from a true 0.
   Bootstrap swaps .collapse for .collapsing while animating, so every rule targets both. */
.fb-card > .collapse,
.fb-card > .collapsing {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.fb-card > .collapse > .container,
.fb-card > .collapsing > .container {
    padding-top: 3rem; /* same as py-5 */
    padding-bottom: 3rem;
}

/* 0.5s with a soft start and finish. Keep in step with DRAWER_DURATION in fb-report.js.
   Bootstrap 4.0.0 cuts animations off at 600ms, so don't go above 0.6s. */
.fb-card > .collapsing {
    transition: height 0.5s cubic-bezier(0.65, 0, 0.35, 1);
}

/* Content fade. fb-report.js adds .fb-anim to each card (so content stays visible if the JS
   doesn't load) and .fb-open while the drawer is open or opening. */
.fb-card.fb-anim > .collapse > .container,
.fb-card.fb-anim > .collapsing > .container {
    opacity: 0;
    transition: opacity 0.25s ease;
}

.fb-card.fb-anim.fb-open > .collapse > .container,
.fb-card.fb-anim.fb-open > .collapsing > .container {
    opacity: 1;
    transition: opacity 0.4s ease 0.15s;
}
