/* colours: light by default, dark when the system asks or the toggle says so */

:root {
  --bg: #FBFAF5;
  --fg: #141414;
  --link: #0B3D91;
  --accent: #B3261E;
  --muted: #5A5750;
  --faint: #8A867C;
  --fainter: #A9A59A;
  --rule: #E4E1D6;
  --rule-strong: #C9C5BA;
  --surface: #FFFFFF;
  --blank: #F1EEE3;
  --star-empty: #E6E2D7;
  --shadow: 20 20 20;
  --currently: #3D3B36;
  --field: #FFFFFF;
  --field-line: #8A867C;
  --button: #141414;
  --button-text: #FBFAF5;
  --button-hover: #0B3D91;
  --sun: #D9A21B;
  --moon: #5A5FA8;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161512;
    --fg: #ECE8DD;
    --link: #93B4F2;
    --accent: #F08A7E;
    --muted: #A8A397;
    --faint: #8A857A;
    --fainter: #6C685F;
    --rule: #302E29;
    --rule-strong: #47443D;
    --surface: #1F1E1A;
    --blank: #26241F;
    --star-empty: #3A3832;
    --shadow: 0 0 0;
  --currently: var(--muted);
  --field: #1C1B17;
  --field-line: #4A4740;
  --button: #E4DFD2;
  --button-text: #161512;
  --button-hover: #93B4F2;
  --sun: #F2C14E;
  --moon: #A7ACEB;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #161512;
  --fg: #ECE8DD;
  --link: #93B4F2;
  --accent: #F08A7E;
  --muted: #A8A397;
  --faint: #8A857A;
  --fainter: #6C685F;
  --rule: #302E29;
  --rule-strong: #47443D;
  --surface: #1F1E1A;
  --blank: #26241F;
  --star-empty: #3A3832;
  --shadow: 0 0 0;
  --currently: var(--muted);
  --field: #1C1B17;
  --field-line: #4A4740;
  --button: #E4DFD2;
  --button-text: #161512;
  --button-hover: #93B4F2;
  --sun: #F2C14E;
  --moon: #A7ACEB;
  color-scheme: dark;
}

body {
  margin: 0;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
  color: var(--fg);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 20px;
  line-height: 1.6;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent);
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 64px 20px 72px;
}

@media (min-width: 600px) {
  main {
    padding: 80px 32px 88px;
  }
}

h1 {
  margin: 0 0 20px;
  font-size: 20px;
  font-weight: 700;
}

p {
  margin: 0 0 20px;
}

.intro {
  margin-bottom: 40px;
}

.currently {
  margin: -16px 0 40px;
  font-style: italic;
  color: var(--currently);
}

ul {
  margin: 0 0 56px;
  padding: 0;
  list-style: none;
}

li {
  margin: 0 0 10px;
}

.updated {
  margin: 0;
  font-size: 16px;
  color: var(--muted);
}

.signup {
  margin: 0 0 56px;
}

.signup label {
  display: block;
  margin: 0 0 8px;
}

.signup-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: 360px;
}

.signup input,
.signup button {
  min-height: 44px;
  box-sizing: border-box;
  border-radius: 0;
  font: inherit;
  font-size: 18px;
  -webkit-appearance: none;
  appearance: none;
}

/* fields: one hairline that turns to ink-blue on focus, no browser ring on top */

