:root {
  --border-radius: 20px;

  --max-width: 42rem;
  --padding:   1em;

  --tint-color: rgb(var(--r), var(--g), var(--b));
}

body {
  margin:  0;
  padding: 0;

  min-height:     100vh;
  display:        flex;
  flex-direction: column;

  font: 12pt monospace;
  line-height: 1.55em;

  /* Background from https://www.toptal.com/designers/subtlepatterns/light-paper-fibers/ */
  background: url('/static/lightpaperfibers.jpg');
}

main {
  flex: 1;
  padding-top:    var(--padding);
  padding-bottom: var(--padding);
}

#header_text, main, footer > * {
  max-width: var(--max-width);
  margin:    0 auto;

  padding-top:    calc(var(--padding) + env(safe-area-inset-top));
  padding-right:  calc(var(--padding) + env(safe-area-inset-right));
  padding-bottom: calc(var(--padding) + env(safe-area-inset-bottom));
  padding-left:   calc(var(--padding) + env(safe-area-inset-left));
}

h1 {
  line-height: 1.25em;
}

h1 .book-title, h1 .book-series {
  font-style: italic;
}

.review a {
  color: rgb(var(--r), var(--g), var(--b));
}

.book_cover img {
  float: right;
  max-width:  180px;
  max-height: 240px;
  margin-top: 10px;
  margin-left: 20px;
  margin-bottom: 20px;
  box-shadow: 0px 5px 5px rgba(var(--r), var(--g), var(--b), 0.25);
}

@media screen and (max-width: 500px) {
  .book_cover img {
    max-width: 90px;
  }
}

a {
  color: black;
}

a:hover {
  text-decoration: underline;
  text-decoration-thickness: 4px;
  text-decoration-skip-ink: none;
}

td, th {
  line-height: 1.4em;
  vertical-align: top;
  padding-top:    3px;
  padding-bottom: 3px;
}

td {
  font-weight: bold;
}

th {
  padding-right: 10px;
  text-align: left;
  font-weight: normal;
  min-width: 6.5em; /* wide enough for "date read" */
}

footer {
  border-top: 0.25px solid #bfbfbf;
  color: #999;
  font-size: 0.75em;
  margin-top: 2em;
  padding: 1em;
  padding-bottom: 2em;
}

footer a {
  color: gray;
}

footer span.heart {
  color: var(--tint-color);
}

blockquote {
  border-left: 3px solid var(--tint-color);
  margin-left: 0;
  padding-left: 1em;
  font-style: italic;
}

/*
 * Styles for the "review preview" component.
 *
 * This component is used on the homepage and list of reviews as a preview
 * of each review, showing the title of the book, some basic metadata,
 * and my star rating.
 *
 * All the review previews are `li` child elements of a `ul.review_previews`.
 *
 * Each instance of this component has four variables:
 *
 *     --r, --g, --b, which represent the r/g/b components of
 *          the tint color.
 *     --ar, which is the aspect ratio of the image
 *
 */
ul.review_previews {
  list-style-type: none;
  margin:  0;
  padding: 0;
}

ul.review_previews > li {
  --border-color: rgb(var(--r), var(--g), var(--b));

  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: 1em;

  --bg-boost-amount:     0.92;
  --bg-boost-multiplier: 0.08;

  background: rgb(
    calc(var(--bg-boost-amount) * 255 + var(--bg-boost-multiplier) * var(--r)),
    calc(var(--bg-boost-amount) * 255 + var(--bg-boost-multiplier) * var(--g)),
    calc(var(--bg-boost-amount) * 255 + var(--bg-boost-multiplier) * var(--b))
  );
}

ul.review_previews > li:hover {
  --bg-boost-amount:     0.74;
  --bg-boost-multiplier: 0.26;
}

ul.review_previews > li a,
.read_at_another_time {
  grid-template-columns: 135px auto;
  display: grid;
  grid-gap: 8px;
  height: 100%;
  width:  100%;
  color: black;
  text-decoration: none;
  align-items: center;
  min-height: 157px;
}

