/*
  [INPUT]: 由 blog/index.html、blog/article.html、blog/error.html 与 blog/fragments.html 引用
  [OUTPUT]: 公开博客的统一视觉样式：共享外壳的视口对齐、品牌 Hero、分类/搜索区、纯文字卡片网格、正文阅读列与错误页
  [POS]: static/blog-assets 的唯一样式入口；开发 mock 与正式 SSR 共用，不使用远程字体、脚本或文章图片
  [CHANGE_IMPACT]: 修改本文件需同步 review BlogTemplateContractTest 的响应式列数与断点契约
*/

:root {
  --ry-ink: #111827;
  --ry-ink-soft: #596273;
  --ry-line: #dce1d8;
  --ry-surface: #ffffff;
  --ry-canvas: #f5f6f1;
  --ry-night: #071728;
  --ry-lime: #84cc16;
  --ry-yellow: #fde047;
  --ry-radius: 12px;
  /* 分类标签与搜索按钮的唯一高度源；两者必须等高，只改这一处，移动端断点单独覆盖 */
  --ry-control-h: 30px;
  /* 正文白卡的左右内边距，同时是返回入口与标题的左对齐基准线 */
  --ry-article-pad-x: 96px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background-color: #FAFAFA;
  background-image:
    radial-gradient(at 0% 0%, rgba(163, 230, 53, 0.4) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(253, 224, 71, 0.4) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(163, 230, 53, 0.4) 0px, transparent 50%),
    radial-gradient(at 0% 100%, rgba(253, 224, 71, 0.4) 0px, transparent 50%);
  background-attachment: fixed;
  background-size: cover;
  color: var(--ry-ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans SC", "Noto Sans JP", sans-serif;
  font-style: normal;
  line-height: 1.6;
}

a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--ry-lime);
  outline-offset: 2px;
  border-radius: 6px;
}

.ry-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ry-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 10px 16px;
  background: var(--ry-surface);
  border: 1px solid var(--ry-line);
}

.ry-skip:focus { left: 8px; top: 8px; z-index: 100; }

.ry-main { display: block; }

/* ---------- RUNYALA 品牌 Hero ---------- */

.ry-main--listing { padding: 96px 0 72px; }

.ry-blog-heading {
  width: min(calc(100% - 48px), 1240px);
  margin: 0 auto;
  padding: 48px 0 18px;
  text-align: center;
}

.ry-blog-heading__title {
  margin: 0 0 1.5rem;
  color: #0f172a;
  font-family: "Barlow Condensed", system-ui, -apple-system, "Segoe UI", "Noto Sans SC", sans-serif;
  font-size: 36px;
  font-style: normal;
  font-weight: 900;
  line-height: 1.2;
  text-transform: uppercase;
}

@media (min-width: 768px) {
  .ry-blog-heading__title { font-size: 60px; }
}

.ry-blog-heading__rule {
  display: block;
  width: 96px;
  height: 4px;
  margin: 24px auto 0;
  background: var(--ry-lime);
}

.ry-blog-heading__subtitle {
  margin: 24px 0 0;
  color: var(--ry-ink-soft);
  font-size: 16px;
  line-height: 1.6;
}

.ry-hero {
  position: relative;
  overflow: hidden;
  color: var(--ry-ink);
  background: #e9f9ef;
}

.ry-hero__inner {
  position: relative;
  min-height: clamp(440px, 40vw, 570px);
  overflow: hidden;
}

.ry-hero__inner::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(240, 255, 245, 0.96) 0%, rgba(231, 252, 239, 0.84) 33%, rgba(239, 255, 247, 0.2) 68%, rgba(239, 255, 247, 0.04) 100%);
}

.ry-hero__visual {
  position: absolute;
  inset: 0;
}

.ry-hero__visual img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

.ry-hero__copy {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  min-height: clamp(440px, 40vw, 570px);
  width: min(calc(100% - 48px), 1240px);
  margin: 0 auto;
  padding: 54px 0;
}

