/**
 * 列表卡片：卡片樣式、分類日期、Grid 版面與滿版大圖、iPad 橫向、圖片淡入、觸控裝置無 hover
 *
 * @package Yafun2027
 */

/* ==========================================================================
   基礎樣式（源自 Dyad，已精簡；先於本檔下方的野放樣式）
   ========================================================================== */

.posts::before,
.posts::after {
  content: "";
}

.posts::after {
  clear: both;
}

.posts {
  background-color: #242629;
}

.posts .hentry {
  background: #fff;
  float: left;
  position: relative;
  width: 33.3333%;
}

.posts .cover-link {
  border: 1px solid transparent;
  inset: 0;
  position: absolute;
  transition: border-color 0.3s, border-width 0.3s;
  z-index: 4;
}

.posts .cover-link:hover,
.posts .cover-link:focus {
  border-color: rgba(0, 0, 0, 0.2);
  border-width: 15px;
}

.posts .entry-media {
  background-color: #242629;
  background-position: center center;
  background-size: cover;
  padding-bottom: 66.666%;
  position: relative;
  width: 50%;
}

.posts .entry-inner {
  background: #fff;
  bottom: 0;
  position: absolute;
  top: 0;
  vertical-align: middle;
  width: 50%;
}

.posts .entry-inner::before {
  color: var(--color-leaf);
  content: "";
  /* 分類剪影：以 CSS mask 顯示 assets/icons/ 的 SVG，顏色跟著 color；大小隨 font-size 變化 */
  background-color: currentcolor;
  -webkit-mask: var(--yf-icon, url("../../icons/footprint.svg")) center / 0.8em no-repeat;
  mask: var(--yf-icon, url("../../icons/footprint.svg")) center / 0.8em no-repeat;
  font-size: 3.5rem;
  height: 50px;
  left: 0;
  line-height: 50px;
  margin-left: -25px;
  margin-top: -25px;
  position: absolute;
  text-align: center;
  top: 50%;
  width: 50px;
  z-index: 5;
}

.posts .entry-inner::after {
  background-color: #fff;
  border-radius: 50px;
  content: "";
  height: 50px;
  left: 0;
  margin-left: -25px;
  margin-top: -25px;
  position: absolute;
  top: 50%;
  width: 50px;
}

.posts .entry-inner-content {
  border-bottom: 3px solid #fff;
  bottom: 50%;
  max-height: 80%;
  overflow: hidden;
  padding: 0 14%;
  position: absolute;
  right: 0;
  text-align: left;
  transform: translateY(50%);
  width: 100%;
}

.posts .entry-header {
  padding: 0;
}

.posts .entry-title {
  text-align: center;
}

.posts .entry-content {
  padding-top: 2rem;
}

.link-more {
  font-weight: 400;
  text-align: center;
}

.link-more a {
  background-color: #e7ae01;
  display: inline-block;
  font-size: 1.4rem;
  margin: 1em 0 0;
  padding: 0.62em 1.62em;
  position: relative;
  text-decoration: none;
  text-transform: uppercase;
  transition: background-color 0.3s;
  z-index: 10;
}

.posts .hentry:hover .link-more a {
  background-color: #f0b80e;
}

.too-short .link-more {
  background: #fff;
  bottom: 0;
  left: 0;
  margin-bottom: -1px;
  position: absolute;
  width: 100%;
}

