/* firmatmm.com.ua — світла editorial/tech тема: пісочний папір + теракота + глибокий бірюзовий */

:root {
  /* Палітра */
  --bg: #f5f0e7;
  --bg-soft: #efe8dc;
  --surface: #fffdf9;
  --surface-2: #faf6ef;
  --ink: #2a2320;
  --ink-soft: #3d3430;
  --muted: #6a5d55;
  --line: #e3d9ca;
  --line-strong: #d3c5b1;
  --accent: #a3401c;
  --accent-hover: #83310f;
  --accent-soft: #f6e4da;
  --accent-2: #1f5c58;
  --accent-2-soft: #e1eeec;
  --threat: #a8222e;
  --code-bg: #f1ebe1;
  --focus: #1f5c58;

  /* Типографіка */
  --f-head: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-body: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, "Times New Roman", serif;
  --f-mono: ui-monospace, SFMono-Regular, "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --fs-base: 1rem;
  --fs-sm: 0.875rem;
  --fs-xs: 0.8125rem;
  --lh-body: 1.7;
  --lh-head: 1.3;

  /* Spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;

  /* Радіуси, тіні */
  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(60, 40, 25, 0.05);
  --shadow-md: 0 2px 6px rgba(60, 40, 25, 0.05), 0 12px 32px -12px rgba(60, 40, 25, 0.12);

  /* Макет */
  --wrap: 1160px;
  --measure: 68ch;
  --gutter: 16px;
  --tap: 44px;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(120, 90, 60, 0.07) 1px, transparent 0);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  overflow-x: hidden;
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img,
picture,
video,
canvas,
svg,
iframe {
  display: block;
  max-width: 100%;
}

img,
video {
  height: auto;
}

iframe {
  border: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

/* ===== Посилання ===== */
a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: rgba(163, 64, 28, 0.4);
  transition: color 0.15s ease, text-decoration-color 0.15s ease, background-color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
}

.skip:focus {
  left: var(--s-3);
  top: var(--s-3);
  z-index: 300;
  padding: var(--s-2) var(--s-4);
  background: var(--surface);
  color: var(--accent);
  border: 2px solid var(--focus);
  border-radius: var(--r-sm);
  font-family: var(--f-head);
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

/* ===== Шапка ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 253, 249, 0.92);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.topbar::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0 38%, var(--accent-2) 38% 62%, var(--line-strong) 62% 100%);
}

.topbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-4);
  min-height: 60px;
  padding-top: var(--s-2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--tap);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--f-head);
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  margin-right: auto;
}

.brand:hover {
  color: var(--ink);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--s-1);
  border-radius: var(--r-sm);
  background: var(--accent);
  color: #fffaf5;
  font-size: 0.95rem;
  line-height: 1;
}

.menu {
  order: 3;
  display: flex;
  gap: var(--s-1);
  width: 100%;
  margin: 0 calc(var(--gutter) * -1);
  padding: 0 var(--gutter) var(--s-2);
  width: calc(100% + var(--gutter) * 2);
  overflow-x: auto;
  scrollbar-width: none;
  font-family: var(--f-head);
  font-weight: 500;
  font-size: 0.9375rem;
  white-space: nowrap;
}

.menu::-webkit-scrollbar {
  display: none;
}

.menu a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--s-3);
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
}

.menu a:hover {
  color: var(--ink);
  background: var(--bg-soft);
}

.menu a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.lang {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-family: var(--f-head);
  font-size: var(--fs-sm);
}

.lang a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap);
  min-height: 38px;
  padding: 0 var(--s-3);
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lang a:hover {
  color: var(--ink);
  background: var(--bg-soft);
}

.lang a[aria-current="true"] {
  color: #fffaf5;
  background: var(--accent-2);
  font-weight: 700;
}

/* ===== Хлібні крихти та заголовок ===== */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1) var(--s-2);
  margin: var(--s-6) 0 var(--s-4);
  font-family: var(--f-head);
  font-size: var(--fs-sm);
  color: var(--muted);
}

.crumbs a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--muted);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.post-head h1 {
  max-width: 34ch;
  font-family: var(--f-head);
  font-weight: 750;
  font-size: clamp(1.25rem, 1.05rem + 1.1vw, 1.4375rem);
  line-height: var(--lh-head);
  letter-spacing: -0.015em;
  color: var(--ink);
  overflow-wrap: anywhere;
  hyphens: auto;
  text-wrap: balance;
}

.post-info {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  margin: var(--s-4) 0 var(--s-6);
  padding-top: var(--s-3);
  border-top: 1px dashed var(--line-strong);
  font-family: var(--f-head);
  font-size: var(--fs-sm);
  color: var(--muted);
}

.post-info > * {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

.post-info > * + *::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.6;
}

