/* ==========================================================================
   Âm Thanh Cũ - Rainy Mood Style Video Background Theme (Optimized Zero Lag)
   ========================================================================== */

:root {
  --bg-pure: #000000;
  --bg-surface: rgba(14, 16, 22, 0.88);
  --bg-card: rgba(24, 27, 36, 0.88);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.22);
  
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  
  --accent-gold: #fbbf24;
  --accent-gold-glow: rgba(251, 191, 36, 0.35);
  
  --font-base: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-cu: 'Charmonman', 'Charm', cursive;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-base);
  background-color: var(--bg-pure);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Rainy Mood Style Canvas Backdrop
   ========================================================================== */

.rain-backdrop {
  position: fixed;
  inset: -15px;
  width: calc(100vw + 30px);
  height: calc(100vh + 30px);
  z-index: 0;
  pointer-events: none;
  background-image: url('bg-hoan-kiem.jpg');
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: blur(8px) brightness(0.55);
}

.rain-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  object-fit: cover;
  /* Không dùng CSS filter trên canvas WebGL để đạt hiệu năng 60FPS tối đa */
}

.rain-ambience {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(0, 0, 0, 0.38) 0%, rgba(0, 0, 0, 0.78) 100%);
}

/* ==========================================================================
   Header & Brand Logo
   ========================================================================== */

.app-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 12px;
  transform: translateZ(0);
}

.doc-header {
  justify-content: space-between;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 10px;
}

.logo-link {
  text-decoration: none;
  color: inherit;
  display: inline-block;
}

.logo-container {
  display: inline-flex;
  align-items: baseline;
  user-select: none;
  cursor: pointer;
  letter-spacing: -0.02em;
}

.logo-prefix {
  font-family: var(--font-base);
  font-size: 1.3rem;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  margin-right: 6px;
  opacity: 1;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.95);
}

.logo-accent {
  font-family: var(--font-cu);
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--accent-gold);
  line-height: 1;
  text-shadow: 
    0 0 25px rgba(251, 191, 36, 0.85),
    0 0 50px rgba(251, 191, 36, 0.4),
    0 2px 10px rgba(0, 0, 0, 0.95);
  transform: translateY(2px);
  display: inline-block;
}

.logo-period {
  font-family: var(--font-base);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-gold);
  margin-left: 2px;
  text-shadow: 0 0 18px rgba(251, 191, 36, 0.85);
}

.btn-back {
  font-size: 0.85rem;
  color: #a1a1aa;
  text-decoration: none;
  padding: 6px 14px;
  border: 1px solid #27272a;
  border-radius: var(--radius-full);
  transition: var(--transition);
  background: rgba(20, 22, 28, 0.85);
}

.btn-back:hover {
  background: #18181b;
  border-color: #3f3f46;
  color: #ffffff;
}

/* ==========================================================================
   Main Content & Groups
   ========================================================================== */

.main-content {
  position: relative;
  z-index: 10;
  flex: 1;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 6px 18px 40px;
  transform: translateZ(0);
}

.sound-groups {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.group-section {
  position: relative;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.group-section:hover {
  z-index: 20;
}

.group-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95);
  margin-bottom: 12px;
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 10px;
}

/* ==========================================================================
   Buttons with Floating Popover Volume Control (Jumps Up on Hover)
   ========================================================================== */

.sound-btn {
  background: rgba(18, 22, 30, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 10px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  outline: none;
  user-select: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  height: 100%;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
}

.sound-btn:hover {
  background: rgba(36, 44, 60, 0.95);
  border-color: rgba(255, 255, 255, 0.45);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.7);
  z-index: 50; /* Elevates above adjacent buttons */
}

.sound-btn:active {
  transform: translateY(0);
}

/* ACTIVE STATE */
.sound-btn.active {
  background: rgba(251, 191, 36, 0.22);
  border-color: var(--accent-gold);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 
    0 0 16px rgba(251, 191, 36, 0.38),
    inset 0 0 8px rgba(251, 191, 36, 0.18);
}

.sound-btn.active::before {
  content: '';
  position: absolute;
  top: 5px;
  right: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-gold);
  box-shadow: 0 0 6px var(--accent-gold);
}

.sound-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  line-height: 1.25;
  pointer-events: none;
  white-space: normal;
  text-align: center;
  word-break: keep-all;
  overflow-wrap: break-word;
  hyphens: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* Floating Popover Jumping Up Above Button */
.sound-vol-popover {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%) translateY(6px) scale(0.95);
  background: #141722;
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: var(--radius-full);
  padding: 5px 11px;
  display: flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.7), 0 0 12px rgba(251, 191, 36, 0.18);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.18s ease;
  z-index: 100;
  white-space: nowrap;
}

