/* ScreenBuddy (web) — 📖 album ảnh kỷ niệm (album.js) + cuốn album trên bàn nhỏ trong phòng (room.js). */

/* ---------------- Cuốn album trong phòng ---------------- */
.album-cover { fill: #e5738f; }
.album-cover-d { fill: #b8506b; }
.room-world.theme-night .album-cover { fill: #c86a9a; }

.furn-album .album-count {
  position: absolute;
  top: 2px;
  left: 58%;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #ff5d8f;
  color: #ffffff;
  font: 700 11px/20px "Segoe UI", system-ui, sans-serif;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.furn-album .album-count[hidden] {
  display: none;
}

.furn-album.pulse .album-book-art {
  animation: album-bounce 0.7s ease 3;
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

@keyframes album-bounce {
  40% { transform: translateY(-5px) scale(1.06); }
}

/* ---------------- Album mở ra ---------------- */
.album-zoom {
  position: absolute;
  inset: 0;
  z-index: 56;
  container-type: size;
  display: grid;
  place-items: center;
  padding: 8px;
}

.album-zoom[hidden],
.album-light[hidden],
.album-drop[hidden],
.album-sheet[hidden] {
  display: none;
}

.album-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.album-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 14px;
  border-radius: 999px;
  background: rgba(22, 24, 38, 0.86);
  color: #ffffff;
  font: 600 13px/1.2 "Segoe UI", system-ui, sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.album-sub {
  opacity: 0.7;
  font-weight: 400;
}

.album-btn {
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font: 600 12.5px/1.2 "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
}

.album-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.26);
}

.album-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.album-btn.primary {
  background: #ec4899;
}

.album-btn.primary:hover:not(:disabled) {
  background: #db2777;
}

.album-btn.danger {
  background: rgba(239, 68, 68, 0.85);
}

.album-btn.danger:hover:not(:disabled) {
  background: #dc2626;
}

.album-foot {
  display: flex;
  gap: 14px;
  align-items: center;
  color: #ffffff;
  font: 12px/1.3 "Segoe UI", system-ui, sans-serif;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.album-pageno {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.album-hint {
  opacity: 0.85;
}

@container (max-width: 700px) {
  .album-hint {
    display: none;
  }

  .album-head {
    padding: 3px 4px 3px 10px;
    font-size: 12px;
  }
}

/* Cuốn sách: bìa da hồng, hai trang giấy kem, gáy giữa */
.album-book {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 10px;
  border-radius: 12px;
  background: linear-gradient(135deg, #e5738f, #c9587a);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.5), inset 0 0 0 2px rgba(255, 255, 255, 0.18);
  perspective: 1800px;
  box-sizing: border-box;
}

.album-page {
  position: relative;
  container-type: size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  gap: 4px;
  min-width: 0;
  min-height: 0;
  padding: 10px 14px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.6), transparent 55%),
    repeating-linear-gradient(0deg, rgba(160, 120, 80, 0.035) 0 2px, transparent 2px 5px),
    #fbf5ea;
  box-sizing: border-box;
}

.album-page.l {
  border-radius: 6px 2px 2px 6px;
  box-shadow: inset -18px 0 22px -14px rgba(90, 50, 20, 0.35);
}

.album-page.r {
  border-radius: 2px 6px 6px 2px;
  box-shadow: inset 18px 0 22px -14px rgba(90, 50, 20, 0.35);
}

.album-spine {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 50%;
  width: 4px;
  margin-left: -2px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(90, 40, 30, 0.35), rgba(255, 255, 255, 0.4), rgba(90, 40, 30, 0.35));
  pointer-events: none;
}

.ap-no {
  position: absolute;
  bottom: 6px;
  color: rgba(90, 60, 40, 0.45);
  font: 11px/1 "Segoe UI", system-ui, sans-serif;
}

.album-page.l .ap-no { left: 12px; }
.album-page.r .ap-no { right: 12px; }

/* Trang đầu */
.ap-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  color: #7a4a5a;
  text-align: center;
}

.ap-title-deco {
  font-size: 15px;
  letter-spacing: 2px;
}

.ap-title-main {
  font: 700 clamp(14px, 11cqw, 34px)/1.1 "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  color: #c2466e;
}

.ap-title-names {
  font: 600 clamp(11px, 6.5cqw, 20px)/1.3 "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  overflow-wrap: anywhere;
}

/* Trang nhỏ (cửa sổ hẹp): bỏ bớt hoa lá, chữ gọn lại */
@container (max-height: 260px) {
  .ap-title {
    gap: 4px;
  }

  .ap-title-deco,
  .ap-title-heart {
    display: none;
  }

  .ap-title-sub {
    font-size: 10.5px;
  }

  .ap-add small {
    display: none;
  }
}

.ap-title-sub {
  max-width: 90%;
  font: 12.5px/1.4 "Segoe UI", system-ui, sans-serif;
  opacity: 0.8;
}

.ap-title-heart {
  color: #ff6f91;
  font-size: 26px;
  animation: ap-beat 1.6s ease-in-out infinite;
}

@keyframes ap-beat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.18); }
  30% { transform: scale(1); }
}

