/**
 * Dafa Theme — visual polish layer, v2 (additive only).
 *
 * Loaded after polish.css. Every selector in this file was written against
 * DOM actually rendered by the theme templates (header.php / footer.php /
 * template-parts / inc/template-tags.php / inc/news-archive.php /
 * inc/breadcrumbs.php). Colors derive from the --dafa-* variables or the
 * theme's own ink/navy palette; motion is wrapped in
 * `@media (prefers-reduced-motion: no-preference)`.
 *
 * @package DafaTheme
 */

/* -------------------------------------------------------------------------
 * 1. Sticky header — scroll state.
 * site.css already makes .site-header sticky with backdrop blur (z-index 20,
 * admin-bar offsets handled). polish-v2.js toggles .is-scrolled beyond 8px.
 * ------------------------------------------------------------------------- */
.site-header {
  transition:
    box-shadow 240ms ease,
    border-color 240ms ease,
    background-color 240ms ease;
}

.site-header.is-scrolled {
  border-bottom-color: color-mix(in srgb, var(--dafa-border) 72%, var(--dafa-text));
  box-shadow: 0 12px 32px -14px color-mix(in srgb, var(--dafa-text) 26%, transparent);
}

/* Slightly stronger transparency only where the blur stays enabled;
 * mobile-navigation.css deliberately drops backdrop-filter below 1024px. */
@media (min-width: 1024px) {
  .site-header.is-scrolled {
    background: color-mix(in srgb, var(--dafa-surface) 86%, transparent);
  }
}

/* -------------------------------------------------------------------------
 * 2. Footer — deep navy band in BOTH color modes.
 * The palette extends the theme's ink family (#172033 / #12161d); it is a
 * deliberate constant surface, so it stays dark in day mode as well.
 * Contrast: --dafa-footer-muted (#9aa5b4) on #11161f ≈ 7.5:1.
 * ------------------------------------------------------------------------- */
.site-footer {
  --dafa-footer-bg: #161c27;
  --dafa-footer-bg-deep: #10151f;
  --dafa-footer-ink: #e9edf3;
  --dafa-footer-muted: #9aa5b4;
  --dafa-footer-line: rgb(255 255 255 / 10%);
  --dafa-footer-accent: #eb7448; /* night-mode brand orange, ≥5:1 on this band */

  position: relative;
  border-top: 0;
  background: linear-gradient(180deg, var(--dafa-footer-bg) 0%, var(--dafa-footer-bg-deep) 100%);
  color: var(--dafa-footer-muted);
}

/* Brand-orange hairline across the top of the band. */
.site-footer::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--dafa-footer-accent) 0%,
    color-mix(in srgb, var(--dafa-footer-accent) 45%, transparent) 55%,
    transparent 100%
  );
  content: "";
}

.site-footer .widget {
  color: var(--dafa-footer-muted);
}

.site-footer .widget-title {
  margin-bottom: 14px;
  color: var(--dafa-footer-ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.site-footer a {
  color: var(--dafa-footer-ink);
}

.site-footer a:hover {
  color: var(--dafa-footer-accent);
}

.site-footer .footer-nav a,
.site-footer .footer-nav button {
  color: var(--dafa-footer-ink);
}

.site-footer .footer-nav a:hover,
.site-footer .footer-nav button:hover {
  color: var(--dafa-footer-accent);
}

/* Hot-tag chips: translucent pills that pick up the brand orange on hover.
 * Same selector specificity as site.css (0,3,1); this file loads later. */
.site-footer .wp-block-tag-cloud.is-style-outline a {
  border-color: var(--dafa-footer-line);
  background: rgb(255 255 255 / 6%);
  color: var(--dafa-footer-ink);
}

.site-footer .wp-block-tag-cloud.is-style-outline a:hover {
  border-color: color-mix(in srgb, var(--dafa-footer-accent) 65%, transparent);
  background: color-mix(in srgb, var(--dafa-footer-accent) 22%, transparent);
  color: #fff;
}

/* Bottom row: separated copyright strip. */
.footer-row {
  margin-top: 8px;
  padding-top: 26px;
  border-top: 1px solid var(--dafa-footer-line);
}

.copyright {
  color: var(--dafa-footer-muted);
}

.copyright a {
  color: var(--dafa-footer-ink);
}

/* -------------------------------------------------------------------------
 * 3. Card typography refinement.
 * DOM: template-parts/content/card.php (.entry-card__media / __body /
 * __title / __excerpt / .entry-meta / .entry-card__badge / __filetype).
 * ------------------------------------------------------------------------- */
.entry-card__title {
  font-weight: 650;
  letter-spacing: -0.012em;
  line-height: 1.4;
}

.entry-card__excerpt {
  line-height: 1.62;
}

.entry-card__body > .entry-meta {
  gap: 6px 12px;
  font-size: 12.5px;
}

.entry-card__body > .entry-meta .entry-meta__metric-icon {
  width: 14px;
  height: 14px;
}

/* Badge chip: crisper small pill. */
.entry-card__badge {
  padding: 4px 10px;
  font-size: 11px;
  letter-spacing: 0.03em;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--dafa-badge-color, var(--dafa-accent)) 18%, transparent);
}

