/*
 * Калькулятор 1ПМ (page-templates/calculator.php): форма підходу, результат,
 * таблиці робочих ваг. Текст під калькулятором — типографіка статті (journal.css).
 *
 * Сітка: комп’ютер — форма ліворуч на всю висоту, праворуч результат і таблиці;
 * планшет — форма й результат поруч, таблиці під ними; телефон — одна колонка.
 */
.calc-head .page-head { padding-bottom: 20px; }
.calc-lifts { margin-top: 20px; }
.calc { padding: 4px 0 56px; }
.calc-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); grid-template-areas: "form result" "form tables"; grid-template-rows: auto 1fr; gap: 24px; align-items: start; }
.calc-form { grid-area: form; }
.calc-result { grid-area: result; }
.calc-tables { grid-area: tables; }

/* Форма */
.calc-form { display: grid; gap: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.calc-h { font-size: 21px; }
.calc-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: end; }
.calc-field { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.calc-field > legend { padding: 0; margin-bottom: 8px; font-size: 14.5px; font-weight: 600; }
.calc-label-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 34px; }
.calc-label-row > label { font-size: 14.5px; font-weight: 600; }
.calc-label-row small { font-weight: 400; color: var(--muted); }
.calc-field .hint { font-size: 13.5px; color: var(--muted); line-height: 1.45; }

