/*
 * Cover image (single.tpl.html:15, [image ... background="1" parallax="parallax"]):
 * parallaxer.js sets background-attachment:fixed unconditionally, plus a scroll-driven
 * background-position that's continuously rewritten via inline style every second
 * (setInterval -> trigger('scroll')). background-attachment:fixed is a documented
 * mobile-browser rendering-failure pattern (notably iOS Safari), and the position
 * offset was calibrated assuming fixed attachment -- pinning attachment alone would
 * leave a stale offset that can push the image out of its container. Pin both via
 * !important: that beats parallaxer.js's inline style regardless of how often it
 * re-writes it (a non-!important inline style always loses to an !important rule in
 * an enqueued stylesheet, independent of load order).
 */
@media (max-width: 768px) {
  [data-parallax] {
    background-attachment: scroll !important;
    background-position: center center !important;
    transition: none !important;
  }
}

/*
 * inkube's parallaxer.js sets background-size:cover inline on load, so this
 * needs !important to win. Scoped to .article-img so other parallax photos keep their crop.
 */
@media (max-width: 768px) {
  .article-img .bg-cover {
    background-size: contain !important;
    background-color: #fff;
  }
  .article-img {
    margin-bottom: 1rem;
  }
}

/*
 * mobile-fixes.js sets aspect-ratio + height:auto inline at every width; restore
 * both here or desktop collapses to h-8's min-height. Keep height in sync with h-md-12.
 */
@media (min-width: 768px) {
  .article-img {
    aspect-ratio: auto !important;
    height: 100vh !important;
  }
}

/*
 * Mobile menu: currently a fixed 300px dropdown (main.css:11972-11985). Feature
 * request: full screen when open. Parent .mobile-nav is position:absolute
 * (main.css:11989), so the child needs position:fixed to actually fill the
 * viewport rather than being sized relative to that ancestor.
 */
@media (max-width: 768px) {
  body.menu-expanded .navigation-mobile {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 9999; /* highest existing z-index in main.css is 1070 */
    overflow-y: auto;
  }

  /* Lock background scroll while the full-screen panel is open. */
  body.menu-expanded {
    overflow: hidden !important;
  }

  /* More breathing room per item now that there's a full screen to use --
     base rule is padding: .5rem 1rem (main.css:11877-11879), cramped for a
     300px dropdown but tight for a full-screen tap target. */
  .navigation-mobile .menu-style-su.top-menu > li > a {
    padding-top: 1.25rem !important;
    padding-bottom: 1.25rem !important;
  }
  .navigation-mobile .menu-style-su.top-menu ul.sub-menu > li > a {
    padding-top: 0.9rem !important;
    padding-bottom: 0.9rem !important;
  }
}

/*
 * Nested submenu (Stories > Testimonies etc.): the theme only ever reveals
 * ul.sub-menu via `.menu-style-su li:hover > ul.sub-menu` (main.css:11939) and
 * `.menu-style-su.top-menu ul.sub-menu` is hidden by default via
 * visibility/max-height/opacity (main.css:11920-11923) -- there is no :hover on
 * touch. js/navigation.js was meant to provide a tap fallback but never runs (see
 * tasks/plan2.md). mobile-fixes.js below adds a real tap handler that toggles this
 * class; this rule makes that class actually reveal the submenu, mirroring the
 * existing :hover rule's mechanism instead of fighting it.
 */
@media (max-width: 768px) {
  .navigation-mobile .menu-style-su.top-menu li.menu-item-has-children.mobile-fixes-expanded > ul.sub-menu {
    visibility: visible !important;
    opacity: 1 !important;
    max-height: 2000px !important;
  }

  /* Rotate the existing caret indicator (main.css:11910-11917) to show open state. */
  .navigation-mobile .menu-style-su.top-menu li.menu-item-has-children.mobile-fixes-expanded > a:after {
    transform: rotate(90deg) !important;
  }
}

/*
 * Footer menu on mobile: single-column list by default (main.css's mobile
 * media query sets .menu-style-su > li to width:100% generically, which
 * applies here too since footer-menu shares the .menu-style-su base class).
 * Two columns instead.
 */
@media (max-width: 768px) {
  .menu-style-su.footer-menu {
    display: flex !important;
    flex-wrap: wrap !important;
  }
  .menu-style-su.footer-menu > li {
    width: 50% !important;
    margin-bottom: 1.25rem !important;
  }
}

