/* ---------- Colours and basics ---------- */

/* Every colour on the site comes from these tokens.
   Night mode is the default; day mode (cream and brown, like paper and
   leather books) is set by the little script at the top of every page,
   which puts data-theme="light" or "dark" on <html> (saved choice, or
   the device setting). The sun/moon button in the header switches. */
:root {
  color-scheme: dark;
  --bg: #14181c;
  --surface: #1f262d;
  --text: #e6e9ec;
  --muted: #9aa5b1;
  --accent: #40bcf4;
  --ok: #00c030;
  --error: #ff6b6b;
  --border: #39424c;          /* lines around boxes, empty stars */
  --on-button: #ffffff;       /* text on green buttons */
  --on-danger: #1a0000;       /* text on red buttons */
  --avatar-bg: #6b7682;       /* circle behind a missing picture */
  --want: #e2b23a;            /* "want to read" outline */
  --shadow: rgba(0, 0, 0, 0.4);
  --shimmer: rgba(255, 255, 255, 0.06);
  --skeleton: #1f262d;        /* loading boxes */
  --radius: 8px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4ecd8;
  --surface: #fbf6e9;
  --text: #3b2a1f;
  --muted: #74604d;
  --accent: #8b5a2b;
  --ok: #2e7d32;
  --error: #b3261e;
  --border: #d9c9a8;
  --on-button: #ffffff;
  --on-danger: #ffffff;
  --avatar-bg: #a58d72;
  --want: #b7791f;
  --shadow: rgba(59, 42, 31, 0.18);
  --shimmer: rgba(255, 255, 255, 0.55);
  --skeleton: #e9dcc0;
}

* {
  box-sizing: border-box;
}

/* Anything marked "hidden" in the HTML stays hidden, even if another rule
   below gives it display: flex. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

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

/* ---------- Header ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.logo img {
  display: block;
  border-radius: 6px;
}

/* Right-hand side of the header: log in links, or your picture + name */
.site-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto; /* stays on the right, even when the header wraps */
}

/* ---------- Header buttons (when logged in) ---------- */

.nav-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.nav-button:hover {
  border-color: var(--muted);
  color: var(--accent);
}

.nav-button svg {
  flex-shrink: 0;
}

/* Profile button: just your picture and name, no border */
.nav-profile {
  padding: 2px 6px 2px 2px;
  border-color: transparent;
  min-width: 0;
}

.nav-username {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Log out is the quietest button */
.nav-log-out {
  border-color: transparent;
  color: var(--muted);
}

/* ---------- Page content ---------- */

.page {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 16px;
}

.page-narrow {
  max-width: 420px;
}

.page-medium {
  max-width: 600px;
}

/* Settings page: one card per setting, with space between */
.settings {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings .form {
  margin-bottom: 0;
}

/* The delete account card: a red edge so it stands apart */
.card-danger {
  border: 1px solid var(--error);
}


.card .form input[type="email"],
.card .form input[type="password"] {
  background: var(--bg);
}

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

.lead {
  color: var(--muted);
  font-size: 1.1rem;
}

/* ---------- Status messages ---------- */

.status {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border-left: 4px solid var(--muted);
}

.status-ok {
  border-left-color: var(--ok);
}

.status-error {
  border-left-color: var(--error);
}

.status-waiting {
  border-left-color: var(--muted);
  color: var(--muted);
}

.status[hidden] {
  display: none;
}

/* ---------- Buttons ---------- */

.button {
  display: inline-block;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  background: var(--ok);
  color: var(--on-button);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  filter: brightness(1.1);
}

.button:disabled {
  opacity: 0.6;
  cursor: default;
}

.button-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--muted);
}

/* Red button for things that delete (delete account, remove review) */
.button-danger {
  background: var(--error);
  color: var(--on-danger);
}

/* Full-width button (used for "Continue with Google") */
.button-wide {
  width: 100%;
}

