/* Storefront polish. Keep the established palette, typography, and button
   language; improve layout, semantics and control sizing without restyling it. */

/* Book legal acknowledgements form a centred editorial footer. */
.store-featured-detail .store-book-attributions {
  justify-items: center;
  margin-inline: auto;
  max-width: min(100%, 54rem);
  text-align: center;
}
.store-featured-detail .store-book-attribution-section {
  max-width: 70ch;
  min-width: 0;
  text-align: center;
}
.store-featured-detail .store-book-attribution-section p {
  margin-inline: auto;
  text-wrap: pretty;
}

/* Apply one body-copy scale to product controls across settings revisions.
   Use the same text proportions as the Test Mode panel. */
.store-admin-product-group {
  --store-setting-label-size: 1rem;
  --store-setting-description-size: 1rem;
  --store-setting-line-height: 1.55;
}
.store-admin-product-group .store-admin-toggle-copy strong {
  font-family: var(--glam-font-family);
  font-size: var(--store-setting-label-size);
  line-height: 1.4;
  white-space: normal;
}
.store-admin-product-group .store-admin-toggle-copy small {
  font-family: var(--glam-font-family);
  font-size: var(--store-setting-description-size);
  line-height: var(--store-setting-line-height);
  white-space: normal;
}

/* Keep all product-setting selection controls at the same dimensions,
   including the narrow-media layouts. */
.store-admin-product-group .store-admin-toggle {
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
}
.store-admin-product-group .store-admin-toggle input[type="checkbox"]:not([name="featured"]) {
  block-size: 20px;
  flex: 0 0 20px;
  inline-size: 20px;
  margin: 0;
  min-block-size: 20px;
  min-inline-size: 20px;
}
.store-admin-product-group .store-admin-toggle-copy {
  flex: 1 1 auto;
  line-height: 1.5;
  min-width: 0;
  overflow-wrap: anywhere;
}
.store-admin-product-group .store-admin-field {
  min-width: 0;
}
.store-admin-product-group .store-admin-field > label:not(.store-admin-toggle) {
  line-height: 1.5;
}
.store-admin-product-media-toggles {
  align-items: stretch;
  grid-auto-rows: minmax(0, auto);
}
.store-admin-product-media-toggles > .store-admin-field > .store-admin-toggle {
  height: 100%;
  min-height: 100px;
}

/* Treat Featured as a true switch, with its share message subordinate to it. */
.store-admin-toggle-featured {
  cursor: pointer;
  position: relative;
}
.store-admin-toggle-featured > input[name="featured"] {
  block-size: 1px;
  inline-size: 1px;
  opacity: 0;
  position: absolute;
}
.store-admin-featured-switch-track {
  background: color-mix(in srgb, var(--glam-color) 15%, var(--glam-background-color));
  border: 1px solid color-mix(in srgb, var(--glam-color) 30%, transparent);
  border-radius: 999px;
  box-sizing: border-box;
  display: block;
  flex: 0 0 48px;
  height: 27px;
  position: relative;
  transition: background-color .22s ease, border-color .22s ease;
  width: 48px;
}
.store-admin-featured-switch-track::after {
  background: var(--glam-color-muted);
  border-radius: 50%;
  content: "";
  height: 19px;
  inset: 3px auto auto 3px;
  position: absolute;
  transition: transform .22s ease, background-color .22s ease;
  width: 19px;
}
.store-admin-toggle-featured input:checked + .store-admin-featured-switch-track {
  background: var(--store-dark-blue);
  border-color: var(--store-dark-blue);
}
.store-admin-toggle-featured input:checked + .store-admin-featured-switch-track::after {
  background: #fff;
  transform: translateX(21px);
}
.store-admin-toggle-featured input:focus-visible + .store-admin-featured-switch-track {
  outline: 2px solid var(--store-dark-blue);
  outline-offset: 3px;
}
.store-admin-product-group-labels > .store-admin-featured-share-panel {
  background: color-mix(in srgb, var(--store-dark-blue) 4%, var(--glam-background-color));
  border: 1px solid color-mix(in srgb, var(--store-dark-blue) 19%, var(--glam-footer-border-color));
  border-radius: 10px;
  box-sizing: border-box;
  display: grid;
  gap: 12px;
  grid-column: 1 / -1;
  min-width: 0;
  padding: clamp(14px, 2vw, 22px);
  width: 100%;
}
.store-admin-product-group-labels > .store-admin-featured-share-panel[hidden] {
  display: none !important;
}
.store-admin-featured-share-panel .store-admin-field textarea {
  box-sizing: border-box;
  max-width: 100%;
  width: 100%;
}

