/* ============================================================
   SITE — Thanh menu dùng chung (1 hàng) + khung trang nội dung + chân trang.
   Dùng biến màu từ theme.css (hoặc :root của trang).
   ============================================================ */

/* ----- 1 HÀNG MENU ----- */
.site-menu {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;   /* các mục menu căn giữa thanh */
  gap: 8px;
  padding: 0 16px;
  min-height: 54px;
  background: linear-gradient(180deg, var(--red), var(--red-deep));
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 2px 10px var(--shadow);
}
.site-menu .sm-brand {
  position: absolute;        /* ghim trái, không làm lệch nhóm menu ở giữa */
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--gold-soft);
  font-family: var(--font-head, 'Charm', cursive);
  font-size: 21px;
  white-space: nowrap;
}
.site-menu .sm-links {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
}
.site-menu .sm-item { position: relative; display: flex; }
.site-menu .sm-link {
  color: var(--gold-soft);
  text-decoration: none;
  padding: 9px 16px;
  border-radius: 20px;
  font-size: 18px;
  white-space: nowrap;
  transition: background .15s, color .15s;
  /* để nút cha (button.sm-link) trông y như liên kết */
  font-family: inherit;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.site-menu .sm-link:hover { background: rgba(255, 248, 232, 0.16); }
.site-menu .sm-link.active {
  background: var(--paper);
  color: var(--red-deep);
  font-weight: 600;
  box-shadow: 0 2px 6px var(--shadow);
}
.site-menu .sm-caret { font-size: 12px; opacity: .85; }

/* ----- Tài khoản / quản trị ----- */
.site-menu .sm-user {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 260;
}
.site-menu .sm-user-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 248, 232, 0.26);
  border-radius: 999px;
  background: rgba(255, 248, 232, 0.1);
  color: var(--gold-soft);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
}
.site-menu .sm-user-btn:hover,
.site-menu .sm-user.open .sm-user-btn {
  border-color: rgba(255, 248, 232, 0.55);
  background: rgba(255, 248, 232, 0.18);
}
.site-menu .sm-user-btn:active {
  transform: translateY(1px);
}
.site-menu .sm-user-icon {
  font-size: 18px;
  line-height: 1;
}
.site-menu .sm-user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: linear-gradient(180deg, var(--red), var(--red-deep));
  border: 1px solid var(--gold);
  border-radius: 10px;
  box-shadow: 0 12px 28px var(--shadow);
}
.site-menu .sm-user.open .sm-user-menu {
  display: flex;
}
.site-menu .sm-user-menu-link {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: var(--gold-soft);
  font: inherit;
  font-size: 15px;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}
.site-menu .sm-user-menu-link:hover {
  background: rgba(255, 248, 232, 0.14);
}
.site-menu .sm-auth.is-user {
  color: #fff8e8;
  font-weight: 600;
}
.site-menu .sm-notify {
  opacity: .58;
  cursor: not-allowed;
}

/* ----- Menu con (dropdown) ----- */
.site-menu .sm-sub {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 190px;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: linear-gradient(180deg, var(--red), var(--red-deep));
  border: 1px solid var(--gold);
  border-radius: 12px;
  box-shadow: 0 10px 28px var(--shadow);
  z-index: 200;
}
/* Hiện menu con khi rê chuột hoặc focus bằng bàn phím (desktop) */
@media (min-width: 721px) {
  .site-menu .sm-item.has-sub:hover > .sm-sub,
  .site-menu .sm-item.has-sub:focus-within > .sm-sub { display: flex; }
}
.site-menu .sm-sub .sm-item { display: block; }
.site-menu .sm-sub .sm-link { width: 100%; border-radius: 8px; }
.site-menu .sm-toggle {
  display: none;
  background: none;
  border: 0;
  color: var(--gold-soft);
  font-size: 26px;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: auto;
}

/* Di động: menu thu lại, bấm ☰ để mở thành cột */
@media (max-width: 720px) {
  .site-menu {
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    max-height: 100dvh;
    overflow-y: auto;
    padding: 8px 12px 0;
  }
  .site-menu.user-open {
    overflow-y: visible;
  }
  .site-menu .sm-brand {        /* trả về dòng chảy bình thường trên di động */
    position: static;
    transform: none;
    min-width: 0;
    flex: 1 1 auto;
    padding: 4px 0 8px;
    font-size: clamp(17px, 5vw, 21px);
  }
  .site-menu .sm-name {
    white-space: normal;
    line-height: 1.12;
  }
  .site-menu .sm-toggle {
    display: block;
    flex: 0 0 auto;
    line-height: 1;
  }
  .site-menu .sm-user {
    position: relative;
    right: auto;
    top: auto;
    transform: none;
    flex: 0 0 auto;
    order: 3;
  }
  .site-menu .sm-user-btn {
    width: 36px;
    height: 36px;
  }
  .site-menu .sm-user-menu {
    right: 0;
    top: calc(100% + 6px);
    z-index: 500;
  }
  .site-menu .sm-links {
    flex-basis: 100%;
    order: 4;
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    display: none;
    padding: 2px 0 10px;
  }
  .site-menu .sm-links.open { display: flex; }
  .site-menu .sm-item { display: block; }
  .site-menu .sm-link {
    padding: 11px 14px;
    width: 100%;
    min-height: 44px;
    border-radius: 12px;
    white-space: normal;
  }
  /* Menu con: trải phẳng theo cột, bấm mục cha để mở */
  .site-menu .sm-sub {
    position: static;
    display: none;
    min-width: 0;
    width: 100%;
    margin: 2px 0 4px;
    padding: 4px 0 4px 14px;
    background: rgba(0, 0, 0, 0.18);
    border: 0;
    border-radius: 8px;
    box-shadow: none;
  }
  .site-menu .sm-item.has-sub:hover > .sm-sub,
  .site-menu .sm-item.has-sub:focus-within > .sm-sub { display: none; }   /* tắt hover/focus desktop trên cảm ứng */
  .site-menu .sm-item.has-sub.open > .sm-sub { display: flex; }
  .site-menu .sm-sub .sm-link {
    padding-left: 12px;
    font-size: 17px;
  }
  .site-menu .sm-parent { justify-content: space-between; }
}

