/* =========================================================
   layout.css — page frame: container, sections, header/nav, footer
   ========================================================= */

/* ----- Container & section shells ----- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.section { padding: 96px 0; }
.section--dark  { background: var(--green-dark); color: var(--white); }
.section--light { background: var(--green-light); color: var(--green-deepest); }
.section--light h2 { color: var(--green-darker); }

.section-title { font-size: clamp(2rem, 4.5vw, 3rem); text-align: center; margin-bottom: .6em; }
/* small gold rule under every section title */
.section-title::after {
  content: ""; display: block;
  width: 56px; height: 3px; margin: 18px auto 0;
  background: var(--gold); border-radius: 2px;
}
.section-intro { text-align: center; max-width: 620px; margin: 0 auto 48px; opacity: .92; }

/* Shared card grid: 3 → 2 → 1 columns */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); list-style: none; padding: 0; margin: 0; }

/* ----- Header / navigation ----- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: rgba(53, 122, 70, .92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: box-shadow .3s, background-color .3s;
}
.site-header.is-scrolled { background: rgba(36, 87, 47, .96); box-shadow: 0 4px 20px rgba(0, 0, 0, .18); }
.site-header .container { max-width: 1320px; }   /* wider than the page so the full English nav (≈1240px) fits on one line */
.nav { display: flex; align-items: center; gap: 20px; height: 100%; }
.nav__brand {
  display: flex; align-items: center; gap: 12px; text-decoration: none;
  font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: .06em;
}
/* square logo tile (same image as the hero) with rounded corners — 10px ≈ the hero card's 14px scaled to 44px */
.nav__brand img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; box-shadow: 0 0 0 1px rgba(255,255,255,.25), 0 2px 6px rgba(0,0,0,.15); }
.nav__links {
  display: flex; gap: 18px; list-style: none; margin: 0 0 0 auto; padding: 0;
  font-size: 14px; font-weight: 500; white-space: nowrap;
}
.nav__links a {
  position: relative; text-decoration: none; padding: 6px 0; opacity: .88;
  transition: opacity .2s;
}
.nav__links a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--gold); border-radius: 2px;
  transform: scaleX(0); transform-origin: left; transition: transform .25s var(--ease);
}
.nav__links a:hover, .nav__links a:focus-visible, .nav__links a[aria-current="true"] { opacity: 1; }
.nav__links a:hover::after,
.nav__links a:focus-visible::after,
.nav__links a[aria-current="true"]::after { transform: scaleX(1); }
.nav__cta { padding: 9px 20px; font-size: 14px; box-shadow: none; }
/* radius 12px = logo tile radius (6px) + inner padding (6px), so the button corners run parallel to the logo's */
.nav__follow { gap: 5px; padding: 6px 6px 6px 16px; white-space: nowrap; border-radius: 12px; }
.nav__brand, .nav__follow, .lang-switch { flex-shrink: 0; }

/* Language slider 中 | EN (assets/js/i18n.js). Same 12px radius / 36px height as the Follow button. */
.lang-switch {
  position: relative;
  display: inline-grid; grid-template-columns: 1fr 1fr; align-items: center;
  width: 78px; height: 36px; padding: 3px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 12px;
  color: var(--white);
  font: 700 13px/1 var(--font-body);
  cursor: pointer;
}
.lang-switch:hover { background: rgba(255, 255, 255, .16); }
.lang-switch__thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px;
  width: calc(50% - 3px);
  background: var(--white); border-radius: 9px;   /* 12px outer − 3px padding */
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
  transition: transform .25s var(--ease);
}
html:lang(en) .lang-switch__thumb { transform: translateX(100%); }
.lang-switch__opt { position: relative; text-align: center; opacity: .75; transition: color .25s, opacity .25s; }
html:lang(zh) .lang-switch__opt--zh,
html:lang(en) .lang-switch__opt--en { color: var(--green-deepest); opacity: 1; }
.nav__toggle {
  display: none; margin-left: auto;
  background: none; border: 0; color: var(--white); cursor: pointer; padding: 8px;
}
.nav__toggle span { display: block; width: 26px; height: 2px; margin: 6px 0; background: currentColor; border-radius: 2px; transition: transform .25s, opacity .25s; }
.nav__toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.nav__toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav__toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* ----- Footer ----- */
.site-footer { background: var(--green-darker); padding: 32px 0; font-size: 15px; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; align-items: center; }
.site-footer a { text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.4); transition: color .2s, border-color .2s; }
.site-footer a:hover { color: var(--gold-light); border-color: var(--gold-light); }
/* [小红书 logo] Glance_瞥见山谷 — underline only the name, not the logo tile */
.site-footer .footer-xhs { display: inline-flex; align-items: center; gap: 10px; border-bottom: 0; }
.footer-xhs__name { border-bottom: 1px solid rgba(255,255,255,.4); transition: border-color .2s; }
.footer-xhs:hover .footer-xhs__name { border-color: var(--gold-light); }

/* ----- Responsive ----- */
/* Compact header (hamburger menu): <html class="nav-compact">.
   Not a fixed breakpoint — main.js (initNavFit) measures whether the full link row fits,
   so it adapts to the current language (Chinese labels are much shorter than English).
   The inline <head> script adds the class below 1100px before first paint (no flicker on phones).
   Without JS the full row simply stays. */
.nav-compact .nav__toggle { display: block; order: 3; margin-left: 2px; }
.nav-compact .nav__cta { display: none; }
.nav-compact .lang-switch { order: 1; margin-left: auto; width: 70px; height: 32px; font-size: 12px; }
.nav-compact .lang-switch__thumb { border-radius: 8px; }
/* keep the Xiaohongshu button, but as just the logo tile next to the menu icon */
.nav-compact .nav__follow { display: inline-flex; order: 2; padding: 6px; background: none; box-shadow: none; }
.nav-compact .nav__follow:hover, .nav-compact .nav__follow:focus-visible { background: none; box-shadow: none; transform: none; }
.nav-compact .nav__follow-text { display: none; }
.nav-compact .nav__links {
  display: none;
  position: absolute; top: var(--nav-h); left: 0; right: 0;
  flex-direction: column; gap: 0; margin: 0;
  background: var(--green-darker);
  box-shadow: 0 12px 24px rgba(0,0,0,.2);
}
.nav-compact .nav__links.is-open { display: flex; }
.nav-compact .nav__links a { display: block; padding: 14px 20px; border-bottom: 1px solid rgba(255,255,255,.1); opacity: 1; }
.nav-compact .nav__links a::after { left: 20px; right: auto; width: 32px; bottom: 8px; }
.nav-compact .nav { gap: 8px; }
.nav-compact .nav__brand { gap: 8px; font-size: 20px; }
.nav-compact .nav__toggle { padding: 8px 4px; }
/* very narrow phones (e.g. 320px): logo only, so slider + Xiaohongshu + menu still fit */
@media (max-width: 374.98px) {
  .nav-compact .nav__brand span { display: none; }
}
@media (max-width: 860px) {
  .section { padding: 64px 0; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  :root { --gap: 20px; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-3.grid-3--keep-2 { grid-template-columns: repeat(2, 1fr); gap: 14px; }
}
