:root {
  --cream: #f3ead9;
  --cream-deep: #ebdfc7;
  --paper: #fbf6ec;
  --ink: #3a2f26;
  --ink-soft: #6b5d4f;
  --clay: #a9633f;
  --clay-deep: #8a4c30;
  --rose: #c17a72;
  --rose-deep: #a35850;
  --line: #d9cbb0;
  --shadow: 0 10px 24px rgba(58, 47, 38, 0.14);
  --radius: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(circle at 13% 15%, rgba(255,255,255,.9) 0 2px, transparent 2.8px),
    radial-gradient(circle at 78% 23%, rgba(255,255,255,.72) 0 1px, transparent 2.2px),
    radial-gradient(ellipse at 50% -10%, #fff6f8 0, transparent 52%),
    linear-gradient(135deg, #f1dce1 0%, #faecdf 48%, #e4d7ef 100%);
  background-size: 33px 37px, 47px 53px, auto, auto;
  color: var(--ink);
  font-family: 'Vazirmatn', sans-serif;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---------- Ambient floating hearts (behind all content) ---------- */
.hearts-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.hearts-bg::before,
.hearts-bg::after {
  position: absolute;
  z-index: -1;
  content: "♥";
  color: #d87991;
  font-family: Georgia, serif;
  line-height: 1;
  opacity: .14;
  filter: drop-shadow(0 14px 18px rgba(152,65,88,.14));
  pointer-events: none;
}
.hearts-bg::before {
  top: 10vh;
  right: -5vw;
  font-size: clamp(200px, 31vw, 520px);
  transform: rotate(15deg);
}
.hearts-bg::after {
  bottom: -13vh;
  left: -3vw;
  font-size: clamp(190px, 29vw, 490px);
  color: #ae91d0;
  transform: rotate(-18deg);
}

.hearts-bg .heart {
  position: absolute;
  bottom: -12%;
  color: var(--rose);
  opacity: 0;
  animation: heartRise linear infinite;
  will-change: transform, opacity;
}

@keyframes heartRise {
  0%   { transform: translateY(0) rotate(-4deg) scale(0.85); opacity: 0; }
  12%  { opacity: 0.48; }
  85%  { opacity: 0.38; }
  100% { transform: translateY(-118vh) rotate(6deg) scale(1.05); opacity: 0; }
}

.hearts-bg .heart:nth-child(1)  { left: 4%;  font-size: 32px; animation-duration: 22s; animation-delay: 0s; }
.hearts-bg .heart:nth-child(2)  { left: 14%; font-size: 25px; animation-duration: 17s; animation-delay: 3s; }
.hearts-bg .heart:nth-child(3)  { left: 24%; font-size: 42px; animation-duration: 26s; animation-delay: 1s; }
.hearts-bg .heart:nth-child(4)  { left: 36%; font-size: 28px; animation-duration: 19s; animation-delay: 6s; }
.hearts-bg .heart:nth-child(5)  { left: 48%; font-size: 36px; animation-duration: 24s; animation-delay: 2s; }
.hearts-bg .heart:nth-child(6)  { left: 60%; font-size: 27px; animation-duration: 20s; animation-delay: 8s; }
.hearts-bg .heart:nth-child(7)  { left: 71%; font-size: 46px; animation-duration: 28s; animation-delay: 4s; }
.hearts-bg .heart:nth-child(8)  { left: 82%; font-size: 30px; animation-duration: 18s; animation-delay: 10s; }
.hearts-bg .heart:nth-child(9)  { left: 91%; font-size: 35px; animation-duration: 23s; animation-delay: 5s; }
.hearts-bg .heart:nth-child(10) { left: 58%; font-size: 24px; animation-duration: 16s; animation-delay: 12s; }

/* dreamy, low-contrast specks make the shelf feel like a small storybook world */
.magic-dust {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.magic-dust::before,
.magic-dust::after {
  content: "";
  position: absolute;
  width: 44vw;
  height: 44vw;
  border-radius: 50%;
  filter: blur(18px);
  opacity: .32;
}
.magic-dust::before { top: 18%; right: -17%; background: #f2aebd; }
.magic-dust::after { bottom: -16%; left: -12%; background: #cdb2e7; }
.magic-dust i {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fffdf6;
  box-shadow: 0 0 0 2px rgba(193,122,114,.15), 0 0 13px 3px rgba(255,255,255,.8);
  animation: twinkle 4s ease-in-out infinite;
}
.magic-dust i:nth-child(1) { top: 12%; right: 12%; } .magic-dust i:nth-child(2) { top: 29%; right: 30%; animation-delay: .8s; }
.magic-dust i:nth-child(3) { top: 17%; left: 20%; animation-delay: 1.7s; } .magic-dust i:nth-child(4) { top: 45%; left: 8%; animation-delay: 2.4s; }
.magic-dust i:nth-child(5) { top: 64%; right: 13%; animation-delay: .4s; } .magic-dust i:nth-child(6) { top: 78%; right: 39%; animation-delay: 2.2s; }
.magic-dust i:nth-child(7) { top: 82%; left: 18%; animation-delay: 1.1s; } .magic-dust i:nth-child(8) { top: 37%; left: 42%; animation-delay: 3s; }
.magic-dust i:nth-child(9) { top: 8%; left: 49%; animation-delay: 1.3s; } .magic-dust i:nth-child(10) { top: 57%; right: 4%; animation-delay: 2.7s; }
.magic-dust i:nth-child(11) { top: 90%; left: 46%; animation-delay: .6s; } .magic-dust i:nth-child(12) { top: 33%; right: 7%; animation-delay: 1.9s; }
@keyframes twinkle { 0%, 100% { transform: scale(.45); opacity: .15; } 50% { transform: scale(1.15); opacity: .9; } }

@media (prefers-reduced-motion: reduce) {
  .hearts-bg .heart {
    animation: none;
    opacity: 0.14;
    bottom: 6%;
  }
}

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.86), transparent 32%),
    linear-gradient(135deg, #f1dce1, #faecdf 52%, #e4d7ef);
}

.login-card {
  position: relative;
  z-index: 1;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 48px 40px;
  width: min(360px, 88vw);
  text-align: center;
}

.login-emblem {
  font-size: 30px;
  color: var(--rose);
  margin-bottom: 8px;
  animation: heartbeat 2.4s ease-in-out infinite;
  display: inline-block;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  15%      { transform: scale(1.14); }
  30%      { transform: scale(1); }
  45%      { transform: scale(1.1); }
  60%      { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .login-emblem { animation: none; }
}

.login-card h1 {
  font-family: 'Noto Serif', serif;
  font-size: 22px;
  margin: 0 0 4px;
  color: var(--ink);
}

.login-sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 28px;
}

.login-card input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 15px;
  text-align: center;
  outline: none;
  transition: border-color .15s;
}

.login-card input:focus {
  border-color: var(--clay);
}

.login-card button {
  width: 100%;
  margin-top: 14px;
  padding: 13px;
  border: none;
  border-radius: 8px;
  background: var(--clay);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  transition: background .15s;
}

.login-card button:hover { background: var(--clay-deep); }

.login-error {
  color: #a13d2b;
  font-size: 13px;
  margin: 14px 0 0;
}

/* ---------- Top bar ---------- */
.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 6vw;
}

.topbar-title {
  font-family: 'Noto Serif', serif;
  font-size: 19px;
  letter-spacing: .3px;
}

.emblem {
  color: var(--rose);
  margin-left: 6px;
  display: inline-block;
  animation: heartbeat 2.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .emblem { animation: none; }
}

.logout-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  transition: all .15s;
}

.logout-btn:hover {
  border-color: var(--clay);
  color: var(--clay-deep);
}

/* ---------- Shelf (3x3 books) ---------- */
.shelf-wrap {
  position: relative;
  z-index: 1;
  padding: 20px 6vw 80px;
}

.shelf {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 34px;
  max-width: 980px;
  margin: 40px auto 0;
}

@media (max-width: 720px) {
  .shelf { grid-template-columns: repeat(2, 1fr); gap: 22px; }
}
@media (max-width: 460px) {
  .shelf { grid-template-columns: 1fr; }
}

.book {
  --cover-light: #faead3;
  --cover-dark: #a9633f;
  --edge: #e0c9a8;
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 6px 10px 10px 6px;
  background:
    linear-gradient(90deg, rgba(91,49,32,.22), transparent 8%),
    linear-gradient(145deg, var(--cover-light), var(--cover-dark));
  border: 1px solid rgba(104,65,43,.25);
  box-shadow:
    -4px 2px 0 var(--edge),
    -7px 4px 0 #f7eddc,
    -10px 6px 0 var(--edge),
    -13px 8px 0 #f7eddc,
    -16px 10px 0 rgba(174,138,100,.68),
    0 15px 24px rgba(58,47,38,.18),
    8px 21px 28px rgba(58,47,38,.10);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 14px;
  text-align: center;
  transform: translateY(0) rotate(0deg);
  transition: transform .35s ease, box-shadow .35s ease;
  overflow: visible;
  isolation: isolate;
}

.book-tone-2 { --cover-light: #f7e1dc; --cover-dark: #ad6870; --edge: #dfbdab; }
.book-tone-3 { --cover-light: #eee1c4; --cover-dark: #a17a38; --edge: #dfc796; }
.book-tone-4 { --cover-light: #dce6e5; --cover-dark: #5f8884; --edge: #b7cfca; }
.book-tone-5 { --cover-light: #e7dced; --cover-dark: #8b6d9e; --edge: #cebad9; }
.book-tone-6 { --cover-light: #f1ded0; --cover-dark: #a65e45; --edge: #dfb79b; }

.book::selection { background: transparent; }
.page-block {
  position: absolute;
  z-index: -1;
  inset: 9px auto -10px -16px;
  width: 18px;
  border-radius: 5px 0 0 5px;
  background: repeating-linear-gradient(to bottom, #fdf6e9 0 2px, #d7c5a8 2px 3px);
  box-shadow: inset 2px 0 rgba(109,75,54,.12);
}

.book::before {
  /* spine ribbon */
  content: "";
  position: absolute;
  z-index: 1;
  top: 0; bottom: 0; right: 17px;
  width: 14px;
  background: linear-gradient(90deg, rgba(67,35,27,.2), rgba(255,255,255,.13) 25%, rgba(67,35,27,.11) 70%, transparent);
  border-left: 1px solid rgba(255,255,255,.22);
  opacity: .9;
}

.book-corner { position: absolute; z-index: 2; right: 0; width: 38px; height: 38px; border-color: rgba(255,255,255,.56); border-style: solid; pointer-events: none; }
.book-corner-top { top: 0; border-width: 1px 1px 0 0; border-radius: 0 9px 0 0; }
.book-corner-bottom { bottom: 0; border-width: 0 1px 1px 0; border-radius: 0 0 9px 0; }
.cover-content { position: relative; z-index: 3; display: flex; height: 100%; width: 100%; flex-direction: column; align-items: center; justify-content: center; }

.book:hover,
.book.is-open {
  transform: translateY(-12px) rotate(-1.6deg) perspective(800px) rotateY(-3deg);
  box-shadow:
    -4px 2px 0 var(--edge), -7px 4px 0 #f7eddc, -10px 6px 0 var(--edge), -13px 8px 0 #f7eddc, -16px 10px 0 rgba(174,138,100,.68),
    0 29px 38px rgba(58,47,38,.28), 10px 35px 44px rgba(58,47,38,.13);
}

/* یک قلب کوچک که با هاور از بالای آلبوم بلند می‌شود و محو می‌شود */
.book::after {
  content: "♥";
  position: absolute;
  z-index: 5;
  top: -20px;
  right: 13px;
  color: var(--rose);
  font-size: 34px;
  filter: drop-shadow(0 4px 4px rgba(128,55,58,.22));
  opacity: 0;
  pointer-events: none;
}

.book:hover::after,
.book.is-open::after {
  animation: heartPop .9s ease forwards;
}

@keyframes heartPop {
  0%   { opacity: 0; transform: translateY(0) scale(.6); }
  30%  { opacity: .98; transform: translateY(-14px) scale(1); }
  100% { opacity: 0; transform: translateY(-48px) scale(1.18); }
}

@media (prefers-reduced-motion: reduce) {
  .book:hover::after,
  .book.is-open::after { animation: none; opacity: 0; }
}

.book .cover-icon {
  font-size: 44px;
  line-height: 1;
  margin-bottom: 14px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.08));
  transition: transform .35s ease;
}

.book:hover .cover-icon,
.book.is-open .cover-icon {
  transform: scale(1.12) translateY(-2px);
}

.book .cover-image {
  width: 100%;
  height: 62%;
  object-fit: cover;
  border-radius: 3px;
  margin-bottom: 10px;
  border: 3px solid rgba(255,250,237,.75);
  box-shadow: 0 5px 11px rgba(54,31,19,.24), inset 0 0 0 1px rgba(85,49,31,.16);
}

.book .book-title {
  font-family: 'Noto Serif', serif;
  font-size: 15px;
  font-weight: 600;
  color: #4a2e25;
  padding: 5px 11px;
  background: rgba(255,250,239,.3);
  border-radius: 4px;
  text-shadow: 0 1px rgba(255,255,255,.35);
}

.book .book-sub {
  font-size: 11.5px;
  color: rgba(59,38,31,.78);
  margin-top: 4px;
}

.book .book-count {
  position: absolute;
  bottom: 10px;
  left: 12px;
  font-size: 10.5px;
  color: var(--ink-soft);
  background: rgba(255,252,242,.72);
  padding: 2px 8px;
  border-radius: 10px;
}

.book .book-count::before {
  content: "♥";
  color: var(--rose);
  margin-left: 4px;
}

/* peek strip that rises on hover, like a book cover lifting */
.book .peek {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(169,99,63,0.08), rgba(169,99,63,0));
  opacity: 0;
  transition: opacity .35s ease;
  pointer-events: none;
}
.book:hover .peek,
.book.is-open .peek { opacity: 1; }

/* ---------- Album (grid view) ---------- */
.album-wrap {
  position: relative;
  z-index: 1;
  padding: 26px 6vw 90px;
  max-width: 1100px;
  margin: 0 auto;
}

.back-btn {
  background: transparent;
  border: none;
  color: var(--clay-deep);
  font-size: 14px;
  padding: 6px 0;
  margin-bottom: 18px;
}
.back-btn:hover { text-decoration: underline; }

.album-title {
  font-family: 'Noto Serif', serif;
  font-size: 26px;
  margin: 0 0 2px;
}
.album-subtitle {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 26px;
}

.album-subtitle::before {
  content: "♥";
  color: var(--rose);
  font-size: 11px;
  margin-left: 7px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

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

@media (max-width: 460px) {
  .photo-grid { grid-template-columns: 1fr; }
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: zoom-in;
  border: 1px solid var(--line);
  transition: transform .2s ease, box-shadow .2s ease;
  background: var(--cream-deep);
}
.photo-grid img:hover {
  transform: scale(1.03);
  box-shadow: 0 10px 20px rgba(58,47,38,0.18);
}

.empty-note {
  color: var(--ink-soft);
  font-size: 14px;
  padding: 30px 4px;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(30, 23, 17, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.lightbox[hidden] {
  display: none;
}
.lightbox img {
  max-width: 88vw;
  max-height: 86vh;
  border-radius: 6px;
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
}
.lb-close {
  position: absolute;
  top: 20px;
  left: 24px;
  background: transparent;
  border: none;
  color: #f3ead9;
  font-size: 22px;
}
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #f3ead9;
  font-size: 40px;
  padding: 10px 16px;
}
.lb-prev { right: 14px; }
.lb-next { left: 14px; }

@media (prefers-reduced-motion: reduce) {
  .book, .cover-icon, .peek, .photo-grid img { transition: none !important; }
}