/* A button that looks like a link (used for "Log out") */
.link-button {
  border: none;
  background: none;
  padding: 0;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.link-button:hover {
  color: var(--text);
}

/* "Resend the email" under the login / sign up message */
.resend-button {
  margin-top: 12px;
}

/* ---------- Forms ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 24px;
}

.form label {
  font-weight: 600;
  margin-top: 8px;
}

.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form input[type="search"],
.form input[type="date"],
.form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.form textarea {
  resize: vertical;
}

.form .button {
  align-self: flex-start;
  margin-top: 12px;
}

.hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.hint-error {
  color: var(--error);
}

.divider {
  text-align: center;
  color: var(--muted);
}

/* ---------- Avatars (round profile pictures) ---------- */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Default avatar: grey circle with the first letter of the username */
.avatar-default {
  background: var(--avatar-bg);
  color: var(--on-button);
  font-weight: 700;
}

.avatar-tiny {
  width: 22px;
  height: 22px;
  font-size: 0.7rem;
}

.avatar-small {
  width: 32px;
  height: 32px;
  font-size: 0.9rem;
}

.avatar-large {
  width: 128px;
  height: 128px;
  font-size: 3.5rem;
}

/* On your own profile the picture is the upload button.
   A small round plus badge is always visible in the corner, and a dark
   "Change" layer covers the picture when you point at it or tab to it. */
.avatar-editable {
  position: relative;
  display: flex;
  border-radius: 50%;
  cursor: pointer;
}

.avatar-editable::before {
  content: "+";
  position: absolute;
  right: 2px;
  bottom: 2px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  font-size: 1.4rem;
  line-height: 1;
}

.avatar-editable::after {
  content: "Change";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.15s;
}

.avatar-editable:hover::after,
.avatar-editable:focus-visible::after {
  opacity: 1;
}

/* ---------- Profile page ---------- */

.profile-top {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 32px;
}

.profile-username {
  margin: 0 0 8px;
  overflow-wrap: anywhere; /* long usernames break instead of overflowing */
}

.profile-top > div {
  min-width: 0;
}

.profile-bio {
  margin: 0;
  white-space: pre-wrap; /* keep the line breaks people type in their bio */
}

.card {
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
}

.card h2 {
  margin-top: 0;
}

.card .form input[type="text"],
.card .form textarea {
  background: var(--bg);
}

.empty-state {
  text-align: center;
  padding-top: 40px;
  padding-bottom: 40px;
}


.profile-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 12px 0;
  color: var(--muted);
}

/* ---------- Header search box ---------- */

.header-search {
  flex: 1;
  min-width: 120px;
  max-width: 320px;
}

.header-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

/* ---------- Search page ---------- */

