/* ============================================================
   NĐH Reader — Reskin APP shell (trang chủ / đăng ký / /me / admin)
   Dựng lại các trang HIỆN CÓ theo design-system Quốc khánh. Tokens +
   base + .article-body + .festive ở reskin.css (nguồn sự thật) — file
   này KHÔNG khai lại biến. Tuân mục 6 (accent duy nhất = đỏ cờ; không
   gradient tím-chàm / glassmorphism / all-caps giãn chữ / #000).
   ============================================================ */

/* Bỏ nền lưới + quầng sáng gradient của giao diện cũ (mục 6). */
.bg-grid, .bg-glow { display: none !important; }

/* ---- Ảnh nền quốc kỳ (trang chủ / đăng ký / /me) ----
   Ảnh full-bleed 1920×1080 dùng `cover` phủ kín cả desktop lẫn mobile — không
   cần tile texture để lấp phần thừa nữa. `fixed` cho nền đứng yên khi cuộn. */
body {
  background-color: #E6D4C6;              /* dự phòng khi ảnh chưa tải — không trắng */
  background-image: url('/img/Anh-nen-quoc-ky.png');
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
}
[data-theme="dark"] body,
.theme-dark body {
  background-color: #0F0F11;
  background-image:
    linear-gradient(rgba(15,15,17,.88), rgba(15,15,17,.93)),
    url('/img/Anh-nen-quoc-ky.png');
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
  background-size: cover, cover;
  background-attachment: fixed;
}

/* ---- Màn chờ (loader) — cùng ảnh nền cover để chuyển tiếp liền mạch ---- */
#page-loader {
  position: fixed; inset: 0; z-index: 9999;
  background-color: #E6D4C6;
  background-image: url('/img/Anh-nen-quoc-ky.png');
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  display: flex; align-items: flex-end; justify-content: center;
  transition: opacity .55s ease;
}
#page-loader.hidden { opacity: 0; pointer-events: none; }
#page-loader .pl-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-bottom: 7vh; }
#page-loader .pl-spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--red-wash); border-top-color: var(--flag-red);
  animation: pl-spin .8s linear infinite;
}
@keyframes pl-spin { to { transform: rotate(360deg); } }
#page-loader .pl-text { font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); }
@media (prefers-reduced-motion: reduce) { #page-loader .pl-spinner { animation: none; } }

/* ---- Shell ---- */
.app-container { min-height: 100vh; display: flex; flex-direction: column; }
.main-content {
  flex: 1; width: 100%; max-width: 30rem;
  margin: 0 auto; padding: clamp(1rem, 4vw, 2rem);
  display: flex; flex-direction: column; gap: var(--s4); justify-content: center;
}

/* ---- Banner thông báo đầu trang (nội dung admin sửa; chạy chữ nếu dài) ----
   Ẩn mặc định; banner.js thêm .show khi admin bật + có nội dung. */
.festive-banner {
  display: none; align-items: center; gap: .5rem;
  background: var(--flag-red); color: #FFF7E6;
  font-size: var(--text-sm); font-weight: 500; letter-spacing: .01em;
  padding: .55rem 1rem;
}
.festive-banner.show { display: flex; }
.festive-banner .bn-star { width: 14px; height: 14px; flex: none; }
.festive-banner .bn-star path { fill: var(--gold); }
/* Khung cắt chữ: chiếm hết chỗ còn lại cạnh ngôi sao, canh giữa khi chữ ngắn. */
.festive-banner .bn-viewport {
  flex: 1 1 auto; min-width: 0; overflow: hidden;
  display: flex; justify-content: center;
}
.festive-banner .bn-track { display: flex; align-items: center; white-space: nowrap; }
.festive-banner .bn-text { display: inline-block; }
/* Chạy chữ: chữ trải từ trái, cuộn -50% (đúng một bản nhân đôi) → liền mạch. */
.festive-banner.marquee .bn-viewport { justify-content: flex-start; }
.festive-banner.marquee .bn-track { animation: bn-scroll linear infinite; }
.festive-banner.marquee .bn-text { padding-right: 3rem; }
.festive-banner.marquee:hover .bn-track { animation-play-state: paused; }
@keyframes bn-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .festive-banner.marquee .bn-track { animation: none; white-space: normal; }
  .festive-banner.marquee .bn-viewport { justify-content: center; }
  .festive-banner.marquee .bn-text { padding-right: 0; }
  .festive-banner.marquee .bn-text.clone { display: none; }
}

