/* =====================================================================
   Screen catcher (screenshot_catcher) — стили инструмента.
   Каркас на Bootstrap + локальные токены НА КОНТЕЙНЕРЕ инструмента (.shc);
   сайтовые токены, синюю шапку, левое меню и центрированный H1 не трогаем
   (см. .tool_conventions/image_tools.md, _common.md «Подложка инструмента и шрифт тела»).
   Ширина .shc совпадает с layout.width в manifest.json (880px).
   ===================================================================== */

.shc {
    --shc-accent:       #0352f1;
    --shc-accent-hover: #0344cc;
    --shc-accent-soft:  #f2f7fe;
    --shc-work-bg:      #eef1f6;
    --shc-drop-bg:      #f9fbfe;
    --shc-drop-border:  #b9cdf9;
    --shc-card-border:  #e6e8ec;
    --shc-line:         #dde1e8;
    --shc-text:         #1f2733;
    --shc-muted:        #6b7480;
    --shc-btn-outline:  #d7dbe2;
    --shc-err:          #b21e1f;
    --shc-err-bg:       #feefef;
    --shc-err-border:   #f6d2d2;
    --shc-live:         #e5322d;
    /* Ручки рамки обрезки. --shc-h — видимый квадрат ручки; на сенсорном экране он крупнее
       (переопределяется ниже в @media (pointer: coarse)). --shc-hit / --shc-hit-line —
       НЕВИДИМЫЕ зоны захвата: по ним палец попадает в ручку, а не мимо рамки.
       Правила скопированы из cut_photo — инструменты автономны, общего кода у них нет
       (см. .tool_conventions/image_tools.md, «Рамка выделения на сенсорном экране»). */
    --shc-h:            7px;
    --shc-hit:          44px;
    --shc-hit-line:     26px;

    --shc-radius:       16px;
    --shc-radius-sm:    12px;
    --shc-radius-xs:    10px;

    max-width: 880px;
    margin-inline: auto;
    background: #fff;
    border: 1px solid var(--shc-card-border);
    border-radius: var(--shc-radius);
    box-shadow: 0 2px 14px rgba(20, 30, 60, .06);
    padding: 24px;
    color: var(--shc-text);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    line-height: 1.45;
}

/* ---------------------------------------------------------------- кнопки */
.shc__btn-primary,
.shc__btn-outline,
.shc__btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--shc-radius-xs);
    padding: 10px 18px;
    white-space: nowrap;
}

.shc__btn-primary {
    background: var(--shc-accent);
    border: 1px solid var(--shc-accent);
    color: #fff;
}
.shc__btn-primary:hover  { background: var(--shc-accent-hover); border-color: var(--shc-accent-hover); color: #fff; }

.shc__btn-outline {
    background: #fff;
    border: 1px solid var(--shc-btn-outline);
    color: var(--shc-text);
}
.shc__btn-outline:hover { background: var(--shc-accent-soft); border-color: var(--shc-drop-border); color: var(--shc-text); }

.shc__btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--shc-muted);
    padding: 8px 10px;
}
.shc__btn-ghost:hover { color: var(--shc-text); background: #f4f6f9; }

.shc__btn-sm { padding: 7px 14px; font-size: 14px; }

/* клавиша-подсказка */
.shc__kbd {
    display: inline-block;
    background: #fff;
    border: 1px solid var(--shc-line);
    border-bottom-width: 2px;
    border-radius: 6px;
    padding: 2px 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--shc-text);
    line-height: 1.5;
}

