/* Version Date: 2022-01-09b */

/*
  Colors:
  #c96 / #cc9966 - light brown
  #633 / #663333 - dark brown
*/

html {
  /* Root font size of 10px to allow easy size calculations */
  font-size: 10px;
  line-height: normal;
  background: black;
}

/* Disable "font boost" feature on the mobile Chrome browser */
html * { max-height: 100000px }

a {
  background-color: transparent;
  color: #633;
  text-decoration: none;
}
.darkbg a, a:hover {
  text-decoration: underline;
  color: #c96;
}
.darkbg {
  color: #c96;
  line-height: 175%;
  margin: 0.5em 0;
}
.darkbg a:hover {
	background-color: #633;
}
.nowrap { white-space: nowrap }

.italic { font-style: italic }

.bigger { font-size: 125%; }

.clear  { clear: both }

body {
  /* body is limited to max width of 1280px and centered. */
  position: relative;
  max-width: 1280px;
  min-height: calc(100vh);
  margin: 0 auto;
  font-size: 1.5rem;
}


/*
 * Navigation Bar (navbar).
 * The navigation bar has two distinct parts: a logo and a menu.
 * A standard height of 5rem (50px) is used for all boxes.
 */

.navbar,
.navbar * {
  color: #c96;
  /* User-select causes chaos when clicking buttons, so disable it */
  user-select: none;
}


/*
 * The Navigation Bar Logo.
 * The logo is an image floated to the left of the page.
 */

.navbar.logo {
  float: left;
  font-size: 5rem;
  margin-right: 0.2em;
}

.navbar.logo * {
  display: inline-block;
  height: 1em;
}


/*
 * The Navigation Bar Menu
 * The menu is made up of several sets of rules gathered into subsections below.
 */

/*
 * Navbar menu basic and generic styling.
 */

.navbar.menu ul {
  /* List of menu items. */
  background-color: black;
  padding: 0;
  margin: 0;
  list-style: none;
  display: none; /* Hide menus by default. They are shown when needed (see later rules). */
}

.navbar.menu li > *:first-child {
  /* Menu item. The first child of the list iten is displayed as the menu item. */
  display: flex;
  align-items: center;
  padding: 0 1em;
  height: 5rem;
}

/* Highlight buttons and menu items as we hover over them */
.navbar.menu .button,
.navbar.menu li > *:first-child {
  /* The highlight includes a border. Allocate space but do not show it. */
  box-sizing: border-box;
  border: 1px solid transparent;
}
.navbar.menu .button:hover,
.navbar.menu li > *:first-child:hover {
  background-color: #633;     /* Highlight the background */
  border-color: currentColor; /* Show the border */
}

/* Icons in menu items are display twice the height of the menu text. */
.navbar.menu li .icon {
  font-size: 2em;
  height: 1em;
}
/* Add a gap to any text that follows the icon. */
.navbar.menu li .icon + * { margin-left: 0.5em }


/*
 * The navbar 'search' menu search contains a magnifying glass icon that's defined here.
 */

.navbar.menu .search.icon {
  /* Define a 1x1em box to contain the icon. The shapes in the icon are drawn
   * with child elements placed relative (anchored) to this box. The 1x1em box
   * simplifies the calculation of size and placement in the children.
   */
  position: relative;
  height: 1em;
  width: 1em;
}
.navbar.menu .search.icon::before {
  /* The glass (a round box) */
  content: "";
  position: absolute;
  box-sizing: border-box;
  border: 0.15em solid;
  border-radius: 50%;
  width: 0.75em;
  height: 0.75em;
  top: 0.05em;
  left: 0.05em;
}
.navbar.menu .search.icon::after {
  /* The handle (a rotated box) */
  content: "";
  position: absolute;
  border-top: 0.15em solid;
  width: 0.35em;
  transform: rotate(45deg);
  top: 0.7em;
  right: 0.05em;
}


/*
 * The navbar menu has two display styles: Horizontal and vertical.
 */

/*
 * Navbar horizontal menu style rules.
 * The horizontal style is used when the page is wide enough and supports hovering.
 * In this case the top-level menu is always shown. Submenus are shown when hovered.
 */

/* The min-width must be paired with the min-width of the vertical rules below. */
@media all and (hover: hover) and (min-width: calc(940px)) {
  /* Display the top-level menu horizontally */
  .navbar.menu > div > ul {
    display: flex;
    flex-flow: row wrap;
  }

  /* Highlight menu items as we hover over them */
  .navbar.menu li:hover {
    position: relative;
    background-color: #633;
  }

  /* Display submenus when we hover over their parent */
  .navbar.menu li:hover > ul {
    display: block;
    position: absolute;
    min-width: 100%;
    white-space: nowrap;
  }

  /* No need to annotate menu icons in horizontal style. */
  .navbar.menu .icon ~ .annotation { display: none }
}


