/* ============================================================
   Viflos — Elevated editorial card design  (card-refresh.css)
   Covers: home "Latest Projects" tabs, /blog/, category pages,
           sidebar "Popular Right Now" mini-posts.
   Also removes the published / updated dates from cards and from
   the single-post meta line (read time + author are kept).

   Loaded after the theme stylesheet, so no !important is needed
   except where noted. Uses the theme's own CSS variables so light
   and dark mode both work.
   Version: 1.0.0
   ============================================================ */

/* ---------- 1. Grids ---------- */
.post-grid {
  gap: 34px 28px;
  align-items: stretch;            /* equal-height cards */
}
.content-layout .post-grid { gap: 28px; }

/* ---------- 2. Card shell ---------- */
.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 12px 12px 18px;
  background: var(--card, #fff);
  border: 1px solid var(--card-border, rgba(20, 18, 15, .09));
  border-radius: 16px;
  box-shadow: var(--card-shadow, 0 1px 3px rgba(20, 18, 15, .05), 0 8px 24px rgba(20, 18, 15, .05));
  transition: transform .34s cubic-bezier(.2, .8, .2, 1),
              box-shadow .34s ease,
              border-color .34s ease;
}

/* accent bar that draws in on hover */
.post-card::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(90deg, var(--red, #F3323A), #FF7A59);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .42s cubic-bezier(.2, .8, .2, 1);
  pointer-events: none;
}

.post-card:hover,
.post-card:focus-within {
  transform: translateY(-6px);
  border-color: rgba(243, 50, 58, .34);
  box-shadow: 0 4px 12px rgba(20, 18, 15, .08),
              0 24px 46px -18px rgba(20, 18, 15, .30);
}
.post-card:hover::after,
.post-card:focus-within::after { transform: scaleX(1); }

/* ---------- 3. Thumbnail ---------- */
.post-card .thumb {
  position: relative;
  margin-bottom: 16px;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--paper-alt, #F1EAD9);
  box-shadow: inset 0 0 0 1px rgba(20, 18, 15, .06);
  isolation: isolate;
}
/* guard: the badge is an <a> too, never stretch it */
.post-card .thumb > a:not(.badge) {
  display: block;
  width: 100%;
  height: 100%;
}
.post-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .62s cubic-bezier(.2, .8, .2, 1);
}
/* soft gradient scrim, fades in on hover */
.post-card .thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  background: linear-gradient(180deg, rgba(10, 9, 7, 0) 45%, rgba(10, 9, 7, .34) 100%);
  transition: opacity .38s ease;
  pointer-events: none;
}
.post-card:hover .thumb img,
.post-card:focus-within .thumb img { transform: scale(1.07); }
.post-card:hover .thumb::after,
.post-card:focus-within .thumb::after { opacity: 1; }

