/* Found in Translation

   Type
   --serif     Instrument Serif: titles, section titles, recordings, English translation
   --sans      Helvetica: navigation, credits, controls, notes
   --deva      Sumana: poetry and titles in Devanagari
   --nastaliq  Noto Nastaliq Urdu: poetry and titles in Urdu script

   Colour roles
   --ink       text and titles
   --ink-2     explanations and supporting text
   --ink-3     labels, numerals, metadata (4.5:1 or better on white and on --wash)
   --accent    one maroon, used for exactly three things:
               the English translation, the site title, and interactive state
               (hover, current page, selected option, focus ring)
   --wash      background of a highlighted couplet
   --rule      hairlines

   Layout
   --gutter    outer page margin
   --rail      a narrow left column for the ghazal index and couplet numbers */

:root {
  --paper: #ffffff;
  --ink: #161616;
  --ink-2: #3f3f3f;
  --ink-3: #636363;
  --accent: #850000;
  --wash: #f7eeee;
  --rule: #e3dddd;

  --serif: "Instrument Serif", Georgia, serif;
  --sans: Helvetica, "Helvetica Neue", Arial, "Liberation Sans", "Nimbus Sans", sans-serif;
  --deva: "Sumana", "Noto Serif Devanagari", serif;
  --nastaliq: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", serif;

  --gutter: clamp(16px, 3vw, 44px);
  --rail: 64px;
  --wide: 1640px;
  --ease: cubic-bezier(.2, .6, .2, 1);
  --nav-h: 72px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-padding-block-start: calc(var(--nav-h) + 24px);
}

body {
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  padding-block-start: var(--nav-h);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

a {
  color: inherit;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

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

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

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  inset-inline-start: var(--gutter);
  inset-block-start: -100px;
  z-index: 20;
  padding: 10px 16px;
  background: var(--paper);
  border: 2px solid var(--accent);
}

.skip:focus {
  inset-block-start: 12px;
}

/* ---------- Scripts ---------- */

[lang="ur-Deva"], [lang="hi"] {
  font-family: var(--deva);
}

[lang="ur"] {
  font-family: var(--nastaliq);
}

bdi.native {
  color: var(--ink-3);
}

/* Only the chosen script and translation are shown.
   <html data-script data-trans> is set in the markup and updated by ghazal.js. */
html[data-script="deva"] [data-s]:not([data-s="deva"]),
html[data-script="arab"] [data-s]:not([data-s="arab"]),
html[data-script="latn"] [data-s]:not([data-s="latn"]),
html[data-trans="en"] [data-t]:not([data-t="en"]),
html[data-trans="hi"] [data-t]:not([data-t="hi"]) {
  display: none;
}

/* ---------- Bracketed navigation ---------- */

.site-nav {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-block-size: var(--nav-h);
  padding-inline: var(--gutter);
  background: var(--paper);
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
  font-size: 18px;
  text-decoration: none;
  color: var(--ink);
  transition: color .18s var(--ease);
}

.site-nav a[aria-current="page"],
.site-nav a:hover {
  color: var(--accent);
}

/* ---------- Page frame ---------- */

main {
  max-inline-size: var(--wide);
  margin-inline: auto;
  padding: 0 var(--gutter) 72px;
}

.page-title {
  font-family: var(--serif);
  font-size: clamp(64px, 11vw, 150px);
  font-weight: 400;
  line-height: .95;
  margin-block: 24px 48px;
}

.section {
  padding-block: 56px 8px;
}

.section-title {
  font-family: var(--serif);
  font-size: clamp(32px, 3.4vw, 44px);
  font-weight: 400;
  line-height: 1.1;
  margin-block-end: 20px;
}

/* Ghazal sections align with the title, leaving the rail for numbers */
.work .section {
  margin-inline-start: var(--rail);
}

.work .section .couplets,
.work .section .columns-label {
  margin-inline-start: calc(-1 * var(--rail));
}

.aside {
  max-inline-size: 40em;
  margin-block-end: 20px;
  color: var(--ink-2);
}

/* ---------- Ghazal: title block ---------- */

.work-head {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 24rem);
  column-gap: 64px;
  align-items: start;
  padding-block: 28px 48px;
  padding-inline-start: var(--rail);
  border-block-end: 1px solid var(--rule);
}

.work-titles {
  grid-column: 1 / -1;
}

