/* Resheh: paper, iron-gall ink and the red ink of manuscript rubrics.
   Reem Kufi carries names, headings and the interface; Markazi Text carries reading. */

:root {
  --paper: #e4e3df;
  --paper-2: #d9d8d3;
  --paper-3: #cdcbc5;
  --ink: #1c1a17;
  --ink-soft: #524e48;
  --red: #b3202a;
  --red-ink: #f2f1ee;

  --field: #1c1a17;
  --field-2: #2a2723;
  --field-ink: #e4e3df;
  --field-soft: #aca8a0;

  --font-kufi: 'Reem Kufi', 'Noto Kufi Arabic', 'Geeza Pro', sans-serif;
  --font-naskh: 'Markazi Text', 'Amiri', 'Times New Roman', serif;

  --t-monument: clamp(6.5rem, 22vw, 24rem);
  --t-display: clamp(2.5rem, 5.4vw, 5.25rem);
  --t-head: clamp(1.625rem, 2.3vw, 2.25rem);
  --t-body: 1.3125rem;
  --t-small: 1.0625rem;

  --gutter: clamp(1.25rem, 2.6vw, 2.25rem);
  --col-gap: clamp(1rem, 2.2vw, 2rem);
  --measure: 92rem;
  --section: clamp(6.5rem, 12vw, 11rem);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-kashida: cubic-bezier(0.65, 0, 0.2, 1);
}

html.night {
  --paper: #191713;
  --paper-2: #24211c;
  --paper-3: #2f2b25;
  --ink: #e6e2d8;
  --ink-soft: #aaa398;
  --red: #e2585d;
  --red-ink: #191713;
  --field: #0f0e0b;
  --field-2: #1d1b17;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background-color: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-naskh);
  font-size: var(--t-body);
  line-height: 1.85;
  color: var(--ink);
  background-color: var(--paper);
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

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

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

::selection {
  background-color: var(--red);
  color: var(--red-ink);
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1.25rem;
  background-color: var(--ink);
  color: var(--paper);
  font-family: var(--font-kufi);
}

.skip-link:focus {
  inset-inline-start: var(--gutter);
  top: var(--gutter);
}

.frame {
  width: 100%;
  max-width: calc(var(--measure) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-block: var(--section);
}

/* Kashida: a word stretched by its own letters. */
.kashida {
  display: flex;
  align-items: baseline;
  width: 100%;
  white-space: nowrap;
}

.k-head,
.k-tail {
  flex: none;
}

.k-run {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  overflow: hidden;
  overflow: clip;
  transform-origin: right center;
}

.k-fill {
  display: inline-block;
  transform-origin: right center;
}

/* Growth: collapsed until the script measures the run and the word arrives on screen.
   If the script never runs, the fallback animation settles the word after three seconds. */
.js-ready [data-kashida-grow]:not(.is-grown) .k-run {
  transform: scaleX(0);
  animation: kashida-settle 1ms 3s forwards;
}

.js-ready [data-kashida-grow]:not(.is-grown) .k-tail {
  opacity: 0;
  transform: translateX(var(--run-w, 0px));
  animation: kashida-settle 1ms 3s forwards;
}

.js-ready [data-kashida-grow].is-armed:not(.is-grown) .k-tail {
  opacity: 1;
}

.js-ready [data-kashida-grow].is-armed .k-run,
.js-ready [data-kashida-grow].is-armed .k-tail {
  animation: none;
}

[data-kashida-grow].is-grown .k-run,
[data-kashida-grow].is-grown .k-tail {
  transition: transform 1400ms var(--ease-kashida), opacity 300ms ease-out;
}

@keyframes kashida-settle {
  to {
    opacity: 1;
    transform: none;
  }
}

/* Shared type */
.h-section {
  margin: 0;
  font-family: var(--font-kufi);
  font-size: var(--t-head);
  font-weight: 600;
  line-height: 1.35;
  text-wrap: balance;
}

.h-sub {
  margin: 0 0 1.5rem;
  font-family: var(--font-kufi);
  font-size: var(--t-head);
  font-weight: 600;
  line-height: 1.35;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
  padding: 0.6rem 1.75rem;
  border: 0;
  border-radius: 0;
  background-color: var(--red);
  color: var(--red-ink);
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  font-weight: 500;
  line-height: 1.4;
  transition: background-color 180ms ease-out, color 180ms ease-out, transform 160ms var(--ease-out);
}

.btn:hover {
  background-color: var(--ink);
  color: var(--paper);
}

.btn:active {
  transform: scale(0.97);
}

.text-link {
  display: inline-block;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  font-weight: 500;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.45em;
  transition: color 160ms ease-out, text-underline-offset 200ms var(--ease-out);
}

.text-link:hover {
  color: var(--red);
  text-underline-offset: 0.3em;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: var(--paper);
  font-family: var(--font-kufi);
}

.page-home .site-header {
  position: absolute;
  inset-inline: 0;
  background-color: transparent;
  color: var(--field-ink);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 4.75rem;
  width: 100%;
  max-width: calc(var(--measure) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.wordmark {
  font-size: var(--t-head);
  font-weight: 700;
  line-height: 1;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.4vw, 2.25rem);
  font-size: var(--t-small);
  font-weight: 500;
}

.site-nav a,
.nav-action {
  position: relative;
  padding-block: 0.4rem;
  transition: color 160ms ease-out;
}

.site-nav a::after,
.nav-action::after {
  content: '';
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 2px;
  background-color: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 260ms var(--ease-out);
}

.site-nav a:hover::after,
.nav-action:hover::after {
  transform: scaleX(1);
}

.nav-action {
  border: 0;
  background: none;
  font-weight: 600;
  color: var(--red);
}

.page-home .nav-action {
  color: var(--field-ink);
}

.nav-theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  transition: background-color 160ms ease-out, color 160ms ease-out, transform 140ms var(--ease-out);
}

.nav-theme:hover {
  background-color: var(--paper-2);
  color: var(--red);
}

.page-home .nav-theme:hover {
  background-color: var(--field-2);
  color: var(--field-ink);
}

.nav-theme:active {
  transform: scale(0.94);
}

.nav-theme .icon-sun {
  display: none;
}

html.night .nav-theme .icon-sun {
  display: block;
}

html.night .nav-theme .icon-moon {
  display: none;
}

/* Hero */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  padding-top: 4.75rem;
  background-color: var(--field);
  color: var(--field-ink);
  overflow: hidden;
}

.hero ::selection {
  background-color: var(--field-ink);
  color: var(--field);
}

.hero :focus-visible {
  outline-color: var(--field-ink);
}

.hero::before,
.hero-foot {
  flex: 1 1 0;
  padding-block: 0.5rem clamp(1.5rem, 3.5vh, 2.5rem);
}

.hero::before {
  content: '';
}

.hero-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  align-content: flex-end;
  justify-content: space-between;
  gap: 2rem;
}