/* Ô "dán ảnh" */
.ap-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 82%;
  height: 72%;
  border: 2.5px dashed rgba(236, 72, 153, 0.45);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
  color: #b0416a;
  font: 600 14px/1.3 "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ap-add:hover:not(.full) {
  border-color: #ec4899;
  background: rgba(255, 228, 240, 0.8);
}

.ap-add small {
  max-width: 85%;
  font-weight: 400;
  font-size: 11.5px;
  opacity: 0.75;
}

.ap-add-plus {
  font-size: 34px;
  line-height: 1;
}

.ap-add.full {
  cursor: default;
}

/* Một tấm ảnh dán: viền trắng kiểu ảnh lấy liền, băng dính giấy ở hai góc, chú thích viết tay */
.ap-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  padding: 7px 7px 0;
  border: 0;
  background: #ffffff;
  box-shadow: 0 3px 10px rgba(60, 30, 10, 0.22), 0 1px 2px rgba(60, 30, 10, 0.18);
  transform: translateX(var(--slot-shift, 0)) rotate(var(--rot, 0deg));
  cursor: zoom-in;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ap-card:hover {
  z-index: 2;
  transform: translateX(var(--slot-shift, 0)) rotate(0deg) scale(1.03);
  box-shadow: 0 10px 24px rgba(60, 30, 10, 0.3);
}

.ap-card::before,
.ap-card::after {
  content: "";
  position: absolute;
  top: -8px;
  width: 42px;
  height: 16px;
  background: var(--tape, #ffd6e0);
  opacity: 0.85;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.ap-card::before {
  left: -12px;
  transform: rotate(-32deg);
}

.ap-card::after {
  right: -12px;
  transform: rotate(32deg);
}

.ap-card.just-added {
  animation: ap-pop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes ap-pop {
  from { transform: translateX(var(--slot-shift, 0)) rotate(var(--rot, 0deg)) scale(0.6); opacity: 0; }
}

.ap-photo {
  position: relative;
  overflow: hidden;
  background: #efe7dc;
}

.ap-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ap-photo.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.6) 50%, transparent 80%) -100% 0 / 60% 100% no-repeat;
  animation: ap-shimmer 1.2s linear infinite;
}

@keyframes ap-shimmer {
  to { background-position: 250% 0; }
}

.ap-photo.broken::after {
  content: "🖼";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 22px;
  opacity: 0.5;
}

.ap-cap {
  display: -webkit-box;
  width: 0; /* không làm khung ảnh rộng ra theo chú thích dài */
  min-width: 100%;
  min-height: 1.3em;
  margin: 5px 0 1px;
  overflow: hidden;
  color: #4a3a44;
  font: 13px/1.3 "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  text-align: center;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ap-date {
  align-self: flex-end;
  margin: 0 -2px 4px 0;
  color: #c2466e;
  font: 600 10.5px/1 "Segoe UI", system-ui, sans-serif;
  opacity: 0.75;
}

