
/* Tufte-inspired styles, adapted for dark mode and the polygonjs.com aesthetic.
   Original: https://edwardtufte.github.io/tufte-css/ */

@layer base {
  html {
    font-size: 15px;
  }
  body {
    font-family: Palatino, 'Palatino Linotype', 'Palatino LT STD', 'Book Antiqua', Georgia, serif;
    background-color: #151515;
    color: #ddd;
    width: 87.5%;
    margin-left: auto;
    margin-right: auto;
  }
  .tufte-container {
    padding-left: 12.5%;
    max-width: 1400px;
    counter-reset: sidenote-counter;
  }

  h1 {
    font-weight: 400;
    margin-top: 4rem;
    margin-bottom: 1.5rem;
    font-size: 3.2rem;
    line-height: 1;
  }

  h2 {
    font-style: italic;
    font-weight: 400;
    margin-top: 2.1rem;
    margin-bottom: 1.4rem;
    font-size: 2.2rem;
    line-height: 1;
  }

  h3 {
    font-style: italic;
    font-weight: 400;
    font-size: 1.7rem;
    margin-top: 2rem;
    margin-bottom: 1.4rem;
    line-height: 1;
  }

  hr {
    display: block;
    height: 1px;
    width: 55%;
    border: 0;
    border-top: 1px solid #555;
    margin: 1em 0;
    padding: 0;
  }

  p, dl, ol, ul {
    font-size: 1.4rem;
    line-height: 2rem;
  }

  p {
    margin-top: 1.4rem;
    margin-bottom: 1.4rem;
  }

  article {
    padding: 5rem 0;
  }

  section {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

  section > p,
  section > footer,
  section > table {
    width: 55%;
  }

  section > dl,
  section > ol,
  section > ul {
    width: 50%;
    padding-inline-start: 5%;
  }

  blockquote {
    font-size: 1.4rem;
  }

  blockquote p {
    width: 55%;
    margin-right: 40px;
  }

  blockquote footer {
    width: 55%;
    font-size: 1.1rem;
    text-align: right;
  }
}

@layer components {
  p.subtitle {
    font-style: italic;
    margin-top: 1rem;
    margin-bottom: 1rem;
    font-size: 1.8rem;
    display: block;
    line-height: 1;
  }

  /* Section-opening italic quote with cite below */
  div.epigraph {
    margin: 5em 0;
  }

  div.epigraph > blockquote {
    margin-top: 3em;
    margin-bottom: 3em;
    font-style: italic;
  }

  div.epigraph > blockquote > footer {
    font-style: normal;
  }

  div.epigraph > blockquote > footer > cite {
    font-style: italic;
  }

  /* Sidenotes and margin notes: floated into the wide right margin.
     Use <span class="sidenote">...</span> with a matching <span class="sidenote-number">
     in the body for auto-numbered sidenotes; .marginnote for unnumbered. */
  .sidenote,
  .marginnote {
    float: right;
    clear: right;
    margin-right: -60%;
    width: 50%;
    margin-top: 0.3rem;
    margin-bottom: 0;
    font-size: 1.1rem;
    line-height: 1.3;
    vertical-align: baseline;
    position: relative;
  }

  .sidenote-number {
    counter-increment: sidenote-counter;
  }

  .sidenote-number:after {
    content: counter(sidenote-counter);
    font-size: 1rem;
    top: -0.5rem;
    left: 0.1rem;
    position: relative;
    vertical-align: baseline;
  }

  .sidenote:before {
    content: counter(sidenote-counter) ' ';
    font-size: 1rem;
    top: -0.5rem;
    position: relative;
    vertical-align: baseline;
  }

  /* Small-caps section openers (use on first word(s) after an <h2>) */
  span.newthought {
    font-variant: small-caps;
    font-size: 1.2em;
  }
}

@media (max-width: 760px) {
  .tufte-container {
    width: 100%;
    padding-left: 8%;
    padding-right: 8%;
  }

  hr,
  section > p,
  section > footer,
  section > table {
    width: 100%;
  }

  section > dl,
  section > ol,
  section > ul {
    width: 90%;
  }

  blockquote p,
  blockquote footer {
    width: 100%;
  }

  .sidenote,
  .marginnote {
    display: none;
  }

  img {
    width: 100%;
  }
}
