/*
Theme Name: Tranglingo
Theme URI: https://tranglingo.top
Author: Tranglingo
Author URI: https://tranglingo.top
Description: Giao diện tranglingo.top - Tiếng Anh Tương Tác. Hỗ trợ dropdown menu Khoá học, tối ưu mobile.
Version: 1.8.1
Requires at least: 5.0
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
Text Domain: tranglingo
*/

body {
  font-family: 'Inter', sans-serif;
  -webkit-tap-highlight-color: transparent;
}
/* ========== TRANG CHỦ: nền xanh hải quân ========== */
body.tr-front-page,
body.home.tr-front-page,
body.tr-front-page.bg-\[\#0A192F\] {
  background-color: #0A192F !important;
  background-image: none;
  color: #f1f5f9;
}
body.tr-front-page main {
  background: transparent !important;
}


.custom-logo-link img,
.custom-logo {
  max-height: 40px;
  width: auto;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* ========== DESKTOP MENU ========== */
.desktop-menu {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center;
  gap: 0.25rem;
}

.desktop-menu > li {
  position: relative !important;
  list-style: none !important;
  margin: 0 !important;
}

.desktop-menu > li > a {
  display: block;
  padding: 0.5rem 0.75rem;
  color: #cbd5e1 !important;
  text-decoration: none !important;
  border-radius: 0.5rem;
  white-space: nowrap;
  transition: color 0.15s;
}

.desktop-menu > li > a:hover {
  color: #22d3ee !important;
}

/* Submenu - Ẩn mặc định */
.desktop-menu .sub-menu {
  display: none !important;
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  min-width: 200px !important;
  background: #0f172a !important;
  border: 1px solid #1e293b !important;
  border-radius: 0.75rem !important;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5) !important;
  /* KHÔNG dùng margin-top để tránh khoảng trống gây chớp giật */
  margin: 0 !important;
  padding: 0.5rem !important;
  padding-top: 0.65rem !important; /* khoảng cách nhìn bằng padding, vẫn thuộc vùng hover */
  z-index: 9999 !important;
  list-style: none !important;
}

/* Cầu nối ảo (bridge) chống mất hover khi di chuột từ link xuống submenu */
.desktop-menu > li.menu-item-has-children::before {
  content: '' !important;
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  right: 0 !important;
  height: 14px !important;
  z-index: 9998 !important;
  background: transparent !important;
  pointer-events: auto !important;
}

.desktop-menu .sub-menu li {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.desktop-menu .sub-menu a {
  display: block !important;
  padding: 0.7rem 1rem !important;
  color: #cbd5e1 !important;
  text-decoration: none !important;
  border-radius: 0.5rem !important;
  font-size: 0.9rem !important;
  white-space: nowrap !important;
  transition: background 0.15s, color 0.15s;
}

.desktop-menu .sub-menu a:hover {
  background: #1e293b !important;
  color: #22d3ee !important;
}

/* HIỆN dropdown khi hover */
.desktop-menu > li:hover > .sub-menu,
.desktop-menu > li.menu-item-has-children:hover > .sub-menu,
.desktop-menu > li.focus > .sub-menu {
  display: block !important;
}

/* Mũi tên nhỏ cạnh mục có con */
.desktop-menu > li.menu-item-has-children > a::after {
  content: '' !important;
  display: inline-block !important;
  width: 0 !important;
  height: 0 !important;
  margin-left: 0.4rem !important;
  vertical-align: middle !important;
  border-left: 4px solid transparent !important;
  border-right: 4px solid transparent !important;
  border-top: 5px solid currentColor !important;
  opacity: 0.7 !important;
}

/* Nested submenu (cấp 2) — flyout sang phải */
.desktop-menu .sub-menu .menu-item-has-children {
  position: relative !important;
}
.desktop-menu .sub-menu .sub-menu {
  top: 0 !important;
  left: 100% !important;
  margin-left: 0.25rem !important;
  padding-top: 0.5rem !important;
}
.desktop-menu .sub-menu .menu-item-has-children:hover > .sub-menu,
.desktop-menu .sub-menu .menu-item-has-children.focus > .sub-menu {
  display: block !important;
}
.desktop-menu .sub-menu .menu-item-has-children > a::after {
  content: '' !important;
  display: inline-block !important;
  width: 0 !important;
  height: 0 !important;
  margin-left: 0.4rem !important;
  vertical-align: middle !important;
  border-top: 4px solid transparent !important;
  border-bottom: 4px solid transparent !important;
  border-left: 5px solid currentColor !important;
  opacity: 0.7 !important;
}

/* ========== MOBILE MENU ========== */
.mobile-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(10, 25, 47, 0.98);
  border-bottom: 1px solid rgba(51, 65, 85, 0.8);
  backdrop-filter: blur(12px);
  z-index: 50;
  padding: 1rem 1.25rem 1.5rem;
}

