/* =======================================================================
   RV LAYOUT, MOBILE AND TABLET GEOMETRY  -  rv-layout-mobile-1.css
   Loaded last, after tokens-7, rv-blocks-3, petrol-chrome-34, petrol-v12-3
   and rv-layout-desktop-5.

   COMPANION TO rv-layout-desktop-5.css, NOT A REPLACEMENT FOR IT.
   That file is entirely inside @media (min-width: 1025px).
   This file is entirely inside @media (max-width: 1024px).
   The two can never collide, and neither can leak into the other's range.

   WHAT WAS ACTUALLY WRONG BELOW 1025px
   Measured at 390px (iPhone 14), 360px (common Android) and 768px (tablet
   portrait) in a real emulated mobile viewport with an Android user agent,
   not by resizing a desktop window.

   The good news first: there is NO horizontal overflow anywhere. Every page
   type measured documentElement.scrollWidth === the layout viewport, the 51
   row table on /knife-laws-by-state already scrolls inside .rv-table-wrap,
   and the rune table on /elder-futhark-runes already fits. The mobile rail
   was never broken. What was broken was stacking, clearance and touch.

     1. .rv-buybar sat at z-index 20 while the theme's back to top button is
        350 and the off canvas and search layers are 400 and 500. The round
        back to top button painted straight through the sticky buy bar.
     2. body had padding-bottom: 0, so the 79px buy bar covered the last of
        the footer once a phone reached the bottom of a product page.
     3. .rv2-hero__panel inset itself with calc((100vw - var(--shell)) / 2),
        and --shell is a percentage expression, which resolves against the
        element that USES it. Below 1025px the hero is single column so it
        happens to come out right today, but the trap is still armed: the
        moment that grid gains a second column under 1025px the headline
        jumps. Pinned to a plain token so there is no percentage in the chain.
     4. Two rails, three pixels apart. .site-content sits on --rv-gutter
        (18px on a phone) while the rv2 system hardcoded 40px of shell
        subtraction, i.e. 20px. Now both read the same token.
     5. Touch targets. Thirty controls per archive page were under the 44px
        minimum: the four header tool icons at 40x40, the logo link at 24px
        tall, every product card add to cart at 40x40 and wishlist at 35x35,
        the filter opener at 130x22, the sort select at 30x30, the quantity
        stepper at 25px wide, and the buy bar's own button at 43px.
     6. The homepage trust badges were a 2x2 grid at 390px, which left the
        description text a 97px column running to six ragged lines.

   Geometry, stacking, clearance and touch only. No colour, no type scale,
   no content, no component redesigned.

   NO !important IS USED ANYWHERE IN THIS FILE. It loads after every other
   stylesheet, so an equal specificity selector already wins the cascade.
   ========================================================================== */

