/* ==========================================================================
   Buying guides - the part of the guide CSS that every guide page loads.

   A guide page prints, in this order:
     1. this file
     2. the guide's own CSS (its "Guide CSS" box), or mhs-guide.css when the
        box is empty - in both cases fenced inside #mhs-guide and given
        !important by system/library/guidecontent.php
     3. the guide inside <div class="mhs-guide" id="mhs-guide">, which sits
        outside the page's #content, so the theme's "#content ..." rules
        never reach it

   The guides were written as stand-alone pages that never loaded the
   store's theme. Here they sit inside it, and the theme's rules reach into
   them: p { font-size: 14px !important }, nav { display: none },
   header { display: contents }, a[href^="tel"] { text-decoration: none
   !important }, .wrap and .tagline (names the guides use too), Bootstrap's
   margins and line-heights, and more. Rather than answer each one - a list
   that would have to grow with every theme change - the first rule below
   puts every element inside the guide back to the browser's own default,
   which is exactly what it was on the stand-alone page. The guide's own
   rules (step 2) then apply on top of that, and win: same or higher
   specificity, later in the page, and !important.

   Id strength (#mhs-guide), not a class: a theme !important rule with a
   class or an attribute in it (a[href^="tel"]) outranks a class-strength
   reset. At id strength it would have to name an id inside the guide.
   ========================================================================== */

/* 1. Nothing of the theme inside the guide.
   :where() keeps this at the specificity of the id alone, so any rule of
   the guide's own - "#mhs-guide p", "#mhs-guide *" - outranks it. "all"
   leaves custom properties (--navy etc.) alone, so the guide's variables
   pass. */
#mhs-guide :where(*),
#mhs-guide :where(*)::before,
#mhs-guide :where(*)::after{all:revert !important}

/* The wrapper itself starts from what <body> was on the stand-alone page:
   the browser's 16px and normal line height, not the theme's 14px. The
   guide's own body {...} rule becomes #mhs-guide {...} and overrides these. */
#mhs-guide{all:revert !important;display:block !important;font-size:16px !important;line-height:normal !important}

/* 2. The page's #content, printed above the guide only when it holds
   layout modules or a title. stylesheet.css gives it "min-height: 600px"
   and all.css "width: 96% !important" on phones; neither is wanted for
   that short strip. Two ids outrank the theme's one. */
#information-buying-guide #content{min-height:0 !important;width:auto !important;margin:0 !important}

/* 3. Contents links land BELOW the site's sticky header, not under it. The
   header's height depends on the screen width (measured 2026-11-11):

     992px and wider   the blue bar .main-header is sticky: 165-187px
     769px - 991px     the whole <header> is sticky: 216px
     768px and below   nothing is sticky

   An id and an attribute, so the reset above cannot undo it.
   If the site header is redesigned, re-measure and update these. */
#mhs-guide [id]{scroll-margin-top:16px !important}

@media (min-width:769px){#mhs-guide [id]{scroll-margin-top:232px !important}}

@media (min-width:992px){#mhs-guide [id]{scroll-margin-top:203px !important}}

/* 4. Contents links glide down to their section instead of jumping. Has to
   sit on <html> - the page scrolls, not the guide - and :has() keeps it to
   a page that holds a guide, the same rule category.twig uses on its own
   page. Visitors who have asked their system for less motion still jump. */
@media (prefers-reduced-motion:no-preference){html:has(#mhs-guide){scroll-behavior:smooth}}

/* 5. Printing a guide prints the guide only. Each guide's own print rules
   hide the header, menu, breadcrumb and footer of the stand-alone page it
   was written as (.smhs-topbar, .smhs-nav, .smhs-crumb, .smhs-foot), which
   do not exist here, so the store's header, cart, side menus, breadcrumb,
   popups and footer were printed around it (checked 2026-11-16).
   At every level from <html> down to the guide, everything that is not the
   guide and does not hold it is hidden; nothing inside the guide is
   touched. The second line does the same for browsers without :has(). */
@media print{
  :has(#mhs-guide) > :not(#mhs-guide, :has(#mhs-guide)){display:none !important}
  body.buying_guide > header, body.buying_guide > footer, #information-buying-guide > .container{display:none !important}
}

/* 6. Fewer half-empty printed pages. Each guide's own print rules say
   "section{break-inside:avoid}": a whole section must fit on one page, so a
   long one jumps to the next page and leaves the rest of the page blank
   (Lockers printed 28 pages, many under a quarter full; checked 2026-11-16).
   Here a section may run across pages, while each box inside it - note,
   card, formula, decision row, scale row, table row, FAQ - stays whole, and
   a heading is never left alone at the foot of a page. Two ids, so these
   win over the guide's own rules (one id). Print only; the screen is not
   touched. */
@media print{
  #information-buying-guide #mhs-guide section{break-inside:auto !important}
  #information-buying-guide #mhs-guide :is(.note, .card, .formula, .decide-row, .scale-row, .hier, details, tr){break-inside:avoid !important}
  #information-buying-guide #mhs-guide :is(h2, h3, h4, .sec-num, .sec-sub, caption){break-after:avoid !important}
}

/* 7. No browser header or footer on a printed guide or its PDF - the date
   and page title at the top, the web address and page number at the
   bottom. Chrome and Edge print those in the page margin unless the page
   defines its own margin content; empty margin boxes do that, and the
   12mm margin keeps white space round every page. Firefox and Safari do
   not read margin boxes and still follow their own print setting.
   Checked 2026-11-17 in Chrome 157 with "Headers and footers" switched on:
   none printed, every page keeps its margin. */
@media print{
  @page{
    margin:12mm;
    @top-left{content:""}
    @top-center{content:""}
    @top-right{content:""}
    @bottom-left{content:""}
    @bottom-center{content:""}
    @bottom-right{content:""}
  }
}
