:root {
  color-scheme: light;
  font-family:
    -apple-system, BlinkMacSystemFont, Inter, ui-sans-serif, system-ui, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  font-synthesis: none;
  --page: #fafafa;
  --ink: #171717;
  --muted: #a3a3a3;
  --soft: #f5f5f5;
  --reading: #f97316;
  --buy: #0ea5e9;
  --will-read: #f59e0b;
  --read: #10b981;
  --dropped: #ef4444;
  --rafa: #ec4899;
  --rating: #eab308;
  --rating-fill: #fef08a;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
  font-size: 16px;
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
a {
  font: inherit;
}

button {
  border: 0;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid #a3a3a3;
  outline-offset: 3px;
}

.page {
  min-height: 100vh;
  width: 100%;
  padding-top: 48px;
}

.shell {
  position: relative;
  width: auto;
  min-height: 100vh;
  margin: 0 24px;
}

.mobile-nav {
  display: flex;
  height: 44px;
  align-items: flex-start;
  gap: 48px;
  padding-bottom: 24px;
}

.desktop-rail {
  display: none;
}

.nav-control,
.rail-trigger {
  display: flex;
  width: fit-content;
  cursor: pointer;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  transition:
    color 150ms ease-in-out,
    background-color 150ms ease-in-out;
}

.nav-control:hover,
.rail-trigger:hover {
  color: #737373;
}

.nav-control > span:last-child,
.rail-trigger > span:last-child {
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.01em;
}

.nav-icon,
.option-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 12px;
  height: 12px;
}

.rail-block + .rail-block {
  padding-top: 24px;
}

.rail-menu {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.motion-menu {
  --rail-spring: cubic-bezier(0.328, 0.695, 0.115, 1);
  height: 0;
  margin-top: 0;
  opacity: 0;
  filter: blur(4px);
  pointer-events: none;
  transform: translateY(-4px);
  will-change: height, margin-top, opacity, filter, transform;
  transition:
    height 400ms var(--rail-spring),
    margin-top 400ms var(--rail-spring),
    opacity 400ms var(--rail-spring),
    filter 400ms var(--rail-spring),
    transform 400ms var(--rail-spring);
}

.motion-menu.is-open {
  height: var(--menu-height);
  margin-top: 12px;
  opacity: 1;
  filter: blur(0);
  pointer-events: auto;
  transform: translateY(0);
}

[data-rail-menu="filters"] {
  --menu-height: 148px;
  width: 160px;
  overflow: hidden;
}

[data-rail-menu="sort"] {
  --menu-height: 96px;
}

[data-rail-menu="lang"] {
  --menu-height: 44px;
}

.rail-option,
.status-chip {
  display: flex;
  width: fit-content;
  cursor: pointer;
  user-select: none;
  align-items: center;
  border: 0;
  background: transparent;
  transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.rail-option {
  gap: 5px;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
  letter-spacing: 0.01em;
}

.rail-option:hover,
.status-chip:hover {
  opacity: 0.7;
}

.rail-option.is-dim {
  opacity: 0.5;
}

.rail-option.is-dim:hover {
  opacity: 0.7;
}

.rail-option[data-status="Read"],
.status-chip[data-status="Read"] {
  color: var(--read);
}

.rail-option[data-status="Reading"],
.status-chip[data-status="Reading"] {
  color: var(--reading);
}

.rail-option[data-status="Buy"],
.status-chip[data-status="Buy"] {
  color: var(--buy);
}

.rail-option[data-status="Will Read"],
.status-chip[data-status="Will Read"] {
  color: var(--will-read);
}

.rail-option[data-status="Dropped"],
.status-chip[data-status="Dropped"] {
  color: var(--dropped);
}

.rail-option[data-status="Rafa's"] {
  color: var(--rafa);
}

.option-icon svg {
  width: 11px;
  height: 11px;
}

.option-close {
  width: 0;
  margin-top: 2px;
  margin-left: -5px;
  overflow: hidden;
  color: #a3a3a3;
  font-size: 12px;
  line-height: 12px;
  opacity: 0;
  filter: blur(4px);
  transform: translateX(-4px);
  transition:
    width 200ms ease-in-out,
    margin-left 200ms ease-in-out,
    opacity 200ms ease-in-out,
    filter 200ms ease-in-out,
    transform 200ms ease-in-out;
}

.rail-option[aria-pressed="true"] .option-close {
  width: 7px;
  margin-left: 1px;
  opacity: 1;
  filter: blur(0);
  transform: translateX(0);
}

@supports (transition-timing-function: linear(0, 1)) {
  .motion-menu {
    --rail-spring: linear(
      0,
      0.114416 6.25%,
      0.320751 12.5%,
      0.516401 18.75%,
      0.671068 25%,
      0.783075 31.25%,
      0.860098 37.5%,
      0.911282 43.75%,
      0.944477 50%,
      0.978895 62.5%,
      0.992211 75%,
      0.997186 87.5%,
      1
    );
  }
}

.catalogue-wrap {
  display: flex;
  flex-direction: column;
  padding-bottom: 192px;
}

.catalogue {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 64px 48px;
  margin-top: 8px;
}

.book-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 20px;
}

.book-scene {
  --bw: 58px;
  --bh: 90px;
  position: relative;
  width: var(--bw);
  height: var(--bh);
  perspective: 600px;
  perspective-origin: 50% 40%;
  user-select: none;
}

.book {
  position: relative;
  width: 100%;
  height: 100%;
  transform: rotateY(-14deg);
  transform-style: preserve-3d;
}

.book-front {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 0 2px 2px 0;
  transform: translateZ(10px);
}

.book-front::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgb(0 0 0 / 12%),
    transparent 10%,
    rgb(255 255 255 / 12%) 16%,
    transparent 28%
  );
  content: "";
}