.too-short .entry-inner-content::before,
.too-short .link-more::before {
  background: linear-gradient(rgba(255, 255, 255, 0) 0%, #fff 100%);
  bottom: 0;
  content: "";
  height: 40%;
  left: 0;
  position: absolute;
  width: 100%;
}

.too-short .link-more::before {
  bottom: 100%;
}

.posts .hentry:not(.has-post-thumbnail) .entry-media {
  background-color: transparent;
}

.posts .hentry:not(.has-post-thumbnail) .entry-inner {
  width: 100%;
}

.posts .hentry:not(.has-post-thumbnail)::before {
  border-top: 1px solid #d8dfe6;
  content: "";
  position: absolute;
  left: 15%;
  margin-top: 20px;
  right: 15%;
  top: 10%;
  z-index: 1;
}

.posts .hentry:not(.has-post-thumbnail) .entry-inner::after,
.posts .hentry:not(.has-post-thumbnail) .entry-inner::before {
  font-size: 2.2rem;
  height: 40px;
  left: 50%;
  line-height: 40px;
  margin-top: 0;
  margin-left: -20px;
  top: 10%;
  width: 40px;
  z-index: 3;
}

.posts .hentry:not(.has-post-thumbnail) .entry-inner::after {
  border: 1px solid #c6cfd8;
  z-index: 2;
}

.posts .hentry:not(.has-post-thumbnail) .entry-inner-content {
  bottom: auto;
  height: 80%;
  padding-top: 15%;
  position: relative;
  transform: translateY(0);
}

@media screen and (min-width: 1601px) {
  .posts .entry-media {
    float: left;
  }

  .posts .hentry.has-post-thumbnail:nth-of-type(6n+4) .entry-media,
  .posts .hentry.has-post-thumbnail:nth-of-type(6n+5) .entry-media,
  .posts .hentry.has-post-thumbnail:nth-of-type(6n+6) .entry-media {
    float: right;
  }

  .posts .entry-inner {
    right: 0;
  }

  .posts .hentry.has-post-thumbnail:nth-of-type(6n+4) .entry-inner,
  .posts .hentry.has-post-thumbnail:nth-of-type(6n+5) .entry-inner,
  .posts .hentry.has-post-thumbnail:nth-of-type(6n+6) .entry-inner {
    right: auto;
  }

  .posts .hentry.has-post-thumbnail:nth-of-type(6n+4) .entry-inner::after,
  .posts .hentry.has-post-thumbnail:nth-of-type(6n+5) .entry-inner::after,
  .posts .hentry.has-post-thumbnail:nth-of-type(6n+6) .entry-inner::after,
  .posts .hentry.has-post-thumbnail:nth-of-type(6n+4) .entry-inner::before,
  .posts .hentry.has-post-thumbnail:nth-of-type(6n+5) .entry-inner::before,
  .posts .hentry.has-post-thumbnail:nth-of-type(6n+6) .entry-inner::before {
    left: auto;
    margin-left: 0;
    margin-right: -25px;
    right: 0;
  }

  .posts .entry-inner-content {
    font-size: 1.6rem;
  }

}
@media only screen and (max-width: 1600px) {
  .posts .hentry {
    width: 50%;
  }

  .posts .entry-media {
    float: left;
  }

  .posts .hentry:nth-of-type(4n+3) .entry-media,
  .posts .hentry:nth-of-type(4n+4) .entry-media {
    float: right;
  }

  .posts .entry-inner {
    right: 0;
  }

  .posts .hentry:nth-of-type(4n+3) .entry-inner,
  .posts .hentry:nth-of-type(4n+4) .entry-inner {
    left: 0;
    right: auto;
  }

  .posts .hentry:nth-of-type(4n+3).has-post-thumbnail .entry-inner::after,
  .posts .hentry:nth-of-type(4n+4).has-post-thumbnail .entry-inner::after,
  .posts .hentry:nth-of-type(4n+3).has-post-thumbnail .entry-inner::before,
  .posts .hentry:nth-of-type(4n+4).has-post-thumbnail .entry-inner::before {
    left: auto;
    margin-left: 0;
    margin-right: -25px;
    right: 0;
  }

}
@media only screen and (max-width: 1200px) {
  .posts {
    background: #fff;
  }

  .posts .hentry {
    float: none;
    width: 100%;
  }

  .posts .hentry:nth-child(2n+1) .entry-media {
    float: left;
  }

  .posts .hentry:nth-child(2n) .entry-media {
    float: right;
  }

  .posts .hentry:nth-child(2n+1) .entry-inner,
  .posts .hentry:nth-child(2n).has-post-thumbnail .entry-inner::after,
  .posts .hentry:nth-child(2n).has-post-thumbnail .entry-inner::before {
    left: auto;
    right: 0;
  }

  .posts .hentry:nth-child(2n).has-post-thumbnail .entry-inner::after,
  .posts .hentry:nth-child(2n).has-post-thumbnail .entry-inner::before {
    margin-left: 0;
    margin-right: -25px;
  }

  .posts .hentry:nth-child(2n) .entry-inner,
  .posts .hentry:nth-child(2n+1).has-post-thumbnail .entry-inner::after,
  .posts .hentry:nth-child(2n+1).has-post-thumbnail .entry-inner::before {
    left: 0;
    right: auto;
  }

  .posts .hentry:nth-child(2n+1).has-post-thumbnail .entry-inner::after,
  .posts .hentry:nth-child(2n+1).has-post-thumbnail .entry-inner::before {
    margin-left: -25px;
    margin-right: 0;
  }

  .posts .hentry:not(.has-post-thumbnail) .entry-inner {
    position: relative;
  }

  .posts .hentry:not(.has-post-thumbnail) .entry-media {
    display: none;
  }

  .posts .hentry:not(.has-post-thumbnail) .entry-inner-content {
    padding-bottom: 4rem;
    padding-top: 12rem;
  }

  .posts .hentry:not(.has-post-thumbnail)::before,
  .posts .hentry:not(.has-post-thumbnail) .entry-inner::after,
  .posts .hentry:not(.has-post-thumbnail) .entry-inner::before {
    top: 4rem;
  }

  .too-short .link-more {
    position: relative;
  }

  .too-short .link-more::before,
  .too-short .entry-inner-content::before {
    display: none;
  }

}
@media only screen and (max-width: 680px) {
  .posts .hentry:hover::after,
  .posts .hentry:focus::after {
    display: none;
  }

  .posts .hentry:nth-child(2n) .entry-media,
  .posts .hentry:nth-child(2n+1) .entry-media {
    float: none;
  }

  .posts .entry-inner-content {
    padding: 4.62rem 4% 2.62rem;
    position: relative;
    transform: none;
  }

  .posts .hentry:nth-child(2n).has-post-thumbnail .entry-inner::after,
  .posts .hentry:nth-child(2n).has-post-thumbnail .entry-inner::before,
  .posts .hentry:nth-child(2n+1).has-post-thumbnail .entry-inner::after,
  .posts .hentry:nth-child(2n+1).has-post-thumbnail .entry-inner::before {
    left: 50%;
    margin-left: -25px;
    margin-right: 0;
    top: 0;
  }

  .posts .entry-inner::before {
    font-size: 3rem;
    line-height: 50px;
  }

  .link-more {
    margin-bottom: 1.5rem;
  }

  .link-more a {
    font-size: 1.2rem;
    margin-top: 0;
  }

  .posts .hentry .entry-media {
    overflow: hidden;
  }

  .posts .hentry .entry-media,
  .posts .hentry .entry-inner,
  .entry-inner-content {
    max-height: 100%;
    position: relative;
    width: 100%;
  }

  .posts .cover-link:hover,
  .posts .cover-link:focus {
    border-width: 10px;
  }

  .posts .hentry:not(.has-post-thumbnail) .entry-media {
    display: none;
  }

}

/* ==========================================================================
   首頁卡片
   ========================================================================== */

.posts .entry-title {
  font-size: clamp(2.2rem, 1.8vw, 2.8rem);
  line-height: 1.45;
}

.posts .entry-title a {
  color: var(--color-ink);
  transition: color 0.25s;
}

.posts .hentry:hover .entry-title a {
  color: var(--color-leaf);
}

.posts .entry-content {
  font-size: 1.6rem;
  line-height: 1.85;
  color: var(--color-muted);
}

.posts .entry-media {
  transition: transform 0.6s ease;
}

.posts .hentry:hover .entry-media {
  transform: scale(1.04);
}

/* 「閱讀全文」：外框按鈕，取代芥末黃 */

.link-more a {
  background-color: transparent;
  border: 1px solid var(--color-leaf);
  color: var(--color-leaf);
  letter-spacing: 0.15em;
  transition: background-color 0.25s, color 0.25s;
  font-weight: 700;
  top: -2px;
}

.posts .hentry:hover .link-more a,
.link-more a:hover,
.link-more a:focus {
  background-color: var(--color-leaf);
  color: #fff;
}

/* 發文日期：鋼筆簽名手寫體（中文字自動以文楷呈現） */
.posts .card-date,
.entry-date.published {
  font-family: var(--font-pen);
  font-weight: 500;
  font-size: 1.9rem;
  letter-spacing: 0.04em;
  color: var(--color-ocean);
  transform: rotate(-1.5deg);
  display: inline-block;
}

/* ==========================================================================
   首頁卡片：分類與日期
   ========================================================================== */

.posts .card-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75em;
  margin-bottom: 0.9em;
  font-size: 1.3rem;
  letter-spacing: 0.08em;
  color: var(--color-muted);
}

