/*
Theme Name: Blocksy Child - 小院
Template: blocksy
Description: diibo的小院 —— 古典小院风格子主题（宣纸底、松烟墨、朱砂印、霞鹜文楷自托管）
Author: Diibo
Version: 2.0
*/

/* ============================================================
   一、全局调色板与字体（覆盖 Blocksy 自定义器变量）
   :root:root 双写提高优先级，确保压过父主题动态 global.css
   ============================================================ */
:root:root {
  /* 传统色 */
  --xy-paper: #f6f2e9;        /* 宣纸 */
  --xy-paper-card: #fbf8f1;   /* 浅纸（卡片） */
  --xy-paper-deep: #efe8d9;   /* 深纸（分区底） */
  --xy-ink: #33302a;          /* 松烟墨 */
  --xy-ink-soft: #4a443a;     /* 次墨（正文） */
  --xy-tea: #7a7263;          /* 茶褐（辅助文字） */
  --xy-cinnabar: #9e3b2c;     /* 朱砂 */
  --xy-cinnabar-deep: #7d2d21;/* 朱砂深（悬停） */
  --xy-indigo: #46564f;       /* 黛青 */
  --xy-hairline: #d9cfba;     /* 茶色细框 */

  /* 映射到 Blocksy 调色板 1-8 */
  --theme-palette-color-1: var(--xy-cinnabar);
  --theme-palette-color-2: var(--xy-cinnabar-deep);
  --theme-palette-color-3: var(--xy-ink-soft);
  --theme-palette-color-4: var(--xy-ink);
  --theme-palette-color-5: var(--xy-hairline);
  --theme-palette-color-6: var(--xy-paper-deep);
  --theme-palette-color-7: var(--xy-paper);
  --theme-palette-color-8: var(--xy-paper-card);

  /* 字体：自托管霞鹜文楷，系统宋楷兜底，无任何外部请求 */
  --theme-font-family: 'LXGW WenKai Screen', 'Songti SC', 'STSong',
    'KaiTi', 'STKaiti', 'Noto Serif CJK SC', serif;

  --theme-text-color: var(--xy-ink-soft);
  --theme-headings-color: var(--xy-ink);
  --theme-link-initial-color: var(--xy-cinnabar);
  --theme-link-hover-color: var(--xy-cinnabar-deep);
  --theme-border-color: var(--xy-hairline);
  --theme-selection-text-color: var(--xy-paper);
  --theme-selection-background-color: var(--xy-cinnabar);

  color-scheme: light;
}

html {
  background-color: var(--xy-paper);
}

body {
  font-size: 17px;
  line-height: 1.9;
  letter-spacing: 0.02em;
  background-color: var(--xy-paper);
  /* 宣纸纤维质感：极淡的横向纹理 */
  background-image: repeating-linear-gradient(
    0deg,
    rgba(122, 114, 99, 0.022) 0px,
    rgba(122, 114, 99, 0.022) 1px,
    transparent 1px,
    transparent 3px
  );
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 400;
  letter-spacing: 0.06em;
}

::selection {
  background: var(--xy-cinnabar);
  color: var(--xy-paper);
}

:focus-visible {
  outline: 2px solid var(--xy-cinnabar);
  outline-offset: 2px;
}

/* ============================================================
   二、页头：纸色横匾 + 墨字 + 朱砂点睛
   ============================================================ */
[data-header*="type-1"] .ct-header [data-row*="middle"] {
  --height: 96px;
  background-color: var(--xy-paper);
  border-bottom: 1px solid var(--xy-hairline);
  box-shadow: 0 1px 0 rgba(158, 59, 44, 0.12),
    0 3px 0 -1px rgba(217, 207, 186, 0.55);
}

.site-branding .site-title a {
  color: var(--xy-ink);
  letter-spacing: 0.08em;
}

.site-branding .site-description {
  color: var(--xy-tea);
  letter-spacing: 0.35em;
}

