/* hamedmalek.com: styles for every page except the home page.
   style.css is loaded first and holds the colours, the typeface and the page frame. */

/* Tables. "#+LAYOUT: record" marks the three-column record of work. */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
  line-height: 1.45;
}

th {
  padding: 0 1.5rem 0.5rem 0;
  border-bottom: 1px solid var(--ink);
  color: var(--quiet);
  font-style: italic;
  font-weight: 400;
  text-align: left;
  vertical-align: bottom;
}

td {
  padding: 0.75rem 1.5rem 0.8rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

th:last-child,
td:last-child {
  padding-right: 0;
}

.layout-record td:first-child {
  width: 5.25rem;
  color: var(--quiet);
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}

.layout-record th:last-child,
.layout-record td:last-child {
  width: 37%;
}

.layout-record .prose table {
  margin-block: 0 1.5rem;
}

@media (max-width: 40rem) {
  .layout-record table,
  .layout-record tbody,
  .layout-record tr,
  .layout-record td {
    display: block;
    width: auto;
  }

  .layout-record thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .layout-record tr {
    padding-block: 0.9rem;
    border-bottom: 1px solid var(--rule);
  }

  .layout-record tr:first-child {
    border-top: 1px solid var(--ink);
  }

  .layout-record td,
  .layout-record td:first-child,
  .layout-record td:last-child {
    width: auto;
    padding: 0;
    border: 0;
  }

  .layout-record td:first-child {
    font-size: 0.92em;
  }

  .layout-record td:last-child {
    margin-top: 0.4rem;
  }

  .layout-record td:last-child::before {
    content: "What came of it: ";
    color: var(--quiet);
    font-style: italic;
  }
}

/* Articles and plain pages */

.article-head h1 {
  max-width: 24ch;
  margin-block: clamp(2.75rem, 9vh, 5.5rem) 1.25rem;
  font-size: clamp(1.9rem, 1.3rem + 2.5vw, 2.9rem);
  font-weight: 400;
  line-height: 1.14;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.article-side {
  color: var(--quiet);
  font-style: italic;
}

.article-side p {
  margin: 0 0 1rem;
}

.draft-flag {
  color: var(--measure);
}

.prose {
  max-width: var(--text);
}

.prose > :first-child,
.prose > section:first-child > :first-child {
  margin-top: 0;
}

@media (min-width: 52rem) {
  .article {
    display: grid;
    grid-template-columns: var(--side) minmax(0, 1fr);
    column-gap: var(--gap);
    align-items: start;
  }

  .article-head {
    grid-column: 1 / -1;
  }

  .article-head h1 {
    margin-bottom: 2.5rem;
  }

  .article-side {
    grid-column: 1;
  }

  .prose {
    grid-column: 2;
  }
}

.prose h2 {
  margin: 2.3em 0 0.6em;
  font-size: 1.32em;
  font-weight: 700;
  line-height: 1.25;
}

.prose h3 {
  margin: 1.9em 0 0.4em;
  font-size: 1.08em;
  font-style: italic;
  font-weight: 400;
  line-height: 1.35;
}

.prose ul,
.prose ol {
  padding-left: 1.3em;
}

.prose li {
  margin-bottom: 0.3em;
}

.prose li > p {
  margin-bottom: 0.3em;
}

.prose blockquote {
  margin-inline: 0;
  padding-left: 1.2rem;
  border-left: 2px solid var(--ink);
}

.prose blockquote > :last-child {
  margin-bottom: 0;
}

.prose img,
.prose svg,
.prose video {
  max-width: 100%;
  height: auto;
}

.prose figure {
  margin-inline: 0;
  margin-block: 1.75em;
}

.prose figcaption,
.prose caption {
  margin-top: 0.5rem;
  color: var(--quiet);
  font-size: 0.88em;
  text-align: left;
}

.prose caption {
  caption-side: bottom;
}

.prose table {
  margin-block: 1.5em;
  font-variant-numeric: lining-nums tabular-nums;
}

.prose hr {
  margin-block: 2.5em;
  border: 0;
  border-top: 1px solid var(--rule);
}

code,
pre,
kbd,
samp {
  font-family: var(--mono);
  font-size: 0.8em;
}

pre {
  padding: 0.95rem 1.1rem;
  overflow-x: auto;
  border-radius: 3px;
  background: var(--wash);
  line-height: 1.5;
  tab-size: 4;
}

pre code {
  font-size: 1em;
}

/* Code colouring, kept quiet: comments recede, keywords are bold, strings are tinted. */

code span.co,
code span.do,
code span.an,
code span.cv,
code span.in {
  color: var(--quiet);
  font-style: italic;
}

code span.kw,
code span.cf,
code span.im {
  font-weight: 700;
}

code span.st,
code span.ss,
code span.vs,
code span.ch {
  color: var(--string);
}

.footnote-ref {
  text-decoration-line: none;
}

.footnotes {
  margin-top: 3em;
  color: var(--quiet);
  font-size: 0.88em;
}

.footnotes hr {
  width: 6rem;
  margin: 0 0 1.25em;
  border: 0;
  border-top: 1px solid var(--rule);
}

.footnotes ol {
  padding-left: 1.3em;
}

/* Pages with "#+LAYOUT: sections": each top-level heading hangs in the
   left margin, as on the home page. Used by the research page. */

.layout-sections .prose > section {
  margin-top: clamp(2.75rem, 8vh, 4.5rem);
}

.layout-sections .prose > section > h2 {
  margin: 0 0 1rem;
  font-size: 1.15em;
  font-style: italic;
  font-weight: 400;
  line-height: 1.35;
}

.layout-sections .prose section section + section {
  margin-top: 1.9rem;
}

.layout-sections .prose h3 {
  margin: 0;
  font-size: 1em;
  font-style: normal;
  font-weight: 700;
  line-height: 1.4;
  text-wrap: pretty;
}

.layout-sections .prose section section > :last-child {
  margin-bottom: 0;
}

.byline p {
  margin: 0.1rem 0 0.45rem;
  color: var(--quiet);
  font-style: italic;
}

/* One figure per thesis: below the text on narrow screens, beside it on wide ones.
   The images keep a white ground in dark mode, since the figures were drawn on white. */

.layout-sections .prose figure {
  max-width: 24rem;
  margin: 1.1rem 0 0;
}

.layout-sections .prose figure a {
  display: block;
}

.layout-sections .prose figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  background: #fff;
}

.layout-sections .prose figcaption {
  margin-top: 0.5rem;
  color: var(--quiet);
  font-size: 0.8em;
  line-height: 1.45;
  text-wrap: pretty;
}

@media (min-width: 64rem) {
  .layout-sections .prose > section > section:has(> figure) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 15rem;
    grid-template-rows: repeat(4, auto) 1fr;
    column-gap: 1.75rem;
    max-width: none;
  }

  .layout-sections .prose > section > section:has(> figure) > :not(figure) {
    grid-column: 1;
  }

  /* The extra rows let a tall figure grow the last row, not push the title away from its text. */
  .layout-sections .prose > section > section:has(> figure) > figure {
    grid-column: 2;
    grid-row: 1 / span 5;
    margin-top: 0.3rem;
  }
}