.posts .card-cat {
  font-family: var(--font-kai);
  padding: 0.15em 0.7em;
  border: 1px solid var(--color-leaf);
  border-radius: 999px;
  color: var(--color-leaf);
}
/* ==========================================================================
   列表頁格線：改為 CSS Grid，並穿插半滿版大圖卡片
   - 每 5 篇中的第 4 篇橫跨整列（.yf-featured）
   - grid-auto-flow: dense 讓後方卡片自動補滿空位
   ========================================================================== */

.posts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-flow: row dense;
}

.posts::before,
.posts::after {
  display: none;
}

.posts .hentry {
  overflow: hidden;
  float: none;
  width: auto;
}

.posts .yf-featured {
  grid-column: 1 / -1;
  min-height: 46rem;
  aspect-ratio: 5 / 2;
  background: var(--color-ink);
}

/* 視差：圖片上下各多出 15%，由 js/parallax.js 依捲動位置設定 --yf-parallax */
.yf-featured-media {
  position: absolute;
  inset: -15% 0;
  background-position: center;
  background-size: cover;
  transform: translate3d(0, var(--yf-parallax, 0), 0) scale(var(--yf-zoom, 1));
  transition: --yf-zoom 1.2s;
  will-change: transform;
}

.yf-featured::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(90deg, rgba(15, 22, 18, 0.78) 0%, rgba(15, 22, 18, 0.45) 40%, rgba(15, 22, 18, 0) 70%);
}