/* File-type chip (PDF/DOC/XLS/PPT/ZIP): tinted pill derived from its own
 * type color, so it stays correct in both modes. */
.entry-card__filetype {
  padding: 3px 7px;
  border-radius: 6px;
  background: color-mix(in srgb, currentColor 12%, transparent);
}

/* -------------------------------------------------------------------------
 * 4. Home section rhythm + "查看全部" micro-interaction.
 * Inter-section whitespace: 72px desktop (32+40), 40px mobile; the existing
 * hairline separator is kept but softened.
 * ------------------------------------------------------------------------- */
.home-stream {
  padding-block: 32px 40px;
  border-top-color: color-mix(in srgb, var(--dafa-border) 55%, transparent);
}

.home-stream:first-of-type {
  border-top: 0;
}

.section-heading {
  margin-bottom: 30px;
}

.section-heading a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 650;
  text-decoration: none;
}

.section-heading a::after {
  content: "→";
}

@media (prefers-reduced-motion: no-preference) {
  .section-heading a::after {
    transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .section-heading a:hover::after {
    transform: translateX(4px);
  }
}

@media (max-width: 782px) {
  .home-stream {
    padding-block: 20px;
  }
}

/* -------------------------------------------------------------------------
 * 5. Archive filters, hot-tag chips and stat cards.
 * DOM: inc/news-archive.php (.news-filter-form …), template-tags.php
 * (.resource-filters / .archive-subs__chip / .archive-stats__item).
 * ------------------------------------------------------------------------- */
.news-filter-form,
.resource-filters {
  box-shadow:
    0 1px 2px color-mix(in srgb, var(--dafa-text) 4%, transparent),
    0 10px 28px -18px color-mix(in srgb, var(--dafa-text) 14%, transparent);
}

@media (prefers-reduced-motion: no-preference) {
  .news-filter-select__toggle {
    transition: border-color 180ms ease, box-shadow 180ms ease;
  }
}

.news-filter-select__toggle:hover {
  border-color: color-mix(in srgb, var(--dafa-accent) 45%, var(--dafa-border));
}

/* Apply = clear primary action; Reset stays quiet (styles already split in
 * site.css, this only adds the branded elevation to the primary). */
.news-filter-actions__apply {
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--dafa-accent) 45%, transparent);
}

/* Resource filter rows: pill hover/active states. */
.resource-filters__row a {
  border: 1px solid transparent;
}

@media (prefers-reduced-motion: no-preference) {
  .resource-filters__row a {
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
  }
}

.resource-filters__row a.is-active {
  border-color: color-mix(in srgb, var(--dafa-accent) 35%, transparent);
  font-weight: 650;
}

/* Hot-tag chips in the archive hero. */
.archive-subs__chip {
  background: color-mix(in srgb, var(--dafa-bg) 55%, transparent);
}

@media (prefers-reduced-motion: no-preference) {
  .archive-subs__chip {
    transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1), border-color 160ms ease, color 160ms ease;
  }

  .archive-subs__chip:hover {
    transform: translateY(-1px);
  }
}

/* Stat cards: inset layering against the hero surface + tighter numerals. */
.archive-stats__item {
  background: var(--dafa-bg);
}

.archive-stats__item strong {
  font-weight: 760;
  letter-spacing: -0.01em;
}

.archive-stats__item span {
  letter-spacing: 0.04em;
}

/* -------------------------------------------------------------------------
 * 6. Single-entry typography (.entry-content) + resource purchase card.
 * ------------------------------------------------------------------------- */
.entry-content {
  line-height: 1.85;
}

