/* ==========================================================================
   KUBIQX — публічна частина сайту
   Шаблон «modern-dark». Mobile-first, без збирання: правте цей файл напряму,
   потім опублікуйте: php bin/console.php theme:publish (або кнопка в адмінці).

   Шрифти й колірні схеми — у public/assets/css/tokens.css.
   Текст статей, блоки коду й блок прошивки — у public/assets/css/content.css
   (спільні для всіх шаблонів; тут їх можна перевизначити).

   1. Основа        3. Головна           5. Запис
   2. Шапка         4. Картки й списки   8. Службове, друк, рух
   ========================================================================== */

/* 1. Основа ------------------------------------------------------------------ */

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 7rem; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 400 1.0625rem/1.6 var(--font);
}

main { flex: 1; }
main:focus { outline: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.2; text-wrap: balance; }
h1 { font-size: clamp(1.875rem, 1.3rem + 2.4vw, 2.75rem); letter-spacing: -0.015em; }
h2 { font-size: 1.375rem; }
p { margin: 0 0 1rem; }

a { color: var(--accent-strong); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--text); }

img, video, svg { max-width: 100%; height: auto; }
code, pre, .hash { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { width: min(100% - 2rem, 72rem); margin-inline: auto; }
.block { padding-block: 2rem; }
.block > h2, .block__head { margin-bottom: 1.25rem; }
.block__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1.5rem; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: -999rem; top: 0; z-index: 20; padding: 0.5rem 1rem; background: var(--accent); color: var(--on-accent); }
.skip-link:focus { left: 0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 2.75rem; padding: 0.5rem 1.125rem;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--raised); color: var(--text);
    font: 500 1rem/1.2 var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }

input[type="search"], select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--bg); color: var(--text); font: inherit;
}
input[type="search"]:hover, select:hover { border-color: var(--muted); }
input::placeholder { color: var(--muted); opacity: 0.8; }

.empty { padding: 1.5rem 0; color: var(--muted); max-width: 60ch; }
.count { color: var(--muted); }

/* 2. Шапка й підвал ---------------------------------------------------------- */

.site-header { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); }
.site-header__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; padding-block: 0.625rem; }

.brand { display: flex; align-items: center; gap: 0.625rem; color: var(--text); text-decoration: none; }
.brand__name { font-weight: 600; letter-spacing: 0.14em; }
.logo-mark { width: 2.125rem; flex: none; color: var(--text); }

.menu-toggle { min-height: 2.5rem; padding: 0.25rem 0.875rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--raised); color: var(--text); font: 500 0.9375rem var(--font); cursor: pointer; }