/* Account menu: restore the original clear, vertically stacked icon/text
   rows. Keep the solid theme background so the dark click-away overlay and
   page content cannot show through admin shortcuts. */
#user-menu.store-user-menu.open {
  align-content: start;
  background-color: var(--glam-background-color);
  display: flex;
  flex-flow: column nowrap;
  gap: 0;
  isolation: isolate;
}
#user-menu.store-user-menu.open > li {
  box-sizing: border-box;
  flex: 0 0 auto;
  min-width: 0;
  width: 100%;
}
#user-menu.store-user-menu.open > li:not(.store-user-identity) {
  background-color: var(--glam-background-color);
}
/* Do not make the shortcuts an icon grid again. Use the established
   two-column (icon / right-aligned text) menu-row component. */
#user-menu.store-user-menu.open > li:is(
  [data-user-admin-item], [data-user-quick-admin-item],
  [data-user-product-management-item], [data-user-simulation-item]
) {
  min-height: 50px;
}
#user-menu.store-user-menu.open > li:is(
  [data-user-admin-item], [data-user-quick-admin-item],
  [data-user-product-management-item], [data-user-simulation-item]
) > button {
  align-items: center;
  background-color: var(--glam-background-color);
  border: 0;
  border-radius: 0;
  box-sizing: border-box;
  display: grid;
  gap: var(--store-padding-mid);
  grid-template-columns: 38px minmax(0, 1fr);
  justify-content: stretch;
  margin: 0;
  max-width: none;
  min-height: 50px;
  padding: var(--store-padding-mid) var(--store-padding-high);
  text-align: left;
  width: 100%;
}
#user-menu.store-user-menu.open > li:is(
  [data-user-admin-item], [data-user-quick-admin-item],
  [data-user-product-management-item], [data-user-simulation-item]
) > button > img {
  filter: var(--store-user-menu-img-filter);
  height: 25px;
  justify-self: center;
  margin: 0;
  width: 25px;
}
#user-menu.store-user-menu.open > li:is(
  [data-user-admin-item], [data-user-quick-admin-item],
  [data-user-product-management-item], [data-user-simulation-item]
) > button > div {
  color: var(--glam-color);
  font-family: var(--glam-font-family);
  font-size: 1rem;
  font-weight: 500;
  height: auto;
  justify-self: end;
  letter-spacing: normal;
  line-height: 1.45;
  min-width: 0;
  overflow-wrap: anywhere;
  position: static;
  text-align: right;
  text-transform: none;
  white-space: normal;
  width: auto;
}
#user-menu.store-user-menu.open > li:is(
  [data-user-admin-item], [data-user-quick-admin-item],
  [data-user-product-management-item], [data-user-simulation-item]
) > button:hover,
#user-menu.store-user-menu.open > li:is(
  [data-user-admin-item], [data-user-quick-admin-item],
  [data-user-product-management-item], [data-user-simulation-item]
) > button:focus-visible {
  background-color: color-mix(in srgb, var(--glam-color) 7%, var(--glam-background-color));
  color: var(--glam-color);
}
#user-menu.store-user-menu.open > li:is(
  [data-user-admin-item], [data-user-quick-admin-item],
  [data-user-product-management-item], [data-user-simulation-item]
) > button:focus-visible {
  outline: 2px solid var(--store-dark-blue);
  outline-offset: -2px;
}
/* Menu separators and inversion are defined in the consolidated logical
   group styling below. Don't add dividers on individual action rows here. */

