/* A Bookworm's Book Nook — Enchanted Fantasy Library */

:root {
  --bg: #eee8d9;
  --paper: #faf6ec;
  --ink: #302f26;
  --muted: #817b6b;
  --green: #52654b;
  --green-dark: #354936;
  --sage: #e1e4d5;
  --line: #dcd2bd;
  --gold: #ad8950;
  --shadow: 0 12px 32px rgba(48, 43, 29, .10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 8% 5%, rgba(184, 164, 119, .16), transparent 35%),
    radial-gradient(ellipse at 95% 30%, rgba(89, 108, 77, .10), transparent 32%),
    var(--bg);
  font-family: 'DM Sans', sans-serif;
  letter-spacing: .01em;
}

button, input, textarea, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  max-width: 1320px;
  margin: auto;
  padding: 0 34px;
}

/* Header */

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.topbar:after {
  content: "✦";
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  color: var(--gold);
  padding: 0 12px;
  font-size: 13px;
}

.brand {
  display: flex;
  gap: 13px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--green-dark);
  color: #e9d9ad;
  border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.08);
  font-size: 22px;
}

.brand strong {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: 21px;
  letter-spacing: .01em;
}

.brand small {
  display: block;
  letter-spacing: 3px;
  font-size: 9px;
  color: var(--gold);
  margin-top: 4px;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  gap: 15px;
  align-items: center;
}

.icon-btn, .text-btn {
  border: 0;
  background: transparent;
  color: var(--green-dark);
  font-size: 19px;
}

.text-btn {
  font-size: 13px;
}

/* Welcome section */

.welcome-row {
  display: flex;
  justify-content: space-between;
  align-items: end;
  padding: 55px 0 34px;
}

h1, h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 500;
  margin: 8px 0;
}

h1 {
  font-size: clamp(32px, 4vw, 49px);
  line-height: 1.12;
  letter-spacing: -.025em;
}

h1 em {
  color: var(--green);
  font-weight: 500;
}

.muted {
  color: var(--muted);
  line-height: 1.7;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 2.8px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}

/* Buttons */

.primary-btn, .secondary-btn {
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 12px 19px;
  font-weight: 600;
  transition: .2s ease;
}

.primary-btn {
  background: var(--green-dark);
  color: #fffaf0;
  box-shadow: 0 4px 12px rgba(45, 63, 43, .18);
}

.primary-btn:hover {
  background: #263a2b;
  transform: translateY(-2px);
}

.secondary-btn {
  background: #e8e2d3;
  color: var(--green-dark);
  border-color: #d7cbb3;
}

.secondary-btn:hover {
  background: #ddd6c3;
}

.full {
  width: 100%;
}

/* Library statistics */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin: 12px 0 36px;
}

.stat-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: .2s ease;
}

.stat-card:before {
  content: "✦";
  position: absolute;
  right: 13px;
  top: 10px;
  color: var(--gold);
  opacity: .55;
  font-size: 13px;
}

.stat-card:hover {
  transform: translateY(-3px);
}

.stat-card span {
  display: block;
  font-size: 9px;
  letter-spacing: 1.8px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: 34px;
  font-weight: 500;
  margin: 8px 0 0;
  color: var(--green-dark);
}

.stat-card small {
  color: var(--muted);
  font-size: 11px;
}

/* Navigation and search */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: flex;
  gap: 25px;
  overflow: auto;
}

.tab {
  white-space: nowrap;
  border: 0;
  background: none;
  padding: 14px 0;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--green-dark);
  border-color: var(--gold);
  font-weight: 700;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 9px 14px;
  border-radius: 4px;
  min-width: 230px;
  color: var(--muted);
}

.search-wrap input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  font-size: 12px;
  color: var(--ink);
}

.sort-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 19px 0;
  color: var(--muted);
  font-size: 12px;
}

.sort-row select {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 4px;
  padding: 9px 13px;
  color: var(--ink);
  font-size: 11px;
}

/* Book collection */

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 34px 24px;
  padding-bottom: 55px;
}

