/*
Theme Name: Hanlin Portal Base
Theme URI: https://github.com/meimouren/wordpress-site-builder
Author: Hanlin Education
Author URI: https://github.com/meimouren/wordpress-site-builder
Description: 翰林通用门户基线主题（FSE block theme）。从 IPsyO 项目沉淀的 31 条避坑修复 + 自托管字体子集 + 后台「工具集」面板（站长验证 / 统计代码 / 全站资源一键替换）+ 动态块（绕 wpautop）+ pre_get_document_title（绕 wptexturize）+ sitemap/robots/FAQ JSON-LD。各项目通过 theme.json 覆盖颜色 / 字体即可，无需派生新主题。
Version: 1.0.0
Requires at least: 6.4
Tested up to: 6.6
Requires PHP: 7.4
License: GPL v2 or later
Text Domain: hanlin-portal-base
Tags: full-site-editing, block-styles, education, competition, chinese
*/

/* ==========================================================================
   基础 reset 与全局
   ========================================================================== */

@import url("assets/fonts.css");

html {
  scroll-behavior: smooth;
}

body,
.wp-site-blocks {
  overflow-x: clip;
}

body {
  background-color: #f7f9fb;
  color: #191c1e;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
}

img,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  transition: color 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

/* ==========================================================================
   字号尺寸约束（针对 H1 Hero、移动端）
   ========================================================================== */

@media (max-width: 880px) {
  h1.wp-block-heading {
    font-size: 36px !important;
    line-height: 1.25 !important;
  }
  h2.wp-block-heading {
    font-size: 24px !important;
    line-height: 1.3 !important;
  }
  h3.wp-block-heading {
    font-size: 20px !important;
  }
}

/* ==========================================================================
   WP 全局空白归零 —— wp-site-blocks / body 自带的 root padding
   ========================================================================== */

body.wp-site-blocks,
body,
.wp-site-blocks {
  --wp--style--root--padding-top: 0 !important;
  --wp--style--root--padding-bottom: 0 !important;
  --wp--style--root--padding-left: 0 !important;
  --wp--style--root--padding-right: 0 !important;
  --wp--style--block-gap: 0 !important;
}

