/* ============================================================
   ALEX-PC — база: скидання, типографіка, сітка, утиліти
   ============================================================ */

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

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

/* Плавної прокрутки на рівні документа навмисно немає.

   Вона виглядає приємно рівно доти, доки не зустрінеться з focus():
   браузер починає анімовано їхати до поля вводу, а якщо в цей момент
   відкривається модалка й блокується прокрутка — сторінка зупиняється
   посеред дороги й лишається там. Саме так пошук «ронив» сайт униз.
   Там, де плавність справді потрібна, скрипти просять її явно через
   scrollTo({ behavior: 'smooth' }). */

/* Атрибут hidden має ховати елемент завжди.
   Без цього правила будь-який авторський display (flex, grid) перебиває
   браузерний [hidden] { display: none } — і панелі, модалки та лайтбокс
   лишаються на екрані назавжди. */
[hidden] {
	display: none !important;
}

body {
	margin: 0;
	font-family: var(--font-sans);
	font-size: var(--fs-md);
	line-height: var(--lh-normal);
	color: var(--color-text);
	background: var(--color-bg);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	overflow-x: hidden;
}

/* Блокування прокрутки під модалками та off-canvas.

   Одного overflow: hidden мало. На мобільних прокручується не body, а
   html, і коли body раптом перестає бути прокрутним, браузер «скидає»
   позицію — сторінка стрибає вниз або вгору, а після закриття модалки
   лишається не там, де була. Тому body ще й фіксується на місці, а
   скрипт запам'ятовує позицію й повертає її при розблокуванні
   (див. lockScroll/unlockScroll у theme.js). */
body.is-locked {
	position: fixed;
	left: 0;
	right: 0;
	width: 100%;
	overflow: hidden;
}

/* ------------------------------------------------------------
   Захист від горизонтального виїзду

   У body стоїть overflow-x: hidden. Він не лікує причину, а ховає
   наслідок: усе, що ширше за екран, просто обрізається — і без
   можливості прокрутити. Покупець бачив таблицю доставки, у якої зрізані
   обидва краї, і нічого не міг із цим зробити.

   Нижче — правила, які не дають вмісту стати ширшим за екран у принципі.
   ------------------------------------------------------------ */

img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
	max-width: 100%;
}

img,
video {
	height: auto;
}

/* Артикул на кшталт HOCO-C164A-PD30W-QC30-USBA-USBC-BLACK для браузера —
   одне довге слово. Переносити його нема де, тож він розпирав картку
   товару, а разом із нею і всю сторінку. */
body {
	overflow-wrap: break-word;
}

/* Елемент сітки чи флексу за замовчуванням не вужчий за свій вміст: одне
   довге слово чи широка таблиця всередині — і колонка розсовує сторінку,
   скільки б ширини їй не призначили. min-width: 0 знімає цю заборону. */
.container > *,
.site-main,
.entry-content,
.page-content {
	min-width: 0;
}

h1, h2, h3, h4, h5, h6 {
	margin: 0 0 var(--sp-4);
	font-weight: var(--fw-semibold);
	line-height: var(--lh-tight);
	color: var(--color-text);
	letter-spacing: -0.01em;
}