.site-branding .site-description::before,
.site-branding .site-description::after {
  content: '·';
  color: var(--xy-cinnabar);
  margin: 0 0.4em;
}

/* 菜单：以 #header 作用域压过自定义器注入的变量（原值为白底主题设计） */
#header [data-id="menu"] > ul > li > a {
  --theme-font-weight: 400;
  --theme-font-size: 15px;
  --theme-text-transform: none;
  --theme-letter-spacing: 0.14em;
  --theme-link-initial-color: var(--xy-ink-soft);
}

#header [data-id="menu"] > ul > li:hover > a,
#header [data-id="menu"] > ul > li.current-menu-item > a {
  color: var(--xy-cinnabar);
}

#header [data-id="menu"] .sub-menu {
  --dropdown-divider: 1px dashed rgba(217, 207, 186, 0.7);
  --theme-border-radius: 0;
  --theme-box-shadow: 0 14px 30px -12px rgba(51, 48, 42, 0.28);
  background-color: var(--xy-paper-card);
  border: 1px solid var(--xy-hairline);
  min-width: 176px;
  padding: 8px;
}

#header [data-id="menu"] .sub-menu .ct-menu-link {
  --theme-link-initial-color: var(--xy-ink-soft);
  --theme-font-size: 14px;
  --theme-font-weight: 400;
  padding: 9px 16px;
  letter-spacing: 0.12em;
}

#header [data-id="menu"] .sub-menu .menu-item {
  transition: background-color 0.2s ease;
}

#header [data-id="menu"] .sub-menu .menu-item:hover {
  background-color: var(--xy-paper-deep);
}

#header [data-id="menu"] .sub-menu .menu-item:hover .ct-menu-link {
  color: var(--xy-cinnabar);
}

.ct-header [data-id="trigger"] svg,
.ct-header .ct-icon {
  fill: var(--xy-ink-soft);
}

/* ============================================================
   三、首页 Hero：院门月洞 + 竖签「吃茶去」+ 朱砂小印
   ============================================================ */
.xy-hero {
  padding: clamp(40px, 7vw, 84px) 20px 30px;
}

.xy-hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px) auto;
  gap: clamp(28px, 5vw, 64px);
  align-items: center;
}

.xy-hero-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
}

.xy-hero-title {
  margin: 0;
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.5;
  color: var(--xy-ink);
  letter-spacing: 0.08em;
}

.xy-hero-source {
  margin: -8px 0 0;
  font-size: 14px;
  letter-spacing: 0.18em;
  color: var(--xy-tea);
}

.xy-hero-desc {
  margin: 0;
  max-width: 34em;
  color: var(--xy-ink-soft);
  line-height: 2.1;
}

/* 月洞门：圆形取景的院门照片 */
.xy-hero-figure {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--xy-hairline);
  box-shadow: 0 0 0 6px var(--xy-paper), 0 0 0 7px var(--xy-hairline),
    0 18px 40px -18px rgba(51, 48, 42, 0.35);
  background-size: cover;
  background-position: 52% 51%;
}

/* 竖排签条 */
.xy-tagline {
  writing-mode: vertical-rl;
  margin: 0;
  padding: 18px 10px;
  font-size: 20px;
  letter-spacing: 0.42em;
  color: var(--xy-ink);
  background: var(--xy-paper-card);
  border: 1px solid var(--xy-hairline);
  box-shadow: 2px 3px 0 rgba(217, 207, 186, 0.5);
  align-self: start;
}

.xy-tagline::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  margin: 0 auto 12px;
  background: var(--xy-cinnabar);
  border-radius: 50%;
}

/* ============================================================
   四、分区标题与分隔纹样
   ============================================================ */
.xy-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) 20px 0;
}

.xy-section-title {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0 0 26px;
  font-size: clamp(22px, 3vw, 28px);
  color: var(--xy-ink);
}