/* ================================================== состояние 1: приём */
.shc__drop {
    border: 2px dashed var(--shc-drop-border);
    border-radius: var(--shc-radius);
    background: var(--shc-drop-bg);
    padding: 34px 20px 26px;
    text-align: center;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.shc__drop.is-drag { background: var(--shc-accent-soft); border-color: var(--shc-accent); }

.shc__drop-icon { font-size: 40px; line-height: 1; color: var(--shc-accent); }
.shc__drop-icon .bi { display: inline-block; }

.shc__drop-title {
    margin: 12px 0 10px;
    font-size: 20px;
    font-weight: 700;
}

.shc__drop-keys {
    margin: 0 0 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.shc__kbd-plus { color: var(--shc-muted); font-weight: 600; }

.shc__drop-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.shc__drop-or {
    margin: 14px 0 0;
    font-size: 13px;
    color: var(--shc-muted);
}

/* инструкция «как снять скриншот» */
.shc__guide {
    margin-top: 18px;
    border: 1px solid var(--shc-card-border);
    border-radius: var(--shc-radius-sm);
    background: #fbfcfe;
    padding: 16px 18px;
}
.shc__guide-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }

.shc__guide-rows { display: flex; flex-direction: column; gap: 8px; }
.shc__guide-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.shc__guide-os {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 92px;
    font-weight: 600;
    color: var(--shc-muted);
}
.shc__guide-txt { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.shc__guide-sep { color: var(--shc-line); padding: 0 2px; }

.shc__guide-then {
    margin: 12px 0 0;
    font-size: 14px;
    color: var(--shc-text);
}

.shc__capture-offer {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--shc-line);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
}
.shc__capture-txt { font-size: 14px; color: var(--shc-muted); }
.shc__capture-ask {
    flex: 1 1 100%;
    margin: 0;
    font-size: 13px;
    color: var(--shc-muted);
}
.shc__btn-capture { padding: 8px 14px; font-size: 14px; }

.shc__formats {
    margin: 14px 0 0;
    text-align: center;
    font-size: 13px;
    color: var(--shc-muted);
}
.shc__formats-dot { padding: 0 6px; }

/* ================================================== состояние 2: захват */
.shc__cap-head { display: flex; align-items: center; gap: 8px; }
.shc__cap-live {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--shc-live);
    animation: shc-pulse 1.4s ease-in-out infinite;
}
@keyframes shc-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .shc__cap-live { animation: none; } }

.shc__cap-title { font-size: 17px; font-weight: 700; }

.shc__cap-hint { margin: 10px 0 14px; font-size: 14px; color: var(--shc-muted); }

.shc__cap-stage {
    background: var(--shc-work-bg);
    border: 1px solid var(--shc-line);
    border-radius: var(--shc-radius-sm);
    padding: 10px;
    display: flex;
    justify-content: center;
}
.shc__cap-video {
    max-width: 100%;
    max-height: 46vh;
    border-radius: var(--shc-radius-xs);
    background: #000;
}

.shc__cap-actions {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}
/* кнопка затвора — не синяя, как остальные действия: её надо находить глазом мгновенно.
   Цвет приходит из config.php через переменную на корне инструмента (см. index.php). */
.shc__btn-snap {
    padding: 12px 28px;
    font-size: 16px;
    background: var(--shc-snap);
    border-color: var(--shc-snap);
}
.shc__btn-snap:hover { background: var(--shc-snap-hover); border-color: var(--shc-snap-hover); }
.shc__cap-key { margin: 10px 0 0; text-align: center; font-size: 13px; color: var(--shc-muted); }
.shc__cap-drag { margin-top: 4px; font-size: 12px; }

