:root {
  --bg: #f6f3ec;
  --fg: #2a2723;
  --muted: #8a8378;
  --line: #e2ddd2;
  --accent: #8c5a3c;
  --grain: 0.05;
  --serif: "Newsreader", "IRMitra", Georgia, serif;
  --persian: "Vazirmatn FA Digits", "Newsreader", "IRMitra", Georgia, serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131217;
    --fg: #e6e1d7;
    --muted: #8b8680;
    --line: #29272f;
    --accent: #d9a877;
    --grain: 0.07;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 19px/1.65 var(--serif);
  -webkit-font-smoothing: antialiased;
}
:lang(fa) body, body:lang(fa) { font: 400 19px/1.95 var(--persian); }
.latin, .fa-link { font-family: inherit; }

/* Film grain, barely there */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

main {
  max-width: 34rem;
  margin: 0 auto;
  padding: 14vh 1.25rem 4rem;
}

/* Top bar */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.25rem;
}
.top nav { display: flex; gap: 1.1rem; font-size: 0.9rem; }
:lang(fa) .top nav { font-size: 1.12rem; }
.top nav a { color: var(--muted); }
.top nav a[aria-current] { color: var(--fg); text-decoration: none; }
.moon {
  display: block;
  width: 26px;
  height: 26px;
  color: var(--accent);
  text-decoration: none;
}
.moon svg { display: block; width: 100%; height: 100%; }
.moon .shadow { fill: var(--line); }
.moon .lit { fill: currentColor; }

h1 {
  font-weight: 500;
  font-size: 1.9rem;
  letter-spacing: -0.01em;
  margin: 0 0 1.5rem;
}
:lang(fa) h1 { letter-spacing: 0; }
p { margin: 0 0 1.1rem; }
.tagline { color: var(--muted); font-style: italic; margin: -0.9rem 0 1.75rem; }
.note { color: var(--muted); font-size: 0.9rem; margin-top: 0.9rem; }
:lang(fa) .note { font-size: 0.95rem; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color .2s, color .2s;
}
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

h2 {
  font-size: 0.8rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 3.25rem 0 1rem;
}
:lang(fa) h2 { text-transform: none; letter-spacing: 0; font-size: 0.85rem; }

ul { list-style: none; padding: 0; margin: 0; }
li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}
li > span { margin-inline-start: auto; padding-inline-start: 1rem; color: var(--muted); font-style: italic; text-align: end; }
:lang(fa) li > span { font-style: normal; }
li small { color: var(--muted); font-size: 0.8em; }
li .stars { color: var(--accent); font-style: normal; letter-spacing: 0.05em; }

/* A line from my writing */
.fragment {
  margin: 4rem 0 0;
  transition: opacity .5s ease, filter .5s ease;
  padding: 0 0 0 1.25rem;
  padding-inline-start: 1.25rem;
  padding-inline-end: 0;
  border-inline-start: 1px solid var(--line);
}
.fragment.out { opacity: 0; filter: blur(6px); }
.fragment p { margin: 0 0 0.6rem; }
.fragment figcaption {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
:lang(fa) .fragment figcaption { font-size: 0.95rem; }
.fragment button {
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline dotted var(--line);
  text-underline-offset: 3px;
}
.fragment button:hover { color: var(--accent); }
.fragment:not([data-live]) button { display: none; }

blockquote {
  margin: 3.5rem 0 0;
  padding: 0;
  font-style: italic;
  color: var(--muted);
}
:lang(fa) blockquote { font-style: normal; }
blockquote cite { display: block; margin-top: 0.3rem; font-size: 0.85rem; font-style: normal; }
footer { margin-top: 3.5rem; font-size: 0.85rem; color: var(--muted); }
:lang(fa) footer { font-size: 0.95rem; }
footer p { margin: 0 0 0.4rem; }
footer a { color: inherit; }

/* Photos: a small photobook. Frames vary in size and sit left, right, or wide. */
.photos { display: grid; gap: 3.5rem; margin: 3rem 0; }
.photo { margin: 0; }
.photo a { display: block; line-height: 0; cursor: zoom-in; }
.photo img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--line);
  box-shadow: 0 1px 2px rgb(0 0 0 / .06), 0 12px 32px -18px rgb(0 0 0 / .35);
  transition: filter .4s ease;
}
.photo a:hover img { filter: brightness(1.05) saturate(1.05); }
.photo figcaption {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.6rem;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.photo figcaption span:first-child { color: var(--accent); }

@media (min-width: 900px) {
  .photos { margin-inline: -6rem; row-gap: 5rem; }
  .photo:nth-child(5n+1) { width: 100%; }
  .photo:nth-child(5n+2) { width: 68%; justify-self: end; }
  .photo:nth-child(5n+3) { width: 78%; justify-self: start; }
  .photo:nth-child(5n+4) { width: 58%; justify-self: center; }
  .photo:nth-child(5n+5) { width: 86%; justify-self: end; }
  .photo:nth-child(5n+2) figcaption,
  .photo:nth-child(5n+5) figcaption { justify-content: flex-end; }
}

/* Photo strip on the now page */
.strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.strip .photo img { aspect-ratio: 3 / 2; object-fit: cover; box-shadow: none; }
@media (max-width: 480px) {
  .strip { gap: 0.4rem; }
}

/* Full-screen viewer */
.viewer {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #e6e1d7;
  overflow: hidden;
}
.viewer::backdrop { background: rgb(12 11 15 / .96); }
.viewer[open] { display: grid; place-items: center; animation: dissolve .4s ease; }
.viewer img {
  max-width: min(92vw, 1216px);
  max-height: 84dvh;
  width: auto;
  height: auto;
  transition: opacity .3s ease, filter .3s ease;
}
.viewer img.out { opacity: 0; filter: blur(6px); }
.viewer-count {
  position: absolute;
  bottom: 1.5rem;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: #8b8680;
}
.viewer button {
  position: absolute;
  border: 0;
  background: none;
  color: #8b8680;
  font: 300 2.2rem/1 var(--serif);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: color .2s;
}
.viewer button:hover, .viewer button:focus-visible { color: #d9a877; }
.viewer-close { top: 0.5rem; inset-inline-end: 0.5rem; }
.viewer-prev { inset-inline-start: 0.25rem; top: 50%; translate: 0 -50%; }
.viewer-next { inset-inline-end: 0.25rem; top: 50%; translate: 0 -50%; }
@keyframes dissolve { from { opacity: 0; } }

/* Page-to-page dissolve (English ↔ فارسی, home ↔ now) */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: .6s; }

@media (prefers-reduced-motion: reduce) {
  .fragment, .photo img, .viewer img, a { transition: none; }
  .viewer[open] { animation: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

@media (max-width: 600px) {
  .viewer img { max-width: 100vw; }
  .viewer-prev, .viewer-next { top: auto; bottom: 0.4rem; translate: none; }
}

@media (max-width: 480px) {
  body { font-size: 18px; }
  .strip { gap: 0.4rem; }
  main { padding-top: 9vh; }
  .fragment { margin-top: 3rem; }
  .top nav { gap: 0.75rem; font-size: 0.85rem; }
  :lang(fa) .top nav { font-size: 1.05rem; }
  li { flex-wrap: wrap; }
  li > span { margin-inline-start: 0; padding-inline-start: 0; flex-basis: 100%; text-align: start; }
}
