/* ============================================================
   FLAT360 — «Чертёж на крафте»
   Design tokens + blueprint/kraft utilities
   ============================================================ */

:root {
  /* Paper / kraft */
  --kraft:        #E7DECB;   /* base section bg */
  --kraft-2:      #EFE7D6;   /* lighter alt section */
  --kraft-deep:   #DDD2BA;   /* darker card / strip */
  --paper:        #F6F1E6;   /* near-white "clean" sheet */
  --scan:         #FBF8F1;   /* scanned sheet white */

  /* Ink */
  --graphite:     #22201C;   /* primary text */
  --graphite-2:   #4A463E;   /* secondary text */
  --graphite-3:   #837C6C;   /* muted / mono captions */
  --hairline:     #C7BCA3;   /* drawn lines on kraft */

  /* Blueprint */
  --blue:         #1F3A5F;   /* drafting lines, schemes */
  --blue-soft:    rgba(31, 58, 95, 0.16);
  --blue-grid:    rgba(31, 58, 95, 0.07);

  /* Accent — terracotta (single accent) */
  --terra:        #C75B33;
  --terra-deep:   #A8431F;
  --terra-soft:   rgba(199, 91, 51, 0.12);

  /* Success / benefit marker */
  --green:        #5A7D5A;
  --green-soft:   rgba(90, 125, 90, 0.14);

  /* Calm accent surfaces */
  --sage:         #E8EDE4;   /* muted green paper */
  --sky:          #E7EDF2;   /* muted blue paper */

  /* Type */
  --f-head: "Space Grotesk", "Manrope", system-ui, sans-serif;
  --f-body: "Manrope", system-ui, sans-serif;
  --f-mono: "Space Mono", "JetBrains Mono", ui-monospace, monospace;

  /* Rhythm */
  --maxw: 1240px;
  --gut: clamp(18px, 5vw, 64px);
  --radius: 2px;

  --shadow-sheet: 0 1px 0 rgba(34,32,28,.04), 0 18px 34px -22px rgba(34,32,28,.55);
  --shadow-card: 0 12px 26px -20px rgba(34,32,28,.5);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--f-body);
  color: var(--graphite);
  background: var(--kraft);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- Paper grain overlay (whole page) ---- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: .5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url%28%23n%29' opacity='0.5'/%3E%3C/svg%3E");
}

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

::selection { background: var(--terra); color: #fff; }

/* Focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

/* ============================================================
   Layout
   ============================================================ */
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding-inline: var(--gut); }

section { position: relative; z-index: 2; }

.section-pad { padding-block: clamp(46px, 6.5vw, 88px); }

.bg-kraft   { background: var(--kraft); }
.bg-kraft-2 { background: var(--kraft-2); }
.bg-paper   { background: var(--paper); }
.bg-blue    { background: var(--blue); color: var(--paper); }
.bg-sage    { background: var(--sage); }
.bg-sky     { background: var(--sky); }

/* soft dotted texture for chosen sections */
.dot-bg {
  background-image: radial-gradient(var(--blue-grid) 1.4px, transparent 1.5px);
  background-size: 22px 22px;
}
.sage-dot-bg {
  background-color: var(--sage);
  background-image: radial-gradient(rgba(90,125,90,.16) 1.4px, transparent 1.5px);
  background-size: 22px 22px;
}

/* faint blueprint grid background for chosen sections */
.grid-bg {
  background-image:
    linear-gradient(var(--blue-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--blue-grid) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* ============================================================
   Typography
   ============================================================ */
h1, h2, h3, h4 { font-family: var(--f-head); font-weight: 700; letter-spacing: -0.02em; line-height: 1.04; margin: 0; color: var(--graphite); }

.h1 { font-size: clamp(34px, 6.4vw, 68px); font-weight: 700; }
.h2 { font-size: clamp(28px, 4.6vw, 50px); }
.h3 { font-size: clamp(21px, 2.6vw, 30px); }

.lead { font-size: clamp(17px, 1.9vw, 21px); color: var(--graphite-2); line-height: 1.5; }

.mono { font-family: var(--f-mono); }
.mono-cap {
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--graphite-3);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--f-mono);
  font-size: 12.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--blue);
}
.eyebrow::before {
  content: "";
  width: 26px; height: 1px;
  background: var(--blue);
  display: inline-block;
}