/* ===== Обкладинка ===== */
.cover {
  width: 100%;
  max-width: calc(var(--wrap) + 120px);
  margin: 0 auto var(--s-7);
  padding-inline: var(--gutter);
}

.cover img {
  width: 100%;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
  border-radius: var(--r-md);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

/* ===== Сітка статті ===== */
.post-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-6);
}

.toc {
  padding: var(--s-4) var(--s-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--f-head);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-sm);
}

.toc-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.toc-title::before {
  content: "";
  width: 14px;
  height: 2px;
  background: var(--accent);
}

.toc ol {
  list-style: none;
  display: grid;
  gap: 2px;
  counter-reset: toc;
}

.toc li {
  counter-increment: toc;
}

.toc a {
  display: flex;
  gap: var(--s-2);
  align-items: baseline;
  min-height: var(--tap);
  padding: 10px var(--s-2);
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  text-decoration: none;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.toc a::before {
  content: counter(toc, decimal-leading-zero);
  flex: none;
  font-family: var(--f-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.toc a:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.toc a:hover::before {
  color: var(--accent);
}

/* ===== Стаття ===== */
.post {
  min-width: 0;
  max-width: calc(var(--measure) + 2 * var(--s-7));
  padding: var(--s-5) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow-wrap: break-word;
}

.post > * {
  max-width: var(--measure);
}

.post p {
  margin-bottom: 1.25em;
}

.post .intro {
  font-size: 1.09em;
  line-height: 1.65;
  color: var(--ink-soft);
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s-5);
}

.post h2,
.post h3,
.post h4 {
  font-family: var(--f-head);
  color: var(--ink);
  line-height: var(--lh-head);
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.post h2 {
  position: relative;
  font-size: 1.1875rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 2.2em 0 0.75em;
  padding-top: var(--s-4);
}

.post h2::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 36px;
  height: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.post h3 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--accent-2);
  margin: 1.8em 0 0.5em;
}

.post h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.5em 0 0.4em;
}

.post > :first-child {
  margin-top: 0;
}

/* Списки */
.post ul,
.post ol {
  margin: 0 0 1.25em;
  padding-left: 1.4em;
}

.post li {
  margin-bottom: 0.45em;
  padding-left: 0.2em;
}

.post li::marker {
  color: var(--accent);
  font-weight: 700;
}

.post ol li::marker {
  font-family: var(--f-head);
  font-size: 0.9em;
}

.post li > ul,
.post li > ol {
  margin: 0.45em 0 0;
}

/* Код */
code,
kbd,
samp {
  font-family: var(--f-mono);
  font-size: 0.875em;
}

.post :not(pre) > code {
  padding: 0.12em 0.4em;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--code-bg);
  color: var(--accent-hover);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.post pre {
  max-width: 100%;
  margin: 0 0 1.5em;
  padding: var(--s-4);
  overflow-x: auto;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent-2);
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--ink);
  -webkit-overflow-scrolling: touch;
  tab-size: 2;
}

.post pre code {
  font-size: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  white-space: pre;
}

/* Таблиці */
.post table {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0 0 1.5em;
  overflow-x: auto;
  border-collapse: collapse;
  font-family: var(--f-head);
  font-size: var(--fs-sm);
  line-height: 1.5;
  -webkit-overflow-scrolling: touch;
}

.post th,
.post td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  min-width: 120px;
}

.post th {
  background: var(--accent-2-soft);
  color: var(--accent-2);
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 2px solid rgba(31, 92, 88, 0.25);
}

.post tbody tr:nth-child(even) {
  background: var(--surface-2);
}

.post tbody tr:hover {
  background: var(--accent-soft);
}

/* Медіа в статті */
.post img,
.post video,
.post iframe {
  max-width: 100%;
  border-radius: var(--r-sm);
  margin: var(--s-5) 0;
}

.post figure {
  margin: var(--s-5) 0;
}

.post figcaption {
  margin-top: var(--s-2);
  font-family: var(--f-head);
  font-size: var(--fs-sm);
  color: var(--muted);
}

.post hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: var(--s-7) 0;
}

/* Короткий підсумок */
.summary {
  margin: var(--s-2) 0 var(--s-5);
  padding: var(--s-4) var(--s-5);
  background: var(--accent-2-soft);
  border: 1px solid rgba(31, 92, 88, 0.18);
  border-radius: var(--r-md);
}