.xy-section-title em {
  font-style: normal;
  color: var(--xy-cinnabar);
}

.xy-section-title small {
  font-size: 13px;
  letter-spacing: 0.3em;
  color: var(--xy-tea);
}

.xy-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--xy-hairline), transparent);
  transform: translateY(-6px);
}

/* ─── ❖ ─── 分隔 */
.xy-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1100px;
  margin: clamp(36px, 6vw, 64px) auto 0;
  padding: 0 20px;
  color: var(--xy-cinnabar);
}

.xy-divider::before,
.xy-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--xy-hairline);
}

/* ============================================================
   五、院内景致 · 花窗影壁（分类导览）
   ============================================================ */
.xy-wall {
  position: relative;
  margin-top: 34px;
  background: linear-gradient(180deg, #f1ebdd, #ece4d2);
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px var(--xy-hairline);
  padding: clamp(30px, 4vw, 50px) clamp(16px, 3vw, 44px) clamp(34px, 4vw, 54px);
}

/* 檐口筒瓦与檐板：伪元素绘制，超出墙体的部分靠 margin-top 留白 */
.xy-wall::before {
  content: '';
  position: absolute;
  top: -20px;
  left: 10px;
  right: 10px;
  height: 20px;
  background: radial-gradient(circle at 10px 0, var(--xy-ink-soft) 9.5px, transparent 10.5px)
    repeat-x;
  background-size: 21px 20px;
}

.xy-wall::after {
  content: '';
  position: absolute;
  top: -25px;
  left: 4px;
  right: 4px;
  height: 6px;
  background: var(--xy-ink);
  border-radius: 3px;
}

.xy-gates {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 208px));
  align-items: end;
  justify-content: center;
  gap: clamp(22px, 3.4vw, 40px);
  max-width: 1020px;
  margin: 0 auto;
}

.xy-gate {
  display: block;
  text-decoration: none;
}

/* 整窗为内联 SVG：形制、棂格、匾心、题名皆在窗内；drop-shadow 沿异形轮廓投影 */
.xy-gate-scene {
  display: block;
  width: min(100%, 190px);
  margin: 0 auto;
  color: var(--xy-tea);
  transition: transform 0.35s ease, color 0.35s ease;
}

.xy-gate-scene svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 3px 7px rgba(51, 48, 42, 0.12));
  transition: filter 0.35s ease;
}

.xy-gate-scene text {
  font-family: inherit;
}

.xy-window-name {
  fill: var(--xy-ink);
  transition: fill 0.25s ease;
}

.xy-gate:hover .xy-gate-scene,
.xy-gate:focus-visible .xy-gate-scene {
  transform: translateY(-5px);
  color: var(--xy-ink);
}

.xy-gate:hover .xy-gate-scene svg,
.xy-gate:focus-visible .xy-gate-scene svg {
  filter: drop-shadow(0 10px 18px rgba(51, 48, 42, 0.18));
}

.xy-gate:hover .xy-window-name,
.xy-gate:focus-visible .xy-window-name {
  fill: var(--xy-cinnabar);
}

.xy-gate:focus-visible {
  outline: none;
}

/* ============================================================
   六、案头新笺（首篇信笺大卡 + 余下窄行）
   ============================================================ */
.xy-letter {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  margin-bottom: 18px;
  background: var(--xy-paper-card);
  border: 1px solid var(--xy-hairline);
  outline: 1px solid rgba(217, 207, 186, 0.45);
  outline-offset: 3px;
  transition: border-color 0.25s ease, outline-color 0.25s ease,
    box-shadow 0.25s ease;
}

.xy-letter:hover {
  border-color: var(--xy-cinnabar);
  outline-color: rgba(158, 59, 44, 0.35);
  box-shadow: 0 14px 28px -14px rgba(51, 48, 42, 0.28);
}

.xy-letter-figure {
  position: relative;
  display: block;
  min-height: 250px;
  overflow: hidden;
  border-right: 1px solid var(--xy-hairline);
  background: var(--xy-paper-deep);
}

