/*
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: Neutral FSE block theme baseline used by the wordpress-site-builder skill. Ships architecture only — no project-specific palette, copy, chrome, or shortcode body. Each project sets its design via /design-brief and applies it via /build-chrome (parts/header.html + parts/footer.html + chrome.css). Bakes in 90+ lessons from production projects (see docs/lessons-learned.md): pre_get_document_title bypass for wptexturize, dynamic blocks (avoid wpautop), self-hosted fonts + Material Symbols subset, FSE templates, REST binary upload for theme files, admin Site Tools panel (verification meta + analytics + QR), L88 is_home/is_front_page handling, L90 admin bar offset, etc.
Version: 2.0.0
Requires at least: 6.4
Tested up to: 6.6
Requires PHP: 7.4
License: GPL v2 or later
Text Domain: hl-baseline
Tags: full-site-editing, block-styles, education, blog, news, neutral
*/

/* ==========================================================================
   1. Base reset + global
   ========================================================================== */

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

html { scroll-behavior: smooth; }

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

body {
  background-color: var(--wp--preset--color--background, #F7F9FB);
  color: var(--wp--preset--color--body, #44474B);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: var(--wp--preset--font-family--sans-cjk, "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; }

/* ==========================================================================
   2. Heading size constraints (mobile)
   ========================================================================== */

@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; }
}

/* ==========================================================================
   3. WP global padding reset — let template-parts edge-to-edge
   ========================================================================== */

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;
}

.wp-block-template-part {
  margin: 0 !important;
  padding: 0 !important;
}

/* ==========================================================================
   4. WP page content container reset — let project section HTML self-own width
       Removes:
       - has-global-padding side effects
       - is-layout-constrained / is-layout-flow auto margins
       - is-layout-flow blockGap (the cause of stray white rows between sections)
   ========================================================================== */

.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;
}

/* ==========================================================================
   5. Full-bleed banner utility (used by project HTML for hero sections)
   ========================================================================== */

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

/* ==========================================================================
   6. Section background utility classes (neutral · projects override colors)
   ========================================================================== */