/* Inline HTTPS-link editor: an actual page control, never a browser prompt. */
.store-content-format-toolbar {
  isolation: isolate;
  position: relative;
}
.store-content-format-toolbar .store-content-link-trigger {
  align-items: center;
  display: inline-flex;
  justify-content: center;
}
.store-content-link-trigger svg {
  fill: none;
  height: 19px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 19px;
}
.store-content-format-toolbar .store-content-link-popover {
  background: var(--glam-background-color);
  border: 1px solid color-mix(in srgb, var(--glam-color) 22%, transparent);
  border-radius: 13px;
  box-shadow: 0 14px 38px color-mix(in srgb, black 20%, transparent);
  box-sizing: border-box;
  color: var(--glam-color);
  display: grid;
  gap: 12px;
  inset: calc(100% + 8px) auto auto 0;
  max-width: min(420px, calc(100vw - 36px));
  padding: clamp(15px, 2vw, 20px);
  position: absolute;
  width: max-content;
  z-index: 100;
}
.store-content-link-popover > strong {
  font: 750 1rem/1.4 var(--glam-font-family);
}
.store-content-link-popover > label {
  display: grid;
  font: 600 .92rem/1.5 var(--glam-font-family);
  gap: 5px;
  min-width: 0;
}
.store-content-link-popover input {
  background: var(--glam-background-color);
  border: 1px solid color-mix(in srgb, var(--glam-color) 28%, transparent);
  border-radius: 7px;
  box-sizing: border-box;
  color: var(--glam-color);
  font: 400 1rem/1.45 var(--glam-font-family);
  min-height: 42px;
  min-width: 0;
  padding: 9px 11px;
  width: 100%;
}
.store-content-link-popover input:focus-visible {
  outline: 2px solid var(--store-dark-blue);
  outline-offset: 2px;
}
.store-content-link-error {
  color: #b33a3a;
  font-size: .9rem;
  line-height: 1.4;
  margin: 0;
}
.store-content-link-error[hidden] {
  display: none;
}
.store-content-link-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.store-content-format-toolbar .store-content-link-actions button {
  font-family: var(--glam-font-family);
  font-size: .9rem;
  min-height: 40px;
}
.store-content-format-toolbar .store-content-link-actions .store-content-link-confirm {
  background: var(--store-dark-blue);
  border-color: var(--store-dark-blue);
  color: white;
}
@media (max-width: 640px) {
  .store-user-menu.open > li:is(
    [data-user-admin-item], [data-user-quick-admin-item],
    [data-user-quick-analytics-item], [data-user-product-management-item],
    [data-user-simulation-item]
  ) > button {
    min-height: 52px;
  }
  .store-content-format-toolbar .store-content-link-popover {
    width: min(340px, calc(100vw - 32px));
  }
}
@media (prefers-reduced-motion: reduce) {
  .store-admin-featured-switch-track,
  .store-admin-featured-switch-track::after {
    transition: none;
  }
}


/* The menu's original click-away overlay lived INSIDE its painted surface.
   In an isolated stacking context that tinted the shortcut section and let
   background patterns show through. Keep the overlay as a sibling instead. */
