*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
::selection { background: #0f0f0f; color: #fafafa; }

:root {
  --ink: #0f0f0f;
  --paper: #FCFCFC;
  --dim: #706e68;
  --dim2: #55534e;
  --rule: #d8d6cf;
}

html { font-size: 19px; }

body {
  font-family: 'EB Garamond', 'Noto Serif Bengali', Georgia, serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-top: 88px; /* compensate for fixed topbar */
}

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

/* ── TOP BAR ── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* Mirror the .page max-width (860px) + 40px side padding */
  padding: 14px max(40px, calc((100vw - 860px) / 2 + 40px));
  opacity: 0;
  animation: appear 0.4s ease 0.05s forwards;
}

.brand { text-decoration: none; color: inherit; line-height: 1.25; }
.brand-mark {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 300; font-size: 0.72em;
  letter-spacing: 0.16em; color: var(--ink);
  display: block;
}
.brand-sub {
  font-family: 'EB Garamond', serif;
  font-style: italic; font-weight: 400;
  font-size: 0.82em; color: var(--dim);
  display: block;
  white-space: nowrap;
}

nav { display: flex; gap: 2em; align-items: center; }
nav a {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68em; font-weight: 400;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--dim); text-decoration: none;
  transition: color 0.15s;
}
nav a:hover, nav a.active { color: var(--ink); }

/* ── PAGE HEADER ── */
.page-header {
  padding: 64px 0 36px;
  opacity: 0;
  animation: slideup 0.55s ease 0.15s forwards;
}

.page-header h1 {
  font-size: clamp(2.6em, 6vw, 4.2em);
  font-weight: 400;
  line-height: 1.0;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.page-header h1 em { font-style: italic; }

.page-header .sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7em; font-weight: 300;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--dim);
}

/* ── SEARCH ── */
.search-row {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--rule);
  opacity: 0;
  animation: appear 0.5s ease 0.28s forwards;
}

.search-input {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78em; font-weight: 300;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  outline: none;
  padding: 6px 0;
  width: 260px;
  max-width: 100%;
  transition: border-color 0.2s;
}
.search-input::placeholder { color: var(--dim); }
.search-input:focus { border-color: var(--ink); }

.no-results {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72em; color: var(--dim);
  margin-top: 32px; display: none;
}

/* ── BOOK LIST ── */
.book-list {
  list-style: none;
  opacity: 0;
  animation: appear 0.55s ease 0.38s forwards;
}

.book-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: baseline;
  column-gap: 20px;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
  transition: padding-left 0.18s;
}
.book-row:hover { padding-left: 5px; }

.book-num {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65em; font-weight: 300;
  color: var(--dim);
  text-align: right;
  padding-top: 3px;
}

/* .book-main {} */

.book-title {
  font-size: 1.08em;
  font-weight: 400;
  color: var(--ink);
  display: block;
  margin-bottom: 4px;
  line-height: 1.3;
}
.book-title em { font-style: italic; }

.book-author {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68em; font-weight: 300;
  color: var(--dim);
}

.book-right { text-align: right; }

.book-cat {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62em; font-weight: 300;
  color: var(--dim2);
  white-space: nowrap;
  display: block;
  margin-bottom: 4px;
}

.book-date {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62em; font-weight: 400;
  color: var(--dim2);
  white-space: nowrap;
  display: block;
}

/* ── FOOTER ── */
footer {
  border-top: 1px solid var(--rule);
  margin-top: 60px;
  padding: 24px 0 36px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  opacity: 0;
  animation: appear 0.5s ease 0.55s forwards;
}

.footer-sig {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65em; font-weight: 300;
  letter-spacing: 0.1em; color: var(--dim);
}

.footer-icons { display: flex; gap: 0.9em; flex-wrap: wrap; }
.footer-icon {
  font-size: 0.88em; color: var(--dim);
  text-decoration: none; transition: color 0.15s;
}
.footer-icon:hover { color: var(--ink); }

@keyframes appear  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideup { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }

/* ── SCROLL TO TOP BUTTON ── */
.scroll-top-btn {
  display: none; /* shown only on mobile via media query */
  position: fixed;
  bottom: 28px;
  right: 22px;
  z-index: 300;
  width: 44px;
  height: 44px;
  background: transparent;
  color: var(--ink);
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1.4em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: none;
}
.scroll-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
}
.scroll-top-btn:hover {
  color: var(--dim);
  background: transparent;
}

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  body { padding-top: 72px; }
  .page { padding: 0 22px; }
  .topbar { padding: 12px 22px; }
  nav { gap: 0.7em; flex-wrap: nowrap; }
  .brand-sub { white-space: normal; }
  .brand-sub-break { display: block; height: 0; }
  .page-header { padding: 44px 0 24px; }
  .page-header h1 { font-size: 2.4em; }

  /* Stack: num | main | right moves below main */
  .book-row {
    grid-template-columns: 24px 1fr;
    grid-template-rows: auto auto;
  }
  .book-right {
    grid-column: 2 / 3;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    text-align: left;
    margin-top: 4px;
  }
  .book-cat { display: inline; margin-bottom: 0; }
  .book-date { display: inline; }
  footer { flex-direction: column; align-items: flex-start; gap: 14px; }

  /* Show scroll-to-top button on mobile */
  .scroll-top-btn {
    display: flex;
  }
}

@media (max-width: 440px) {
  nav { gap: 0.6em; }
  nav a { font-size: 0.62em; }
}