.hl-section-white { background-color: var(--wp--preset--color--surface, #FFFFFF); }
.hl-section-soft  { background-color: var(--wp--preset--color--surface-alt, #F2F4F6); }
.hl-section-bg    { background-color: var(--wp--preset--color--background, #F7F9FB); }
.hl-section-ink   { background-color: var(--wp--preset--color--ink, #0F172A); color: var(--wp--preset--color--surface, #FFFFFF); }

/* ==========================================================================
   7. Long-form article prose · .hl-prose
       Used for legal pages / privacy / about copy / blog post bodies.
       Neutral colors — projects can override via project chrome.css.
   ========================================================================== */

.hl-prose {
  font-family: var(--wp--preset--font-family--sans-cjk, "Noto Sans SC"), -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 17px;
  color: var(--wp--preset--color--heading, #1A1C1E);
  line-height: 1.85;
  letter-spacing: 0.01em;
}

.hl-prose p {
  margin: 0 0 1.5rem;
  color: var(--wp--preset--color--heading, #1A1C1E);
}

.hl-prose h2 {
  font-family: inherit;
  font-size: 26px;
  font-weight: 700;
  color: var(--wp--preset--color--heading, #1A1C1E);
  line-height: 1.4;
  margin: 3rem 0 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--wp--preset--color--border, #E2E8F0);
}

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

.hl-prose h3 {
  font-family: inherit;
  font-size: 20px;
  font-weight: 600;
  color: var(--wp--preset--color--heading, #1A1C1E);
  line-height: 1.4;
  margin: 2rem 0 0.75rem;
}

.hl-prose h4 {
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  color: var(--wp--preset--color--heading, #1A1C1E);
  margin: 1.5rem 0 0.5rem;
}

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

.hl-prose ul { list-style: disc; }
.hl-prose ol { list-style: decimal; }

.hl-prose ul li::marker { color: var(--wp--preset--color--accent, #2563EB); }
.hl-prose ol li::marker { color: var(--wp--preset--color--accent, #2563EB); font-weight: 700; }

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

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

.hl-prose strong { color: var(--wp--preset--color--heading, #1A1C1E); font-weight: 700; }

.hl-prose em { font-style: italic; color: var(--wp--preset--color--body, #44474B); }

.hl-prose a {
  color: var(--wp--preset--color--accent, #2563EB);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  transition: color 0.2s, text-decoration-color 0.2s;
  font-weight: 600;
}

.hl-prose a:hover {
  color: var(--wp--preset--color--heading, #1A1C1E);
  text-decoration-color: var(--wp--preset--color--heading, #1A1C1E);
}

.hl-prose blockquote {
  border-left: 4px solid var(--wp--preset--color--accent, #2563EB);
  padding: 1.5rem 1.75rem;
  margin: 2rem 0;
  background-color: var(--wp--preset--color--surface-alt, #F2F4F6);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--wp--preset--color--heading, #1A1C1E);
  font-size: 16px;
  line-height: 1.75;
}

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

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

.hl-prose code {
  font-family: "SF Mono", Consolas, Monaco, monospace;
  background-color: var(--wp--preset--color--surface-alt, #F2F4F6);
  color: var(--wp--preset--color--accent, #2563EB);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  border: 1px solid var(--wp--preset--color--border, #E2E8F0);
}

.hl-prose pre {
  background: var(--wp--preset--color--ink, #0F172A);
  color: var(--wp--preset--color--surface, #FFFFFF);
  padding: 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 14px;
  line-height: 1.6;
}

.hl-prose pre code {
  background: none;
  color: inherit;
  border: 0;
  padding: 0;
}

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

.hl-prose th,
.hl-prose td {
  padding: 0.85rem 1rem;
  border: 1px solid var(--wp--preset--color--border, #E2E8F0);
  text-align: left;
  vertical-align: top;
}

.hl-prose th {
  background: var(--wp--preset--color--ink, #0F172A);
  color: #fff;
  font-weight: 700;
  font-family: var(--wp--preset--font-family--inter, "Inter"), "Noto Sans SC", sans-serif;
  font-size: 14px;
  letter-spacing: 0.04em;
}

.hl-prose tr:nth-child(even) td {
  background: var(--wp--preset--color--background, #F7F9FB);
}

/* First paragraph as "updated on: ..." meta · weakened style */
.hl-prose > p:first-child {
  color: var(--wp--preset--color--muted, #75777C) !important;
  font-size: 14px !important;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--wp--preset--color--border, #E2E8F0);
}

@media (max-width: 640px) {
  .hl-prose { font-size: 16px; line-height: 1.8; }
  .hl-prose h2 { font-size: 22px; margin-top: 2.25rem; }
  .hl-prose h3 { font-size: 18px; }
}

/* ==========================================================================
   8. Section underline (decorative · projects can override color)
   ========================================================================== */

.hl-section-underline {
  width: 64px;
  height: 4px;
  border-radius: 2px;
  background-color: var(--wp--preset--color--accent, #2563EB);
  margin: 0 auto;
}

/* ==========================================================================
   9. Floating TOC widget · neutral colors, projects override
   ========================================================================== */

.hl-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: var(--wp--preset--color--surface, #FFFFFF);
  border: 1px solid var(--wp--preset--color--border, #E2E8F0);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  overflow-y: auto;
  z-index: 40;
}

.hl-toc-float.is-hidden {
  opacity: 0;
  transform: translateX(-24px);
  pointer-events: none;
}

.hl-toc-float h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--wp--preset--color--accent, #2563EB);
  margin: 0 0 12px;
}

.hl-toc-float ul { list-style: none; padding: 0; margin: 0; }
.hl-toc-float li {
  margin: 6px 0;
  position: relative;
  padding-left: 10px;
  border-left: 2px solid transparent;
  transition: border-left-color 0.2s ease, padding-left 0.2s ease;
}

.hl-toc-float a {
  color: var(--wp--preset--color--heading, #1A1C1E);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.4;
  display: block;
  padding: 4px 0;
}

.hl-toc-float a:hover { color: var(--wp--preset--color--accent, #2563EB); }

.hl-toc-float li.is-active {
  border-left-color: var(--wp--preset--color--accent, #2563EB);
  padding-left: 12px;
}

.hl-toc-float li.is-active > a {
  color: var(--wp--preset--color--accent, #2563EB);
  font-weight: 600;
}

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

/* ==========================================================================
   10. Back to top button · neutral, projects override colors
   ========================================================================== */

.hl-back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--wp--preset--color--ink, #0F172A);
  color: var(--wp--preset--color--surface, #FFFFFF);
  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;
}

.hl-back-to-top:hover { transform: translateY(-2px); }
.hl-back-to-top.is-visible { display: inline-flex; }

/* ==========================================================================
   11. Breadcrumb · neutral
   ========================================================================== */

.hl-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--wp--preset--font-family--inter, "Inter"), sans-serif;
  font-size: 14px;
  color: var(--wp--preset--color--body, #44474B);
}

.hl-breadcrumb a {
  color: var(--wp--preset--color--body, #44474B);
  text-decoration: none;
}

.hl-breadcrumb a:hover { color: var(--wp--preset--color--heading, #1A1C1E); }
.hl-breadcrumb .sep { font-size: 12px; opacity: 0.5; }
.hl-breadcrumb-current {
  color: var(--wp--preset--color--heading, #1A1C1E);
  font-weight: 600;
}

/* ==========================================================================
   12. Skip-to-content (a11y · L47 baseline-required)
   ========================================================================== */

.hl-skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 99999;
  background: var(--wp--preset--color--ink, #0F172A);
  color: #fff;
  padding: 12px 16px;
  text-decoration: none;
  font-size: 14px;
  border-radius: 4px;
}

.hl-skip-link:focus {
  left: 16px;
  outline: 2px solid var(--wp--preset--color--accent, #2563EB);
  outline-offset: 2px;
}

/* ==========================================================================
   13. Focus-visible (a11y · L47 baseline-required)
   ========================================================================== */

:focus-visible {
  outline: 2px solid var(--wp--preset--color--accent, #2563EB);
  outline-offset: 2px;
  border-radius: 2px;
}