.store-nav-actions > .store-user-menu-backdrop {
  appearance: none;
  background: rgb(0 0 0 / 45%);
  border: 0;
  border-radius: 0;
  cursor: default;
  display: none;
  height: 100dvh;
  inset: 0;
  padding: 0;
  position: fixed;
  width: 100vw;
  z-index: 3;
}
#user-menu.store-user-menu.open + .store-user-menu-backdrop {
  display: block;
}
#user-menu.store-user-menu.open {
  background: var(--glam-background-color);
  background-image: none;
  border: 1px solid var(--glam-footer-border-color);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0;
  max-height: calc(100dvh - var(--store-nav-height) - 18px);
  opacity: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0;
  z-index: 4;
}
#user-menu.store-user-menu.open > li:not(.store-user-identity):not(.off):not([hidden]) {
  background: var(--glam-background-color);
  border: 0;
  box-sizing: border-box;
  display: block;
  flex: 0 0 auto;
  opacity: 1;
  position: relative;
  width: 100%;
}
#user-menu.store-user-menu.open > li:not(.store-user-identity)::before {
  /* Remove inherited per-row separators; only logical group starts draw. */
  content: none !important;
  display: none !important;
}
#user-menu.store-user-menu.open > li:not(.store-user-identity)::after {
  content: none !important;
  display: none !important;
}
#user-menu.store-user-menu.open > li:not(.store-user-identity) > :is(button, a, label) {
  background-color: var(--glam-background-color);
  background-image: none;
  backdrop-filter: none;
  border-radius: 0;
  box-shadow: none;
  box-sizing: border-box;
  min-height: 50px;
  opacity: 1;
  width: 100%;
}
/* A complete, theme-aware foreground/background inversion is applied
   below, including menu toggle labels but excluding the switch controls. */
/* An off-session admin action must stay hidden, even with menu-row resets. */
#user-menu.store-user-menu.open > li:is(.off, [hidden]) {
  display: none !important;
}

/* The company wordmark remains centred and entirely visible. Use a single
   non-cropped 4:1 SVG at every breakpoint rather than scaling the background
   independently of its box. */
.store-nav-brand {
  align-items: center;
}
.store-nav-brand .store-rx-media-logo {
  background-position: center center;
  background-size: contain;
  max-width: 100%;
  min-width: 0;
}
@media (max-width: 560px) {
  .store-nav .store-nav-brand {
    left: 50%;
    max-width: calc(100vw - 160px);
    transform: translate(-50%, -50%);
    width: clamp(92px, 32vw, 170px);
  }
  .store-nav-brand .store-rx-media-logo {
    flex: 0 0 auto;
    height: min(52px, calc(var(--store-nav-height) - 8px));
    width: 100%;
  }
}
@media (max-width: 380px) {
  .store-nav-left .rx-home-button {
    flex-basis: 30px;
    height: 30px;
    margin-inline: 4px;
    width: 30px;
  }
  .store-nav-left .store-title {
    padding-inline-start: 5px;
  }
  .store-nav-left .store-title > :is([data-store-title-link], [data-store-menu-toggle]) {
    font-size: .83rem;
    letter-spacing: .03em;
  }
}


/* Menu groups are semantic attributes on the existing <li> items. Select the
   FIRST VISIBLE member of each group so role-based hidden admin/settings
   rows never leave separators in the middle of a group or at the menu top.
   The identity strip is its own header; library, admin tools, session modes,
   account and appearance are the actual menu groups. */
#user-menu.store-user-menu.open > li[data-user-menu-group="library"]:nth-child(1 of [data-user-menu-group="library"]:not(.off):not([hidden])):not(:nth-child(1 of :not(.off):not([hidden])))::before,
#user-menu.store-user-menu.open > li[data-user-menu-group="admin"]:nth-child(1 of [data-user-menu-group="admin"]:not(.off):not([hidden])):not(:nth-child(1 of :not(.off):not([hidden])))::before,
#user-menu.store-user-menu.open > li[data-user-menu-group="modes"]:nth-child(1 of [data-user-menu-group="modes"]:not(.off):not([hidden])):not(:nth-child(1 of :not(.off):not([hidden])))::before,
#user-menu.store-user-menu.open > li[data-user-menu-group="account"]:nth-child(1 of [data-user-menu-group="account"]:not(.off):not([hidden])):not(:nth-child(1 of :not(.off):not([hidden])))::before,
#user-menu.store-user-menu.open > li[data-user-menu-group="appearance"]:nth-child(1 of [data-user-menu-group="appearance"]:not(.off):not([hidden])):not(:nth-child(1 of :not(.off):not([hidden])))::before {
  background: color-mix(in srgb, var(--glam-color) 18%, transparent);
  content: "" !important;
  display: block !important;
  height: 1px;
  inset: 0 20px auto;
  margin: 0;
  pointer-events: none;
  position: absolute;
  width: auto;
}

