/*! web-calculator.ru © 2022-2026 — авторский код, копирование запрещено. src:matematicheskie-kalkulatori/kalkulyator-ploschadi-trapecii.css */

.calculator {
  font-family: 'Unbounded', sans-serif;
  font-size: 16px;
  max-width: 720px;
  margin: 20px auto;
  padding: 20px;
  border: 1px solid rgb(224, 224, 224);
  border-radius: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  background-color: #fff;
}

/* Форма слева, чертёж справа: рисунок объясняет, какая сторона называется
   основанием, и нужен ДО ввода — здесь он не украшение, а часть условия */
.calc-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.calc-layout .calculator__form {
  flex: 1 1 auto;
  min-width: 0;
}

.calc-visual {
  flex: 0 0 200px;
  align-self: stretch;
}

.calc-visual #calc-svg {
  position: sticky;
  top: 16px;
}

.calc-visual svg {
  width: 100%;
  height: auto;
  display: block;
}

.calculator__input {
  font-size: inherit;
  width: 100%;
  padding: 26px 16px 10px;
  border: 1px solid #ccc;
  border-radius: 16px;
  box-sizing: border-box;
  margin: 0;
  background: #fff;
}

/* Ровно 16px и через id, иначе не перебивает inputs-style.css, который
   подключается после этого файла. Поле мельче 16px мобильный Safari считает
   поводом увеличить страницу при фокусе — форма прыгает под пальцем. */
#simple-calc .calculator__input {
  font-size: 16px;
}

#simple-calc .form-group {
  margin-bottom: 8px;
}

/* Поля попарно: в трапеции величины ходят парами — два основания,
   две боковые стороны, две диагонали. Одна колонка растянула бы форму
   на два экрана телефона. */
.trap-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.trap-fields .form-group {
  margin-bottom: 0 !important;
  min-width: 0;
}

.mode-hint {
  font-family: 'Unbounded', serif;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(0, 0, 0, 0.62);
  margin: 0 0 10px;
}

.mode-hint b {
  color: #000;
}

/* Разбор фигуры: строка «показатель — значение».
   Периметр, диагонали и углы считаются попутно, потому что запрос
   «площадь и периметр трапеции» люди задают одной фразой. */
.trap-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid #f0f0f0;
}

.trap-row:last-child {
  border-bottom: none;
}

.trap-row span {
  color: rgba(0, 0, 0, 0.62);
}

.trap-row b {
  color: #000;
  text-align: right;
  white-space: nowrap;
}

.trap-presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
  margin: 0 0 10px;
}

.trap-presets__label {
  font-family: 'Unbounded', serif;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.62);
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.trap-preset {
  font-family: 'Unbounded', serif;
  font-size: 12px;
  color: #000;
  background: #fff;
  border: 1px solid #DDD;
  border-radius: 16px;
  /* 40px — нижняя граница удобной цели пальцем */
  min-height: 40px;
  height: auto;
  width: auto;
  padding: 6px 10px;
  cursor: pointer;
  text-align: center;
  line-height: 1.25;
}

.trap-preset:hover {
  background: #f3f4f6;
}

.calc-params {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.calc-params > * {
  flex: 1;
  min-width: 0;
}

#simple-calc .calc-params .custom-select {
  margin-bottom: 0;
}

#simple-calc .btn-wrapper {
  margin-top: 0;
}

.calc-error {
  display: none;
  margin: 4px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fdeced;
  color: #b3261e;
  font-size: 13px;
  line-height: 1.4;
}

.calculator__buttons-container {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.calculator__buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 300px;
  height: 48px;
  padding: 0 24px;
  font-family: 'Unbounded', sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.15;
  border-radius: 16px;
  border: 1px solid #DDD;
  cursor: pointer;
  background-color: #000;
  color: #fff;
  text-align: center;
  box-sizing: border-box;
  transition: background-color 0.3s ease;
  margin: 0;
}

.calculator__buttons:hover {
  background-color: #333;
}

.button--gray {
  background-color: #fff;
  color: #000;
}

.button--gray:hover {
  background-color: #f1f1f1;
}