ul.review_previews > li img {
  max-width: 110px;
  max-height: 130px;
  vertical-align: middle;
  border: 0.1px solid var(--border-color);
}

ul.review_previews > li[data-rv-s="5"] {
  border-width: 3px;
  margin-left:  -1px;
  margin-right: -1px;
  box-shadow: 0px 0px 5px rgba(var(--r), var(--g), var(--r), 0.3);

  --bg-boost-amount:     0.8;
  --bg-boost-multiplier: 0.3;
}

ul.review_previews > li[data-rv-s="5"]:hover {
  --bg-boost-amount:     0.58;
  --bg-boost-multiplier: 0.42;
}

ul.review_previews > li .title + p {
  font-size: smaller;
}

/* bk_t = book thumbnail */
.bk_t {
  margin: auto;
  aspect-ratio: var(--ar);
  background: rgb(var(--r), var(--g), var(--b));
}

/* ar = aspect ratio,
 * ar_p = portrait, ar_s = square, ar_l = landscape */
.bk_t.ar_p {               height: 130px; }
.bk_t.ar_s { width: 110px; height: 110px; }
.bk_t.ar_l { width: 110px;                }

.bk_t img {
  margin: auto;
  max-width:  110px;
  max-height: 130px;
  aspect-ratio: var(--ar);
}

/* bk_m = book metadata */
.bk_m {
  grid-row: 1/1;
  grid-column: 2/2;
  display: inline-block;
  margin-top:    auto;
  margin-bottom: auto;
  border-collapse: collapse;
  line-height: 1.25em;
  padding-right: 10px;
  padding-top:    10px;
  padding-bottom: 10px;
}

.bk_m p.title {
  font-style: italic;
  font-size: 1.15em;
  margin-bottom: 0.5em;
  line-height: 1.3em;
}

.bk_m .did_not_finish {
  font-weight: normal;
}

.bk_m p {
  margin: 0;
}

hr {
  height: 50px;
  width:  50px;
  border: 0;

  background-image: url("/static/book.svg");
  background-size:   contain;
  background-repeat: repeat-x;
}

/* sr = star rating */
.sr {
  font-size: 100%;
  letter-spacing: 4px;
  display: block;
}

/* bk_s = book series */
.book-series, .bk_s {
  color: #999;
  font-weight: normal;
}

@media screen and (min-width: 500px) {
  /* For books with long attribution info, e.g. "Your Computer is on Fire" */
  main > .bk_m {
    max-width: calc(100% - 210px);
  }
}

@media screen and (max-width: 500px) {
  ul.review_previews > li a {
    grid-template-columns: auto;
    grid-row-gap: 0.75em;
  }

  ul.review_previews > li img {
    max-width:  100%;
    max-height: 100%;
  }

  .bk_t {
    margin-top: 15px;
    margin-bottom: 10px;
    grid-column: 1/1;
    grid-row: 1/2;
  }

  .bk_t.ar_p {
    height: 150px;
  }

  .bk_t.ar_s {
    width:  150px;
    height: 150px;
  }

  .bk_m {
    grid-column: 1/1;
    grid-row: 2/2;
    padding: 15px;
    padding-top: 0;
    max-width: 100%;
  }

  .thumbnail_helper {
    display: none;
  }

  .book_cover {
    text-align: center;
  }

  .book_cover img {
    float: none;
    max-width:  120px;
    max-height: 240px;
    margin-top: 10px;
    margin-left:  auto;
    margin-right: auto;
    margin-bottom: 0;
    box-shadow: 0px 5px 5px rgba(0,0,0,0.25);
  }
}

/************************************************/
/* Styles for the filter bar and filter pickers */
/************************************************/

/* Filters require JavaScript, so they're hidden by default and made visible
 * by JavaScript on initial page load.
 * cf. corresponding JS in window.onload in list_reviews.html */