.work-index {
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: 28px;
  padding-block-start: .45em;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  color: var(--ink-3);
}

.work-title {
  font-family: var(--serif);
  font-size: clamp(54px, 9vw, 128px);
  font-weight: 400;
  line-height: .95;
  letter-spacing: -.01em;
  text-wrap: balance;
}

.work-title-script {
  text-wrap: balance;
  margin-block-start: 16px;
  color: var(--ink-2);
}

.work-title-script [lang="ur-Deva"] {
  font-size: clamp(34px, 4.8vw, 58px);
  line-height: 1.35;
}

.work-title-script [lang="ur"] {
  display: inline-block;
  font-size: clamp(30px, 4.2vw, 50px);
  line-height: 2.1;
}

html[data-script="latn"] .work-title-script {
  display: none;
}

.intro {
  grid-column: 1;
  grid-row: 2;
  max-inline-size: 40em;
  margin-block-start: 36px;
  font-size: 19px;
  line-height: 1.65;
  color: var(--ink-2);
}

.credits {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  gap: 10px;
  margin-block-start: 40px;
  font-size: 17px;
  line-height: 1.4;
}

.credits > div {
  display: grid;
  grid-template-columns: 8.5em 1fr;
  gap: 12px;
}

.credits dt {
  color: var(--ink-3);
}

.credits .note {
  color: var(--ink-3);
}

/* ---------- Choices: recordings, script, translation ---------- */

.choice {
  border: 0;
  min-inline-size: 0;
}

.choice legend {
  float: inline-start;
  margin-inline-end: 16px;
  min-block-size: 44px;
  display: flex;
  align-items: center;
  font-size: 16px;
  color: var(--ink-3);
}

.choice-options {
  display: flex;
  flex-wrap: wrap;
  column-gap: 22px;
}

.choice label {
  position: relative;
  cursor: pointer;
}

.choice input {
  position: absolute;
  opacity: 0;
  inline-size: 1px;
  block-size: 1px;
}

.choice label > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-block-size: 44px;
  font-size: 17px;
  color: var(--ink-2);
  text-decoration: underline transparent;
  text-underline-offset: 6px;
  text-decoration-thickness: 1px;
  transition: color .18s var(--ease), text-decoration-color .18s var(--ease);
}

.choice label:hover > span,
.choice input:checked + span {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.choice input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.choice bdi[lang="ur"] {
  font-size: 18px;
  line-height: 1;
}

/* Recording names are set in the serif: they are the performers, not settings */
.renditions label > span {
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.1;
  color: var(--ink);
}

.read-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 40px;
  margin-block-end: 12px;
}

.read-head .section-title {
  margin-block-end: 0;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0 36px;
}

.controls:empty {
  display: none;
}

/* ---------- Listen ---------- */

.recording {
  display: grid;
  grid-template-columns: minmax(0, 640px) minmax(14rem, 1fr);
  gap: 20px 48px;
  align-items: start;
  margin-block-start: 20px;
}

.player {
  grid-column: 1;
  grid-row: 1;
}

.now {
  grid-column: 2;
  grid-row: 1;
  max-inline-size: 30em;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-2);
}

.now .ctx::first-letter {
  text-transform: uppercase;
}

.now .about {
  margin-block-start: 10px;
  color: var(--ink-3);
}

.player iframe {
  display: block;
  inline-size: 100%;
  border: 0;
}

.player .yt {
  aspect-ratio: 16 / 9;
}

.player .bc {
  block-size: 120px;
}

.player .elsewhere {
  margin-block-start: 10px;
  font-size: 16px;
  color: var(--ink-2);
}

/* Native audio player, for recordings hosted with the site */
.audio {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
}