.hero-lead {
  margin: 0;
  max-width: 34rem;
  font-size: var(--t-body);
  line-height: 1.7;
}

.hero .btn:hover {
  background-color: var(--field-ink);
  color: var(--field);
}

.monument {
  margin-block: 0;
  font-family: var(--font-kufi);
  font-size: var(--t-monument);
  font-weight: 700;
  line-height: 1.12;
}

/* A line from the archive */
.epigraph {
  padding-top: var(--section);
}

.epigraph-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.epigraph-label {
  margin: 0 0 clamp(1.5rem, 3vw, 2.5rem);
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  font-weight: 500;
  color: var(--red);
}

.epigraph-body {
  width: 100%;
  max-width: 58rem;
  transition: opacity 600ms ease-out, transform 600ms var(--ease-out);
}

.epigraph-body.is-leaving {
  opacity: 0;
  transform: translateY(-10px);
}

.epigraph-body.is-entering {
  opacity: 0;
  transform: translateY(10px);
  transition: none;
}

.epigraph-quote {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 2lh;
  margin: 0;
  font-family: var(--font-naskh);
  font-size: clamp(1.875rem, 3.2vw, 3.25rem);
  line-height: 1.55;
  text-wrap: balance;
}

.epigraph-quote p {
  margin: 0;
}

.epigraph-quote.is-verse p {
  display: inline-flex;
  flex-direction: column;
  gap: 0.15em;
  max-width: 100%;
}

.epigraph-cite {
  margin: 1.5rem 0 0;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  color: var(--ink-soft);
}

.epigraph-cite a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.45em;
}

.epigraph-next {
  margin-top: 1.25rem;
  padding: 0.5rem 0.25rem;
  border: 0;
  background: none;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  font-weight: 500;
  color: var(--ink-soft);
  transition: color 160ms ease-out, transform 160ms var(--ease-out);
}

.epigraph-next:hover {
  color: var(--red);
}

.epigraph-next:active {
  transform: scale(0.96);
}

/* Intro and facts */
.intro-head {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: var(--col-gap);
  align-items: start;
}

.intro-head .h-section {
  grid-column: 1 / 6;
  font-size: var(--t-display);
  line-height: 1.2;
}

.intro-note {
  grid-column: 7 / 13;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  font-size: var(--t-body);
  line-height: 1.8;
}

.intro-note p {
  margin: 0;
}

.facts {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-block: clamp(4.5rem, 8vw, 7.5rem) 0;
}

.fact {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 16rem;
}

