/* =============================================================
   resistant atlas — styles shared by every page

   The page is set on a grid: one line of text = --line.
   Every space (above a heading, around a picture, between
   sections) is a whole number of lines, so everything lines up.
   Press G on any page to see the guides.
   ============================================================= */

:root {
  /* colour */
  --paper: #f9f8f2;                    /* the cream page */
  --veil:  rgba(249, 248, 242, 0.9);   /* thin paper: the menu — the page shows through */
  --veil-bar: rgba(249, 248, 242, 0.95); /* header and footer: a fainter show-through */
  --ink:   #2e2a26;                    /* text: warm near-black */
  --soft:  rgba(46, 42, 38, 0.6);      /* labels, captions */
  --rule:  rgba(46, 42, 38, 0.16);     /* hairlines */
  --rule-bar: rgba(46, 42, 38, 0.32);  /* the lines under the header and above the footer */
  --night: #1b1a18;                    /* the dark table around the page */
  --blue:  #2c3c6c;                    /* Rumma night blue: the menu leaf */
  --on-blue: #f3e9d8;                  /* Rumma cream: text on the blue */

  /* type */
  --text:  1.22rem;                    /* body text */
  --line:  1.75rem;                    /* one line = the grid unit */
  --small: 0.96rem;                    /* captions, notes, menu */
  --title: 1.55rem;                    /* chapter titles */

  /* layout */
  --column: 50%;                       /* page width on a computer */
  --frame:  2.4rem;                    /* dark space above and below the page */
  --margin: calc(var(--line) * 2);     /* page margins, left and right */
  --indent: var(--line);               /* first-line indent */
  --gutter: var(--line);               /* space between columns */
}

* { box-sizing: border-box; }

/* Text size grows with the window, like it did on Cargo. */
html {
  font-size: max(13px, 1.4vw);
  background: var(--night);
}

body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: "EB Garamond", "Noto Naskh Arabic", Garamond, Georgia, serif;
  font-size: var(--text);
  font-weight: 400;
  line-height: var(--line);
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums proportional-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- the page: one book page on a dark table ---------- */

/* the dark strip above and below the page stays put while you scroll */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 30;
  left: 50%;
  width: var(--column);
  height: var(--frame);
  transform: translateX(-50%);
  background: var(--night);
  pointer-events: none;
}
body::before { top: 0; }
body::after  { bottom: 0; }

.page {
  width: var(--column);
  min-height: calc(100vh - 2 * var(--frame));
  margin: var(--frame) auto;
  padding: 0 var(--margin) calc(var(--line) * 2);
  background: var(--paper);
  overflow-x: clip;          /* nothing pokes out sideways, so a phone only scrolls up and down */
}

/* Small lowercase text: "menu", page number */
.label {
  font-size: var(--small);
  line-height: var(--line);
  color: var(--ink);
}

/* Running head (made by site.js): your mark on the left, "menu" on the right.
   Its edges sit exactly on the text margins. Three lines tall. */
.head {
  position: sticky;
  top: var(--frame);
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: calc(var(--line) * 3);
  margin: 0 calc(var(--margin) * -1);
  padding: 0 var(--margin);
  background: var(--veil-bar);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
}
/* your name: "resistant atlas" in text, then the Arabic calligraphy */
.head .mark {
  white-space: nowrap;
  font-size: calc(var(--text) * 1.2);
  font-style: italic;
  color: var(--ink);
}
.head .mark img {
  display: inline-block;
  height: 1.4em;
  width: auto;
  margin-left: 0.6em;
  vertical-align: -0.35em;   /* puts the long Arabic stroke on the same line as the English */
  opacity: 0.85;             /* black calligraphy softened to the same warm ink as the text */
}
.head a:hover,
.head button:hover { color: var(--ink); }
/* hairline under the header, the width of the text */
.head::after {
  content: "";
  position: absolute;
  left: var(--margin);
  right: var(--margin);
  bottom: 0;
  height: 1px;
  background: var(--rule-bar);
}
.head button:focus:not(:focus-visible),
.menu-close:focus:not(:focus-visible) { outline: none; }
.head button {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ---------- chapter opener: number and name, centred ---------- */

.title {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  margin: calc(var(--line) * 4) 0 calc(var(--line) * 2);
  font-size: var(--title);
  line-height: var(--line);
}
.title p {
  margin: 0;
  color: var(--soft);
}
.title p::after { content: "."; }
.title h1 {
  margin: 0;
  font: inherit;
}

/* ---------- text ---------- */

/* Book paragraphs: no blank line between them, the next one is indented. */
p { margin: 0; }
p + p { text-indent: var(--indent); }
main p { hanging-punctuation: first; text-wrap: pretty; }

b, strong { font-weight: 600; }

a { color: inherit; text-decoration: none; }
a:active { opacity: 0.7; }
main p a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--rule);
}
main p a:hover { text-decoration-color: currentColor; }