.audio button {
  inline-size: 52px;
  block-size: 52px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.audio button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.audio input[type="range"] {
  inline-size: 100%;
  block-size: 24px;
  accent-color: var(--accent);
}

.audio .time {
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  color: var(--ink-2);
}

/* ---------- Poem and translation ---------- */

.columns-label {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
  padding-block-end: 10px;
  padding-inline: var(--rail) 20px;
  font-size: 15px;
  color: var(--ink-3);
  border-block-end: 1px solid var(--rule);
}

.columns-label .tr-label {
  color: var(--accent);
}

.couplets {
  list-style: none;
}

.couplet {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 64px;
  align-items: start;
  padding-block: 26px;
  padding-inline: var(--rail) 20px;
  border-block-end: 1px solid var(--rule);
  transition: background-color .22s var(--ease);
}

.couplet:focus {
  outline: none;
}

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

.couplet.is-active {
  background: var(--wash);
}

.c-num {
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: 30px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}

.couplet.is-active .c-num {
  color: var(--accent);
}

.l {
  display: block;
  padding-inline-start: 1em;
  text-indent: -1em;
}

/* Each script gets its own size and leading, set by eye in the browser. */
.src [lang="ur-Deva"] {
  font-size: 25px;
  line-height: 1.8;
}

.src [lang="ur"] {
  font-size: 24px;
  line-height: 2.35;
}

.src [lang="ur-Latn"] {
  font-family: var(--sans);
  font-size: 20px;
  line-height: 1.75;
}

.src .refrain {
  color: var(--ink-2);
}

.tr {
  font-family: var(--serif);
  font-size: 27px;
  line-height: 1.4;
  color: var(--accent);
}

.tr-missing,
.text-note {
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink-3);
}

/* Glossary: opens with its couplet when scripting is on, always shown otherwise */
.gloss {
  grid-column: 1 / -1;
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows .26s var(--ease), opacity .26s var(--ease);
}

.gloss > dl {
  overflow: hidden;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 32px;
  padding-block-start: 10px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink-2);
}

.gloss dt {
  display: inline;
  color: var(--ink);
}

.gloss .term[lang="ur-Deva"] { font-size: 19px; }
.gloss .term[lang="ur"] { font-size: 18px; line-height: 2; }
.gloss .term[lang="ur-Latn"] { font-weight: 700; }

.gloss .tl {
  margin-inline-start: 8px;
  color: var(--ink-3);
}

html[data-script="latn"] .gloss .tl {
  display: none;
}

.gloss dd {
  display: inline;
}

.gloss dd::before {
  content: ": ";
}

.js .gloss {
  grid-template-rows: 0fr;
  opacity: 0;
}

.js .couplet.is-active .gloss {
  grid-template-rows: 1fr;
  opacity: 1;
}

/* ---------- Notes and sources: quiet endnotes ---------- */

.endnotes {
  max-inline-size: 46em;
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-2);
}

.endnotes .section-title {
  font-size: 30px;
  color: var(--ink);
}

.endnotes > p,
.endnotes > div {
  margin-block-start: 14px;
}

.endnotes b {
  font-weight: 700;
  color: var(--ink);
}

.endnotes ul {
  list-style: none;
  margin-block-start: 4px;
}

.endnotes li + li {
  margin-block-start: 4px;
}

.endnotes .missing {
  color: var(--ink-3);
}

/* ---------- Previous / next ---------- */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-inline-size: var(--wide);
  margin-inline: auto;
  padding: 32px var(--gutter) 64px;
  border-block-start: 1px solid var(--rule);
}

.pager a {
  display: block;
  padding-block: 6px;
  text-decoration: none;
  color: var(--ink);
}

.pager .next {
  grid-column: 2;
  text-align: end;
}

.pager .dir {
  display: block;
  font-size: 16px;
  color: var(--ink-2);
}

.pager .to {
  display: block;
  margin-block-start: 2px;
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.2;
}

.pager a:hover .dir,
.pager a:hover .to {
  color: var(--accent);
}

/* ---------- Ghazal list ---------- */

.entries {
  list-style: none;
}

.entry {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  padding-block: 32px;
  border-block-start: 1px solid var(--rule);
}

.entry .n {
  padding-block-start: 14px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}

.entry h2 {
  font-family: var(--serif);
  font-size: clamp(38px, 5vw, 60px);
  font-weight: 400;
  line-height: 1.05;
}

.entry h2 a {
  text-decoration: none;
}

.entry .meta {
  margin-block-start: 8px;
  font-size: 16px;
  color: var(--ink-3);
}

.entry .summary {
  margin-block-start: 14px;
  max-inline-size: 40em;
  line-height: 1.65;
  color: var(--ink-2);
}

/* ---------- Info ---------- */

.prose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 56px 64px;
}

.prose section {
  max-inline-size: 36em;
}

.prose h2 {
  font-family: var(--serif);
  font-size: clamp(34px, 3.6vw, 48px);
  font-weight: 400;
  line-height: 1.1;
}

.prose p {
  margin-block-start: 14px;
  font-size: 19px;
  line-height: 1.7;
  color: var(--ink-2);
}