.calc-input { position: relative; }
.calc-input input { width: 100%; min-height: 56px; border: 1px solid var(--control); border-radius: var(--radius-s); background: #fff; padding: 0 52px 0 14px; font-family: var(--font-head); font-size: 24px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.calc-input-sm input { min-height: 48px; font-family: var(--font-body); font-size: 16px; font-weight: 500; letter-spacing: 0; }
.calc-suffix { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }
.calc-input input[aria-invalid="true"], .calc-qty:has(input[aria-invalid="true"]) { border: 2px solid var(--error); background: var(--error-soft); }

/* Кількість повторень: − число + */
.calc-qty { display: inline-grid; grid-template-columns: 48px 56px 48px; height: 56px; border: 1px solid var(--control); border-radius: var(--radius-s); background: #fff; }
.calc-qty button { display: grid; place-items: center; border: 0; background: none; color: var(--ink); }
.calc-qty button:hover { background: var(--subtle); }
.calc-qty button svg { width: 18px; height: 18px; }
.calc-qty input { width: 100%; min-width: 0; border: 0; border-inline: 1px solid var(--line); background: none; text-align: center; font-family: var(--font-head); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.calc-qty input::-webkit-outer-spin-button, .calc-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.calc-qty input[aria-invalid="true"] { background: none; border-block: 0; }

/* Перемикачі: одиниці й запас повторень */
.calc-seg { display: flex; gap: 6px; margin: 0; padding: 0; border: 0; }
.calc-seg label { position: relative; cursor: pointer; }
.calc-seg input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.calc-seg span { display: flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; font-size: 14.5px; font-weight: 500; white-space: nowrap; transition: background-color .15s, border-color .15s; }
.calc-seg label:hover span { border-color: var(--ink); }
.calc-seg input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
.calc-seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.calc-units { gap: 0; }
.calc-units span { min-height: 34px; min-width: 44px; padding: 0 10px; font-size: 13.5px; }
.calc-units label:first-of-type span { border-radius: var(--radius-s) 0 0 var(--radius-s); }
.calc-units label:last-of-type span { border-radius: 0 var(--radius-s) var(--radius-s) 0; margin-left: -1px; }
.calc-rir { display: grid; grid-template-columns: minmax(0, 1.7fr) repeat(3, minmax(0, 1fr)); }
.calc-rir span { padding: 0 8px; }

.calc-err { display: flex; gap: 8px; align-items: center; color: var(--error); font-size: 14px; font-weight: 600; }
.calc-err svg { width: 18px; height: 18px; flex: none; }
.calc-err[hidden] { display: none; }

/* Результат */
.calc-result { background: var(--ink); color: #F1F1EA; border-radius: var(--radius); padding: 26px 28px 28px; }
.calc-tag { font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #C9CCC2; }
.calc-one { margin-top: 10px; font-family: var(--font-head); font-size: clamp(48px, 6vw, 72px); font-weight: 800; line-height: 1; letter-spacing: -.035em; color: var(--accent); font-variant-numeric: tabular-nums; }
.calc-range { margin-top: 12px; color: #DADCD4; }
.calc-ratio { margin-top: 4px; font-weight: 600; }
.calc-ratio[hidden], .calc-warn[hidden] { display: none; }
.calc-warn { display: flex; gap: 10px; margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-s); background: rgba(255, 255, 255, .09); font-size: 14.5px; line-height: 1.45; }
.calc-warn svg { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--accent); }
.calc-result.is-stale .calc-one, .calc-result.is-stale .calc-range, .calc-result.is-stale .calc-ratio { opacity: .4; }
.calc-tables.is-stale tbody, .calc-tables.is-stale tfoot { opacity: .4; }

/* Таблиці */
.calc-tables { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 24px 16px; }
.calc-tabs { display: flex; gap: 4px; margin: 0 -24px; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.calc-tabs[hidden] { display: none; }
.calc-tabs [role="tab"] { flex: none; min-height: 52px; padding: 0 12px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); font-weight: 600; font-size: 15px; }
.calc-tabs [role="tab"]:hover { color: var(--ink); }
.calc-tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.calc-panel:focus-visible { outline-offset: 4px; }
.calc-panel[hidden] { display: none; }
.calc-panel + .calc-panel { margin-top: 20px; }
.calc-table { width: 100%; border-collapse: collapse; font-size: 15.5px; font-variant-numeric: tabular-nums; }
.calc-table caption { padding: 16px 0 8px; text-align: left; font-size: 13.5px; color: var(--muted); }
.calc-table th, .calc-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.calc-table th:first-child, .calc-table td:first-child { padding-left: 0; }
.calc-table thead th { padding-top: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.calc-table tbody th { font-weight: 600; }
.calc-table td[data-w], .calc-table td[data-calc-mean] { font-family: var(--font-head); font-weight: 700; white-space: nowrap; }
.calc-table tr.is-mine th, .calc-table tr.is-mine td { background: var(--accent-soft); }
.calc-table tr.is-mine th:first-child { box-shadow: -8px 0 0 var(--accent-soft); }
.calc-table small { margin-left: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.calc-table small[hidden] { display: none; }
.calc-formulas tbody th { font-weight: 600; }
.calc-formulas code { display: block; margin-top: 2px; font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); overflow-wrap: anywhere; }
.calc-formulas .badge { margin-left: 6px; vertical-align: 1px; }
.calc-formulas tfoot th, .calc-formulas tfoot td { border-bottom: 0; font-weight: 800; }
.calc-note { margin-top: 10px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.calc-round { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 8px; font-size: 14.5px; cursor: pointer; }
.calc-round[hidden] { display: none; }
.calc-round input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); flex: none; }

/* Після калькулятора */
.calc-text { padding-top: 8px; }
.calc-text .page-body { padding-bottom: 0; }
.calc-cats { margin-top: 24px; }

/* Високий екран комп’ютера: форма лишається поруч, поки гортаєте таблиці (шапка сайту — 126 px). */
@media (min-width: 1100px) and (min-height: 760px) {
  .calc-form { position: sticky; top: 150px; }
}
@media (max-width: 1099px) {
  .calc-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "form result" "tables tables"; grid-template-rows: auto auto; }
  .calc-result { align-self: start; }
}
@media (max-width: 767px) {
  .calc-head .page-head { padding: 12px 0 16px; }
  .calc-head .lead { font-size: 16.5px; margin-top: 10px; }
  /* Вправи — одним рядком із прокруткою, щоб форма була ближче до першого екрана. */
  .calc-lifts { flex-wrap: nowrap; overflow-x: auto; margin: 16px calc(-1 * var(--pad)) 0; padding: 2px var(--pad); scrollbar-width: none; }
  .calc-lifts::-webkit-scrollbar { display: none; }
  .calc-lifts li { flex: none; }
  .calc { padding-bottom: 40px; }
  .calc-pair { grid-template-columns: minmax(0, 1fr); }
  .calc-qty { width: 100%; grid-template-columns: 56px minmax(0, 1fr) 56px; }
  .calc-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "form" "result" "tables"; gap: 16px; }
  .calc-form { padding: 18px; gap: 18px; }
  .calc-result { padding: 20px; }
  .calc-tables { padding: 0 16px 12px; }
  .calc-tabs { margin: 0 -16px; padding: 0 8px; }
  .calc-tabs [role="tab"] { padding: 0 10px; }
  .calc-table { font-size: 15px; }
  .calc-table th, .calc-table td { padding: 9px 6px; }
}
@media (max-width: 360px) {
  .calc-rir { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .calc-rir label:first-child { grid-column: 1 / -1; }
}