.entry-content h2 {
  position: relative;
  margin-top: 2em;
  padding-left: 16px;
}

.entry-content h2::before {
  position: absolute;
  top: 0.2em;
  bottom: 0.2em;
  left: 0;
  width: 5px;
  border-radius: 3px;
  background: linear-gradient(
    180deg,
    var(--dafa-accent) 0%,
    color-mix(in srgb, var(--dafa-accent) 55%, transparent) 100%
  );
  content: "";
}

.entry-content h3 {
  margin-top: 1.7em;
}

/* Blockquote → branded card. */
.entry-content blockquote {
  padding: 18px 22px;
  border-left: 4px solid var(--dafa-accent);
  border-radius: 0 var(--dafa-radius) var(--dafa-radius) 0;
  background: color-mix(in srgb, var(--dafa-accent-soft) 55%, var(--dafa-surface));
  color: var(--dafa-text);
}

/* Content imagery. */
.entry-content img {
  border-radius: calc(var(--dafa-radius) * 0.8);
}

.entry-content figure img,
.entry-content .wp-block-image img {
  box-shadow: var(--dafa-shadow);
}

/* Content links: brand underline that solidifies on hover. */
.entry-content a:not(.button):not(.wp-block-button__link) {
  text-decoration-line: underline;
  text-decoration-color: color-mix(in srgb, var(--dafa-accent) 40%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.entry-content a:not(.button):not(.wp-block-button__link):hover {
  text-decoration-color: var(--dafa-accent);
  text-decoration-thickness: 2px;
}

/* Lists. */
.entry-content ul,
.entry-content ol {
  padding-inline-start: 1.5em;
}

.entry-content li::marker {
  color: var(--dafa-accent);
  font-weight: 700;
}

/* Tables: framed, striped, rounded. */
.entry-content table {
  border: 1px solid var(--dafa-border);
  border-radius: var(--dafa-radius);
}

.entry-content thead th {
  background: var(--dafa-surface-muted);
  font-weight: 700;
}

.entry-content tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--dafa-surface-muted) 50%, transparent);
}

/* Resource purchase card (theme-owned classes only; the #erphpdown compat
 * rules in sidebar-v3.css are deliberately not touched). */
@media (prefers-reduced-motion: no-preference) {
  .sidebar .dafa-resource-card {
    transition: box-shadow 240ms cubic-bezier(0.22, 1, 0.36, 1), border-color 240ms ease;
  }

  .sidebar .dafa-resource-card:hover {
    box-shadow: 0 24px 60px color-mix(in srgb, var(--dafa-accent) 14%, transparent);
  }
}

/* -------------------------------------------------------------------------
 * 7. Back-to-top floating button (created by polish-v2.js).
 * bottom: 88px keeps it clear of any bottom-right chat entry; z-index 40
 * stays below the mobile drawer (50) and the AI drawer (99991).
 * ------------------------------------------------------------------------- */
.dafa-back-to-top {
  position: fixed;
  right: 24px;
  bottom: 88px;
  z-index: 40;
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--dafa-accent);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--dafa-accent) 36%, transparent);
  color: var(--dafa-on-accent);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  visibility: hidden;
}

.dafa-back-to-top.is-visible {
  opacity: 1;
  transform: none;
  visibility: visible;
}

.dafa-back-to-top svg {
  width: 20px;
  height: 20px;
}

@media (prefers-reduced-motion: no-preference) {
  .dafa-back-to-top {
    transition:
      opacity 240ms ease,
      transform 240ms cubic-bezier(0.22, 1, 0.36, 1),
      visibility 240ms ease,
      background-color 160ms ease;
  }

  .dafa-back-to-top:hover {
    background: var(--dafa-accent-strong);
    transform: translateY(-2px);
  }
}

@media (max-width: 782px) {
  .dafa-back-to-top {
    right: 16px;
    bottom: 76px;
    width: 40px;
    height: 40px;
  }
}

/* -------------------------------------------------------------------------
 * 8. Breadcrumbs refinement.
 * ------------------------------------------------------------------------- */
.dafa-breadcrumbs a {
  color: var(--dafa-text-soft);
  text-decoration: none;
}

.dafa-breadcrumbs a:hover {
  color: var(--dafa-accent-strong);
}

.dafa-breadcrumbs [aria-current="page"] {
  color: var(--dafa-text);
  font-weight: 600;
}
