/*
 * CSS nền đi kèm core.js: chỉ những thứ chức năng cần có để chạy đúng.
 * Màu sắc lấy từ biến (có giá trị dự phòng) để giao diện chính đổi được:
 *   --lb-bg, --lb-fg, --toast-bg, --toast-fg, --heart-color
 */

/* thuộc tính hidden phải thắng mọi display khác */
[hidden] {
  display: none !important;
}

/* chỉ dành cho trình đọc màn hình */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ── Màn hình mở thiệp ── */
html.no-js [data-gate],
html.gate-open [data-gate] {
  display: none !important;
}
html.gate-on,
html.gate-on body {
  overflow: hidden;
  height: 100%;
}
html.gate-on body {
  overscroll-behavior: none;
}

/* ── Hộp xem ảnh ── */
html.lb-open,
html.lb-open body {
  overflow: hidden;
}
.lb {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--lb-bg, rgba(20, 8, 9, 0.94));
  color: var(--lb-fg, #fff);
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y pinch-zoom;
  animation: lb-in 0.22s ease both;
}
@keyframes lb-in {
  from {
    opacity: 0;
  }
}
.lb__stage {
  margin: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 8px 52px;
  box-sizing: border-box;
}
.lb__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  transition: opacity 0.2s ease;
  -webkit-user-select: none;
  user-select: none;
}
.lb.is-loading .lb__img {
  opacity: 0.25;
}
.lb.is-loading .lb__stage::after {
  content: '';
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: currentColor;
  animation: lb-spin 0.8s linear infinite;
}
@keyframes lb-spin {
  to {
    transform: rotate(360deg);
  }
}
.lb__btn {
  position: absolute;
  z-index: 2;
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: background 0.2s ease;
}
.lb__btn:hover,
.lb__btn:focus-visible {
  background: rgba(255, 255, 255, 0.26);
}
.lb__btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
.lb__close {
  top: calc(8px + env(safe-area-inset-top, 0px));
  right: 10px;
}
.lb__prev {
  left: 8px;
  top: 50%;
  margin-top: -22px;
}
.lb__next {
  right: 8px;
  top: 50%;
  margin-top: -22px;
}
.lb__count {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  margin: 0;
  text-align: center;
  font: 500 13px/1 system-ui, sans-serif;
  letter-spacing: 0.14em;
  opacity: 0.8;
}
@media (hover: none) and (max-width: 600px) {
  /* trên điện thoại vuốt để chuyển ảnh, nút mũi tên thu nhỏ cho đỡ che ảnh */
  .lb__prev,
  .lb__next {
    width: 38px;
    height: 38px;
    margin-top: -19px;
    background: rgba(255, 255, 255, 0.08);
  }
}

/* ── Thông báo nhỏ ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  z-index: 1100;
  max-width: min(88vw, 360px);
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--toast-bg, rgba(40, 14, 16, 0.92));
  color: var(--toast-fg, #fff);
  font: 500 14px/1.35 system-ui, sans-serif;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 10px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
  pointer-events: none;
}
.toast.is-on {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s;
}

/* ── Tim bay khi thả tim ── */
.heart-float {
  position: fixed;
  z-index: 1050;
  margin: -0.5em 0 0 -0.5em;
  font-size: var(--size, 22px);
  line-height: 1;
  color: var(--heart-color, #e0455e);
  pointer-events: none;
  animation: heart-float 2.2s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
  will-change: transform, opacity;
}
@keyframes heart-float {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.4) rotate(0deg);
  }
  15% {
    opacity: 1;
    transform: translate(calc(var(--dx, 0px) * 0.15), -24px) scale(1.15) rotate(calc(var(--rot, 0deg) * 0.3));
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx, 0px), -190px) scale(0.9) rotate(var(--rot, 0deg));
  }
}

/* ── Cánh hoa rơi ── */
canvas[data-petals] {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 40;
  pointer-events: none;
}
html.gate-on canvas[data-petals] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .lb,
  .heart-float {
    animation: none;
  }
  canvas[data-petals] {
    display: none;
  }
}