/*
 * Navbar vertical menu style rules.
 * The vertical style is used when the horizontal style cannot be (eg. on a tablet).
 * In this case the top-level menu is shown (opened) only after a menu icon is clicked.
 * This style is more complex than horizontal and requires several sets of rules.
 */

/*
 * Navbar vertical menu icon.
 * The icon can be styled as a hamburger or a cross. The hamburger is used when
 * the menu is closed and is clicked to open it. The cross is used when the menu
 * is open and is clicked to close it. Both icons are styled here.
*/

.navbar.menu .hamburger,
.navbar.menu .close {
  /* Define a 1x1em box to contain the icon. The shapes in the icon are drawn
   * with child elements placed relative (anchored) to this box. The 1x1em box
   * simplifies the calculation of size and placement in the children.
   */
  position: relative;
  width: 1em;
  height: 1em;
  font-size: 5rem;  /* The 1x1em box will be 5x5rem = 50x50px. */
  display: none;    /* Hide the icons by default. They are shown when needed. */
  margin-left: 0.2em;
}

/* Black background so the close icon looks like part of the menu */
.navbar.menu .close {
  background-color: black;
}

.navbar.menu .hamburger div,
.navbar.menu .close div {
  /* Common styling for the bars in the hamburger and close icons */
  position: absolute;
  background-color: currentColor;
  border-style: solid;
  border-width: 0.05em 0;
  border-radius: 0.05em;
  top: calc(50% - 0.05em);  /* Place all bars in the center by default */
}

.navbar.menu .hamburger div {
  /* Hamburger specific bar styling */
  /* Width and horizontal placement. Subsequent rules adjust vertical placement. */
  width: 0.64em;
  left: calc(50% - 0.32em);
}
.navbar.menu .hamburger div:nth-child(2) { top: calc(50% - 0.05em - 0.26em) }
.navbar.menu .hamburger div:nth-child(3) { top: calc(50% - 0.05em + 0.26em) }

.navbar.menu .close div {
  /* Close (cross) specific bar styling */
  /* Width and horizontal placement. The subsequent rule adjusts rotation to form a cross. */
  width: 0.8em;
  left: calc(50% - 0.4em);
  transform: rotate(45deg);
}
.navbar.menu .close div:nth-child(2) { transform: rotate(135deg) }

.navbar.menu .close::before {
 /* When the close icon is displayed, we darken the page around it. We do this by
  * overlaying a semi-transparent box. This box is defined as part of the close
  * icon, so clicking it counts as a click on the close icon.
  */
  content: "";
  position: fixed;
  background-color: rgba(0,0,0,50%);
  left: 0;
  right: 1em;
  top: 0;
  height: 100%;
}

/*
 * Navbar vertical menu style rules.
 */

/* The min-width must be paired with the min-width of the horizontal rules above. */
@media not all and (hover: hover) and (min-width: calc(940px)) {
  /* Float the menu to the right. This embeds the menu icon into the page header. */
  .navbar.menu {
    float: right;
  }

  /* Show the hamburger or close icon depending on whether the menu icon is clicked */
  .navbar.menu > div:not([data-clicked]) .hamburger,
  .navbar.menu > div[data-clicked] .close {
    display: block;
  }

  /* Place the top-level menu in front of the page on the right. */
  .navbar.menu > div > ul {
    position: absolute;
    right: 0;
    top: 5rem;
    width: 13em;
    height: calc(100% - 5rem);
    overflow: hidden;
  }

  /* Show (sub)menu if its parent has been clicked (ie. open the menu). */
  .navbar.menu *[data-clicked] > ul {
    display: block;
  }

  /* Place list items containing submenus in front of the top-level menu.
   * This results in the submenu button being shown above the submenu itself
   * and allows it to be clicked to close the submenu.
   */
  .navbar.menu li[data-clicked] {
    z-index: 1;
    position: absolute;
    top: 0;
    background-color: inherit;
    width: 100%;
    height: 100%;
    white-space: nowrap;
  }

  /* If a submenu is open, invert the color of its submenu button so it
   * appears distinct from the submenu iself.
   */
  .navbar.menu li[data-clicked] > *:first-child:not(:hover) {
    background-color: #c96;
    color: black;
  }

  /*
   * Chevron icons are used to show when a menu item is a button to open a submenu.
   * They also show if the button has been clicked or not (ie, if the submenu is open
   * or not) by pointing left or right respectively.
   */

  .navbar.menu .chevron::before,
  .navbar.menu .chevron::after {
    /* The chevron is made from the corner of the border of a box */
    box-sizing: border-box;
    border-style: solid;
    border-width: 0.2em 0.2em 0 0;
    border-radius: 0 0.05em;
    height: 0.8em;
    width: 0.8em;
  }

  .navbar.menu li[data-clicked] > .chevron::before {
    /* Left pointing chevron before the button text */
    content: "";
    margin-right: 0.5em;
    transform: rotate(225deg);
  }

  .navbar.menu li:not([data-clicked]) > .chevron::after {
    /* Right pointing chevron after the button text */
    content: "";
    margin-left: 0.5em;
    transform: rotate(45deg);
  }
}