/*
 * Newsletter page (page-template-news.php -> dynamic_sidebar('newsletter')):
 * NOT fixed with CSS here. Both bugs turned out to be copy-paste typos in
 * widget content, fixed directly at the source instead:
 *  - custom_html 13/15 heading: "col-4 offset-md-4" -> "col-md-4 offset-md-4"
 *    (missing the "md-" prefix on col- specifically -- offset-md-4 already
 *    had it, and an unused sibling widget had the correct version).
 *  - yikes_easy_mc_widget 7/9 form container_class: "col-6 offset-3" ->
 *    "col-12 col-md-6 offset-md-3 mt-4" (no responsive prefix at all, no
 *    mobile-first base -- again matching an unused sibling that had it right).
 * Both are theme classes (main.css has the full col-md-*/offset-md-*
 * responsive grid) applied via the widgets' own settings, not new CSS.
 *
 * Separately: the yikes-mailchimp plugin's own public CSS (field widths,
 * spacing, submit button styling) was never being enqueued anywhere on the
 * front end -- confirmed by checking the page's actual <link> tags. Loaded
 * via mobile-fixes.php instead of writing replacement rules for what that
 * stylesheet already does.
 *
 * One layout the plugin's own CSS doesn't provide, and can't come from a
 * theme class since these fields (label > input, and the submit button) are
 * plugin-generated with no per-field class hook: one row on larger-than-
 * mobile, four items (email/name/last-name/submit) at 25% each. Genuinely
 * needs CSS for that specific arrangement.
 *
 * Scoped to #yikes_easy_mc_widget-7/-9 specifically (the newsletter page's
 * two forms, ar/en), NOT the bare .yikes-easy-mc-form class -- that class is
 * also used by widget-3/widget-5, a *different* pair of Mailchimp forms
 * embedded in the homepage's AR/EN sidebars (custom-sidebar-28/25). The
 * first version of this rule targeted the class globally and broke those
 * too, cramming them into a 4-column row inside a much narrower homepage
 * column they were never meant to have.
 *
 * NOTE (16 Aug): "never meant to have" was wrong -- the homepage forms are
 * in fact the ones the design requirements are about, and they now get the
 * same four-across treatment in their own block at the end of this file.
 * The scoping itself still stands: they are handled by an explicit selector
 * list, not by loosening this one to the bare class.
 *
 * The container itself is widened from col-md-6 to col-md-10 via the
 * widget's own container_class setting (fix-newsletter-classes.php) -- 50%
 * of the page is too narrow to hold 4 fields legibly in one row; that's a
 * theme grid class change, not new CSS, same approach as the typo fixes.
 */
#yikes_easy_mc_widget-7 .yikes-easy-mc-form,
#yikes_easy_mc_widget-9 .yikes-easy-mc-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start; /* without this, flex's default align-items:stretch
    pulls the submit button (naturally short) to the height of the tallest
    label+input, rendering it as an oversized block next to normal fields. */
  gap: 0.5em 1em;
}

@media (min-width: 768px) {
  /* One row, four equal columns. flex:1 1 0 (not width:25%): the plugin's
     own CSS gives the button margin-top:.5em and labels margin-bottom:.5em
     (yikes-inc-easy-mailchimp-extender-public.css), and width:25% x4 plus
     that margin/the gap above sums past 100%, wrapping the 4th item (the
     submit button) onto its own row. flex:1 1 0 divides the remaining space
     evenly after gap instead of claiming a fixed percentage, so it can't
     overflow the row. margin reset removes the vertical spacing that made
     sense when these stacked (mobile) but throws off row alignment here. */
  #yikes_easy_mc_widget-7 .yikes-easy-mc-form > label,
  #yikes_easy_mc_widget-7 .yikes-easy-mc-form > .yikes-easy-mc-submit-button,
  #yikes_easy_mc_widget-9 .yikes-easy-mc-form > label,
  #yikes_easy_mc_widget-9 .yikes-easy-mc-form > .yikes-easy-mc-submit-button {
    flex: 1 1 0;
    min-width: 0;
    margin-top: 0;
    margin-bottom: 0;
  }
}

/* Arabic field order: deliberately no rule here. main.rtl.css:12360 sets
   body{direction:rtl}, which already makes flexbox's default `row` axis run
   right-to-left -- the form is already in RTL order (email first field on
   the right) with zero extra CSS. An earlier version of this file added
   flex-direction:row-reverse for #yikes_easy_mc_widget-7, which flipped the
   row a second time and put it back into LTR-looking order -- the opposite
   of what was asked for. */

