:root {
  --ink: #111111;
  --muted: #9a9a9a;
  --paper: #fbfbfa;
  --page-bg: #000000;
  --zone-divider: rgba(120, 120, 120, 0.6);
  --grid-line: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--page-bg);
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

body::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1.5px, transparent 1.5px),
    linear-gradient(90deg, var(--grid-line) 1.5px, transparent 1.5px);
  background-size: 64px 64px, 64px 64px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000000 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, #000000 100%);
}

main {
  flex: 1 0 auto;
}

/* --- Navigation --- */

.nav-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 32px;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 40px;
  min-width: 0;
}

.site-logo {
  display: block;
  width: 195px;
  height: 32px;
  flex-shrink: 0;
}

.nav-categories {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}

.nav-pill {
  appearance: none;
  border: none;
  background: transparent;
  color: #aaaaaa;
  font: inherit;
  font-size: 14px;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

.nav-pill.is-active {
  background: #ffffff;
  color: #111111;
  font-weight: 600;
}

.nav-pill--hidden {
  display: none;
}

.nav-more {
  flex-shrink: 0;
}

.nav-more--hidden {
  display: none;
}

.nav-more__menu {
  display: none;
  position: absolute;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
  background: #111111;
  border: 1px solid #333333;
  border-radius: 10px;
  padding: 8px;
  z-index: 55;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

.nav-more__menu.is-open {
  display: flex;
}

.nav-more__item {
  appearance: none;
  border: none;
  background: transparent;
  color: #aaaaaa;
  font: inherit;
  font-size: 14px;
  text-align: left;
  padding: 10px 14px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.nav-more__item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-more__item.is-active {
  background: #ffffff;
  color: #111111;
  font-weight: 600;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-field {
  position: relative;
  width: 208px;
}

.search-input {
  width: 100%;
  background: #111111;
  border: 1px solid #333333;
  border-radius: 6px;
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  padding: 9px 36px 9px 16px;
}

.search-input::placeholder {
  color: #555555;
}

.search-input:focus {
  outline: none;
  border-color: #666666;
}

.search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: #111111;
  border: 1px solid #333333;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.nav-toggle .icon-close {
  display: none;
}

.nav-toggle.is-open .icon-hamburger {
  display: none;
}

.nav-toggle.is-open .icon-close {
  display: block;
}

.mobile-menu {
  display: none;
}

.mobile-menu.is-open {
  display: block;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--page-bg);
  z-index: 40;
  padding: 24px 32px 40px;
  overflow-y: auto;
}

.mobile-menu .search-field {
  width: 100%;
  margin-bottom: 8px;
}

.mobile-menu .search-input {
  font-size: 16px;
  padding: 14px 44px 14px 18px;
}

.mobile-menu .search-icon {
  right: 18px;
  width: 18px;
  height: 18px;
}

.nav-categories--mobile {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: 16px;
}

.nav-categories--mobile .nav-pill {
  width: 100%;
  text-align: left;
  font-size: 20px;
  padding: 16px 20px;
  border-radius: 10px;
  color: #cccccc;
}

.nav-categories--mobile .nav-pill.is-active {
  color: #111111;
}

@media (max-width: 1000px) {
  .nav-bar .nav-categories {
    display: none;
  }

  .nav-right .search-field {
    display: none;
  }

  .nav-toggle {
    display: flex;
  }
}

.card-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px 64px;
}

@media (max-width: 900px) {
  .card-preview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .card-preview {
    grid-template-columns: minmax(0, 1fr);
  }
}

.card-preview__error {
  grid-column: 1 / -1;
  color: #767676;
  font-size: 14px;
  text-align: center;
  padding: 48px 16px;
}

/* --- Book card component --- */

.book-card {
  background: var(--paper);
  border: 1px solid #000000;
  border-radius: 10px;
  overflow: hidden;
}

.book-card__image {
  position: relative;
  aspect-ratio: 3 / 2;
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid #000000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8%;
}

.book-card__cover {
  height: 75%;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  background: transparent;
  border: none;
  outline: none;
  box-shadow: none;
}

.book-card__tag {
  position: absolute;
  top: 12px;
  right: 12px;
  max-width: calc(100% - 24px);
  z-index: 2;
  background: #ff60a0;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.3;
  text-align: center;
  white-space: normal;
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

a.book-card__tag {
  cursor: pointer;
}

a.book-card__tag:hover {
  background: #ff7cb1;
}

.book-card__tag--static {
  cursor: default;
}

.book-card__info {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.book-card__category {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #767676;
}

.book-card__title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  color: #111111;
}

.book-card__author {
  margin: 0 0 20px;
  font-size: 14px;
  color: #767676;
}

.book-card__button {
  align-self: flex-end;
  appearance: none;
  border: none;
  font: inherit;
  background: #111111;
  color: #ffffff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
}

/* --- Footer --- */

.site-footer {
  flex-shrink: 0;
  background-color: var(--page-bg);
  border-top: 1px solid var(--zone-divider);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  white-space: nowrap;
}

.footer-credit {
  margin: 0;
  color: #555555;
  font-size: 13px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.footer-link {
  color: #555555;
  font-size: 13px;
  text-decoration: none;
}

.footer-link:hover {
  color: #ffffff;
}

.footer-divider {
  color: #555555;
  font-size: 13px;
}

@media (max-width: 480px) {
  .site-footer {
    padding: 14px 16px;
    gap: 8px;
  }

  .footer-credit,
  .footer-link,
  .footer-divider {
    font-size: 10px;
  }

  .footer-links {
    gap: 8px;
  }
}

/* --- Book detail modal --- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 60;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 512px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid #000000;
  border-radius: 10px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-image {
  position: relative;
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid #000000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8%;
}

.modal-cover {
  height: 75%;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  background: transparent;
  border: none;
  outline: none;
  box-shadow: none;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  appearance: none;
  border: none;
  border-radius: 50%;
  background: #111111;
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.modal-content {
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.modal-meta {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #767676;
}

.modal-title {
  margin: 12px 0 0;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.25;
  color: #111111;
}

.modal-author {
  margin: 8px 0 0;
  font-size: 16px;
  color: #767676;
}

.modal-summary {
  margin: 16px 0 24px;
  font-size: 14px;
  line-height: 1.6;
  color: #555555;
}

.modal-link {
  display: block;
  width: 100%;
  background: #111111;
  color: #ffffff;
  text-decoration: none;
  text-align: center;
  font-size: 15px;
  padding: 13px 16px;
  border-radius: 6px;
}

@media (max-width: 480px) {
  .modal-overlay {
    padding: 16px;
  }

  .modal-content {
    padding: 20px;
  }

  .modal-title {
    font-size: 22px;
  }
}