.ry-hero__eyebrow,
.ry-listing__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.ry-hero__eyebrow { color: #5c8e08; }
.ry-hero__eyebrow::before,
.ry-listing__eyebrow::before {
  content: "";
  width: 34px;
  height: 2px;
  background: currentColor;
}

.ry-hero__title {
  max-width: 620px;
  margin: 20px 0 18px;
  font-size: clamp(48px, 6vw, 86px);
  font-weight: 820;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.ry-hero__description {
  max-width: 500px;
  margin: 0;
  color: #475569;
  font-size: clamp(16px, 1.5vw, 20px);
}

.ry-hero__cta {
  display: inline-flex;
  align-items: center;
  gap: 26px;
  margin-top: 30px;
  padding: 12px 18px;
  background: var(--ry-lime);
  color: var(--ry-ink);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  border-radius: 4px;
}

.ry-hero__cta:hover { background: var(--ry-yellow); }

/* ---------- 目录标题与搜索 ---------- */

.ry-listing__heading {
  max-width: 1240px;
  margin: 0 auto;
  padding: 48px 24px 28px;
}

.ry-listing__intro { min-width: 0; }
.ry-listing__eyebrow { color: #557a16; }
.ry-listing__lead {
  max-width: 620px;
  margin: 16px 0 0;
  color: var(--ry-ink-soft);
  font-size: 16px;
}

.ry-listing__title {
  margin: 12px 0 0;
  font-size: clamp(32px, 3vw, 42px);
  font-weight: 820;
  letter-spacing: -0.055em;
  line-height: 0.98;
  overflow-wrap: anywhere;
}

.ry-blog-tools {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(calc(100% - 96px), 1192px);
  min-height: var(--ry-control-h);
  margin: 32px auto 0;
}

.ry-search {
  position: static;
  display: flex;
  align-items: center;
  width: var(--ry-control-h);
  height: var(--ry-control-h);
  min-height: 0;
  margin-left: auto;
  overflow: hidden;
  padding: 0;
  background: var(--ry-surface);
  border: 1px solid #cfd6c9;
  border-radius: 999px;
  transition: width .2s ease, border-color .18s ease, box-shadow .18s ease;
}

.ry-search:is(:hover, :focus-within, .is-open) { width: 300px; }
.ry-search:focus-within { border-color: #7ba31e; box-shadow: 0 0 0 3px rgba(163, 230, 53, 0.18); }
.ry-search__toggle { display: grid; flex: 0 0 var(--ry-control-h); place-items: center; width: var(--ry-control-h); height: var(--ry-control-h); min-height: 0; padding: 0; border: 0; background: transparent; color: var(--ry-ink); cursor: pointer; }
.ry-search__toggle:focus-visible { outline: 2px solid var(--ry-lime); outline-offset: -4px; }
.ry-search__icon { width: 18px; height: 18px; fill: none; stroke: var(--ry-ink-soft); stroke-width: 1.8; }
.ry-search input { flex: 0 0 0; width: 0; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ry-ink); font: inherit; opacity: 0; transition: flex-basis .2s ease, opacity .12s ease; }
.ry-search__submit { flex: 0 0 0; width: 0; min-height: 0; height: calc(var(--ry-control-h) - 8px); margin: 0; padding: 0; overflow: hidden; border: 0; border-radius: 999px; background: var(--ry-ink); color: #fff; font-weight: 750; opacity: 0; pointer-events: none; cursor: pointer; transition: opacity .12s ease; }
.ry-search__submit:hover { background: #2c3747; }
.ry-search:is(:hover, :focus-within, .is-open) input { flex: 1 1 auto; width: auto; padding: 0 6px; opacity: 1; }
.ry-search:is(:hover, :focus-within, .is-open) .ry-search__submit { flex-basis: 58px; width: 58px; margin-right: 7px; opacity: 1; pointer-events: auto; }

/* ---------- 分类导航 ---------- */

.ry-categories {
  width: auto;
  margin: 0;
  background: transparent;
  border: 0;
}

.ry-categories__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: none;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}

.ry-categories__list::-webkit-scrollbar { display: none; }

.ry-categories__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  height: var(--ry-control-h);
  white-space: nowrap;
  padding: 0 14px;
  border: 1px solid rgba(15, 23, 42, .14);
  border-radius: 999px;
  background: rgba(255, 255, 255, .56);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  color: var(--ry-ink-soft);
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.ry-categories__item:hover {
  border-color: var(--ry-lime);
  background: rgba(255, 255, 255, .82);
  color: var(--ry-ink);
  transform: translateY(-1px);
}

.ry-categories__item.is-active {
  border-color: var(--ry-lime);
  background: var(--ry-lime);
  color: #ffffff;
}

/* ---------- 纯文字卡片 ---------- */

.ry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 48px 24px 0;
}

.ry-card {
  display: flex;
  min-width: 0;
  background: var(--ry-surface);
  border: 1px solid #d8ddd4;
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.ry-card__link {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 292px;
  width: 100%;
  padding: 30px;
  text-decoration: none;
  border-radius: 8px;
}

.ry-card:hover,
.ry-card:focus-within { border-color: #9bb43d; transform: translateY(-3px); box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08); }
.ry-card__link:hover .ry-card__title { color: #39580c; }
.ry-card__link:active { background: #f2f7e9; }

.ry-card__category {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ry-lime);
}

.ry-card__title {
  margin: 0;
  font-size: clamp(21px, 1.7vw, 26px);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.ry-card__summary {
  margin: 0;
  color: var(--ry-ink-soft);
  font-size: 15px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.ry-card__date {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid #e7eae4;
  font-size: 13px;
  color: var(--ry-ink-soft);
}

.ry-more { display: flex; justify-content: center; padding: 38px 20px 0; }
.ry-more button { padding: 13px 24px; border: 1px solid var(--ry-ink); border-radius: 4px; background: transparent; color: var(--ry-ink); font-weight: 750; cursor: pointer; }
.ry-more button:hover { background: var(--ry-ink); color: #fff; }

.ry-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  color: var(--ry-ink-soft);
  text-align: center;
}

.ry-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 0 20px 56px;
}

.ry-pagination__link {
  padding: 8px 16px;
  font-weight: 600;
  text-decoration: none;
  background: var(--ry-surface);
  border: 1px solid var(--ry-line);
  border-radius: 999px;
}

.ry-pagination__link:hover { border-color: var(--ry-lime); }
.ry-pagination__status { font-size: 14px; color: var(--ry-ink-soft); }

/* ---------- 正文阅读 ---------- */

.ry-main--article { padding: 96px 0 64px; }

/* 白卡外框宽度对齐列表页卡片区（.ry-grid 的 1240 - 左右各 24 = 1192px），
   两个页面的可见方块左右边缘逐像素对齐。
   半透明白 + 毛玻璃配方与官网站内其它浮层保持一致 */
.ry-article {
  max-width: 1192px;
  margin: 0 auto;
  padding: 40px var(--ry-article-pad-x);
  background: rgba(255, 255, 255, .6);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-radius: var(--ry-radius);
}

/* 文章头部：分类、标题、署名整块由左侧渐变装饰条统起来，底边框同时充当与正文的分割线 */
.ry-article__header {
  position: relative;
  margin: 20px 0 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--ry-line);
}

/* 装饰条落在卡片内边距里，absolute 定位不占用正文布局宽度 */
.ry-article__header::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 0;
  bottom: 20px;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--ry-lime) 0%, var(--ry-yellow) 100%);
}

.ry-article__category {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ry-lime);
  text-decoration: none;
}

.ry-article__title {
  margin: 10px 0 12px;
  font-size: clamp(26px, 3.4vw, 38px);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.ry-article__meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 13px;
  color: var(--ry-ink-soft);
}

/* 署名在灰色元信息行里需要可辨识，用正文字色与半粗体区分 */
.ry-article__author { color: var(--ry-ink); font-weight: 600; }

.ry-article__body { font-size: 17px; line-height: 1.8; overflow-wrap: anywhere; }
.ry-article__body h2 { margin: 40px 0 12px; font-size: 26px; line-height: 1.3; }
.ry-article__body h3 { margin: 32px 0 10px; font-size: 21px; }
.ry-article__body p { margin: 0 0 18px; }
.ry-article__body ul,
.ry-article__body ol { margin: 0 0 18px; padding-left: 24px; }
.ry-article__body li { margin-bottom: 6px; }

.ry-article__body blockquote {
  margin: 0 0 18px;
  padding: 6px 18px;
  border-left: 4px solid var(--ry-lime);
  color: var(--ry-ink-soft);
}

.ry-article__body pre {
  margin: 0 0 18px;
  padding: 16px;
  overflow-x: auto;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
}

.ry-article__body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.94em; }
.ry-article__body pre code { white-space: pre-wrap; word-break: break-word; }

.ry-article__body table {
  width: 100%;
  margin: 0 0 18px;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}

.ry-article__body th,
.ry-article__body td { padding: 8px 12px; border: 1px solid var(--ry-line); text-align: left; }

.ry-article__body a { color: #3f6212; text-underline-offset: 3px; }

/* 返回入口：白卡内的第一个子元素，落在卡片左上角（距边缘 24px）。
   负 margin 把它从内容区左上角拉回卡片自身；底边框即文字下方那道横线 */
.ry-article__back {
  display: flex;
  align-items: center;
  width: fit-content;
  margin-top: -16px;
  margin-bottom: 32px;
  margin-left: calc(24px - var(--ry-article-pad-x));
  padding: 4px 0 6px;
  border-bottom: 2px solid var(--ry-lime);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  color: var(--ry-ink-soft);
  transition: color .18s ease;
}

.ry-article__back:hover { color: var(--ry-ink); }

.ry-article__back:hover {
  color: var(--ry-ink);
}

.ry-article__back:focus-visible {
  outline: 2px solid var(--ry-lime);
  outline-offset: 4px;
  border-radius: 4px;
}

.ry-article__languages {
  width: 100%;
  max-width: 1192px;
  margin: 32px auto 0;
  padding: 0 var(--ry-article-pad-x);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ry-article__languages a {
  padding: 6px 12px;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--ry-line);
  border-radius: 999px;
  background: var(--ry-surface);
}

.ry-article__languages a:hover { border-color: var(--ry-lime); }

/* ---------- 错误页 ---------- */

.ry-main--error {
  max-width: 640px;
  margin: 0 auto;
  padding: 96px 20px;
  text-align: center;
}

.ry-error__title { margin: 0 0 12px; font-size: 32px; }
.ry-error__body { margin: 0 0 28px; color: var(--ry-ink-soft); }

.ry-error__back {
  display: inline-block;
  padding: 10px 22px;
  font-weight: 600;
  text-decoration: none;
  background: var(--ry-lime);
  border-radius: 999px;
}

/* ---------- 响应式：桌面三列 / 平板两列 / 手机一列 ---------- */

@media (max-width: 1024px) {
  .ry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ry-hero__visual img { object-position: 58% center; }
}

@media (max-width: 639px) {
  /* 手机触控目标比桌面大，标签与搜索按钮同步放大；正文内边距同时收窄 */
  :root { --ry-control-h: 36px; --ry-article-pad-x: 24px; }
  .ry-grid { grid-template-columns: 1fr; gap: 14px; padding: 16px 16px 0; }
  .ry-hero__inner { min-height: 0; display: flex; flex-direction: column; }
  .ry-hero__inner::after { display: none; }
  .ry-hero__copy { min-height: 0; width: calc(100% - 32px); padding: 126px 0 40px; }
  .ry-hero__title { margin-top: 16px; font-size: clamp(40px, 13vw, 58px); }
  .ry-hero__description { font-size: 16px; }
  .ry-hero__visual { position: relative; height: 260px; order: 2; }
  .ry-hero__visual::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(240, 255, 245, .78) 0%, transparent 28%); }
  .ry-hero__visual img { object-position: 70% center; }
  .ry-listing__heading { padding: 40px 16px 24px; }
  .ry-listing__title { font-size: 32px; }
  /* 右侧为绝对定位的搜索按钮让出圆形按钮宽度 + 12px 间距，避免标签滑到按钮底下 */
  .ry-categories { width: calc(100% - var(--ry-control-h) - 12px); }
  .ry-categories__list { flex-wrap: nowrap; justify-content: flex-start; padding-bottom: 12px; }
  .ry-categories__item { min-width: auto; padding: 0 15px; }
  .ry-search { position: absolute; top: 0; right: 0; margin-left: 0; }
  .ry-blog-tools:has(.ry-search:is(:hover, :focus-within, .is-open)) { min-height: 108px; }
  .ry-search:is(:hover, :focus-within, .is-open) { top: 60px; }
  .ry-card__link { min-height: 250px; padding: 24px; }
  .ry-article { padding: 28px 24px; }
  /* 窄屏卡片上内边距更小，取消负 margin-top 避免返回入口顶到卡片边缘；
     左右由 --ry-article-pad-x 的 calc 自动落回距卡片 24px，无需覆盖 */
  .ry-article__back { margin-top: 0; }
  .ry-article__header { margin: 16px 0 20px; padding-bottom: 16px; }
  .ry-article__header::before { left: -14px; bottom: 16px; }
  .ry-article__languages { margin-top: 24px; padding: 0 24px; }
  .ry-article__body { font-size: 16px; }
}

@media print {
  .ry-hero, .ry-pagination, .ry-article__languages, .ry-skip { display: none; }
  .ry-article { width: 100%; }
  .ry-article__body a { text-decoration: underline; }
}