h1 { font-size: clamp(1.75rem, 3.5vw, var(--fs-4xl)); }
h2 { font-size: clamp(1.375rem, 2.6vw, var(--fs-3xl)); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5, h6 { font-size: var(--fs-md); }

p {
	margin: 0 0 var(--sp-4);
}

a {
	color: var(--color-accent);
	text-decoration: none;
	transition: color var(--t-fast) var(--ease);
}

a:hover {
	color: var(--color-accent-hover);
}

img,
picture,
video,
svg {
	max-width: 100%;
	height: auto;
	display: block;
}

ul, ol {
	margin: 0 0 var(--sp-4);
	padding-left: var(--sp-5);
}

/* Списки-навігації без маркерів. */
nav ul,
.list-reset {
	list-style: none;
	margin: 0;
	padding: 0;
}

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

button {
	cursor: pointer;
	background: none;
	border: 0;
	padding: 0;
}

table {
	width: 100%;
	border-collapse: collapse;
}

hr {
	border: 0;
	border-top: 1px solid var(--color-border);
	margin: var(--sp-8) 0;
}

code, pre {
	font-family: var(--font-mono);
	font-size: 0.9em;
}

/* --- Фокус: видимий, але лише з клавіатури --- */

:focus {
	outline: none;
}

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

/* --- Контейнери та сітка --- */

.container {
	width: 100%;
	max-width: var(--container);
	margin-inline: auto;
	padding-inline: var(--gutter);
}

.container--wide {
	max-width: var(--container-wide);
}

.container--narrow {
	max-width: 780px;
}

.section {
	padding-block: var(--sp-10);
}

.section--tight {
	padding-block: var(--sp-6);
}

.section--soft {
	background: var(--color-bg-soft);
}

.section__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--sp-4);
	margin-bottom: var(--sp-6);
	flex-wrap: wrap;
}

.section__title {
	margin: 0;
	font-size: clamp(1.25rem, 2.4vw, var(--fs-2xl));
}

.section__link {
	font-size: var(--fs-base);
	font-weight: var(--fw-medium);
	white-space: nowrap;
	display: inline-flex;
	align-items: center;
	gap: var(--sp-1);
}

.section__link::after {
	content: '→';
	transition: transform var(--t-fast) var(--ease);
}

.section__link:hover::after {
	transform: translateX(3px);
}

.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); }
.grid--5 { grid-template-columns: repeat(5, 1fr); }
.grid--6 { grid-template-columns: repeat(6, 1fr); }

@media (max-width: 1100px) {
	.grid--5, .grid--6 { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 900px) {
	.grid--4, .grid--5, .grid--6 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 680px) {
	.grid--3, .grid--4, .grid--5, .grid--6 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 420px) {
	.grid--2, .grid--3, .grid--4, .grid--5, .grid--6 { grid-template-columns: 1fr; }
}

/* --- Утиліти --- */

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

.screen-reader-text:focus {
	position: fixed !important;
	top: 8px;
	left: 8px;
	width: auto;
	height: auto;
	clip: auto;
	padding: var(--sp-3) var(--sp-4);
	background: var(--color-bg);
	box-shadow: var(--shadow-lg);
	border-radius: var(--r-md);
	z-index: var(--z-toast);
}

.text-muted { color: var(--color-text-soft); }
.text-small { font-size: var(--fs-sm); }
.text-center { text-align: center; }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }

.hide { display: none !important; }

@media (max-width: 767px) {
	.hide-mobile { display: none !important; }
}

@media (min-width: 768px) {
	.hide-desktop { display: none !important; }
}

.stack > * + * { margin-top: var(--sp-4); }

.truncate {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Обрізання тексту до N рядків — назви товарів у картках. */
.clamp-2,
.clamp-3 {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }

/* --- Хлібні крихти --- */

.breadcrumbs {
	padding-block: var(--sp-3);
	font-size: var(--fs-sm);
	color: var(--color-text-soft);
}

.breadcrumbs__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--sp-2);
	list-style: none;
	margin: 0;
	padding: 0;
}

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

.breadcrumbs a {
	color: var(--color-text-soft);
}

.breadcrumbs a:hover {
	color: var(--color-accent);
}

.breadcrumbs__current {
	color: var(--color-text);
}

/* Довгі крихти на мобільному прокручуються, а не переносяться. */
@media (max-width: 680px) {
	.breadcrumbs__list {
		flex-wrap: nowrap;
		overflow-x: auto;
		scrollbar-width: none;
	}

	.breadcrumbs__list::-webkit-scrollbar {
		display: none;
	}

	.breadcrumbs__item {
		white-space: nowrap;
	}
}
