:root {
  color-scheme: light dark;
  --paper: light-dark(#f6f5f8, #1e1d24);
  --ink: light-dark(#302e3c, #eeecf5);
  --quiet: light-dark(#6b6577, #b6b0c4);
  --wash: light-dark(#eeecf2, #292732);
  --line: light-dark(#dddae4, #3b3746);
  --accent: light-dark(#665281, #c7b5e0);
  --hover: light-dark(#e7e3ed, #322e3e);
  font-family: "DM Sans", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
body { margin: 0; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }
[hidden] { display: none !important; }
::selection { color: var(--paper); background: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.pocket {
  width: min(100% - 40px, 480px);
  margin: clamp(40px, 10vh, 100px) auto 40px;
  font-size: 14px;
  line-height: 1.65;
}

.identity { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 13px; margin-bottom: 25px; }
.monogram {
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  height: 46px;
  padding-top: 3px;
  border-radius: 16px;
  background: var(--wash);
  color: var(--accent);
  font: 400 33px/1 "Newsreader", Georgia, serif;
}
.name { min-width: 0; }
h1 { margin: 0; font-size: 23px; font-weight: 600; line-height: 1.3; letter-spacing: -.8px; }
.handle { display: inline-block; color: var(--quiet); font-size: 12px; line-height: 1.4; }
.controls { display: flex; align-items: center; gap: 2px; margin-inline-start: auto; }
.controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 40px;
  padding: 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--quiet);
  cursor: pointer;
}
.controls button:hover { background: var(--wash); color: var(--ink); }
.language { font-size: 12px; }
.theme .sun { display: none; }
:root[data-theme="dark"] .theme .sun { display: block; }
:root[data-theme="dark"] .theme .moon { display: none; }

.intro { margin: 0; color: var(--quiet); }
.intro strong { color: var(--ink); font-weight: 500; }
h2 { margin: 0 0 10px; font-size: 12px; line-height: 1.5; font-weight: 500; color: var(--quiet); }
.projects { margin-top: 27px; }
.work-list { margin: 0; padding: 4px 14px; list-style: none; background: var(--wash); border-radius: 15px; }
.work-list li + li { border-top: 1px solid var(--line); }
.work {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-inline: -10px;
  padding: 13px 10px;
  border-radius: 10px;
  transition: background-color 150ms ease;
}
.work:hover { background: var(--hover); }
.work h3 { width: fit-content; margin: 0; font-size: 14px; font-weight: 500; line-height: 1.55; }
.work p { margin: 2px 0 0; color: var(--quiet); font-size: 12px; line-height: 1.6; }
.arrow { display: inline-block; flex-shrink: 0; color: var(--accent); transition: transform 150ms ease; }
a:hover .arrow { transform: translate(2px, -2px); }
.research { margin-top: 26px; }
.publication { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 18px; padding-block: 4px; font-size: 13px; }
.publication small { flex-shrink: 0; font-size: 11px; color: var(--quiet); }
.publication:hover > span { color: var(--accent); }
footer { margin-top: 27px; }
.sign-off { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.hello { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; color: var(--accent); font-size: 13px; }
.signature { padding-top: 3px; font: italic 400 25px/1 "Newsreader", Georgia, serif; color: var(--quiet); }
.socials { display: flex; align-items: center; flex-wrap: wrap; gap: 0 18px; margin-top: 5px; }
.socials a { display: inline-flex; align-items: center; min-height: 36px; font-size: 12px; color: var(--quiet); }
.socials a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }

:lang(fa) { font-family: "Vazirmatn", sans-serif; }
:lang(en) { font-family: "DM Sans", Arial, sans-serif; }
html[lang="fa"] h1 { letter-spacing: normal; font-size: 22px; }
html[lang="fa"] .pocket { line-height: 1.9; }
html[lang="fa"] .publication { flex-wrap: wrap; }
html[dir="rtl"] .arrow { transform: scaleX(-1); }
html[dir="rtl"] a:hover .arrow { transform: translate(-2px, -2px) scaleX(-1); }
.monogram { font-family: "Newsreader", Georgia, serif; }
.signature { font-family: "Newsreader", Georgia, serif; }

@media (max-width: 420px) {
  .identity { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; }
  h1 { font-size: 20px; }
  .monogram { flex-basis: 40px; height: 40px; border-radius: 13px; font-size: 29px; }
  .controls { gap: 0; }
  .controls button { min-width: 32px; padding-inline: 4px; }
  .publication { flex-wrap: wrap; }
}

@media (max-width: 360px) {
  h1, html[lang="fa"] h1 { font-size: 18px; }
}

@media (pointer: coarse) {
  .controls button, .socials a, .hello { min-height: 44px; min-width: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