/* Section headings inside a page: italic, a line of space above */
h3 {
  font: inherit;
  font-style: italic;
  margin: calc(var(--line) * 2) 0 var(--line);
}

blockquote {
  margin: var(--line) 0;
  padding-left: var(--indent);
}

ol, ul {
  margin: var(--line) 0;
  padding-left: calc(var(--indent) * 1.5);
}
ol { list-style-type: decimal-leading-zero; }
li ul { margin: 0; }
li::marker { color: var(--soft); }

/* A thin line between sections: one line of space above and below */
hr {
  border: 0;
  height: 1px;
  margin: calc(var(--line) - 1px) 0 var(--line);
  background: var(--rule);
}

sub {
  position: relative;
  vertical-align: baseline;
  top: 0.3em;
  font-size: 0.75em;
  line-height: 0;
}

.center { text-align: center; }
.right  { text-align: right; }
.larger { font-size: 1.2em; }
.center p, .right p, [dir="rtl"] p { text-indent: 0; }

/* Lines up with the page title, e.g. <p class="inset">I</p> */
.inset { padding-left: calc((100% - var(--gutter)) / 6 + var(--gutter)); }

/* Arabic text: two grid lines per line */
[dir="rtl"] {
  font-family: "Noto Naskh Arabic", "EB Garamond", serif;
  line-height: calc(var(--line) * 1.5);
}

/* Journal entries: set in from both sides, same voice as the text */
.journal {
  margin: var(--line) 0;
  padding: 0 var(--indent);
}

/* Small text: captions and footnotes */
figcaption,
.notes {
  font-size: var(--small);
  line-height: calc(var(--line) * 0.75);
  color: var(--soft);
}

/* ---------- images and videos ----------
   Three sizes: <figure> is the full text width,
   <figure class="half"> and <figure class="small"> are centred.
   site.js pads each picture so the text after it stays on the grid. */

figure {
  margin: calc(var(--line) * 2) 0;
}
figure.center,
figure.large,
figure.half,
figure.small {
  margin-left: auto;
  margin-right: auto;
}
figure.large { width: 75%; }
figure.half  { width: 55%; }
figure.small { width: 35%; }

figure img,
figure video {
  display: block;
  width: 100%;
  height: auto;
}

figcaption { margin-top: calc(var(--line) * 0.5); }

/* Two images side by side */
.pair {
  display: flex;
  gap: var(--gutter);
  align-items: flex-start;
  margin: calc(var(--line) * 2) 0;
}
.pair figure { flex: 1 1 0; margin: 0; }

/* ---------- columns ----------
   <div class="cols"> with children like <div style="--span:4">.
   Spans are out of 12. */

.cols {
  display: flex;
  gap: var(--gutter);
  margin: var(--line) 0;
}
.cols > * { flex: var(--span, 1) 1 0; min-width: 0; }
.cols p + p { text-indent: 0; }

/* Footnotes: in the right half of the page */
.notes { margin: calc(var(--line) * 2) 0 0 50%; }
.note {
  display: grid;
  grid-template-columns: 1fr 5fr;
  margin-bottom: calc(var(--line) * 0.25);
}
.note span { min-width: 0; overflow-wrap: anywhere; }   /* long web addresses wrap instead of running off the page */

/* ---------- little extras (being phased out page by page) ---------- */

.pill { color: var(--soft); font-style: italic; }

.button {
  display: inline-block;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--rule);
}

/* Folder mark after reading titles: <span class="folder"></span> */
.folder {
  display: inline-block;
  width: 0.9em;
  height: 0.72em;
  margin-left: 0.2em;
  vertical-align: -0.02em;
  background: var(--soft);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 16'%3E%3Cpath d='M1.5 2.5h6l2 2h9v10h-17z' fill='none' stroke='black' stroke-width='1.2' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 16'%3E%3Cpath d='M1.5 2.5h6l2 2h9v10h-17z' fill='none' stroke='black' stroke-width='1.2' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- field notes (collapsible journal entries) ---------- */

.field-note {
  border-top: 1px solid var(--rule);
  margin: 0;
}
.field-note:last-of-type { border-bottom: 1px solid var(--rule); }
.field-note summary {
  cursor: pointer;
  list-style: none;
  padding: var(--line) 0;
}
.field-note summary::-webkit-details-marker { display: none; }
.field-note .when {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft);
}
.field-note .journal { margin: 0; padding: 0; }
.field-note .more {
  display: block;
  font-style: italic;
  font-size: var(--small);
  color: var(--soft);
}
.field-note .more::after { content: "Read entry"; }
.field-note[open] .more::after { content: "Close"; }
.field-note .body { padding: 0 0 var(--line); }
.field-note .close {
  display: inline-block;
  margin-top: var(--line);
  font-style: italic;
  font-size: var(--small);
  color: var(--soft);
  cursor: pointer;
}

