/* ============================================================
   Калькулятор нарезки рельсовых направляющих.
   Подключается ТОЛЬКО на карточках направляющих (см. template.php).

   Наследник калькулятора со старого сайта: там он был мелкой ссылкой
   «Информация по заказу» внизу описания, и его никто не находил.
   Здесь — заметная кнопка и модалка в стиле нового сайта.
   ============================================================ */

:root {
    --rc-brand: #4fa44f;
    --rc-brand-dark: #3d8b3d;
    --rc-ink: #14181f;
    --rc-muted: #6b7280;
    --rc-line: #e6eaef;
    --rc-bg: #f6f8fa;
}

/* ─── Кнопка в карточке (под фотографией) ─────────────────── */
.rc-cta {
    display: inline-flex; align-items: center; gap: 10px; max-width: 100%;
    margin: 30px 0 0; padding: 12px 18px;
    border: 0; border-radius: 12px; cursor: pointer;
    font-family: inherit; text-align: left;
    color: #fff; background: linear-gradient(135deg, #4fa44f 0%, #3d8b3d 100%);
    box-shadow: 0 6px 18px -8px rgba(79, 164, 79, .8);
    transition: transform .18s ease, box-shadow .18s ease;
}
.rc-cta:hover { transform: translateY(-1px); box-shadow: 0 12px 24px -10px rgba(79, 164, 79, .9); }
.rc-cta:active { transform: translateY(0); }
.rc-cta__ico {
    flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px;
    background: rgba(255, 255, 255, .18);
    display: flex; align-items: center; justify-content: center;
}
.rc-cta__ico svg { width: 17px; height: 17px; stroke: #fff; fill: none; stroke-width: 1.8; }
.rc-cta__title { font-size: 14.5px; font-weight: 700; line-height: 1.2; }
.rc-cta__arrow { flex: 0 0 auto; font-size: 17px; opacity: .85; }
/* Аннотация под кнопкой: объясняет, что внутри, не раздувая саму кнопку */
.rc-cta__note { margin-top: 8px; max-width: 340px; font-size: 12.5px; line-height: 1.45; color: #8a9099; }

/* ─── Оверлей и окно ──────────────────────────────────────── */
.rc-overlay {
    position: fixed; inset: 0; z-index: 10000; display: none;
    align-items: flex-start; justify-content: center; padding: 24px 16px;
    background: rgba(12, 16, 22, .55);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    overflow-y: auto;
}
.rc-overlay.is-open { display: flex; animation: rcFade .22s ease both; }
@keyframes rcFade { from { opacity: 0; } to { opacity: 1; } }

/* 🔥 Было 860px и «просторные» отступы — окно не влезало в экран ноутбука
   целиком, приходилось скроллить до кнопок. Ужато до 700px и по всем
   блокам срезаны паддинги: содержимое то же, экран — один. */
.rc-modal {
    position: relative; width: 100%; max-width: 700px; margin: auto;
    background: #fff; border-radius: 20px; overflow: hidden;
    box-shadow: 0 40px 90px -30px rgba(8, 12, 20, .55);
    animation: rcRise .28s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes rcRise { from { transform: translateY(18px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }

.rc-close {
    position: absolute; top: 12px; right: 12px; z-index: 3;
    width: 32px; height: 32px; border: 0; border-radius: 50%; cursor: pointer;
    background: rgba(20, 24, 31, .06); color: #14181f; font-size: 18px; line-height: 1;
    transition: background .15s;
}
.rc-close:hover { background: rgba(20, 24, 31, .12); }

/* ─── Шапка (она же шапка сохраняемой картинки) ───────────── */
.rc-head {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    /* справа оставляем место под крестик — иначе он ложится на текст контактов */
    padding: 13px 58px 13px 20px; border-bottom: 1px solid var(--rc-line);
}
.rc-head__l h3 { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .12em;
    text-transform: uppercase; color: var(--rc-muted); }
.rc-head__name { margin-top: 4px; font-size: 17px; font-weight: 800; color: var(--rc-ink);
    font-variant-numeric: tabular-nums; }
.rc-head__r { text-align: right; font-size: 11.5px; line-height: 1.45; color: var(--rc-muted); }
.rc-head__r b { display: block; font-size: 13.5px; color: var(--rc-brand); margin-bottom: 2px; }

/* ─── Чертёж ──────────────────────────────────────────────── */
/* Снизу оставляем место под размеры E₁/E₂ — иначе они вылезают на поля ввода */
.rc-draw { padding: 30px 20px 38px; background:
    radial-gradient(120% 80% at 50% 0%, #fbfcfd 0%, #f4f6f8 100%); }
.rc-draw__stage { position: relative; max-width: 520px; margin: 0 auto; }

/* Рельс: тело + верхняя грань + ряд отверстий. Рисуем CSS, а не картинкой —
   отверстия должны переезжать вслед за расчётом. */
.rc-rail { position: relative; height: 48px; border-radius: 6px;
    background: linear-gradient(180deg, #e8ecf0 0%, #cfd6dd 42%, #aeb7c1 43%, #dfe4e9 100%);
    border: 1px solid #9aa4af; box-shadow: inset 0 1px 0 #fff; }
.rc-rail__holes { position: absolute; inset: 0; }
.rc-hole { position: absolute; top: 50%; width: 11px; height: 11px; margin: -6px 0 0 -5.5px;
    border-radius: 50%; background: radial-gradient(circle at 35% 30%, #6b7580, #2f3742);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .55), inset 0 1px 1px rgba(0,0,0,.6); }
/* Подсветка выбранного участка — тёмно-зелёная: бледно-салатовая рамка
   терялась на сером рельсе, каретку было не найти глазом. */
.rc-carriage { position: absolute; top: -6px; height: 60px; width: 92px;
    border-radius: 8px; background: linear-gradient(180deg, rgba(20, 67, 31, .18), rgba(20, 67, 31, .07));
    border: 2px solid #14431f; box-shadow: 0 0 0 3px rgba(20, 67, 31, .10); }

/* Размерные линии */
.rc-dim { position: absolute; display: flex; align-items: center; }
.rc-dim__line { flex: 1; height: 1px; background: var(--rc-ink); position: relative; }
.rc-dim__line:before, .rc-dim__line:after {
    content: ''; position: absolute; top: -3px; width: 7px; height: 7px;
    border-top: 1px solid var(--rc-ink); border-right: 1px solid var(--rc-ink);
}
.rc-dim__line:before { left: 0; transform: rotate(-135deg); }
.rc-dim__line:after  { right: 0; transform: rotate(45deg); }
.rc-dim--l { left: 0; right: 0; top: -28px; }
.rc-dim--e { bottom: -32px; }
.rc-dim__cap { position: absolute; left: 50%; transform: translateX(-50%);
    top: -10px; background: #f4f6f8; padding: 0 8px; font-size: 11.5px;
    font-weight: 700; color: var(--rc-ink); white-space: nowrap; }

/**
 * 🔥 У E₁/E₂ отрезок короткий — иногда 2% ширины, десяток пикселей.
 * Наклонные стрелки на такой длине сходятся и наезжают на подпись:
 * получается клякса вместо размера. Поэтому у краевых размеров
 * стрелки заменены вертикальными засечками, а подпись убрана под линию.
 */
.rc-dim--e .rc-dim__line { min-width: 14px; }
.rc-dim--e .rc-dim__line:before,
.rc-dim--e .rc-dim__line:after {
    transform: none; border: 0; width: 1px; height: 9px; top: -4px;
    background: var(--rc-ink);
}
.rc-dim--e .rc-dim__cap { top: 7px; background: transparent; padding: 0; }

/* ─── Поля ввода ──────────────────────────────────────────── */
.rc-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 16px 20px; }
.rc-field label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; color: var(--rc-muted); margin-bottom: 6px; }
.rc-field label span { text-transform: none; letter-spacing: 0; font-weight: 500; opacity: .8; }
.rc-input {
    width: 100%; box-sizing: border-box; padding: 11px 13px; font: inherit; font-size: 15.5px;
    font-weight: 700; font-variant-numeric: tabular-nums; color: var(--rc-ink);
    background: var(--rc-bg); border: 1.5px solid transparent; border-radius: 12px;
    transition: border-color .15s, background .15s;
}
.rc-input:focus { outline: none; background: #fff; border-color: var(--rc-brand); }
.rc-input.is-bad { border-color: #dc2626; background: #fef2f2; }
.rc-hint { margin-top: 5px; font-size: 11.5px; color: var(--rc-muted); }
.rc-hint.is-bad { color: #dc2626; font-weight: 600; }

/* ─── Итоги ───────────────────────────────────────────────── */
.rc-result { margin: 0 20px 16px; border: 1px solid var(--rc-line); border-radius: 14px; overflow: hidden; }
.rc-result__top { display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 13px 16px; background: linear-gradient(135deg, rgba(79,164,79,.10), rgba(79,164,79,.04)); }
.rc-result__lbl { font-size: 11px; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--rc-muted); }
.rc-result__val { font-size: 16.5px; font-weight: 800; color: var(--rc-ink);
    font-variant-numeric: tabular-nums; word-break: break-all; }
.rc-copy { flex: 0 0 auto; border: 1px solid var(--rc-line); background: #fff; color: var(--rc-ink);
    border-radius: 10px; padding: 8px 13px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.rc-copy:hover { border-color: var(--rc-brand); color: var(--rc-brand-dark); }

/* 🔥 Двенадцать строк в один столбец растягивали окно на полтора экрана.
   Раскладываем таблицу в две колонки: tbody становится гридом, строка —
   его ячейкой. Разметку в JS при этом не трогаем. */
.rc-table { width: 100%; display: block; font-size: 13px; }
.rc-table tbody { display: grid; grid-template-columns: 1fr 1fr; }
.rc-table tr {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    padding: 7px 16px; border-top: 1px solid var(--rc-line);
}
.rc-table tr:nth-child(odd) { border-right: 1px solid var(--rc-line); }
/* зебра по ВИДИМЫМ строкам: пара ячеек — одна полоса */
.rc-table tr:nth-child(4n+1), .rc-table tr:nth-child(4n+2) { background: #fafbfc; }
.rc-table td { display: block; padding: 0; border: 0; }
.rc-table td:last-child { text-align: right; font-weight: 700; color: var(--rc-ink);
    font-variant-numeric: tabular-nums; white-space: nowrap; }
.rc-table td:first-child { color: var(--rc-muted); }

/* ─── Действия ────────────────────────────────────────────── */
/* Кнопка сохранения — справа: она вторична по отношению к отправке заявки,
   и левый край занимает основное действие в форме выше. */
.rc-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 0 20px 16px; }
.rc-btn { border: 0; border-radius: 12px; padding: 11px 18px; font: inherit; font-size: 14px;
    font-weight: 700; cursor: pointer; transition: background .15s, transform .12s; }
.rc-btn:active { transform: translateY(1px); }
.rc-btn--main { background: var(--rc-brand); color: #fff; flex: 1 1 240px; }
.rc-btn--main:hover { background: var(--rc-brand-dark); }
.rc-btn--ghost { background: var(--rc-bg); color: var(--rc-ink); }
.rc-btn--ghost:hover { background: #eef1f4; }
.rc-note { padding: 0 20px 18px; font-size: 12px; line-height: 1.5; color: var(--rc-muted); }

/* ─── Форма заявки ────────────────────────────────────────── */
.rc-form { margin: 0 20px 12px; padding: 14px 16px; border-radius: 14px; background: var(--rc-bg); }
.rc-form__head { font-size: 14px; font-weight: 700; color: var(--rc-ink); margin-bottom: 10px; }
.rc-form__row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; }
.rc-form__row .rc-input { background: #fff; font-size: 15px; font-weight: 500; }
.rc-form__agree { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px;
    font-size: 12.5px; line-height: 1.45; color: var(--rc-muted); cursor: pointer; }
.rc-form__agree input { margin-top: 2px; accent-color: var(--rc-brand); }
.rc-form__msg { margin-top: 8px; font-size: 13px; font-weight: 600; min-height: 18px; }
.rc-form__note { margin-top: 4px; font-size: 12.5px; color: var(--rc-muted); }
@media (max-width: 640px) {
    .rc-form { margin: 0 20px 20px; }
    .rc-form__row { grid-template-columns: 1fr; }
}

/* Подпись — только в сохранённой картинке, на экране не нужна */
.rc-stamp { display: none; padding: 14px 26px; border-top: 1px solid var(--rc-line);
    font-size: 12px; color: var(--rc-muted); text-align: center; }
.rc-modal.is-shooting .rc-stamp { display: block; }

/* Интерфейс в кадре не нужен: картинку уносят в переписку и в закупку, а
   поля ввода и кнопки там уже ничего не делают.
   🔥 display:none, а не visibility:hidden — скрытая форма оставляла в PNG
   пустую плашку на треть высоты. Класс вешается только на КЛОН документа
   внутри html2canvas, поэтому окно на экране при съёмке не дёргается. */
.rc-modal.is-shooting .rc-close,
.rc-modal.is-shooting .rc-form,
.rc-modal.is-shooting .rc-actions { display: none; }

@media (max-width: 640px) {
    /* на телефоне две колонки не помещаются — возвращаем список */
    .rc-table tbody { grid-template-columns: 1fr; }
    .rc-table tr:nth-child(odd) { border-right: 0; }
    .rc-table tr:nth-child(4n+2) { background: none; }
    .rc-table tr:nth-child(4n+3) { background: #fafbfc; }
    .rc-fields { grid-template-columns: 1fr; gap: 12px; padding: 16px 20px; }
    .rc-head { flex-direction: column; align-items: flex-start; gap: 10px; padding: 20px; }
    .rc-head__r { text-align: left; }
    .rc-result { margin: 0 20px 18px; }
    .rc-actions { padding: 0 20px 20px; }
    /* нижний отступ обязан вмещать размеры E₁/E₂ (bottom:-32px), иначе они
       уезжают под поля ввода */
    .rc-draw { padding: 22px 16px 34px; }
}