#filterBar, #filtersApplied, #noResults {
  display: none;
}

#filtersApplied .appliedFilter {
  margin-right: 1em;
  white-space: nowrap;
}

#filtersApplied .appliedFilterValue {
  font-weight: bold;
}

#filtersApplied .removeFilter {
  color: #d01c11;
  text-decoration: none;
}

#filtersApplied .removeFilter:hover {
  background: none;
}

#filterBar button {
  background: white;
  border: 1px solid black;
  font: 12pt monospace;
  cursor: pointer;
  border-radius: 20px;
  padding: 3px 10px;
  color: black;  /* iOS renders these as blue */
}

ul#author_filters, ul#star_rating_filters {
  padding: 0;
  padding-right: 10px;
  margin: 0;
  list-style: none;
}

.tippy-box, .tippy-content {
  border-radius: 10px;
  max-width: 100%;
}

.tippy-arrow {
  color: white;

    /* The arrow is rendered separately to the rest of the box; this makes
     * it appear over the box shadow which greys out the rest of the page */
  z-index: 1000;
}

.tippy-content {
  background: white;
  color: black;

  line-height: 1.75em;

  padding: 20px 22px;
  max-height: 450px;
  overflow: scroll;

  /* This renders a perma-shadow that greys out the rest of the page. */
  box-shadow: 0px 5px 10000px 10000px rgba(0, 0, 0, 0.5);
}

#jumpTo a[disabled] {
  color: #999;
  text-decoration: none;
  cursor: default;
}

#jumpTo a[disabled]:hover {
  background: none;
}

#roundups {
  list-style-type: none;
  margin:  0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-gap: 20px;
}

#roundups div.roundup_item {
  aspect-ratio: 2 / 1;
  position: relative;
  font-size: 3em;
}

#roundups div.roundup_item img {
  border: 2px solid black;
  border-radius: var(--border-radius);
  width: 100%;
  filter: brightness(30%);
  aspect-ratio: 2 / 1;
}

#roundups div.roundup_item:hover img {
  filter: brightness(20%);
}

#roundups div.roundup_item p {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  margin: 0;
}

/* This is for the header shown at the top of every page.
 *
 * See the `header.html` component.
 */
header {
  color: white;
  font-size: 13pt;
  line-height: 1.5em;
  margin-bottom: 2.2em;
}

header #fallback_background, header #shelf_background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}

header #fallback_background {
  background: #666666;
  height: 30px;
  z-index: 1;
}

header #shelf_background {
  background: var(--shelf-background);
  background-size: auto 100%;
  height: 46px;
  z-index: 2;
}

header #header_text {
  padding-top: calc(4px + env(safe-area-inset-top));
  padding-bottom: 3px;
}

header a {
  text-decoration: none;
  color: white;
}

header img {
  height: 30px;
  margin-bottom: -8px;
  margin-top:    -2px;
}

header h1 {
  margin-top: 0;
  margin-bottom: 0;
  display: inline;
  font-size: 1em;
}

/* This is for the full book metadata shown on individual review pages.
 *
 * See the `full_book_metadata.html` component.
 */
.full_book_metadata {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-column-gap: 1em;
  grid-row-gap: 3px;
}

.full_book_metadata dt::after {
  content: ":";
}

.full_book_metadata dd {
  margin: 0;
  font-weight: bold;
}

.full_book_metadata .did_not_finish {
  font-weight: normal;
}

/* This is for the "Skip to main content" link at the top of the page
 *
 * See https://accessibility.oit.ncsu.edu/it-accessibility-at-nc-state/developers/accessibility-handbook/mouse-and-keyboard-events/skip-to-main-content/ */
a.skip-main {
  position: absolute;
  left:     -999px;
  top:      auto;

  width:  1px;
  height: 1px;

  overflow: hidden;

  z-index: -999;
}