.fact dt {
  font-family: var(--font-kufi);
  font-size: var(--t-display);
  font-weight: 400;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.fact dd {
  margin: 0;
  font-size: var(--t-body);
  line-height: 1.5;
  color: var(--ink-soft);
}

/* Categories: each name's tatweel runs in proportion to what was published in it */
.cats {
  background-color: var(--paper-2);
}

.cat-lines {
  list-style: none;
  margin: clamp(2.5rem, 5vw, 4rem) 0 0;
  padding: 0;
  container-type: inline-size;
  --run-max: 56cqi;
}

.cat-line {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  font-family: var(--font-kufi);
  font-size: var(--t-display);
  font-weight: 600;
  line-height: 1.6;
  transition: color 200ms ease-out;
}

.cat-line:hover,
.cat-line:focus-visible {
  color: var(--red);
}

.cat-name {
  display: flex;
  flex: none;
}

.cat-name .kashida {
  width: auto;
}

.cat-name .k-run {
  flex: none;
  width: calc(0.35em + var(--share) * var(--run-max));
}

.cat-count {
  flex: none;
  order: -1;
  width: 6.5rem;
  text-align: end;
  font-size: var(--t-small);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.cats-minor {
  margin: clamp(2rem, 4vw, 3rem) 0 0;
  font-size: var(--t-body);
  color: var(--ink-soft);
}

.cats-minor a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.4em;
}

/* Start from a letter */
.letters-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 88svh;
}

.letter-plate {
  display: grid;
  place-items: center;
  align-self: center;
  justify-self: center;
  width: min(100% - var(--gutter) * 2, 82svh);
  aspect-ratio: 1;
  margin-block: var(--gutter);
  background-color: var(--red);
  color: var(--red-ink);
  container-type: inline-size;
}

.plate-glyph {
  font-family: var(--font-kufi);
  font-size: 62cqi;
  font-weight: 700;
  line-height: 1.2;
  transition: opacity 220ms ease-out, transform 320ms var(--ease-out);
}

.plate-glyph.is-swapping {
  opacity: 0;
  transform: scale(0.92);
}

.letter-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2.5rem;
  padding: clamp(3rem, 7vw, 6rem) var(--gutter);
  padding-inline-start: clamp(1rem, 3vw, 3rem);
  max-width: 44rem;
}

.letter-keys {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 0.25rem;
  margin-top: 1.75rem;
}

.letter-keys button {
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  background-color: transparent;
  font-family: var(--font-kufi);
  font-size: var(--t-body);
  font-weight: 500;
  line-height: 1;
  transition: background-color 140ms ease-out, color 140ms ease-out, transform 140ms var(--ease-out);
}

.letter-keys button:hover {
  background-color: var(--paper-2);
}

.letter-keys button:active {
  transform: scale(0.92);
}

.letter-keys button[aria-pressed='true'] {
  background-color: var(--ink);
  color: var(--paper);
}

.letter-title {
  margin: 0;
  font-family: var(--font-kufi);
  font-size: var(--t-head);
  font-weight: 600;
  line-height: 1.35;
}

.letter-count {
  margin: 0.35rem 0 0;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  color: var(--ink-soft);
}

.letter-list {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.letter-list li {
  position: relative;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.1rem 1.5rem;
}

.letter-list a {
  font-family: var(--font-kufi);
  font-size: var(--t-body);
  font-weight: 500;
  line-height: 1.5;
  transition: color 140ms ease-out;
}

.letter-list a::after {
  content: '';
  position: absolute;
  inset: 0;
}

.letter-list li:hover a,
.letter-list a:hover {
  color: var(--red);
}

.letter-list span {
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  color: var(--ink-soft);
}

.letter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 4.5rem;
  padding: 0.5rem 1rem;
  border: 0;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  font-weight: 500;
  text-align: center;
  transition: background-color 160ms ease-out, color 160ms ease-out, transform 160ms var(--ease-out);
}

.cell:active {
  transform: scale(0.98);
}

.cell-ink {
  background-color: var(--ink);
  color: var(--paper);
}

.cell-ink:hover {
  background-color: var(--red);
  color: var(--red-ink);
}

.cell-tone {
  background-color: var(--paper-2);
}

.cell-tone:hover {
  background-color: var(--paper-3);
}

/* Seasons */
.seasons {
  padding-bottom: calc(var(--section) * 0.6);
  background-color: var(--paper-2);
}

.seasons-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: var(--col-gap);
  align-items: start;
}

.seasons-main {
  grid-column: 1 / 8;
}

