/*
 * Theme Name:  Sugar Blog Child – Fayi Design
 * Theme URI:   https://sugar.codesupply.co/
 * Description: Child theme styled to match the 發一慈濟電子報 design
 * Author:      Code Supply Co.
 * Author URI:  https://codesupply.co/
 * Template:    sugar-blog
 * Version:     1.0.0
 */

/* ============================================================
   SECTION 1 – CSS VARIABLE OVERRIDES (colours, spacing, radii)
   ============================================================ */

:root,
[data-scheme=light] {
  /* Background & surface colours */
  --cs-site-background:          #FFFFFF;
  --cs-layout-background:        #F7F7F7;

  /* Primary palette */
  --cs-color-primary:            #1A1A1A;
  --cs-color-primary-contrast:   #FFFFFF;
  --cs-color-secondary:          #666666;

  /* Accent – orange, matching the arrows & category highlight */
  --cs-color-accent:             #E8501A;

  /* Borders */
  --cs-color-border:             #E5E5E5;
  --cs-color-divider:            #E5E5E5;

  /* Buttons */
  --cs-color-button:             #E8501A;
  --cs-color-button-contrast:    #FFFFFF;
  --cs-color-button-hover:       #C93F0F;
  --cs-color-button-hover-contrast: #FFFFFF;

  /* Tag / badge defaults */
  --cs-color-tag-background:     #F0F0F0;
  --cs-color-tag-background-hover: #E5E5E5;

  /* Radii – keep rounded for category tags, sharp for cards */
  --cs-tag-border-radius:        200px;
  --cs-thumbnail-border-radius:  0px;
  --cs-button-border-radius:     4px;
  --cs-layout-elements-border-radius: 0px;
}

/* Header backgrounds */
:root,
body[data-scheme=light] {
  --cs-header-background:        #FFFFFF;
  --cs-header-topbar-background: #FFFFFF;
  --cs-footer-background:        #FFFFFF;
}


/* ============================================================
   SECTION 2 – GLOBAL TYPOGRAPHY
   Use a system CJK-friendly font stack that renders well for
   Traditional Chinese content.
   ============================================================ */

body {
  font-family:
    "Noto Sans TC", "PingFang TC", "Microsoft JhengHei",
    "Helvetica Neue", Arial, sans-serif;
  color: #1A1A1A;
  background-color: #FFFFFF;
  -webkit-font-smoothing: antialiased;
}

/* Slightly looser line-height for CJK reading comfort */
p,
.cs-entry__excerpt,
.cs-entry__content {
  line-height: 1.8;
}

/* Bold, tight headings */
h1, h2, h3, h4, h5, h6,
.cs-entry__title,
.cs-entry__title a {
  font-weight: 700;
  line-height: 1.3;
  color: #1A1A1A;
}

a {
  color: inherit;
  text-decoration: none;
}
a:hover {
  color: #E8501A;
}


/* ============================================================
   SECTION 3 – HEADER
   Centre the logo, clean white bar, subtle bottom border
   ============================================================ */

/* Remove default bottom border shadow, use thin line */
.cs-header__outer {
  border-bottom: 1px solid #E5E5E5 !important;
  box-shadow: none !important;
}

/* Full-width white topbar that holds the logo */
.cs-header-topbar {
  background: #FFFFFF;
  border-bottom: 1px solid #E5E5E5;
  padding: 12px 0;
}

.cs-header-topbar .cs-container {
  display: flex;
  justify-content: center;
}

.cs-header-topbar__inner {
  justify-content: center !important;
  width: 100%;
}

/* Centre logo in the topbar */
.cs-header-topbar .cs-col-center {
  flex: 0 0 auto;
  margin: 0 auto;
}

/* Logo sizing */
.cs-header__logo img,
.cs-header-topbar .cs-header__logo img {
  max-height: 48px;
  width: auto;
}

