/* Storefront-only tokens. Never attach these to body, main, or :root: the
   cinematic/header/builder must retain their existing inherited values.
   Native nesting keeps the exclusion boundary explicit for every rule. */
:is(#MainContent > .shopify-section:not(.revroom-cinematic-section):not(:has(.revroom-room-builder)), #CartDrawer, .footer) {
  --rr-ink: 17, 19, 22;
  --rr-paper: 247, 247, 242;
  --rr-red: 184, 15, 26;
  --rr-text: var(--rr-ink);
  --rr-surface: var(--rr-paper);
  --rr-action: var(--rr-ink);
  --rr-action-text: var(--rr-paper);
  --rr-radius: 6px;
  --rr-control: 48px;
  --rr-section-space: 64px;
  --rr-body: 'RevRoom Storefront Body', var(--font-body-family);
  --font-body-weight: 400;
  --font-body-weight-bold: 700;
  --buttons-radius: var(--rr-radius);
  --buttons-radius-outset: var(--rr-radius);
  --inputs-radius: var(--rr-radius);
  --inputs-border-opacity: 0.24;
  --inputs-shadow-opacity: 0;
  --buttons-shadow-opacity: 0;
  --badge-corner-radius: 4px;
  color: rgb(var(--rr-text));
  background: rgb(var(--rr-surface));
  font-family: var(--rr-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0;

  /* Reset both legacy and scheme tokens locally, including nested schemes. */
  &, & :where([class*='color-'], .gradient) {
    --color-background: var(--rr-surface);
    --gradient-background: rgb(var(--rr-surface));
    --color-foreground: var(--rr-text);
    --color-link: var(--rr-text);
    --color-button: var(--rr-action);
    --color-button-text: var(--rr-action-text);
    --color-secondary-button-text: var(--rr-text);
    --color-base-text: var(--rr-text);
    --color-base-background-1: var(--rr-surface);
    --color-base-background-2: var(--rr-surface);
    --color-base-accent-1: var(--rr-red);
    --color-base-accent-2: var(--rr-ink);
    --color-base-outline-button-labels: var(--rr-text);
  }

  /* Only the existing homepage brand band is inverse. Other custom rich-text
     sections (including Contact) are not necessarily dark surfaces. */
  &.footer, &[id$='__rich_text_tMJXNr'] .rich-text.color-custom {
    --rr-text: var(--rr-paper);
    --rr-surface: var(--rr-ink);
    --rr-action: var(--rr-paper);
    --rr-action-text: var(--rr-ink);
  }

  & :where(h1, h2, h3, .h0, .h1, .h2, .h3, .card__heading) {
    color: rgb(var(--rr-text));
    font-family: var(--font-heading-family);
    line-height: 1.25;
    letter-spacing: 0;
  }
  & :where(.collection-hero__title, .main-page-title) { font-size: 32px; }
  & :where(.title, .rich-text__heading, .newsletter h2) { font-size: 28px; }
  & .product__title h1 { font-size: 28px; }
  & :where(.rte, .collection-hero__description, .footer-block__details-content) {
    font-family: var(--rr-body);
    font-weight: 400;
    line-height: 1.65;
    color: rgb(var(--rr-text));
  }
  & :where(.rich-text__text, .newsletter__subheading, .multicolumn-card__info .rte) :where(p, h5) {
    font: 400 16px/1.65 var(--rr-body);
    letter-spacing: 0;
    color: rgb(var(--rr-text));
  }
  & :where(.collection-hero__description, .rich-text__text, .newsletter__subheading) {
    max-width: 68ch;
    font-size: 16px;
  }
  & :where(.form__label, .field__label, .facet-filters__label, .product-count__text) {
    font-family: var(--rr-body);
    font-weight: 400;
    color: rgb(var(--rr-text));
    letter-spacing: 0;
  }
  & .product__accordion .accordion__content { font-size: 16px; line-height: 1.65; }
  & .localization-form__select { min-height: 44px; border-radius: var(--rr-radius); }
  & :where(.price, .card-information, .card__information) { color: rgb(var(--rr-text)); }

  /* Only theme buttons, never accelerated-payment or provider controls. */
  & .button {
    min-height: var(--rr-control);
    padding: 12px 24px;
    border: 1px solid transparent;
    border-radius: var(--rr-radius);
    background: rgb(var(--rr-action));
    color: rgb(var(--rr-action-text));
    font: 700 16px/1.35 var(--rr-body);
    letter-spacing: 0;
    box-shadow: none;
    transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
  }
  & .button::before, & .button::after { box-shadow: none; }
  & .button--secondary, & .button--tertiary {
    background: transparent;
    color: rgb(var(--rr-text));
    border-color: rgba(var(--rr-text), 0.4);
  }
  & .button--tertiary { border-color: transparent; }
  & .button:hover:not(:disabled):not([aria-disabled='true']) {
    background: rgb(var(--rr-red));
    border-color: rgb(var(--rr-red));
    color: rgb(var(--rr-paper));
  }
  & .button:active:not(:disabled):not([aria-disabled='true']) { background: #960d16; }
  & .button:is(:disabled, [aria-disabled='true']) { opacity: 0.5; cursor: not-allowed; }
  & :where(.link, .underlined-link, .mobile-facets__open) { color: rgb(var(--rr-text)); }
  & :where(.link, .underlined-link):hover { color: rgb(var(--rr-red)); }
  & :where(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid rgb(var(--rr-red));
    outline-offset: 3px;
    box-shadow: none;
  }

  & :where(.field__input, .select__select, .customer input, .customer select) {
    min-height: var(--rr-control);
    border: 1px solid rgba(var(--rr-text), 0.28);
    border-radius: var(--rr-radius);
    background: rgb(var(--rr-surface));
    color: rgb(var(--rr-text));
    font-family: var(--rr-body);
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0;
    box-shadow: none;
  }
  & :where(.field, .select)::before, & :where(.field, .select)::after { box-shadow: none; }
  & .text-area { min-height: 144px; }
  & .quantity {
    min-height: var(--rr-control);
    border: 1px solid rgba(var(--rr-text), 0.28);
    border-radius: var(--rr-radius);
    background: rgb(var(--rr-surface));
    color: rgb(var(--rr-text));
  }
  & .quantity::before, & .quantity::after { box-shadow: none; }
  & :where(.quantity__button, .field__button, .newsletter-form__button) { min-width: 44px; min-height: 44px; }
  & :where(.quantity__input, .quantity__button) { color: rgb(var(--rr-text)); }
  & :where(.facets__summary, .mobile-facets__open, .mobile-facets__close-button, .facet-checkbox, .mobile-facets__label) {
    min-height: 44px;
    align-items: center;
    color: rgb(var(--rr-text));
  }
  & .facets__summary { display: flex; }
  & .facet-filters__sort { padding-right: 28px; }
  & input[type='checkbox'] { accent-color: rgb(var(--rr-red)); }
  & .product-form__input input[type='radio'] + label {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-color: rgba(var(--rr-text), 0.3);
    color: rgb(var(--rr-text));
    background: rgb(var(--rr-surface));
    font-family: var(--rr-body);
  }
  & .product-form__input input[type='radio']:checked + label {
    background: rgb(var(--rr-ink)); color: rgb(var(--rr-paper)); border-color: rgb(var(--rr-ink));
  }
  & .product-form__input input[type='radio']:focus-visible + label {
    outline: 2px solid rgb(var(--rr-red)); outline-offset: 3px; box-shadow: none;
  }

  & .product-card-wrapper .card {
    --border-radius: var(--rr-radius);
    border: 1px solid rgba(var(--rr-ink), 0.1);
    border-radius: var(--rr-radius);
    background: #fff;
    box-shadow: none;
    transform: none;
  }
  & .product-card-wrapper .card::after { box-shadow: none; }
  & .product-card-wrapper .card > :where(.card__inner, .card__content) {
    --rr-surface: 255, 255, 255;
    background: #fff;
  }
  & .product-card-wrapper .card__heading { font-size: 16px; font-weight: 600; line-height: 1.4; }
  & .product-card-wrapper .card > .card__content { padding: 16px; gap: 8px; }
  & .product-card-wrapper .quick-add__submit { min-height: var(--rr-control); padding: 12px; }
  & .badge {
    background: rgb(var(--rr-ink)); color: rgb(var(--rr-paper));
    border: 0; border-radius: 4px; font-size: 12px; font-weight: 700; letter-spacing: 0; padding: 6px 8px;
  }
  & :where(.price__badge-sale, .card__badge .badge[class*='accent']) { background: rgb(var(--rr-red)); }

  /* Content rhythm only; no blanket padding on product/media/hero wrappers. */
  & :where(.multicolumn, .rich-text, .newsletter__wrapper, .contact) {
    padding-top: var(--rr-section-space);
    padding-bottom: var(--rr-section-space);
  }
  & .collection-hero__inner { padding-top: 40px; padding-bottom: 32px; }
  & .collection-hero__description { margin-top: 16px; }
  & .collection { padding-bottom: 48px; }
  & .multicolumn-card__info { padding-top: 24px; padding-bottom: 0; }
  & .multicolumn-card__info .rte { margin-top: 12px; }
  & .cart__warnings { padding-top: 48px; padding-bottom: 48px; }
  &.footer { --rr-section-space: 48px; }
  &.footer .footer-block__details-content .list-menu__item--link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  &.footer :where(.link, .copyright__content a):hover {
    color: rgb(var(--rr-paper));
    text-decoration: underline;
    text-decoration-color: rgb(var(--rr-red));
    text-underline-offset: 4px;
  }
  &.footer :focus-visible { outline-color: rgb(var(--rr-paper)); }

  @media (max-width: 749px) {
    --rr-section-space: 40px;
    & :where(.collection-hero__title, .main-page-title, .product__title h1) { font-size: 24px; }
    & :where(.title, .rich-text__heading, .newsletter h2) { font-size: 24px; }
    & .product-card-wrapper .card > .card__content { padding: 12px; }
    & .product-card-wrapper .card__heading { font-size: 15px; }
    & .product-card-wrapper .quick-add__submit { font-size: 14px; padding: 10px 8px; }
    & .collection-hero__inner { padding-top: 24px; padding-bottom: 24px; }
    & .collection { padding-bottom: 32px; }
  }
  @media (prefers-reduced-motion: reduce) {
    & .button { transition: none; }
  }
}
