/* 崇修堂歷史頁：時光之門、時光長卷、章回故事。只在 history.js 成功重排後（body.cx-on）生效。 */
.cx-on { --paper: #f3ede2; --paper-2: #e9e1d2; --card: #fbf8f2; --ink: #1e1c18; --muted: #686155; --line: #d9cfbe; --accent: #d0652e; --accent-ink: #a9481a; --green: #1f3a31; --sepia: #8a6a45;
  background: var(--paper); }
.cx-on main.page-main { max-width: none; padding: 0; min-height: 0; }
.cx { color: var(--ink); font-size: 18px; line-height: 1.9; }
.cx [hidden] { display: none !important; }
.cx h1, .cx h2, .cx h3 { margin: 0; }
.cx-eyebrow { font-size: 14px; letter-spacing: .26em; font-weight: 700; color: var(--accent-ink); margin: 0 0 14px; }
.cx :focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* 出場：只淡入上移；減少動態時只淡入 */
.cx .reveal { opacity: 0; transform: translateY(28px); transition: opacity .9s ease, transform .9s cubic-bezier(.2,.7,.2,1); }
.cx .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) and (min-width: 861px) { .cx .reveal { transform: none; transition: opacity .6s ease; } }

/* ---------- 1. 時光之門 ---------- */
.cx-hero { position: relative; height: 220vh; height: 220svh; background: #0f0e0c; }
.cx-hero-stage { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; display: grid; align-items: end; }
.cx-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cx-now { transform: scale(calc(1.08 - var(--p, 0) * .08)); }
.cx-then { opacity: 0; filter: grayscale(1) sepia(.35) contrast(1.05); transform: scale(calc(1 + var(--p, 0) * .06)); }
.cx-hero-stage::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,9,8,.25) 0%, rgba(10,9,8,.1) 35%, rgba(10,9,8,.82) 100%); pointer-events: none; }
.cx-hero-copy { position: relative; z-index: 1; color: #f6efe3; padding: 0 max(24px, calc(50% - 600px)) clamp(64px, 13vh, 140px); }
.cx-hero .cx-eyebrow { color: #f0a173; }
.cx-hero h1 { font-family: var(--serif); font-size: clamp(64px, 11vw, 168px); font-weight: 900; line-height: 1; letter-spacing: .04em; color: #fbf6ec; }
.cx-lead { font-size: clamp(18px, 2vw, 24px); margin: 18px 0 26px; max-width: 34em; color: rgba(246,239,227,.92); }
.cx-yearline { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; margin: 0; }
.cx-counter { font-family: var(--serif); font-size: clamp(40px, 6vw, 80px); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; color: #f0a173; }
.cx-hint { font-size: 15px; letter-spacing: .12em; color: rgba(246,239,227,.8); }
@media (prefers-reduced-motion: reduce) and (min-width: 861px) { .cx-hero { height: 100vh; height: 100svh; } .cx-now, .cx-then { transform: none; } }

/* ---------- 章節目錄 ---------- */
.cx-index { position: fixed; z-index: 30; left: 20px; top: 50%; transform: translate(-12px, -50%); opacity: 0; pointer-events: none; transition: opacity .4s, transform .4s; }
.cx-index.show { opacity: 1; transform: translate(0, -50%); pointer-events: auto; }
.cx-index.show.at-end { opacity: 0; pointer-events: none; }
.cx-index-toggle { display: none; }
.cx-index ol { list-style: none; margin: 0; padding: 10px 0; display: grid; gap: 2px; max-height: 80vh; overflow: auto; }
.cx-index a { display: grid; grid-template-columns: 52px 1fr; align-items: baseline; gap: 6px; width: 210px; padding: 6px 12px; border-radius: 10px; text-decoration: none; color: var(--muted); font-size: 14px; line-height: 1.5; transition: background .2s, color .2s; }
.cx-index a b { font-size: 12px; font-weight: 700; color: var(--accent-ink); opacity: .7; }
.cx-index a:hover { background: rgba(255,255,255,.6); color: var(--ink); }
.cx-index a.on { background: var(--ink); color: #fff; }
.cx-index a.on b { color: #f0a173; opacity: 1; }
@media (max-width: 1680px) { .cx-index { left: 10px; } .cx-index a { width: 46px; height: 40px; grid-template-columns: 1fr; place-items: center; font-size: 0; padding: 0; } .cx-index a b { font-size: 0; opacity: 1; } .cx-index a b::after { content: attr(data-short); font-size: 14px; white-space: nowrap; color: var(--accent-ink); } .cx-index a:hover, .cx-index a.on { background: var(--ink); } .cx-index a:hover b::after, .cx-index a.on b::after { color: #f0a173; } }

/* ---------- 2. 時光長卷 ---------- */
.cx-chrono { padding: 15vh max(24px, calc(50% - 600px)) 10vh; }
.cx-chrono-head h2 { font-family: var(--serif); font-size: clamp(40px, 6vw, 84px); font-weight: 900; line-height: 1.1; }
.cx-chrono-head h2 span { display: block; font-size: clamp(20px, 2.4vw, 30px); font-weight: 700; color: var(--muted); margin-top: 14px; }
.cx-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 30px; }
.cx-filters button { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font: inherit; font-size: 15px; font-weight: 700; color: var(--ink); cursor: pointer; transition: background .2s, color .2s, border-color .2s; }
.cx-filters button i { font-style: normal; font-weight: 400; color: var(--muted); margin-left: 4px; }
.cx-filters button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.cx-filters button.on i { color: rgba(255,255,255,.7); }
.cx-map { margin: 34px 0 10px; }
.cx-bars { display: flex; align-items: flex-end; gap: 3px; height: 74px; }
.cx-bar { flex: 1; height: 100%; display: flex; align-items: flex-end; padding: 0; border: 0; background: none; cursor: pointer; }
.cx-bar i { display: block; width: 100%; height: calc(var(--h) * 100%); border-radius: 3px 3px 0 0; background: var(--line); transition: background .3s, height .3s; }
.cx-bar:not([disabled]) i { background: #c9b79c; }
.cx-bar:not([disabled]):hover i { background: var(--accent); }
.cx-bar.on i { background: var(--accent); }
.cx-bar.dim i { background: var(--paper-2); }
.cx-bar[disabled] { cursor: default; }
.cx-map-axis { display: flex; justify-content: space-between; gap: 10px; margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.cx-map-axis span:nth-child(2) { color: var(--accent-ink); font-weight: 700; }
.cx-chrono-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.3fr); gap: 56px; margin-top: 50px; }
.cx-year { position: sticky; top: 22vh; align-self: start; display: grid; gap: 6px; }
.cx-y { font-family: var(--serif); font-size: clamp(90px, 13vw, 190px); font-weight: 900; line-height: .9; letter-spacing: -.03em; color: var(--ink); font-variant-numeric: tabular-nums; }
.cx-y.flip { animation: cx-flip .55s cubic-bezier(.2,.7,.2,1); }
@keyframes cx-flip { from { opacity: 0; transform: translateY(24px); } }
.cx-roc { font-family: var(--serif); font-size: clamp(20px, 2vw, 28px); font-weight: 700; color: var(--accent-ink); }
.cx-gz { font-size: 16px; color: var(--muted); letter-spacing: .2em; }
.cx-events { list-style: none; margin: 0; padding: 0 0 0 30px; border-left: 2px solid var(--line); }
.cx-decade { position: relative; margin: 34px 0 14px -30px; padding-left: 30px; }
.cx-decade:first-child { margin-top: 0; }
.cx-decade span { display: inline-block; font-size: 13px; font-weight: 700; letter-spacing: .2em; color: #fff; background: var(--green); padding: 4px 12px; border-radius: 999px; }
.cx-event { position: relative; padding: 20px 24px; margin: 0 0 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; transition: border-color .3s, box-shadow .3s, opacity .9s, transform .9s; }
.cx-event::before { content: ""; position: absolute; left: -38px; top: 28px; width: 12px; height: 12px; border-radius: 50%; background: var(--paper); border: 2px solid #b9a688; transition: background .3s, border-color .3s, transform .3s; }
.cx-event.is-current { border-color: var(--accent); box-shadow: 0 14px 34px rgba(60,45,25,.12); }
.cx-event.is-current::before { background: var(--accent); border-color: var(--accent); transform: scale(1.3); }
.cx-date { margin: 0; font-size: 14px; font-weight: 700; color: var(--accent-ink); letter-spacing: .04em; }
.cx-date span { margin-left: 10px; color: var(--muted); font-weight: 400; }
.cx-text { margin: 6px 0 0; font-size: 18px; line-height: 1.85; }
.cx-tags { margin: 10px 0 0; display: flex; gap: 6px; }
.cx-tags span { font-size: 12.5px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--paper-2); color: var(--ink); }
.cx-tags [data-tag="考驗"] { background: #f3dcd0; color: #8c2f12; }
.cx-tags [data-tag="顯化"] { background: #e5dcef; color: #4b3471; }
.cx-tags [data-tag="建設"] { background: #e3ece6; color: var(--green); }
.cx-tags [data-tag="法會班程"] { background: #f6ebd2; color: #7a5410; }

/* ---------- 3. 章回故事 ---------- */
.cx-chapter { padding: 14vh max(24px, calc(50% - 600px)) 6vh; border-top: 1px solid var(--line); }
.cx-chapter:nth-of-type(even) { background: #efe8db; }
.cx-ch-head { margin-bottom: 44px; }
.cx-ch-head span { display: block; font-family: var(--serif); font-size: clamp(18px, 1.8vw, 22px); font-weight: 700; letter-spacing: .3em; color: var(--accent-ink); }
.cx-ch-head h2 { font-family: var(--serif); font-size: clamp(36px, 5vw, 68px); font-weight: 900; line-height: 1.2; margin-top: 8px; color: var(--ink); }
.cx-ch-body { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap: 56px; align-items: start; }
.cx-chapter:nth-of-type(odd) .cx-ch-photo { order: 2; }
.cx-chapter.no-photo .cx-ch-body { grid-template-columns: minmax(0, 760px); }
.cx-ch-photo { position: sticky; top: 110px; }
.cx-ch-text { font-size: 18px; line-height: 2.05; }
.cx-ch-text > p:first-of-type::first-letter { float: left; font-family: var(--serif); font-size: 3.4em; line-height: .9; font-weight: 900; margin: .08em .12em 0 0; color: var(--accent-ink); }
.cx-ch-text p { margin: 0 0 1.2em; }
.cx-ch-text h3 { font-family: var(--serif); font-size: 24px; margin: 1.6em 0 .6em; color: var(--green); }
.cx-ch-text a { color: var(--accent-ink); }
.cx-ch-text small { color: var(--muted); font-size: 14px; }
.cx-ch-text .video-link { border-radius: 14px; background: var(--green); }
.cx-ch-text figure { margin: 1.6em 0; }
.cx-photo { margin: 0; background: #fffdf8; padding: 12px 12px 14px; border-radius: 4px; box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 24px 50px rgba(60,45,25,.18); transform: rotate(-.8deg); }
.cx-chapter:nth-of-type(odd) .cx-photo { transform: rotate(.8deg); }
.cx-photo img { width: 100%; height: auto; display: block; filter: sepia(.18) contrast(1.03); cursor: zoom-in; border-radius: 2px; }
.cx-photo figcaption { font-family: var(--serif); font-size: 14px; color: var(--muted); text-align: center; margin-top: 10px; }
.cx .cx-photo.reveal { transform: translateY(28px) rotate(-.8deg); }
.cx .cx-photo.reveal.in { transform: rotate(-.8deg); }
.cx-strip { display: flex; gap: 22px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 34px 6px 26px; margin-top: 30px; scrollbar-width: thin; }
.cx-strip .cx-photo { flex: 0 0 min(320px, 70vw); scroll-snap-align: start; }
.cx-strip .cx-photo img { aspect-ratio: 4 / 3; object-fit: cover; }

/* ---------- 4. 結尾 ---------- */
.cx-end { padding: 18vh 24px; text-align: center; background: var(--green); color: #f3ede2; }
.cx-end .cx-eyebrow { color: #f0a173; }
.cx-end h2 { font-family: var(--serif); font-size: clamp(36px, 5vw, 68px); font-weight: 900; line-height: 1.2; }
.cx-end p { max-width: 36em; margin: 20px auto 34px; color: rgba(243,237,226,.88); }
.cx-end-links { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.cx-btn { display: inline-flex; align-items: center; min-height: 54px; padding: 0 28px; border-radius: 10px; background: #f3ede2; color: var(--ink) !important; font-weight: 700; text-decoration: none !important; }
.cx-btn.ghost { background: transparent; color: #f3ede2 !important; border: 1px solid rgba(243,237,226,.6); }

/* ---------- 燈箱 ---------- */
.cx-lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(12,11,10,.94); color: #f3ede2; }
.cx-lightbox[open] { display: grid; place-items: center; }
.cx-lightbox img { max-width: min(92vw, 1400px); max-height: 80vh; object-fit: contain; }
.cx-lightbox p { position: absolute; left: 0; right: 0; bottom: 22px; text-align: center; font-size: 15px; margin: 0; padding: 0 70px; }
.cx-lightbox button { position: absolute; width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 28px; cursor: pointer; }
.cx-lb-prev { left: 18px; top: 50%; } .cx-lb-next { right: 18px; top: 50%; } .cx-lb-close { right: 18px; top: 18px; }

/* ---------- 手機 ---------- */
@media (max-width: 860px) {
  .cx { font-size: 17px; }
  .cx-hero { height: 180vh; height: 180svh; }
  .cx-chrono { padding-top: 10vh; }
  .cx-chrono-grid { grid-template-columns: 1fr; gap: 0; margin-top: 30px; }
  /* 手機：年份改成頂端固定的小橫條 */
  .cx-year { top: 64px; z-index: 5; grid-template-columns: auto 1fr; align-items: baseline; gap: 4px 12px; padding: 10px 14px; margin: 0 -10px 18px; background: rgba(243,237,226,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); border-radius: 0 0 12px 12px; }
  .cx-y { font-size: 44px; grid-row: span 2; }
  .cx-roc { font-size: 16px; } .cx-gz { font-size: 13px; }
  .cx-events { padding-left: 22px; }
  .cx-decade { margin-left: -22px; padding-left: 22px; }
  .cx-event { padding: 16px 18px; } .cx-event::before { left: -30px; }
  .cx-text { font-size: 17px; }
  .cx-bars { height: 56px; gap: 2px; }
  .cx-chapter { padding-top: 10vh; }
  .cx-ch-body, .cx-chapter.no-photo .cx-ch-body { grid-template-columns: 1fr; gap: 30px; }
  .cx-chapter:nth-of-type(odd) .cx-ch-photo { order: 0; }
  .cx-ch-photo { position: static; }
  .cx-ch-text { font-size: 17px; }
  /* 手機目錄：底部小膠囊，點開往上展開 */
  .cx-index { left: 12px; right: 12px; top: auto; bottom: 14px; transform: translateY(12px); }
  .cx-index.show { transform: none; }
  .cx-index-toggle { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 0 18px; border: 0; border-radius: 999px; background: rgba(30,28,24,.92); color: #fff; font: inherit; font-size: 15px; font-weight: 700; box-shadow: 0 12px 30px rgba(0,0,0,.25); }
  .cx-index-now { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cx-index-toggle i { font-style: normal; font-size: 13px; color: #f0a173; flex: none; }
  .cx-index ol { display: none; position: absolute; left: 0; right: 0; bottom: 60px; max-height: 60vh; background: var(--card); border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.25); padding: 8px; }
  .cx-index.open ol { display: grid; }
  .cx-index a, .cx-index a:hover { width: auto; height: auto; grid-template-columns: 64px 1fr; place-items: baseline start; font-size: 15px; padding: 10px 12px; justify-items: start; background: none; }
  .cx-index a b { font-size: 12px; }
  .cx-index a b::after { content: none; }
  .cx-index a.on { background: var(--ink); }
  .cx-lightbox button.cx-lb-prev, .cx-lightbox button.cx-lb-next { top: auto; bottom: 60px; }
}
