/* ============================================================
   HOME.CSS — Score Input, School Cards, Bát Tự, Sections
   ============================================================ */

/* ══════════════════════════════════════════
   SECTION LABELS (Bước 1/2/3)
   ══════════════════════════════════════════ */
.home-section {
  padding: var(--sp-12) 0;
  scroll-margin-top: calc(var(--navbar-h) + 60px);
}

.step-section-header {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--border);
}

.step-badge {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-xl);
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.step-info .step-number-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--primary-light);
  margin-bottom: 2px;
}
.step-info h2 {
  font-size: clamp(var(--fs-lg), 2.5vw, var(--fs-2xl));
  font-weight: 800;
  color: var(--text-primary);
}
.step-info p {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: 4px;
}

/* ══════════════════════════════════════════
   SCORE INPUT GRID (Bước 1)
   ══════════════════════════════════════════ */
.score-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

@media (min-width: 480px) {
  .score-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
  .score-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1024px) {
  .score-grid { grid-template-columns: repeat(5, 1fr); }
}

.score-item {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  transition: var(--transition);
  position: relative;
}
.score-item:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.score-item:has(input:focus) {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,60,228,0.15);
  background: rgba(108,60,228,0.04);
}
.score-item:has(input.valid) {
  border-color: var(--success);
}
.score-item:has(input.invalid) {
  border-color: var(--danger);
}

.score-item-icon {
  font-size: 20px;
  height: 28px;
  display: flex;
  align-items: center;
}

.score-item label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-align: center;
}
.score-item input {
  width: 100%;
  padding: 8px 6px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: clamp(16px, 1.5vw, var(--fs-xl));
  font-weight: 700;
  font-family: var(--font-mono);
  text-align: center;
  transition: var(--transition-fast);
  -moz-appearance: textfield;
}
.score-item input::-webkit-outer-spin-button,
.score-item input::-webkit-inner-spin-button { -webkit-appearance: none; }
.score-item input:focus {
  outline: none;
  border-color: var(--primary);
}
.score-item input.valid   { border-color: var(--success); color: var(--success); }
.score-item input.invalid { border-color: var(--danger); color: var(--danger); }

/* Khối grid */
.khoi-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.khoi-item {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  min-width: 100px;
  text-align: center;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.khoi-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: var(--transition);
}
.khoi-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}
.khoi-item:hover::before { opacity: 1; }

.khoi-name {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--sp-1);
}
.khoi-score {
  font-size: var(--fs-2xl);
  font-weight: 800;
  font-family: var(--font-mono);
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.khoi-subjects {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ══════════════════════════════════════════
   SCHOOL CARDS (Bước 2)
   ══════════════════════════════════════════ */
.schools-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-4);
}
@media (min-width: 640px) {
  .schools-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .schools-grid { grid-template-columns: repeat(3, 1fr); }
}

.school-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.school-card:hover {
  border-color: rgba(108,60,228,0.3);
  box-shadow: var(--shadow-glow);
  transform: translateY(-3px);
}
.school-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: var(--transition);
}
.school-card:hover::before { opacity: 1; }

.school-card-header {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
}
.school-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  background: rgba(108,60,228,0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.school-icon.kim   { background: var(--ngh-kim-bg); }
.school-icon.moc   { background: var(--ngh-moc-bg); }
.school-icon.thuy  { background: var(--ngh-thuy-bg); }
.school-icon.hoa   { background: var(--ngh-hoa-bg); }
.school-icon.tho   { background: var(--ngh-tho-bg); }

.school-info { flex: 1; min-width: 0; }

.school-name {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.school-truong {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.school-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.school-score {
  font-size: var(--fs-xl);
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--primary-light);
}
.school-score .score-label {
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--text-muted);
  font-family: var(--font-main);
}

.school-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.school-card-footer {
  display: flex;
  gap: var(--sp-2);
  margin-top: auto;
}
.school-card-footer .btn {
  flex: 1;
  font-size: var(--fs-xs);
  padding: 8px 12px;
  min-height: 36px;
}

/* Fit badge */
.fit-badge {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(0,212,170,0.15);
  border: 1px solid rgba(0,212,170,0.35);
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* Result meta row */
.results-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.results-count {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
}
.results-count strong { color: var(--text-primary); }

/* ══════════════════════════════════════════
   BÁT TỰ SECTION (Bước 3)
   ══════════════════════════════════════════ */
.battu-display {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
  margin: var(--sp-6) 0;
}

@media (max-width: 640px) {
  .battu-display { grid-template-columns: repeat(2, 1fr); }
}

.battu-column {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
  text-align: center;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.battu-column::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(108,60,228,0.12) 0%, transparent 70%);
  opacity: 0;
  transition: var(--transition);
}
.battu-column:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
  transform: translateY(-4px);
}
.battu-column:hover::before { opacity: 1; }