/* ================================================== состояние 3: редактор */
.shc__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.shc__zoom {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--shc-line);
    border-radius: var(--shc-radius-xs);
    padding: 3px;
    background: #fff;
}
.shc__zoom-btn,
.shc__zoom-mode {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 0;
    border-radius: 8px;
    padding: 6px 9px;
    color: var(--shc-text);
    font-size: 14px;
    font-weight: 600;
}
.shc__zoom-btn:hover,
.shc__zoom-mode:hover { background: var(--shc-accent-soft); }
.shc__zoom-mode.is-active { background: var(--shc-accent); color: #fff; }
.shc__zoom-val {
    min-width: 56px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* размеры снимка */
.shc__meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}
.shc__meta-cell {
    background: #f7f9fc;
    border: 1px solid var(--shc-card-border);
    border-radius: var(--shc-radius-xs);
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.shc__meta-cap { font-size: 12px; color: var(--shc-muted); }
.shc__meta-val {
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* рабочая область. Прокрутка ВНУТРИ этой рамки — это функция инструмента
   (просмотр снимка 1:1), а не побочный скроллбар страницы: у .tool-stage
   и у документа скролла по-прежнему нет (см. _common.md). */
.shc__viewport {
    background: var(--shc-work-bg);
    border: 1px solid var(--shc-line);
    border-radius: var(--shc-radius-sm);
    padding: 10px;
    overflow: auto;
    max-height: 62vh;
    min-height: 220px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overscroll-behavior: contain;
}

.shc__wrap {
    position: relative;
    line-height: 0;
    flex: 0 0 auto;
    box-shadow: 0 1px 8px rgba(20, 30, 60, .14);
}

.shc__canvas { display: block; max-width: none; background: #fff; }
.shc__canvas[hidden], .shc__cropimg[hidden] { display: none; }

.shc__overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}
.shc[data-mode="crop"] .shc__overlay { display: none; }

.shc__cropimg { display: block; max-width: none; }

/* поле ввода текста поверх снимка */
.shc__textinput {
    position: absolute;
    z-index: 5;
    border: 1px dashed var(--shc-accent);
    border-radius: 6px;
    background: rgba(255, 255, 255, .92);
    padding: 2px 6px;
    font-weight: 700;
    line-height: 1.2;
    outline: none;
    min-width: 120px;
}

/* панель инструментов разметки */
.shc__panelbar { margin-top: 12px; }

.shc__tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.shc__tool {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #fff;
    border: 1px solid var(--shc-btn-outline);
    border-radius: var(--shc-radius-xs);
    padding: 8px 13px;
    font-size: 14px;
    font-weight: 600;
    color: var(--shc-text);
}
.shc__tool:hover { background: var(--shc-accent-soft); border-color: var(--shc-drop-border); }
.shc__tool.is-active {
    background: var(--shc-accent);
    border-color: var(--shc-accent);
    color: #fff;
}
.shc__tool .bi { font-size: 16px; line-height: 1; }
.shc__tools-sep {
    width: 1px;
    align-self: stretch;
    background: var(--shc-line);
    margin: 2px 4px;
}

/* цвет и толщина */
.shc__brushbar {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    background: #f7f9fc;
    border: 1px solid var(--shc-card-border);
    border-radius: var(--shc-radius-xs);
    padding: 10px 12px;
}

.shc__colors { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.shc__color {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: var(--shc-sw);
    box-shadow: 0 0 0 1px var(--shc-line);
    padding: 0;
}
.shc__color.is-active { box-shadow: 0 0 0 2px var(--shc-accent); }

.shc__color-custom { display: inline-flex; margin: 0; }
.shc__color-input {
    width: 30px;
    height: 26px;
    padding: 2px;
    border: 1px solid var(--shc-line);
    border-radius: 6px;
    background: #fff;
}

.shc__sizes { display: flex; align-items: center; gap: 6px; }
.shc__sizes-cap { font-size: 13px; color: var(--shc-muted); margin-right: 2px; }
.shc__size {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--shc-btn-outline);
    border-radius: 8px;
    padding: 0;
}
.shc__size.is-active { border-color: var(--shc-accent); background: var(--shc-accent-soft); }
.shc__size-dot {
    display: block;
    width: var(--shc-dot);
    height: var(--shc-dot);
    border-radius: 50%;
    background: var(--shc-text);
}

.shc__undo { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.shc__iconbtn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--shc-btn-outline);
    border-radius: 8px;
    color: var(--shc-text);
    font-size: 16px;
}
.shc__iconbtn:hover:not(:disabled) { background: var(--shc-accent-soft); border-color: var(--shc-drop-border); }
.shc__iconbtn:disabled { opacity: .4; }

/* строка режима обрезки */
.shc__cropbar {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background: var(--shc-accent-soft);
    border: 1px solid var(--shc-drop-border);
    border-radius: var(--shc-radius-xs);
    padding: 10px 12px;
}
.shc__cropbar-hint { font-size: 14px; color: var(--shc-text); }
.shc__cropbar-sel {
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-left: auto;
}

/* итоговые действия */
.shc__actions {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.shc__actions--error { margin-top: 14px; }

.shc__dl-main { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.shc__dl-split { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.shc__dl-menu .dropdown-item.active { background: var(--shc-accent); color: #fff; }

/* ================================================== ошибка */
.shc__alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--shc-err-bg);
    border: 1px solid var(--shc-err-border);
    border-radius: var(--shc-radius-sm);
    padding: 14px 16px;
}
.shc__alert-icon { color: var(--shc-err); font-size: 20px; line-height: 1.2; }
.shc__alert-text { display: flex; flex-direction: column; gap: 3px; }
.shc__alert-title { font-size: 15px; color: var(--shc-err); }
.shc__alert-hint { font-size: 14px; color: var(--shc-text); }
.shc__alert-close {
    margin-left: auto;
    background: transparent;
    border: 0;
    color: var(--shc-muted);
    font-size: 15px;
    padding: 2px 4px;
}

/* ================================================== тост */
.shc__toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    background: rgba(24, 32, 46, .94);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(15, 22, 40, .22);
    z-index: 1080;
    max-width: min(92vw, 460px);
    text-align: center;
}

/* ================================================== мобайл */
@media (max-width: 640px) {
    .shc { padding: 16px; border-radius: var(--shc-radius-sm); }

    .shc__drop { padding: 24px 14px 20px; }
    .shc__drop-title { font-size: 18px; }
    .shc__drop-actions .btn { flex: 1 1 100%; }

    .shc__guide-os { min-width: 100%; }

    .shc__capture-offer { flex-direction: column; align-items: stretch; }
    .shc__btn-capture { width: 100%; }

    .shc__toolbar { justify-content: center; }
    /* масштаб — одной строкой на всю ширину, иначе «Fit» и «Actual size»
       разъезжаются по двум рядам и панель выглядит рваной */
    .shc__zoom { width: 100%; justify-content: space-between; flex-wrap: nowrap; }
    .shc__zoom-btn, .shc__zoom-mode { padding: 6px 7px; font-size: 13px; }
    .shc__zoom-mode { gap: 4px; }
    .shc__zoom-val { min-width: 44px; font-size: 13px; }

    .shc__meta { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .shc__meta-cell { padding: 6px 8px; }
    .shc__meta-cap { font-size: 11px; }
    /* «1200 × 760 px» в треть узкого экрана помещается только уменьшённым шрифтом;
       перенос оставлен запасным путём, чтобы цифры не обрезались многоточием */
    .shc__meta-val { font-size: 11px; white-space: normal; overflow: visible; text-overflow: clip; }

    /* на узком экране снимок вписывается мелко — не держим под ним пустую серую зону */
    .shc__viewport { max-height: 52vh; min-height: 140px; padding: 6px; }

    /* подписи инструментов остаются (правило «не сворачивать в иконку»), но мельче */
    .shc__tool { padding: 7px 9px; font-size: 12px; gap: 5px; }
    .shc__tools-sep { display: none; }

    .shc__brushbar { gap: 10px; padding: 8px 10px; }
    .shc__undo { margin-left: 0; }

    .shc__actions .btn-group { width: 100%; }
    .shc__actions > .btn { flex: 1 1 calc(50% - 5px); }
    .shc__dl-main { flex: 1 1 auto; }
}

@media (max-width: 380px) {
    .shc__tool-lbl { font-size: 11px; }
    .shc__actions > .btn { flex: 1 1 100%; }
}

/* =====================================================================
   Cropper.js — ручки рамки обрезки.
   Ручка сидит ЦЕНТРОМ на грани рамки, поэтому смещение всегда половина её размера
   (вендор зашивает 5px/-3px по месту — пересчитываем от токена).
   ===================================================================== */
.shc .cropper-point { width: var(--shc-h); height: var(--shc-h); }
.shc .cropper-point.point-n  { top:    calc(var(--shc-h) / -2); margin-left: calc(var(--shc-h) / -2); }
.shc .cropper-point.point-s  { bottom: calc(var(--shc-h) / -2); margin-left: calc(var(--shc-h) / -2); }
.shc .cropper-point.point-e  { right:  calc(var(--shc-h) / -2); margin-top:  calc(var(--shc-h) / -2); }
.shc .cropper-point.point-w  { left:   calc(var(--shc-h) / -2); margin-top:  calc(var(--shc-h) / -2); }
.shc .cropper-point.point-ne { top:    calc(var(--shc-h) / -2); right: calc(var(--shc-h) / -2); }
.shc .cropper-point.point-nw { top:    calc(var(--shc-h) / -2); left:  calc(var(--shc-h) / -2); }
.shc .cropper-point.point-sw { bottom: calc(var(--shc-h) / -2); left:  calc(var(--shc-h) / -2); }
.shc .cropper-point.point-se { bottom: calc(var(--shc-h) / -2); right: calc(var(--shc-h) / -2);
                               width: var(--shc-h); height: var(--shc-h); }

/* Сенсорный экран: ручка видимо крупнее, а вокруг неё невидимая зона захвата.
   У граней зона растёт НАРУЖУ рамки — там палец промахивается чаще всего. */
@media (pointer: coarse) {
    .shc { --shc-h: 14px; }

    .shc .cropper-point { border-radius: 50%; opacity: 1;
                          box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
    .shc .cropper-point::after { content: ''; position: absolute; left: 50%; top: 50%;
                                 width: var(--shc-hit); height: var(--shc-hit);
                                 transform: translate(-50%, -50%); }

    .shc .cropper-line::after { content: ''; position: absolute; }
    .shc .cropper-line.line-n::after { left: 0; right: 0; bottom: 0; height: var(--shc-hit-line); }
    .shc .cropper-line.line-s::after { left: 0; right: 0; top: 0;    height: var(--shc-hit-line); }
    .shc .cropper-line.line-e::after { top: 0; bottom: 0; left: 0;   width:  var(--shc-hit-line); }
    .shc .cropper-line.line-w::after { top: 0; bottom: 0; right: 0;  width:  var(--shc-hit-line); }
}
