/*
Theme Name: Results Performance — Astra Child
Template:   astra
Version:    2.0.0
Description: RP dark-first brand system. theme.json is the single source of truth for colour/spacing/type — this file only aliases those tokens (--c-*, --space-*, --text-*) for legible selectors below, plus component CSS and interaction polish. ZERO !important — uses CSS layers.
Author:     Mediamantra
*/

/* ==========================================================================
   CSS LAYERS — explicit cascade order so child rules win without !important
   ========================================================================== */
@layer reset, wp-core, astra, child;

/* ==========================================================================
   CHILD LAYER — all overrides + polish live here
   ========================================================================== */
@layer child {

  /* ----- Token aliases -----------------------------------------------------
     theme.json is the source of truth (settings.color.palette / spacing /
     typography). These are READ-ONLY aliases — same values, no drift.
     Two values (--c-text-muted, --c-border) are derived with color-mix()
     from the ink token so the original locked rgba alpha intent
     (rgba(251,247,241,.65) / .12) survives without hardcoding a second hex.
     ---------------------------------------------------------------------- */
  :root {
    /* Spacing scale */
    --space-0:   var(--wp--preset--spacing--0);
    --space-3xs: var(--wp--preset--spacing--3xs);
    --space-2xs: var(--wp--preset--spacing--2xs);
    --space-xs:  var(--wp--preset--spacing--xs);
    --space-s:   var(--wp--preset--spacing--sm);
    --space-m:   var(--wp--preset--spacing--md);
    --space-l:   var(--wp--preset--spacing--lg);
    --space-xl:  var(--wp--preset--spacing--xl);
    --space-2xl: var(--wp--preset--spacing--2xl);
    --space-3xl: var(--wp--preset--spacing--3xl);

    /* Typography scale */
    --text-sm:   var(--wp--preset--font-size--sm);
    --text-body: var(--wp--preset--font-size--base);
    --text-lg:   var(--wp--preset--font-size--lg);
    --text-h4:   var(--wp--preset--font-size--h4);
    --text-h3:   var(--wp--preset--font-size--h3);
    --text-h2:   var(--wp--preset--font-size--h2);
    --text-h1:   var(--wp--preset--font-size--h1);

    /* Colour tokens — RP locked dark-first palette (design-system.md v1) */
    --c-bg:            var(--wp--preset--color--bg);
    --c-surface:       var(--wp--preset--color--surface);
    --c-text:          var(--wp--preset--color--ink);
    --c-text-muted:    color-mix(in srgb, var(--wp--preset--color--ink) 65%, transparent);
    --c-primary:       var(--wp--preset--color--primary);
    --c-primary-hover: var(--wp--preset--color--primary-hover);
    --c-accent:        var(--wp--preset--color--accent);
    --c-border:        color-mix(in srgb, var(--wp--preset--color--ink) 12%, transparent);

    /* Macro chip colours — shared with the RP Fuel app, do not change independently */
    --c-protein: var(--wp--preset--color--protein);
    --c-carbs:   var(--wp--preset--color--carbs);
    --c-fat:     var(--wp--preset--color--fat);

    /* Component tokens */
    --radius-card:      12px;
    --radius-section:   16px;
    --section-padding:  clamp(var(--space-xl), 8vw, var(--space-3xl));
    --ph-ratio:          16/9;

    /* Line heights */
    --lh-tight:    1.1;
    --lh-headings: 1.2;
    --lh-body:     1.6;

    /* Motion */
    --easing-smooth:     cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --duration-fast:     150ms;
    --duration-normal:   200ms;
    --duration-slow:     300ms;
    --transition-smooth: all var(--duration-normal) var(--easing-smooth);

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 10px 20px rgba(0, 0, 0, 0.16);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.22);
  }

  /* ----- Light band inversion ---------------------------------------------
     Menus / FAQ / forms that sit on a light surface. --c-text-muted here is
     the one value with no theme.json slot (design-system.md locks it at an
     exact hex, #6B6560, distinct from the dark-band alpha-blend) — defined
     once, only here, so it is not a duplicate of anything in theme.json.
     ---------------------------------------------------------------------- */
  .band-light {
    --c-bg:         var(--wp--preset--color--bg-light);
    --c-surface:    var(--wp--preset--color--surface-alt);
    --c-text:       var(--wp--preset--color--muted);
    --c-text-muted: #6B6560;
    --c-border:     var(--wp--preset--color--border);
    background-color: var(--c-bg);
    color: var(--c-text);
  }

  .band-light .eyebrow { color: var(--c-primary); }

  .band-light .wp-block-button.is-style-outline .wp-block-button__link {
    border-color: var(--c-primary);
    color: var(--c-text);
  }

  .band-light .wp-block-button.is-style-outline .wp-block-button__link:hover {
    background: var(--c-primary);
    color: #FFFFFF;
  }

  /* ----- Base ------------------------------------------------------------ */
  body {
    color: var(--c-text);
    background: var(--c-bg);
    font-family: var(--wp--preset--font-family--body);
    font-size: var(--text-body);
    line-height: var(--lh-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* ----- Header ------------------------------------------------------------
     Astra classic header. Logo image (Media Library #23) already contains
     the full "Results Performance" wordmark, so the auto site-title text
     next to it is a duplicate — it was wrapping into 4 cramped lines.
     Hide it; keep it in the DOM (not display:none on the whole identity
     block) so screen readers still get the site name via itemprop="name".
     ---------------------------------------------------------------------- */
  .ast-site-title-wrap {
    display: none;
  }

  .main-header-bar {
    background: var(--c-bg);
    border-color: var(--c-border);
    padding-top: var(--space-xs);
    padding-bottom: var(--space-xs);
  }

  .ast-sticky-main-header-bar {
    padding-top: calc(var(--space-xs) * 0.5);
    padding-bottom: calc(var(--space-xs) * 0.5);
  }

  .main-navigation .main-header-menu .menu-item > a {
    padding-left: var(--space-s);
    padding-right: var(--space-s);
    font-size: var(--text-body);
    color: var(--c-text);
    transition: var(--transition-smooth);
  }

  .main-navigation .main-header-menu .menu-item > a:hover,
  .main-navigation .main-header-menu .menu-item > a:focus {
    color: var(--c-accent);
  }

  /* ----- BUTTONS — premium hover/active feedback --------------------------- */
  .wp-block-button__link,
  .wp-element-button {
    transition: var(--transition-smooth);
    transform: translateY(0);
    will-change: transform, box-shadow;
    border-radius: var(--radius-card);
    font-weight: 700;
  }

  .wp-block-button__link:hover,
  .wp-element-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }

  .wp-block-button__link:active,
  .wp-element-button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
  }

  .wp-block-button__link:focus-visible,
  .wp-element-button:focus-visible {
    outline: 2px solid var(--c-accent);
    outline-offset: 3px;
  }

  .wp-block-button.is-style-outline .wp-block-button__link {
    border: 1.5px solid var(--c-accent);
    color: var(--c-text);
    background: transparent;
  }

  .wp-block-button.is-style-outline .wp-block-button__link:hover {
    background: var(--c-accent);
    color: var(--c-bg);
  }

  /* ----- CARDS — group/column blocks with .card / .card-highlighted ------- */
  .wp-block-group.card,
  .wp-block-column.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-card);
    padding: var(--space-m);
    transition: var(--transition-smooth);
    will-change: transform, box-shadow, border-color;
  }

  .wp-block-group.card:hover,
  .wp-block-column.card:hover {
    transform: translateY(-4px);
    border-color: var(--c-primary);
    box-shadow: var(--shadow-lg);
  }

  .wp-block-group.card.is-highlighted,
  .wp-block-column.card.is-highlighted,
  .wp-block-group.card-highlighted,
  .wp-block-column.card-highlighted {
    border-width: 2px;
    border-color: var(--c-primary);
  }

  /* ----- IMAGES & COVERS — subtle zoom on hover ---------------------------- */
  .wp-block-cover {
    overflow: hidden;
    border-radius: var(--radius-card);
  }

  .wp-block-cover .wp-block-cover__background,
  .wp-block-cover .wp-block-cover__image-background {
    transition: transform var(--duration-slow) var(--easing-smooth);
  }

  .wp-block-cover:hover .wp-block-cover__background,
  .wp-block-cover:hover .wp-block-cover__image-background {
    transform: scale(1.03);
  }

  /* ----- FAQ ACCORDION — native <details>, zero JS ------------------------- */
  .premium-faq {
    border-bottom: 1px solid var(--c-border);
    padding: var(--space-s) 0;
  }

  .premium-faq summary {
    font-size: var(--text-h4);
    font-weight: 600;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    color: var(--c-text);
    transition: var(--transition-smooth);
  }

  .premium-faq summary:hover {
    color: var(--c-accent);
  }

  .premium-faq summary::-webkit-details-marker {
    display: none;
  }

  .premium-faq summary::after {
    content: '+';
    font-size: 1.5rem;
    font-weight: 300;
    transition: var(--transition-smooth);
  }

  .premium-faq[open] summary::after {
    content: '\2212';
    transform: rotate(180deg);
  }

  .premium-faq p {
    margin-top: var(--space-xs);
    color: var(--c-text-muted);
  }

  /* ----- UTILITY: eyebrow text (small caps label above headings) ----------- */
  .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: var(--text-sm);
    color: var(--c-accent);
    margin-bottom: var(--space-xs);
    display: block;
  }

  /* ----- UTILITY: section vertical rhythm ---------------------------------- */
  .rp-section {
    padding-top: var(--section-padding);
    padding-bottom: var(--section-padding);
  }

  .rp-stat__number {
    font-family: var(--wp--preset--font-family--heading);
    font-weight: 700;
    font-size: var(--text-h2);
    color: var(--c-accent);
    display: block;
    line-height: 1;
    margin-bottom: var(--space-2xs);
  }

  .rp-stat__label {
    font-size: var(--text-sm);
    color: var(--c-text-muted);
    display: block;
  }

  /* ----- RP image placeholder component ------------------------------------
     Dashed-box placeholder used until Anil supplies real photography.
     Per IMAGES.md: grep + replace every instance before ship.
     ---------------------------------------------------------------------- */
  .rp-img-placeholder {
    width: 100%;
    aspect-ratio: var(--ph-ratio, 16/9);
    border: 2px dashed var(--c-border);
    border-radius: var(--radius-card);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--c-surface);
    text-align: center;
    padding: 1.25rem;
    box-sizing: border-box;
  }

  .rp-img-placeholder-row {
    display: grid;
    gap: var(--space-s);
  }

  @media (min-width: 640px) {
    .rp-img-placeholder-row--2 { grid-template-columns: 1fr 1fr; }
    .rp-img-placeholder-row--3 { grid-template-columns: 1fr 1fr 1fr; }
  }

  .rp-img-placeholder__inner { max-width: 320px; }

  .rp-img-placeholder__icon {
    font-size: 1.75rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.5;
  }

  .rp-img-placeholder__dim {
    display: block;
    font-family: var(--wp--preset--font-family--heading);
    font-weight: 700;
    font-size: 1rem;
    color: var(--c-text);
    margin-bottom: 0.35rem;
  }

  .rp-img-placeholder__desc {
    display: block;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--c-text-muted);
  }

  /* ----- RP meal card component --------------------------------------------- */
  .rp-meal-card {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-card);
    overflow: hidden;
    background: var(--c-surface);
  }

  .rp-meal-card img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
  }

  .rp-meal-card__body { padding: var(--space-s); }

  .rp-meal-card__macros {
    font-size: 0.8rem;
    color: var(--c-text-muted);
    margin: 0.35rem 0;
  }

  .rp-meal-grid {
    display: grid;
    gap: var(--space-m);
    grid-template-columns: 1fr;
  }

  @media (min-width: 640px) {
    .rp-meal-grid { grid-template-columns: 1fr 1fr; }
  }

  @media (min-width: 1024px) {
    .rp-meal-grid { grid-template-columns: 1fr 1fr 1fr; }
  }

} /* end @layer child */

