/*
 * The name page — /skhemy/s-imenami, page one (templates/catalog/names.html.twig).
 * Design: design/name-page-2026-11/SPEC.md and its mockup. Loaded on that page only.
 * Site tokens from site.css, plus the constructor's danger colours and an amber tint for the advice.
 * Section gap 56 px on a phone, 80 px on a desktop; tap targets 44 px and up.
 */
.nh {
    --danger: #B3261E;
    --danger-tint: #FBE9E6;
    --amber-tint: #FCF1DC;
    --paper-line: #E4D8CC;
}
.nh-lead { max-width: 640px; margin: 0 0 20px; font-size: 16.5px; color: var(--body); }
.nh-sec { margin-top: 56px; scroll-margin-top: 80px; }
.nh-sec > h2 { margin-bottom: 8px; }
.nh-lede { max-width: 640px; margin: 0 0 20px; font-size: 15.5px; color: var(--body); }
.nw { white-space: nowrap; }
.nh button { font-family: var(--text); cursor: pointer; }
.nh button.btn { border: 0; }
.nh button.btn-secondary { border: 1px solid var(--line); }

/* ---------------------------------------------------------------- the name card */
.nc {
    background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-md);
    padding: 22px 20px 20px; scroll-margin-top: 80px;
}
.nc-form { display: contents; }
.nc-eyebrow { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 13px; font-weight: 600; color: var(--accent-2); }
.nc-eyebrow i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); }
.nc-label { display: block; margin-bottom: 8px; font-size: 15px; font-weight: 600; }
.nc-input {
    display: block; width: 100%; height: 56px; padding: 0 16px;
    border: 1px solid var(--line); border-radius: var(--radius-control); background: #FFFDFB;
    font: 500 18px var(--text); color: var(--ink);
}
.nc-input::placeholder { color: #A99C93; }
.nc-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.nc-input.is-error { border-color: var(--danger); background: var(--danger-tint); }
.nc-input.is-error:focus { outline-color: var(--danger); }
.nc-note { min-height: 20px; margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.nc-note.is-error { color: var(--danger); }
.nc-well {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    min-height: 132px; margin-top: 18px; padding: 18px 14px 14px; border-radius: 16px; background: var(--tint-2);
}
.nc-pic { width: 100%; display: flex; justify-content: center; }
.nc-pic svg { display: block; width: calc(var(--n) * 12px); max-width: 100%; height: auto; }
.nc-canvas { display: block; max-width: 100%; }
.nc-pic[hidden], .nc-canvas[hidden] { display: none; }
.nc-facts { font-size: 13.5px; color: var(--muted); text-align: center; }
.nc-facts b { color: var(--ink); font-weight: 600; }
.nc-height { margin-top: 18px; }
.nc-height-name { margin-bottom: 8px; font-size: 13.5px; font-weight: 500; color: var(--muted); }
.seg {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
    padding: 4px; border-radius: 14px; background: var(--tint-2);
}
.seg button {
    height: 44px; border: 0; border-radius: 10px; background: transparent;
    font-size: 14.5px; font-weight: 500; line-height: 1.1; color: var(--body);
}
.seg button small { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--muted); }
.seg button.is-on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.nc-make { width: 100%; margin-top: 18px; }
.nc-after { margin: 10px 0 0; font-size: 13.5px; color: var(--muted); text-align: center; }

/* ---------------------------------------------------------------- in-page contents */
.nh-toc {
    display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
    margin: 24px -20px 0; padding: 0 20px 4px;
}
.nh-toc::-webkit-scrollbar { display: none; }
.nh-toc a {
    flex: none; display: inline-flex; align-items: center; height: 40px; padding: 0 14px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
    font-size: 14.5px; font-weight: 500; color: var(--body);
}
.nh-toc a:hover { border-color: var(--accent); color: var(--accent); }
.nh-toc a span { margin-left: 6px; font-weight: 400; color: var(--muted); }

/* ---------------------------------------------------------------- alphabet */
.ab-controls { display: grid; gap: 14px; margin-bottom: 18px; }
.ab-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.ab-tabs button {
    flex: 1; height: 46px; margin-bottom: -1px; border: 0; border-bottom: 3px solid transparent; background: none;
    font-size: 15.5px; font-weight: 500; color: var(--muted);
}
.ab-tabs button.is-on { border-bottom-color: var(--accent); font-weight: 600; color: var(--ink); }
.ab-height { display: flex; align-items: center; gap: 12px; }
.ab-height > span { flex: none; font-size: 13.5px; font-weight: 500; color: var(--muted); }
.ab-height .seg { flex: 1; }
.seg-sm button { height: 38px; font-size: 14px; }
.ab-panel[hidden] { display: none; }
/* Cell size per letter height: the widest glyphs (Щ at 7 threads, Ж at 9) fit a 5-column phone tile. */
.ab-s { --cell: 8px; }
.ab-m { --cell: 6px; }
.ab-l { --cell: 5px; }
.ab-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.ab-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px;
    padding: 10px 2px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.ab-tile svg { display: block; width: calc(var(--n) * var(--cell)); max-width: 100%; height: auto; overflow: visible; }
.ab-tile b { font-size: 14px; font-weight: 600; line-height: 1; color: var(--muted); }
.ab-sheet {
    display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px 14px;
    margin-top: 16px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface);
}
.ab-thumb { width: 88px; height: 64px; border: 1px solid var(--line); border-radius: 10px; background: #fff; object-fit: contain; }
.ab-sheet-text b { display: block; font-size: 15px; }
.ab-sheet-text span { font-size: 13px; color: var(--muted); }
.ab-sheet-acts { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ab-sheet-acts .btn { height: 44px; padding: 0 12px; border-radius: 12px; font-size: 14.5px; gap: 8px; white-space: nowrap; }
.ab-note { margin: 12px 0 0; font-size: 13.5px; color: var(--muted); }

/* ---------------------------------------------------------------- the thread table */
.sz-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
.sz { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.sz th, .sz td { padding: 12px 6px; border-bottom: 1px solid var(--line); text-align: center; }
.sz tr:last-child > * { border-bottom: 0; }
.sz thead th { background: var(--tint-2); font-size: 14px; font-weight: 600; line-height: 1.2; }
.sz thead th small { display: block; margin-top: 3px; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.sz th.sz-name, .sz th[scope=row] { padding-left: 14px; text-align: left; }
.sz th[scope=row] { font-weight: 600; overflow-wrap: anywhere; }
.sz th[scope=row] small { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.sz td b { display: block; font-size: 15.5px; font-weight: 600; white-space: nowrap; }
.sz td span { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.sz tr.is-base { background: #FCF8F4; }
.sz tr.is-yours { background: #FFF7F3; }
.sz tr.is-yours th[scope=row] { color: var(--accent-dark); font-size: 13px; overflow-wrap: normal; white-space: nowrap; }  /* «АЛЕКС / АНДРА» broke mid-word at 320 px */
.sz .sz-yours { display: block; max-width: 6.2em; overflow: hidden; text-overflow: ellipsis; }
.sz-foot { max-width: 640px; margin: 12px 2px 0; font-size: 13.5px; color: var(--muted); }
.nh-advice { display: flex; gap: 12px; margin-top: 16px; padding: 16px; border-radius: 16px; background: var(--amber-tint); }
.nh-advice svg { flex: none; margin-top: 2px; }
.nh-advice p { margin: 0; font-size: 15px; color: var(--body); }
.nh-advice a { font-weight: 600; white-space: nowrap; }

/* ---------------------------------------------------------------- how-to */
.nh-steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.nh-steps li {
    position: relative; padding: 18px 18px 16px 60px;
    border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface);
}
.nh-steps li::before {
    counter-increment: step; content: counter(step);
    position: absolute; left: 16px; top: 16px; display: grid; place-items: center; width: 30px; height: 30px;
    border-radius: 50%; background: var(--tint); font-size: 15px; font-weight: 700; color: var(--accent-dark);
}
.nh-steps h3 { margin: 2px 0 6px; }
.nh-steps p { margin: 0; font-size: 15px; color: var(--body); }

/* ---------------------------------------------------------------- ready patterns */
.nh-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.nh-head h2 { margin-bottom: 8px; }
.nh-count { font-size: 14px; color: var(--muted); white-space: nowrap; }

/* ---------------------------------------------------------------- more */
.nh-more { display: grid; gap: 10px; margin: 16px 0 20px; }
.nh-more a {
    display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 14px 16px;
    border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink);
}
.nh-more a:hover { border-color: #DFCFC0; box-shadow: var(--shadow-md); color: var(--ink); }
.nh-more a:hover b { color: var(--accent); }
.nh-more-icon {
    flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
    background: var(--tint-2); font-size: 13px; font-style: normal; font-weight: 600; color: var(--accent-dark);
}
.nh-more-text { min-width: 0; }
.nh-more-text b { display: block; font-size: 15.5px; font-weight: 600; }
.nh-more-text span { font-size: 13.5px; color: var(--muted); }
.nh-more-arrow { flex: none; margin-left: auto; color: var(--muted); }

/* ---------------------------------------------------------------- print: one chart, one A4 landscape page */
.ab-print { display: none; }
@page alphabet { size: A4 landscape; margin: 10mm; }
@media print {
    body.is-printing-alphabet > *, body.is-printing-alphabet main > .nh > * { display: none !important; }
    body.is-printing-alphabet main, body.is-printing-alphabet .nh { display: block !important; padding: 0; margin: 0; }
    body.is-printing-alphabet .ab-print { display: block !important; page: alphabet; }
    .ab-print img { display: block; width: 100%; height: auto; max-height: 185mm; object-fit: contain; }
}

/* ---------------------------------------------------------------- 320 px phones */
@media (max-width: 359px) {
    /* «Распечатать» with its icon is wider than half the card here */
    .ab-sheet-acts .btn svg { display: none; }
    .sz th, .sz td { padding-inline: 4px; }
    .sz th.sz-name, .sz th[scope=row] { padding-left: 10px; }
    .sz td b { font-size: 14.5px; }
}

/* ---------------------------------------------------------------- desktop */
@media (min-width: 900px) {
    .nh-lead { margin-bottom: 28px; font-size: 18px; }
    .nh-sec { margin-top: 80px; }
    .nc {
        display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; gap: 0 40px; padding: 36px;
        grid-template-areas: "eyebrow well" "label well" "input well" "note well" "height well" "make well" "after well" ". well";
    }
    .nc-eyebrow { grid-area: eyebrow; }
    .nc-label { grid-area: label; }
    .nc-input { grid-area: input; }
    .nc-note { grid-area: note; }
    .nc-height { grid-area: height; }
    .nc-make { grid-area: make; justify-self: start; width: auto; padding: 0 32px; }
    .nc-after { grid-area: after; text-align: left; }
    .nc-well { grid-area: well; align-self: stretch; min-height: 300px; margin: 0; }
    .nc-pic svg { width: calc(var(--n) * 16px); }
    .nh-toc { flex-wrap: wrap; overflow: visible; margin: 28px 0 0; padding: 0; }
    .ab-controls { grid-template-columns: auto auto; justify-content: space-between; align-items: end; }
    .ab-tabs button { flex: none; padding: 0 22px; }
    .ab-height .seg { min-width: 340px; }
    .ab-s { --cell: 11px; }
    .ab-m { --cell: 9px; }
    .ab-l { --cell: 8px; }
    .ab-grid { grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 10px; }
    .ab-tile { padding: 14px 4px 8px; }
    .ab-sheet { max-width: 720px; grid-template-columns: auto minmax(0, 1fr) auto; padding: 14px 16px; }
    .ab-thumb { width: 140px; height: 92px; }
    .ab-sheet-acts { grid-column: auto; display: flex; }
    .nh-sizes { display: grid; grid-template-columns: minmax(0, 720px) minmax(0, 1fr); align-items: start; gap: 40px; }
    .nh-sizes .nh-advice { flex-direction: column; margin-top: 0; padding: 22px; }
    .nh-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
    .nh-steps li { padding: 64px 22px 22px; }
    .nh-steps li::before { left: 22px; top: 22px; }
    .nh-more { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* A 320 px phone: the nine-letter example name broke mid-word («АЛЕКСАН / ДР»); a smaller face and
   tighter cells keep every name whole without pushing the last column out of the card. */
@media (max-width: 359px) {
    .sz th, .sz td { padding-left: 4px; padding-right: 4px; }
    .sz th[scope=row] { font-size: 12px; overflow-wrap: normal; }
    .sz td b { font-size: 14px; }
    .sz td span { font-size: 11.5px; }
    .sz .sz-yours { max-width: 4.6em; }
}