/* Pointer arrow pointing down to button */
.sound-vol-popover::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px 5px 0 5px;
  border-style: solid;
  border-color: #141722 transparent transparent transparent;
}

/* Invisible bridge so moving cursor between button and popover doesn't flicker */
.sound-vol-popover::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 11px;
}

/* Jump up on hover */
.sound-btn:hover .sound-vol-popover {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateX(-50%) translateY(0) scale(1);
}

.vol-icon {
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0.85;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.vol-icon:hover {
  opacity: 1;
  transform: scale(1.15);
}

.sound-vol-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent-gold);
  min-width: 28px;
  text-align: right;
  letter-spacing: -0.01em;
}

/* Sleek Slider */
.sound-vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 75px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, #fbbf24 80%, rgba(255, 255, 255, 0.2) 80%);
  outline: none;
  cursor: pointer;
  display: block;
}

.sound-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fbbf24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.9);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.sound-vol-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

.sound-vol-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fbbf24;
  border: none;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.9);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.sound-vol-slider::-moz-range-thumb:hover {
  transform: scale(1.25);
}

/* ==========================================================================
   Document Article Pages (/dieu-khoan-su-dung, /chinh-sach-bao-mat, etc.)
   ========================================================================== */

.doc-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.65);
  margin-top: 10px;
}

.doc-title {
  font-size: 1.65rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.doc-date {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 28px;
}

.doc-content section {
  margin-bottom: 24px;
}

.doc-content h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fbbf24;
  margin-bottom: 10px;
}

.doc-content p {
  font-size: 0.9rem;
  color: #f4f4f5;
  line-height: 1.7;
  margin-bottom: 12px;
}

.doc-content ul {
  list-style: none;
  padding-left: 0;
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doc-content ul li {
  font-size: 0.9rem;
  color: #f4f4f5;
  line-height: 1.6;
  position: relative;
  padding-left: 18px;
}

.doc-content ul li::before {
  content: '•';
  color: #fbbf24;
  position: absolute;
  left: 4px;
  font-weight: bold;
}

.doc-content a {
  color: #fbbf24;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.app-footer {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 18px 36px;
  border-top: none;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
}

.footer-link {
  color: #ffffff;
  text-decoration: none;
  font-weight: 500;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  opacity: 0.9;
  transition: var(--transition);
}

.footer-link:hover,
.footer-link.is-active {
  color: var(--accent-gold);
  opacity: 1;
  text-decoration: underline;
}

.link-dot {
  color: rgba(255, 255, 255, 0.4);
}

.badge-author {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(18, 22, 30, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  color: #ffffff;
  text-decoration: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: var(--transition);
}

.badge-author:hover {
  border-color: var(--accent-gold);
  color: #ffffff;
}

.badge-author strong {
  color: var(--accent-gold);
}

/* ==========================================================================
   Pending Notice Modal (Giảng đường & Tiếng phố)
   ========================================================================== */

.notice-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.notice-modal.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.notice-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.notice-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: #141722;
  border: 1px solid rgba(251, 191, 36, 0.5);
  border-radius: 18px;
  padding: 28px 24px 24px;
  box-shadow: 
    0 24px 50px rgba(0, 0, 0, 0.8),
    0 0 25px rgba(251, 191, 36, 0.2);
  text-align: center;
  transform: scale(0.92) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.notice-modal.active .notice-card {
  transform: scale(1) translateY(0);
}

.notice-card.notice-shake {
  animation: noticePop 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes noticePop {
  0% { transform: scale(0.95); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.notice-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
}

.notice-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.notice-icon {
  font-size: 2.2rem;
  margin-bottom: 12px;
  line-height: 1;
}

.notice-message {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #f4f4f5;
  margin: 0 0 12px 0;
  font-weight: 400;
}

.notice-author {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent-gold);
  margin-bottom: 22px;
  letter-spacing: 0.02em;
}

.notice-btn {
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid var(--accent-gold);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 24px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.15s ease, box-shadow 0.18s ease;
}

.notice-btn:hover {
  background: var(--accent-gold);
  color: #0d0f14;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(251, 191, 36, 0.4);
}

.notice-btn:active {
  transform: translateY(0);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .btn-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
  }

  .app-footer {
    flex-direction: column;
    gap: 14px;
    align-items: center;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .btn-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  
  .group-section {
    padding: 10px 12px;
  }

  .sound-btn {
    min-height: 38px;
    font-size: 0.75rem;
    padding: 6px 6px;
  }
}
