/* Блог Product Hub — дополнения к ds/blog.css: навигация методички, таблица техник, попапы, форма заявки.
   Только переменные из ds/tokens.css, поэтому тёмная тема работает сама. */

/* ===== Навигация в начале поста ===== */
.ph-nav-panel { padding: 20px; max-width: var(--measure); }
.ph-nav-panel ol { display: flex; flex-direction: column; }
.ph-nav-panel .ph-contents__item { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: baseline; gap: 8px; min-height: var(--tap); padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink-2); transition: color var(--motion-fast) var(--ease-standard); }
.ph-nav-panel li:last-child .ph-contents__item { border-bottom: 0; padding-bottom: 0; }
.ph-nav-panel .ph-contents__item:hover { color: var(--ink); }
.ph-nav-panel .ph-contents__num { font-size: 13px; }
.ph-contents__sub { display: block; margin-top: 2px; font-size: 13px; color: var(--ink-3); }
@media (min-width: 900px) { .ph-nav-panel { padding: 24px; } }

/* Оглавление длиннее экрана: прокручивается само, а не уходит за край */
@media (min-width: 1100px) {
  .ph-post__rail { max-height: calc(100vh - 96px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
}

/* ===== Принцип: свойство / принцип / следствия ===== */
.ph-facts--principle { max-width: var(--measure); }
.ph-facts--principle .ph-facts__row { grid-template-columns: 96px minmax(0, 1fr); }
.ph-facts--principle dd { font-size: 16px; line-height: 1.55; }
@media (min-width: 640px) { .ph-facts--principle .ph-facts__row { grid-template-columns: 140px minmax(0, 1fr); gap: 20px; } .ph-facts--principle dd { font-size: 17px; } }

/* ===== Таблица «техники × принципы» ===== */
.ph-matrix__hint { font-size: 13px; color: var(--ink-3); }
@media (min-width: 900px) { .ph-matrix__hint { display: none; } }
/* Шапка закреплена при прокрутке. Если таблица шире колонки текста — она листается внутри своей рамки (вбок и вниз), шапка липнет к верху рамки.
   Если помещается — overflow: clip вместо auto: рамка не становится контейнером прокрутки, и шапка липнет к странице под верхней панелью. */
.ph-matrix-host { container: matrix / inline-size; --matrix-col: 44px; --matrix-first: 168px; --matrix-top: 56px; }
@media (min-width: 900px) { .ph-matrix-host { --matrix-first: 270px; --matrix-top: 64px; } }
.ph-matrix { overflow: auto; overscroll-behavior-x: contain; max-height: calc(100svh - var(--matrix-top) - 32px); margin-inline: calc(-1 * var(--gutter)); border-block: 1px solid var(--line); background: var(--surface); scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
@media (min-width: 640px) { .ph-matrix { margin-inline: 0; border: 1px solid var(--line); border-radius: var(--radius); } }
.ph-matrix table { border-collapse: separate; border-spacing: 0; width: 100%; }
.ph-matrix th, .ph-matrix td { padding: 0; border-bottom: 1px solid var(--line); background: var(--surface); }
.ph-matrix tbody tr:last-child > * { border-bottom: 0; }
.ph-matrix thead > tr > * { position: sticky; top: 0; z-index: 2; }
@container matrix (min-width: 608px) { .ph-matrix { overflow: clip; max-height: none; } .ph-matrix thead > tr > * { top: var(--matrix-top); } }
@media (min-width: 900px) { @container matrix (max-width: 709.98px) { .ph-matrix { overflow: auto; max-height: calc(100svh - var(--matrix-top) - 32px); } .ph-matrix thead > tr > * { top: 0; } } }
/* Первая колонка закреплена при прокрутке вбок */
.ph-matrix th[scope="row"], .ph-matrix__corner { position: sticky; left: 0; z-index: 1; width: var(--matrix-first); min-width: var(--matrix-first); text-align: left; border-right: 1px solid var(--line); }
.ph-matrix thead > tr > .ph-matrix__corner { z-index: 3; }
.ph-matrix thead th:hover, .ph-matrix thead th:focus-within { z-index: 4; }

/* В шапке только номера принципов, название — во всплывающей подсказке */
.ph-matrix thead a { position: relative; display: flex; justify-content: center; padding: 14px 0 12px; color: var(--accent-deep); }
.ph-matrix__pnum { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ph-matrix thead a:hover .ph-matrix__pnum { color: var(--ink); }
.ph-matrix__tip { position: absolute; top: calc(100% - 2px); left: 50%; z-index: 1; translate: -50% 4px; padding: 6px 10px; border-radius: 8px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow-float); font-size: 13px; line-height: 1.3; font-weight: 500; white-space: nowrap; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity var(--motion-fast) var(--ease-standard), translate var(--motion-fast) var(--ease-standard), visibility 0s linear var(--motion-fast); }
/* Крайние колонки: подсказка прижата к краю, чтобы не уходить под первую колонку и за рамку */
.ph-matrix thead th:nth-child(-n+3) .ph-matrix__tip { left: 0; translate: 0 4px; }
.ph-matrix thead th:nth-last-child(-n+3) .ph-matrix__tip { left: auto; right: 0; translate: 0 4px; }
.ph-matrix thead a:focus-visible .ph-matrix__tip { opacity: 1; visibility: visible; translate: -50% 0; transition-delay: 0s; }
@media (hover: hover) { .ph-matrix thead a:hover .ph-matrix__tip { opacity: 1; visibility: visible; translate: -50% 0; transition-delay: 0s; } }
.ph-matrix thead th:nth-child(-n+3) a:focus-visible .ph-matrix__tip, .ph-matrix thead th:nth-last-child(-n+3) a:focus-visible .ph-matrix__tip { translate: 0; }
@media (hover: hover) { .ph-matrix thead th:nth-child(-n+3) a:hover .ph-matrix__tip, .ph-matrix thead th:nth-last-child(-n+3) a:hover .ph-matrix__tip { translate: 0; } }

.ph-matrix__group th { padding: 14px 14px 6px; font-size: 12px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); text-align: left; background: var(--subtle); }
.ph-matrix__group th span { position: sticky; left: 14px; }

.ph-matrix__tech { display: grid; grid-template-columns: 26px minmax(0, 1fr); align-items: baseline; gap: 6px; width: 100%; min-height: var(--tap); padding: 8px 12px 8px 14px; border: 0; background: none; text-align: left; font-size: 14px; line-height: 1.3; font-weight: 500; color: var(--ink); cursor: pointer; transition: color var(--motion-fast) var(--ease-standard); }
.ph-matrix__tech:hover { color: var(--accent-deep); }
.ph-matrix__tnum { font-size: 12px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
@media (min-width: 900px) { .ph-matrix__tech { font-size: 15px; } }

.ph-matrix td, .ph-matrix thead th { min-width: var(--matrix-col); text-align: center; }
.ph-matrix tbody tr:not(.ph-matrix__group):hover > * { background: var(--subtle); }
.ph-matrix__cell { display: block; width: 100%; height: var(--tap); padding: 6px; border: 0; background: none; cursor: pointer; }
.ph-matrix__cell::before { content: ""; display: block; width: 100%; height: 100%; max-width: 40px; margin: 0 auto; border-radius: 8px; background: var(--accent); transition: background-color var(--motion-fast) var(--ease-standard), scale var(--motion-press) ease; }
.ph-matrix__cell:hover::before { background: var(--accent-deep); }
.ph-matrix__cell:active::before { scale: 0.92; }

/* ===== Попап (техника и форма заявки) ===== */
.ph-modal { width: 100%; max-width: 640px; max-height: 92vh; margin: auto auto 0; padding: 0; border: 0; border-radius: 20px 20px 0 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-float); overflow: hidden; }
.ph-modal[open] { display: flex; flex-direction: column; animation: ph-sheet-up var(--motion-base) var(--ease-out); }
.ph-modal::backdrop { background: rgba(11, 11, 12, 0.45); }
@media (min-width: 640px) { .ph-modal { margin: auto; max-height: 86vh; border-radius: var(--radius); } }
.ph-modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 4px 20px; }
@media (min-width: 640px) { .ph-modal__head { padding: 14px 14px 4px 28px; } }
.ph-modal__close { width: var(--tap); height: var(--tap); padding: 0; display: grid; place-items: center; border: 0; background: none; color: var(--ink-2); cursor: pointer; border-radius: var(--radius-pill); }
.ph-modal__close:hover { color: var(--ink); background: var(--subtle); }
.ph-modal__close svg { width: 22px; height: 22px; }
.ph-modal__body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 20px calc(24px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .ph-modal__body { padding: 4px 28px 28px; } }
.ph-modal__title { font-size: 22px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; text-wrap: balance; }
.ph-modal__lead { margin-top: 8px; font-size: 15px; line-height: 1.5; color: var(--ink-2); }
html:has(dialog[open]) { overflow: hidden; }

/* ===== Техника в попапе ===== */
.ph-tech-store { display: none; }
.ph-tech { display: flex; flex-direction: column; gap: 16px; }
.ph-tech__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 13px; line-height: 1.4; color: var(--ink-3); }
.ph-tech__num { font-weight: 600; color: var(--accent-deep); font-variant-numeric: tabular-nums; }
.ph-tech__title { margin-top: -8px; font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; text-wrap: balance; }
@media (min-width: 640px) { .ph-tech__title { font-size: 24px; } }
.ph-tech__label { display: block; margin-bottom: 4px; font-size: 12px; line-height: 1.4; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.ph-tech p { font-size: 16px; line-height: 1.55; color: var(--ink-2); hyphens: auto; }
.ph-tech p strong { color: var(--ink); font-weight: 600; }
.ph-tech__principles { padding-top: 16px; border-top: 1px solid var(--line); }

.ph-prompt { padding: 16px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.ph-prompt__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.ph-prompt__top .ph-tech__label { margin: 0; color: var(--accent-deep); }
.ph-prompt pre { margin: 0; font-family: var(--font-sans); font-size: 15px; line-height: 1.55; font-weight: 500; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.ph-copy { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid var(--accent-tint); border-radius: var(--radius-pill); background: var(--surface); color: var(--accent-deep); font-size: 13px; font-weight: 500; cursor: pointer; transition: border-color var(--motion-fast) var(--ease-standard), scale var(--motion-press) ease; }
.ph-copy:hover { border-color: var(--accent); }
.ph-copy:active { scale: 0.98; }
.ph-copy svg { width: 15px; height: 15px; }
.ph-copy[hidden] { display: none; }
.ph-copy__status { display: block; font-size: 13px; color: var(--accent-deep); }
.ph-copy__status:empty { display: none; }
@media (min-width: 640px) { .ph-prompt { padding: 18px 20px; } .ph-prompt pre { font-size: 16px; } }

.ph-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ph-chips a { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-pill); color: var(--ink-2); font-size: 14px; font-weight: 500; transition: border-color var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard); }
.ph-chips a span { font-size: 12px; font-weight: 600; color: var(--accent-deep); font-variant-numeric: tabular-nums; }
.ph-chips a:hover { color: var(--ink); border-color: var(--line-strong); }

/* ===== Форма заявки ===== */
.ph-form { display: flex; flex-direction: column; gap: 16px; }
.ph-form .ph-modal__lead { margin-top: -8px; }
.ph-field { display: flex; flex-direction: column; gap: 6px; }
.ph-field__label { padding: 0; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.ph-input { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; transition: border-color var(--motion-fast) var(--ease-standard), box-shadow var(--motion-fast) var(--ease-standard); }
.ph-input::placeholder { color: var(--ink-3); }
.ph-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ph-input[aria-invalid="true"] { border-color: var(--accent-deep); }
.ph-choices { margin: 0; padding: 0; border: 0; min-width: 0; }
.ph-choices legend { margin-bottom: 8px; }
.ph-choices__list { display: flex; flex-direction: column; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.ph-choice { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 15px; line-height: 1.35; color: var(--ink-2); cursor: pointer; transition: background-color var(--motion-fast) var(--ease-standard); }
.ph-choice:last-child { border-bottom: 0; }
.ph-choice:hover { background: var(--subtle); }
.ph-choice input { flex-shrink: 0; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.ph-choice:has(input:checked) { background: var(--accent-soft); color: var(--ink); font-weight: 500; }
.ph-choices[aria-invalid="true"] .ph-choices__list { border-color: var(--accent-deep); }
.ph-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.ph-form__error { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink); font-size: 14px; line-height: 1.45; }
.ph-form__submit { margin-top: 4px; }
.ph-form__submit[disabled] { opacity: 0.6; cursor: progress; }
.ph-form__note { font-size: 12px; line-height: 1.45; color: var(--ink-3); }
.ph-form__done { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; padding: 8px 0 4px; }
.ph-form__done .ph-modal__lead { margin-top: -8px; }
.ph-form[hidden], .ph-form__done[hidden], .ph-form__error[hidden] { display: none; }

@media print {
  .ph-modal, .ph-matrix__hint { display: none !important; }
  .ph-matrix { overflow: visible; }
}