.text-terra { color: var(--terra); }
.text-blue  { color: var(--blue); }
.text-green { color: var(--green); }
.text-muted { color: var(--graphite-2); }

.balance { text-wrap: balance; }
.pretty  { text-wrap: pretty; }

/* terracotta hand-underline */
.u-mark { position: relative; white-space: nowrap; }
.u-mark::after {
  content: "";
  position: absolute;
  left: -2px; right: -2px; bottom: -2px;
  height: 8px;
  background: var(--terra);
  opacity: .22;
  border-radius: 6px;
  transform: rotate(-.6deg);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  --bg: var(--terra);
  --fg: #fff;
  font-family: var(--f-head);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px 26px;
  min-height: 52px;
  background: var(--bg);
  color: var(--fg);
  border: 1.5px solid var(--terra-deep);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
  box-shadow: 3px 3px 0 var(--terra-deep);
}
.btn:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--terra-deep); }
.btn:active { transform: translate(2px,2px); box-shadow: 0 0 0 var(--terra-deep); }

.btn--ghost {
  --bg: transparent; --fg: var(--graphite);
  border: 1.5px solid var(--graphite);
  box-shadow: 3px 3px 0 rgba(34,32,28,.22);
}
.btn--ghost:hover { background: rgba(34,32,28,.05); box-shadow: 4px 4px 0 rgba(34,32,28,.22); }
.btn--ghost:active { box-shadow: 0 0 0 rgba(34,32,28,.22); }

