/* styles.css — domkamin.com.ua
   Editorial / Tech · Light theme "Warm Stone & Ember"
   Palette: warm paper + smoked terracotta + deep slate-teal */

:root {
  /* Palette */
  --bg: #f5f0e8;
  --bg-alt: #efe8dd;
  --surface: #fffdf9;
  --card: #fffdf9;
  --text: #2a2420;
  --text-soft: #3d3530;
  --muted: #675b51;
  --accent: #9e3d1c;
  --accent-hover: #7f2f13;
  --accent-soft: rgba(158, 61, 28, 0.08);
  --accent-line: rgba(158, 61, 28, 0.28);
  --accent2: #2c5a5f;
  --accent2-soft: rgba(44, 90, 95, 0.09);
  --border: rgba(62, 42, 28, 0.12);
  --border-strong: rgba(62, 42, 28, 0.2);
  --code-bg: #f0e9df;
  --focus: #2c5a5f;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(62, 42, 28, 0.05), 0 1px 1px rgba(62, 42, 28, 0.03);
  --shadow-md: 0 6px 18px -8px rgba(62, 42, 28, 0.16), 0 2px 6px -2px rgba(62, 42, 28, 0.06);
  --shadow-lg: 0 16px 34px -14px rgba(62, 42, 28, 0.22), 0 4px 10px -4px rgba(62, 42, 28, 0.08);

  /* Typography */
  --font-main: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-base: 1.0625rem;
  --fs-sm: 0.9rem;
  --fs-xs: 0.78rem;
  --fs-h1: clamp(1.25rem, 1.05rem + 1vw, 1.45rem);
  --fs-h2: clamp(1.15rem, 1.05rem + 0.5vw, 1.35rem);
  --fs-h3: clamp(1.05rem, 1rem + 0.3vw, 1.18rem);
  --lh-body: 1.7;
  --lh-head: 1.32;
  --measure: 70ch;

  /* Spacing scale */
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 20px;
  --space-lg: 32px;
  --space-xl: 48px;
  --space-2xl: 72px;
  --gutter: 16px;

  /* Radii */
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --container: 1160px;
  --header-h: 60px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---------- 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: calc(var(--header-h) + 16px);
}

body {
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(rgba(62, 42, 28, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, #f8f4ee 0%, var(--bg) 40%, var(--bg-alt) 100%);
  background-size: 22px 22px, 100% 100%;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-main);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  overflow-x: hidden;
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

main { flex: 1 0 auto; }

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

img,
video { height: auto; }

iframe { border: 0; }

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

ul,
ol { list-style: none; }

::selection {
  background: rgba(158, 61, 28, 0.18);
  color: var(--text);
}

/* ---------- Links & focus ---------- */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.18s var(--ease), background-color 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

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

:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- Headings ---------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text);
  font-weight: 700;
  line-height: var(--lh-head);
  letter-spacing: -0.012em;
  overflow-wrap: break-word;
  hyphens: auto;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: 1.05rem; }

p { overflow-wrap: break-word; }

strong,
b { font-weight: 650; color: var(--text); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 246, 240, 0.88);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header::after {
  content: "";
  display: block;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0 64px, transparent 64px);
}

.header-inner {
  max-width: var(--container);
  margin: 0 auto;
  min-height: var(--header-h);
  padding: var(--space-xs) var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  min-width: 0;
  color: var(--text);
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.logo:hover { color: var(--accent); }

.logo img,
.logo svg {
  width: auto;
  max-height: 32px;
  flex-shrink: 0;
}

.lang-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.lang-switcher a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  color: var(--muted);
}

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

.lang-switcher a.active {
  color: #fffdf9;
  background: var(--accent);
}

.lang-switcher a.active:hover { background: var(--accent-hover); }

/* ---------- Main layout ---------- */
main {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-lg) var(--gutter) var(--space-xl);
}

.article-title {
  position: relative;
  max-width: 44ch;
  margin-bottom: var(--space-lg);
  padding-top: var(--space-sm);
  font-size: var(--fs-h1);
  line-height: 1.3;
  color: var(--text);
  overflow-wrap: anywhere;
}

.article-title::before {
  content: "";
  display: block;
  width: 36px;
  height: 3px;
  margin-bottom: var(--space-sm);
  background: var(--accent);
  border-radius: 2px;
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.hero-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.hero-content .lead {
  margin-bottom: var(--space-md);
  padding-left: var(--space-sm);
  border-left: 2px solid var(--accent-line);
  font-family: var(--font-serif);
  font-size: 1.1rem;
  line-height: 1.65;
  color: var(--text-soft);
}

.meta-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.02em;
  color: var(--muted);
}

.meta-info > * + *::before {
  content: "/";
  margin-right: 10px;
  color: var(--border-strong);
}

.meta-info svg { flex-shrink: 0; }

.hero-visual {
  position: relative;
  width: 100%;
  height: 240px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #ebe2d5, #e3d8c8);
  box-shadow: var(--shadow-md);
}

.hero-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.hero-visual img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

/* ---------- Article content ---------- */
.content-body {
  max-width: var(--measure);
  margin: 0 auto var(--space-xl);
  color: var(--text-soft);
}

.content-body > * + * { margin-top: 0; }

.content-body p {
  margin-bottom: 1.25em;
  color: var(--text-soft);
  font-size: 1em;
}

