/**
 * NOTICE OF LICENSE
 *
 * This file is proprietary software and is not open source.
 * Your subscription grants you a limited, non-transferable right to use this code
 * solely as part of the Retail Media Manager platform, and only for the duration
 * of your valid subscription.
 *
 * @author     Corebuilt Labs <info@corebuilt.com>
 * @copyright  2026 Corebuilt Labs
 * @license    Limited to use within an active subscription to Retail Media Manager
 */

/*
 * RDEV-335 (stsitebuilder 0.8.5): what Element Flow's widgets need once the theme is off.
 *
 * Loaded only on a page a signed-out visitor opens (StSiteBuilder::isThemeOff()), where none of the active
 * theme's stylesheets and scripts are loaded (StSiteBuilder::applyThemeOff()). The page is drawn by Element Flow;
 * this file gives it the few defaults the theme used to give and Element Flow has no setting for.
 *
 * Every rule sits inside :where(), so it has zero specificity: Site Settings (Theme Style, Background, the global
 * colours and fonts), the page's own Style tab and every widget's settings still win. Values come from Element
 * Flow's globals (--e-global-*), with a neutral fallback where a shop has not set them. Signed-in pages never load
 * this file, so nothing here changes the Advertiser Portal.
 *
 * Sections: 1 base, 2 the theme frame's hidden helpers, 3 notifications, 4 dropdowns, 5 form fields.
 */

/* 1. Base: the page's defaults come from Element Flow's globals, not from the browser. */
:where(*, *::before, *::after) {
  box-sizing: border-box;
}