/* Main nav bar – keep clean */
.cs-header {
  background: #FFFFFF;
}

.cs-header__inner {
  justify-content: center;
}

/* Centre the navigation links */
.cs-header__nav {
  display: flex;
  justify-content: center;
}

/* Nav link styling */
.cs-nav__menu > li > a,
.cs-nav .menu-item > a {
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #1A1A1A;
  padding: 0 14px;
  text-decoration: none;
  transition: color 0.2s;
}

.cs-nav__menu > li > a:hover,
.cs-nav .menu-item > a:hover {
  color: #E8501A;
}

/* Active nav item – orange text + underline indicator */
.cs-nav .current-menu-item > a,
.cs-nav .current-menu-item > a:hover {
  color: #E8501A;
  background: transparent;
  position: relative;
}
.cs-nav .current-menu-item > a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 14px;
  right: 14px;
  height: 2px;
  background: #E8501A;
  border-radius: 2px 2px 0 0;
}


/* ============================================================
   SECTION 4 – HERO / FEATURED POST SLIDER
   Left image (~60 %), right text (~40 %), arrow nav below
   ============================================================ */

/* Wrapper that contains the featured/hero block */
.cs-hero,
.cs-featured-posts,
.wp-block-cs-post-slider,
.cs-post-slider,
[class*="is-style-cs-hero"],
[class*="cs-hero"] {
  background: #FFFFFF;
  margin-bottom: 0;
}

/* --- Tile-layout hero (the "half-image / half-text" block) --- */
.cs-post-slider .is-style-cs-tile-layout .cs-post-slider__wrapper {
  display: grid;
  grid-template-columns: 3fr 2fr;
  align-items: stretch;
  gap: 0;
}

.cs-post-slider .is-style-cs-tile-layout .cs-post-slider__item {
  display: flex;
  flex-direction: column;
}

/* Thumbnail fills its column */
.cs-post-slider .is-style-cs-tile-layout .cs-post-slider__item
  .wp-block-latest-posts__featured-image {
  flex: 1;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.cs-post-slider .is-style-cs-tile-layout .cs-post-slider__item
  .wp-block-latest-posts__featured-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Right (text) column */
.cs-post-slider .is-style-cs-tile-layout .cs-post-slider__item
  .wp-block-latest-posts__post-title,
.cs-post-slider .is-style-cs-tile-layout .cs-post-slider__item h3 {
  font-size: clamp(1.58rem, 3vw, 2.33rem);
  font-weight: 700;
  line-height: 1.25;
  color: #1A1A1A;
  margin-bottom: 0.75rem;
}

.cs-post-slider .is-style-cs-tile-layout .cs-post-slider__item
  .wp-block-latest-posts__post-excerpt {
  font-size: 0.96rem;
  color: #555555;
  line-height: 1.75;
}

/* Category label in hero */
.cs-post-slider .is-style-cs-tile-layout .cs-post-slider__item
  .wp-block-latest-posts__category a {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
  padding: 3px 8px;
  border-radius: 200px;
  text-decoration: none;
  transition: opacity 0.2s;
}
.cs-post-slider .is-style-cs-tile-layout .cs-post-slider__item
  .wp-block-latest-posts__category a:hover {
  opacity: 0.8;
}

/* Navigation arrows – orange, minimal */
.cs-post-slider__button-prev,
.cs-post-slider__button-next,
.cs-post-slider .swiper-button-prev,
.cs-post-slider .swiper-button-next {
  color: #E8501A;
  background: transparent;
  border: none;
  box-shadow: none;
  font-size: 1.38rem;
  transition: opacity 0.2s;
}
.cs-post-slider__button-prev:hover,
.cs-post-slider__button-next:hover,
.cs-post-slider .swiper-button-prev:hover,
.cs-post-slider .swiper-button-next:hover {
  opacity: 0.7;
}

/* Swiper pagination dots – orange active */
.cs-post-slider .swiper-pagination-bullet-active {
  background: #E8501A;
}
.cs-post-slider .swiper-pagination-bullet {
  background: #CCCCCC;
  opacity: 1;
}


/* ============================================================
   SECTION 5 – SECTION HEADINGS  (最新消息 etc.)
   ============================================================ */

.cs-section-heading,
.wp-block-group__inner-container > h2,
.cs-section-heading-styling {
  font-size: 1.63rem;
  font-weight: 800;
  color: #1A1A1A;
  margin-bottom: 0.2rem;
  border: none;
  padding: 0;
}

/* Subtitle beneath section heading */
.cs-section-heading + p,
.cs-section-heading-widget + p,
.cs-section-heading ~ .cs-section-description,
.wp-block-group .wp-block-paragraph:first-of-type {
  font-size: 0.86rem;
  color: #888888;
  margin-top: 0.15rem;
  margin-bottom: 1.25rem;
}


/* ============================================================
   SECTION 6 – POST CARDS  (the 3-column "Latest News" grid)
   ============================================================ */

/* Remove card shadow / border – flat design */
.cs-entry {
  background: transparent;
  box-shadow: none;
  border: none;
}

/* Thumbnail – sharp corners, full-width */
.cs-entry__inner.cs-entry__thumbnail,
.cs-entry__inner.cs-entry__overlay {
  border-radius: 0;
  overflow: hidden;
}

.cs-entry__inner.cs-entry__thumbnail img,
.cs-entry__inner.cs-entry__overlay img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.cs-entry:hover .cs-entry__inner.cs-entry__thumbnail img,
.cs-entry:hover .cs-entry__inner.cs-entry__overlay img {
  transform: scale(1.03);
}

/* Content area below thumbnail */
.cs-entry__inner.cs-entry__content {
  padding: 0.75rem 0 0;
}

.cs-entry__inner.cs-entry__content-standard {
  padding: 0.75rem 0 0;
}

/* Post meta row: category • source · date */
.cs-entry__post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  margin-bottom: 0.4rem;
}