/* ==========================================================================
 * Homepage newsletter form (above the footer) -- the element the design
 * requirements are actually about.
 *
 *   #yikes_easy_mc_widget-5  English, custom-sidebar-25, Mailchimp form 2
 *   #yikes_easy_mc_widget-3  Arabic,  custom-sidebar-28, Mailchimp form 1
 *
 * Requirements (user, 16 August):
 *   1. mobile: one field per row, 100% width with side margins, centered
 *   2. above mobile: whole form on one row, each element 25%, small gaps
 *   3. Arabic order right-to-left: email, first name, last name
 *
 * What the plugin does on its own, and why none of the three are met: these
 * fields carry the plugin's `field-third` class, which is FLOAT-based, not
 * flex -- `width: 32%; float: left` at full width, `48%` odd/even between
 * 525px and 955px, `100% !important` below 525px. The submit button is a
 * separate `display: block; width: 100%` element, so it always lands on its
 * own row: three fields across, button underneath. Never four across, and
 * the mobile stack only kicks in at 525px rather than at the theme's 768px
 * breakpoint.
 *
 * So this is a genuine float-to-flex replacement, not a nudge. The float
 * declarations have to be beaten explicitly (`float: none`), and the widths
 * need `!important` because `field-third` sets `width: 100% !important`
 * below 525px -- a plain declaration would lose there.
 *
 * Requirement 1 also needed a non-CSS fix first: widget-5's container was
 * `col-6` (a fixed 50% at every width, the usual missing `-md-` typo), so
 * the form could never be full-width on a phone no matter what these rules
 * say. Corrected to `col-12 col-md-6 offset-md-3 mt-4` -- matching what
 * widget-3 already had -- via tools/fix-homepage-newsletter-classes.php.
 * The side margins in requirement 1 come from that column's own padding.
 * ========================================================================== */

#yikes_easy_mc_widget-3 .yikes-easy-mc-form,
#yikes_easy_mc_widget-5 .yikes-easy-mc-form {
  /* Extra side padding on the form itself, on top of the px-3/px-md-5 already on
     the widget container. Done here rather than with another spacing utility
     because the theme's scale stops at 5 (3rem) and this needs to sit inside
     that, not replace it -- the container padding aligns the block with the
     footer, this insets the fields a bit further within it. */
  padding-left: 2rem;
  padding-right: 2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start; /* otherwise the naturally-short submit button is
    stretched to the height of the tallest field */
  gap: 0.5em 1em;
}

/* Mobile-first base: one item per row, full width. Overrides the plugin's
   float layout outright rather than trying to coexist with it. */
#yikes_easy_mc_widget-3 .yikes-easy-mc-form > label,
#yikes_easy_mc_widget-3 .yikes-easy-mc-form > .yikes-easy-mc-submit-button,
#yikes_easy_mc_widget-5 .yikes-easy-mc-form > label,
#yikes_easy_mc_widget-5 .yikes-easy-mc-form > .yikes-easy-mc-submit-button {
  float: none !important;
  flex: 0 0 100%;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important; /* the plugin's own margin-right: 1.33333% on
    field-third is float gutter -- meaningless here and it throws the gap off */
}

/* Above mobile: one row, four equal columns.
   flex: 1 1 0 rather than width: 25% -- with a 1em gap, four items at a hard
   25% sum past 100% and the submit button wraps to a second row. Dividing the
   space that remains after the gaps is what actually keeps them on one line. */
@media (min-width: 768px) {
  #yikes_easy_mc_widget-3 .yikes-easy-mc-form > label,
  #yikes_easy_mc_widget-3 .yikes-easy-mc-form > .yikes-easy-mc-submit-button,
  #yikes_easy_mc_widget-5 .yikes-easy-mc-form > label,
  #yikes_easy_mc_widget-5 .yikes-easy-mc-form > .yikes-easy-mc-submit-button {
    flex: 1 1 0;
    min-width: 0;
    width: auto !important;
  }
}

/* Requirement 3 (Arabic right-to-left: email, first name, last name) is
   deliberately not implemented with a rule. main.rtl.css:12360 sets
   body{direction:rtl}, and flexbox's default `row` axis already follows the
   inline direction -- so the fields run right-to-left in Arabic for free, in
   exactly the requested order. Adding flex-direction: row-reverse here would
   flip an already-flipped axis and put Arabic back into LTR order; that is
   the precise mistake an earlier version of the /newsletter/ rules made. */

/* ==========================================================================
 * tasks/2B.md item 2 -- carousel_multiple widgets (CarouselMultipleView,
 * inkube/view/CollectionView.class.php:157-189) group items into buckets of
 * 3 server-side (`floor($i/3)`) and wrap each group in a plain `.d-flex`
 * (display:flex, no flex-wrap -- main.css:4295). With no wrap the 3
 * children just flex-shrink to fit one row at any width, so mobile gets 3
 * cramped cards per slide. The grouping-of-3 is PHP, not a class, so it
 * can't be changed from a widget setting; hiding two of the three per slide
 * is the closest same-mechanism fix -- the carousel still advances by
 * groups of 3 underneath, but only the first of each group is visible.
 * ========================================================================== */