/* Tờ giấy lật qua gáy sách */
.album-sheet {
  position: absolute;
  top: 10px;
  bottom: 10px;
  width: calc(50% - 10px);
  background: #f6eedf;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  backface-visibility: visible;
  z-index: 3;
}

.album-sheet.turn-next {
  left: 50%;
  transform-origin: 0 50%;
  border-radius: 2px 6px 6px 2px;
}

.album-sheet.turn-prev {
  right: 50%;
  transform-origin: 100% 50%;
  border-radius: 6px 2px 2px 6px;
}

.album-sheet.turn-next.go {
  animation: sheet-next 0.5s cubic-bezier(0.4, 0.1, 0.3, 1) forwards;
}

.album-sheet.turn-prev.go {
  animation: sheet-prev 0.5s cubic-bezier(0.4, 0.1, 0.3, 1) forwards;
}

@keyframes sheet-next {
  from { transform: rotateY(0deg); filter: brightness(1); }
  50% { filter: brightness(0.82); }
  to { transform: rotateY(-180deg); filter: brightness(1); opacity: 0.4; }
}

@keyframes sheet-prev {
  from { transform: rotateY(0deg); filter: brightness(1); }
  50% { filter: brightness(0.82); }
  to { transform: rotateY(180deg); filter: brightness(1); opacity: 0.4; }
}

/* Nút lật trang hai bên sách */
.album-nav {
  position: absolute;
  top: 50%;
  z-index: 4;
  width: 34px;
  height: 34px;
  padding: 0;
  margin-top: -17px;
  border-radius: 50%;
  background: rgba(22, 24, 38, 0.78);
  font: 700 22px/32px "Segoe UI", system-ui, sans-serif;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.album-nav.prev { left: -40px; }
.album-nav.next { right: -40px; }

.album-nav:disabled {
  opacity: 0.25;
}

/* Kéo thả ảnh vào */
.album-drop {
  position: absolute;
  inset: 8px;
  z-index: 6;
  display: grid;
  place-items: center;
  border: 3px dashed #ffffff;
  border-radius: 18px;
  background: rgba(236, 72, 153, 0.35);
  color: #ffffff;
  font: 700 18px/1.3 "Segoe UI", system-ui, sans-serif;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* ---------------- Xem to / sửa một ảnh ---------------- */
.album-light {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 10px 52px;
  background: rgba(12, 12, 20, 0.72);
}

.al-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
}

.al-img {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 10px 10px 12px;
  background: #ffffff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.al-img img {
  display: block;
  max-width: min(78vw, calc(var(--stage-w, 100vw) - 130px));
  max-height: calc(var(--stage-h, 100vh) - 150px);
  object-fit: contain;
}

.al-box.loading .al-img {
  min-width: 240px;
  min-height: 160px;
}

.al-meta {
  color: #ffffff;
  font: 12px/1.3 "Segoe UI", system-ui, sans-serif;
  opacity: 0.85;
  text-align: center;
}

.al-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(22, 24, 38, 0.86);
}

.al-cap,
.al-date {
  height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font: 13px/1 "Segoe UI", system-ui, sans-serif;
  box-sizing: border-box;
}

.al-cap {
  width: min(360px, 60vw);
}

.al-date {
  color-scheme: dark;
}

.al-cap:focus,
.al-date:focus {
  border-color: #ec4899;
  outline: none;
}

.al-form [hidden] {
  display: none;
}

.al-nav,
.al-close {
  position: absolute;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  font: 700 24px/38px "Segoe UI", system-ui, sans-serif;
}

.al-nav {
  top: 50%;
  margin-top: -20px;
}

.al-nav.prev { left: 6px; }
.al-nav.next { right: 6px; }

.al-close {
  top: 8px;
  right: 8px;
  font-size: 16px;
}

.al-nav[hidden] {
  display: none;
}

.album-light.compose .al-meta {
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .ap-title-heart,
  .ap-card.just-added,
  .furn-album.pulse .album-book-art {
    animation: none;
  }
}