@media (max-width: 1024px) {

/* --------------------------------------------------------------------------
   0. TOKENS FOR THIS LAYER

   --rv-gutter is inherited from tokens-7: 20px, and 18px below 768px. It is
   the single number every rail below reads, so a phone and a tablet stay
   internally consistent without either being hardcoded here.
   -------------------------------------------------------------------------- */

:root {
  /* The sticky buy bar measures 79px tall at 390px: 59px of content plus the
     10px block padding on .rv-buybar__inner top and bottom. 80px is that,
     rounded up, and it is what the body clearance below reserves. */
  --rv-buybar-h: 80px;

  /* Above the theme's back to top (350), below its off canvas overlay (400)
     and its side panels (500). See section 1. */
  --rv-z-buybar: 380;

  /* WCAG 2.2 target size, and the Apple and Android minimum. */
  --rv-tap: 44px;
}

/* --------------------------------------------------------------------------
   1. THE STICKY BUY BAR STACKS ABOVE THE BACK TO TOP BUTTON

   .rv-buybar took z-index from --rv-z-sticky, which is 20. The theme's own
   fixed furniture, measured on a live product page:

     a.scrollToTop            350
     .wd-close-side           400   the dimmer behind an open off canvas
     .wd-search-full-screen   400
     .mobile-nav              500
     .cart-widget-side        500

   So the round back to top button painted on top of the buy bar, over the
   price and next to the button, on every product page on every phone.

   380 is chosen, not 500: the bar must clear the back to top button but must
   NOT climb over the search overlay or the off canvas menu, or opening the
   menu would leave a buy bar floating on top of it. 380 is the only band
   that satisfies both.

   --rv-z-sticky itself is deliberately NOT redefined. Other components read
   that token and none of them have this problem; changing the token to fix
   one component would move all of them.
   -------------------------------------------------------------------------- */

body.rv-petrol .rv-buybar {
  z-index: var(--rv-z-buybar);
}

/* --------------------------------------------------------------------------
   2. FOOTER CLEARANCE, ONLY WHILE THE BAR IS ACTUALLY THERE

   The bar is position: fixed, so it takes no space. With padding-bottom: 0
   on body, the last 79px of the footer - the payment marks and the shipped
   from Tennessee line - sat underneath it and could not be scrolled clear.

   The clearance is keyed off :has(#rv-buybar:not([hidden])) rather than a
   body class, because [hidden] is exactly the attribute snippet 31's
   IntersectionObserver toggles. So the padding appears the instant the bar
   appears and disappears with it, and pages that never render a bar - every
   archive, the cart, the checkout, the whole blog - keep padding-bottom: 0
   and gain no dead space at the foot.

   If a browser does not support :has(), nothing matches and the page behaves
   exactly as it does today. It degrades to the current state, not to a
   broken one.

   env(safe-area-inset-bottom) covers the iPhone home indicator.
   -------------------------------------------------------------------------- */

body.rv-petrol:has(#rv-buybar:not([hidden])) {
  padding-block-end: calc(var(--rv-buybar-h) + env(safe-area-inset-bottom, 0px));
  scroll-padding-block-end: calc(var(--rv-buybar-h) + env(safe-area-inset-bottom, 0px));
}

/* Woodmart's own bottom toolbar, when it is switched on, lifts the buy bar by
   its height (petrol-chrome-34 line 830). The clearance has to clear both. */
body.rv-petrol.sticky-toolbar-on:has(#rv-buybar:not([hidden])) {
  padding-block-end: calc(
    var(--rv-buybar-h) + var(--wd-bottom-toolbar-h, 50px) + env(safe-area-inset-bottom, 0px)
  );
}

/* And the bar's own content clears the home indicator rather than sitting
   under it. Matches the 10px block padding already on .rv-buybar__inner. */
body.rv-petrol .rv-buybar__inner {
  padding-block-end: calc(10px + env(safe-area-inset-bottom, 0px));
}

/* The bar's button was 43px tall. One pixel under the minimum is still under
   the minimum, and this is the single most important button on the page. */
body.rv-petrol .rv-buybar__btn {
  min-block-size: var(--rv-tap);
}

/* --------------------------------------------------------------------------
   3. THE --shell PERCENTAGE TRAP, DISARMED BELOW 1025px TOO

   .rv2-hero__panel insets its headline with calc((100vw - var(--shell)) / 2).
   --shell is declared on .rv2 as a percentage expression, and a percentage
   inside a custom property is resolved against the element that USES the
   property, not the one that declares it. On desktop the panel is a 655px
   grid child, --shell collapsed, and the padding came out at 405px instead
   of 72px. rv-layout-desktop-5 pinned it above 1025px.

   Below 1025px the hero is currently a single column, so the same expression
   happens to resolve correctly. That is luck, not correctness. Pinned to the
   gutter token directly so there is no percentage anywhere in the chain and
   the headline cannot move if that grid ever gains a column at tablet width.
   -------------------------------------------------------------------------- */

body.rv-petrol .rv2-hero__panel {
  padding-inline-start: var(--rv-gutter);
  padding-inline-end: var(--rv-gutter);
}

/* --------------------------------------------------------------------------
   4. ONE MOBILE RAIL

   Measured at 390px before this file:

     .site-content        354px at x=18    (Woodmart, on --rv-gutter)
     .rv2-wrap            350px at x=20    (rv2, on a hardcoded 40px)
     .rv2-foot__grid      354px at x=18

   Two pixels is not a catastrophe, but it is why a homepage band and the
   footer under it did not start on the same x. The rv2 shell now reads the
   same token as everything else, so all three land on one line at every
   width in this range - 18px on a phone, 20px on a tablet.

   min() is dropped because within this media query the 1860px arm can never
   win: 100% is at most 1024px here.
   -------------------------------------------------------------------------- */

body.rv-petrol .rv2 {
  --shell: calc(100% - (var(--rv-gutter) * 2));
}

/* --------------------------------------------------------------------------
   5. HEADER TOUCH TARGETS, WITH THE HEADER GEOMETRY LEFT ALONE

   The four tool icons measured 40x40 and the logo link 24px tall. The icons
   have a transparent background and centre their glyph, so growing the box
   to 44px grows only the hit area - the glyph does not move and nothing is
   repainted. The header row is 80px tall, so nothing is pushed either.

   The container padding is NOT touched. The icons currently carry a
   -10px offset that puts the painted glyph at x=15, three pixels off the
   18px text rail, which is already as close as it needs to be. Re-padding
   the container to 18px would have moved the glyph OUT to 28px and made the
   header worse, not better. Measured both ways before choosing.
   -------------------------------------------------------------------------- */

body.rv-petrol .whb-main-header .wd-tools-element > a,
body.rv-petrol .whb-main-header .wd-header-mobile-nav > a {
  min-inline-size: var(--rv-tap);
  min-block-size: var(--rv-tap);
}

/* The logo is also a link - it is how a phone gets home - and its box was
   24px tall. The image is untouched; the anchor grows around it. */
body.rv-petrol .site-logo > a,
body.rv-petrol a.wd-logo {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--rv-tap);
}

