:root {
  color-scheme: light;
  --bg: #f3f0e8;
  --surface: #e8e3d8;
  --surface-strong: #ddd6c8;
  --text: #171714;
  --muted: #6b675f;
  --line: #cbc4b6;
  --accent: #9c4937;
  --accent-soft: #ead7d0;
  --max: 1220px;
  --header: 86px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #11110f;
    --surface: #191916;
    --surface-strong: #24231f;
    --text: #f1eee6;
    --muted: #aaa49a;
    --line: #323029;
    --accent: #e08a74;
    --accent-soft: #3b2721;
  }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header) + 22px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  text-align: right;
  font-family: "Vazirmatn", "Noto Sans Arabic", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}

.ltr {
  direction: ltr;
  unicode-bidi: isolate;
}

.shell {
  width: min(calc(100% - 48px), var(--max));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(243, 240, 232, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

@media (prefers-color-scheme: dark) {
  .site-header { background: rgba(17, 17, 15, 0.94); }
}

.header-inner {
  width: min(calc(100% - 48px), var(--max));
  min-height: var(--header);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 36px;
}

.brand {
  display: inline-grid;
  gap: 2px;
}

.brand-word {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.72rem;
}

nav {
  display: flex;
  align-items: center;
  gap: 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

nav a {
  transition: color 160ms ease;
}

nav a:hover,
.nav-external:hover {
  color: var(--text);
}

.nav-external {
  color: var(--accent);
}

.hero {
  min-height: calc(100vh - var(--header));
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
  align-items: center;
  gap: clamp(48px, 8vw, 110px);
  padding-block: clamp(84px, 11vw, 148px);
}

.hero-main {
  max-width: 850px;
}

.section-tag {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 30px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.section-tag span {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  direction: ltr;
}

.hero-name {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 600;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.32;
  letter-spacing: -0.035em;
}

h1 {
  max-width: 900px;
  margin-bottom: 32px;
  font-size: clamp(3.15rem, 7.5vw, 7rem);
  font-weight: 800;
}

h1 em {
  color: var(--accent);
  font-style: normal;
}

h2 {
  margin-bottom: 26px;
  font-size: clamp(2.25rem, 4.7vw, 4.7rem);
  font-weight: 750;
}

h3 {
  margin-bottom: 16px;
  font-size: clamp(1.65rem, 2.6vw, 2.55rem);
  font-weight: 700;
}

.lead {
  max-width: 750px;
  margin-bottom: 34px;
  color: var(--muted);
  font-size: clamp(1.08rem, 1.8vw, 1.38rem);
  line-height: 2;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  align-items: center;
}

.text-link {
  color: var(--muted);
  border-bottom: 1px solid transparent;
  font-size: 0.94rem;
  transition: color 160ms ease, border-color 160ms ease;
}

.text-link:hover {
  color: var(--text);
  border-color: var(--text);
}

.text-link.strong {
  color: var(--text);
  font-weight: 650;
}

.hero-system {
  min-height: 520px;
  padding: 22px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 44px 44px;
  background-color: var(--bg);
}

.system-head,
.system-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.69rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.08em;
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  direction: ltr;
}

.status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.system-flow {
  padding: 26px 6px;
}

.flow-node {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.flow-node span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  direction: ltr;
  font-size: 0.75rem;
}

.flow-node strong {
  font-size: 1.25rem;
  font-weight: 600;
}

.flow-node.active strong,
.flow-node.active span {
  color: var(--accent);
}

.flow-line {
  width: 1px;
  height: 48px;
  margin: 8px 14px 8px 0;
  background: var(--line);
}

.accent-line {
  background: var(--accent);
}

.system-foot {
  flex-wrap: wrap;
  direction: ltr;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.system-foot p { margin: 0; }

.section {
  padding-block: clamp(96px, 12vw, 150px);
  border-top: 1px solid var(--line);
}

.section-header {
  display: grid;
  grid-template-columns: minmax(180px, 0.35fr) minmax(0, 1fr);
  gap: 60px;
  margin-bottom: 76px;
}

.section-header .section-tag { margin-top: 14px; }
.section-header h2 { max-width: 800px; }

.section-intro {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.03rem;
}

.projects {
  border-bottom: 1px solid var(--line);
}

.project {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 160px;
  gap: 34px;
  align-items: stretch;
  padding-block: 44px;
  border-top: 1px solid var(--line);
  transition: background 180ms ease, padding-inline 180ms ease;
}

.project:hover {
  padding-inline: 18px;
  background: var(--surface);
}

.project-number {
  padding-top: 5px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
}

.project-body {
  max-width: 760px;
}

.project-type,
.list-label {
  margin-bottom: 10px;
  color: var(--accent);
  direction: ltr;
  unicode-bidi: isolate;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.73rem;
  letter-spacing: 0.05em;
  text-align: right;
}

.project-body > p:not(.project-type):not(.project-meta) {
  max-width: 710px;
  margin-bottom: 24px;
  color: var(--muted);
}

.project-meta {
  margin: 0;
  color: var(--muted);
  direction: ltr;
  unicode-bidi: isolate;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  text-align: left;
}

.project-mark {
  min-height: 150px;
  border-inline-start: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  padding-inline-start: 24px;
  direction: ltr;
}

.project-mark span {
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 4.8rem;
  line-height: 1;
}

.project-mark small {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.project-featured .project-mark span {
  font-size: 6rem;
}

.two-column,
.about-section {
  display: grid;
  grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr);
  gap: clamp(60px, 9vw, 130px);
}

.two-column > header h2 {
  max-width: 520px;
  font-size: clamp(2.1rem, 4vw, 4rem);
}

.editorial-list {
  border-bottom: 1px solid var(--line);
}

.editorial-list article,
.lab-item {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 24px;
  padding-block: 32px;
  border-top: 1px solid var(--line);
}

.list-index {
  padding-top: 3px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
}

.editorial-list h3 {
  margin-bottom: 12px;
  font-size: 1.65rem;
}

.editorial-list p:not(.list-label) {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
}

.lab-item {
  transition: padding-inline 160ms ease, background 160ms ease;
}

.lab-item:hover {
  padding-inline: 16px;
  background: var(--surface);
}

.lab-item:hover h3 { color: var(--accent); }

.about-title h2 {
  max-width: 620px;
  font-size: clamp(2.35rem, 4.6vw, 4.7rem);
}

.about-copy {
  padding-top: 46px;
}

.about-copy > p {
  max-width: 710px;
  color: var(--muted);
}

.about-lead {
  color: var(--text) !important;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  font-weight: 500;
}

.stineva-note {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.stineva-note > span {
  display: block;
  margin-bottom: 14px;
  color: var(--accent);
  font-size: 0.76rem;
}

.stineva-note p {
  max-width: 710px;
  margin-bottom: 0;
  color: var(--muted);
}

.site-footer {
  min-height: 190px;
  padding-block: 46px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
}

.site-footer p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.footer-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

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

@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .hero-system {
    min-height: 420px;
    width: min(100%, 600px);
  }

  .section-header,
  .two-column,
  .about-section {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .section-header { margin-bottom: 54px; }
  .section-header .section-tag { margin-top: 0; }
  .about-copy { padding-top: 0; }
}

@media (max-width: 760px) {
  :root { --header: auto; }

  .shell,
  .header-inner {
    width: min(calc(100% - 32px), var(--max));
  }

  .site-header { position: relative; }

  .header-inner {
    padding-block: 20px;
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }

  nav {
    width: 100%;
    gap: 15px 20px;
    flex-wrap: wrap;
    font-size: 0.82rem;
  }

  .hero {
    padding-block: 70px 84px;
    gap: 52px;
  }

  h1 {
    font-size: clamp(2.75rem, 13vw, 4.5rem);
  }

  .section {
    padding-block: 78px;
  }

  .project {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 18px;
    padding-block: 34px;
  }

  .project-mark { display: none; }
  .project:hover { padding-inline: 10px; }
  .project-meta { text-align: right; }

  .site-footer {
    min-height: 170px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
  }

  .footer-meta { align-items: flex-start; }
}

@media (max-width: 520px) {
  .hero-system { min-height: 380px; }
  .system-foot { gap: 10px 18px; }

  .editorial-list article,
  .lab-item {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 14px;
  }

  .editorial-list h3 { font-size: 1.42rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