.season-rows {
  margin: 3rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.season {
  position: relative;
  cursor: pointer;
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 1.75rem;
  align-items: baseline;
}

.season dt {
  font-family: var(--font-kufi);
  font-size: var(--t-head);
  font-weight: 500;
  line-height: 1.3;
  text-align: end;
  font-variant-numeric: tabular-nums;
}

.season dt a {
  transition: color 140ms ease-out;
}

.season dt a::after {
  content: '';
  position: absolute;
  inset: 0;
}

.season-count {
  font-weight: 600;
  transition: color 140ms ease-out;
}

.season:hover dt a,
.season:hover .season-count,
.season dt a:hover {
  color: var(--red);
}

.season dd {
  margin: 0;
  max-width: 40ch;
  font-size: var(--t-body);
  line-height: 1.6;
}

.seasons-peak {
  grid-column: 9 / 13;
  margin-top: 5rem;
  container-type: inline-size;
}

.peak-figure {
  margin: 0;
  font-family: var(--font-kufi);
  font-size: 46cqi;
  font-weight: 700;
  line-height: 1.05;
  color: var(--red);
  font-variant-numeric: tabular-nums;
}

.peak-note {
  margin: 1rem 0 0;
  max-width: 24rem;
  font-size: var(--t-body);
  line-height: 1.6;
}

/* Most read */
.mr-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: var(--col-gap);
  margin-top: clamp(2.5rem, 5vw, 3.5rem);
  align-items: start;
}

.mr-list {
  grid-column: 1 / 9;
  list-style: none;
  margin: 0;
  padding: 0;
}

.mr-item {
  position: relative;
}

.mr-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 9rem;
  align-items: baseline;
  gap: 0.25rem 1.5rem;
  padding-block: 0.35rem;
  color: var(--ink-soft);
  transition: color 200ms ease-out;
}

.mr-link::after {
  content: '';
  position: absolute;
  inset: 0;
}

.mr-item.is-active .mr-link {
  color: var(--ink);
}

.mr-title {
  font-family: var(--font-kufi);
  font-size: var(--t-display);
  font-weight: 600;
  line-height: 1.25;
}

.mr-meta {
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  font-weight: 500;
}

.mr-inline {
  display: none;
}

.mr-frame {
  grid-column: 9 / 13;
  position: sticky;
  top: 15vh;
  display: grid;
  aspect-ratio: 4 / 5;
  background-color: var(--paper-2);
}

.mr-preview {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  padding: clamp(1.5rem, 2.6vw, 2.5rem);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 220ms ease-out, transform 320ms var(--ease-out);
}

.mr-preview.is-active {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.mr-excerpt {
  margin: 0;
  font-size: var(--t-body);
  line-height: 1.85;
}

.mr-by {
  margin: auto 0 0;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  font-weight: 600;
}

.mr-reads {
  margin: 0.15rem 0 0;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  color: var(--ink-soft);
}

/* About */
.about {
  background-color: var(--paper-2);
}

.about-row {
  display: grid;
  grid-template-columns: 30% 1fr;
  column-gap: var(--col-gap);
  align-items: start;
}

.about-facts {
  margin: 0.6rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
}

.about-facts dt {
  color: var(--ink-soft);
}

.about-facts dd {
  margin: 0;
  font-weight: 500;
}

.about-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.75rem;
}

.about-quote {
  margin: 0;
  max-width: 36em;
}

.about-quote p {
  margin: 0;
  font-size: var(--t-head);
  line-height: 1.6;
}

.about-film,
.about-writers {
  margin-top: clamp(4.5rem, 8vw, 7rem);
}

.film {
  margin: 0;
  max-width: 48rem;
}

.film.post-film {
  margin-top: clamp(3rem, 6vw, 4.5rem);
}

.post-credit {
  margin-top: clamp(2.5rem, 5vw, 3.5rem);
  font-size: var(--t-small);
  color: var(--ink-soft);
}

.film-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background-color: var(--field);
}

.film-poster,
.film-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.film-poster {
  display: block;
  overflow: hidden;
}

.film-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.05);
  transition: filter 240ms ease-out, transform 600ms var(--ease-out);
}

html.night .film-poster img {
  filter: grayscale(1) invert(0.88) contrast(1.1);
}

.film-play {
  position: absolute;
  inset-block-end: 0;
  inset-inline-start: 0;
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  background-color: var(--red);
  color: var(--red-ink);
  transition: background-color 180ms ease-out, color 180ms ease-out;
}

.film-poster:hover img {
  filter: grayscale(0.4);
  transform: scale(1.02);
}

.film-poster:hover .film-play {
  background-color: var(--ink);
  color: var(--paper);
}

.film figcaption {
  margin-top: 0.9rem;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  color: var(--ink-soft);
}

.about-side {
  margin: 0;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  font-weight: 600;
}

.writer-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 20rem));
  gap: 0 4rem;
}

.writer-cols ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.writer-cols a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.4rem;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  transition: color 140ms ease-out;
}

.writer-cols a:hover {
  color: var(--red);
}

