/*
Theme Name:     Neve Child
Theme URI:      https://www.typecalendar.com
Description:    TypeCalendar custom child theme for Neve. Hosts all customizations so the parent theme can be safely updated.
Author:         TypeCalendar
Author URI:     https://www.typecalendar.com
Template:       neve
Version:        2.1.0
License:        GNU General Public License v2 or later
License URI:    http://www.gnu.org/licenses/gpl-2.0.html
Text Domain:    neve-child
*/

/* ============================================================================
   Category Grid — modern minimal system (v2)
   ----------------------------------------------------------------------------
   - Token-driven (CSS custom properties on the wrapper).
   - Per-card accent (set via inline style="--card-accent: …").
   - Mobile-first responsive grid with explicit breakpoints.
   - Honors prefers-reduced-motion and print.
   ============================================================================ */

.neve-category-grid-wrap {
  /* Foundation tokens */
  --tc-bg:          #ffffff;
  --tc-bg-soft:     #f8fafc;
  --tc-fg:          #0f172a;
  --tc-fg-muted:    #64748b;
  --tc-fg-soft:     #94a3b8;
  --tc-line:        #e2e8f0;
  --tc-line-strong: #cbd5e1;

  /* Geometry */
  --tc-radius-card: 18px;
  --tc-radius-chip: 999px;
  --tc-radius-cta:  12px;
  --tc-gap:         clamp(12px, 1.6vw, 22px);
  --tc-pad:         clamp(16px, 1.6vw, 22px);

  /* Motion */
  --tc-anim:      220ms cubic-bezier(0.32, 0.72, 0, 1);
  --tc-anim-fast: 140ms cubic-bezier(0.32, 0.72, 0, 1);

  /* Per-card accent defaults (overridden inline by PHP) */
  --card-accent:      #475569;
  --card-accent-soft: #e2e8f0;

  margin: clamp(20px, 3vw, 36px) 0;
  color: var(--tc-fg);
}

/* ── Stats strip ──────────────────────────────────────────────── */

.neve-category-grid-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 18px;
}

.neve-stat-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--tc-line);
  border-radius: var(--tc-radius-chip);
  background: var(--tc-bg);
}

.neve-stat-num {
  color: var(--tc-fg);
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.neve-stat-label {
  color: var(--tc-fg-muted);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Grid ─────────────────────────────────────────────────────── */

.neve-category-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--tc-gap);
}

.neve-category-grid.columns-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.neve-category-grid.columns-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.neve-category-grid.columns-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1279px) {
  .neve-category-grid.columns-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1023px) {
  .neve-category-grid.columns-3,
  .neve-category-grid.columns-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 599px) {
  .neve-category-grid.columns-2,
  .neve-category-grid.columns-3,
  .neve-category-grid.columns-4 { grid-template-columns: minmax(0, 1fr); }
}

/* ── Card ─────────────────────────────────────────────────────── */

.neve-category-card {
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--tc-bg);
  border: 1px solid var(--tc-line);
  border-radius: var(--tc-radius-card);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  overflow: hidden;
  isolation: isolate;
  transition:
    transform var(--tc-anim),
    border-color var(--tc-anim),
    box-shadow var(--tc-anim);
}

.neve-category-card:hover {
  transform: translateY(-3px);
  /* Fallback for browsers without color-mix */
  border-color: var(--tc-line-strong);
  border-color: color-mix(in srgb, var(--card-accent) 38%, var(--tc-line));
  box-shadow:
    0 6px 14px rgba(15, 23, 42, 0.08),
    0 18px 38px rgba(15, 23, 42, 0.10);
}

.neve-category-card .neve-category-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.neve-category-card .neve-category-link:hover,
.neve-category-card .neve-category-link:focus,
.neve-category-card .neve-category-link:active {
  color: inherit;
  text-decoration: none;
}

/* ── Media area ───────────────────────────────────────────────── */

.neve-category-media {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 5 / 3;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(255, 255, 255, 0.6), transparent 60%),
    linear-gradient(155deg, var(--card-accent-soft) 0%, #ffffff 100%);
  overflow: hidden;
}

.neve-category-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 360ms cubic-bezier(0.32, 0.72, 0, 1);
}

.neve-category-card:hover .neve-category-image { transform: scale(1.04); }

.neve-category-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  line-height: 0;
}

.neve-category-icon svg {
  display: block;
  width: clamp(64px, 11vw, 104px);
  height: auto;
  transition: transform 320ms cubic-bezier(0.32, 0.72, 0, 1);
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.04));
}