@media (min-width: 52rem) {
  .layout-sections .prose {
    grid-column: 1 / -1;
    max-width: none;
  }

  .layout-sections .prose > :not(section) {
    max-width: var(--text);
    margin-left: calc(var(--side) + var(--gap));
  }

  .layout-sections .prose > section {
    display: grid;
    grid-template-columns: var(--side) minmax(0, 1fr);
    column-gap: var(--gap);
    align-items: start;
  }

  .layout-sections .prose > section > h2 {
    grid-column: 1;
    margin: 0;
    font-size: 1em;
    line-height: 1.4;
  }

  .layout-sections .prose > section > :not(h2) {
    grid-column: 2;
    max-width: var(--text);
  }

  .layout-sections .prose > section > table {
    max-width: none;
  }
}

/* List of articles */

.index {
  margin: 0;
  padding: 0;
  list-style: none;
}

.index li {
  margin: 0;
  padding-block: 1.1rem;
  border-bottom: 1px solid var(--rule);
}

.index li:first-child {
  padding-top: 0;
}

.index a {
  font-size: 1.15em;
}

.index time {
  display: block;
  color: var(--quiet);
  font-size: 0.88em;
  font-style: italic;
}

.index p {
  margin: 0.35rem 0 0;
}

/* Inner pages can be long, so the name, the icons and the menu stay at the top while you scroll. */
.site-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-block: clamp(0.7rem, 2vw, 1rem);
  background: var(--paper);
  box-shadow: 0 1px 0 var(--rule);
}
