*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* Sticky Header + admin bar: native hash / scrollIntoView land below chrome. */
  scroll-padding-top: calc(
    var(--sp-drawer-header-h, var(--sp-header-h, 70px)) +
      var(--sp-admin-bar-visible, 0px) + 12px
  );
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  font-family: var(--ital-font-primary);
  color: var(--ital-color-ink);
  background: var(--ital-color-paper);
  line-height: var(--ital-leading-body);
  font-size: var(--ital-text-body);
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
}

.ital-container {
  width: min(
    var(--ital-content-max),
    calc(100% - 2 * var(--ital-content-pad-x, 0px))
  );
  max-width: none;
  margin-inline: auto;
  padding-inline: 0;
  box-sizing: border-box;
}

/* Tablet / mobile gutters — same donor rhythm as Hero inner (Hero untouched). */
@media (max-width: 899.98px) {
  :root {
    --ital-content-pad-x: calc(4 * var(--q2-rem, 1rem));
  }
}

@media (max-width: 699px) {
  :root {
    --ital-content-pad-x: 15px;
  }
}

/*
 * Skip link — clipped / out of flow from first paint (014).
 * Do NOT use padded absolute box (padding ~8px) that can reserve flow
 * if position is overridden by later CSS.
 */
.ital-skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  background: transparent;
  z-index: 10000;
}

.ital-skip-link:focus {
  position: fixed;
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0.5rem 1rem;
  clip: auto;
  overflow: visible;
  background: var(--ital-color-ink);
  color: var(--ital-color-paper);
  outline: 2px solid var(--ital-color-accent);
  z-index: 1000005;
}

.ital-main {
  min-height: 40vh;
}

/*
 * Defeat legacy sticky on semantic section <header> heads.
 * Root cause lived in legacy-main (`header { position: sticky }`); keep a
 * theme-side guard so content intros stay in normal document flow even if
 * legacy CSS is reintroduced. Site chrome (.sp-header) is excluded.
 */
body.italplast-theme header:not(.sp-header):not(.header) {
  position: static;
  top: auto;
  z-index: auto;
}

.ital-hide-desktop {
  /* shown by default; hidden on desktop */
}

@media (min-width: 1024px) {
  .ital-hide-desktop {
    display: none !important;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .ital-hide-tablet {
    display: none !important;
  }
}

@media (max-width: 767px) {
  .ital-hide-mobile {
    display: none !important;
  }
}

.ital-show-mobile {
  display: none;
}

@media (max-width: 767px) {
  .ital-show-mobile {
    display: inline-flex;
  }
}

:focus-visible {
  outline: 2px solid var(--ital-color-accent);
  outline-offset: 2px;
}

/*
 * Scroll lock gutter (ital-scroll-lock.js → --ital-scroll-lock-gap).
 * Fixed / full-bleed chrome is viewport-relative — body padding alone is not enough.
 * Gap is 0 when the scrollbar does not occupy layout width (overlay / mobile).
 */
html.ital-scroll-locked {
  --ital-scroll-lock-gap: 0px;
}

html.ital-scroll-locked .sp-header,
html.ital-scroll-locked .sp-header-chrome,
html.ital-scroll-locked #wpadminbar,
html.ital-scroll-locked .ital-product-grid__sticky.is-stuck,
html.ital-scroll-locked [class*='ital-catalog-hub__sticky'].is-stuck,
html.ital-scroll-locked .ital-tools-cookie,
html.ital-scroll-locked .ital-tools-mobile {
  padding-right: var(--ital-scroll-lock-gap, 0px);
  box-sizing: border-box;
}

/* Right-anchored floating help — keep edge distance when gutter appears. */
html.ital-scroll-locked .ital-tools-desktop,
html.ital-scroll-locked .ital-tools-desktop-widget {
  margin-right: var(--ital-scroll-lock-gap, 0px);
}