/* ==========================================================================
   ACCESSIBILITY: respect user motion preferences (outside layers — always wins)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
    transition-duration: 0.01ms;
    scroll-behavior: auto;
  }
}

/* ============================================================
   RP Home rebuild -- cascade-priority fixes (2026-07-14)
   Astra's Customizer/global dynamic CSS is unlayered and always
   beats any @layer child rule per the CSS cascade spec, no matter
   the declared layer order. These few rules stay unlayered so the
   locked RP tokens (theme.json) actually reach rendered output.
   No new colors introduced -- all values reference existing tokens.
   ============================================================ */
body {
  background-color: var(--wp--preset--color--bg);
  color: var(--wp--preset--color--ink);
}
#masthead.site-header {
  background-color: var(--wp--preset--color--bg-light);
}
.wp-block-button:not(.is-style-outline) .wp-block-button__link,
.wp-block-button__link {
  background-color: var(--wp--preset--color--primary);
  color: var(--wp--preset--color--ink);
}
.wp-block-button__link:hover {
  background-color: var(--wp--preset--color--primary-hover);
}
.page-id-5 .entry-header {
  display: none;
}

/* ============================================================
   RP Home rebuild -- !important escape hatch (2026-07-14)
   Verified via devtools that Astra's own parent-theme stylesheet
   (link#astra-theme-css-css) ships a plain "body{background-color:
   #fff}" rule that, despite loading earlier in the DOM than this
   child stylesheet, was still winning in the rendered page. Normal
   source-order overriding was not resolving it after repeated
   testing, so these few properties use !important as a targeted,
   documented exception -- not a general practice for this file.
   ============================================================ */