/* ---------- menu (made by site.js) ----------
   A leaf of blue paper laid over the right of the page, unfolding from the right.
   It reads like a table of contents: numbers hang in their own column,
   chapters are full size, the pages inside them are smaller and set in. */

.menu {
  position: fixed;
  z-index: 25;
  top: var(--frame);
  right: calc((100% - var(--column)) / 2);
  width: calc(var(--column) * 0.72);
  max-height: calc(100vh - 2 * var(--frame));
  overflow-y: auto;
  padding: 0 var(--margin) var(--line);
  background: var(--blue);
  color: var(--on-blue);
  font-weight: 500;
  visibility: hidden;
  clip-path: inset(0 0 0 100%);
  transition: clip-path 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s 0.5s;
}
body.menu-open .menu {
  visibility: visible;
  clip-path: inset(0 0 0 0);
  transition: clip-path 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s;
}

/* "close" sits exactly where "menu" was */
.menu-top {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  height: calc(var(--line) * 3);
  margin-bottom: calc(var(--line) * 0.5);
}
.menu-close {
  font: inherit;
  font-size: var(--small);
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.toc ul { list-style: none; margin: 0 0 calc(var(--line) * 0.6); padding: 0; }
.toc li { font-size: var(--text); line-height: calc(var(--line) * 0.85); }
.toc a {
  display: grid;
  grid-template-columns: 2.6rem 1fr;
  color: inherit;
}
.toc .n { opacity: 0.55; }
.toc li.sub { opacity: 0.85; }   /* same size as the chapters; only set in */
.toc li.sub a { padding-left: 2.6rem; }
.toc li.sub + li:not(.sub) { margin-top: calc(var(--line) * 0.2); }
.toc a[aria-current] .t { font-style: italic; }
.toc a:hover .t { opacity: 0.7; }

/* ---------- ← page number → at the foot (made by site.js) ---------- */

/* Stays stuck to the bottom of the window while you read */
.pager {
  position: sticky;
  bottom: var(--frame);
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: calc(var(--line) * 2);
  margin: calc(var(--line) * 3) calc(var(--margin) * -1) 0;
  padding: 0 var(--margin);
  background: var(--veil-bar);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
}
.pager > :nth-child(3) { text-align: right; }
/* hairline above the footer, the width of the text */
.pager::before {
  content: "";
  position: absolute;
  left: var(--margin);
  right: var(--margin);
  top: 0;
  height: 1px;
  background: var(--rule-bar);
}
.pager a { font-size: var(--text); padding: 0 0.2em; }
.pager a:hover { color: var(--soft); }

/* ---------- guides: press G ---------- */

body.guides .page {
  background-image:
    linear-gradient(to right,
      transparent calc(var(--margin) - 1px), rgba(220, 60, 90, 0.5) calc(var(--margin) - 1px) var(--margin),
      transparent var(--margin) calc(100% - var(--margin)),
      rgba(220, 60, 90, 0.5) calc(100% - var(--margin)) calc(100% - var(--margin) + 1px),
      transparent calc(100% - var(--margin) + 1px)),
    linear-gradient(to right, transparent calc(50% - 0.5px), rgba(220, 60, 90, 0.3) calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--line) - 1px), rgba(60, 120, 220, 0.18) calc(var(--line) - 1px) var(--line));
}
body.guides .head, body.guides .pager { background: transparent; }

/* ---------- phones and narrow windows ---------- */

@media (max-width: 800px) {
  :root {
    --column: 100%;
    --frame: 0px;
    --margin: var(--line);
  }
  html { font-size: max(14px, min(4vw, 18px)); }
  .head .mark { font-size: var(--text); }
  .head .mark img { height: 1.25em; margin-left: 0.45em; }
  .page { margin: 0; min-height: 100vh; }
  .title { margin: calc(var(--line) * 3) 0 calc(var(--line) * 2); }
  figure.large { width: 100%; }
  .menu { right: 0; width: 86%; max-height: 100vh; max-height: 100dvh; }
  figure.half { width: 75%; }
  figure.small { width: 50%; }
  figure[style] { width: auto !important; }
  .notes { margin-left: 0; }
}

/* ---------- fingers: on phones and tablets every menu line is easy to tap ---------- */

@media (max-width: 800px), (pointer: coarse) {
  .toc ul { margin-bottom: var(--line); }
  .toc li,
  .toc li.sub { line-height: var(--line); }
  .toc a { padding: calc(var(--line) * 0.25) 0; }
  .toc li.sub + li:not(.sub) { margin-top: 0; }
  /* "menu" and "close" keep their look but take a bigger touch */
  .head button,
  .menu-close { padding: 0.7rem; margin: -0.7rem; }
}