.yf-featured-inner {
  position: absolute;
  top: 50%;
  left: 8%;
  z-index: 2;
  width: min(44%, 56rem);
  transform: translateY(-50%);
  color: #fff;
}

.posts .yf-featured .card-meta {
  justify-content: flex-start;
  color: rgba(255, 255, 255, 0.85);
}

.posts .yf-featured .card-cat {
  border-color: rgba(255, 255, 255, 0.7);
  color: #fff;
}

.posts .yf-featured .card-date {
  color: #f1e3c4;
  font-size: 2.2rem;
}

.posts .yf-featured .entry-title {
  margin: 0 0 2.4rem;
  font-size: clamp(2.8rem, 3vw, 4.4rem);
  line-height: 1.35;
  text-align: left;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

.posts .yf-featured .entry-title a {
  color: #fff;
}

.yf-featured .link-more {
  text-align: left;
}

.yf-featured .link-more a {
  border-color: #fff;
  color: #fff;
}

/* 滿版區塊不做 Hover 變化，只保留捲動視差（標題維持白色：綠色在深色照片上看不清楚） */
.posts .yf-featured:hover .entry-title a {
  color: #fff;
}

.posts .yf-featured:hover .link-more a {
  background-color: transparent;
  color: #fff;
}

@media only screen and (max-width: 1600px) {
  .posts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media only screen and (max-width: 1200px) {
  .posts {
    grid-template-columns: minmax(0, 1fr);
  }

  .posts .yf-featured {
    aspect-ratio: 4 / 3;
    min-height: 0;
  }

  .yf-featured::before {
    background: linear-gradient(0deg, rgba(15, 22, 18, 0.82) 0%, rgba(15, 22, 18, 0.35) 55%, rgba(15, 22, 18, 0) 80%);
  }

  .yf-featured-inner {
    top: auto;
    bottom: 3rem;
    left: 2.4rem;
    right: 2.4rem;
    width: auto;
    transform: none;
  }

  .posts .yf-featured .entry-title {
    margin-bottom: 1.6rem;
  }
}
/* ==========================================================================
   iPad 橫向（961–1200px）：列表一列 2 篇，沿用桌面版「圖文並排」卡片
   父主題在此寬度改為單欄並以 odd/even 交錯；這裡改回桌面版的 4n+3／4n+4 交錯，
   讓每一列為「圖文｜圖文」、下一列為「文圖｜文圖」。以 !important 覆蓋父主題的 nth-child 規則。
   ========================================================================== */

@media only screen and (min-width: 961px) and (max-width: 1200px) {
  .posts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .posts .hentry:not(.yf-featured) .entry-media {
    float: left;
    width: 50%;
    padding-bottom: 66.666%;
  }

  .posts .hentry:not(.yf-featured) .entry-inner {
    position: absolute;
    top: 0;
    bottom: 0;
    left: auto;
    right: 0;
    width: 50%;
  }

  .posts .hentry:not(.yf-featured) .entry-inner::before,
  .posts .hentry:not(.yf-featured) .entry-inner::after {
    top: 50%;
    left: 0;
    right: auto;
    margin-left: -25px;
    margin-right: 0;
  }

  .posts .hentry:not(.yf-featured):nth-of-type(4n+3) .entry-media,
  .posts .hentry:not(.yf-featured):nth-of-type(4n+4) .entry-media {
    float: right;
  }

  .posts .hentry:not(.yf-featured):nth-of-type(4n+3) .entry-inner,
  .posts .hentry:not(.yf-featured):nth-of-type(4n+4) .entry-inner {
    left: 0;
    right: auto;
  }

  .posts .hentry:not(.yf-featured):nth-of-type(4n+3) .entry-inner::before,
  .posts .hentry:not(.yf-featured):nth-of-type(4n+3) .entry-inner::after,
  .posts .hentry:not(.yf-featured):nth-of-type(4n+4) .entry-inner::before,
  .posts .hentry:not(.yf-featured):nth-of-type(4n+4) .entry-inner::after {
    left: auto;
    right: 0;
    margin-left: 0;
    margin-right: -25px;
  }

  .posts .hentry:not(.yf-featured) .entry-title {
    font-size: 2rem;
  }

  .posts .hentry:not(.yf-featured) .entry-content {
    font-size: 1.4rem;
  }
}
/* ==========================================================================
   圖片淡入（由 js/lazy-bg.js 控制）
   卡片背景圖：覆蓋層在原本的預讀色塊上淡入；<img>：載入完成後淡入
   ========================================================================== */

.yf-bg-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-position: center;
  background-size: cover;
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
}

/* 卡片封面改用 <img>：填滿容器、置中裁切，與背景圖 cover 的效果相同 */
img.yf-bg-layer {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
}

.yf-bg-layer.is-loaded {
  opacity: 1;
}

/* 背景圖容器需為定位元素，覆蓋層才會對齊 */
.posts .entry-media {
  position: relative;
}

img.yf-fade {
  opacity: 0;
  transition: opacity 0.8s ease;
}

img.yf-fade.is-loaded {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .yf-bg-layer,
  img.yf-fade {
    transition: none;
  }
}
/* ==========================================================================
   手機／平板（1200px 以下）：列表頁不做 Hover 效果（觸控裝置點一下會卡在 hover 狀態）
   ========================================================================== */

@media only screen and (max-width: 1200px) {
  .posts .hentry:hover .entry-title a {
    color: var(--color-ink);
  }

  .posts .hentry:hover .entry-media {
    transform: none;
  }

  .posts .hentry:not(.yf-featured):hover .link-more a {
    background-color: transparent;
    color: var(--color-leaf);
  }

  .posts .hentry:not(.yf-featured):hover .entry-title .yf-latin {
    color: inherit;
  }
}

/* 平板（768–1200px，直式與橫式）：滿版區塊維持扁長比例 */
@media only screen and (min-width: 768px) and (max-width: 1200px) {
  .posts .yf-featured {
    aspect-ratio: 2 / 1;
  }
}

/* 手機：列表卡片只顯示分類、日期與標題，隱藏摘要（整張卡片可點擊進入文章） */
@media (max-width: 767px) {
  .posts .hentry .entry-content {
    display: none;
  }

  .posts .entry-inner-content {
    max-height: none;
  }
}

/* 減少動態效果：滿版區塊不做視差（需在上方 .yf-featured-media 之後） */
@media (prefers-reduced-motion: reduce) {
  .yf-featured-media {
    inset: 0;
    transform: none;
    transition: none;
  }
}

/* 分類剪影對應（class 由 inc/icons.php 依文章分類加上） */
.yf-icon-butterfly { --yf-icon: url("../../icons/butterfly.svg"); }
.yf-icon-beetle { --yf-icon: url("../../icons/beetle.svg"); }
.yf-icon-bird { --yf-icon: url("../../icons/bird.svg"); }
.yf-icon-bee { --yf-icon: url("../../icons/bee.svg"); }
.yf-icon-dragonfly { --yf-icon: url("../../icons/dragonfly.svg"); }
.yf-icon-frog { --yf-icon: url("../../icons/frog.svg"); }
.yf-icon-spider { --yf-icon: url("../../icons/spider.svg"); }
.yf-icon-orchid { --yf-icon: url("../../icons/orchid.svg"); }
.yf-icon-leaf { --yf-icon: url("../../icons/leaf.svg"); }
.yf-icon-crab { --yf-icon: url("../../icons/crab.svg"); }
.yf-icon-gecko { --yf-icon: url("../../icons/gecko.svg"); }
.yf-icon-magnifier { --yf-icon: url("../../icons/magnifier.svg"); }
.yf-icon-wolf { --yf-icon: url("../../icons/wolf.svg"); }
.yf-icon-sprout { --yf-icon: url("../../icons/sprout.svg"); }
.yf-icon-mountain { --yf-icon: url("../../icons/mountain.svg"); }
.yf-icon-globe { --yf-icon: url("../../icons/globe.svg"); }
.yf-icon-vase { --yf-icon: url("../../icons/vase.svg"); }
.yf-icon-footprint { --yf-icon: url("../../icons/footprint.svg"); }
