/* ==========================================================================
   X SHOP — Base: reset, typography, accessibility
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--c-bg);
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  font-weight: var(--fw-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  overflow-x: hidden;
}

h1, h2, h3, h4, p, ul, ol, figure {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

h1, h2, h3, h4 {
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* iOS: поле с шрифтом < 16px вызывает зум при фокусе */
input,
select,
textarea {
  font-size: max(16px, 1em);
}

img,
svg {
  display: block;
  max-width: 100%;
}

::selection {
  background: var(--c-accent-soft);
  color: var(--c-text);
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ---------- Utilities ---------- */

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

.tnum {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--c-text-2);
}

.ellipsis {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ---------- Boot & file:// fallback ---------- */

.boot {
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

.boot__mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--c-surface);
  display: grid;
  place-items: center;
  box-shadow: var(--glow-accent);
  animation: boot-pulse 1.4s var(--ease-in-out) infinite;
}

@keyframes boot-pulse {
  50% { transform: scale(0.94); opacity: 0.7; }
}

.boot-error {
  max-width: 420px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 48px) var(--gutter) 48px;
  color: var(--c-text-2);
}

.boot-error h1 {
  color: var(--c-text);
  font-size: var(--fs-xl);
  margin-bottom: var(--sp-3);
}

.boot-error code {
  display: block;
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: var(--fs-sm);
}

/* ---------- Reduced motion ---------- */

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