.writer-cols a span:last-child {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.writers-all {
  grid-column: 2;
  justify-self: start;
  margin-top: 2rem;
}

/* Footer */
.site-footer {
  position: relative;
  overflow: hidden;
  padding-top: clamp(5rem, 10vw, 9rem);
  background-color: var(--field);
  color: var(--field-ink);
  font-family: var(--font-kufi);
}

.site-footer ::selection {
  background-color: var(--field-ink);
  color: var(--field);
}

.site-footer :focus-visible {
  outline-color: var(--field-ink);
}

.footer-top {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: var(--col-gap);
  align-items: start;
}

.footer-invite {
  grid-column: 1 / 8;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2rem;
}

.footer-title {
  margin: 0;
  font-size: var(--t-display);
  font-weight: 600;
  line-height: 1.2;
}

.site-footer .btn:hover {
  background-color: var(--field-ink);
  color: var(--field);
}

.footer-links {
  grid-column: 10 / 13;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: var(--t-small);
}

.footer-links a {
  transition: color 140ms ease-out;
}

.footer-links a:hover {
  color: var(--field-soft);
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  margin-top: clamp(4rem, 8vw, 7rem);
  font-size: var(--t-small);
  color: var(--field-soft);
}

.footer-legal p {
  margin: 0;
}

.footer-legal a {
  color: var(--field-ink);
}

.footer-name {
  margin: 0;
  padding-inline: var(--gutter);
  font-size: clamp(8rem, 30vw, 32rem);
  font-weight: 700;
  line-height: 1;
  transform: translateY(26%);
  margin-top: -0.12em;
}

/* Article */
.post {
  padding-block: clamp(3rem, 7vw, 6rem) var(--section);
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: var(--col-gap);
}

.post-head {
  grid-column: 1 / 10;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.post-title {
  margin: 0;
  font-family: var(--font-kufi);
  font-size: var(--t-display);
  font-weight: 700;
  line-height: 1.25;
  text-wrap: balance;
}

.post-title.is-long {
  font-size: var(--t-head);
  line-height: 1.4;
}

.hamish {
  grid-column: 10 / 13;
  grid-row: 2;
  align-self: start;
  position: sticky;
  top: 6.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
}

.hamish-notes {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hamish-notes dt {
  color: var(--ink-soft);
}

.hamish-notes dd {
  margin: 0;
  font-weight: 500;
}

.hamish-notes a {
  color: var(--red);
  transition: color 140ms ease-out;
}

.hamish-notes a:hover {
  color: var(--ink);
}

.reader-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.reader-tools button {
  min-height: 2.5rem;
  padding: 0.25rem 0.85rem;
  border: 0;
  background-color: var(--paper-2);
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  transition: background-color 140ms ease-out, transform 140ms var(--ease-out);
}

.reader-tools button:hover {
  background-color: var(--paper-3);
}

.reader-tools button:active {
  transform: scale(0.95);
}

.post-main {
  grid-column: 1 / 9;
  grid-row: 2;
  min-width: 0;
}

.post-figure {
  margin: 0 0 2.5rem;
  max-width: 36rem;
}

.post-body {
  max-width: 34em;
  font-size: var(--reader-font-size, 1.4375rem);
  line-height: 2;
}

.post-body p {
  margin: 0 0 1.2em;
}

.post-body hr {
  height: 0;
  margin: 2.4em 0;
  border: 0;
}

.post-body strong {
  font-weight: 600;
}

.post-body a {
  color: var(--red);
  text-decoration: underline;
  text-underline-offset: 0.35em;
}

.post-body blockquote {
  margin: 1.75em 0;
  padding: 1.25em 1.5em;
  background-color: var(--paper-2);
}

.post-body ul,
.post-body ol {
  padding-inline-start: 1.25em;
}

.post-body h2,
.post-body h3,
.post-body h4 {
  font-family: var(--font-kufi);
  font-size: 1em;
  font-weight: 600;
}

.post-body img {
  margin-block: 1.5em;
}

.post-body.is-poetry .verse-stanza {
  margin-bottom: 1.6em;
  line-height: 2.15;
}

.article-figure {
  margin: 2rem 0;
}

.archival-note {
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  padding: 0.9rem 1.15rem;
  background-color: var(--paper-2);
}

.archive-banner {
  margin: 0 0 2.5rem;
  padding: 1.35rem 1.65rem;
  background-color: var(--paper-2);
  border-inline-start: 4px solid var(--red);
}

.archive-banner-title {
  margin: 0 0 0.45rem;
  font-family: var(--font-kufi);
  font-size: var(--t-body);
  font-weight: 600;
  color: var(--red);
  line-height: 1.45;
}

.archive-banner p:last-child {
  margin: 0;
  line-height: 1.75;
}

/* Classical verse: the two half-lines of a bayt face each other across a gap */
.bayt {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 12.5em));
  justify-content: center;
  column-gap: 3em;
  margin-block: 0.35em;
  font-weight: 400;
}

.shatr {
  text-align: justify;
  text-align-last: justify;
}

.post-tags {
  margin: 2.5rem 0 0;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  line-height: 2;
}

.post-tags span {
  color: var(--ink-soft);
}

.post-tags a {
  text-decoration: underline;
  text-underline-offset: 0.4em;
  transition: color 140ms ease-out;
}

.post-tags a:hover {
  color: var(--red);
}

.author-card {
  position: relative;
  cursor: pointer;
  margin-top: 3.5rem;
  padding: clamp(1.5rem, 3vw, 2.25rem);
  background-color: var(--paper-2);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  transition: background-color 160ms ease-out;
}

.author-card:hover {
  background-color: var(--paper-3);
}

.author-card-name {
  margin: 0;
  font-family: var(--font-kufi);
  font-size: var(--t-head);
  font-weight: 600;
  line-height: 1.35;
}

.author-card-name a::after {
  content: '';
  position: absolute;
  inset: 0;
}

.author-card:hover .text-link {
  color: var(--red);
  text-underline-offset: 0.3em;
}

.author-card-count {
  margin: 0;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  color: var(--ink-soft);
}

.author-card-bio {
  margin: 0.4rem 0 0.6rem;
  max-width: 40em;
  line-height: 1.8;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.pager-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.25rem 1.5rem;
  background-color: var(--paper-2);
  font-family: var(--font-kufi);
  transition: background-color 160ms ease-out;
}

.pager-next {
  text-align: end;
}

.pager-link:hover {
  background-color: var(--paper-3);
}

.pager-dir {
  font-size: var(--t-small);
  color: var(--ink-soft);
}

.pager-title {
  font-size: var(--t-body);
  font-weight: 600;
  line-height: 1.5;
}

.comments,
.related {
  margin-top: clamp(4rem, 7vw, 5.5rem);
}

.comment {
  padding: 1.25rem 1.5rem;
  background-color: var(--paper-2);
  margin-bottom: 0.5rem;
}

.comment-children {
  margin-top: 1rem;
}

.comment-reply {
  background-color: var(--paper);
  margin-inline-start: 1.5rem;
}

.comment-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  color: var(--ink-soft);
}