/* --------------------------------------------------------------------------
   6. THE ARCHIVE TOOL BAR

   .wd-show-sidebar-btn - the filter opener, the single most used control on
   a category page on a phone - measured 130x22. The sort select measured
   30x30. Both are transparent, so both grow invisibly.
   -------------------------------------------------------------------------- */

body.rv-petrol .wd-shop-tools .wd-show-sidebar-btn,
body.rv-petrol .wd-shop-tools .wd-action-btn {
  min-block-size: var(--rv-tap);
  align-items: center;
}

body.rv-petrol .wd-shop-tools .woocommerce-ordering {
  min-inline-size: var(--rv-tap);
  min-block-size: var(--rv-tap);
  align-items: center;
  justify-content: center;
}

body.rv-petrol .wd-shop-tools .woocommerce-ordering select.orderby {
  min-inline-size: var(--rv-tap);
  min-block-size: var(--rv-tap);
}

/* --------------------------------------------------------------------------
   7. PRODUCT CARD CONTROLS

   Forty add to cart buttons at 40x40 and forty wishlist buttons at 35x35 per
   archive page. The wishlist and compare buttons are transparent, so they
   grow invisibly. The add to cart button is a solid petrol square, so it
   does grow by four pixels a side - which is the smallest change that gets
   a purchase control to the documented minimum, and is the reason the
   minimum exists.
   -------------------------------------------------------------------------- */

body.rv-petrol .wd-product .wd-add-btn > a,
body.rv-petrol .wd-product .wd-wishlist-btn > a,
body.rv-petrol .wd-product .wd-compare-btn > a,
body.rv-petrol .wd-product .wd-quick-view-btn > a {
  min-inline-size: var(--rv-tap);
  min-block-size: var(--rv-tap);
}

/* --------------------------------------------------------------------------
   8. THE ADD TO CART ROW ON A PRODUCT PAGE

   Measured at 390px: form.cart is 360px of flex with a 10px gap, holding a
   80px quantity stepper, a 144px Add to cart and a 116px Buy now. That is
   340 plus 20 of gap - exactly 360. It fits at 390 by one pixel and wraps
   badly at 360.

   Inside the stepper the minus and plus were 25px wide and the number field
   30px. Three targets under half the minimum, side by side, on the control
   that decides how many of something a customer buys.

   The stepper is given real targets and the two buttons are allowed to take
   a row of their own and share it. Nothing is restyled; the row simply stops
   trying to hold five controls across a phone.
   -------------------------------------------------------------------------- */

