/* ==========================================================================
   andrewhalliday.wiki
   An encyclopedia-style reference theme, written from scratch.
   Tokens first; every rule downstream references them.
   ========================================================================== */

:root {
  /* colour */
  --ink:          #202122;
  --ink-soft:     #54595d;
  --ink-faint:    #72777d;
  --paper:        #ffffff;
  --chrome:       #f6f6f6;
  --panel:        #f8f9fa;
  --rule:         #a2a9b1;
  --rule-soft:    #c8ccd1;
  --rule-faint:   #eaecf0;
  --link:         #3366cc;
  --link-visited: #6b4ba1;
  --link-new:     #b32424;
  --accent-bar:   #36c;
  --focus:        #3366cc;

  /* type */
  --font-serif: Georgia, "Times New Roman", times, serif;
  --font-body:  -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono:  ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --size-body:   0.875rem;   /* 14px, the encyclopedia baseline */
  --size-small:  0.8125rem;
  --size-tiny:   0.75rem;
  --lh-body:     1.6;

  /* spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* layout */
  --shell-max:  1200px;
  --rail-width: 11rem;
}

/* --------------------------------------------------------------------------
   Reset and base
   -------------------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--chrome);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--size-body);
  line-height: var(--lh-body);
}

a {
  color: var(--link);
  text-decoration: none;
}
a:visited { color: var(--link-visited); }
a:hover, a:focus-visible { text-decoration: underline; }

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

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

/* Skip link */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--paper);
  color: var(--ink);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--rule);
  z-index: 100;
}
.skip:focus {
  left: var(--space-4);
  top: var(--space-2);
}

/* --------------------------------------------------------------------------
   Site chrome: masthead
   -------------------------------------------------------------------------- */

.masthead {
  background: var(--paper);
  border-bottom: 1px solid var(--rule-soft);
}

.masthead__inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-family: var(--font-serif);
  font-size: 1.125rem;
  color: var(--ink);
  text-decoration: none;
}
.wordmark:visited { color: var(--ink); }
.wordmark:hover { text-decoration: none; }

.wordmark__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--panel);
  font-size: 0.9375rem;
  line-height: 1;
  color: var(--ink-soft);
  flex: none;
  align-self: center;
}

.wordmark__tld {
  font-family: var(--font-body);
  font-size: var(--size-tiny);
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.masthead__search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.masthead__search input {
  font: inherit;
  font-size: var(--size-small);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  border-radius: 2px;
  width: 12rem;
  max-width: 40vw;
}

/* --------------------------------------------------------------------------
   Shell: rail + article
   -------------------------------------------------------------------------- */

.shell {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: var(--space-4);
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

/* Left rail */

.rail {
  font-size: var(--size-small);
  position: sticky;
  top: var(--space-4);
}

.rail__group + .rail__group { margin-top: var(--space-5); }

.rail__title {
  font-size: var(--size-tiny);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  font-weight: 400;
  margin: 0 0 var(--space-2);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--rule-faint);
}

.rail__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rail__list li { margin-bottom: var(--space-1); }

/* Article surface */

.article {
  background: var(--paper);
  border: 1px solid var(--rule-soft);
  padding: var(--space-5) var(--space-6) var(--space-7);
  min-width: 0;
}

/* Tab strip above the title */

.tabs {
  display: flex;
  gap: var(--space-4);
  margin: 0 0 var(--space-4);
  padding: 0 0 var(--space-2);
  list-style: none;
  border-bottom: 1px solid var(--rule-soft);
  font-size: var(--size-small);
}
.tabs li { color: var(--ink-faint); }
.tabs .is-active {
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 -3px 0 var(--accent-bar);
  padding-bottom: var(--space-2);
  margin-bottom: calc(var(--space-2) * -1);
}

/* --------------------------------------------------------------------------
   Article typography
   -------------------------------------------------------------------------- */

.article h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.75rem;
  line-height: 1.3;
  margin: 0 0 var(--space-1);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--rule-soft);
}

.tagline {
  color: var(--ink-soft);
  font-size: var(--size-small);
  font-style: italic;
  margin: 0 0 var(--space-5);
}

.article h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.375rem;
  line-height: 1.4;
  margin: var(--space-6) 0 var(--space-3);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--rule-soft);
  clear: none;
}

.article h3 {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  margin: var(--space-5) 0 var(--space-2);
}

.article p { margin: 0 0 var(--space-3); }

.article ul, .article ol {
  margin: 0 0 var(--space-3);
  padding-left: var(--space-5);
}
.article li { margin-bottom: var(--space-1); }

.article blockquote {
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-4);
  background: var(--panel);
  border-left: 3px solid var(--rule);
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--ink);
}
.article blockquote p:last-child { margin-bottom: 0; }

/* The decorative [edit] marker that gives the encyclopedia its texture */
.editmark {
  font-family: var(--font-body);
  font-size: var(--size-tiny);
  font-weight: 400;
  color: var(--ink-faint);
  white-space: nowrap;
}
.editmark::before { content: "[" ; }
.editmark::after  { content: "]" ; }

/* Superscript citations */
.cite {
  font-size: var(--size-tiny);
  line-height: 1;
  vertical-align: super;
}

/* --------------------------------------------------------------------------
   Infobox
   -------------------------------------------------------------------------- */

.infobox {
  float: right;
  width: 22rem;
  max-width: 100%;
  margin: 0 0 var(--space-4) var(--space-5);
  border: 1px solid var(--rule);
  background: var(--panel);
  font-size: var(--size-small);
  border-collapse: collapse;
  line-height: 1.5;
}

.infobox caption {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  padding: var(--space-3) var(--space-2);
  background: var(--panel);
  border-bottom: 1px solid var(--rule-soft);
  caption-side: top;
}