.comment-author {
  font-weight: 600;
  color: var(--ink);
}

.comment-body {
  margin: 0.5rem 0 0;
  line-height: 1.8;
}

.related-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.related-list a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  font-family: var(--font-kufi);
  transition: color 140ms ease-out;
}

.related-list a:hover {
  color: var(--red);
}

.related-title {
  font-size: var(--t-body);
  font-weight: 500;
}

.related-meta {
  font-size: var(--t-small);
  color: var(--ink-soft);
}

/* Lists: archive, sections, seasons, tags, writers */
.list-page {
  padding-block: clamp(3rem, 7vw, 6rem) var(--section);
}

.list-head {
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.list-title {
  margin: 0;
  font-family: var(--font-kufi);
  font-size: var(--t-display);
  font-weight: 700;
  line-height: 1.3;
  text-wrap: balance;
}

.list-sub {
  margin: 1rem 0 0;
  max-width: 44rem;
  font-size: var(--t-body);
  line-height: 1.7;
}

.rows {
  display: flex;
  flex-direction: column;
}

.row {
  position: relative;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.25fr) 12rem;
  grid-template-areas: 'title excerpt meta';
  align-items: start;
  column-gap: var(--col-gap);
  padding: 1.6rem 1.25rem;
  margin-inline: -1.25rem;
  transition: background-color 160ms ease-out;
}

.row:hover {
  background-color: var(--paper-2);
}

.row-title {
  grid-area: title;
  margin: 0;
  font-family: var(--font-kufi);
  font-size: var(--t-head);
  font-weight: 600;
  line-height: 1.4;
}

.row-title a {
  transition: color 140ms ease-out;
}

.row-title a::after {
  content: '';
  position: absolute;
  inset: 0;
}

.row:hover .row-title a,
.row-title a:hover {
  color: var(--red);
}

.row-excerpt {
  grid-area: excerpt;
  margin: 0;
  padding-top: 0.35rem;
  line-height: 1.75;
}

.row-meta {
  grid-area: meta;
  margin: 0;
  padding-top: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: end;
  gap: 0.15rem;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  color: var(--ink-soft);
}

.row-meta a {
  position: relative;
  z-index: 1;
  font-weight: 600;
  color: var(--ink);
  transition: color 140ms ease-out;
}

.row-meta a:hover {
  color: var(--red);
  text-decoration: underline;
  text-underline-offset: 0.35em;
}