:where(body) {
  margin: 0;
  font-family: var(--e-global-typography-text-font-family, system-ui), sans-serif;
  font-size: var(--e-global-typography-text-font-size, 1rem);
  font-weight: var(--e-global-typography-text-font-weight, 400);
  line-height: var(--e-global-typography-text-line-height, 1.5);
  color: var(--e-global-color-tertiary, var(--e-global-color-text, #212529));
  background-color: #fff;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Markup that carries the hidden attribute stays hidden even where its own class sets a display (as Bootstrap's
 * reboot did; the sign-in card's account picker relies on it). */
:where([hidden]) {
  display: none !important;
}

:where(p) {
  margin-top: 0;
  margin-bottom: 1rem;
}

/* Headings: the spacing and the size scale Element Flow's widgets were laid out against, relative to the global
 * Text size. Site Settings › Theme Style › Typography and every widget's own Typography override them. */
:where(h1, h2, h3, h4, h5, h6) {
  margin-top: 0;
  margin-bottom: 1rem;
  font-weight: 600;
  line-height: 1.2;
}

:where(h1) { font-size: calc(var(--e-global-typography-text-font-size, 1rem) * 2); }
:where(h2) { font-size: calc(var(--e-global-typography-text-font-size, 1rem) * 1.5); }
:where(h3) { font-size: calc(var(--e-global-typography-text-font-size, 1rem) * 1.25); }
:where(h4) { font-size: calc(var(--e-global-typography-text-font-size, 1rem) * 1.125); }
:where(h5) { font-size: var(--e-global-typography-text-font-size, 1rem); }
:where(h6) { font-size: calc(var(--e-global-typography-text-font-size, 1rem) * 0.875); }

/* Lists carry no bullets and no indent: Element Flow's menus, breadcrumbs and icon lists are lists. */
:where(ul, ol) {
  margin-top: 0;
  margin-bottom: 1rem;
  padding-left: 0;
  list-style: none;
}

:where(ul ul, ul ol, ol ul, ol ol) {
  margin-bottom: 0;
}

:where(img, svg) {
  vertical-align: middle;
}

:where(img, video) {
  max-width: 100%;
}

:where(label) {
  display: inline-block;
}

:where(button, input, optgroup, select, textarea) {
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

:where(button:not(:disabled), [type="button"]:not(:disabled), [type="submit"]:not(:disabled), [role="button"]) {
  cursor: pointer;
}

/* 2. The theme frame's helpers: its layout still prints a skip link, a back-to-top link and a page loader. */
:where(.d-none) {
  display: none !important;
}

:where(.visually-hidden, .visually-hidden-focusable:not(:focus):not(:focus-within)) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

:where(.skip-link:focus, .back-to-top-link:focus) {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 2000;
  padding: 0.5rem 1rem;
  background-color: #fff;
}

/* 3. Notifications the theme's layout prints (#notifications), e.g. after a contact form is sent. */
:where(#notifications .container) {
  max-width: var(--content-width, 1140px);
  margin: 0 auto;
  padding: 0 1rem;
}

:where(.alert) {
  position: relative;
  margin: 1rem 0;
  padding: 1rem 3rem 1rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.375rem;
}

:where(.alert-success) { color: #0f5132; background-color: #d1e7dd; border-color: #badbcc; }
:where(.alert-danger) { color: #842029; background-color: #f8d7da; border-color: #f5c2c7; }
:where(.alert-warning) { color: #664d03; background-color: #fff3cd; border-color: #ffecb5; }
:where(.alert-info) { color: #055160; background-color: #cff4fc; border-color: #b6effb; }

:where(.alert ul) {
  margin-bottom: 0;
}

:where(.alert .btn-close) {
  position: absolute;
  top: 0;
  right: 0;
  padding: 1rem;
  color: inherit;
  background: none;
  border: 0;
  line-height: 1;
}

:where(.alert .btn-close)::before {
  content: "\00d7";
  font-size: 1.25rem;
}

/* 4. Dropdowns (language and currency, account, listing sort): Bootstrap's dropdown, reduced to what Element
 * Flow's widgets use. The widgets' Dropdown menu / Dropdown item settings style it; these are the defaults and
 * the mechanics (hidden until no-theme.js adds .show). */
:where(.dropdown, .dropup, .dropstart, .dropend) {
  position: relative;
}

:where(.dropdown-menu) {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  display: none;
  min-width: 10rem;
  margin: 0.125rem 0 0;
  padding: 0;
  font-size: 1rem;
  color: inherit;
  text-align: left;
  list-style: none;
  background-color: #fff;
  background-clip: padding-box;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  border-radius: 0.375rem;
}

:where(.dropdown-menu.show) {
  display: block;
}

:where(.dropdown-menu-right, .dropdown-menu-end) {
  right: 0;
  left: auto;
}

:where(.dropdown-menu-center) {
  left: 50%;
  transform: translateX(-50%);
}

:where(.dropdown-item) {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  clear: both;
  font-weight: 400;
  color: inherit;
  text-align: inherit;
  text-decoration: none;
  white-space: nowrap;
  background-color: transparent;
  border: 0;
}

:where(.dropdown-item:hover, .dropdown-item:focus) {
  background-color: rgba(0, 0, 0, 0.05);
  background-color: color-mix(in srgb, currentColor 8%, transparent);
}

:where(.dropdown-header) {
  display: block;
  margin-bottom: 0;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  white-space: nowrap;
  opacity: 0.7;
}

:where(.dropdown-divider) {
  height: 0;
  margin: 0.5rem 0;
  overflow: hidden;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
  border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent);
}

/* 5. Form fields Element Flow's widgets print with Bootstrap classes (the product variant select). The widget's
 * Dropdowns style settings (width, height, font, colours, border) override these defaults. */
:where(.form-control, .form-select) {
  display: block;
  width: 100%;
  padding: 0.375rem 1rem;
  font-size: 1rem;
  line-height: 1.5;
  color: inherit;
  background-color: #fff;
  background-clip: padding-box;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  border-radius: 0.25rem;
  -webkit-appearance: none;
  appearance: none;
}

:where(select.form-control, .form-select) {
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 14px 10px;
}

:where(.form-control:disabled, .form-select:disabled) {
  opacity: 0.6;
}