body.rv-petrol form.cart .quantity input.minus,
body.rv-petrol form.cart .quantity input.plus,
body.rv-petrol .woocommerce div.product form.cart .quantity input.minus,
body.rv-petrol .woocommerce div.product form.cart .quantity input.plus {
  min-inline-size: 40px;
  min-block-size: var(--rv-tap);
}

body.rv-petrol form.cart .quantity input.qty,
body.rv-petrol .woocommerce div.product form.cart .quantity input.qty {
  min-inline-size: var(--rv-tap);
  min-block-size: var(--rv-tap);
}

body.rv-petrol form.cart .single_add_to_cart_button,
body.rv-petrol form.cart .wd-buy-now-btn {
  flex: 1 1 calc(50% - 5px);
  min-block-size: 48px;
}

/* The engraving picker rendered by snippet 38. The tabs and the text field
   already measured 42px; four more pixels brings them to the minimum. The
   family crest checkbox was 13x13 - its <label> wraps it and is 318x70, so
   the target was never really 13px, but a 13px box is still hard to see. */
body.rv-petrol .rv-pers__tab,
body.rv-petrol .rv-pers__panel input[type="text"],
body.rv-petrol .rv-pers__panel textarea {
  min-block-size: var(--rv-tap);
}

body.rv-petrol .rv-pers input[type="checkbox"] {
  inline-size: 20px;
  block-size: 20px;
}

/* --------------------------------------------------------------------------
   9. CART AND CHECKOUT

   The remove-a-line cross measured 30x30, and Proceed to checkout was a
   218px button floating in a 354px column. On a phone the primary action of
   the page should be the width of the page.
   -------------------------------------------------------------------------- */