.archive-tools {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: clamp(1.25rem, 2.5vw, 2rem);
  background-color: var(--paper-2);
  font-family: var(--font-kufi);
}

.archive-fields {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  font-size: var(--t-small);
  font-weight: 500;
}

.field input,
.field select {
  min-height: 3rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--paper-3);
  border-radius: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-kufi);
  font-size: var(--t-small);
}

.field input:focus,
.field select:focus {
  border-color: var(--ink);
}

.harf-rail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(2.6rem, 1fr));
  gap: 0.25rem;
}

.harf-rail button {
  min-width: 2.6rem;
  min-height: 2.6rem;
  padding: 0 0.6rem;
  border: 0;
  background-color: transparent;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  font-weight: 500;
  transition: background-color 140ms ease-out, color 140ms ease-out;
}

.harf-rail button:hover {
  background-color: var(--paper-3);
}

.harf-rail button[aria-pressed='true'] {
  background-color: var(--ink);
  color: var(--paper);
}

.archive-status {
  margin: 1.5rem 0 1rem;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
  color: var(--ink-soft);
}

.author-profile {
  margin-bottom: 2.5rem;
  max-width: 44rem;
}

.author-profile-bio {
  margin: 0;
  font-size: var(--t-body);
  line-height: 1.8;
}

.author-social {
  margin: 1rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-family: var(--font-kufi);
  font-size: var(--t-small);
}

.author-social a {
  text-decoration: underline;
  text-underline-offset: 0.4em;
}

.index-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
  font-family: var(--font-kufi);
  font-size: var(--t-body);
}

.index-rail a {
  display: grid;
  place-items: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding-inline: 0.5rem;
  background-color: var(--paper-2);
  transition: background-color 140ms ease-out, color 140ms ease-out;
}

.index-rail a:hover {
  background-color: var(--ink);
  color: var(--paper);
}

.name-index {
  display: flex;
  flex-direction: column;
  gap: clamp(1.75rem, 3vw, 2.5rem);
}

.index-group {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  column-gap: var(--col-gap);
  align-items: baseline;
  scroll-margin-top: 6rem;
}

.index-letter {
  margin: 0;
  font-family: var(--font-kufi);
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--red);
}

.index-letter.is-latin {
  font-size: var(--t-head);
  white-space: nowrap;
}

.index-names {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--font-kufi);
  font-size: var(--t-head);
  line-height: 1.75;
}

.index-names li {
  display: inline;
  white-space: nowrap;
}

.index-name {
  unicode-bidi: isolate;
}

.index-names li:not(:last-child)::after {
  content: '،';
  color: var(--ink-soft);
}

.index-names a {
  font-weight: 600;
  transition: color 140ms ease-out;
}

.index-names a:hover {
  color: var(--red);
}

.index-count {
  margin-inline-start: 0.3em;
  font-size: var(--t-small);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.tag-field {
  margin: 0;
  font-family: var(--font-kufi);
  line-height: 1.9;
  text-align: justify;
}

.tag-field + .tag-field {
  margin-top: 1.5rem;
}

.tag-field a {
  display: inline-block;
  transition: color 140ms ease-out;
}

.tag-field a:hover {
  color: var(--red);
}

.tag-field a span {
  font-size: var(--t-small);
  color: var(--ink-soft);
}

.tag-1 {
  font-size: var(--t-head);
  font-weight: 600;
}

.tag-2 {
  font-size: var(--t-body);
  font-weight: 500;
}

.tag-3 {
  font-size: var(--t-small);
}

.tag-sep {
  font-size: var(--t-small);
  color: var(--ink-soft);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  margin: 0;
}

.lost-list {
  margin-top: var(--section);
}

.lost-list ol {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  columns: 2 22rem;
  column-gap: var(--col-gap);
}

.lost-list li {
  break-inside: avoid;
}

.lost-list a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  padding-block: 0.6rem;
  font-family: var(--font-kufi);
  transition: color 140ms ease-out;
}

.lost-list a:hover {
  color: var(--red);
}

.lost-title {
  font-size: var(--t-head);
  font-weight: 600;
}

.lost-meta {
  flex: none;
  font-size: var(--t-small);
  color: var(--ink-soft);
}

/* Arrival */
.js-ready [data-reveal] {
  opacity: 0;
  transform: translateY(24px);
}

.js-ready [data-reveal].is-revealed {
  opacity: 1;
  transform: none;
  transition: opacity 700ms ease-out, transform 800ms var(--ease-out);
}