.signup input,
.controls input {
  border: 1px solid var(--field-line);
  background: var(--field);
  color: var(--fg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.signup input {
  width: 100%;
  padding: 0 12px;
}

.signup input::placeholder,
.controls input::placeholder {
  color: var(--faint);
  opacity: 1;
}

.signup input:focus,
.controls input:focus {
  outline: none;
  border-color: var(--link);
  box-shadow: inset 0 0 0 1px var(--link);
}

.signup button {
  padding: 0 20px;
  border: 0;
  background: var(--button);
  color: var(--button-text);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.signup button:hover {
  background: var(--button-hover);
}

.signup button:focus {
  outline: none;
}

.signup button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.back {
  margin: 0 0 40px;
  font-size: 16px;
}

.issues li {
  margin: 0 0 16px;
}

.issues .teaser {
  display: block;
  font-size: 16px;
  color: var(--muted);
}

h2,
h3 {
  margin: 40px 0 12px;
  font-size: 20px;
  font-weight: 700;
}

h3 {
  margin-top: 28px;
}

.letter ul {
  margin: 0 0 20px;
  padding-left: 1.2em;
  list-style: disc;
}

.letter li {
  margin: 0 0 10px;
}

.signoff {
  margin-top: 40px;
}

.issue-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 56px 0 0;
  font-size: 16px;
}

.controls {
  display: grid;
  gap: 12px;
  margin: 0 0 28px;
  font-size: 16px;
}

.controls input {
  min-width: 0;
  min-height: 44px;
  box-sizing: border-box;
  padding: 0 12px;
  border-radius: 0;
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.filter {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: baseline;
}

.filter[hidden] {
  display: none;
}

.filter-label {
  font-size: 13px;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--faint);
}

/* filters and the layout switch read as a line of words, the chosen one underlined */

.chips,
.views {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 18px;
}

.chips button,
.views button,
.fold-all {
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.chips .label,
.views button,
.fold-all {
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.chips button:hover,
.views button:hover,
.fold-all:hover {
  color: var(--link);
}

.chips button:hover .label,
.views button:hover,
.fold-all:hover {
  text-decoration-color: currentColor;
}

.chips button[aria-pressed="true"] .label,
.views button[aria-pressed="true"] {
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
}

.chips button[aria-pressed="true"],
.views button[aria-pressed="true"] {
  color: var(--fg);
}

.chips .n {
  margin-left: 5px;
  font-size: 13px;
  color: var(--fainter);
}

.chips button[aria-pressed="true"] .n {
  color: var(--faint);
}

.chips button:focus-visible,
.views button:focus-visible,
.fold-all:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

#genres button {
  font-style: italic;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 0 0 8px;
}

.count {
  margin: 0;
  font-size: 16px;
  color: var(--muted);
}

.fold-all {
  margin-left: 14px;
  font-size: 15px;
  text-decoration-color: var(--rule-strong);
}

.fold-all[hidden] {
  display: none;
}

/* years fold away under their heading */

.year > summary {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 0 12px;
  background: var(--bg);
  list-style: none;
  cursor: pointer;
}

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

.year > summary h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  padding: 28px 0 8px;
  border-bottom: 1px solid var(--rule);
}

.year > summary h2::after {
  content: "";
  align-self: center;
  width: 7px;
  height: 7px;
  margin-left: auto;
  margin-right: 4px;
  border-right: 1.5px solid var(--faint);
  border-bottom: 1.5px solid var(--faint);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.2s ease;
}

.year:not([open]) > summary h2::after {
  transform: rotate(-45deg);
}

.year > summary:hover h2,
.year > summary:hover .year-count {
  color: var(--link);
}

.year > summary:hover h2::after {
  border-color: var(--link);
}

.year > summary:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.year > ul {
  margin: 20px 0 32px;
}

.year > .rows {
  margin-top: 0;
}

.year > .rows li:first-child {
  border-top: 0;
}

.year-count {
  font-weight: 400;
  color: var(--muted);
}

.empty {
  color: var(--muted);
}

/* grid: covers stand on a shared baseline, whole cover always visible */

.books {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 36px 24px;
  max-width: 640px;
}

.books li {
  margin: 0;
  min-width: 0;
}

.books .book button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.books .book button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 6px;
}

.frame {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  aspect-ratio: 2 / 3;
  max-width: 160px;
  margin: 0 0 12px;
}

.frame .cover {
  width: auto;
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 1px 2px rgb(var(--shadow) / 0.12), 0 6px 14px rgb(var(--shadow) / 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.frame .cover.blank {
  width: 100%;
  height: 100%;
}

.books .book button:hover .cover,
.books .book button[aria-expanded="true"] .cover {
  transform: translateY(-3px);
  box-shadow: 0 2px 4px rgb(var(--shadow) / 0.14), 0 12px 22px rgb(var(--shadow) / 0.12);
}

.books .book button:hover .title,
.books .book button[aria-expanded="true"] .title {
  color: var(--link);
}

.cover {
  display: block;
  width: 100%;
  height: auto;
  box-sizing: border-box;
}

.cover.blank {
  aspect-ratio: 2 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border: 1px solid var(--rule);
  background: var(--blank);
  font-style: italic;
  font-size: 14px;
  line-height: 1.3;
  text-align: center;
}

.cover.blank span,
.books .title,
.rows .title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
}

.cover.blank span {
  -webkit-line-clamp: 6;
}

.books .title {
  -webkit-line-clamp: 2;
  font-size: 16px;
}

.books .author {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
}

.books .rating {
  display: flex;
  align-items: center;
  margin-top: 5px;
}

/* ratings: five stars filled to the score, halves included; the higher, the brighter */

.stars {
  --s: 14px;
  --star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 13'%3E%3Cpath d='M6 .6l1.6 3.6 3.9.4-2.9 2.6.8 3.9L6 9.1 2.6 11.1l.8-3.9L.5 4.6l3.9-.4z'/%3E%3C/svg%3E");
  display: inline-block;
  flex: none;
  width: calc(var(--s) * 5);
  height: calc(var(--s) * 13 / 14);
  background: linear-gradient(90deg, var(--c, var(--fg)) calc(var(--r) * 20%), var(--star-empty) 0);
  -webkit-mask: var(--star) 0 0 / var(--s) 100% repeat-x;
  mask: var(--star) 0 0 / var(--s) 100% repeat-x;
}

/* sorted by rating, each score heading gets a face */

.year > summary h2 .stars {
  --s: 21px;
  align-self: center;
}

.mood {
  display: inline-block;
  font-size: 20px;
  line-height: 1;
  opacity: 0;
  transform: scale(0);
}

.mood.pop {
  animation: mood-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes mood-pop {
  0% { opacity: 0; transform: scale(0) rotate(-25deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@media (prefers-reduced-motion: reduce) {
  .mood {
    opacity: 1;
    transform: none;
  }

  .mood.pop {
    animation: none;
  }
}

/* list: every note visible */

.rows li {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 18px;
  align-items: start;
  margin: 0;
  padding: 18px 0;
  border-top: 1px solid var(--rule);
}

.rows li:last-child {
  border-bottom: 1px solid var(--rule);
}

.thumb .cover {
  box-shadow: 0 1px 2px rgb(var(--shadow) / 0.12), 0 4px 10px rgb(var(--shadow) / 0.06);
}

.thumb .cover.blank {
  padding: 4px;
  font-size: 10px;
  box-shadow: none;
}

/* wide: stars beside the title; narrow: under the byline, so the title keeps the width */

.row-text {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "head stars"
    "meta meta"
    "note note";
  column-gap: 16px;
  min-width: 0;
}

.row-head {
  grid-area: head;
}



.row-text p {
  margin: 0;
}

.rows .title {
  -webkit-line-clamp: 2;
  min-width: 0;
}

.rows .rating {
  grid-area: stars;
  display: flex;
  margin-top: 10px;
}

.row-meta {
  grid-area: meta;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 15px;
  color: var(--muted);
}

.rows .clipped .row-head,
.rows .clipped .row-meta {
  cursor: pointer;
}

.rows .clipped .title:hover {
  color: var(--link);
}

.rows .clipped .title:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.rows .full .title {
  display: block;
  overflow: visible;
}

.rows .full .row-meta {
  white-space: normal;
}

.row-text .row-note {
  grid-area: note;
  margin-top: 8px;
  font-size: 16px;
  line-height: 1.55;
}

/* notes panel: opens under the row of the tapped book */

.books .detail {
  grid-column: 1 / -1;
  display: grid;
  grid-template-rows: 0fr;
  margin-top: -32px;
  opacity: 0;
  transition: grid-template-rows 0.32s ease, margin-top 0.32s ease, opacity 0.24s ease;
}

.books .detail.open {
  grid-template-rows: 1fr;
  margin-top: -14px;
  opacity: 1;
}

.detail-inner {
  min-height: 0;
  overflow: hidden;
  padding: 0 1px;
}

.detail-card {
  position: relative;
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 24px;
  align-items: start;
  margin: 8px 0 2px;
  padding: 24px;
  border: 1px solid var(--rule);
  background: var(--surface);
  box-shadow: 0 10px 28px rgb(var(--shadow) / 0.06);
  transform: translateY(-6px);
  transition: transform 0.32s ease;
}

.detail.open .detail-card {
  transform: none;
}

.detail-card::before {
  content: "";
  position: absolute;
  top: -7px;
  left: calc(var(--caret, 50%) - 6px);
  width: 12px;
  height: 12px;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
  background: var(--surface);
  transform: rotate(45deg);
  transition: left 0.25s ease;
}

.detail-text {
  min-width: 0;
}

.detail-text p {
  margin: 0;
}

.detail-title {
  margin-right: 32px;
  font-size: 22px;
  line-height: 1.3;
  text-wrap: balance;
}

.detail-author {
  margin-top: 4px;
  font-size: 16px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 0;
  margin-top: 6px;
  font-size: 15px;
  color: var(--muted);
}

.detail-meta > span + span::before {
  content: "\00b7";
  margin: 0 8px;
}

.detail-text .score {
  display: flex;
  margin-top: 8px;
}

.detail-text .detail-note {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 18px;
  line-height: 1.6;
}

.detail-card .close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.detail-card .close:hover {
  color: var(--accent);
}

.detail-card .close:focus-visible {
  outline: 2px solid var(--link);
}

@media (max-width: 480px) {
  .row-text {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "head"
      "meta"
      "stars"
      "note";
  }

  .rows .rating {
    margin-top: 7px;
  }

  .row-text .row-note {
    margin-top: 10px;
  }

  .detail-meta {
    flex-direction: column;
    gap: 0;
    line-height: 1.45;
  }

  .detail-meta > span + span::before {
    content: none;
  }

  .detail-card {
    grid-template-columns: 84px 1fr;
    gap: 16px;
    padding: 20px 16px;
  }

  .detail-title {
    font-size: 19px;
  }

  .detail-note {
    font-size: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .books .detail,
  .detail-card,
  .detail-card::before,
  .books .book .cover,
  .year > summary h2::after {
    transition: none;
  }
}

/* sun/moon switch, top right of every page */

.theme-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--moon);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.4s ease;
}

.theme-toggle.is-dark {
  color: var(--sun);
}

.theme-toggle:focus {
  outline: none;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 22px;
  height: 22px;
  transition: transform 0.3s ease;
}

.theme-toggle:hover svg {
  transform: rotate(-15deg) scale(1.1);
}

.theme-toggle.is-dark:hover svg {
  transform: rotate(45deg) scale(1.1);
}

.theme-toggle svg.turn {
  animation: turn-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes turn-in {
  0% { opacity: 0; transform: rotate(-120deg) scale(0.4); }
  100% { opacity: 1; transform: none; }
}

/* switching themes eases every colour across instead of snapping */

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.45s;
  animation-timing-function: ease;
}

.theme-fade,
.theme-fade *,
.theme-fade *::before,
.theme-fade *::after {
  transition: color 0.4s ease, background-color 0.4s ease, border-color 0.4s ease,
    text-decoration-color 0.4s ease, box-shadow 0.4s ease, fill 0.4s ease, stroke 0.4s ease !important;
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle svg,
  .theme-toggle svg.turn {
    animation: none;
    transition: none;
  }
}
