@font-face { font-family: 'CMU Serif'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/cmunrm.woff') format('woff'); }
@font-face { font-family: 'CMU Serif'; font-style: italic; font-weight: 400; font-display: swap; src: url('fonts/cmunti.woff') format('woff'); }
@font-face { font-family: 'CMU Serif'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/cmunbx.woff') format('woff'); }
@font-face { font-family: 'CMU Serif'; font-style: italic; font-weight: 700; font-display: swap; src: url('fonts/cmunbi.woff') format('woff'); }

:root {
  --bg: #ffffff;
  --text: #2b2b2b;
  --body: #3d3d3d;
  --muted: #6b6b6b;
  --line: rgba(0, 0, 0, 0.08);
  --pad: clamp(28px, 6vw, 80px);
  --font: 'CMU Serif', Georgia, 'Times New Roman', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
  overflow-x: hidden;
}
::selection { background: rgba(0, 0, 0, 0.12); }
a { color: inherit; text-decoration: none; }

/* ---------- Dot wave (home) ---------- */
#scene { position: fixed; top: 0; right: 0; width: 78vw; height: 100%; z-index: 0; display: block; }
.fade {
  position: fixed; top: 0; right: 0; width: 78vw; height: 100%; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, var(--bg) 0%, rgba(255, 255, 255, 0.92) 24%, rgba(255, 255, 255, 0.5) 38%, rgba(255, 255, 255, 0) 55%);
}

.page { position: relative; z-index: 2; }

/* ---------- Header ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px var(--pad);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 25%, rgba(255, 255, 255, 0));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.wordmark {
  font-size: clamp(21px, 2.5vw, 27px);
  letter-spacing: -0.025em;
  white-space: nowrap;
}
nav { display: flex; gap: clamp(22px, 3vw, 40px); }
nav a { font-size: 16px; color: var(--muted); white-space: nowrap; transition: color 0.3s ease; }
nav a:hover, nav a[aria-current="page"] { color: var(--text); }

/* ---------- Hero ---------- */
.hero {
  min-height: 80vh;
  display: flex;
  align-items: center;
  padding: 0 var(--pad);
}
.intro { max-width: 36rem; }
.intro .eyebrow, .block .label {
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}
.intro .lead {
  font-size: clamp(36px, 5.2vw, 64px);
  line-height: 1.08;
  letter-spacing: -0.005em;
  color: var(--text);
}
.intro .body {
  margin-top: 0.8em;
  color: var(--muted);
  font-size: clamp(18px, 1.9vw, 22px);
  line-height: 1.55;
  max-width: 32rem;
}

/* ---------- Content sections ---------- */
.block {
  padding: 64px var(--pad);
  scroll-margin-top: 72px;
}
.block .col { max-width: 44rem; }
.block p {
  font-size: clamp(17px, 1.9vw, 21px);
  line-height: 1.65;
  color: var(--body);
}
.block p + p { margin-top: 1em; }
.block p a { border-bottom: 1px solid rgba(0, 0, 0, 0.25); transition: border-color 0.3s; }
.block p a:hover { border-color: var(--text); }
.block a.mail {
  display: inline-block;
  margin-top: 8px;
  font-size: clamp(22px, 3vw, 32px);
  color: var(--text);
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
  padding-bottom: 3px;
  transition: border-color 0.3s;
}
.block a.mail:hover { border-color: var(--text); }

/* ---------- Home: latest article tiles ---------- */
.block .wide { max-width: 72rem; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.sec-head .label { margin-bottom: 0; }
.sec-all { font-size: 15px; color: var(--muted); white-space: nowrap; transition: color 0.2s; }
.sec-all:hover { color: var(--text); }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(16px, 2vw, 28px); }
.tiles[hidden] { display: none; }
.tile {
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border: 1px solid rgba(0, 0, 0, 0.09); border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.tile:hover { transform: translateY(-3px); border-color: rgba(0, 0, 0, 0.14); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.09); }
.tile:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.tile-img { display: block; aspect-ratio: 16 / 10; background: #eeebe2; overflow: hidden; }
.tile-img img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.tile:hover .tile-img img { transform: scale(1.03); }
.tile.no-cover .tile-img { background: linear-gradient(135deg, #eeebe2, #dcd8cc); }
.tile-body { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px 22px; }
.tile-meta { font-size: 13px; color: var(--muted); }
.tile-title { font-size: clamp(19px, 1.7vw, 22px); line-height: 1.28; color: var(--text); }
.tile-sum {
  font-size: 15px; line-height: 1.55; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
@media (max-width: 900px) {
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .tile { flex-direction: row; }
  .tile-img { flex: 0 0 38%; aspect-ratio: auto; min-height: 150px; }
}
@media (max-width: 520px) {
  .tile { flex-direction: column; }
  .tile-img { flex: none; aspect-ratio: 16 / 9; min-height: 0; }
  .tile-body { padding: 14px 16px 18px; }
  .tile-sum { -webkit-line-clamp: 2; }
}

/* ---------- Home: Ukraine line in the footer ---------- */
.ua-note { flex: 1 0 100%; display: flex; align-items: flex-start; gap: 12px; padding-bottom: 22px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.ua-note img { flex: none; display: block; width: 20px; height: 15px; margin-top: 4px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08); }
.ua-note p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--muted); }
.ua-label { margin-inline-end: 6px; font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text); }

/* ---------- Footer ---------- */
footer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 40px var(--pad);
  margin-top: 40px;
  font-size: 14px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--bg);
}
footer .right { display: flex; flex-wrap: wrap; gap: 8px 26px; }
footer a:hover { color: var(--text); }