/* category badge: frosted pill, lifted off the image edge */
.post-card .thumb .badge {
  top: 10px;
  left: 10px;
  z-index: 2;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(250, 246, 239, .94);
  color: var(--ink, #141414);
  font-weight: 600;
  letter-spacing: .07em;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .14);
  transition: background .3s ease, transform .3s ease;
}
.post-card:hover .thumb .badge { background: #fff; transform: translateY(-1px); }

/* ---------- 4. Title ---------- */
.post-card h3 {
  margin: 2px 4px 10px;
  font-size: 1.16rem;
  line-height: 1.3;
  letter-spacing: -.015em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card h3 a {
  color: var(--ink, #141414);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1.5px;
  transition: background-size .38s cubic-bezier(.2, .8, .2, 1), color .25s ease;
}
.post-card:hover h3 a,
.post-card:focus-within h3 a,
.post-card h3 a:focus-visible { color: var(--red, #F3323A); background-size: 100% 1.5px; }

/* ---------- 5. Excerpt ---------- */
.post-card .excerpt {
  margin: 0 4px 16px;
  font-size: .94rem;
  line-height: 1.58;
  color: var(--ink-soft, #3A3733);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 6. Meta: read time only ---------- */
/* published + "Updated" dates carry a <time> element -> hidden */
.post-card .post-meta > span:has(time) { display: none; }
.post-card .post-meta > .sep { display: none; }

.post-card .post-meta {
  margin-top: auto;
  padding-top: 12px;
  gap: 8px;
  border-top: 1px solid var(--line, rgba(20, 18, 15, .12));
}
.post-card .post-meta > span:last-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--paper-alt, #F1EAD9);
  color: var(--muted, #6E685F);
  font-size: .7rem;
  letter-spacing: .08em;
  transition: background .3s ease, color .3s ease;
}
.post-card:hover .post-meta > span:last-child {
  background: rgba(243, 50, 58, .10);
  color: var(--red, #F3323A);
}

/* ---------- 7. Single-post meta line: dates off, author + read time stay ---------- */
.post-header-single .post-meta > span:has(time) { display: none; }
.post-header-single .post-meta > span:has(time) + .sep { display: none; }

/* ---------- 8. Sidebar "Popular Right Now" mini-posts ---------- */
.widget .mini-post { padding: 13px 0; }
.widget .mini-post .thumb {
  width: 74px;
  height: 74px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--card-border, rgba(20, 18, 15, .09));
}
.widget .mini-post .thumb img { transition: transform .45s cubic-bezier(.2, .8, .2, 1); }
.widget .mini-post:hover .thumb img { transform: scale(1.06); }
.widget .mini-post h4 a { transition: color .2s ease; }
.widget .mini-post:hover h4 a { color: var(--red, #F3323A); }
/* the mini-post meta held nothing but the date */
.widget .mini-post .post-meta { display: none; }

/* ---------- 9. Dark mode ---------- */
:root[data-theme="dark"] .post-card {
  box-shadow: 0 2px 7px rgba(0, 0, 0, .38), 0 16px 32px -18px rgba(0, 0, 0, .62);
}
:root[data-theme="dark"] .post-card:hover,
:root[data-theme="dark"] .post-card:focus-within {
  border-color: rgba(255, 71, 84, .40);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .42), 0 26px 52px -20px rgba(0, 0, 0, .78);
}
:root[data-theme="dark"] .post-card .thumb .badge {
  background: rgba(30, 27, 23, .92);
  color: var(--ink, #F3EFE6);
}
:root[data-theme="dark"] .post-card:hover .thumb .badge { background: #23201B; }
:root[data-theme="dark"] .post-card .thumb { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
:root[data-theme="dark"] .post-card .post-meta > span:last-child { background: rgba(255, 255, 255, .07); }
:root[data-theme="dark"] .post-card:hover .post-meta > span:last-child {
  background: rgba(255, 71, 84, .14);
  color: #FF8A93;
}

/* ---------- 10. Responsive ---------- */
@media (max-width: 960px) {
  .post-grid { gap: 26px 22px; }
}
@media (max-width: 620px) {
  .post-grid { gap: 22px; }
  .post-card { padding: 10px 10px 16px; border-radius: 14px; }
  .post-card::after { border-radius: 14px 14px 0 0; }
  .post-card .thumb { border-radius: 10px; }
  .post-card h3 { font-size: 1.1rem; }
  /* no hover on touch: keep cards static */
  .post-card:hover { transform: none; }
}

/* ---------- 11. Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .post-card,
  .post-card::after,
  .post-card .thumb img,
  .post-card .thumb::after,
  .post-card h3 a,
  .post-card .thumb .badge,
  .widget .mini-post .thumb img {
    transition: none !important;
  }
  .post-card:hover,
  .post-card:focus-within { transform: none; }
  .post-card:hover .thumb img,
  .post-card:focus-within .thumb img,
  .widget .mini-post:hover .thumb img { transform: none; }
}

/* ---------- 12. Print ---------- */
@media print {
  .post-card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .post-card::after { display: none; }
}

/* ============================================================
   13. Article idea images (.vf-fig) — portrait-native framing
   The idea images are 1024x1536 (2:3 portrait) but the original
   CSS put them in a 16/10 landscape box with object-fit:contain,
   which pillarboxed every photo with cream bands. Taller frame +
   cover = full-bleed image, no bands, consistent card rhythm.
   The in-content rule is scoped to a per-post id (#vf-xxxx .vf-fig),
   so !important is required to win from an external stylesheet.
   ============================================================ */
div[id^="vf-"] .vf-fig {
  aspect-ratio: 4 / 5 !important;
  max-height: none !important;
  max-width: none !important;
  background: transparent !important;
  border-radius: 12px !important;
  margin: 0 auto 2px !important;
}
div[id^="vf-"] .vf-fig img {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover !important;
  object-position: 50% 50% !important;
}
@media (max-width: 720px) {
  div[id^="vf-"] .vf-fig {
    aspect-ratio: 3 / 4 !important;
    border-radius: 10px !important;
  }
}