/* ---- Header ---- */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  width: 100%; max-width: 30rem; margin: 0 auto;
  padding: var(--s5) clamp(1rem, 4vw, 2rem) 0;
}
.logo { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; }
.logo-icon { width: 40px; height: 40px; flex: none; }
.logo-icon .mark-bg { fill: var(--flag-red); }
.logo-icon .star-gold { fill: #FFF7E6; }
.festive .logo-icon .star-gold { fill: var(--gold); }
/* Header nằm trực tiếp trên ảnh nền cờ (đỏ/vàng), không có thẻ nền phía sau →
   chữ kem + đổ bóng tối để đọc rõ trên mọi vùng ảnh, cả theme sáng lẫn tối. */
.logo-text h1 {
  font-family: var(--font-ui); font-weight: 800; font-size: var(--text-base);
  letter-spacing: -.02em; margin: 0; color: #FFF7E6;
  text-shadow: 0 1px 3px rgba(0,0,0,.55), 0 0 2px rgba(0,0,0,.4);
}
.logo-subtitle {
  font-size: .72rem; color: rgba(255,247,230,.92);
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.header-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: var(--text-xs); font-weight: 600; color: var(--ink-2);
  background: var(--paper); border: 1px solid var(--line); border-radius: 100px;
  padding: .3rem .7rem; text-decoration: none;
}
.header-badge:hover { text-decoration: none; border-color: var(--line-2); }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--flag-red); }

/* ---- Card ---- */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s6); box-shadow: var(--shadow-sm);
}
.card-header { text-align: center; margin-bottom: var(--s5); }
.card-icon {
  width: 48px; height: 48px; margin: 0 auto var(--s3);
  display: grid; place-items: center; font-size: 24px;
  background: var(--red-wash); border-radius: var(--r); color: var(--red-ink);
}
.card-header h2 { font-family: var(--font-ui); font-weight: 800; font-size: var(--text-xl); letter-spacing: -.01em; color: var(--ink); margin: 0; }
.accent-bar { width: 40px; height: 3px; background: var(--flag-red); border-radius: 2px; margin: var(--s3) auto 0; }
.accent-bar.left { margin-left: 0; }
.card-desc { font-family: var(--font-read); font-size: var(--text-base); color: var(--ink-2); margin: var(--s3) 0 0; line-height: var(--lh-snug); }
.login-card { padding-top: var(--s6); }

/* ---- Form ---- */
.form-group { margin-bottom: var(--s4); }
.form-group label { display: block; font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); margin-bottom: var(--s2); }
.form-group input[type="text"],
.form-group input[type="password"] {
  width: 100%; font-family: var(--font-ui); font-size: var(--text-base); color: var(--ink);
  background: var(--shell); border: 1px solid var(--line-2); border-radius: var(--r);
  padding: .7rem .85rem; outline: none;
}
.form-group input::placeholder { color: var(--ink-3); }
.form-group input:focus { border-color: var(--flag-red); box-shadow: 0 0 0 3px var(--red-wash); }
.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 2.6rem; }
.toggle-password {
  position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--ink-3);
  display: grid; place-items: center; padding: .3rem; border-radius: var(--r-sm);
}
.toggle-password:hover { color: var(--ink-2); }
.form-options { margin-bottom: var(--s4); }
.option-hint { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--ink-3); line-height: 1.5; }

/* ---- Buttons ---- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: var(--font-ui); font-size: var(--text-base); font-weight: 700;
  background: var(--flag-red); color: #FFF7E6; border: none; border-radius: var(--r);
  padding: .75rem 1.1rem; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-icon { font-weight: 800; }
.login-card .btn-primary { width: 100%; }
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 600;
  background: var(--paper); color: var(--ink); border: 1px solid var(--line-2);
  border-radius: var(--r); padding: .6rem .9rem; cursor: pointer;
}
.btn-secondary:hover { border-color: var(--ink-3); }

/* ---- Error (index dùng style.display; register dùng .show) ---- */
.error-message {
  display: none; align-items: center; gap: .5rem; margin-top: var(--s3);
  font-size: var(--text-sm); color: var(--red-ink);
  background: var(--red-wash); border: 1px solid color-mix(in srgb, var(--flag-red) 25%, transparent);
  border-radius: var(--r); padding: .6rem .8rem;
}
.error-message.show { display: flex; }