.infobox__portrait {
  padding: var(--space-3) var(--space-2);
  text-align: center;
  border-bottom: 1px solid var(--rule-faint);
}

.infobox__monogram {
  width: 7.5rem;
  height: 7.5rem;
  margin: 0 auto var(--space-2);
  border: 1px solid var(--rule-soft);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 2.75rem;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.infobox__caption {
  font-size: var(--size-tiny);
  color: var(--ink-soft);
  margin: 0;
}

.infobox th,
.infobox td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-2);
  border-top: 1px solid var(--rule-faint);
}

.infobox th {
  width: 7.5rem;
  font-weight: 700;
  color: var(--ink);
}

.infobox__section th {
  width: auto;
  background: var(--rule-faint);
  text-align: center;
  font-weight: 700;
}

.infobox ul {
  margin: 0;
  padding-left: var(--space-4);
}

/* --------------------------------------------------------------------------
   Table of contents
   -------------------------------------------------------------------------- */

.toc {
  display: inline-block;
  min-width: 16rem;
  max-width: 100%;
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--panel);
  border: 1px solid var(--rule-soft);
}

.toc__title {
  font-family: var(--font-serif);
  font-size: 1rem;
  text-align: center;
  margin: 0 0 var(--space-2);
}

.toc ol {
  list-style: none;
  counter-reset: toc;
  margin: 0;
  padding: 0;
}
.toc ol ol {
  counter-reset: toc-sub;
  padding-left: var(--space-4);
  margin-top: var(--space-1);
}
.toc li {
  counter-increment: toc;
  margin-bottom: var(--space-1);
}
.toc li::before {
  content: counter(toc) " ";
  color: var(--ink-soft);
}
.toc ol ol li { counter-increment: toc-sub; }
.toc ol ol li::before {
  content: counter(toc) "." counter(toc-sub) " ";
}

/* --------------------------------------------------------------------------
   Quick facts / key-value blocks
   -------------------------------------------------------------------------- */

.factgrid {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--size-small);
  margin: 0 0 var(--space-4);
  border: 1px solid var(--rule-soft);
}
.factgrid caption {
  caption-side: top;
  text-align: left;
  font-weight: 700;
  padding-bottom: var(--space-2);
}
.factgrid th,
.factgrid td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--rule-faint);
}
.factgrid tr:first-child th,
.factgrid tr:first-child td { border-top: 0; }
.factgrid th {
  width: 12rem;
  background: var(--panel);
  font-weight: 700;
}

/* Principles list, set as a quoted stack */
.principles {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-4);
  border-top: 1px solid var(--rule-faint);
}
.principles li {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--rule-faint);
  font-family: var(--font-serif);
  font-size: 1rem;
}

/* --------------------------------------------------------------------------
   References and external links
   -------------------------------------------------------------------------- */

.references {
  font-size: var(--size-small);
  padding-left: var(--space-5);
  color: var(--ink-soft);
}
.references li { margin-bottom: var(--space-2); }
.references a { word-break: break-word; }

.linklist {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-4);
}
.linklist li {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--rule-faint);
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: baseline;
}
.linklist__label {
  min-width: 11rem;
  font-weight: 700;
  flex: none;
}
.linklist__note {
  color: var(--ink-faint);
  font-size: var(--size-tiny);
  flex-basis: 100%;
}

/* Long URLs must wrap rather than push the article sideways on a phone. */
.linklist a { word-break: break-word; min-width: 0; }

/* The small outbound arrow the encyclopedia convention puts on external links */
a[rel~="external"]::after,
.linklist a::after {
  content: "";
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-left: 0.3em;
  background: currentColor;
  opacity: 0.55;
  -webkit-mask: var(--ext-icon) center / contain no-repeat;
          mask: var(--ext-icon) center / contain no-repeat;
}
:root {
  --ext-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 1h5v5H9.5V3.56L4.53 8.53 3.47 7.47 8.44 2.5H6V1z'/%3E%3Cpath d='M1 3h3v1.5H2.5v5h5V8H9v3H1V3z'/%3E%3C/svg%3E");
}

/* --------------------------------------------------------------------------
   Notices
   -------------------------------------------------------------------------- */

.notice {
  border: 1px solid var(--rule-soft);
  border-left: 4px solid var(--rule);
  background: var(--panel);
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-5);
  font-size: var(--size-small);
  color: var(--ink-soft);
}
.notice p { margin: 0; }
.notice p + p { margin-top: var(--space-2); }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.footer {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-7);
  font-size: var(--size-small);
  color: var(--ink-soft);
  border-top: 1px solid var(--rule-soft);
}
.footer ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin: 0 0 var(--space-3);
  padding: 0;
}
.footer p { margin: 0 0 var(--space-2); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 60rem) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }
  .rail {
    position: static;
    border-bottom: 1px solid var(--rule-soft);
    padding-bottom: var(--space-4);
  }
  .rail__group + .rail__group { margin-top: var(--space-4); }
  .infobox {
    float: none;
    width: 100%;
    margin: 0 0 var(--space-5);
  }
}

@media (max-width: 40rem) {
  .article {
    padding: var(--space-4) var(--space-4) var(--space-6);
    border-left: 0;
    border-right: 0;
  }
  .shell { padding: var(--space-3) 0; }
  .masthead__search { margin-left: 0; width: 100%; }
  .masthead__search input { width: 100%; max-width: none; }
  .article h1 { font-size: 1.5rem; }
  .article h2 { font-size: 1.25rem; }
  .linklist__label { min-width: 0; flex-basis: 100%; }
  .factgrid th { width: auto; }
  .toc { display: block; }
}

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

@media print {
  body { background: #fff; }
  .rail, .masthead__search, .tabs, .skip { display: none; }
  .article { border: 0; padding: 0; }
}