/*
 **************** End of navbar rules ****************
 */


/*
 * Header banner
 */

header {
  background-color: #633;
  color: #c96;
  text-align: center;
  text-shadow: 0 0 4px black;
  font-size: calc(2rem + 2.1875vw);
  padding: 0 16px 4px;
  box-shadow:
    inset  0.5em 0.5em 1em   -0.5em rgba(0,0,0,100%),
    inset -0.5em 0.5em 1.5em -0.5em rgba(0,0,0,50%)
    ;
}
@media (min-width: 1280px) {
  /* Prevent header font growing excessively large on wide displays. */
  header { font-size: 4.8rem }
}

header h1 {
  font-weight: normal;
  font-size: 1em;
  margin: 0;
}

header h2 {
  font-weight: normal;
  font-size: 0.5em;
  margin: 0;
}


/*
 * Announcements (eg. date of last site update).
 */

.announce {
  background-color: black;
  color: #c96;
  text-align: center;
  line-height: 175%;
  margin: 0.5em 0;
}


/*
 * Donate to read ahead.
 */

.readahead {
  background-color: black;
  color: #c96;
  text-align: center;
  margin: 0.5em 0;
}

/* Donate button */
.readahead a {
  display: inline-block;
  font-weight: bold;
  color: inherit;
  padding: 0.1em 0.2em;
  border: 2px solid #c96;
  border-radius: 0.5em;
  transition: all 0.2s ease;
  margin: 3px 0;
}
.readahead a:hover {
  background-color: #c96;
  color: black;
}


/*
 * Containers hold a group of one or more panels.
 * A container arranges its panels horizontally (and wraps them if needed).
 * Panels contain most of the page content.
 * A panel arranges its content vertically and can contain a variety of
 * things, including:
 *   - A headers (h3)
 *   - A list (ol+li). Typically a list of story links.
 * Extra container specific styling may be applied.
 */

.container {
  display: flex;
  flex-flow: row wrap;
}

.container > .panel {
  flex: 1 1 250px;
  background-color: white;
  border: solid 1px black;
  margin: 4px;
  box-shadow: 0 0 2px 2px rgba(255, 255, 255, 100%);
  text-align: center;
  display: flex;
  flex-flow: column nowrap;
}

.container > .panel h3 {
  font-weight: bold;
  font-size: 1.5em;
  background-color: #c96;
  color: #633;
  padding: 8px 4px;
  margin: 0 0 4px;
  white-space: nowrap;
}

.container > .panel > ol {
  flex: 1;
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.container > .panel li,
.container > .panel p {
  margin: 8px;
}

/* Nodes with the 'new' class have the "NEW" graphic added after them. */
.container > .panel .new::after {
  content: "NEW";
  font-family: 'Noto Sans', sans-serif;
  background-color: #633;
  color: white;
  font-weight: bold;
  font-size: 0.8em;
  padding: 0 0.3em;
  border-radius: 0.25em;
  margin-left: 1em;
}

/* A strongly emphasized link to a major index page. */
.container > .panel .indexlink {
  display: block;
  background-color: #633;
  color: #c96;
  font-weight: bold;
  padding: 4px 16px;
  border-radius: 2em;
  margin: 10px auto;
  width: calc(100% - 64px);
  max-width: 320px;
}

/* The bottom container panels each link a selected story and image. This requires extra styling. */
.container.bottom > .panel {
  padding: 8px 0;
  justify-content: space-evenly;
  align-items: center;
  overflow: hidden;       /* Crop images that are too wide */
}
.container.bottom > .panel > * { margin: 8px }
.container.bottom img { height: 16em }


/*
 * Copyright etc.
 */

footer {
  background-color: white;
  text-align: center;
  padding: 4px;
  border-top: solid 1px;
}

footer a {
  text-decoration: underline;
}

footer .copyright {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80%;
}

footer .copyright > * {
  padding: 0 0.2em;
}