.wp-site-blocks > *,
.wp-site-blocks > .wp-block-template-part {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* template-part wrapper 不要 margin/padding，让 header/footer 直接贴上下边 */
.wp-block-template-part {
  margin: 0 !important;
  padding: 0 !important;
}

/* ==========================================================================
   WP page content 容器还原 —— 让 site/*.html 推上去的 <section> 完全自主
   关键：
   1. 移除 has-global-padding / is-layout-constrained 的副作用
   2. 移除 is-layout-flow 给子元素自动加的 blockGap (margin-block-start)
      → 否则 section 之间会有白条空行
   ========================================================================== */

.wp-block-post-content,
.wp-block-post-content.has-global-padding,
.wp-block-post-content.is-layout-constrained,
main.wp-block-group.is-layout-flow {
  padding-left: 0 !important;
  padding-right: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  max-width: 100% !important;
  --wp--style--block-gap: 0 !important;
}

.wp-block-post-content > *,
.wp-block-post-content > section,
main.wp-block-group > *,
main.wp-block-group > .wp-block-post-content,
main.wp-block-group.is-layout-flow > * {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  margin-block: 0 !important;
}

.wp-block-post-content > section {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}

/* ==========================================================================
   全宽 banner（兼容主题原 .ip-banner-fullbleed 类，向后兼容）
   ========================================================================== */

.ip-banner-fullbleed {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  box-sizing: border-box;
}

/* ==========================================================================
   Section 底色 utility
   ========================================================================== */

.ip-section-white { background-color: #FFFFFF; }
.ip-section-soft  { background-color: #f2f4f6; }
.ip-section-grey  { background-color: #f7f9fb; }
.ip-section-navy  { background-color: #1A242F; color: #FFFFFF; }
.ip-section-ink   { background-color: #0F172A; color: #FFFFFF; }

/* ==========================================================================
   文字色 utility
   ========================================================================== */

.ip-text-navy    { color: #1A242F; }
.ip-text-red     { color: #B91C3C; }
.ip-text-gold    { color: #FFD700; }
.ip-text-slate   { color: #44474b; }
.ip-text-muted   { color: #75777c; }
.ip-text-white   { color: #FFFFFF; }

/* ==========================================================================
   编辑式 portal 装饰系统
   ========================================================================== */

.ip-rule-gold {
  width: 48px;
  height: 3px;
  background: #FFD700;
  border-radius: 2px;
  margin-bottom: 1.25rem;
  display: block;
}

.ip-rule-red {
  width: 64px;
  height: 4px;
  background: #B91C3C;
  border-radius: 2px;
  margin: 0 auto 0;
  display: block;
}

.ip-kicker {
  font-family: "Inter", sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #FFD700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: 1rem;
  display: inline-block;
}

.ip-kicker-on-light {
  color: #B91C3C;
}

.ip-lead {
  font-family: "Noto Sans SC", sans-serif;
  font-size: clamp(17px, 2vw, 20px);
  font-weight: 400;
  color: #44474b;
  line-height: 1.55;
  max-width: 720px;
  margin: 0 auto 1.5rem;
}

/* ==========================================================================
   品牌组件
   ========================================================================== */

.ip-ambient-shadow {
  box-shadow: 0px 4px 20px rgba(26, 36, 47, 0.05);
}

.ip-glass-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   QR 占位（运营换图前的视觉填充）
   ========================================================================== */

.ip-qr-placeholder {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><rect width='160' height='160' fill='%23ffffff'/><g fill='%231A242F'><rect x='10' y='10' width='30' height='30'/><rect x='15' y='15' width='20' height='20' fill='%23ffffff'/><rect x='20' y='20' width='10' height='10'/><rect x='120' y='10' width='30' height='30'/><rect x='125' y='15' width='20' height='20' fill='%23ffffff'/><rect x='130' y='20' width='10' height='10'/><rect x='10' y='120' width='30' height='30'/><rect x='15' y='125' width='20' height='20' fill='%23ffffff'/><rect x='20' y='130' width='10' height='10'/></g></svg>");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #FFFFFF;
}

/* ==========================================================================
   Tag pill
   ========================================================================== */

.ip-tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* ==========================================================================
   Header（自定义 sticky nav）
   ========================================================================== */

.ip-header {
  background: #FFFFFF;
  border-bottom: 1px solid #E2E8F0;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}

.ip-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 80px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.ip-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  text-decoration: none;
}
.ip-logo img { height: 36px; width: auto; display: block; }
.ip-logo-text {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: #1A242F;
}

.ip-nav {
  display: none;
  gap: 24px;
  align-items: center;
}
.ip-nav a {
  font-family: "Inter", sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: #44474b;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 4px;
}
.ip-nav a:hover { background: #f2f4f6; color: #1A242F; }
.ip-nav a.is-current {
  color: #B91C3C;
  font-weight: 700;
  border-bottom: 2px solid #B91C3C;
  padding-bottom: 4px;
  border-radius: 0;
}

.ip-header-cta {
  display: none;
  align-items: center;
  justify-content: center;
  background: #1A242F;
  color: #FFFFFF !important;
  font-family: "Inter", sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 8px 16px;
  border-radius: 4px;
  text-decoration: none;
  gap: 8px;
}
.ip-header-cta:hover { opacity: 0.8; }

.ip-nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  padding: 8px;
  color: #1A242F;
  cursor: pointer;
}

.ip-mobile-menu {
  display: none;
  border-top: 1px solid #E2E8F0;
  background: #FFFFFF;
  padding: 16px 24px;
}
.ip-mobile-menu.is-open { display: block; }
.ip-mobile-menu nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 1200px;
  margin: 0 auto;
}
.ip-mobile-menu nav a {
  font-family: "Inter", sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #44474b;
  text-decoration: none;
  padding: 8px 0;
}
.ip-mobile-menu nav a.is-current {
  color: #B91C3C;
  font-weight: 700;
}

@media (min-width: 1024px) {
  .ip-nav { display: flex; }
  .ip-header-cta { display: inline-flex; }
  .ip-nav-toggle { display: none; }
  .ip-mobile-menu { display: none !important; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .ip-header-cta { display: inline-flex; }
}

@media (max-width: 767px) {
  .ip-header-inner { height: 64px; }
  .ip-logo img { height: 28px; }
  .ip-logo-text { font-size: 18px; }
}

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

.ip-footer {
  background: #1A242F;
  color: #FFFFFF;
  padding: 80px 24px 24px;
  border-top: 1px solid #75777c;
}
.ip-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
}
@media (min-width: 768px) {
  .ip-footer-inner { grid-template-columns: 2fr 1fr 1fr; }
}
.ip-footer-brand img { height: 40px; margin-bottom: 16px; }
.ip-footer-brand-name {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: #FFD700;
  margin-left: 12px;
  vertical-align: middle;
}
.ip-footer-tagline {
  font-size: 16px;
  color: #e0e3e5;
  margin: 16px 0 24px;
  max-width: 480px;
  line-height: 1.6;
}
.ip-footer h4 {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #FFD700;
  margin: 0 0 16px;
}
.ip-footer ul { list-style: none; padding: 0; margin: 0; }
.ip-footer ul li { margin-bottom: 8px; }
.ip-footer ul li a,
.ip-footer-bottom-links a {
  font-family: "Inter", sans-serif;
  font-size: 14px;
  color: #e0e3e5;
  text-decoration: none;
}
.ip-footer ul li a:hover,
.ip-footer-bottom-links a:hover {
  color: #FFD700;
}
.ip-footer-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #FFD700;
  color: #1A242F !important;
  padding: 10px 20px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}
.ip-footer-cta:hover { background: #ffd000; }
.ip-footer-bottom {
  max-width: 1200px;
  margin: 48px auto 0;
  padding-top: 24px;
  border-top: 1px solid rgba(117, 119, 124, 0.3);
  display: flex;
  flex-direction: column;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
}
@media (min-width: 768px) {
  .ip-footer-bottom { flex-direction: row; }
}
.ip-footer-copyright {
  font-size: 14px;
  color: #e0e3e5;
  opacity: 0.8;
}
.ip-footer-bottom-links {
  display: flex;
  gap: 24px;
}

.ip-icp-link {
  display: inline-block;
  margin-top: 6px;
  color: #e0e3e5;
  opacity: 0.6;
  font-size: 13px;
  text-decoration: none;
  font-family: "Inter", sans-serif;
}
.ip-icp-link:hover { opacity: 1; color: #FFD700; }

/* ==========================================================================
   .ipsyo-prose · 长文本排版（法律页 / 隐私 / 学术诚信 / 单文章 等）
   阅读列宽 880px，中文最佳行高 1.85，品牌色装饰
   ========================================================================== */

.ipsyo-prose {
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 17px;
  color: #191c1e;
  line-height: 1.85;
  letter-spacing: 0.01em;
}

.ipsyo-prose p {
  margin: 0 0 1.5rem;
  color: #191c1e;
}

.ipsyo-prose h2 {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: #1A242F;
  line-height: 1.4;
  margin: 3rem 0 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #E2E8F0;
}

.ipsyo-prose h2:first-child,
.ipsyo-prose > p:first-child + h2 {
  margin-top: 1rem;
}

.ipsyo-prose h3 {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: #1A242F;
  line-height: 1.4;
  margin: 2rem 0 0.75rem;
}

.ipsyo-prose h4 {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: #1A242F;
  margin: 1.5rem 0 0.5rem;
}

.ipsyo-prose ul,
.ipsyo-prose ol {
  margin: 0 0 1.5rem;
  padding-left: 1.75rem;
}

.ipsyo-prose ul {
  list-style: disc;
}

.ipsyo-prose ul li::marker {
  color: #FFD700;
}

.ipsyo-prose ol {
  list-style: decimal;
}

.ipsyo-prose ol li::marker {
  color: #B91C3C;
  font-weight: 700;
}

.ipsyo-prose li {
  margin-bottom: 0.6rem;
  line-height: 1.8;
  padding-left: 0.25rem;
}

.ipsyo-prose li > ul,
.ipsyo-prose li > ol {
  margin: 0.5rem 0;
}

.ipsyo-prose strong {
  color: #1A242F;
  font-weight: 700;
}

.ipsyo-prose em {
  font-style: italic;
  color: #44474b;
}

.ipsyo-prose a {
  color: #1A242F;
  text-decoration: underline;
  text-decoration-color: #FFD700;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  transition: color 0.2s, text-decoration-color 0.2s;
  font-weight: 600;
}

.ipsyo-prose a:hover {
  color: #B91C3C;
  text-decoration-color: #B91C3C;
}

.ipsyo-prose blockquote {
  border-left: 4px solid #FFD700;
  padding: 1.5rem 1.75rem;
  margin: 2rem 0;
  background-color: #f2f4f6;
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: #1A242F;
  font-size: 16px;
  line-height: 1.75;
}

.ipsyo-prose blockquote p {
  margin: 0;
}
.ipsyo-prose blockquote p + p {
  margin-top: 0.75rem;
}

.ipsyo-prose hr {
  border: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, #E2E8F0 20%, #E2E8F0 80%, transparent);
  margin: 3rem 0;
}

.ipsyo-prose code {
  font-family: "SF Mono", Consolas, Monaco, monospace;
  background-color: #f2f4f6;
  color: #B91C3C;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  border: 1px solid #E2E8F0;
}

.ipsyo-prose pre {
  background: #1A242F;
  color: #FFD700;
  padding: 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 14px;
  line-height: 1.6;
}
.ipsyo-prose pre code {
  background: none;
  color: inherit;
  border: 0;
  padding: 0;
}

.ipsyo-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 15px;
}

.ipsyo-prose th,
.ipsyo-prose td {
  padding: 0.85rem 1rem;
  border: 1px solid #E2E8F0;
  text-align: left;
  vertical-align: top;
}

.ipsyo-prose th {
  background: #1A242F;
  color: #fff;
  font-weight: 700;
  font-family: "Inter", "Noto Sans SC", sans-serif;
  font-size: 14px;
  letter-spacing: 0.04em;
}

.ipsyo-prose tr:nth-child(even) td {
  background: #f7f9fb;
}

/* 第一段如果是 "更新日期：..." 这种 meta 信息，弱化样式 */
.ipsyo-prose > p:first-child {
  color: #75777c !important;
  font-size: 14px !important;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #E2E8F0;
}

/* 移动端缩小一点 */
@media (max-width: 640px) {
  .ipsyo-prose { font-size: 16px; line-height: 1.8; }
  .ipsyo-prose h2 { font-size: 22px; margin-top: 2.25rem; }
  .ipsyo-prose h3 { font-size: 18px; }
}

/* ==========================================================================
   Section underline（h2 下的红色短线）
   ========================================================================== */

.ip-section-underline {
  width: 64px;
  height: 4px;
  border-radius: 2px;
  background-color: #B91C3C;
  margin: 0 auto;
}

/* ==========================================================================
   Floating TOC（仅 single post，≥1440px）
   ========================================================================== */

.ip-toc-float {
  display: none;
  position: fixed;
  left: 24px;
  top: 80px;
  width: 240px;
  max-height: calc(100vh - 120px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  opacity: 1;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(26, 36, 47, 0.06);
  overflow-y: auto;
  z-index: 40;
}
.ip-toc-float.is-hidden {
  opacity: 0;
  transform: translateX(-24px);
  pointer-events: none;
}
.ip-toc-float h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #B91C3C;
  margin: 0 0 12px;
}
.ip-toc-float ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ip-toc-float li {
  margin: 6px 0;
}
.ip-toc-float a {
  color: #1A242F;
  text-decoration: none;
  font-size: 13px;
  line-height: 1.4;
  display: block;
  padding: 4px 0;
}
.ip-toc-float a:hover {
  color: #B91C3C;
}

/* Scrollspy active state：当前 viewport 对应的 li 高亮 */
.ip-toc-float li {
  position: relative;
  padding-left: 10px;
  border-left: 2px solid transparent;
  transition: border-left-color 0.2s ease, padding-left 0.2s ease;
}
.ip-toc-float li.is-active {
  border-left-color: #B91C3C;
  padding-left: 12px;
}
.ip-toc-float li.is-active > a {
  color: #B91C3C;
  font-weight: 600;
}

/* 文章读到底部自动隐藏 */
.ip-toc-float.is-hidden {
  opacity: 0;
  transform: translateX(-24px);
  pointer-events: none;
}

@media (min-width: 1440px) {
  .ip-toc-float { display: block; }
}

/* ==========================================================================
   Back to top
   ========================================================================== */

.ip-back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #1A242F;
  color: #FFD700;
  border: 0;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  z-index: 40;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: opacity 0.3s, transform 0.2s;
}
.ip-back-to-top:hover { transform: translateY(-2px); }
.ip-back-to-top.is-visible { display: inline-flex; }

/* ==========================================================================
   Breadcrumb
   ========================================================================== */

.ip-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Inter", sans-serif;
  font-size: 14px;
  color: #44474b;
}
.ip-breadcrumb a {
  color: #44474b;
  text-decoration: none;
}
.ip-breadcrumb a:hover { color: #1A242F; }
.ip-breadcrumb .sep { font-size: 12px; opacity: 0.5; }
.ip-breadcrumb-current { color: #1A242F; font-weight: 600; }

/* ==========================================================================
   News cards (used by archive)
   ========================================================================== */

.ip-news-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 768px) {
  .ip-news-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .ip-news-grid { grid-template-columns: repeat(3, 1fr); }
}
.ip-news-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
}
.ip-news-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(26,36,47,0.08);
}
.ip-news-card-media {
  aspect-ratio: 16/9;
  background: #e0e3e5;
  overflow: hidden;
}
.ip-news-card-media img { width:100%; height:100%; object-fit: cover; }
.ip-news-card-body { padding: 24px; flex: 1; display:flex; flex-direction:column; }
.ip-news-card-meta {
  font-family: "Inter", sans-serif;
  font-size: 12px;
  color: #75777c;
  margin-bottom: 8px;
}
.ip-news-card-title {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #1A242F;
  line-height: 1.4;
  margin: 0 0 12px;
}
.ip-news-card-excerpt {
  font-size: 14px;
  color: #44474b;
  line-height: 1.6;
  margin: 0;
  flex: 1;
}
