/* ==========================================================================
   CALQ — base.css
   Токены, сброс, «лист»-оболочка, шапка, титульный блок, типографика.
   Проект: calculator.gitiox.com · ревизия 4.2
   ========================================================================== */

:root {
  /* светлая сталь / графит */
  --paper: #eef0e9;
  --paper-2: #e4e7dd;
  --paper-3: #f7f8f3;
  --ink: #191d1f;
  --ink-2: #3b4245;
  --ink-3: #5a6260;
  --rule: #bfc5bb;
  --rule-2: #d3d8ce;
  --acid: #b7f22c;
  --acid-2: #98d400;
  --acid-wash: rgba(183, 242, 44, 0.26);
  --table: #1d2125;
  --white: #fbfcf7;

  --gutter: clamp(24px, 3.3vw, 54px);
  --gap: clamp(18px, 2.4vw, 34px);

  --display: "HelveticaNeue-CondensedBlack", "Helvetica Neue Condensed Black",
    "HelveticaNeue-CondensedBold", "Helvetica Neue Condensed Bold",
    "Helvetica Neue", Impact, "Franklin Gothic Medium", "Nimbus Sans Narrow",
    "Liberation Sans Narrow", "DejaVu Sans Condensed", sans-serif;
  --serif: "Palatino Linotype", "Book Antiqua", Palatino, "URW Palladio L",
    "P052", Georgia, serif;
  --mono: "SF Mono", "SFMono-Regular", ui-monospace, "JetBrains Mono",
    "IBM Plex Mono", Menlo, "Cascadia Mono", Consolas, "DejaVu Sans Mono",
    monospace;

  --shadow: 6px 6px 0 rgba(25, 29, 31, 0.09);
  --shadow-sm: 3px 3px 0 rgba(25, 29, 31, 0.1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  padding: clamp(0px, 2.3vw, 32px);
  background-color: var(--table);
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.038) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.038) 1px, transparent 1px),
    radial-gradient(120% 80% at 50% 0%, rgba(255, 255, 255, 0.05), transparent 60%);
  background-size: 12px 12px, 12px 12px, 100% 100%;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.62;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

@media (max-width: 760px) {
  body { padding: 0; background-image: none; }
}

img, svg { display: block; max-width: 100%; }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 400;
  font-stretch: condensed;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0 0 1.1em; }
p:last-child { margin-bottom: 0; }

a { color: inherit; }

::selection { background: var(--acid); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(183, 242, 44, 0.5);
  border-radius: 1px;
}

/* --------------------------------------------------------------------------
   Лист на чертёжном столе
   -------------------------------------------------------------------------- */

.sheet {
  position: relative;
  max-width: 1468px;
  margin: 0 auto;
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, rgba(25, 29, 31, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(25, 29, 31, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(25, 29, 31, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(25, 29, 31, 0.06) 1px, transparent 1px);
  background-size: 8px 8px, 8px 8px, 40px 40px, 40px 40px;
  background-position: 0 0, 0 0, 0 0, 0 0;
  border: 1px solid #101315;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55), 0 2px 0 rgba(255, 255, 255, 0.05) inset;
  isolation: isolate;
}

/* внутренняя рамка листа */
.sheet::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid var(--rule);
  pointer-events: none;
  z-index: 0;
}

/* зерно бумаги */
.sheet::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.28;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.16'/%3E%3C/svg%3E");
}

.frame {
  position: relative;
  z-index: 2;
  padding: clamp(26px, 3vw, 48px);
  padding-top: clamp(22px, 2.4vw, 38px);
}

@media (max-width: 760px) {
  .sheet { border: 0; box-shadow: none; }
  .frame { padding: 20px 16px 26px; }
}

/* реперные крестики по углам листа */
.sheet .marks {
  position: absolute;
  inset: -1px;
  z-index: 3;
  pointer-events: none;
  background-image:
    var(--cross), var(--cross), var(--cross), var(--cross);
  background-repeat: no-repeat;
  background-size: 13px 13px;
  background-position: 2px 2px, calc(100% - 2px) 2px, 2px calc(100% - 2px),
    calc(100% - 2px) calc(100% - 2px);
  --cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13'%3E%3Cpath d='M6.5 0v13M0 6.5h13' stroke='%235a6260' stroke-width='1'/%3E%3C/svg%3E");
}

@media (max-width: 760px) { .sheet .marks { display: none; } }

/* вертикальная полоса «стола» */
.table-rail {
  display: none;
}

@media (min-width: 1240px) {
  .table-rail {
    display: block;
    position: fixed;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 30;
    writing-mode: vertical-rl;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.36em;
    text-transform: uppercase;
    color: rgba(238, 240, 233, 0.34);
    pointer-events: none;
    white-space: nowrap;
  }
}

