/**
 * SBX disclosure — loads only when a disclosure region (the size guide,
 * §22.2, 0.3.0) is rendered (§11).
 * Pre-enhancement: a <details> under the buttons, its summary the same plain
 * ruler link the enhanced state shows (readable, no JS; §14.1).
 * Post-enhancement (.sbx-disclosure--enhanced): a text link that opens a
 * pop-up appended to <body>: centred on desktop, a bottom sheet on a phone
 * (§15). Since 0.3.3 the size guide's link sits on the Size row, right-aligned
 * (.sbx-disclosure-host). Longhands before `inset`, `-webkit-backdrop-filter` before
 * `backdrop-filter`, no flex `gap`, prefix media queries: the product page's
 * Safari 12 floor (review P21).
 */

.sbx-experience.sbx-disclosure {
  margin: 0.75rem 0 0;
}

/* ---- The link (summary before enhancement, button after) ---- */

.sbx-disclosure__summary,
.sbx-disclosure__link {
  display: inline-flex;
  align-items: center;
  background: none;
  border: 0;
  padding: 0.25rem 0;
  font-family: var(--sb-font-primary, inherit);
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--sb-color-ink, inherit);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--sb-color-border, #d4d0ca);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  list-style: none;
}

.sbx-disclosure__summary::-webkit-details-marker {
  display: none;
}

.sbx-disclosure__summary::marker {
  content: '';
}

.sbx-disclosure__summary:hover,
.sbx-disclosure__link:hover {
  text-decoration-color: var(--sb-color-ink, currentcolor);
}

.sbx-disclosure__summary:focus-visible,
.sbx-disclosure__link:focus-visible,
.sbx-disclosure__close:focus-visible {
  outline: 2px solid currentcolor;
  outline-offset: 2px;
}

.sbx-disclosure__icon {
  width: 20px;
  height: 20px;
  flex: none;
  margin-right: 8px;
}

/* ---- On the Size row (0.3.3): the label left, the link right ---- */

.sbx-disclosure-host {
  display: flex;
  align-items: center;
}

.sbx-disclosure-host > .sbx-disclosure__link {
  margin-left: auto;
  padding-left: 16px;
}

/* 0.3.4: the label's own bottom margin made the row 11px taller and set
   the link 6px off the label's centre (gate § 27 finding 1). 0.3.5: `[for]`
   outranks WooCommerce's `.woocommerce-page label`, which loads later and
   won the tie (gate § 28 finding 2). */
.sbx-disclosure-host > label[for] {
  margin-bottom: 0;
}

/* The region's own wrapper is empty once its link has moved. */
.sbx-experience.sbx-disclosure--placed {
  display: none;
}

/* No JS: the open <details> shows the content in the page. */
.sbx-disclosure__details[open] > .sbx-disclosure__body {
  margin-top: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--sb-color-border, #d4d0ca);
  border-radius: var(--sb-radius-lg, 14px);
}

/* ---- The pop-up (appended to <body> by sbx-disclosure.js) ---- */

.sbx-disclosure-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  z-index: 400; /* above SBNav's --sb-z-mobile (300) */
  background: rgb(0 0 0 / 6%);
  -webkit-backdrop-filter: blur(4px) grayscale(1);
  backdrop-filter: blur(4px) grayscale(1);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.sbx-disclosure-backdrop[hidden] {
  display: none;
}

.sbx-disclosure-dialog {
  position: fixed;
  z-index: 401;
  left: 50%;
  top: 50%;
  width: 640px;
  width: min(640px, calc(100% - 48px));
  max-height: calc(100% - 64px);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background: var(--sb-color-surface, #fff);
  color: var(--sb-color-ink, inherit);
  border: 1px solid var(--sb-color-border, #d4d0ca);
  border-radius: var(--sb-radius-lg, 14px);
  box-shadow:
    0 2px 6px rgb(0 0 0 / 10%),
    0 24px 48px -8px rgb(0 0 0 / 28%);
  opacity: 0;
  -webkit-transform: translate(-50%, -46%);
  transform: translate(-50%, -46%);
  transition:
    opacity 0.28s ease,
    -webkit-transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sbx-disclosure-dialog[hidden] {
  display: none;
}

.sbx-disclosure-backdrop.is-open,
.sbx-disclosure-dialog.is-open {
  opacity: 1;
}

.sbx-disclosure-dialog.is-open {
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}

.sbx-disclosure-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px 14px;
  border-bottom: 1px solid var(--sb-color-border, #d4d0ca);
}

.sbx-disclosure-dialog__title {
  margin: 0 16px 0 0;
  font-family: var(--sb-font-primary, inherit);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sbx-disclosure__close {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--sb-color-border, #d4d0ca);
  background: var(--sb-color-surface, #fff);
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.sbx-disclosure__close svg {
  width: 16px;
  height: 16px;
}

.sbx-disclosure-dialog__body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 28px 26px;
}

/* The region's content is a Section like any other; the pop-up is its box. */
.sbx-disclosure-dialog__body .sbx-experience {
  margin: 0;
}

.sbx-disclosure-dialog__body > .sbx-container,
.sbx-disclosure-dialog__body > .sbx-section {
  margin-top: 0;
}

/* The page behind does not scroll while the pop-up is open. */
body.sbx-disclosure-open {
  overflow: hidden;
}

/* ---- Phone: a bottom sheet ---- */

@media (max-width: 640px) {
  .sbx-disclosure-dialog {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    max-height: 86%;
    border-radius: var(--sb-radius-lg, 14px) var(--sb-radius-lg, 14px) 0 0;
    border-bottom: 0;
    box-shadow:
      0 -2px 6px rgb(0 0 0 / 10%),
      0 -24px 48px -8px rgb(0 0 0 / 28%);
    opacity: 1;
    -webkit-transform: translateY(100%);
    transform: translateY(100%);
  }

  .sbx-disclosure-dialog.is-open {
    -webkit-transform: translateY(0);
    transform: translateY(0);
  }

  .sbx-disclosure-dialog::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 4px;
    background: var(--sb-color-border, #d4d0ca);
    margin: 10px auto 0;
  }

  .sbx-disclosure-dialog__head {
    padding: 12px 20px;
  }

  .sbx-disclosure-dialog__body {
    padding: 16px 20px 28px;
  }
}

/* Motion discipline (§15): no transition under reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .sbx-disclosure-backdrop,
  .sbx-disclosure-dialog {
    transition: none;
  }
}