/* Tablet */
@media (max-width: 1024px) {
  .intro-head .h-section {
    grid-column: 1 / 7;
  }

  .intro-note {
    grid-column: 7 / 13;
  }

  .facts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    row-gap: 2.5rem;
  }

  .letters-grid {
    grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
    grid-template-areas:
      'plate title'
      'keys keys'
      'result result'
      'actions actions';
    column-gap: var(--col-gap);
    row-gap: 2.25rem;
    align-items: end;
    min-height: 0;
    padding: var(--section) var(--gutter);
  }

  .letter-panel,
  .letter-top {
    display: contents;
  }

  .letter-plate {
    grid-area: plate;
    width: 100%;
    margin: 0;
  }

  .letter-top .h-section {
    grid-area: title;
  }

  .letter-keys {
    grid-area: keys;
    margin-top: 0;
  }

  .letter-result {
    grid-area: result;
  }

  .letter-actions {
    grid-area: actions;
  }

  .seasons-main {
    grid-column: 1 / -1;
  }

  .seasons-peak {
    grid-column: 1 / 8;
    margin-top: 4rem;
  }

  .mr-list {
    grid-column: 1 / -1;
  }

  .mr-frame {
    display: none;
  }

  .mr-link {
    color: var(--ink);
  }

  .mr-inline {
    display: block;
    margin: 0.25rem 0 2rem;
    max-width: 38em;
    line-height: 1.8;
  }

  .post-head,
  .post-main {
    grid-column: 1 / -1;
  }

  .hamish {
    grid-column: 1 / -1;
    grid-row: 2;
    position: static;
    margin-bottom: 2.5rem;
    gap: 1.25rem;
  }

  .hamish-notes {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem 2rem;
  }

  .post-main {
    grid-row: 3;
  }
}

/* Phone */
@media (max-width: 680px) {
  :root {
    --t-display: clamp(2.25rem, 10vw, 3rem);
  }

  .site-nav {
    gap: clamp(0.75rem, 3vw, 1.5rem);
  }

  .nav-optional,
  .nav-action {
    display: none;
  }

  .hero-foot {
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 1.25rem;
  }

  .monument {
    font-size: 28vw;
  }

  .intro-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1.5rem;
  }

  .facts {
    column-gap: 1.25rem;
  }

  .cat-line {
    flex-wrap: wrap;
    gap: 0 1rem;
    font-size: 11vw;
    line-height: 1.35;
    margin-bottom: 0.75rem;
  }

  .cat-name {
    flex-basis: 100%;
  }

  .cat-lines {
    --run-max: 58cqi;
  }

  .about-quote p {
    font-size: var(--t-body);
  }

  .mr-link {
    grid-template-columns: 1fr;
  }

  .cat-count {
    order: 0;
    width: auto;
    text-align: start;
  }

  .letters-grid {
    grid-template-columns: minmax(0, 9rem) minmax(0, 1fr);
    row-gap: 1.75rem;
  }

  .letter-keys {
    grid-template-columns: repeat(7, 1fr);
  }

  .epigraph-quote {
    font-size: var(--t-head);
  }

  .letter-actions {
    grid-template-columns: 1fr;
  }

  .cell {
    min-height: 3.75rem;
  }

  .season {
    grid-template-columns: 5rem 1fr;
    gap: 1rem;
  }

  .seasons-peak {
    grid-column: 1 / -1;
  }

  .about-row {
    grid-template-columns: 1fr;
    row-gap: 2rem;
  }

  .about-facts {
    order: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .writer-cols {
    grid-template-columns: 1fr;
  }

  .writers-all {
    grid-column: 1;
  }

  .footer-invite,
  .footer-links {
    grid-column: 1 / -1;
  }

  .footer-links {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin-top: 3rem;
  }

  .footer-name {
    font-size: 36vw;
  }

  .bayt {
    grid-template-columns: 1fr;
    row-gap: 0.1em;
  }

  .bayt .shatr {
    text-align: start;
    text-align-last: auto;
  }

  .bayt .shatr + .shatr {
    padding-inline-start: 2.5em;
    text-align: end;
  }

  .pager {
    grid-template-columns: 1fr;
  }

  .pager-next {
    text-align: start;
  }

  .row {
    grid-template-columns: 1fr;
    grid-template-areas:
      'title'
      'excerpt'
      'meta';
  }

  .row-meta {
    flex-direction: row;
    align-items: baseline;
    text-align: start;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
  }

  .archive-fields {
    grid-template-columns: 1fr 1fr;
  }

  .field-search {
    grid-column: 1 / -1;
  }

  .index-group {
    grid-template-columns: 3.5rem 1fr;
  }
}

@media (min-width: 681px) and (max-width: 1024px) {
  .row {
    grid-template-columns: minmax(0, 1fr) 11rem;
    grid-template-areas:
      'title meta'
      'excerpt meta';
  }
}

@media (prefers-reduced-motion: reduce) {
  .js-ready [data-reveal],
  .js-ready [data-kashida-grow] .k-run,
  .js-ready [data-kashida-grow] .k-tail {
    opacity: 1;
    transform: none;
    animation: none;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