/* Category tag pill */
.cs-meta-category .post-categories {
  margin: 0;
  padding: 0;
  list-style: none;
  display: inline-flex;
  gap: 4px;
}

.cs-meta-category .post-categories li {
  display: inline-flex;
}

.cs-meta-category .post-categories li a {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 200px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: opacity 0.2s;
  /* Colour provided via --cs-category-color & --cs-category-bg-color inline vars */
  color: var(--cs-category-color, #E8501A);
  background: var(--cs-category-bg-color, #FFF0EB);
}

.cs-meta-category .post-categories li a:hover {
  opacity: 0.8;
  background: var(--cs-category-bg-hover-color, #FFE0D5);
  color: var(--cs-category-color, #E8501A);
}

/* Author / source */
.cs-meta-author {
  font-size: 0.83rem;
  color: #888888;
}

.cs-meta-author .cs-meta-author-by {
  display: none; /* hide "by" prefix */
}

.cs-meta-author .cs-meta-author-name,
.cs-meta-author a {
  color: #555555;
  font-weight: 500;
  text-decoration: none;
}

.cs-meta-author a:hover {
  color: #E8501A;
}

/* Dot separator between author and date */
.cs-meta-author:not(:last-child)::after,
.cs-meta-date:not(:last-child)::after {
  content: "·";
  margin-left: 0.35rem;
  color: #BBBBBB;
}

/* Date */
.cs-meta-date {
  font-size: 0.83rem;
  color: #888888;
}

/* Entry title */
.cs-entry__title {
  margin: 0.3rem 0 0;
}

.cs-entry__title a {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.4;
  color: #1A1A1A;
  text-decoration: none;
  transition: color 0.2s;
}

.cs-entry__title a:hover {
  color: #E8501A;
}

/* Excerpt under title */
.cs-entry__excerpt {
  font-size: 0.96rem;
  color: #666666;
  margin-top: 0.4rem;
  line-height: 1.7;
}

/* 3-column grid spacing */
.cs-posts-area__posts.cs-post-layout__grid {
  gap: 2rem 1.5rem;
}


/* ============================================================
   SECTION 7 – CATEGORY COLOUR PRESETS
   These defaults align with the screenshot's visible categories.
   Admins can override per-category in WP admin → Posts → Categories.
   ============================================================ */

/* 國際活動盛況 – warm orange */
.cs-meta-category .post-categories li a[href*="international"],
.cs-meta-category .post-categories li a[style*="--cs-category-color: #E8501A"],
.cs-meta-category .post-categories li a[style*="--cs-category-color: #FF6B35"] {
  color: #E8501A !important;
  background: #FFF0EB !important;
}

/* 台灣活動盛況 – teal green */
.cs-meta-category .post-categories li a[href*="taiwan"],
.cs-meta-category .post-categories li a[style*="--cs-category-color: #0FA37F"],
.cs-meta-category .post-categories li a[style*="--cs-category-color: #1ABC9C"] {
  color: #0A8F6E !important;
  background: #E6FAF5 !important;
}

/* 聖訓經典 – deep red */
.cs-meta-category .post-categories li a[href*="scripture"],
.cs-meta-category .post-categories li a[style*="--cs-category-color: #C0392B"],
.cs-meta-category .post-categories li a[style*="--cs-category-color: #E74C3C"] {
  color: #C0392B !important;
  background: #FAEAEA !important;
}

/* 影音專區 – amber */
.cs-meta-category .post-categories li a[href*="media"],
.cs-meta-category .post-categories li a[style*="--cs-category-color: #E67E22"],
.cs-meta-category .post-categories li a[style*="--cs-category-color: #F39C12"] {
  color: #C87000 !important;
  background: #FFF8E1 !important;
}


/* ============================================================
   SECTION 8 – FOOTER
   Plain white, copyright left, links right
   ============================================================ */

.cs-footer {
  background: #FFFFFF;
  border-top: 1px solid #E5E5E5;
  padding: 1.25rem 0;
}

.cs-footer .cs-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Copyright text */
.cs-footer__copyright,
.cs-footer .copyright,
.cs-footer-bottom__copyright {
  font-size: 0.83rem;
  color: #888888;
}

/* Footer nav links */
.cs-footer__nav a,
.cs-footer-bottom__nav a,
.cs-footer .menu a {
  font-size: 0.83rem;
  color: #555555;
  text-decoration: none;
  transition: color 0.2s;
}
.cs-footer__nav a:hover,
.cs-footer-bottom__nav a:hover,
.cs-footer .menu a:hover {
  color: #E8501A;
}

/* No multi-column footer widgets – hide if not used */
.cs-footer-columns:empty {
  display: none;
}


/* ============================================================
   SECTION 9 – FAYI CUSTOMISATIONS
   ============================================================ */

/* 1. Hide social share bar on single posts */
.cs-entry__share,
.cs-share,
.cs-post-share,
.csco-share {
  display: none !important;
}

/* 2. Hide "Related Posts / 相關文章" section below single posts */
.cs-read-next {
  display: none !important;
}

/* 3. Pagination – replace Next / Previous text with arrows via CSS */
.page-numbers.next,
.page-numbers.prev {
  font-size: 0 !important;   /* hide the text */
  line-height: 1;
}

.page-numbers.next::after {
  content: '→';
  font-size: 1rem;
  font-weight: 700;
}

.page-numbers.prev::before {
  content: '←';
  font-size: 1rem;
  font-weight: 700;
}

/* 4. Footer – hide policy link column if present */
.cs-footer__col.cs-col-left .menu {
  display: none !important;
}


/* ============================================================
   SECTION 9b – UTILITY OVERRIDES
   ============================================================ */

/* Page container max-width */
.cs-container {
  max-width: 1240px;
  padding-left: 20px;
  padding-right: 20px;
}

/* Remove any sticky-header colour changes that clash */
.cs-header.is-sticky .cs-header__outer {
  background: #FFFFFF;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* Search toggle icon colour */
.cs-search-toggle,
.cs-header__search-toggle {
  color: #1A1A1A;
}

/* Offcanvas / burger sidebar */
.cs-offcanvas,
.cs-burger-menu {
  background: #FFFFFF;
}

/* Swiper / slider on mobile: full-width single column */
@media (max-width: 767px) {
  .cs-post-slider .is-style-cs-tile-layout .cs-post-slider__wrapper {
    grid-template-columns: 1fr;
  }

  .cs-posts-area__posts.cs-post-layout__grid {
    gap: 1.5rem;
  }

  .cs-section-heading,
  .cs-section-heading-styling {
    font-size: 1.25rem;
  }
}

/* ============================================================
   SECTION 10 – HOME PAGE HERO  (fayi_home_hero PHP hook output)
   Left image (~60 %), right text (~40 %)
   ============================================================ */

.fayi-hero {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.fayi-hero__inner {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 0 2.5rem;
  align-items: center;
  background: #FFFFFF;
}

/* Featured image column */
.fayi-hero__media {
  position: relative;
  overflow: hidden;
  border-radius: 0;
  aspect-ratio: 16 / 9;
}

.fayi-hero__media img,
.fayi-hero__media a {
  display: block;
  width: 100%;
  height: 100%;
}

.fayi-hero__media img {
  object-fit: cover;
  transition: transform 0.4s ease;
}

.fayi-hero__media:hover img {
  transform: scale(1.03);
}

/* Text column */
.fayi-hero__content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.fayi-hero__content .cs-meta-category {
  margin-bottom: 0;
}

.fayi-hero__title {
  font-size: clamp(1.5rem, 2.5vw, 2.1rem);
  font-weight: 800;
  line-height: 1.3;
  margin: 0;
}

.fayi-hero__title a {
  color: #1A1A1A;
  text-decoration: none;
  transition: color 0.2s;
}

.fayi-hero__title a:hover {
  color: #E8501A;
}

.fayi-hero__excerpt {
  font-size: 0.96rem;
  color: #555555;
  line-height: 1.75;
  margin: 0;
  /* clamp to ~4 lines */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fayi-hero__read-more {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.25rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #E8501A;
  text-decoration: none;
  transition: opacity 0.2s;
}

.fayi-hero__read-more::after {
  content: '→';
}

.fayi-hero__read-more:hover {
  opacity: 0.75;
  color: #E8501A;
}

/* Divider between hero and posts grid */
.fayi-hero + .cs-posts-area,
.fayi-hero + * {
  border-top: 1px solid #E5E5E5;
  padding-top: 2rem;
}

/* Mobile: stack vertically */
@media (max-width: 767px) {
  .fayi-hero__inner {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .fayi-hero__title {
    font-size: 1.4rem;
  }
}


/* ============================================================
   SECTION 11 – FEATURED MENU POSTS (header top featured bar)
   ============================================================ */

.cs-featured-menu {
  border-bottom: 1px solid #E5E5E5;
}

.cs-featured-menu .menu-post-item-standard .cs-entry__title a {
  font-size: 0.96rem;
  font-weight: 600;
  color: #1A1A1A;
}

.cs-featured-menu .menu-post-item-standard .cs-entry__title a:hover {
  color: #E8501A;
}


/* ========== FAYI CUSTOM FIXES ========== */

/* 1. Hide footer site name "發一慈濟國際網站" */
.cs-footer__item-top-bar {
  display: none !important;
}

/* 2. Remove gray horizontal line below top logo */
.cs-header__outer {
  border-bottom: none !important;
}

/* 3. Hide light/dark mode switcher */
.cs-site-scheme-toggle {
  display: none !important;
}