.site-nav { display: none; flex-basis: 100%; padding-bottom: 0.75rem; }
.site-nav.is-open { display: block; }
.site-nav__list { display: grid; margin: 0 0 1rem; padding: 0; list-style: none; }
.site-nav__list a { display: block; padding: 0.625rem 0; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.site-nav__list a[aria-current="page"] { color: var(--accent-strong); }
.site-nav__flash { color: var(--accent-strong) !important; }

.site-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.site-search { flex: 1 1 12rem; }
.site-search input { width: 100%; }
.lang-switch { display: flex; gap: 0.25rem; margin: 0; padding: 0; list-style: none; }
.lang-switch a { display: block; padding: 0.375rem 0.5rem; border-radius: var(--radius); color: var(--muted); font-size: 0.875rem; font-weight: 500; text-decoration: none; }
.lang-switch a:hover { color: var(--text); }
.lang-switch a[aria-current="true"] { color: var(--text); background: var(--raised); }
.theme-switch select { padding-block: 0.375rem; font-size: 0.875rem; }

@media (min-width: 62rem) {
    /* Два ряди: логотип та інструменти зверху, розділи — під ними */
    .menu-toggle { display: none; }
    .site-header__row { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1.5rem; padding-bottom: 0; }
    .site-nav { display: contents; }
    .site-nav > nav { grid-column: 1 / -1; grid-row: 2; }
    .site-nav__list { display: flex; flex-wrap: wrap; gap: 0 1.75rem; margin: 0; }
    .site-nav__list a { padding: 0.5rem 0; border-bottom: 2px solid transparent; font-size: 0.9375rem; color: var(--muted); white-space: nowrap; }
    .site-nav__list a:hover { color: var(--text); }
    .site-nav__list a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
    .site-tools { grid-column: 2; grid-row: 1; justify-self: end; flex-wrap: nowrap; }
    .site-search { flex: 0 1 14rem; }
    .site-search input { padding-block: 0.375rem; font-size: 0.875rem; }
}

.site-footer { margin-top: 3rem; padding-block: 2rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9375rem; }
.site-footer__row { display: grid; gap: 1.5rem; }
.site-footer__brand { margin-bottom: 0.375rem; color: var(--text); font-weight: 600; letter-spacing: 0.14em; }
.site-footer__small { font-size: 0.8125rem; }
.site-footer__links { display: grid; gap: 0.375rem; margin: 0; padding: 0; list-style: none; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }
@media (min-width: 48rem) { .site-footer__row { grid-template-columns: 2fr 1fr; } }

/* 3. Головна ----------------------------------------------------------------- */

.hero { padding-block: 2.5rem 1.5rem; border-bottom: 1px solid var(--line); }
.hero__row { display: grid; gap: 2rem; align-items: center; }
.hero h1 { max-width: 18ch; margin-bottom: 1.75rem; }
.hero__mark { display: none; }
.hero__mark .logo-mark { width: 100%; }

/* Чотири розділи сайту: маркер — грань куба з логотипа */
.hero__sections { display: grid; gap: 0; margin: 0 0 1.75rem; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.hero__sections a { position: relative; display: grid; gap: 0.125rem; padding: 0.75rem 0 0.75rem 2rem; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.hero__sections a::before { content: ""; position: absolute; left: 0; top: 1.3rem; width: 1.125rem; height: 0.7rem; background: var(--line); clip-path: var(--tile); }
.hero__sections a:hover::before { background: var(--accent); }
.hero__section-name { font-weight: 500; }
.hero__section-text { color: var(--muted); font-size: 0.9375rem; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0; }

@media (min-width: 56rem) {
    .hero { padding-block: 4rem 3rem; }
    .hero__row { grid-template-columns: minmax(0, 1fr) minmax(14rem, 22rem); gap: 4rem; }
    .hero__mark { display: block; }
    .hero__sections { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 2rem; border-top: 0; }
    .hero__sections a { border-top: 1px solid var(--line); border-bottom: 0; }
}

/* 4. Картки й списки --------------------------------------------------------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 2rem 1.75rem; }
.card { display: grid; align-content: start; gap: 0.875rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.card__cover { display: block; line-height: 0; }
.card__cover img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); background: var(--raised); }
.card__meta { display: flex; flex-wrap: wrap; gap: 0.25rem 0.875rem; margin: 0 0 0.375rem; color: var(--muted); font-size: 0.875rem; }
.card__type { position: relative; padding-left: 1.25rem; color: var(--text); }
.card__type::before { content: ""; position: absolute; left: 0; top: 0.5em; width: 0.8125rem; height: 0.5rem; background: var(--accent); clip-path: var(--tile); }
.card__title { font-size: 1.1875rem; line-height: 1.3; }
.card__title a { color: var(--text); text-decoration: none; }
.card__title a:hover { color: var(--accent-strong); text-decoration: underline; }
.card__summary { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.9375rem; }
.card__out { margin: 0.5rem 0 0; font-size: 0.875rem; }

.page-head { margin-bottom: 2rem; }
.page-head__lead { max-width: 60ch; margin: 0.75rem 0 0; color: var(--muted); font-size: 1.125rem; }

.pagination { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; align-items: center; margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--muted); }

.search-form { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.5rem; }
.search-form input { flex: 1 1 14rem; min-height: 2.75rem; }

.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 2rem 0 0; padding: 0; list-style: none; }
.tags a { display: block; padding: 0.25rem 0.75rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 0.875rem; text-decoration: none; }
.tags a:hover { color: var(--text); border-color: var(--muted); }

/* 5. Запис ------------------------------------------------------------------- */

.entry { padding-block: 2rem; }
.entry__head { max-width: 46rem; margin-bottom: 1.75rem; }
.crumbs { margin-bottom: 0.75rem; font-size: 0.9375rem; }
.crumbs a { color: var(--muted); }
.entry__summary { margin: 1rem 0 0; color: var(--muted); font-size: 1.1875rem; line-height: 1.5; }
.entry__meta { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin: 1rem 0 0; color: var(--muted); font-size: 0.875rem; }
.entry__cover { margin: 0 0 2rem; line-height: 0; }
.entry__cover img { width: 100%; max-height: 32rem; object-fit: cover; border-radius: var(--radius); background: var(--raised); }

.entry__layout { display: grid; gap: 2rem; }
.entry__main { min-width: 0; max-width: 46rem; }
.entry__side { display: grid; gap: 1.5rem; align-content: start; order: -1; }
.entry__links { display: grid; gap: 0.625rem; justify-items: start; }
.entry__note { margin: 0; color: var(--muted); font-size: 0.8125rem; max-width: 30ch; }

.toc { padding: 1rem 1.125rem; border: 1px solid var(--line); border-radius: var(--radius); font-size: 0.9375rem; }
.toc__title { margin-bottom: 0.5rem; font-weight: 600; }
.toc ol { display: grid; gap: 0.375rem; margin: 0; padding-left: 1.25rem; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--text); text-decoration: underline; }

@media (min-width: 64rem) {
    .entry__layout { grid-template-columns: minmax(0, 46rem) minmax(0, 16rem); justify-content: space-between; }
    .entry__side { order: 0; position: sticky; top: 7rem; }
}

.specs, .entry__firmware { margin-top: 2.5rem; }
.specs h2, .entry__firmware h2 { margin-bottom: 1rem; }
.entry__firmware > p { margin: 0.875rem 0 0; }

/* 8. Службове, друк, рух ----------------------------------------------------- */

.notice-page { max-width: 34rem; padding-block: 4rem; }
.notice-page__code { margin: 0; color: var(--accent); font: 600 4rem/1 var(--mono); }
.notice-page h1 { margin: 0.75rem 0; }

@media print {
    .site-header, .site-footer, .entry__side, .code-block__copy, .skip-link, esp-web-install-button { display: none !important; }
    body { background: #fff; color: #000; }
    a { color: inherit; }
    .code-block, pre { border-color: #999; white-space: pre-wrap; }
}

@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
    .btn, .card__title a, .hero__sections a::before, input, select { transition: color 0.12s, background-color 0.12s, border-color 0.12s; }
}

/* Власний логотип із медіатеки (налаштування «Зовнішній вигляд») */
.brand__logo { width: auto; height: 2.125rem; flex: none; }
