/* Раздел «Генератор подписей». Mobile-first. Подключается только на
   страницах с генератором (index, буквенные). */

/* --- Шрифты MVP (self-host, кириллица, swap). woff2 для отображения. ---
   Файлы лежат в /fonts-podpis/. font-display: swap + резерв размеров ячеек
   в .sg-cell (анти-CLS). */
/* Курируемый набор: только кириллические рукописные/каллиграфические
   шрифты, реально похожие на подпись (проверено по charset). */
@font-face { font-family: 'Caveat';       src: url('/fonts-podpis/caveat.woff2') format('woff2');       font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Marck Script'; src: url('/fonts-podpis/marck-script.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Bad Script';   src: url('/fonts-podpis/bad-script.woff2') format('woff2');   font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Great Vibes';  src: url('/fonts-podpis/great-vibes.woff2') format('woff2');  font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Comforter';    src: url('/fonts-podpis/comforter.woff2') format('woff2');    font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Playpen Sans'; src: url('/fonts-podpis/playpen-sans.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }

.sg { margin: 0 0 2em; }

/* --- Переключатель режимов (вкладки) ----------------------------------- */
.sg-tabs {
    display: flex;
    gap: 0.4em;
    margin-bottom: 1.1em;
    border-bottom: 2px solid rgba(120, 130, 140, 0.2);
}
.sg-tab {
    -webkit-appearance: none; appearance: none;
    background: none; border: none;
    padding: 0.6em 1.1em;
    margin-bottom: -2px;
    font-size: 0.95em;
    font-weight: 600;
    color: #8a8f94;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}
.sg-tab.is-active { color: #c5302e; border-bottom-color: #c5302e; }

.sg-form { margin: 0 0 1.2em; }

/* --- Режим рисования --------------------------------------------------- */
.sg-draw { margin: 0 0 1.5em; }
.sg-draw-hint { color: #777; margin-bottom: 0.7em; }
.sg-draw-stage {
    border: 1px dashed rgba(120, 130, 140, 0.45);
    border-radius: 0.6em;
    background:
        linear-gradient(45deg, #f3f4f6 25%, transparent 25%, transparent 75%, #f3f4f6 75%) 0 0/22px 22px,
        linear-gradient(45deg, #f3f4f6 25%, #fff 25%, #fff 75%, #f3f4f6 75%) 11px 11px/22px 22px;
    margin-bottom: 0.9em;
    overflow: hidden;
}
#sg-draw-canvas {
    display: block;
    width: 100%;
    height: auto;
    touch-action: none; /* чтобы рисование не скроллило страницу на тач */
    cursor: crosshair;
}
.sg-control-range input[type="range"] { width: 8em; vertical-align: middle; }

.sg-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75em;
    margin-bottom: 1em;
}
@media (min-width: 720px) {
    .sg-fields { grid-template-columns: repeat(3, 1fr); }
}
.sg-field { display: flex; flex-direction: column; }
.sg-field > span { font-size: 0.85em; color: #555; margin-bottom: 0.25em; }
.sg-field input[type="text"] {
    width: 100%;
    height: 2.75em;
    padding: 0 0.9em;
    border: 1px solid rgba(120, 130, 140, 0.45);
    border-radius: 0.4em;
    background: #fff;
    color: #202020;
    font-size: 1em;
}
.sg-field input[type="text"]:focus { outline: none; border-color: #c5302e; }

.sg-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75em 1em;
}
.sg-control { display: inline-flex; align-items: center; gap: 0.4em; font-size: 0.9em; }
.sg-control input[type="color"] { width: 2.2em; height: 2.2em; border: none; background: none; padding: 0; cursor: pointer; }
.sg-control-check { cursor: pointer; }

/* Кнопки используют глобальный класс .button из main.css; мелкая настройка. */
.sg #sg-generate { color: #fff !important; background-color: #c5302e; box-shadow: inset 0 0 0 2px #c5302e; }

/* --- Сетка вариантов --------------------------------------------------- */
.sg-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.9em;
    margin-top: 1em;
    min-height: 168px; /* резерв под первую строку (анти-CLS) */
}
@media (min-width: 560px) { .sg-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1040px) { .sg-grid { grid-template-columns: repeat(3, 1fr); } }

.sg-cell {
    position: relative;
    display: block;
    width: 100%;
    min-height: 168px;        /* зарезервированная высота ячейки */
    padding: 6px 10px 24px;
    border: 1px solid rgba(120, 130, 140, 0.22);
    border-radius: 0.7em;
    background: #fff;
    cursor: pointer;
    overflow: hidden;
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    text-align: center;
}
.sg-cell:hover { border-color: #c5302e; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10); }
.sg-cell:active { transform: translateY(1px); }
.sg-cell svg { display: block; width: 100%; height: 150px; }
.sg-cell-name {
    position: absolute;
    left: 0; right: 0; bottom: 7px;
    font-size: 0.7em;
    color: #9aa0a6;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}
.sg-hint { color: #777; padding: 1.5em 0; }

/* --- Крупный предпросмотр (модалка) ------------------------------------ */
.sg-preview {
    position: fixed;
    inset: 0;
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 22, 30, 0.55);
    padding: 1em;
}
.sg-preview[hidden] { display: none; }
.sg-preview-inner {
    position: relative;
    width: 100%;
    max-width: 820px;
    background: #fff;
    border-radius: 0.8em;
    padding: 1.4em 1.4em 1.6em;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.sg-preview-close {
    position: absolute;
    top: 0.4em; right: 0.6em;
    border: none; background: none;
    font-size: 1.8em; line-height: 1; color: #999; cursor: pointer;
}
.sg-preview-style { font-size: 0.9em; color: #666; margin-bottom: 0.6em; }
.sg-preview-canvas {
    border: 1px dashed rgba(120, 130, 140, 0.4);
    border-radius: 0.5em;
    background:
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%) 0 0/20px 20px,
        linear-gradient(45deg, #f0f0f0 25%, #fff 25%, #fff 75%, #f0f0f0 75%) 10px 10px/20px 20px;
    margin-bottom: 1em;
}
.sg-preview-canvas svg { display: block; width: 100%; height: 260px; }
.sg-preview-actions { display: flex; flex-wrap: wrap; gap: 0.6em; }

body.sg-modal-open { overflow: hidden; }
