/*
 * base.css — Reset, типографика, утилиты, сетка (MEBELSHOP)
 * Подключать ПОСЛЕ tokens.css
 */

/* ─── Reset ─────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
video,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: var(--transition-color);
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

ul,
ol {
  list-style: none;
}

button {
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  background: none;
  border: none;
}

button:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* ─── Типографика ────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-tight);
  color: var(--color-text);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); font-weight: var(--fw-semibold); }
h6 { font-size: var(--text-sm);   font-weight: var(--fw-semibold); }

@media (min-width: 768px) {
  h1 { font-size: var(--text-4xl); }
  h2 { font-size: var(--text-3xl); }
  h3 { font-size: var(--text-2xl); }
}

@media (min-width: 1024px) {
  h1 { font-size: var(--text-5xl); }
}

p {
  line-height: var(--lh-relaxed);
  max-width: 68ch;
}

p + p {
  margin-top: var(--sp-4);
}

strong, b { font-weight: var(--fw-bold); }
em, i     { font-style: italic; }

small {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.text-xs     { font-size: var(--text-xs); }
.text-sm     { font-size: var(--text-sm); }
.text-base   { font-size: var(--text-base); }
.text-lg     { font-size: var(--text-lg); }
.text-xl     { font-size: var(--text-xl); }
.text-2xl    { font-size: var(--text-2xl); }
.text-3xl    { font-size: var(--text-3xl); }
.text-muted  { color: var(--color-text-muted); }
.text-subtle { color: var(--color-text-subtle); }
.text-primary{ color: var(--color-primary); }
.text-cta    { color: var(--color-cta); }
.fw-medium   { font-weight: var(--fw-medium); }
.fw-semibold { font-weight: var(--fw-semibold); }
.fw-bold     { font-weight: var(--fw-bold); }

/* ─── Контейнеры ─────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-padding);
}

.container-narrow {
  width: 100%;
  max-width: 800px;
  margin-inline: auto;
  padding-inline: var(--container-padding);
}

/* ─── Сетка ──────────────────────────────────────────────────────── */
.grid {
  display: grid;
  gap: var(--sp-4);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* mobile: 1 колонка */
.grid-auto {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: 1fr;
}

@media (min-width: 480px) {
  .grid-auto { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .grid-auto { grid-template-columns: repeat(4, 1fr); }
}

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.gap-8 { gap: var(--sp-8); }

/* ─── Утилиты ────────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--sp-4);
  padding: var(--sp-2) var(--sp-4);
  background: var(--color-primary);
  color: var(--color-primary-text);
  border-radius: var(--r-md);
  font-weight: var(--fw-semibold);
  z-index: var(--z-toast);
  transition: top var(--dur-fast) var(--ease-out);
}
.skip-link:focus {
  top: var(--sp-4);
}

.w-full  { width: 100%; }
.h-full  { height: 100%; }

.rounded    { border-radius: var(--r-md); }
.rounded-lg { border-radius: var(--r-lg); }
.rounded-xl { border-radius: var(--r-xl); }
.rounded-full { border-radius: var(--r-full); }

.shadow    { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hidden { display: none !important; }

@media (min-width: 768px)  { .hidden-md { display: none !important; } }
@media (max-width: 767px)  { .visible-md { display: none !important; } }
@media (min-width: 1024px) { .hidden-lg { display: none !important; } }
@media (max-width: 1023px) { .visible-lg { display: none !important; } }

/* ─── Секции ─────────────────────────────────────────────────────── */
.section {
  padding-block: var(--sp-12);
}

@media (min-width: 768px) {
  .section { padding-block: var(--sp-16); }
}

.section-title {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
  margin-bottom: var(--sp-2);
}

@media (min-width: 768px) {
  .section-title { font-size: var(--text-3xl); }
}

.section-subtitle {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 48ch;
  margin-bottom: var(--sp-8);
}

/* ─── Divider ─────────────────────────────────────────────────────── */
hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin-block: var(--sp-6);
}

/* ─── Selection ──────────────────────────────────────────────────── */
::selection {
  background-color: var(--c-brand-200);
  color: var(--c-brand-900);
}

/* ─── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-surface-alt); }
::-webkit-scrollbar-thumb { background: var(--c-neutral-300); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--c-neutral-400); }