.battu-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: var(--sp-3);
  position: relative;
}
.battu-can {
  font-size: clamp(var(--fs-2xl), 4vw, 44px);
  font-weight: 800;
  color: var(--primary-light);
  margin-bottom: var(--sp-1);
  text-shadow: 0 0 20px rgba(108,60,228,0.4);
  position: relative;
  font-family: 'Noto Serif SC', serif;
}
.battu-chi {
  font-size: clamp(var(--fs-xl), 3vw, var(--fs-2xl));
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
  position: relative;
  font-family: 'Noto Serif SC', serif;
}
.battu-phonam {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-bottom: 2px;
  position: relative;
}
.battu-napam {
  font-size: var(--fs-xs);
  color: var(--secondary);
  position: relative;
}

/* Ngũ Hành chart row */
.nguhanh-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4);
  margin: var(--sp-5) 0;
}
@media (min-width: 768px) {
  .nguhanh-row { grid-template-columns: auto 1fr 1fr; }
}

.nguhanh-chart-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
}

.nguhanh-bars {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: 100%;
}
.nguhanh-bar-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.nguhanh-bar-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  width: 32px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.nguhanh-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.nguhanh-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.nguhanh-bar-count {
  font-size: var(--fs-xs);
  font-weight: 700;
  width: 20px;
  text-align: right;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Dung Than card */
.dungtan-card {
  background: linear-gradient(135deg, rgba(108,60,228,0.12), rgba(0,212,170,0.06));
  border: 1.5px solid rgba(108,60,228,0.2);
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
  text-align: center;
}
.dungtan-icon {
  font-size: 36px;
  margin-bottom: var(--sp-2);
}
.dungtan-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--sp-1);
}
.dungtan-value {
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--secondary);
}

/* Đại Vận Timeline */
.daivan-timeline {
  display: flex;
  gap: var(--sp-3);
  overflow-x: auto;
  padding-bottom: var(--sp-2);
  scrollbar-width: thin;
  scrollbar-color: rgba(108,60,228,0.3) transparent;
}
.daivan-timeline::-webkit-scrollbar { height: 4px; }
.daivan-timeline::-webkit-scrollbar-track { background: transparent; }
.daivan-timeline::-webkit-scrollbar-thumb {
  background: rgba(108,60,228,0.3);
  border-radius: 2px;
}

.daivan-item {
  flex-shrink: 0;
  min-width: 100px;
  max-width: 130px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
}
.daivan-item:hover, .daivan-item.current {
  border-color: var(--primary);
  background: rgba(108,60,228,0.08);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}
.daivan-age {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-bottom: 4px;
}
.daivan-can {
  font-size: var(--fs-xl);
  font-weight: 800;
  color: var(--primary-light);
  font-family: 'Noto Serif SC', serif;
}
.daivan-chi {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Noto Serif SC', serif;
}
.daivan-nguhanh {
  font-size: var(--fs-xs);
  margin-top: 4px;
}

/* ══════════════════════════════════════════
   STUDENT GROUPS
   ══════════════════════════════════════════ */
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-3);
}

.group-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition);
}
.group-card:hover {
  border-color: #1877F2;
  background: rgba(24,119,242,0.06);
  transform: translateY(-2px);
  color: var(--text-primary);
}
.group-card-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(24,119,242,0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: #1877F2;
  flex-shrink: 0;
}
.group-card-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ══════════════════════════════════════════
   COURSES
   ══════════════════════════════════════════ */