.book-front img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.book-spine {
  position: absolute;
  top: 0;
  left: calc(50% - 10px);
  width: 20px;
  height: 100%;
  background-position: 0;
  background-size: 900% 100%;
  filter: brightness(0.6) saturate(1.15);
  transform: rotateY(-90deg) translateZ(calc(var(--bw) / 2));
}

.book-pages {
  position: absolute;
  top: 1px;
  left: calc(50% - 9px);
  width: 18px;
  height: calc(100% - 2px);
  background: linear-gradient(90deg, #ddd6c3, #f3eee0 40%, #e6dfcc);
  box-shadow: inset 1px 0 2px rgb(0 0 0 / 15%);
  transform: rotateY(90deg) translateZ(calc(var(--bw) / 2));
}

.book-ground {
  position: absolute;
  right: -10px;
  bottom: -7px;
  left: -6px;
  height: 10px;
  background: radial-gradient(
    ellipse 50% 100% at 40% 50%,
    rgb(0 0 0 / 18%),
    rgb(0 0 0 / 6%) 60%,
    transparent 80%
  );
  filter: blur(4px);
}

.book-info {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-chip {
  gap: 3px;
  padding: 0;
  font-size: 11px;
  line-height: 11px;
}

.status-chip svg {
  width: 9px;
  height: 9px;
}

.book-title {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  text-wrap: balance;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.book-author {
  overflow: hidden;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rating {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 9px;
}

.star,
.star-slot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
}

.star {
  display: block;
  fill: var(--rating-fill);
  color: var(--rating);
}

.star-slot {
  position: relative;
}

.star-slot > .star:first-child {
  position: absolute;
  fill: transparent;
  color: transparent;
}

.star-half {
  position: absolute;
  width: 50%;
  overflow: hidden;
}

.empty-state {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

@media (min-width: 640px) {
  .page {
    padding-top: 80px;
  }

  .shell {
    width: 480px;
    margin-right: auto;
    margin-left: auto;
  }
}

@media (min-width: 768px) {
  .shell {
    width: 640px;
  }

  .mobile-nav {
    display: none;
  }

  .desktop-rail {
    position: fixed;
    top: 84.8px;
    left: calc(50% - 26rem);
    z-index: 2;
    display: block;
  }

  .catalogue {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .desktop-rail {
    left: calc(50% - 29rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