/* Slightly softened body text instead of high-contrast black/white at rest.
   Mixed from the current theme tokens rather than a fixed desaturated shade. */
#user-menu.store-user-menu.open {
  --store-user-menu-label-color: color-mix(in srgb, var(--glam-color) 78%, var(--glam-background-color));
}
#user-menu.store-user-menu.open > li[data-user-menu-group]:not(.store-user-identity) > :is(button, a, label) {
  color: var(--store-user-menu-label-color);
}
#user-menu.store-user-menu.open > li[data-user-menu-group]:not(.store-user-identity) > :is(button, a) > div,
#user-menu.store-user-menu.open > li[data-user-menu-group]:not(.store-user-identity) .store-admin-checkout-mode-label,
#user-menu.store-user-menu.open > li[data-user-menu-group]:not(.store-user-identity) .store-theme-cycle-label {
  color: var(--store-user-menu-label-color);
  font-weight: 400;
}

/* Invert ALL menu rows when hovered or keyboard-focused, including the TEXT
   of both switches. Their actual tracks/thumbs must never be inverted. */
#user-menu.store-user-menu.open > li[data-user-menu-group]:not(.store-user-identity) > :is(button, a, label):is(:hover, :focus-visible, :focus-within) {
  background-color: var(--glam-color);
  color: var(--glam-background-color);
}
#user-menu.store-user-menu.open > li[data-user-menu-group]:not(.store-user-identity) > :is(button, a, label):is(:hover, :focus-visible, :focus-within) > div,
#user-menu.store-user-menu.open > li[data-user-menu-group]:not(.store-user-identity) > :is(button, a, label):is(:hover, :focus-visible, :focus-within) .store-admin-checkout-mode-label,
#user-menu.store-user-menu.open > li[data-user-menu-group]:not(.store-user-identity) > :is(button, a, label):is(:hover, :focus-visible, :focus-within) .store-theme-cycle-label,
#user-menu.store-user-menu.open > li[data-user-menu-group]:not(.store-user-identity) > :is(button, a, label):is(:hover, :focus-visible, :focus-within) [data-theme-cycle-label] {
  color: var(--glam-background-color);
}
/* Menu icon inversion tracks the same hover/focus as the row text. */
#user-menu.store-user-menu.open > li[data-user-menu-group] > :is(button, a):is(:hover, :focus-visible) > img {
  filter: var(--store-user-menu-hover-img-filter);
}
#user-menu.store-user-menu.open > li[data-user-menu-group] .store-simulation-menu-button:is(:hover, :focus-visible) .store-simulation-menu-icon {
  filter: var(--store-simulation-menu-icon-hover-filter);
}
/* The whole Theme row also inverts on :focus-within. Its three SVGs must
   follow the same state, otherwise white Dim/Dark icons disappear against the
   light inverted background while the menu remains keyboard/touch-focused. */
#user-menu.store-user-menu.open > li[data-user-menu-group] .store-theme-cycle-button:is(:hover, :focus-visible, :focus-within) .store-theme-cycle-icon {
  filter: var(--store-theme-cycle-icon-hover-filter);
}
/* Never recolour/invert or filter the visual switch, whether off or checked.
   The adjacent label still inherits the row's inverted text colour. */
#user-menu.store-user-menu.open .store-admin-checkout-mode-control:is(:hover, :focus-within) .store-admin-checkout-mode-switch {
  filter: none !important;
}

