/*
 * Frame and controls of the platform-owned pages (ADR 0015, ADR 0017): header with
 * the shop's logo, minimal legal footer, fields, choices and buttons. Colors, font and
 * corner radius come from the `--sp-*` variables the layout sets from the shop's
 * branding (src/standard/branding.ts); nothing here names a color of its own.
 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

:root[data-scheme="dark"] {
  color-scheme: dark;
}

:root {
  /* Inner padding of fields and choices: grows with very round corners. */
  --sp-pad: max(14px, calc(var(--sp-radius) * 0.62));
  /* Boxes taller than a field (lists, panels) never turn into pills. */
  --sp-radius-box: min(var(--sp-radius), 14px);
  --sp-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* `hidden` always hides, whatever display a class sets (buttons are inline-flex). */
[hidden] {
  display: none !important;
}

.sp {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--sp-bg);
  color: var(--sp-fg);
  font-family: var(--sp-font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.sp-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  outline: 0;
}

.sp-container {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: 20px;
}

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

.sp-skip {
  position: absolute;
  left: 12px;
  top: -80px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--sp-radius-box);
  background: var(--sp-fg);
  color: var(--sp-bg);
  font-weight: 600;
  text-decoration: none;
}

.sp-skip:focus {
  top: 12px;
}

/* Header */

/* The theme's header color (a light logo on a colored header stays readable). */
.sp-header {
  border-bottom: 1px solid var(--sp-border);
  background: var(--sp-header-bg, var(--sp-bg));
  color: var(--sp-header-fg, var(--sp-fg));
}

.sp-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
}

.sp-header__logo {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  color: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-decoration: none;
}

.sp-header__logo img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(200px, 52vw);
  max-height: 38px;
}

.sp-header__logo span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-header__link {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: inherit;
  font-size: 0.875rem;
  text-decoration: none;
}

.sp-header__link span {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
}

.sp-header__link:hover span {
  text-decoration-color: currentColor;
}

/* Narrow phones: the icon alone, so the logo keeps its room (the text stays for screen readers). */
@media (max-width: 479px) {
  .sp-header__link {
    justify-content: center;
    min-width: 44px;
  }

  .sp-header__link span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* Customer account (issue #850): logo, the Orders and Profile tabs, "Back to shop" and
   the account menu. On a phone the tabs take a row of their own under the logo. */
.sp-header--account .sp-header__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "logo actions"
    "tabs tabs";
  column-gap: 12px;
  min-height: 0;
  padding-top: 6px;
}

.sp-header--account .sp-header__logo {
  grid-area: logo;
  min-height: 44px;
}

.sp-header__actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sp-tabs {
  grid-area: tabs;
  display: flex;
  gap: 24px;
}

.sp-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  opacity: 0.68;
  transition: opacity 0.15s;
}

.sp-tab:hover {
  opacity: 1;
}

.sp-tab[aria-current="page"] {
  opacity: 1;
  font-weight: 600;
}

/* The current tab sits on the header's bottom border. */
.sp-tab[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

/* On the header's own color (a dark header on Pulse): the ring takes its text color. */
.sp-tab:focus-visible,
.sp-menu__toggle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -2px;
  border-radius: 6px;
}

.sp-menu__item:focus-visible {
  outline: 2px solid var(--sp-focus);
  outline-offset: -2px;
}

@media (min-width: 760px) {
  .sp-header--account .sp-header__inner {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "logo tabs actions";
    column-gap: 40px;
    min-height: 68px;
    padding-top: 0;
  }

  .sp-tabs {
    align-self: stretch;
    gap: 28px;
    margin-top: 0;
  }
}

.sp-menu {
  position: relative;
}

.sp-menu__toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 999px;
  color: inherit;
  list-style: none;
  cursor: pointer;
}

.sp-menu__toggle::-webkit-details-marker {
  display: none;
}

.sp-menu__toggle:hover,
.sp-menu[open] .sp-menu__toggle {
  background: color-mix(in srgb, currentColor 8%, transparent);
}

.sp-menu__chevron {
  opacity: 0.7;
  transition: transform 0.15s var(--sp-ease);
}

.sp-menu[open] .sp-menu__chevron {
  transform: rotate(180deg);
}