.mobile-menu.is-open {
  display: block;
}

.mobile-menu .mobile-nav,
.mobile-menu ul {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.mobile-menu li {
  list-style: none !important;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
}

.mobile-menu li > a {
  display: block;
  padding: 0.9rem 0.75rem;
  color: #cbd5e1;
  font-weight: 500;
  font-size: 1rem;
  text-decoration: none;
  border-radius: 0.5rem;
}

.mobile-menu li > a:hover {
  background: rgba(30, 41, 59, 0.8);
  color: #22d3ee;
}

.mobile-menu .sub-menu {
  display: none;
  list-style: none !important;
  margin: 0 !important;
  padding: 0 0 0.5rem 1rem !important;
  background: transparent !important;
  border: none !important;
  position: static !important;
  box-shadow: none !important;
}

.mobile-menu li.menu-item-has-children.is-open > .sub-menu,
.mobile-menu .sub-menu.is-open {
  display: block !important;
}

.mobile-menu .sub-menu a {
  padding: 0.65rem 1rem;
  color: #94a3b8;
  font-size: 0.95rem;
}

#menu-toggle .icon-close { display: none; }
#menu-toggle.is-active .icon-open { display: none; }
#menu-toggle.is-active .icon-close { display: block; }



.btn-primary, .btn-secondary {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}


@supports (padding: max(0px)) {
  header, footer, main {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

@media (max-width: 639px) {
  .hero-buttons {
    flex-direction: column;
    width: 100%;
  }
  .hero-buttons a {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
}

/* ========== NỘI DUNG TRANG (không phải trang chủ): nền trắng ========== */
body.tr-content-page {
  background: #0A192F;
}

body.tr-content-page main.tr-main-content {
  background: transparent;
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
}

/* Khung nội dung trắng */
.tr-content-card {
  background: #ffffff;
  color: #1e293b;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  padding: 1.5rem 1.25rem;
  animation: tr-fade-up 0.45s ease-out both;
}

@media (min-width: 640px) {
  .tr-content-card {
    padding: 2rem 2.25rem;
  }
}

@keyframes tr-fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Hiệu ứng chuyển nhẹ khi load trang nội dung */
body.tr-content-page main.tr-main-content {
  animation: tr-page-in 0.35s ease-out both;
}

@keyframes tr-page-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Tiêu đề / meta trong card trắng */
.tr-content-card .tr-entry-title {
  color: #0f172a !important;
  font-weight: 800;
  line-height: 1.25;
  margin: 0 0 0.75rem;
}

.tr-content-card .tr-entry-meta {
  color: #64748b;
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.tr-content-card .tr-entry-meta a {
  color: #0891b2;
  text-decoration: none;
}
.tr-content-card .tr-entry-meta a:hover {
  text-decoration: underline;
}

/* ---- Nội dung bài: tôn trọng định dạng Gutenberg / Classic Editor ---- */
/* Tailwind Preflight hay làm mất style — khôi phục rõ ràng */
.tr-entry-content {
  color: #334155;
  font-size: 1.0625rem;
  line-height: 1.75;
  word-wrap: break-word;
}

.tr-entry-content > *:first-child { margin-top: 0; }
.tr-entry-content > *:last-child { margin-bottom: 0; }

.tr-entry-content h1,
.tr-entry-content h2,
.tr-entry-content h3,
.tr-entry-content h4,
.tr-entry-content h5,
.tr-entry-content h6 {
  color: #0f172a;
  font-weight: 700;
  line-height: 1.3;
  margin: 1.5em 0 0.6em;
}

.tr-entry-content h1 { font-size: 2em; }
.tr-entry-content h2 { font-size: 1.5em; }
.tr-entry-content h3 { font-size: 1.25em; }
.tr-entry-content h4 { font-size: 1.125em; }
.tr-entry-content h5 { font-size: 1em; }
.tr-entry-content h6 { font-size: 0.9em; }

.tr-entry-content p {
  margin: 0 0 1.1em;
}

.tr-entry-content a {
  color: #0891b2;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.tr-entry-content a:hover {
  color: #0e7490;
}

.tr-entry-content ul,
.tr-entry-content ol {
  margin: 0 0 1.1em;
  padding-left: 1.5em;
}
.tr-entry-content ul { list-style: disc; }
.tr-entry-content ol { list-style: decimal; }
.tr-entry-content li { margin: 0.35em 0; }

.tr-entry-content blockquote {
  margin: 1.25em 0;
  padding: 0.75em 1em;
  border-left: 4px solid #22d3ee;
  background: #f8fafc;
  color: #475569;
  font-style: italic;
}

.tr-entry-content img,
.tr-entry-content figure {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 1.25em 0;
}

.tr-entry-content figure img {
  margin: 0;
}

.tr-entry-content figcaption {
  font-size: 0.875rem;
  color: #64748b;
  text-align: center;
  margin-top: 0.5em;
}

.tr-entry-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25em 0;
  font-size: 0.95em;
}
.tr-entry-content th,
.tr-entry-content td {
  border: 1px solid #e2e8f0;
  padding: 0.5em 0.75em;
  text-align: left;
}
.tr-entry-content th {
  background: #f1f5f9;
  font-weight: 600;
}

.tr-entry-content pre,
.tr-entry-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
}
.tr-entry-content pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1em;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1.25em 0;
}
.tr-entry-content :not(pre) > code {
  background: #f1f5f9;
  color: #be123c;
  padding: 0.15em 0.4em;
  border-radius: 0.25rem;
}

.tr-entry-content hr {
  border: 0;
  border-top: 1px solid #e2e8f0;
  margin: 2em 0;
}

/* Giữ màu / cỡ chữ inline từ editor (không bị theme đè) */
.tr-entry-content [style*="color"] {
  /* cho phép inline color từ WP */
}
.tr-entry-content .has-text-align-center { text-align: center; }
.tr-entry-content .has-text-align-right { text-align: right; }
.tr-entry-content .has-text-align-left { text-align: left; }
.tr-entry-content .aligncenter {
  display: block;
  margin-left: auto;
  margin-right: auto;
}
.tr-entry-content .alignleft {
  float: left;
  margin: 0.5em 1.25em 0.5em 0;
}
.tr-entry-content .alignright {
  float: right;
  margin: 0.5em 0 0.5em 1.25em;
}

/* WP block library bổ sung */
.tr-entry-content .wp-block-image img {
  border-radius: 0.5rem;
}
.tr-entry-content .wp-block-quote {
  border-left: 4px solid #22d3ee;
  padding-left: 1em;
}
.tr-entry-content .wp-block-pullquote {
  border-top: 4px solid #22d3ee;
  border-bottom: 4px solid #22d3ee;
  padding: 1.5em 0;
  text-align: center;
}

/* Card danh sách bài (archive) trên nền tối */
.tr-posts-grid .tr-post-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: tr-fade-up 0.4s ease-out both;
}
.tr-posts-grid .tr-post-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}
.tr-posts-grid .tr-post-card h2,
.tr-posts-grid .tr-post-card h2 a {
  color: #0f172a !important;
}
.tr-posts-grid .tr-post-card h2 a:hover {
  color: #0891b2 !important;
}
.tr-posts-grid .tr-post-card .tr-card-excerpt {
  color: #475569;
}
.tr-posts-grid .tr-post-card .tr-card-meta {
  color: #94a3b8;
}
.tr-posts-grid .tr-post-card .tr-card-more {
  color: #0891b2;
  font-weight: 600;
}