.calculator-wrapper #res-main {
  font-family: 'Unbounded', serif;
  font-size: 16px;
  line-height: 1.15;
  color: #000;
}

.calculator-wrapper #res-extra {
  font-family: 'Unbounded', serif;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(0, 0, 0, 0.7);
  margin-top: 10px;
}

.calculator-wrapper #res-steps {
  width: 100%;
  font-family: 'Unbounded', serif;
  font-size: 12px;
  line-height: 1.7;
  color: rgba(0, 0, 0, 0.7);
}

.calculator-wrapper #res-steps .pr-step {
  display: block;
  margin: 0 0 8px;
}

.calculator-wrapper #res-steps .pr-step:last-child {
  margin-bottom: 0;
}

.calculator-wrapper #res-steps .pr-step span,
.calculator-wrapper #res-steps .pr-step b {
  color: #000;
}

.calculator-wrapper .rz-chip {
  font-family: 'Unbounded', serif;
  font-size: 12px;
  color: #000;
  background: #fff;
  border: 1px solid #DDD;
  border-radius: 16px;
  height: 34px;
  padding: 0 14px;
  cursor: pointer;
  width: auto;
}

.calculator-wrapper .rz-chip:hover {
  background: #f3f4f6;
}

@media (max-width: 640px) {
  .calc-layout {
    flex-direction: column;
    align-items: stretch;
  }
  /* Чертёж поднимается НАД формой (в разметке он идёт после неё), в отличие
     от калькулятора пропорций: там схема повторяла содержимое полей, а здесь
     она показывает, что считать основанием, а что боковой стороной — без неё
     половина полей непонятна. Ширина 120px, чтобы не съесть первый экран. */
  .calc-visual {
    order: -1;
    flex: 0 0 auto;
    width: 120px;
    max-width: 120px;
    margin: 0 auto 2px;
  }
  .calc-visual #calc-svg {
    position: static;
  }
  .calculator {
    padding: 15px;
  }
  .calc-params {
    flex-direction: column;
    gap: 8px;
  }
  .calc-params > * {
    flex: none;
  }
  /* Кнопки в один ряд: в общем CSS сайта у кнопки width 100%, из-за чего
     во flex-строке они расходятся по одной и вдвоём съедают 150px высоты.
     ⚠ Направление задаём явно: контейнер на узком экране разворачивается
     в колонку, и тогда flex-basis 0 работает как ВЫСОТА — кнопки схлопываются
     в полоски по 25px. Ловится только скриншотом, в DOM всё на месте. */
  #simple-calc .btn-wrapper {
    flex-direction: row;
    align-items: center;
  }
  #simple-calc .calculator__buttons {
    min-width: 0;
    flex: 1 1 0;
    max-width: none;
    height: 48px;
    padding: 0 8px;
  }
  /* Вертикаль ужата, чтобы кнопка расчёта осталась в первом экране:
     на 390px запас до сгиба был 22px */
  .mode-hint {
    font-size: 11px;
    margin: 0 0 6px;
  }
  .trap-fields {
    gap: 6px;
    margin-bottom: 6px;
  }
  #simple-calc .form-group {
    margin-bottom: 6px;
  }
}

/* Таблицы описания: три колонки с формулами не сжимаются до ширины телефона —
   min-content таблицы 448px против 358px у контейнера, и страница получает
   горизонтальный скролл целиком. Разрешаем перенос внутри слов и уменьшаем
   шрифт: формулы всё равно переносятся по пробелам, break-word включается
   только там, где слово реально не влезает. */
@media (max-width: 640px) {
  .box.howto table {
    font-size: 12px;
    table-layout: fixed;
    width: 100%;
  }
  .box.howto table td {
    overflow-wrap: anywhere;   /* рвёт слово только когда иначе не влезает */
    padding-left: 6px;
    padding-right: 6px;
  }
}

@media (max-width: 360px) {
  /* Ниже 360px подпись «Боковая сторона c» в половине ширины уже режется */
  .trap-fields {
    grid-template-columns: 1fr;
  }
}