@media (max-width: 768px) {
  .carousel_multiple .carousel-item .d-flex.px-5 > * {
    display: none;
  }
  .carousel_multiple .carousel-item .d-flex.px-5 > *:first-child {
    display: block;
  }
}

/* ==========================================================================
 * tasks/2B.md items 3 & 4 -- mobile header.
 *
 * Item 4 (box): the hamburger toggle (`.js-toggle-menu`, site-head.php:3-6)
 * has a hardcoded box: `border: 1px solid #3D7b77; border-radius: .2rem`
 * (main.css:12001-12003). No class controls this, so it's overridden here.
 *
 * Item 4 (vertical align): the logo wrapper carries a `v-center` class
 * (site-head.php:35) that has no matching rule anywhere in main.css or
 * main.rtl.css -- confirmed by grep, it's dead. That's why the logo doesn't
 * line up with the hamburger/search icons on mobile: nothing was ever
 * actually centering it. The class hook already exists on the markup, so
 * this defines it instead of adding a new one.
 *
 * Item 3 (close button): once the mobile menu goes full-screen (task 2's
 * `body.menu-expanded .navigation-mobile` rule above, position:fixed
 * z-index:9999), the toggle button becomes invisible -- it's a sibling that
 * comes before the nav in site-head.php with no z-index of its own, so the
 * now-fixed full-screen panel covers it. The button already knows how to
 * close the menu: main.css:12009-12011 already swaps its icon to an X when
 * `body.menu-expanded`, and its one click handler (site-head.php:26-31)
 * just toggles the same class either way. Rather than add a second close
 * button and a second handler, this lifts that SAME button above the open
 * panel via position:fixed + a higher z-index, and gives the panel's menu
 * list enough top padding to clear it. `.pull-right` is unmirrored in both
 * main.css and main.rtl.css (float:right in both), so the toggle already
 * sits on the physical right in both languages -- `right` here matches
 * that, not `.opposite`.
 * ========================================================================== */
@media (max-width: 768px) {
  .v-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 5rem; /* matches .js-toggle-menu: 3rem box + 1rem margin, main.css:11992-11998 */
  }

  .mobile-nav .js-toggle-menu {
    border: none !important;
    border-radius: 0 !important;
  }

  body.menu-expanded .mobile-nav .js-toggle-menu {
    position: fixed !important;
    top: 1rem !important;
    right: 1rem !important;
    z-index: 10000 !important; /* above .navigation-mobile's 9999 */
  }

  body.menu-expanded .navigation-mobile {
    padding-top: 5rem; /* clears the close button now fixed on top of it */
  }

  /* FontAwesome 4 (main.css:6910) ships one weight per glyph -- no
     light/regular variant to switch to -- so the only lever for a visibly
     thinner X is shrinking it below the 2rem it inherits from
     .js-toggle-menu (main.css:11992-11998). The 3rem tap target is
     untouched since that's the box, not the glyph. */
  .mobile-nav .js-toggle-menu .fa-close {
    font-size: 1.25rem;
  }
}

/* ==========================================================================
 * "Simple" page template (page-template-simple.php -- About Us, Support Us,
 * Privacy Policy, anything built on it) wraps its body as:
 *   <div class="content row format-default"><div class="entry-content">
 * .content.row is a flex container (main.css:699, base .row rule), and
 * .entry-content has no col-* / w-100 class at all -- every OTHER template
 * checked wraps entry-content in a proper col-12 first (e.g. single.tpl.html
 * uses `{{classes}} col-12 ...`). Without one, .entry-content is a flex item
 * with no width, so it sizes to fit its content instead of filling the row.
 * The site has no generated image thumbnails yet (see prep.md/CLAUDE.md --
 * media_details.sizes is empty), so a content image renders near its native
 * pixel width; with entry-content unconstrained, that drags the whole row
 * wider than the viewport on mobile. Giving it width:100% is what col-12
 * would already provide -- entry-content becomes a normal flex item that
 * fills the row, and img-fluid/w-100 images inside it can then actually
 * resolve their percentage widths against something. */
@media (max-width: 768px) {
  /* body_class() renders the template's actual filename-based slug, not a
     shortened one -- confirmed via curl: page-template-page-template-simple-php. */
  .page-template-page-template-simple-php .content.row > .entry-content {
    width: 100%;
  }
}