.sp-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  width: max-content;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 32px));
  padding: 6px;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-box);
  background: var(--sp-bg);
  color: var(--sp-fg);
  box-shadow: 0 12px 32px -12px rgb(0 0 0 / 0.28);
}

.sp-menu__panel form {
  margin: 0;
}

.sp-menu__who {
  display: grid;
  margin: 0 0 6px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--sp-border);
  font-size: 0.875rem;
}

.sp-menu__label {
  color: var(--sp-muted);
  font-size: 0.8125rem;
}

.sp-menu__email {
  overflow-wrap: anywhere;
  font-weight: 500;
}

.sp-menu__item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0 10px;
  border: 0;
  border-radius: calc(var(--sp-radius-box) - 2px);
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.9375rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.sp-menu__item:hover {
  background: color-mix(in srgb, var(--sp-fg) 6%, transparent);
}

/* Footer */

.sp-footer {
  margin-top: 32px;
  padding: 20px 0 8px;
  border-top: 1px solid var(--sp-border);
  color: var(--sp-muted);
  font-size: 0.8125rem;
}

/* The provider's notice is a frame of its own: full width, never clipped or scaled. */
.sp-footer__notice {
  margin: 0 0 14px;
}

.sp-footer__notice:empty {
  display: none;
}

.sp-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sp-footer__links a,
.sp-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  text-underline-offset: 3px;
}

.sp-footer__links a:hover,
.sp-link:hover {
  color: var(--sp-fg);
  text-decoration-color: currentColor;
}

.sp-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
}

/* Fields: the label sits inside the box and moves up once there is a value. */

.sp-fields {
  display: grid;
  gap: 12px;
}

.sp-fields__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.sp-field {
  position: relative;
  min-width: 0;
}

.sp-field input,
.sp-field select {
  display: block;
  width: 100%;
  height: 54px;
  margin: 0;
  padding: 23px var(--sp-pad) 7px;
  border: 1px solid var(--sp-field-border);
  border-radius: var(--sp-radius);
  background: var(--sp-field);
  color: var(--sp-fg);
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  appearance: none;
  -webkit-appearance: none;
  outline: 0;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.sp-field select {
  padding-right: calc(var(--sp-pad) + 22px);
  text-overflow: ellipsis;
  cursor: pointer;
}

.sp-field label {
  position: absolute;
  left: calc(var(--sp-pad) + 1px);
  top: 16px;
  max-width: calc(100% - var(--sp-pad) * 2);
  overflow: hidden;
  color: var(--sp-muted);
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  transform-origin: left top;
  transition: transform 0.15s var(--sp-ease);
}

.sp-field input:focus + label,
.sp-field input:not(:placeholder-shown) + label,
.sp-field input:-webkit-autofill + label,
.sp-field--select label {
  max-width: calc((100% - var(--sp-pad) * 2) / 0.75);
  transform: translateY(-9px) scale(0.75);
}

.sp-field input:hover,
.sp-field select:hover {
  border-color: var(--sp-fg);
}

.sp-field input:focus,
.sp-field select:focus {
  border-color: var(--sp-focus);
  box-shadow: 0 0 0 1px var(--sp-focus);
}

.sp-field input[readonly] {
  color: var(--sp-muted);
}

/* A required field the server found empty. */
.sp-field input[aria-invalid="true"]:not(:focus) {
  border-color: var(--sp-danger);
  box-shadow: 0 0 0 1px var(--sp-danger);
}

.sp-field input:-webkit-autofill {
  -webkit-text-fill-color: var(--sp-fg);
  box-shadow: 0 0 0 100px var(--sp-field) inset;
  caret-color: var(--sp-fg);
}

.sp-field input:-webkit-autofill:focus {
  box-shadow:
    0 0 0 100px var(--sp-field) inset,
    0 0 0 1px var(--sp-focus);
}

.sp-field__chevron {
  position: absolute;
  right: var(--sp-pad);
  top: 21px;
  color: var(--sp-muted);
  pointer-events: none;
}

/* A field and its button on one line. */
.sp-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.sp-inline .sp-button {
  padding-inline: 18px;
}

/* Buttons */

.sp-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  margin: 0;
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: var(--sp-button-radius, var(--sp-radius));
  background: var(--sp-accent);
  color: var(--sp-accent-fg);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    opacity 0.15s,
    background-color 0.15s,
    transform 0.15s var(--sp-ease);
}