/* Prev/next trên single trong card trắng */
.tr-content-card .tr-post-nav {
  border-top: 1px solid #e2e8f0;
  margin-top: 2rem;
  padding-top: 1.25rem;
}
.tr-content-card .tr-post-nav a {
  color: #64748b;
  text-decoration: none;
}
.tr-content-card .tr-post-nav a:hover {
  color: #0891b2;
}
.tr-content-card .tr-post-nav .tr-nav-title {
  color: #0f172a;
  font-weight: 600;
}


/* ========== Tác giả (byline) ========== */
.tr-author-byline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  vertical-align: middle;
}
.tr-author-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none !important;
  color: inherit;
}
.tr-author-link:hover .tr-author-name {
  color: #0891b2;
  text-decoration: underline;
}
.tr-author-avatar {
  border-radius: 9999px !important;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid #e2e8f0;
}
.tr-author-name {
  font-weight: 600;
  font-size: 0.9em;
  color: #334155;
}
.tr-author-md .tr-author-name {
  font-size: 0.95rem;
}
.tr-entry-meta .tr-author-byline {
  margin-right: 0.15rem;
}
.tr-card-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  font-size: 0.75rem;
}
.tr-card-meta-row .tr-author-name {
  font-size: 0.75rem;
  color: #64748b;
}
.tr-card-meta-row .tr-author-avatar {
  border-width: 1px;
}


/* Khung tài liệu Lớp 7 */
.tr-lop7-frame {
  border-radius: 0 0 1rem 1rem;
}