.xy-letter-figure img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 无图占位：淡墨「笺」字 */
.xy-letter-figure.is-blank::after {
  content: '笺';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 76px;
  color: rgba(70, 86, 79, 0.16);
}

.xy-letter-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(22px, 3vw, 34px) clamp(20px, 3vw, 38px);
}

.xy-letter-kicker {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.xy-letter-kicker .xy-cat {
  color: var(--xy-tea);
}

/* 朱砂小印：日期钤在笺首 */
.xy-seal {
  display: inline-grid;
  place-items: center;
  min-width: 46px;
  height: 46px;
  padding: 0 7px;
  border: 1.5px solid var(--xy-cinnabar);
  border-radius: 2px;
  color: var(--xy-cinnabar);
  font-size: 13.5px;
  line-height: 1.25;
  letter-spacing: 0.04em;
  transform: rotate(-3deg);
  box-shadow: inset 0 0 0 1px rgba(158, 59, 44, 0.16);
}

.xy-letter-title {
  margin: 0;
  font-size: clamp(21px, 2.4vw, 26px);
  line-height: 1.5;
  letter-spacing: 0.03em;
}

.xy-letter-title a {
  color: var(--xy-ink);
  text-decoration: none;
}

.xy-letter-title a:hover {
  color: var(--xy-cinnabar);
}

.xy-letter-excerpt {
  margin: 0;
  font-size: 15px;
  line-height: 2;
  color: var(--xy-tea);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.xy-note {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 15px 8px;
  border-bottom: 1px dashed var(--xy-hairline);
}

.xy-note-date {
  flex: none;
  font-size: 13px;
  color: var(--xy-tea);
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

.xy-note-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 16.5px;
  line-height: 1.7;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.xy-note-title a {
  color: var(--xy-ink);
  text-decoration: none;
  transition: color 0.2s ease;
}

.xy-note-title a:hover {
  color: var(--xy-cinnabar);
}

.xy-note-cat {
  flex: none;
  padding: 3px 10px;
  border: 1px solid var(--xy-hairline);
  border-radius: 999px;
  font-size: 12px;
  color: var(--xy-tea);
  letter-spacing: 0.06em;
}

.xy-more {
  margin-top: 34px;
  text-align: center;
}

.xy-more a {
  display: inline-block;
  padding: 10px 34px;
  border: 1px solid var(--xy-hairline);
  background: var(--xy-paper-card);
  color: var(--xy-ink-soft);
  text-decoration: none;
  letter-spacing: 0.3em;
  transition: border-color 0.25s ease, color 0.25s ease;
}

.xy-more a:hover {
  border-color: var(--xy-cinnabar);
  color: var(--xy-cinnabar);
}

.xy-empty {
  padding: 60px 0;
  text-align: center;
  color: var(--xy-tea);
  letter-spacing: 0.2em;
}

/* ============================================================
   七、归档/文章列表卡片（Blocksy 原生结构轻改）
   ============================================================ */
.entries[data-archive] .entry-card {
  background: var(--xy-paper-card);
  border: 1px solid var(--xy-hairline);
  border-radius: 0;
  transition: transform 0.25s ease, border-color 0.25s ease;
}

.entries[data-archive] .entry-card:hover {
  transform: translateY(-3px);
  border-color: var(--xy-cinnabar);
}

.entries[data-archive] .entry-card .card-content {
  padding: 18px 20px;
}

/* ============================================================
   八、正文页（single/page）阅读体验
   ============================================================ */
.entry-content {
  font-size: 17px;
  line-height: 2.05;
  color: var(--xy-ink-soft);
}

.entry-content h2,
.entry-content h3 {
  color: var(--xy-ink);
  margin-top: 1.8em;
}

.entry-content h2::before {
  content: '§ ';
  color: var(--xy-cinnabar);
  font-size: 0.75em;
  vertical-align: 0.15em;
  margin-right: 0.2em;
}

.entry-content a {
  color: var(--xy-cinnabar);
  text-decoration: underline;
  text-decoration-color: rgba(158, 59, 44, 0.4);
  text-underline-offset: 4px;
}

.entry-content a:hover {
  text-decoration-color: var(--xy-cinnabar);
}

.entry-content blockquote {
  margin: 1.6em 0;
  padding: 14px 22px;
  background: var(--xy-paper-deep);
  border-left: 3px solid var(--xy-cinnabar);
  color: var(--xy-ink-soft);
}

.entry-content blockquote p {
  margin: 0.2em 0;
}

.entry-content hr {
  border: none;
  height: 1px;
  margin: 2.4em auto;
  width: 60%;
  background: linear-gradient(
    to right,
    transparent,
    var(--xy-hairline),
    transparent
  );
}

.entry-content img {
  border-radius: 2px;
}

.wp-block-code,
pre {
  background: #2b2823;
  color: #e8e2d4;
  border-radius: 2px;
}

.ct-post-meta,
.entry-meta {
  color: var(--xy-tea);
}

/* ============================================================
   九、按钮 → 素笺描边式
   ============================================================ */
.ct-button,
button[type="submit"],
.wp-block-button__link {
  background: transparent !important; /* Blocksy 内联按钮底色需压制 */
  color: var(--xy-cinnabar) !important;
  border: 1px solid var(--xy-cinnabar);
  border-radius: 0;
  letter-spacing: 0.25em;
  transition: background 0.25s ease, color 0.25s ease;
}

.ct-button:hover,
button[type="submit"]:hover,
.wp-block-button__link:hover {
  background: var(--xy-cinnabar) !important;
  color: var(--xy-paper) !important;
}

/* ============================================================
   十、搜索弹层 / 抽屉：墨色反转
   ============================================================ */
#search-modal,
#offcanvas .ct-panel-inner {
  background-color: rgba(38, 35, 30, 0.98) !important;
}

#search-modal input,
#offcanvas a {
  color: var(--xy-paper) !important;
}

#search-modal ::placeholder {
  color: rgba(246, 242, 233, 0.5);
}