/* --------------------------------------------------------------------------
   Сетка контента
   -------------------------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: 1290px;
  margin: 0 auto;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--acid);
  color: var(--ink);
  padding: 10px 16px;
  font: 600 11px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid var(--ink);
}
.skip:focus { left: 12px; top: 12px; }

/* --------------------------------------------------------------------------
   Шапка листа
   -------------------------------------------------------------------------- */

.head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: clamp(12px, 3vw, 34px);
  padding: 12px 0 13px;
  margin: calc(-1 * clamp(22px, 2.4vw, 38px)) 0 0;
  background: rgba(238, 240, 233, 0.93);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--ink);
}

@media (max-width: 760px) {
  .head { margin: -20px 0 0; padding-top: 14px; flex-wrap: wrap; row-gap: 10px; }
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  flex: 0 0 auto;
}

.brand__mark { width: 26px; height: 26px; flex: 0 0 auto; }
.brand__mark rect, .brand__mark circle, .brand__mark path { vector-effect: non-scaling-stroke; }

.brand__word {
  font-family: var(--display);
  font-size: 23px;
  line-height: 1;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  transform: translateY(1px);
}

.brand__ver {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  align-self: flex-start;
  padding-top: 2px;
}

.head__nav {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2.2vw, 28px);
  margin-left: auto;
  flex-wrap: wrap;
}

.navlink {
  position: relative;
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-2);
  padding: 5px 0 4px;
  white-space: nowrap;
}

.navlink::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.28s cubic-bezier(0.22, 0.68, 0.2, 1);
}

.navlink:hover { color: var(--ink); }
.navlink:hover::after { transform: scaleX(1); background: var(--ink); }

.navlink[aria-current="page"] { color: var(--ink); }
.navlink[aria-current="page"]::after {
  transform: scaleX(1);
  height: 2px;
  bottom: -1px;
  background: var(--ink);
  box-shadow: 0 2px 0 var(--acid);
}

.head__meta {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-left: clamp(10px, 2vw, 26px);
  border-left: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}

.head__meta b { color: var(--ink); font-weight: 500; }

.livedot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
}
.livedot::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--acid-2);
  border: 1px solid var(--ink);
  animation: pulse 2.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (max-width: 980px) {
  .head__meta { display: none; }
  .head__nav { margin-left: auto; }
}

@media (max-width: 520px) {
  .head__nav { width: 100%; margin-left: 0; justify-content: space-between; gap: 8px; }
  .navlink { font-size: 10px; letter-spacing: 0.1em; }
}

/* --------------------------------------------------------------------------
   Типографика
   -------------------------------------------------------------------------- */

.lbl {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 14px;
}

.kicker__sq {
  width: 8px;
  height: 8px;
  background: var(--acid);
  border: 1px solid var(--ink);
  flex: 0 0 auto;
}

.kicker__sep { color: var(--rule); }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.deck {
  font-family: var(--serif);
  font-size: clamp(16.5px, 1.35vw, 19.5px);
  line-height: 1.58;
  color: var(--ink-2);
  max-width: 46ch;
}

.deck--wide { max-width: 62ch; }

.small { font-size: 13.5px; line-height: 1.55; color: var(--ink-3); }

.serif-i { font-family: var(--serif); font-style: italic; }

/* маркер */
.hl {
  background: var(--acid);
  color: var(--ink);
  padding: 0 0.08em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* размерная линия с концами-засечками */
.dim {
  position: relative;
  height: 16px;
  margin: 22px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  --tick: rgba(25, 29, 31, 0.55);
}
.dim::before, .dim::after {
  content: "";
  position: absolute;
  top: 50%;
  height: 1px;
  background: var(--rule);
  left: 0;
  right: 0;
}
.dim > span {
  position: relative;
  padding: 0 14px;
  background: var(--paper);
  z-index: 1;
}
.dim > span::before, .dim > span::after {
  content: "";
  position: absolute;
  top: -5px;
  width: 1px;
  height: 11px;
  background: var(--tick);
}
.dim > span::before { left: 0; }
.dim > span::after { right: 0; }

/* --------------------------------------------------------------------------
   Кнопки, ссылки, метки
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 20px 12px;
  border: 1.5px solid var(--ink);
  background: var(--acid);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
  cursor: pointer;
}
.btn:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.btn svg { width: 15px; height: 15px; flex: 0 0 auto; }

.btn--ghost {
  background: transparent;
  box-shadow: none;
  border-color: var(--ink);
  color: var(--ink);
}
.btn--ghost:hover {
  background: var(--acid-wash);
  transform: none;
  box-shadow: none;
}
.btn--ghost:active { transform: none; }

.btn--dark { background: var(--ink); color: var(--paper); box-shadow: 4px 4px 0 rgba(183, 242, 44, 0.9); }
.btn--dark:hover { box-shadow: 2px 2px 0 rgba(183, 242, 44, 0.9); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px 2px;
  border: 1px solid var(--rule);
  background: var(--paper-3);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
}
.tag--acid { background: var(--acid); border-color: var(--ink); color: var(--ink); }
.tag--ink { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--acid-2);
  border: 1px solid var(--ink);
  flex: 0 0 auto;
}

/* тексты-ссылки */
.tlink {
  color: var(--ink);
  text-decoration: none;
  background-image: linear-gradient(var(--acid), var(--acid));
  background-repeat: no-repeat;
  background-size: 100% 0.42em;
  background-position: 0 0.72em;
  transition: background-size 0.2s ease, background-position 0.2s ease;
  padding-bottom: 1px;
}
.tlink:hover {
  background-size: 100% 0.95em;
  background-position: 0 0.28em;
}

.arrow-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 4px;
}
.arrow-link svg { width: 13px; height: 13px; transition: transform 0.2s ease; }
.arrow-link:hover svg { transform: translateX(4px); }

