/*
 * Pneumat design foundation
 *
 * This file is deliberately small and component-neutral.  It gives every
 * page one contract for tokens, focus treatment and motion without replacing
 * page layout rules.  Page styles remain responsible for their own geometry.
 */

:root {
  /* Semantic colours: new components use these instead of literal values. */
  --ds-color-brand: var(--blue, #006fba);
  --ds-color-brand-strong: var(--blue-dark, #0e3342);
  --ds-color-success: var(--green, #35b957);
  --ds-color-surface: var(--surface, #ffffff);
  --ds-color-surface-soft: var(--surface-soft, #edf3f7);
  --ds-color-text: var(--ink, #111827);
  --ds-color-text-muted: var(--muted, #697586);
  --ds-color-border: var(--line, rgba(17, 24, 39, .1));

  /* Spacing, radius and elevation form the component contract. */
  --ds-space-1: 4px;
  --ds-space-2: 8px;
  --ds-space-3: 12px;
  --ds-space-4: 16px;
  --ds-space-5: 20px;
  --ds-space-6: 24px;
  --ds-space-8: 32px;
  --ds-radius-sm: 10px;
  --ds-radius-md: 14px;
  --ds-radius-lg: 18px;
  --ds-shadow-sm: 0 6px 18px rgba(15, 23, 42, .06);
  --ds-shadow-md: 0 12px 28px rgba(15, 23, 42, .10);
  --ds-focus-ring: 0 0 0 3px rgba(0, 111, 186, .24);
  --ds-ease-standard: cubic-bezier(.2, .7, .2, 1);
  --ds-duration-fast: 160ms;

  /* Global layer contract. Keep transient popovers above every page shell. */
  --ds-z-header: 10020;
  --ds-z-utility: 10040;
  --ds-z-popover: 10100;
  --ds-z-modal: 10200;
}

/* Opt-in base for new controls. Existing controls can migrate one by one. */
.ui-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-2);
  min-height: 40px;
  padding: 9px var(--ds-space-4);
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-color-surface);
  color: var(--ds-color-brand-strong);
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--ds-shadow-sm);
  transition: transform var(--ds-duration-fast) var(--ds-ease-standard),
    border-color var(--ds-duration-fast) var(--ds-ease-standard),
    box-shadow var(--ds-duration-fast) var(--ds-ease-standard),
    background-color var(--ds-duration-fast) var(--ds-ease-standard);
}

.ui-button:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--ds-color-brand) 32%, var(--ds-color-border));
  box-shadow: var(--ds-shadow-md);
}

.ui-button--primary {
  border-color: var(--ds-color-brand);
  background: var(--ds-color-brand);
  color: #fff;
}

.ui-button--primary:hover {
  background: var(--ds-color-brand-strong);
}

/* One consistent keyboard focus indication across both migrated and legacy controls. */
:where(a, button, input, select, textarea, summary, [role="button"], [tabindex]):focus-visible {
  outline: 2px solid var(--ds-color-brand);
  outline-offset: 3px;
  box-shadow: var(--ds-focus-ring);
}

/* Popovers are a global top layer. Modal dialogs keep their own higher band. */
:where(.account-popover, .catalog-popover, .working-hours__popover, .working-hours-popover, [data-email-actions-popover]) {
  z-index: var(--ds-z-popover) !important;
}

:where(.auth-modal, .contact-modal, .cart-drawer) {
  z-index: var(--ds-z-modal) !important;
}

/* The superuser strip is global chrome, not page content. It must remain
   visible above sticky headers and their popovers on every template. */
.admin-toolbar {
  z-index: calc(var(--ds-z-modal) + 100) !important;
}

/* One authenticated-session indicator on every template. Avoid the compact
   cached-only hotspot used before the profile script has finished loading. */
.icon-button.is-authenticated,
.auth-cached-auth .icon-button[data-auth-open] {
  background:
    radial-gradient(ellipse 120% 110% at 8% 50%, rgba(53, 185, 87, .16), rgba(53, 185, 87, 0) 72%),
    rgba(255, 255, 255, .82) !important;
}

.icon-button.is-authenticated::before,
.auth-cached-auth .icon-button[data-auth-open]::before {
  inset: 0 !important;
  border-radius: inherit !important;
  background: linear-gradient(90deg, rgba(53, 185, 87, .10), rgba(53, 185, 87, .02)) !important;
  filter: none !important;
}

/* Mobile account status keeps the existing account icon. Authentication is
   communicated only by replacing the guest orange glow with a green glow. */