.book-card {
  min-width: 0;
  position: relative;
  transition: transform .2s ease;
}

.book-card:hover {
  transform: translateY(-5px);
}

.cover-wrap {
  height: 225px;
  background: #e4ddcc;
  border-radius: 3px 7px 7px 3px;
  overflow: hidden;
  box-shadow: 6px 8px 16px rgba(39, 42, 29, .19);
  position: relative;
}

.cover-wrap:before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: #00000020;
  z-index: 1;
}

.cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
}

.cover-placeholder {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 15px;
  font-family: 'Playfair Display', serif;
  color: var(--green-dark);
  background:
    radial-gradient(circle at center, #f6edda, transparent 70%),
    linear-gradient(145deg, #dce2d1, #eee1c9);
}

.cover-placeholder span {
  font-size: 28px;
}

.book-info {
  padding: 12px 3px;
}

.book-info h3 {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 5px;
  line-height: 1.4;
}

.book-info p {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 10px;
  color: var(--green);
}

.book-actions {
  position: absolute;
  right: 7px;
  top: 7px;
  display: flex;
  gap: 4px;
}

.mini-btn {
  border: 0;
  background: #faf6eced;
  color: var(--green-dark);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 13px;
  box-shadow: 0 2px 8px #0002;
}

/* Empty library */

.empty-state {
  text-align: center;
  padding: 65px 20px 90px;
  background: rgba(250, 246, 236, .65);
  border: 1px dashed #c9b995;
  border-radius: 7px;
  margin: 22px 0 55px;
}

.empty-state > div {
  font-size: 38px;
  color: var(--gold);
}

.empty-state h2 {
  font-size: 26px;
}

.empty-state p {
  color: var(--muted);
  font-size: 13px;
}

/* Login */

.auth-wrap {
  min-height: calc(100vh - 145px);
  display: grid;
  place-items: center;
  padding: 40px 0;
}

.auth-card {
  width: min(100%, 430px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 38px;
  box-shadow: 0 22px 60px rgba(36, 42, 30, .13);
}

.auth-card h1 {
  font-size: 38px;
}

.book-stack {
  font-size: 32px;
  margin-bottom: 16px;
}

.auth-card label,
.book-form label,
.setup-card label {
  display: block;
  font-size: 11px;
  color: var(--green-dark);
  font-weight: 700;
  margin: 14px 0;
}

.auth-card input,
.setup-card input,
.setup-card textarea,
.book-form input,
.book-form textarea,
.book-form select,
.lookup-row input {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fffdf7;
  color: var(--ink);
  outline-color: var(--gold);
  font-size: 13px;
}

.auth-card form .primary-btn {
  margin-top: 12px;
}

.tiny {
  font-size: 10px;
}

.form-message {
  font-size: 12px;
  color: #9a624b;
  min-height: 16px;
}

/* Add book and scanner windows */

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(25, 35, 27, .78);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: min(100%, 720px);
  max-height: 90vh;
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 30px;
  box-shadow: 0 20px 70px #0004;
}

.modal-card h2 {
  font-size: 30px;
}

.close-btn {
  position: absolute;
  right: 18px;
  top: 12px;
  border: 0;
  background: var(--sage);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 23px;
  color: var(--green-dark);
}

.lookup-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin: 20px 0 8px;
}

.lookup-row input {
  margin: 0;
}

.scanner-wrap {
  margin: 16px auto;
  max-width: 360px;
}

.scanner-wrap #reader {
  width: 100%;
}