/* --------------------------------------------------------------------------
   Секции
   -------------------------------------------------------------------------- */

.sec {
  padding: clamp(34px, 4.6vw, 66px) 0;
  border-top: 1px solid var(--rule);
}
.sec:first-of-type { border-top: 0; }

.sec-head {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: clamp(12px, 2vw, 26px);
  margin-bottom: clamp(22px, 3vw, 38px);
}

.sec-no {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 5px 4px;
  text-align: center;
  background: var(--paper-3);
  align-self: start;
  transform: translateY(-2px);
}

.sec-title {
  font-size: clamp(26px, 3.2vw, 43px);
  line-height: 0.94;
  letter-spacing: 0.005em;
  text-transform: uppercase;
}

.sec-note {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .sec-head { grid-template-columns: 44px minmax(0, 1fr); }
  .sec-note { grid-column: 2; text-align: left; white-space: normal; }
  .sec-no { font-size: 9px; }
}

/* --------------------------------------------------------------------------
   Титульный блок в подвале
   -------------------------------------------------------------------------- */

.foot { margin-top: clamp(34px, 5vw, 62px); }

.tb {
  border: 1px solid var(--ink);
  background: var(--paper-3);
}
.tb-row {
  display: grid;
  border-bottom: 1px solid var(--ink);
}
.tb-row:last-child { border-bottom: 0; }
.tb-row--4 { grid-template-columns: 2.3fr 1fr 1fr 1fr; }
.tb-row--3 { grid-template-columns: 2.3fr 1fr 2fr; }
.tb-row--2 { grid-template-columns: 2.3fr 3fr; }

.tb-cell {
  padding: 9px 12px 10px;
  border-right: 1px solid var(--ink);
  min-width: 0;
}
.tb-cell:last-child { border-right: 0; }

.tb-cell--brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.tb-brand__word {
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
}

.tb-brand__sub {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  line-height: 1.35;
  margin-left: 2px;
}

.tb-k {
  display: block;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}

.tb-v {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.tb-v--lg { font-size: 13px; }

.tb-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding-top: 11px;
  padding-bottom: 11px;
}
.tb-links a { text-decoration: none; border-bottom: 1px solid transparent; padding-bottom: 1px; }
.tb-links a:hover { border-color: var(--ink); background: var(--acid-wash); }

.tb-note {
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.65;
  letter-spacing: 0.03em;
  color: var(--ink-3);
  padding-top: 11px;
  padding-bottom: 11px;
}

.colophon {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 24px;
  padding: 10px 2px 0;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

@media (max-width: 900px) {
  .tb-row--4 { grid-template-columns: 1.6fr 1fr 1fr; }
  .tb-row--4 .tb-cell:nth-child(4) { display: none; }
  .tb-row--3 { grid-template-columns: 1fr 1fr; }
  .tb-row--3 .tb-cell:nth-child(3) { grid-column: 1 / -1; border-right: 0; border-top: 1px solid var(--ink); }
}

@media (max-width: 620px) {
  .tb-row--4, .tb-row--3, .tb-row--2 { grid-template-columns: 1fr 1fr; }
  .tb-row--4 .tb-cell--brand { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid var(--ink); }
  .tb-row--4 .tb-cell:nth-child(2) { border-right: 1px solid var(--ink); }
  .tb-cell:nth-child(2n) { border-right: 0; }
  .tb-row--2 .tb-cell { border-right: 0; }
  .tb-row--2 .tb-cell:first-child { border-bottom: 1px solid var(--ink); }
}

/* --------------------------------------------------------------------------
   Общие мелочи
   -------------------------------------------------------------------------- */

.hair { height: 1px; background: var(--rule); border: 0; margin: 0; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* появление */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: rise 0.75s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
.reveal--1 { animation-delay: 0.06s; }
.reveal--2 { animation-delay: 0.14s; }
.reveal--3 { animation-delay: 0.22s; }
.reveal--4 { animation-delay: 0.3s; }

@keyframes rise {
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

@media print {
  body { background: #fff; padding: 0; }
  .sheet { box-shadow: none; border: 0; }
  .head { position: static; }
  .table-rail, .marks { display: none; }
}