.neve-category-card:hover .neve-category-icon svg { transform: translateY(-2px) scale(1.03); }

/* ── Content ──────────────────────────────────────────────────── */

.neve-category-content {
  padding: var(--tc-pad);
  padding-bottom: 8px;
}

.neve-category-eyebrow {
  display: inline-block;
  margin: 0 0 8px;
  color: var(--card-accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.neve-category-card .neve-category-title {
  margin: 0 0 6px;
  color: var(--tc-fg);
  font-size: clamp(1.05rem, 0.92rem + 0.42vw, 1.24rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.neve-category-desc {
  margin: 6px 0 0;
  color: var(--tc-fg-muted);
  font-size: 0.93rem;
  line-height: 1.55;

  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Subcategory chips ────────────────────────────────────────── */

.neve-subcategory-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
  padding: 0 var(--tc-pad);
  list-style: none;
}

.neve-subcategory-list li {
  margin: 0;
  padding: 0;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
}

.neve-subcategory-list a,
.neve-subcategory-more {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--tc-line) !important;
  border-radius: var(--tc-radius-chip);
  background: var(--tc-bg) !important;
  color: var(--tc-fg) !important;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none !important;
  transition: border-color var(--tc-anim-fast), color var(--tc-anim-fast);
  box-shadow: none !important;
  background-image: none !important;
  -webkit-appearance: none;
  appearance: none;
}

.neve-subcategory-list a::before,
.neve-subcategory-list a::after {
  content: none !important;
}

.neve-subcategory-list a:visited {
  color: var(--tc-fg) !important;
  border-color: var(--tc-line) !important;
  background: var(--tc-bg) !important;
}

.neve-subcategory-list a:focus,
.neve-subcategory-list a:active {
  color: var(--tc-fg) !important;
  border-color: var(--tc-line) !important;
  background: var(--tc-bg) !important;
  box-shadow: none !important;
}

.neve-subcategory-list a:hover {
  color: var(--card-accent) !important;
  border-color: var(--card-accent) !important;
  background: var(--card-accent-soft) !important;
}

.neve-subcategory-list li:focus-within,
.neve-subcategory-list li:active,
.neve-subcategory-list li:hover,
.neve-subcategory-list li:focus {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.neve-subcategory-list a:focus-visible {
  color: var(--card-accent) !important;
  border-color: var(--card-accent) !important;
  background: var(--card-accent-soft) !important;
}

.neve-subcategory-list a {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.neve-subcategory-more {
  background: var(--card-accent-soft);
  color: var(--card-accent);
  border-color: transparent;
  font-variant-numeric: tabular-nums;
}

/* ── Footer / CTA ─────────────────────────────────────────────── */

.neve-category-footer {
  display: flex;
  align-items: center;
  margin-top: auto;
  padding: 14px var(--tc-pad);
}

.neve-category-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--tc-line);
  border-radius: var(--tc-radius-cta);
  background: var(--tc-bg);
  color: var(--tc-fg);
  font-size: 0.83rem;
  font-weight: 700;
  text-decoration: none;
  transition:
    border-color var(--tc-anim-fast),
    background-color var(--tc-anim-fast),
    color var(--tc-anim-fast);
}

.neve-cta-arrow {
  display: inline-block;
  font-weight: 700;
  transform: translateX(0);
  transition: transform var(--tc-anim-fast);
}

.neve-category-card:hover .neve-category-cta,
.neve-category-cta:hover {
  border-color: var(--card-accent);
  background: var(--card-accent-soft);
  color: var(--card-accent);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02), 0 3px 10px rgba(15, 23, 42, 0.08);
}

.neve-category-card:hover .neve-cta-arrow,
.neve-category-cta:hover .neve-cta-arrow { transform: translateX(2px); }

/* ── Focus / accessibility ────────────────────────────────────── */

.neve-category-link:focus-visible,
.neve-subcategory-list a:focus-visible,
.neve-category-cta:focus-visible {
  outline: 2px solid var(--card-accent);
  outline-offset: 2px;
}

/* ── Reduced motion ───────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .neve-category-card,
  .neve-category-image,
  .neve-category-icon svg,
  .neve-cta-arrow,
  .neve-subcategory-list a,
  .neve-category-cta { transition-duration: 0.01ms !important; }

  .neve-category-card:hover,
  .neve-category-card:hover .neve-category-image,
  .neve-category-card:hover .neve-category-icon svg,
  .neve-category-card:hover .neve-cta-arrow { transform: none !important; }
}

/* ── Print ────────────────────────────────────────────────────── */

@media print {
  .neve-category-grid-wrap { color: #000; }

  .neve-category-card {
    page-break-inside: avoid;
    break-inside: avoid;
    border-color: #999;
    box-shadow: none !important;
  }

  .neve-category-footer { display: none; }
}

/* ============================================================================
   Category archive header (used on /category/* pages, not the homepage grid)
   ============================================================================ */

.category-title {
  margin: 0 0 10px;
  color: #0f172a;
  font-size: clamp(1.6rem, 1.2rem + 1vw, 2.1rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.category-subcategories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 22px;
}

.subcategory-link {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
}

.subcategory-link:hover,
.subcategory-link:focus-visible {
  background: #f0fdfa;
  border-color: #5eead4;
  color: #115e59;
}

/* ============================================================================
   CLS guard — single post column / sidebar layout (grid lock)
   ----------------------------------------------------------------------------
   ROOT CAUSE: On single templates with sidebar, the sidebar (`.nv-sidebar-wrap`) is
   parsed AFTER the article in the HTML. Browsers do incremental painting,
   so the very first paint contains only the article inside `.row` — and
   without a stable column system the article ends up centered (x≈295). When
   the sidebar arrives a few hundred ms later, `.row` rebalances and the
   article shifts to x≈90. That single horizontal repaint produces a
   ~0.10 CLS hit because the article covers the entire desktop viewport.

   FIX: Use CSS Grid on `.row` with explicit `grid-template-columns: 65%
   35%`. The article is permanently anchored to column 1 (left) regardless
   of whether the sidebar element has been parsed yet. When the sidebar
   arrives, it slots into column 2 with zero impact on the article's
   position. No more horizontal CLS.

   Mobile (<992px) keeps the default stacked block flow so content/sidebar
   stacks naturally.
   ============================================================================ */

@media (min-width: 992px) {
  body.nv-sidebar-right .neve-main > .single-post-container > .row,
  body.nv-sidebar-right .neve-main > .single-page-container > .row {
    display: grid !important;
    grid-template-columns: minmax(0, 65%) minmax(0, 35%) !important;
    align-items: start;
  }

  body.wp-singular.nv-sidebar-right .neve-main > .single-post-container > .row > .nv-single-post-wrap,
  body.wp-singular.nv-sidebar-right .neve-main > .single-post-container > .row > .nv-single-post-wrap.col,
  body.wp-singular.nv-sidebar-right .neve-main > .single-page-container > .row > .nv-single-page-wrap,
  body.wp-singular.nv-sidebar-right .neve-main > .single-page-container > .row > .nv-single-page-wrap.col,
  body.wp-singular.nv-sidebar-right .neve-main > .single-post-container > .row > .nv-sidebar-wrap,
  body.wp-singular.nv-sidebar-right .neve-main > .single-page-container > .row > .nv-sidebar-wrap {
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    float: none !important;
    justify-self: stretch !important;
  }
}

/* ============================================================================
   CLS guard — Related Posts (rp4wp) thumbnails
   ----------------------------------------------------------------------------
   The Related Posts plugin (rp4wp) outputs a fluid float-based layout where
   the inner attachment thumbnail is a 150x150 image. When lazy-load swaps
   the <img> src to a placeholder, the rendered image briefly collapses and
   the surrounding <article> grows on real-image arrival — producing a large
   CLS hit on singular posts.

   We do NOT touch the plugin's outer `.rp4wp-related-post-image` width
   (`width: 35%`). Instead we lock the inner <img> to a fixed 150x150 box
   with object-fit, so the layout is fixed regardless of which src
   is currently active.
   ============================================================================ */

.rp4wp-related-post-image > a {
  display: inline-block;
  width: 150px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.rp4wp-related-post-image img,
.rp4wp-related-post-image .attachment-thumbnail,
.rp4wp-related-post-image .wp-post-image {
  display: block;
  width: 150px !important;
  height: 150px !important;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

/* Plugin's <li> hosts a float:left thumbnail wrapper plus floating text.
   Without containment the LI height collapses around its floats and reflows
   when images stream in. flow-root + min-height pin the row at 150px image +
   20px bottom padding so the surrounding article never grows late. */
.rp4wp-related-posts ul > li {
  display: flow-root;
  contain: layout;
  min-height: 170px;
  padding-bottom: 20px;
  box-sizing: border-box;
}

/* Reserve full container row regardless of image arrival. */
.rp4wp-related-posts ul {
  contain: layout;
}