.search-form {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.search-form .button {
  margin-top: 0;
  align-self: auto;
}

.people-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.person {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.book-result {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--surface);
  color: var(--text);
  text-decoration: none;
}

.book-result:hover .book-result-title {
  color: var(--accent);
}

.book-result p {
  margin: 0;
}

.book-result-title {
  font-weight: 600;
}

/* ---------- Book covers ---------- */

.cover {
  display: block;
  flex-shrink: 0;
  border-radius: 4px;
  background: var(--surface);
  object-fit: cover;
  box-shadow: 0 2px 8px var(--shadow);
}

/* No cover: a box with the title written on it */
.cover-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

.cover-small {
  width: 60px;
  height: 90px;
}

.cover-large {
  width: 200px;
  height: 300px;
  font-size: 1rem;
}

/* ---------- Book page ---------- */

.book-top {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  margin-bottom: 32px;
}

.book-info {
  flex: 1;
  min-width: 0;
}

.book-title {
  margin: 0 0 4px;
}

.book-title + .lead {
  margin-top: 0;
}

.book-description {
  white-space: pre-wrap;
}

.stars-average {
  color: var(--ok);
  font-weight: 600;
}

/* ---------- Star rating picker ---------- */

.star-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.star-input {
  position: relative;
  display: inline-block;
  font-size: 2rem;
  line-height: 1;
  color: var(--border); /* grey stars */
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

/* The green stars, cut off at the chosen rating by their width */
.star-input-full {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  overflow: hidden;
  color: var(--ok);
}

.star-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.form-buttons {
  display: flex;
  align-items: center;
  gap: 20px;
}

.form-buttons .button {
  margin-top: 12px;
}

.form-buttons .link-button {
  margin-top: 12px;
  color: var(--error);
}

/* ---------- Log cards (feed, book page, profile) ---------- */

.log-list {
  display: flex;
  flex-direction: column;
}

.log-card {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--surface);
}

.log-body {
  flex: 1;
  min-width: 0;
}

.log-body p {
  margin: 0 0 4px;
}

.log-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.log-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.log-title {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.log-user:hover,
.log-title:hover {
  color: var(--accent);
}

.log-meta {
  display: flex;
  gap: 12px;
  font-size: 0.9rem;
}

.stars {
  color: var(--ok);
  letter-spacing: 1px;
}

.log-review {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* ---------- Home page ---------- */

.welcome {
  margin-bottom: 40px;
}

.welcome-login {
  margin-left: 12px;
}

/* ---------- Narrow screens: icons only in the header ---------- */

@media (max-width: 1000px) {
  /* Just your picture, the gear and the log out icon */
  .nav-username,
  .nav-label {
    display: none;
  }

  .nav-button {
    padding: 6px;
  }

  .nav-profile {
    padding: 2px;
  }
}

/* ---------- Phones ---------- */

@media (max-width: 600px) {
  .site-header {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
  }

  /* Row 1: logo and your account. Row 2: search box, Genres and Popular. */
  .header-search {
    order: 3;
    flex: 1 1 120px;
    min-width: 0;
    max-width: none;
  }

  .header-link {
    order: 4;
  }

  .profile-top,
  .book-top {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .profile-stats {
    justify-content: center;
  }

  .profile-username {
    font-size: 1.6rem;
  }

  .site-nav {
    gap: 8px;
  }

  .book-info {
    text-align: left;
  }
}

/* ---------- Shelves (Want to read / Currently reading) ---------- */

.shelf-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.shelf-button {
  padding: 8px 14px;
  font-size: 0.9rem;
}

/* The shelf the book is on */
.shelf-button.shelf-active {
  background: var(--ok);
  border-color: var(--ok);
  color: var(--on-button);
}

/* A row of covers that wraps onto more lines */
.cover-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}

.cover-link {
  display: block;
  border-radius: 4px;
  text-decoration: none;
  transition: transform 0.15s;
}

.cover-link:hover,
.cover-link:focus-visible {
  transform: translateY(-3px);
}

.cover-medium {
  width: 90px;
  height: 135px;
}

@media (prefers-reduced-motion: reduce) {
  .cover-link {
    transition: none;
  }
}

/* ---------- Text pages (About, Privacy, Terms) ---------- */

.prose {
  max-width: 680px;
}

.prose h2 {
  margin-top: 32px;
}

.prose li {
  margin-bottom: 6px;
}

/* ---------- Footer ---------- */

/* Keeps the footer at the bottom of short pages */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body > main {
  flex: 1;
  width: 100%;
}

.site-footer {
  padding: 24px 16px;
  border-top: 1px solid var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text);
  text-decoration: underline;
}

.footer-note {
  margin: 12px 0 0;
  font-size: 0.8rem;
}

.footer-note a {
  color: var(--muted);
}

/* ---------- Report buttons ---------- */

.log-actions {
  display: flex;
  gap: 16px;
  margin: 4px 0 0;
  font-size: 0.85rem;
}

.report-button:disabled {
  cursor: default;
  opacity: 0.7;
}

/* ---------- Admin page ---------- */

.report-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.report-card p {
  margin: 0 0 8px;
}

.report-reason {
  font-weight: 600;
}

.report-target {
  padding: 12px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  background: var(--bg);
}

.report-person {
  display: flex;
  align-items: center;
  gap: 8px;
}

.report-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Load more ---------- */

.load-more {
  align-self: center;
  margin: 20px auto 0;
}

/* ---------- Problems and the 404 page ---------- */

.page-problem {
  margin-bottom: 24px;
}

.not-found-search {
  max-width: 460px;
  margin: 24px auto;
}

/* ---------- Welcome page ---------- */

.welcome-steps {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.welcome-steps .card .form {
  margin-bottom: 0;
}

.suggested-people {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.suggested-person {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.suggested-person-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.suggested-person-name span {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
}

.welcome-done {
  margin-top: 28px;
  text-align: center;
}

/* ---------- Genres ---------- */

.header-link {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.header-link:hover {
  color: var(--accent);
}

/* Small genre tags on a book page */
.genre-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.genre-tag {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.genre-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Browse page: a grid of genre cards */
.genre-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.genre-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 72px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.genre-card:hover {
  outline: 2px solid var(--accent);
}

.genre-card-name {
  font-weight: 700;
}

.genre-card-count {
  color: var(--muted);
  font-size: 0.85rem;
}

.breadcrumb {
  margin: 0;
  font-size: 0.9rem;
}

.center {
  text-align: center;
}

/* Book tiles: cover with title and author underneath */
/* A message inside a tile grid (like "nothing here yet") spans the whole row */
.tile-grid > p {
  grid-column: 1 / -1;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 20px 14px;
  margin-bottom: 12px;
}

.book-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.book-tile .cover {
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  margin-bottom: 6px;
}

.book-tile:hover .book-tile-title {
  color: var(--accent);
}

.book-tile-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  /* At most two lines, then "..." */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-tile-author,
.book-tile-note {
  color: var(--muted);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-tile-note {
  color: var(--ok);
}

@media (max-width: 600px) {
  .tile-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Taste questionnaire (welcome page) ---------- */

.welcome-step h2 {
  margin-top: 8px;
}

.genre-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 24px;
}

/* A genre you can switch on and off */
.genre-choice {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.genre-choice:hover {
  border-color: var(--accent);
}

.genre-choice[aria-pressed="true"] {
  border-color: var(--ok);
  background: var(--ok);
  color: var(--on-button);
  font-weight: 600;
}

.step-buttons {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 8px;
}

/* Book covers you can tap */
.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 16px 12px;
  margin: 16px 0 24px;
}

.pick-grid > p {
  grid-column: 1 / -1;
}

.pick-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.pick-tile .cover {
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  outline: 3px solid transparent;
  outline-offset: 2px;
}

.pick-tile[data-pick="read"] .cover { outline-color: var(--accent); }
.pick-tile[data-pick="loved"] .cover { outline-color: var(--ok); }
.pick-tile[data-pick="want"] .cover { outline-color: var(--want); }

/* "Read" / "Loved" / "Want to read" label on a picked cover */
.pick-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.8);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

.pick-tile[data-pick="loved"] .pick-badge::before { content: "\2665  "; color: var(--ok); }

@media (max-width: 600px) {
  .pick-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- For you (home page) ---------- */

.for-you {
  margin-bottom: 32px;
}

/* One row of book tiles you can scroll sideways */
.tile-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 112px;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
}

.tile-row .book-tile {
  scroll-snap-align: start;
}

.book-tile-reason {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.3;
}

/* Covers that are links never get an underline (books with no picture
   show their title on the cover) */
.log-cover,
.book-tile {
  text-decoration: none;
}

/* A little space between a hint line and the books under it */
.hint + .tile-row,
.hint + .tile-grid {
  margin-top: 12px;
}

/* ---------- Home page rows ---------- */

.home-rows {
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin-bottom: 36px;
}

.row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.row-title {
  margin: 0;
  font-size: 1.25rem;
  min-width: 0;
}

.row-title a {
  color: var(--text);
  text-decoration: none;
}

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

.row-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.see-all {
  margin-right: 4px;
  font-size: 0.9rem;
  white-space: nowrap;
}

/* Left/right arrows: only on computers with a mouse. Phones scroll
   the row with a finger. */
.row-arrow {
  display: none;
  width: 30px;
  height: 30px;
  border: 1px solid var(--muted);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.row-arrow:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@media (hover: hover) and (pointer: fine) {
  .row-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* Grey book shapes while a row loads */
/* ---------- Loading placeholders (grey shimmer boxes) ---------- */

.skeleton,
.tile-placeholder {
  display: block;
  border-radius: 4px;
  background-color: var(--skeleton);
  background-image: linear-gradient(90deg, transparent 0, var(--shimmer) 50%, transparent 100%);
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  from { background-position: 150% 0; }
  to { background-position: -50% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .tile-placeholder {
    animation: none;
  }
}

.tile-placeholder {
  height: 168px;
}

.sk-lines {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.sk-line {
  height: 12px;
  width: 100%;
}

.sk-short {
  width: 45%;
}

.sk-title {
  height: 28px;
  width: 60%;
}

.sk-cover {
  width: 60px;
  height: 90px;
  flex-shrink: 0;
}

.sk-avatar {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sk-book {
  width: 200px;
  height: 300px;
  flex-shrink: 0;
}

.sk-tile {
  aspect-ratio: 2 / 3;
}

.skeleton-group {
  display: flex;
  flex-direction: column;
}

.skeleton-log {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--surface);
}

.skeleton-top {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 32px;
}

.skeleton-profile {
  align-items: center;
}

/* Tile grids: the boxes take the grid's columns */
.skeleton-tiles {
  display: contents;
}

@media (max-width: 600px) {
  .skeleton-top {
    flex-direction: column;
    align-items: center;
  }

  .skeleton-top .sk-lines {
    width: 100%;
  }

  .sk-book {
    width: 160px;
    height: 240px;
  }
}

/* Scrollbar under a row: thin and quiet */
.tile-row {
  scrollbar-width: thin;
  scrollbar-color: var(--surface) transparent;
}

/* Genre buttons on the home page */
.genre-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.genre-pill {
  padding: 7px 14px;
  border: 1px solid var(--surface);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
}

.genre-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.home-nudge {
  margin: 0;
}

/* An empty spot that triggers the extra genre rows; takes no space */
.home-more {
  height: 1px;
  margin-top: -28px;
}

.row-fits .row-arrow {
  display: none;
}

/* On phones the genre buttons are one line you scroll sideways */
@media (max-width: 600px) {
  .genre-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
  }

  .genre-pill {
    flex-shrink: 0;
  }
}

/* ---------- Install app (footer) ---------- */

.footer-install {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Live search suggestions (js/search-suggest.js) ---------- */

.suggest-box {
  position: absolute; /* placed under the search bar by the script */
  z-index: 50;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px var(--shadow);
}

.suggest-heading {
  margin: 8px 10px 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.suggest-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px; /* easy to tap on phones */
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}

.suggest-option:hover,
.suggest-option[aria-selected="true"] {
  background: var(--bg);
}

.suggest-option[aria-selected="true"] {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.suggest-cover {
  flex-shrink: 0;
  width: 28px;
  height: 42px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg);
}

.suggest-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.suggest-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.suggest-main,
.suggest-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggest-detail {
  color: var(--muted);
  font-size: 0.85rem;
}

.suggest-message {
  margin: 0;
  padding: 12px 10px;
  color: var(--muted);
}

.suggest-see-all {
  justify-content: center;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Author page ---------- */

.author-bio {
  margin: 0;
  white-space: pre-line; /* keep paragraph breaks */
}

/* First 4 lines only, until "Read more" is pressed */
.author-bio.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.read-more {
  margin-top: 6px;
  color: var(--accent);
  font-weight: 600;
}

.person-detail {
  font-size: 0.85rem;
}

/* ---------- Day / night switch (header) ---------- */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: none;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--muted);
}

/* Night: show the sun (switch to day). Day: show the moon. */
.theme-toggle .icon-moon,
:root[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

/* Very small phones (iPhone SE and smaller): tighter header so the logo,
   day/night switch and your buttons stay on one row. */
@media (max-width: 400px) {
  .site-header {
    gap: 8px;
    padding: 12px;
  }

  .logo {
    gap: 6px;
    font-size: 1.15rem;
  }

  .logo img {
    width: 24px;
    height: 24px;
  }

  .theme-toggle {
    width: 30px;
    height: 30px;
  }

  .site-nav {
    gap: 6px;
  }

  .nav-button {
    padding: 4px;
  }

  .site-nav .button {
    padding: 6px 12px;
  }
}

/* ---------- Pop-up boxes (Feedback, Invite friends) ---------- */

.dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 24px var(--shadow);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.dialog-box {
  padding: 16px 20px 20px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head h2 {
  margin: 0;
}

.dialog-close {
  font-size: 1.6rem;
  line-height: 1;
  padding: 4px 8px;
}

.invite-text {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.footer-links .link-button {
  font-size: inherit;
}

/* ---------- Likes (heart on log cards) ---------- */

.like-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 2px 6px;
  margin-left: -6px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.like-button:hover:not(:disabled) {
  color: var(--error);
}

.like-button:disabled {
  cursor: default;
}

.like-heart {
  font-size: 1.1rem;
  line-height: 1;
}

.like-button[aria-pressed="true"] {
  color: var(--error);
}

.log-actions {
  align-items: center;
}

/* Hidden on screen, still read out by screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* A tick box with its words on one line */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
  cursor: pointer;
}

/* ---------- Rating breakdown (book page) ---------- */

.rating-chart {
  max-width: 260px;
  margin: 4px 0 16px;
}

.rating-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 56px;
  border-bottom: 1px solid var(--border);
}

.rating-bar {
  flex: 1;
  border-radius: 2px 2px 0 0;
  background: var(--muted);
}

.rating-bar-empty {
  background: var(--border);
}

.rating-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  color: var(--ok);
  font-size: 0.75rem;
}

/* ---------- Spoilers ---------- */

.spoiler-box {
  margin: 6px 0;
}

.spoiler-note {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

.spoiler-button {
  padding: 4px 12px;
  font-size: 0.85rem;
}

/* ---------- Rereads ---------- */

.reread-badge {
  color: var(--accent);
  font-size: 0.85rem;
}

.reread-area {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.reread-area p {
  margin: 0 0 8px;
}

.reread-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.reread-buttons input,
.progress-inputs input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

/* ---------- Page progress ---------- */

.progress-form {
  margin: 8px 0 12px;
  max-width: 360px;
}

.progress-form p {
  margin: 4px 0;
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--ok);
}

.progress-bar-small {
  height: 5px;
  margin-top: 6px;
}

.progress-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.progress-inputs input {
  width: 80px;
}

.progress-inputs .button {
  padding: 6px 12px;
}

.reading-item {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.reading-note {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

/* ---------- Reading goal (profile) ---------- */

.goal-card {
  margin-bottom: 24px;
}

.goal-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.goal-head h2 {
  margin: 0 0 12px;
}

.goal-text {
  margin: 8px 0 0;
}

.goal-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.goal-inputs input {
  width: 100px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 8px 0 0;
  font-size: 0.95rem;
}

/* ---------- Diary ---------- */

.diary-month {
  margin: 28px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: 1.1rem;
}

.diary-entry {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--surface);
}

.diary-entry .cover {
  width: 46px;
  height: 69px;
}

.diary-day {
  flex-shrink: 0;
  width: 28px;
  padding-top: 4px;
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
}

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

.diary-title {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.diary-title:hover {
  color: var(--accent);
}

.diary-author {
  display: block;
  font-size: 0.9rem;
}

.diary-text .log-meta {
  margin: 2px 0;
}

.diary-snippet {
  margin: 4px 0 0;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

/* ---------- Year in review ---------- */

.year-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.year-nav .button {
  margin-left: auto;
}

.year-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.year-stat {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
}

.year-number {
  color: var(--ok);
  font-size: 1.8rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.year-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.month-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 140px;
  margin-bottom: 24px;
}

.month-column {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.month-bar {
  width: 100%;
  max-width: 36px;
  border-radius: 3px 3px 0 0;
  background: var(--ok);
}

.month-bar-empty {
  background: var(--border);
}

.month-count,
.month-name {
  color: var(--muted);
  font-size: 0.75rem;
}

.year-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.year-pick {
  width: 140px;
}

.year-pick h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.year-skeleton {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.sk-stat {
  height: 84px;
}