@media (max-width: 720px) {
  header { flex-direction: column; align-items: flex-start; gap: 12px; padding-top: 18px; padding-bottom: 14px; }
  nav { gap: 6px 16px; flex-wrap: wrap; }
  nav a { font-size: 14px; }
  #scene, .fade { width: 100vw; opacity: 0.45; }
  .fade { background: radial-gradient(70% 60% at 50% 45%, transparent 30%, var(--bg) 100%); }
  footer { flex-direction: column; gap: 10px; align-items: flex-start; }
  .ua-note { flex: none; width: 100%; margin-bottom: 8px; }
  .ua-label { display: block; margin-bottom: 4px; }
}

/* ---------- Language selector (added by /i18n.js to every header) ---------- */
header nav { margin-inline-start: auto; }
.lang-pick { position: relative; flex-shrink: 0; }
.lang-btn {
  display: flex; align-items: center; gap: 7px;
  font: inherit; font-size: 14px; color: var(--muted); letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.7); border: 1px solid rgba(0, 0, 0, 0.12); border-radius: 999px;
  padding: 5px 10px 5px 8px; cursor: pointer; transition: color 0.2s, border-color 0.2s;
}
.lang-btn:hover, .lang-btn[aria-expanded="true"] { color: var(--text); border-color: rgba(0, 0, 0, 0.3); }
.lang-btn img, .lang-menu img { display: block; width: 20px; height: 15px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08); }
.lang-caret { width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.lang-menu {
  position: absolute; top: calc(100% + 8px); right: 0; left: auto; z-index: 20;
  list-style: none; min-width: 172px; padding: 6px;
  background: #fff; border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}
.lang-menu[hidden] { display: none; }
.lang-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  font: inherit; font-size: 15px; color: var(--body); text-align: start;
  background: none; border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.lang-menu button:hover, .lang-menu button:focus-visible { background: #f2f1ed; outline: none; }
.lang-menu button[aria-current="true"] { color: var(--text); background: #f6f5f1; }
.lang-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
/* right-to-left pages: keep the selector physically at the top right */
[dir="rtl"] header .lang-pick { order: -1; }

@media (max-width: 720px) {
  header { padding-right: calc(var(--pad) + 92px); }
  header .lang-pick { position: absolute; top: 14px; right: var(--pad); }
  header nav { margin-inline-start: 0; }
}

/* ---------- Arabic and Hindi ---------- */
:lang(ar) { --font: 'CMU Serif', 'Geeza Pro', 'Noto Naskh Arabic', 'Amiri', 'Times New Roman', serif; }
:lang(hi) { --font: 'CMU Serif', 'Kohinoor Devanagari', 'Noto Serif Devanagari', 'Mangal', 'Nirmala UI', serif; }
:lang(ar) body, :lang(hi) body, body :lang(ar), body :lang(hi) { font-family: var(--font); }
:lang(ar) .eyebrow, :lang(ar) .label, :lang(ar) .lbl, :lang(hi) .eyebrow, :lang(hi) .label, :lang(hi) .lbl { letter-spacing: 0; text-transform: none; }
:lang(ar) .ua-label, :lang(hi) .ua-label { font-size: 14px; letter-spacing: 0; text-transform: none; }
:lang(ar) .wordmark, :lang(hi) .wordmark { letter-spacing: -0.025em; }
:lang(ar) .intro .lead, :lang(hi) .intro .lead { line-height: 1.3; letter-spacing: 0; }
:lang(ar) h1, :lang(ar) h2, :lang(hi) h1, :lang(hi) h2 { letter-spacing: 0; line-height: 1.3; }

/* home on right-to-left pages: the dot wave sits on the left */
[dir="rtl"] #scene, [dir="rtl"] .fade { right: auto; left: 0; }
[dir="rtl"] .fade { background: linear-gradient(270deg, var(--bg) 0%, rgba(255, 255, 255, 0.92) 24%, rgba(255, 255, 255, 0.5) 38%, rgba(255, 255, 255, 0) 55%); }
@media (max-width: 720px) {
  [dir="rtl"] .fade { background: radial-gradient(70% 60% at 50% 45%, transparent 30%, var(--bg) 100%); }
}
/* terminal panels stay left-to-right; translated lines take their own direction */
[dir="rtl"] .win, [dir="rtl"] .traj, [dir="rtl"] .code, [dir="rtl"] pre { direction: ltr; }
.win .ln, .traj .ln > span, .win .bar span { unicode-bidi: plaintext; }