.content-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-line);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.content-body a:hover {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

.content-body h2,
.content-body h3,
.content-body h4 {
  color: var(--text);
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.content-body h2 {
  position: relative;
  margin: var(--space-xl) 0 var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
  font-size: var(--fs-h2);
}

.content-body h2::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 48px;
  height: 2px;
  background: var(--accent);
}

.content-body h3 {
  margin: var(--space-lg) 0 var(--space-xs);
  font-size: var(--fs-h3);
  color: var(--accent2);
}

.content-body h4 {
  margin: var(--space-md) 0 var(--space-xs);
}

.content-body blockquote {
  margin: var(--space-lg) 0;
  padding: var(--space-md) var(--space-md) var(--space-md) calc(var(--space-md) + 2px);
  border-left: 3px solid var(--accent2);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent2-soft);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.06em;
  line-height: 1.65;
  color: var(--text);
}

.content-body blockquote p { color: inherit; }
.content-body blockquote p:last-child { margin-bottom: 0; }

.content-body blockquote cite {
  display: block;
  margin-top: var(--space-xs);
  font-family: var(--font-main);
  font-style: normal;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.content-body ul,
.content-body ol {
  margin: 0 0 1.25em;
  padding-left: 1.4em;
}

.content-body ul li {
  position: relative;
  margin-bottom: 0.5em;
  padding-left: 0.2em;
  list-style: none;
  color: var(--text-soft);
}

.content-body ul li::before {
  content: "";
  position: absolute;
  top: 0.72em;
  left: -1em;
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 2px;
  transform: rotate(45deg);
}

.content-body ol {
  list-style: decimal;
}

.content-body ol li {
  margin-bottom: 0.5em;
  padding-left: 0.3em;
}

.content-body ol li::marker {
  color: var(--accent);
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.content-body li > ul,
.content-body li > ol {
  margin-top: 0.5em;
  margin-bottom: 0.25em;
}

.content-body ul li strong { color: var(--text); }

.content-body img,
.content-body video,
.content-body iframe {
  margin: var(--space-lg) auto;
  border-radius: var(--radius);
}

.content-body iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
}

.content-body figure { margin: var(--space-lg) 0; }

.content-body figcaption {
  margin-top: var(--space-xs);
  font-size: var(--fs-sm);
  color: var(--muted);
  text-align: center;
}

.content-body hr {
  margin: var(--space-xl) auto;
  border: 0;
  height: 1px;
  background: var(--border-strong);
}

/* Code */
code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.88em;
}

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

pre {
  margin: var(--space-md) 0 var(--space-lg);
  padding: var(--space-md);
  max-width: 100%;
  overflow-x: auto;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.6;
  color: var(--text);
  -webkit-overflow-scrolling: touch;
  tab-size: 2;
}

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

/* Tables */
.content-body table,
main table {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: var(--space-md) 0 var(--space-lg);
  overflow-x: auto;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: var(--fs-sm);
  -webkit-overflow-scrolling: touch;
}

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

main th {
  background: var(--bg-alt);
  color: var(--text);
  font-weight: 650;
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

main tbody tr:nth-child(even) { background: rgba(239, 232, 221, 0.45); }
main tbody tr:hover { background: var(--accent-soft); }
main tbody tr:last-child td { border-bottom: 0; }

/* ---------- Related materials ---------- */
.related-materials {
  margin-top: var(--space-2xl);
}

.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.section-header h2,
.section-header h3 {
  flex-shrink: 0;
  max-width: 75%;
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.divider-line {
  flex-grow: 1;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--border-strong) 0 6px, transparent 6px 10px);
}

.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--space-md);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  overflow: hidden;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease);
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-line);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}

.card:hover::before,
.card:focus-within::before { transform: scaleX(1); }

.card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: var(--radius);
}

.card a { color: inherit; }

.card-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
  font-size: var(--fs-xs);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.4;
}

.badge.accent-badge {
  background: var(--accent2-soft);
  color: var(--accent2);
  border-color: rgba(44, 90, 95, 0.3);
}

.date {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--muted);
}

.card h4 {
  margin-bottom: var(--space-xs);
  font-size: 1.05rem;
  line-height: 1.38;
  color: var(--text);
  overflow-wrap: anywhere;
}

.card:hover h4 { color: var(--accent); }

.card p {
  flex-grow: 1;
  margin-bottom: var(--space-md);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--accent);
  transition: gap 0.2s var(--ease);
}

.card:hover .card-footer { gap: 10px; }

/* ---------- Footer ---------- */
footer {
  margin-top: var(--space-xl);
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
}

.footer-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-lg) var(--gutter);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  text-align: center;
}

.footer-left {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.footer-center {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 8px;
}

.footer-center a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--text-soft);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
}

.footer-center a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent-line);
}

.dmca-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  color: var(--muted);
  cursor: default;
}

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

  .hero-visual { height: 280px; }

  .logo { font-size: 1.08rem; }
}

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

  main { padding-top: var(--space-xl); }

  .article-title { margin-bottom: var(--space-xl); }

  .hero-visual { height: 340px; }

  .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .card { padding: 24px; }

  .footer-inner {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    text-align: left;
  }

  .footer-left { justify-content: flex-start; }

  main th,
  main td { min-width: 0; }

  .content-body table,
  main table { display: table; }
}

@media (min-width: 1024px) {
  :root {
    --fs-base: 1.125rem;
    --fs-h1: clamp(1.6rem, 1rem + 1vw, 1.95rem);
    --fs-h2: 1.42rem;
    --fs-h3: 1.2rem;
    --gutter: 32px;
  }

  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    gap: var(--space-xl);
    align-items: center;
  }

  .hero-visual {
    height: 100%;
    min-height: 400px;
  }

  .hero-content .lead { font-size: 1.15rem; }

  .cards-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .footer-inner { flex-wrap: nowrap; }
}

@media (min-width: 1280px) {
  .hero-visual { min-height: 440px; }

  .cards-grid { gap: 24px; }
}

/* ---------- 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;
  }

  .card:hover { transform: none; }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; }
  .site-header,
  .related-materials,
  footer { display: none; }
  .content-body a { text-decoration: underline; }
}