.sp-button:hover {
  opacity: 0.88;
}

.sp-button:active {
  transform: scale(0.985);
}

.sp-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.sp-button--quiet {
  border-color: var(--sp-field-border);
  background: transparent;
  color: var(--sp-fg);
  font-weight: 500;
}

.sp-button--quiet:hover {
  border-color: var(--sp-fg);
  background: color-mix(in srgb, var(--sp-fg) 5%, transparent);
  opacity: 1;
}

.sp-header__logo:focus-visible,
.sp-header__link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.sp-button:focus-visible,
.sp-link:focus-visible,
.sp-footer__links a:focus-visible,
.sp-choice:focus-visible {
  outline: 2px solid var(--sp-focus);
  outline-offset: 2px;
}

/* Choices: one bordered list, a row per option, the chosen row outlined. */

.sp-choices {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--sp-field-border);
  border-radius: var(--sp-radius-box);
  background: var(--sp-field);
}

.sp-choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 13px 16px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.sp-choices > * + .sp-choice,
.sp-choices > li + li > .sp-choice {
  border-top: 1px solid var(--sp-border);
}

.sp-choices > :first-child,
.sp-choices > :first-child > .sp-choice {
  border-top-left-radius: calc(var(--sp-radius-box) - 1px);
  border-top-right-radius: calc(var(--sp-radius-box) - 1px);
}

.sp-choices > :last-child,
.sp-choices > :last-child > .sp-choice {
  border-bottom-left-radius: calc(var(--sp-radius-box) - 1px);
  border-bottom-right-radius: calc(var(--sp-radius-box) - 1px);
}

.sp-choice--top {
  align-items: flex-start;
}

.sp-choice:has(input:checked),
.sp-choice.is-selected {
  background: color-mix(in srgb, var(--sp-focus) 7%, var(--sp-field));
  box-shadow: 0 0 0 1px var(--sp-focus);
  z-index: 1;
}

.sp-choice:has(input:focus-visible) {
  outline: 2px solid var(--sp-focus);
  outline-offset: 2px;
  z-index: 2;
}

.sp-choice input,
.sp-choice__mark {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1px solid var(--sp-field-border);
  border-radius: 50%;
  background: var(--sp-field);
  appearance: none;
  -webkit-appearance: none;
  outline: 0;
  cursor: pointer;
  transition:
    border-width 0.12s,
    border-color 0.12s;
}

.sp-choice--top input {
  margin-top: 3px;
}

.sp-choice input[type="radio"]:checked,
.sp-choice.is-selected .sp-choice__mark {
  border: 6px solid var(--sp-focus);
}

.sp-choice input[type="checkbox"] {
  border-radius: 5px;
}

.sp-choice input[type="checkbox"]:checked,
.sp-check input:checked {
  border-color: var(--sp-focus);
  background: var(--sp-focus)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m4.5 9.3 3 3 6-6.4'/%3E%3C/svg%3E")
    center / 16px no-repeat;
}

:root[data-scheme="dark"] .sp-choice input[type="checkbox"]:checked,
:root[data-scheme="dark"] .sp-check input:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m4.5 9.3 3 3 6-6.4'/%3E%3C/svg%3E");
}

/* A lone checkbox and its text, outside a list of choices (the checkout's email sign-up box). */
.sp-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
  cursor: pointer;
}

.sp-check input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  border: 1px solid var(--sp-field-border);
  border-radius: 5px;
  background: var(--sp-field);
  appearance: none;
  -webkit-appearance: none;
  outline: 0;
  cursor: pointer;
  transition: border-color 0.12s;
}

.sp-check input:focus-visible {
  outline: 2px solid var(--sp-focus);
  outline-offset: 2px;
}

.sp-choice__body {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.sp-choice__detail {
  color: var(--sp-muted);
  font-size: 0.875rem;
}

.sp-choice__price {
  display: grid;
  flex: none;
  justify-items: end;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sp-choice__price s {
  color: var(--sp-muted);
  font-size: 0.875rem;
  font-weight: 400;
}

/* Messages */

.sp-message {
  margin: 12px 0 0;
  color: var(--sp-muted);
  font-size: 0.875rem;
}

.sp-message--error {
  color: var(--sp-danger);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