/* ---- Register CTA ---- */
.register-cta { text-align: center; margin-top: var(--s4); font-size: var(--text-sm); color: var(--ink-2); }
.register-cta a { font-weight: 700; }

/* ---- Đăng ký (register.html) ---- */
.register-card { padding-top: var(--s6); }
.ref-note {
  display: flex; align-items: center; gap: .5rem; margin-bottom: var(--s4);
  font-size: var(--text-sm); color: var(--red-ink);
  background: var(--red-wash); border: 1px solid color-mix(in srgb, var(--flag-red) 20%, transparent);
  border-radius: var(--r); padding: .6rem .8rem;
}
.form-group select {
  width: 100%; font-family: var(--font-ui); font-size: var(--text-base); color: var(--ink);
  background: var(--shell); border: 1px solid var(--line-2); border-radius: var(--r);
  padding: .7rem .85rem; outline: none; cursor: pointer;
}
.form-group select:focus { border-color: var(--flag-red); box-shadow: 0 0 0 3px var(--red-wash); }
.form-group select.placeholder-active { color: var(--ink-3); }
.field-error { display: none; margin-top: var(--s2); font-size: var(--text-xs); color: var(--red-ink); }
.form-group.has-error .field-error { display: block; }
.form-group.has-error input,
.form-group.has-error select { border-color: var(--flag-red); }
.btn-primary.loading { opacity: .7; pointer-events: none; }
.login-link { text-align: center; margin-top: var(--s4); font-size: var(--text-sm); color: var(--ink-2); }
.login-link a { font-weight: 700; }
.success-message { display: none; text-align: center; padding: var(--s5) var(--s2); }
.success-message.show { display: block; }
.success-icon {
  width: 56px; height: 56px; margin: 0 auto var(--s3); display: grid; place-items: center;
  font-size: 28px; background: var(--red-wash); color: var(--red-ink); border-radius: 50%;
}
.success-title { font-family: var(--font-ui); font-weight: 800; font-size: var(--text-lg); color: var(--ink); margin: 0 0 var(--s2); }
.success-desc { font-family: var(--font-read); font-size: var(--text-base); color: var(--ink-2); line-height: var(--lh-snug); margin: 0; }
.success-link { display: inline-block; margin-top: var(--s4); font-weight: 700; }

/* ---- Social proof / activity ticker (đổ bằng JS) ---- */
.social-proof {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px;
  padding: .55rem .9rem; font-size: var(--text-sm); color: var(--ink-2);
  background: var(--paper); border: 1px solid var(--line); border-radius: 100px;
}
.sp-item b { color: var(--ink); }
.sp-dot { color: var(--ink-3); }
.activity-ticker {
  display: flex; align-items: center; gap: var(--s2);
  height: 40px; padding: 0 var(--s4); overflow: hidden;
  background: var(--paper); border: 1px solid var(--line); border-radius: 100px;
}
.act-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--flag-red); animation: act-pulse 2s ease-in-out infinite; }
@keyframes act-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.act-line { display: flex; align-items: baseline; gap: 7px; min-width: 0; animation: act-in 260ms ease; }
.act-line.leaving { animation: act-out 220ms ease forwards; }
@keyframes act-in  { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes act-out { to { opacity: 0; transform: translateY(-6px); } }
.act-ico { flex: none; font-size: var(--text-sm); }
.act-text { font-size: var(--text-sm); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-ago { flex: none; font-size: var(--text-xs); color: var(--ink-3); white-space: nowrap; }
.act-line[data-kind="upgrade"] .act-text { color: var(--red-ink); font-weight: 700; }


/* ---- Footer ---- */
.app-footer { text-align: center; padding: var(--s6) var(--s4) var(--s5); color: var(--ink-3); font-size: var(--text-xs); }
.disclaimer { color: var(--red-ink); font-weight: 700; margin: 0; }
.disclaimer-fine { color: var(--red-ink); font-size: 9px; font-weight: 700; opacity: .8; margin: 2px 0 0; }
.admin-link { color: var(--ink-3); font-size: 11px; }

/* ---- Nút đổi sáng/tối (theme.js tạo, đè lại cho hợp reskin) ---- */
#theme-toggle {
  background: var(--paper) !important;
  border: 1px solid var(--line-2) !important;
  box-shadow: var(--shadow) !important;
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