.form-book {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.form-book label {
  margin: 10px 0;
}

.form-book label input,
.form-book label select,
.form-book label textarea {
  font-weight: 400;
}

.form-book > label {
  margin-top: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

.form-book .primary-btn {
  margin-top: 16px;
}

.form-book input,
.form-book textarea,
.form-book select {
  padding: 9px;
}

.form-book textarea {
  resize: vertical;
}

.form-book label:has(textarea) {
  display: block;
}

.form-book > label {
  display: block;
}

.form-book .form-grid label {
  min-width: 0;
}

.form-book .form-grid input,
.form-book .form-grid select {
  min-width: 0;
}

.form-book .form-book-preview {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.form-book-preview img {
  width: 54px;
  height: 76px;
  object-fit: contain;
  background: #eee8d9;
  border-radius: 3px;
  box-shadow: 3px 4px 9px #0002;
}

.form-book-preview strong,
.form-book-preview span {
  display: block;
}

.form-book-preview strong {
  font-family: 'Playfair Display', serif;
}

.form-book-preview span {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}

/* Notifications and footer */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: var(--green-dark);
  color: #fffaf0;
  padding: 12px 18px;
  border-radius: 5px;
  font-size: 12px;
  transition: .25s;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

footer {
  text-align: center;
  padding: 25px 0 32px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .08em;
}

footer span {
  color: var(--gold);
  padding-left: 5px;
}

.hidden {
  display: none !important;
}

.series-heading {
  grid-column: 1 / -1;
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  padding: 17px 0 0;
  border-top: 1px solid var(--gold);
  color: var(--green-dark);
}

/* Dark mode */

body.dark {
  --bg: #202820;
  --paper: #2b352b;
  --ink: #f0eadc;
  --muted: #b8b4a5;
  --green: #a6b79a;
  --green-dark: #d5dfc8;
  --sage: #3d4a3c;
  --line: #495346;
  --gold: #d2b276;
  --shadow: 0 12px 32px rgba(0,0,0,.2);
}

body.dark {
  background:
    radial-gradient(ellipse at 10% 0%, #3b4c382e, transparent 38%),
    var(--bg);
}

body.dark .brand-mark {
  background: #40513d;
}

body.dark .cover-wrap {
  background: #465044;
}

body.dark .cover-placeholder {
  background: linear-gradient(145deg, #39493e, #554b3b);
  color: #eee5d1;
}

body.dark input,
body.dark textarea,
body.dark select {
  background: #253129;
  color: var(--ink);
  border-color: var(--line);
}

body.dark .search-wrap {
  background: var(--paper);
}

body.dark .mini-btn {
  background: #344239;
  color: #f5f1e6;
}

body.dark .empty-state {
  background: #2b352b;
}

/* Smaller screens */

@media(max-width: 700px) {
  .app-shell {
    padding: 0 18px;
  }

  .topbar {
    min-height: 74px;
  }

  .welcome-row {
    align-items: start;
    gap: 15px;
    flex-direction: column;
    padding: 36px 0 22px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 9px;
  }

  .stat-card {
    padding: 14px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column-reverse;
    padding-bottom: 8px;
  }

  .tabs {
    gap: 18px;
  }

  .search-wrap {
    width: 100%;
  }

  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 15px;
  }

  .cover-wrap {
    height: 225px;
  }

  .modal-card {
    padding: 24px 18px;
  }

  .lookup-row {
    grid-template-columns: 1fr 1fr;
  }

  .lookup-row input {
    grid-column: 1 / -1;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 28px 22px;
  }
}
/* Enchanted fantasy banner */

.fantasy-banner {
  position: relative;
  min-height: 300px;
  margin: 30px 0 25px;
  overflow: hidden;
  border: 2px solid #b99a65;
  border-radius: 8px;
  background-image: url("book_nook_fantasy_banner.png");
  background-size: cover;
  background-position: center;
  box-shadow: 0 8px 24px rgba(65, 48, 26, .15);
}

.fantasy-banner-title,
.fantasy-banner-art {
  display: none;
}

@media(max-width: 700px) {
  .fantasy-banner {
    min-height: 190px;
    background-position: center;
  }
}

.fantasy-banner-title {
  position: relative;
  z-index: 2;
  max-width: 55%;
}

.fantasy-banner-title span {
  color: #987443;
  font-size: 10px;
  letter-spacing: 3px;
  font-weight: 700;
}

.fantasy-banner-title h2 {
  color: #40301f;
  font-size: clamp(27px, 4vw, 43px);
  line-height: 1.15;
  margin: 12px 0;
}

.fantasy-banner-title p {
  color: #756044;
  font-family: 'Playfair Display', serif;
  font-size: 16px;
}

.fantasy-banner-art span {
  position: absolute;
  z-index: 1;
  filter: drop-shadow(2px 4px 3px #5a402533);
}

.banner-castle {
  right: 30%;
  top: 35px;
  font-size: 75px;
}

.banner-dragon {
  right: 9%;
  top: 35px;
  font-size: 85px;
}

.banner-books {
  right: 23%;
  bottom: 20px;
  font-size: 55px;
}

.banner-crown {
  right: 12%;
  bottom: 25px;
  color: #a77b32;
  font-size: 48px;
}

.banner-rose {
  font-size: 34px;
}

.rose-one {
  right: 3%;
  top: 12px;
}

.rose-two {
  right: 42%;
  bottom: 18px;
}

.banner-ivy {
  left: 15px;
  bottom: 8px;
  color: #68764c;
  font-size: 45px;
}

@media(max-width: 700px) {
  .fantasy-banner {
    min-height: 230px;
    padding: 25px 20px;
  }

  .fantasy-banner-title {
    max-width: 65%;
  }

  .banner-castle {
    right: 20%;
    font-size: 48px;
  }

  .banner-dragon {
    right: 2%;
    top: 55px;
    font-size: 55px;
  }

  .banner-books {
    right: 12%;
    font-size: 38px;
  }

  .banner-crown {
    right: 4%;
    font-size: 32px;
  }
}
/* Antique book stack above My Books */

.my-books-card {
  position: relative;
  text-align: center;
  padding-top: 12px;
}

.book-stack-art {
  width: 55px;
  height: 33px;
  margin: -5px auto 0;
  background-image: url("my-books-stack.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
.my-books-card strong {
  margin-top: 2px;
  line-height: 1;
}
/* Antique books and scroll above To Be Read */

.tbr-card {
  text-align: center;
  padding-top: 12px;
}

.tbr-art {
  width: 55px;
  height: 40px;
  margin: -5px auto 0;
  background-image: url("to-be-read-stack.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
/* Antique open book above Read */

.read-card {
  text-align: center;
  padding-top: 12px;
}

.read-art {
  width: 55px;
  height: 40px;
  margin: -5px auto 0;
  background-image: url("read-book.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
/* Antique wishlist book illustration */

.wishlist-card {
  text-align: center;
  padding-top: 12px;
}

.wishlist-art {
  width: 55px;
  height: 40px;
  margin: -5px auto 0;
  background-image: url("wishlist-book.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
/* Antique fantasy navigation tabs */

.tabs {
  gap: 10px;
  align-items: center;
}

.tab {
  padding: 11px 17px;
  border: 1px solid transparent;
  border-radius: 4px 4px 0 0;
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 14px;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: .2s ease;
}

.tab:hover {
  color: var(--green-dark);
  background: var(--sage);
  border-color: var(--line);
}

.tab.active {
  color: var(--paper);
  background: var(--green-dark);
  border: 1px solid var(--gold);
  border-bottom: 2px solid var(--gold);
  font-weight: 700;
}
/* Parchment-style search box */

.search-wrap {
  background: var(--paper);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 12px 18px;
  min-width: 300px;
  box-shadow: 0 3px 10px rgba(90, 65, 30, 0.10);
  gap: 12px;
}

.search-wrap span {
  font-size: 20px;
  color: var(--green-dark);
}

.search-wrap input {
  font-family: Georgia, serif;
  font-size: 14px;
}
/* Matching antique sort dropdown */

.sort-row select {
  border: 1px solid var(--gold);
  background: var(--paper);
  border-radius: 12px !important;
  padding: 11px 16px;
  color: var(--green-dark);
  font-family: Georgia, serif;
  font-size: 13px;
  box-shadow: 0 3px 10px rgba(90, 65, 30, 0.10);
  cursor: pointer;
}
/* Clean Libib-style book covers */

.cover-wrap {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

.cover-wrap img {
  background: transparent;
  object-fit: contain;
}