/* ============================================================
   十一、页脚：庭院深深
   ============================================================ */
.ct-footer {
  background: var(--xy-paper);
  border-top: 1px solid var(--xy-hairline);
  box-shadow: inset 0 1px 0 rgba(158, 59, 44, 0.1);
}

.ct-footer-copyright {
  text-align: center;
  color: var(--xy-tea);
  letter-spacing: 0.18em;
  font-size: 14px;
}

.ct-footer-copyright a {
  color: var(--xy-cinnabar);
}

/* ============================================================
   十二、响应式
   ============================================================ */
@media (max-width: 1000px) {
  .xy-hero-inner {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .xy-hero-figure {
    display: none;
  }

  .xy-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  body {
    font-size: 16px;
  }

  .xy-hero-inner {
    grid-template-columns: minmax(0, 1fr);
  }

  .xy-tagline {
    writing-mode: horizontal-tb;
    align-self: flex-start;
    padding: 8px 16px;
    letter-spacing: 0.42em;
  }

  .xy-tagline::before {
    display: inline-block;
    vertical-align: middle;
    margin: 0 10px 2px 0;
  }

  .xy-gates {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px 14px;
  }

  .xy-gate:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .xy-gate-scene {
    width: min(100%, 148px);
  }

  .xy-letter {
    grid-template-columns: 1fr;
  }

  .xy-letter-figure {
    min-height: 190px;
    border-right: 0;
    border-bottom: 1px solid var(--xy-hairline);
  }

  .xy-note-cat {
    display: none;
  }

  .xy-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .xy-card,
  .xy-letter,
  .xy-gate,
  .xy-gate-scene,
  .entries[data-archive] .entry-card {
    transition: none;
  }
}