.course-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-4);
}

.course-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
}
.course-card:hover {
  border-color: rgba(108,60,228,0.3);
  box-shadow: var(--shadow-glow);
  transform: translateY(-3px);
}

.course-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg-card);
  position: relative;
  overflow: hidden;
}
.course-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.course-card:hover .course-thumb img { transform: scale(1.05); }

.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  opacity: 0;
  transition: var(--transition);
}
.course-card:hover .play-overlay { opacity: 1; }
.play-btn-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: var(--primary);
}

.course-body {
  padding: var(--sp-4);
}
.course-meta-row {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.course-title {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: var(--sp-2);
}
.course-instructor {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* ══════════════════════════════════════════
   ARTICLES (Home section)
   ══════════════════════════════════════════ */
.home-articles-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-4);
}
@media (min-width: 768px) {
  .home-articles-grid {
    grid-template-columns: 1.6fr 1fr;
    grid-template-rows: auto auto;
  }
  .home-articles-grid .article-card:first-child {
    grid-row: span 2;
  }
}

.article-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}
.article-card:hover {
  border-color: rgba(108,60,228,0.25);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.article-thumb {
  width: 100%;
  background: var(--bg-card);
  overflow: hidden;
  flex-shrink: 0;
}
.article-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
  display: block;
}
.article-card:hover .article-thumb img { transform: scale(1.04); }

.article-card:first-child .article-thumb { aspect-ratio: 16/9; }
.article-thumb { aspect-ratio: 16/7; }

.article-body {
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: 1;
}
.article-category {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary-light);
}
.article-title {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-card:first-child .article-title {
  font-size: var(--fs-lg);
  -webkit-line-clamp: 3;
}
.article-excerpt {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-meta-footer {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: auto;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.article-date, .article-read-time {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ══════════════════════════════════════════
   COMMUNITY SUPPORT CARDS
   ══════════════════════════════════════════ */
.support-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4);
}
@media (max-width: 480px) {
  .support-grid { grid-template-columns: 1fr; }
}

.support-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-6);
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
}
.support-card:hover {
  transform: translateY(-3px);
}
.support-card.report:hover {
  border-color: var(--warning);
  box-shadow: 0 4px 20px rgba(245,158,11,0.2);
}
.support-card.donate:hover {
  border-color: #EF4444;
  box-shadow: 0 4px 20px rgba(239,68,68,0.2);
}

.support-card-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}
.support-card.report .support-card-icon { background: rgba(245,158,11,0.12); }
.support-card.donate .support-card-icon { background: rgba(239,68,68,0.12); }

.support-card h3 {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text-primary);
}
.support-card p {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.6;
}

/* ══════════════════════════════════════════
   PARTNER LOGOS
   ══════════════════════════════════════════ */
.partners-strip {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  overflow-x: auto;
  padding: var(--sp-4) 0;
  scrollbar-width: none;
}
.partners-strip::-webkit-scrollbar { display: none; }

.partner-logo {
  height: 36px;
  flex-shrink: 0;
  opacity: 0.45;
  filter: grayscale(1);
  transition: var(--transition);
}
.partner-logo:hover { opacity: 1; filter: grayscale(0); }

/* ══════════════════════════════════════════
   VIDEO CONTAINER & YOUTUBE FACADE
   ══════════════════════════════════════════ */
.video-container {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background: var(--bg-card);
}
.video-container iframe,
.video-container .youtube-facade {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

/* YouTube Facade (lazy thumbnail) */
.youtube-facade {
  cursor: pointer;
  background: #000;
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.youtube-facade img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease, filter 0.3s ease;
}
.youtube-facade:hover img {
  transform: scale(1.03);
  filter: brightness(0.75);
}
.yt-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
}
.yt-play-btn {
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.5));
  transition: transform 0.2s ease;
}
.youtube-facade:hover .yt-play-btn {
  transform: scale(1.1);
}
.yt-play-label {
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 600;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  letter-spacing: 0.3px;
}