/* ----- KHUNG TRANG NỘI DUNG (giới thiệu, thủy tổ, hương ước...) ----- */
.page-wrap {
  width: min(1080px, 92%);
  margin: 28px auto 50px;
}
.page-paper {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 40px var(--shadow);
  padding: 0 0 34px;
  overflow: hidden;
}
.page-hero {
  text-align: center;
  padding: 42px 24px 22px;
  border-bottom: 2px solid var(--gold);
}
.page-hero h1 {
  font-family: var(--font-head, 'Charm', cursive);
  font-size: clamp(30px, 5vw, 52px);
  color: var(--red-deep);
  margin: 0;
  text-shadow: 1px 1px 0 var(--gold-soft);
}
.page-hero .subtitle {
  color: var(--ink-soft);
  font-style: italic;
  font-size: 20px;
  margin-top: 8px;
}
.page-body {
  padding: 26px clamp(18px, 4vw, 46px) 6px;
  font-size: 19px;          /* chữ to hơn cho người lớn tuổi dễ đọc */
  line-height: 1.9;
  color: var(--ink);
}
.page-body h2, .page-body h3 { color: var(--red-deep); }
.page-body img { border-radius: 8px; margin: 14px auto; box-shadow: 0 4px 12px var(--shadow); }
.page-body .gp-iframe-embed,
.page-body .gp-video-embed,
.page-body .gp-sheet-embed {
  width: 100%;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  background: #fff;
  box-shadow: 0 4px 12px var(--shadow);
}
.page-body .gp-iframe-embed iframe,
.page-body .gp-video-embed iframe,
.page-body .gp-video-embed video,
.page-body .gp-sheet-embed iframe {
  display: block;
  width: 100%;
  border: 0;
}
.page-body .gp-video-embed {
  overflow: hidden;
}
.page-body .gp-sheet-embed iframe {
  min-width: 760px;
}
.page-body blockquote {
  margin: 18px 0;
  padding: 10px 18px;
  border-left: 4px solid var(--gold);
  background: rgba(199, 154, 58, 0.08);
  color: var(--jade);
  font-style: italic;
  border-radius: 0 8px 8px 0;
}
.page-body a { color: var(--red); }
.page-body .ql-align-center { text-align: center; }
.page-body .ql-align-right { text-align: right; }
.page-body .ql-align-justify { text-align: justify; }
.page-meta {
  text-align: center;
  color: var(--ink-soft);
  font-size: 15px;
  font-style: italic;
  margin-top: 20px;
}
.page-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-soft);
  font-style: italic;
}
.page-state.error { color: var(--red-deep); font-style: normal; }
.page-state code { background: rgba(0,0,0,0.06); padding: 2px 6px; border-radius: 5px; }

/* ----- BÀI VIẾT ----- */
.posts-shell {
  padding-bottom: 18px;
}
.posts-list {
  display: grid;
  gap: 0;
  padding: 8px clamp(14px, 3vw, 34px) 20px;
}
.post-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 22px 0;
  border-bottom: 1px solid rgba(184, 155, 106, 0.45);
}
.post-card:last-child {
  border-bottom: 0;
}
.post-card-main {
  display: block;
  color: inherit;
  text-decoration: none;
}
.post-card-main h2 {
  font-family: var(--font-serif, 'Noto Serif', serif);
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.25;
  color: var(--red-deep);
  margin: 0 0 8px;
}
.post-card-main:hover h2 {
  color: var(--red);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.post-card-main p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1.65;
}
.post-card-meta {
  min-width: 150px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  color: var(--ink-soft);
  font-size: 15px;
  white-space: nowrap;
}
.post-detail .page-hero {
  padding-top: 26px;
}
.post-back {
  margin: 0 0 14px;
  font-family: var(--font-body);
  font-size: 17px;
}
.post-back a {
  color: var(--jade);
  text-decoration: none;
}
.post-back a:hover {
  text-decoration: underline;
}
.post-detail-meta {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  color: var(--ink-soft);
  font-size: 16px;
}
.post-detail-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ----- Nút thả tim ----- */
.post-like {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-3);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 17px;
  cursor: pointer;
  transition: border-color .15s, color .15s, transform .1s, background .15s;
}
.like-btn:hover { border-color: var(--rose); color: var(--rose); }
.like-btn:active { transform: scale(.96); }
.like-btn:disabled { cursor: default; opacity: .7; }
.like-heart {
  font-size: 20px;
  line-height: 1;
  color: var(--line);
  transition: color .15s, transform .15s;
}
.like-btn:hover .like-heart { color: var(--rose); }
.like-btn.liked { border-color: var(--rose); color: var(--rose-deep, var(--red-deep)); }
.like-btn.liked .like-heart {
  color: var(--red);
  transform: scale(1.12);
}
.like-count { font-weight: 600; }

@media (max-width: 720px) {
  .post-card {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .post-card-meta {
    min-width: 0;
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
    white-space: normal;
  }
}

/* ----- CHÂN TRANG DÙNG CHUNG ----- */
.site-foot {
  text-align: center;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 16px;
  margin: 30px auto 26px;
  padding: 0 20px;
}
.site-foot .ornament {
  color: var(--gold);
  letter-spacing: 6px;
  margin-bottom: 8px;
}