@media (max-width: 820px) {
  :where(.is-authenticated-user, .auth-cached-auth) .mobile-app-nav .mobile-account-icon-button[data-mobile-action="account"],
  .mobile-app-nav .mobile-account-icon-button.is-authenticated[data-mobile-action="account"] {
    border: 0 !important;
    background: transparent !important;
    color: var(--blue, #0070ba) !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  :where(.is-authenticated-user, .auth-cached-auth) .mobile-app-nav .mobile-account-icon-button[data-mobile-action="account"]::before,
  .mobile-app-nav .mobile-account-icon-button.is-authenticated[data-mobile-action="account"]::before {
    inset: 4px !important;
    border-radius: 11px !important;
    opacity: 1 !important;
    filter: blur(1px) !important;
    background:
      radial-gradient(ellipse 74% 34% at 72% 35%, rgba(53, 185, 87, .30), rgba(53, 185, 87, .16) 42%, rgba(53, 185, 87, 0) 80%),
      radial-gradient(ellipse 48% 22% at 32% 78%, rgba(53, 185, 87, .13), rgba(53, 185, 87, 0) 74%) !important;
  }
}

/* Account pages keep the global chrome in view while their content scrolls. */
body.account-page .site-header {
  position: sticky !important;
  top: var(--admin-toolbar-offset, 0px) !important;
  z-index: var(--ds-z-header) !important;
}

body.account-page .topline__contact-module {
  position: fixed !important;
}

/* The desktop contact rail must remain above sticky page content and drawers. */
@media (min-width: 1101px) {
  body .site-header {
    z-index: var(--ds-z-header) !important;
  }

  body .topline {
    z-index: calc(var(--ds-z-header) + 10) !important;
  }

  body .topline__contact-module,
  body[data-static-layout] .site-header .topline .topline__contact-module {
    top: 181px !important;
    z-index: var(--ds-z-utility) !important;
  }

  @supports (top: anchor(--pneumat-contact-header bottom)) {
    body .site-header {
      anchor-name: --pneumat-contact-header;
    }

    body .topline__contact-module,
    body[data-static-layout] .site-header .topline .topline__contact-module {
      top: calc(anchor(--pneumat-contact-header bottom, calc(165px + var(--admin-toolbar-offset, 0px))) + 16px - var(--admin-toolbar-offset, 0px)) !important;
    }
  }
}

/* Product reviews: compact mobile composition. Keep identity and rating in
   the header while the review body and merchant reply use the full card. */
@media (max-width: 820px) {
  :where(.reviews-panel, .reviews-list, .review-card, .review-interactions, .review-replies) {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
  }

  .reviews-panel {
    gap: 12px;
  }

  .reviews-summary {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    gap: 8px;
    padding: 11px 13px;
    border-radius: var(--ds-radius-md);
  }

  .reviews-summary strong {
    font-size: 14px;
  }

  .reviews-summary .stars {
    font-size: 17px;
    letter-spacing: .015em;
  }

  .reviews-summary > span:last-child {
    font-size: 11px;
    white-space: nowrap;
  }

  .reviews-list {
    gap: 10px;
  }

  .review-card,
  .review-card:has(.review-interactions) {
    width: 100%;
    padding: 13px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto auto;
    align-items: start;
    gap: 4px 10px;
    border-radius: var(--ds-radius-lg);
  }

  .review-card > div:first-child {
    display: contents;
  }

  .review-card > div:first-child > strong {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    min-width: 0;
    color: var(--ds-color-brand-strong);
    font-size: 15px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .review-card > div:first-child > span {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
    max-width: 100%;
    margin: 1px 0 0 !important;
    padding: 2px 7px !important;
    font-size: 9px !important;
    line-height: 1.35;
    white-space: normal;
  }

  .review-card__meta {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: start;
    justify-self: end;
    min-width: 0;
    gap: 6px;
    color: var(--ds-color-text-muted);
    font-size: 10px;
    line-height: 1.25;
    white-space: nowrap;
  }

  .review-card__meta .stars {
    font-size: 15px;
    line-height: 1;
    letter-spacing: 0;
  }

  .review-card__meta time {
    font-size: 9px;
    font-variant-numeric: tabular-nums;
  }

  .review-card > div:first-child > p {
    grid-column: 1 / -1;
    grid-row: 3;
    min-width: 0;
    margin: 9px 0 0;
    color: var(--ds-color-text);
    font-size: 14px;
    line-height: 1.48;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .review-card .review-interactions {
    grid-column: 1 / -1;
    grid-row: 4;
    width: 100%;
    margin-top: 8px;
  }

  .review-replies {
    display: grid;
    gap: 7px;
  }

  .review-card .review-reply {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 9px 10px;
    border-left-width: 2px;
    border-radius: 0 12px 12px 0;
  }

  .review-card .review-reply strong {
    font-size: 11px;
  }

  .review-card .review-reply strong span {
    margin-left: 5px;
    font-size: 9px;
  }

  .review-card .review-reply p {
    margin: 5px 0 0;
    font-size: 12.5px;
    line-height: 1.42;
    overflow-wrap: anywhere;
  }

  .review-reactions {
    gap: 6px;
    margin-top: 8px;
  }

  .review-reactions button {
    min-width: 38px;
    min-height: 36px;
    gap: 5px;
    padding: 6px 9px;
    border-radius: 12px;
  }

  .review-reactions svg {
    width: 16px;
    height: 16px;
  }

  .review-reactions b {
    font-size: 11px;
  }

  .review-reply-form {
    margin-top: 8px;
  }

  .review-reply-form textarea {
    min-height: 74px;
    padding: 10px;
    border-radius: 12px;
    font-size: 14px;
  }

  .review-card .review-interactions-status {
    margin-top: 6px;
    font-size: 11px;
  }
}

@media (max-width: 380px) {
  .review-card__meta {
    display: grid;
    justify-items: end;
    gap: 2px;
  }
}

/* Respect an OS-level request to reduce movement, including the contact rail. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