.btn--blue { --bg: var(--blue); --fg: var(--paper); border-color: #142845; box-shadow: 3px 3px 0 #142845; }
.btn--blue:hover { box-shadow: 4px 4px 0 #142845; }
.btn--green { --bg: var(--green); --fg: #fff; border-color: #3f5c3f; box-shadow: 3px 3px 0 #3f5c3f; }
.btn--green:hover { box-shadow: 4px 4px 0 #3f5c3f; }
.btn--sm { min-height: 44px; padding: 11px 18px; font-size: 14.5px; }
.btn--lg { min-height: 58px; padding: 18px 34px; font-size: 18px; }
.btn--block { display: flex; width: 100%; }

/* ============================================================
   Stamp (rubber-stamp / oттиск)
   ============================================================ */
.stamp {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--blue);
  border: 1.5px solid var(--blue);
  border-radius: 3px;
  padding: 7px 12px 6px;
  background: transparent;
  line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(31,58,95,.06);
  opacity: .92;
}
.stamp b { font-family: var(--f-head); font-weight: 700; font-size: 14px; letter-spacing: 0; }
.stamp--terra { color: var(--terra); border-color: var(--terra); box-shadow: inset 0 0 0 2px rgba(199,91,51,.07); }
.stamp--green { color: var(--green); border-color: var(--green); box-shadow: inset 0 0 0 2px rgba(90,125,90,.08); }
.stamp--tilt { transform: rotate(-3deg); }
.stamp--tilt2 { transform: rotate(2deg); }

/* big circular stamp */
.stamp-seal {
  font-family: var(--f-mono);
  text-transform: uppercase;
  display: grid;
  place-items: center;
  text-align: center;
  width: 116px; height: 116px;
  border-radius: 50%;
  border: 2px solid var(--terra);
  color: var(--terra);
  letter-spacing: .08em;
  line-height: 1.25;
  font-size: 11px;
  padding: 12px;
  box-shadow: inset 0 0 0 4px rgba(199,91,51,.08);
  opacity: .9;
}

/* ============================================================
   Title block frame (чертёжный штамп с номером листа)
   ============================================================ */
.titleblock {
  position: relative;
  border: 1.5px solid var(--graphite);
  background: var(--paper);
  box-shadow: var(--shadow-card);
}
.titleblock__tag {
  position: absolute;
  top: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  border-left: 1.5px solid var(--graphite);
  border-bottom: 1.5px solid var(--graphite);
  padding: 6px 10px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--graphite-3);
  background: var(--kraft-2);
}
.titleblock__tag b { color: var(--graphite); font-size: 12px; }

/* corner ticks (drafting registration marks) */
.ticks { position: relative; }
.ticks::before, .ticks::after {
  content: ""; position: absolute; width: 14px; height: 14px;
  border: 1.5px solid var(--blue); opacity: .5;
}
.ticks::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.ticks::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

/* ============================================================
   Dimension line (|<-- value -->|)
   ============================================================ */
.dim {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--f-mono);
  color: var(--blue);
  font-size: 13px;
  white-space: nowrap;
}
.dim__line { position: relative; height: 1px; background: currentColor; flex: 1; min-width: 26px; }
.dim__line::before, .dim__line::after {
  content: ""; position: absolute; top: 50%; width: 7px; height: 7px;
  border-top: 1.5px solid currentColor; border-right: 1.5px solid currentColor;
}
.dim__line::before { left: 0; transform: translateY(-50%) rotate(-135deg); }
.dim__line::after  { right: 0; transform: translateY(-50%) rotate(45deg); }
/* end caps (vertical ticks) */
.dim__cap { width: 1px; height: 13px; background: currentColor; }

/* ============================================================
   Scan sheet (отсканированный лист с загибом)
   ============================================================ */
.scan-sheet {
  position: relative;
  background: var(--scan);
  border: 1px solid #E2DAC9;
  box-shadow: var(--shadow-sheet);
  overflow: hidden;
}
.scan-sheet__fold {
  position: absolute; top: 0; right: 0;
  width: 0; height: 0;
  border-style: solid;
  border-width: 0 34px 34px 0;
  border-color: transparent var(--kraft) transparent transparent;
  filter: drop-shadow(-2px 2px 2px rgba(0,0,0,.12));
}

/* pencil check */
.pcheck { color: var(--green); flex: none; }

/* hairline divider with arrows */
.rule-dim {
  display: flex; align-items: center; gap: 14px;
  color: var(--hairline);
}
.rule-dim__l { flex: 1; height: 1px; background: currentColor; position: relative; }

/* ============================================================
   Reveal on scroll
   ============================================================ */
.reveal { opacity: 1; transform: none; filter: none; transition: opacity .7s ease, transform .75s cubic-bezier(.22,.61,.36,1), filter .7s ease; }
/* Hidden-then-animate state is only enabled once JS confirms the tab is rendering
   (anim-ready added inside rAF). If the tab is throttled/hidden, content stays visible. */
html.anim-ready .reveal:not(.in) { opacity: 0; transform: translateY(26px) scale(.972); filter: blur(4px); }
.reveal[data-d="1"] { transition-delay: .08s; }
.reveal[data-d="2"] { transition-delay: .16s; }
.reveal[data-d="3"] { transition-delay: .24s; }
.reveal[data-d="4"] { transition-delay: .32s; }
@media (prefers-reduced-motion: reduce) {
  html.anim-ready .reveal:not(.in) { opacity: 1; transform: none; filter: none; }
  .reveal { transition: none; }
  html { scroll-behavior: auto; }
}

/* ============================================================
   Placeholder (client content)
   ============================================================ */
.ph {
  position: relative;
  width: 100%;
  min-width: 0;
  background:
    repeating-linear-gradient(135deg, rgba(31,58,95,.05) 0 10px, transparent 10px 20px),
    var(--kraft-2);
  border: 1.4px dashed var(--blue-soft);
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--graphite-3);
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: .04em;
  padding: 18px;
}
.ph span { max-width: 80%; }

/* scrollbars for carousels */
.hscroll { display: flex; gap: 18px; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; padding-bottom: 8px; }
.hscroll > * { scroll-snap-align: start; flex: none; }
.hscroll::-webkit-scrollbar { height: 8px; }
.hscroll::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 8px; }
.hscroll::-webkit-scrollbar-track { background: transparent; }

.noscrollbar::-webkit-scrollbar { display: none; }
.noscrollbar { scrollbar-width: none; }

/* utility */
.flex { display: flex; }
.center { align-items: center; }
.between { justify-content: space-between; }
.wrap-flex { flex-wrap: wrap; }
.gap-s { gap: 10px; }
.gap-m { gap: 18px; }
.gap-l { gap: 32px; }
.col { flex-direction: column; }
.mt-s { margin-top: 12px; } .mt-m { margin-top: 24px; } .mt-l { margin-top: 44px; }
.tac { text-align: center; }
.nowrap { white-space: nowrap; }
.strike { text-decoration: line-through; text-decoration-color: var(--graphite-3); color: var(--graphite-3); }
