/*
 * Engine home kit (docs/engine-home-kit.md): icons, home hero + search + popular chips, calculator
 * section/tile grids, category links. Linked by the site after engine.css and before its own theme CSS.
 * Colours come only from engine tokens (--c-accent, --c-accent-soft, --c-link, --c-focus, --c-surface,
 * --c-border, --c-border-strong, --c-muted, --c-text) and spacing/type tokens (--s-*, --fs-*, --radius*, --shadow, --gap).
 * Mobile first, no fixed widths.
 */

/* ---------- Icons (Tabler sprite, @SeoEngine/_icons.svg.twig) ---------- */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
/* Category / page mark: the icon on a soft accent square. */
.cat-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; border-radius: var(--radius); background: var(--c-accent-soft); color: var(--c-accent); }
.cat-icon .icon { width: 22px; height: 22px; }
/* Float allows long words to wrap under the icon, avoiding flexbox widening. */
.title-icon { display: flow-root; }
.title-icon > .cat-icon { float: left; margin: calc((1em * 1.2 - 36px) / 2) var(--s-3) 0 0; }

/* ---------- Home: hero, search, popular chips ---------- */
.hero { margin-bottom: var(--s-5); }
.hero .lead { margin-bottom: var(--s-4); }
.calc-search { position: relative; max-width: 40rem; }
.calc-search__icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--c-muted); pointer-events: none; }
.calc-search input { width: 100%; min-width: 0; min-height: 52px; padding: 12px 14px 12px 48px; border-radius: var(--radius-lg); font-size: var(--fs-lg); box-shadow: var(--shadow); }
.calc-search input::-webkit-search-cancel-button { cursor: pointer; }
/* Phones: one scrolling row bleeding to the screen edges (the container's gutter), no page overflow. */
.popular { margin: var(--s-3) calc(-1 * var(--gap)) 0; }
.popular ul { display: flex; gap: var(--s-2); margin: 0; padding: 2px var(--gap) var(--s-1); list-style: none; overflow-x: auto; scrollbar-width: none; }
.popular ul::-webkit-scrollbar { display: none; }
.popular li { flex: none; }
.popular a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s-4); border: 1px solid var(--c-border); border-radius: 999px; background: var(--c-surface); color: var(--c-text); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; text-decoration: none; }
.popular a:hover { border-color: var(--c-accent); background: var(--c-accent-soft); color: var(--c-link); }

/* ---------- Home sections and calculator tiles ---------- */
.calc-groups { margin-bottom: var(--s-5); }
.calc-section { margin-bottom: var(--s-6); }
.calc-section[hidden], .tiles > li[hidden] { display: none; }
.calc-section__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 var(--s-4); margin-bottom: var(--s-3); }
.calc-section__head h2 { min-width: 0; margin: 0; font-size: var(--fs-h2); }
.calc-section__head h2 a { display: inline-flex; align-items: center; gap: var(--s-3); min-height: 44px; color: var(--c-text); text-decoration: none; }
.calc-section__head h2 a:hover { color: var(--c-link); }
.calc-section__all { display: inline-flex; align-items: center; min-height: 44px; font-size: var(--fs-sm); }
/* Phones: «все →» stays on the heading row; the full words remain for screen readers. */
@media (max-width: 559px) {
    .calc-section__head { flex-wrap: nowrap; }
    .calc-section__all-long { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* min(100%, …): one column instead of overflow when the screen is narrower than a tile. */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: var(--s-2); margin: 0; padding: 0; list-style: none; }
.tiles > li { display: flex; min-width: 0; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 44px; padding: var(--s-3); border: 1px solid var(--c-border); border-radius: var(--radius-lg); background: var(--c-surface); box-shadow: var(--shadow); color: var(--c-text); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.tile:hover { border-color: var(--c-accent); box-shadow: 0 0 0 1px var(--c-accent); }
.tile:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; border-radius: var(--radius-lg); }
.tile__icon { display: inline-flex; margin-bottom: var(--s-2); color: var(--c-accent); }
.tile__title { margin: 0; font-family: var(--font); font-size: var(--fs-base); font-weight: 700; line-height: 1.3; letter-spacing: 0; }
.tile:hover .tile__title { color: var(--c-link); }
.tile__hint { font-size: var(--fs-sm); line-height: 1.4; color: var(--c-muted); }
.search-empty { margin: 0 0 var(--s-5); padding: var(--s-4); border: 1px dashed var(--c-border-strong); border-radius: var(--radius-lg); color: var(--c-muted); }
.link-button { min-height: 44px; padding: 0; border: 0; background: none; color: var(--c-link); font: inherit; text-decoration: underline; text-underline-offset: .15em; cursor: pointer; }

/* Category page: larger tiles with the lead sentence. */
.tiles--lg { grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: var(--s-3); margin-bottom: var(--s-5); }
.tile--lg { padding: var(--s-4); }
.tile--lg .tile__title { font-family: var(--font-display); font-size: var(--fs-h3); text-wrap: balance; }
.tile--lg .tile__hint { margin-top: var(--s-1); }
.cat-links { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0; padding: 0; list-style: none; }
.cat-links a { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-4) 0 var(--s-3); border: 1px solid var(--c-border); border-radius: 999px; background: var(--c-surface); color: var(--c-text); font-size: var(--fs-sm); font-weight: 600; text-decoration: none; }
.cat-links a .icon { width: 20px; height: 20px; color: var(--c-accent); }
.cat-links a:hover { border-color: var(--c-accent); background: var(--c-accent-soft); }


@media (min-width: 560px) {
    .popular { margin-inline: 0; }
    .popular ul { flex-wrap: wrap; padding-inline: 0; overflow: visible; }
    .tiles:not(.tiles--lg) { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-3); }
}