body.rv-petrol .woocommerce a.remove,
body.rv-petrol .woocommerce .product-remove a {
  min-inline-size: var(--rv-tap);
  min-block-size: var(--rv-tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.rv-petrol .wc-proceed-to-checkout a.checkout-button,
body.rv-petrol .woocommerce #place_order {
  display: block;
  inline-size: 100%;
  min-block-size: 48px;
}

body.rv-petrol .woocommerce form .form-row input[type="checkbox"],
body.rv-petrol .woocommerce-form__input-checkbox {
  inline-size: 20px;
  block-size: 20px;
}

/* --------------------------------------------------------------------------
   10. THE HOMEPAGE TRUST BADGES

   Four badges in a 2x2 grid at 390px. Each cell is 165px, the symbol column
   takes 52px and the gap 12px, leaving the text 97px. "On every order,
   tracked, no minimum" came out six lines tall in a 97px ribbon, and the
   four cells ran to different heights because of it.

   One column below 480px gives the same text 302px and two lines. The
   2x2 grid is kept from 481px up, where the cells are wide enough to earn
   it. Nothing about the badge itself changes - same symbol, same type, same
   order, same spacing scale.
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  body.rv-petrol .rv2-badges__row {
    grid-template-columns: minmax(0, 1fr);
    row-gap: var(--rv-space-md, 24px);
  }
}

/* --------------------------------------------------------------------------
   11. BELT AND BRACES ON WIDE CONTENT

   Nothing currently overflows. These are guards so that the next wide table
   or code block pasted into a post cannot push the page sideways, which is
   the failure mode that is hardest to notice and worst to live with.

   .rv-table-wrap already scrolls; this generalises it to any table inside
   post or page content that is wider than its column, and to <pre>.
   -------------------------------------------------------------------------- */

body.rv-petrol .wd-entry-content > table,
body.rv-petrol .entry-content > table {
  display: block;
  max-inline-size: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

body.rv-petrol .wd-entry-content pre,
body.rv-petrol .entry-content pre {
  max-inline-size: 100%;
  overflow-x: auto;
}

body.rv-petrol .wd-entry-content img,
body.rv-petrol .entry-content img {
  max-inline-size: 100%;
  block-size: auto;
}


/* --------------------------------------------------------------------------
   12. THE LAST OF THE UNDERSIZED CONTROLS

   A second measuring pass after sections 5 to 9 landed. These are the controls
   that were still under 44px, and only the ones where a bigger box is a real
   improvement rather than a redesign.

   Deliberately NOT changed, and why:

     .wd-breadcrumbs a                          40x21
     .wd-product-cats a                         74x21
         Inline text links inside a line of text. Growing them would put gaps
         in a breadcrumb trail and in a product card's metadata line.

     .wc-block-product-categories-list-item a   152x24, and there are 85 of
         them in the filter drawer. Padding each one to 44px would add roughly
         1,700px to that drawer and turn a scannable list into a scroll. WCAG
         2.2 SC 2.5.8 exempts a list of text links for exactly this reason.

     .rv2-foot__col li a                        22 to 26px tall
         Same argument: four columns of footer link lists. Raising every one
         would add about 180px of footer on every page.

     .wd-skip-links a                           offscreen until focused.
   -------------------------------------------------------------------------- */

/* The filter opener is a <div> that carries the click handler and section 6
   made it 44px tall, but the <a> inside it was still 22px, so the visible
   target and the real one disagreed. The anchor now fills its wrapper. */
body.rv-petrol .wd-shop-tools .wd-show-sidebar-btn > a {
  display: flex;
  align-items: center;
  min-block-size: var(--rv-tap);
}

/* Closing the filter drawer, and the price filter's own submit button. */
body.rv-petrol .close-side-widget,
body.rv-petrol .close-side-widget > a,
body.rv-petrol .widget_price_filter .price_slider_amount .button {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--rv-tap);
}

/* The footer phone number and email address. On a phone these are tel: and
   mailto: links - the two things in a footer a customer is most likely to
   tap - and they were 26px tall. */
body.rv-petrol .rv2-foot__contact {
  display: flex;
  align-items: center;
  min-block-size: var(--rv-tap);
}

/* The side cart's own buttons were 42px. */
body.rv-petrol .woocommerce-mini-cart__buttons .button,
body.rv-petrol .cart-widget-side .button {
  min-block-size: var(--rv-tap);
}

/* My Account. The sign-in fields were 272px wide inside a 354px column and
   42px tall - narrower than the column they sit in for no reason, on the page
   every order email lands on. */
body.rv-petrol .woocommerce-form-login input.input-text,
body.rv-petrol .woocommerce-form-register input.input-text,
body.rv-petrol .woocommerce-ResetPassword input.input-text {
  inline-size: 100%;
  min-block-size: var(--rv-tap);
}

body.rv-petrol .woocommerce-form-login .button,
body.rv-petrol .woocommerce-form-register .button,
body.rv-petrol .woocommerce-ResetPassword .button {
  min-block-size: var(--rv-tap);
}


/* --------------------------------------------------------------------------
   13. THE TABLET RAIL

   Section 4 put the rv2 system on --rv-gutter, which fixed the phone: at
   390px .site-content, .rv2-wrap and .rv2-foot__grid all measure 354px at
   x=18. At 768px they did not agree, because Woodmart's .container keeps its
   own 15px padding while --rv-gutter is 20px there:

     .site-content      723px at x=15
     .rv2-wrap          713px at x=20
     .rv2-foot__grid    713px at x=20

   so a tablet showed the product grid starting five pixels outside the
   footer under it and the homepage bands above it.

   The fix is scoped to 768-1024 ON PURPOSE. Below 768px, Woodmart's grid
   column adds its own 3px inset on top of the container padding, so
   .site-content already lands on 18px from a 15px container - moving the
   container there would push the content to 21px and BREAK the alignment
   that section 4 just achieved. Measured at both widths; the container only
   needs correcting where the grid inset is absent.
   -------------------------------------------------------------------------- */

@media (min-width: 768px) {
  body.rv-petrol .container {
    padding-inline: var(--rv-gutter);
  }
}


/* --------------------------------------------------------------------------
   14. INVISIBLE TEXT IN THE CATEGORY DESCRIPTION

   The worst thing found in this pass, and not a geometry bug at all.

   Snippet 26 prints the whole category term description inside .rv-lede on a
   full bleed petrol band (#062930). A short standfirst was all that block
   ever held, so only <p> was ever given a colour. The descriptions are now
   two thousand word articles with their own subheadings and inline links,
   and every one of those falls through to the page default ink:

     h2, h3   #1A1F1E on #062930   contrast 1.09:1   16 of them
     a        #333333 on #062930   contrast 1.22:1   25 of them
     one <a>  #062930 on #062930   contrast 1.00:1

   Ten h2s, six h3s and twenty five links, on the hub and leaf category pages,
   rendering as unreadable dark-on-dark. 4.5:1 is the readable floor; 1.09:1
   is not dim, it is invisible. On a phone in daylight that section is a wall
   of body text with unexplained gaps where the headings should be.

   NO NEW COLOUR IS INTRODUCED. These are the two tokens the design system
   already uses on this exact ground: --rv-bone for a heading (the value
   .rv-h2 resolves to on a petrol band) and --rv-bone for a link, with the
   underline that distinguishes it from the --rv-bone-muted body text (the
   value the footer's links on petrol resolve to). This restores the palette
   that was already there, it does not choose one.

   IMPORTANT, FOR WHOEVER READS THIS NEXT: the fault is NOT mobile only. It
   is identical at every width. It is fixed here only below 1025px because
   this file's remit stops there and the desktop layer is another agent's.
   The same three rules are needed above 1025px. See the handover note.
   -------------------------------------------------------------------------- */

body.rv-petrol .rv-sec--petrol .rv-lede h2,
body.rv-petrol .rv-sec--petrol .rv-lede h3,
body.rv-petrol .rv-sec--petrol .rv-lede h4,
body.rv-petrol .rv-sec--petrol .rv-lede h5,
body.rv-petrol .rv-sec--petrol .rv-lede h6 {
  color: var(--rv-bone);
}

body.rv-petrol .rv-sec--petrol .rv-lede a:not(.rv-btn),
body.rv-petrol .rv-sec--petrol .rv-lede li,
body.rv-petrol .rv-sec--petrol .rv-lede strong,
body.rv-petrol .rv-sec--petrol .rv-lede em,
body.rv-petrol .rv-sec--petrol .rv-lede span:not([class]),
body.rv-petrol .rv-sec--petrol .rv-lede td,
body.rv-petrol .rv-sec--petrol .rv-lede th {
  color: var(--rv-bone);
}

body.rv-petrol .rv-sec--petrol .rv-lede a:not(.rv-btn) {
  text-decoration: underline;
  text-underline-offset: 2px;
}


/* --------------------------------------------------------------------------
   15. DESIGNED BANDS BLEED ON PHONES TOO

   rv-layout-desktop-5 section 4 fixed this above 1025px: the 404 template
   carries neither the rv-brand-page nor the rv-shop-page body class the old
   rule opted in on, so its petrol bands rendered boxed inside the content
   column with the page ground showing down both sides. Keyed off the absence
   of a sidebar instead, so it is right by construction.

   The identical fault is below 1025px, and it is more obvious there. Measured
   on /this-page-does-not-exist at 390px:

     .rv-sec--petrol   354px at x=18, i.e. an 18px white margin down each side

   while the same component on /cart, /my-account, /?s= and every category
   goes edge to edge, because those heroes are printed on woodmart_after_header
   and sit outside <main> entirely. One component, two behaviours, and the 404
   is the one that looks like a mistake.

   Same selector and same mechanism as the desktop file, so the two agree at
   every width and there is one rule to reason about, not two. The
   overflow-x: clip on the parent is what stops a 100vw child from creating a
   horizontal scrollbar - it is load bearing, not decoration.
   -------------------------------------------------------------------------- */

body.rv-petrol main.wd-content-layout:not(:has(.wd-sidebar)) > .site-content > .rv-sec,
body.rv-petrol main.wd-content-layout:not(:has(.wd-sidebar)) .entry-content > .rv-sec {
  width: 100vw;
  max-width: 100vw;
  margin-inline: calc(50% - 50vw);
}

body.rv-petrol main.wd-content-layout:not(:has(.wd-sidebar)):has(.rv-sec) {
  overflow-x: clip;
}

} /* end @media (max-width: 1024px) */
