/* Linked from every page by `restore.py build`. Fixes layout only: on a desktop the
   pages should look as they did, and on a phone the columns stack. */

/* The older pages tile a ~1100px-wide border image; on a wider screen the stripe
   reappeared down the right-hand side. */
body {
  background-repeat: repeat-y;
}

/* Home page: the build keeps one copy of the section list (the original pasted eight
   down the left column so one was always in view) and this keeps it in view. */
@media (min-width: 701px) {
  .toc {
    position: sticky;
    top: 0;
  }
}

/* Article pages: the date the home page lists against each one. */
.updated {
  text-align: center;
  font-size: small;
  color: #666;
}

/* Home page: phones get the sections as an accordion instead of the tables. */
.sections {
  display: none;
}

@media (max-width: 700px) {
  /* Home page: hide the section list (keeping the featured articles above it)
     and the tables the accordion stands in for. */
  .toc > center,
  table.section {
    display: none;
  }

  .sections {
    display: block;
    margin: 1em 0 2em;
  }

  .sections details {
    border-bottom: 1px solid #ddd;
  }

  .sections summary {
    display: flex;
    justify-content: space-between;
    padding: 0.8em 0;
    font-weight: bold;
    color: #3333ff;
    cursor: pointer;
    list-style: none;
  }

  .sections summary::-webkit-details-marker {
    display: none;
  }

  .sections summary::after {
    content: "+";
  }

  .sections details[open] summary::after {
    content: "\2212";
  }

  .sections ul {
    margin: 0 0 0.8em;
    padding: 0;
    list-style: none;
  }

  .sections li a {
    display: block;
    padding: 0.5em 0;
    font-weight: bold;
  }

  /* Stack the sidebar | article | margin columns of the page-layout table. */
  body > table,
  body > table > tbody,
  body > table > tbody > tr,
  body > table > tbody > tr > td {
    display: block;
    width: auto !important;
  }

  /* The border stripe would sit under the stacked text. */
  body {
    background-image: none !important;
  }

  /* Fixed widths sized for an 800px screen (the quizzes write a 500px table). */
  img,
  table,
  hr {
    max-width: 100%;
  }

  img {
    height: auto !important;
  }

  /* A table cell grows to fit these rather than letting max-width shrink them. */
  hr {
    width: auto;
  }

  p {
    overflow-wrap: anywhere; /* long URLs in the article text */
  }
}