.summary-title {
  margin-bottom: var(--s-2) !important;
  font-family: var(--f-head);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.summary p:last-child {
  margin-bottom: 0;
}

/* Терміни */
.terms {
  display: grid;
  gap: var(--s-3);
  margin: 0 0 1.5em;
}

.terms div {
  padding: var(--s-3) var(--s-4);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.terms dt {
  font-family: var(--f-head);
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.terms dd {
  margin-top: var(--s-1);
  color: var(--muted);
}

/* Цитата */
.post blockquote {
  position: relative;
  margin: 1.75em 0;
  padding: var(--s-5) var(--s-5) var(--s-5) var(--s-6);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-md) var(--r-md) 0;
}

.post blockquote::before {
  content: "\201C";
  position: absolute;
  top: 2px;
  left: 10px;
  font-family: Georgia, serif;
  font-size: 2.5rem;
  line-height: 1;
  color: var(--accent);
  opacity: 0.45;
}

.post blockquote p {
  margin: 0;
  font-size: 1.05em;
  font-style: italic;
  line-height: 1.6;
  color: var(--ink-soft);
}

.post blockquote p + p {
  margin-top: var(--s-3);
}

.post blockquote cite,
.post blockquote footer {
  display: block;
  margin-top: var(--s-3);
  font-family: var(--f-head);
  font-size: var(--fs-sm);
  font-style: normal;
  color: var(--muted);
}

/* ===== Читайте також ===== */
.more {
  margin-top: var(--s-8);
  padding: var(--s-7) 0;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.more h2 {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
  font-family: var(--f-head);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: var(--lh-head);
  color: var(--ink);
}

.more h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-strong);
}

.more-list {
  list-style: none;
  display: grid;
  gap: var(--s-3);
}

.more-list a {
  display: grid;
  gap: var(--s-1) var(--s-5);
  min-height: var(--tap);
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.more-list a:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.more-list a:hover .more-name {
  color: var(--accent);
}

.more-topic {
  justify-self: start;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-2-soft);
  font-family: var(--f-head);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--accent-2);
}

.more-topic.is-threat {
  background: #f8e3e4;
  color: var(--threat);
}

.more-name {
  font-family: var(--f-head);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  transition: color 0.15s ease;
}

.more-desc {
  color: var(--muted);
  font-size: 0.95em;
  line-height: 1.6;
}

/* ===== Підвал ===== */
.foot {
  background: var(--bg-soft);
  color: var(--muted);
  font-family: var(--f-head);
  font-size: var(--fs-sm);
  border-top: 1px solid var(--line);
}

.foot-row {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding-top: var(--s-6);
  padding-bottom: var(--s-6);
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1) var(--s-4);
}

.foot a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--ink-soft);
  text-decoration: none;
}

.foot a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.foot .dmca,
.dmca {
  min-height: 32px;
  padding: 2px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* ===== ~480px ===== */
@media (min-width: 480px) {
  :root {
    --gutter: 20px;
  }

  .post {
    padding: var(--s-6) var(--s-5);
  }

  .more-list a {
    padding: var(--s-4) var(--s-5);
  }
}

/* ===== ~768px ===== */
@media (min-width: 768px) {
  :root {
    --gutter: 28px;
  }

  body {
    font-size: 1.0625rem;
  }

  .topbar-row {
    flex-wrap: nowrap;
    min-height: 68px;
    padding-top: 0;
    gap: var(--s-5);
  }

  .brand {
    margin-right: 0;
    font-size: 1.1875rem;
  }

  .menu {
    order: 0;
    width: auto;
    margin: 0 auto 0 0;
    padding: 0;
    overflow: visible;
  }

  .crumbs {
    margin-top: var(--s-7);
  }

  .post-head h1 {
    font-size: clamp(1.5rem, 1rem + 1.2vw, 1.75rem);
    line-height: 1.28;
  }

  .post {
    padding: var(--s-7) var(--s-7);
  }

  .post h2 {
    font-size: 1.3125rem;
  }

  .post h3 {
    font-size: 1.125rem;
  }

  .post th,
  .post td {
    min-width: 0;
  }

  .more-list a {
    grid-template-columns: 120px 220px minmax(0, 1fr);
    align-items: baseline;
  }

  .foot-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }
}

/* ===== ~1024px ===== */
@media (min-width: 1024px) {
  :root {
    --gutter: 32px;
  }

  body {
    font-size: 1.125rem;
  }

  .post-head h1 {
    font-size: 1.875rem;
    line-height: 1.26;
  }

  .post-layout {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: var(--s-8);
  }

  .toc {
    position: sticky;
    top: 100px;
    align-self: start;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: var(--s-4);
    background: transparent;
    border: 0;
    border-left: 1px solid var(--line-strong);
    border-radius: 0;
    box-shadow: none;
  }

  .toc a {
    min-height: 0;
    padding: 6px var(--s-2);
  }

  .post h2 {
    font-size: 1.375rem;
  }
}

/* ===== ~1280px ===== */
@media (min-width: 1280px) {
  .post-layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .post-head h1 {
    font-size: 2rem;
  }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .more-list a:hover {
    transform: none;
  }
}

/* ===== Друк ===== */
@media print {
  body {
    background: #fff;
  }

  .topbar,
  .toc,
  .more,
  .foot,
  .skip {
    display: none;
  }

  .post {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}