body {
  background-color: var(--wp--preset--color--bg) !important;
  color: var(--wp--preset--color--ink) !important;
}
#masthead.site-header {
  background-color: var(--wp--preset--color--bg-light) !important;
}
.wp-block-button:not(.is-style-outline) .wp-block-button__link,
.wp-block-button__link {
  background-color: var(--wp--preset--color--primary) !important;
  color: var(--wp--preset--color--ink) !important;
}
.wp-block-button__link:hover {
  background-color: var(--wp--preset--color--primary-hover) !important;
}

/* ============================================================
   RP Home rebuild -- heading contrast fix (2026-07-14)
   Same root cause as the body/button fixes above: Astra's parent
   theme ships an unlayered default heading color (dark navy,
   rgb(30,41,59) -- meant for light backgrounds) that was beating
   the child theme's heading color on every H1-H6, making all page
   titles and section headings nearly invisible against the dark
   charcoal background. Targeted !important exception, same as above.
   ============================================================ */
h1, h2, h3, h4, h5, h6,
.wp-block-heading {
  color: var(--wp--preset--color--ink) !important;
}

/* ============================================================
   RP Home rebuild -- button border-color fix (2026-07-14)
   Same root cause again: Astra's unlayered default styles set a
   bright blue border-color (rgb(4,107,210)) on button/link elements
   that beat the child theme's border-color on the outline-style
   button variant ("Calculate my macros"). Targeted !important
   exception, consistent with the fixes above.
   ============================================================ */
.wp-block-button__link {
  border-color: var(--wp--preset--color--primary) !important;
}
.wp-block-button__link:hover {
  border-color: var(--wp--preset--color--primary-hover) !important;
}