/* ---------- Home ---------- */

.home {
  min-block-size: calc(100vh - var(--nav-h) - 72px);
  display: grid;
  place-items: center;
}

#title {
  position: relative;
  z-index: 1;
  font-family: var(--serif);
  font-size: clamp(56px, 9.5vw, 128px);
  font-weight: 400;
  line-height: .95;
  text-align: center;
  color: var(--accent);
  margin-block-end: 8vh;
}

.drift {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.drift > div {
  position: absolute;
  opacity: 0;
  color: var(--ink-3);
  animation: drift 12s linear infinite;
}

.drift [lang="ur-Deva"] { font-size: 26px; }
.drift [lang="ur"] { font-size: 23px; line-height: 2.2; }

.drift > div:nth-child(1) { inset-inline-start: 8vw;  inset-block-start: 18vh; animation-delay: 0s; }
.drift > div:nth-child(2) { inset-inline-start: 58vw; inset-block-start: 14vh; animation-delay: 4s; }
.drift > div:nth-child(3) { inset-inline-start: 52vw; inset-block-start: 66vh; animation-delay: 8s; }
.drift > div:nth-child(4) { inset-inline-start: 12vw; inset-block-start: 72vh; animation-delay: 6s; }
.drift > div:nth-child(5) { inset-inline-start: 74vw; inset-block-start: 28vh; animation-delay: 2s; }
.drift > div:nth-child(6) { inset-inline-start: 5vw;  inset-block-start: 58vh; animation-delay: 10s; }
.drift > div:nth-child(7) { inset-inline-start: 36vw; inset-block-start: 84vh; animation-delay: 5s; }

@keyframes drift {
  0%   { opacity: 0; transform: scale(.9); }
  20%  { opacity: .7; transform: scale(1); }
  45%  { opacity: .7; }
  70%  { opacity: 0; transform: scale(1.35); }
  100% { opacity: 0; }
}

/* ---------- Medium screens ---------- */

@media (max-width: 1000px) {
  .work-head {
    grid-template-columns: minmax(0, 1fr);
  }

  .credits {
    grid-column: 1;
    grid-row: 3;
    margin-block-start: 28px;
  }

  .recording {
    grid-template-columns: minmax(0, 1fr);
  }

  .now {
    grid-column: 1;
    grid-row: 1;
  }

  .player {
    grid-row: 2;
    max-inline-size: 640px;
  }

  .prose {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
  :root {
    --nav-h: 60px;
    --rail: 36px;
  }

  body {
    font-size: 17px;
  }

  .site-nav a {
    font-size: 16px;
  }

  /* On phones the index sits above the title and text uses the full width */
  .work-head {
    display: flex;
    flex-direction: column;
    padding-inline-start: 0;
  }

  .intro { order: 1; }
  .credits { order: 2; }

  .work-index {
    position: static;
    padding-block-start: 0;
    margin-block-end: 6px;
  }

  .work .section {
    margin-inline-start: 0;
  }

  .work .section .couplets,
  .work .section .columns-label {
    margin-inline-start: 0;
  }

  .credits > div {
    grid-template-columns: 7.5em 1fr;
  }

  .columns-label {
    display: none;
  }

  .couplet {
    grid-template-columns: 1fr;
    padding-block: 22px;
    padding-inline-end: 8px;
  }

  .c-num {
    inset-block-start: 26px;
  }

  .src [lang="ur-Deva"] { font-size: 20px; }
  .src [lang="ur"] { font-size: 19px; line-height: 2.3; }
  .src [lang="ur-Latn"] { font-size: 18px; }

  .tr {
    font-size: 23px;
    padding-block-start: 4px;
  }

  .renditions label > span {
    font-size: 23px;
  }

  .choice legend {
    float: none;
    min-block-size: 0;
    margin-block-end: 2px;
  }

  .pager .to {
    font-size: 22px;
  }

  .drift [lang="ur-Deva"] { font-size: 18px; }
  .drift [lang="ur"] { font-size: 17px; }

  .drift > div:nth-child(2) { inset-inline-start: 40vw; inset-block-start: 10vh; }
  .drift > div:nth-child(5) { inset-inline-start: 56vw; inset-block-start: 26vh; }
  .drift > div:nth-child(6) { inset-block-start: 62vh; }
}

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

  .drift > div {
    animation: none;
    opacity: .35;
  }
}
