/* =====================================================================
   SALERM BG v4 - Reset + база + примитиви
   ===================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
  overflow-x: clip;
}

[hidden] { display: none !important; }

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

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: var(--lh-body);
  color: var(--ink-soft);
  background: var(--surface-alt);
  /* Montserrat има "български" форми (д като g, т като m) - при lang="bg" се включват сами и се четат трудно.
     "locl" 0 ги изключва и в Safari (font-language-override там не работи); RUS остава за останалите. */
  font-feature-settings: "kern", "liga", "locl" 0;
  font-language-override: "RUS";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

img, picture, svg, video { display: block; max-width: 100%; height: auto; }
img { background: var(--surface-alt-2); }

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
ul, ol { list-style: none; }

::selection { background: var(--ink); color: #fff; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ---- Типографски примитиви ------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); letter-spacing: var(--tracking-display); line-height: 1.1; }
h2 { font-size: var(--fs-h2); letter-spacing: var(--tracking-display); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }
p { text-wrap: pretty; }

.u-display {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-display);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-display);
  text-wrap: balance;
}

.u-lead {
  font-size: var(--fs-lead);
  line-height: 1.6;
  color: var(--ink-soft);
  font-weight: 400;
}


.u-serif-italic {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
}

.u-muted { color: var(--ink-muted); }

/* ---- Layout helpers ------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--wide { max-width: var(--container-wide); }
.container--text { max-width: var(--container-text); }

.section { padding-block: var(--section-y); }
.section--tight { padding-block: clamp(2.5rem, 5vw, 4.5rem); }
.section--alt { background: var(--surface-alt-2); }
.section--paper { background: var(--paper); }
.section--ink { background: var(--dark); color: #E9E5DE; }
.section--ink h1, .section--ink h2, .section--ink h3, .section--ink h4 { color: #fff; }

.stack > * + * { margin-top: var(--space-md); }

/* ---- Бутони -------------------------------------------------- */
.btn {
  --btn-bg: var(--ink);
  --btn-fg: #fff;
  --btn-bd: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  min-height: var(--tap);
  padding: 1.05rem 2.6rem;
  font-family: var(--font-label);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-bd);
  transition: background var(--dur) var(--ease),
              color var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              transform 100ms ease-out;
}
.btn:hover { --btn-bg: transparent; --btn-fg: var(--ink); }

.btn--ghost { --btn-bg: transparent; --btn-fg: var(--ink); --btn-bd: var(--ink); }
.btn--ghost:hover { --btn-bg: var(--ink); --btn-fg: #fff; }

.btn--light { --btn-bg: #fff; --btn-fg: var(--ink); --btn-bd: #fff; }
.btn--light:hover { --btn-bg: transparent; --btn-fg: #fff; --btn-bd: #fff; }

.btn--on-ink-ghost { --btn-bg: transparent; --btn-fg: #fff; --btn-bd: rgba(255,255,255,0.5); }
.btn--on-ink-ghost:hover { --btn-bg: #fff; --btn-fg: var(--ink); --btn-bd: #fff; }

.btn--sm { min-height: 40px; padding: 0.75rem 1.6rem; font-size: var(--fs-label); }
.btn--block { display: flex; width: 100%; }

/* текстов линк с шеврон - „Виж повече" / „Прочети повече" */
.link-more {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  font-family: var(--font-label);
  font-weight: 600;
  font-size: var(--fs-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  padding-bottom: 3px;
  border-bottom: 1px solid currentColor;
  align-self: flex-start; /* в карти не се разтяга на цяла ширина */
}
.link-more svg { width: 14px; height: 14px; transition: transform var(--dur) var(--ease); }
.link-more:hover svg { transform: translateX(5px); }

/* ---- Дребни utility ----------------------------------------- */
.tag {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  font-family: var(--font-label);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.tag--sale { background: var(--ink); color: #fff; }
.tag--new { background: var(--ink); color: #fff; }
.tag--soft { background: var(--surface-alt); color: var(--ink-soft); }

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

.divider { height: 1px; background: var(--line); border: 0; }

/* ---- Reveal анимации (управляват се от main.js) ------------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
  animation: reveal-failsafe 0.01s linear 2.5s forwards;
}
[data-reveal].is-visible { opacity: 1; transform: none; animation: none; }
@keyframes reveal-failsafe { to { opacity: 1; transform: none; } }
[data-reveal-delay="1"] { transition-delay: 0.1s; }
[data-reveal-delay="2"] { transition-delay: 0.2s; }
[data-reveal-delay="3"] { transition-delay: 0.3s; }
[data-reveal-delay="4"] { transition-delay: 0.4s; }

/* ---- Реакция при натискане (Apple: отговор веднага, при докосване, не при пускане) ---- */
html { -webkit-tap-highlight-color: transparent; }
a, button, input, select, textarea, label, summary { touch-action: manipulation; } /* без 300 ms чакане за двойно докосване */
.btn:active, .icon-btn:active, .link-more:active, .swatch:active, .filter:active, .cat-tile:active, .post:active, .quick-add:active {
  transform: scale(0.97);
  transition: transform 100ms ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .btn:active, .icon-btn:active, .link-more:active, .swatch:active, .filter:active, .cat-tile:active, .post:active, .quick-add:active { transform: none; opacity: 0.75; }
}

/* ---- Повишен контраст (настройка на телефона/компютъра) ---- */
@media (prefers-contrast: more) {
  :root { --ink-soft: var(--ink); --ink-muted: var(--ink); --line: var(--ink); }
  input, select, textarea { border-color: var(--ink) !important; }
}
