/* ==========================================================
   BRENNA SALOTTI — JOURNAL POLISH
   Add AFTER assets/journal.css in journal.php.
   Designed to style journal_card() output without changing PHP.
   Desktop: 3 columns | Tablet: 2 | Mobile: 1
   ========================================================== */

/* Elegant, editorial styling scoped to the Journal page. */
body:has(.jn-grid, .jn-featured, .jn-empty) {
  --jn-ink: #252520;
  --jn-ink-soft: #68665e;
  --jn-stroke: #e7e4df;
  --jn-paper: #fff;
  --jn-subtle: #f8f7f4;
  --jn-accent: #9b8063;
}

/* Tighten overall section rhythm without affecting other pages. */
body:has(.jn-filters) .section:has(.jn-filters) {
  padding-top: clamp(44px, 6vw, 86px);
  padding-bottom: clamp(64px, 7vw, 110px);
}

/* ---------- category & tag filters ---------- */
.jn-filters {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px !important;
  padding: 0 0 24px !important;
  margin: 0 0 clamp(28px, 3.5vw, 48px) !important;
  border-bottom: 1px solid var(--jn-stroke, #e7e4df);
}
.jn-filters > a {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 40px;
  padding: 9px 17px !important;
  border: 1px solid #e8e5df !important;
  border-radius: 100px !important;
  background: #fff !important;
  color: #55534f !important;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .015em;
  line-height: 1.35;
  text-decoration: none !important;
  white-space: nowrap;
  transition: background .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
}
.jn-filters > a small {
  font-size: 10px;
  opacity: .65;
  font-weight: 600;
}
.jn-filters > a:hover {
  border-color: #9b8063 !important;
  color: #252520 !important;
  transform: translateY(-1px);
}
.jn-filters > a.on {
  background: #292824 !important;
  border-color: #292824 !important;
  color: #fff !important;
}
.jn-filters .jn-active-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #57554e;
}
.jn-filters .jn-active-tag a { color: #826a50; text-decoration: underline; }

/* ---------- featured story ---------- */
.jn-featured {
  display: grid !important;
  grid-template-columns: minmax(0, 1.17fr) minmax(0, 1fr);
  align-items: stretch;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--jn-stroke, #e7e4df) !important;
  border-radius: 4px;
  background: var(--jn-subtle, #f8f7f4);
  margin: 0 0 clamp(35px, 5vw, 65px) !important;
  box-shadow: 0 12px 36px rgba(30, 27, 22, .035);
}
.jn-featured-img {
  display: block;
  min-width: 0;
  min-height: 390px;
  height: 100%;
  overflow: hidden;
  background: #eeece7;
}
.jn-featured-img img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  min-height: 390px;
  object-fit: cover !important;
  transition: transform .7s cubic-bezier(.2,.8,.2,1);
}
.jn-featured:hover .jn-featured-img img { transform: scale(1.035); }
.jn-featured-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  min-width: 0;
  padding: clamp(30px, 4.5vw, 66px) !important;
}
.jn-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  padding: 7px 13px;
  margin-bottom: 22px;
  border-radius: 30px;
  background: #e9e2d6;
  color: #775d42;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.jn-featured-body .jn-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  font-size: 11px;
  color: #777169;
  margin-bottom: 18px;
}
.jn-meta a, .jn-grid .jn-cat { color: #947554; text-decoration: none; }
.jn-featured-body h2 {
  max-width: 650px;
  margin: 0 0 18px;
  font-size: clamp(29px, 3.1vw, 47px) !important;
  font-weight: 450;
  letter-spacing: -.045em;
  line-height: 1.15;
}
.jn-featured-body h2 a { color: var(--jn-ink, #252520); text-decoration: none; }
.jn-featured-body > p {
  margin: 0 0 27px !important;
  color: var(--jn-ink-soft, #68665e);
  font-size: 15px;
  line-height: 1.8;
}
.jn-featured-body > .btn { margin-top: 0; }

/* ---------- 3 / 2 / 1 article grid ---------- */
.jn-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  column-gap: clamp(18px, 2.5vw, 32px) !important;
  row-gap: clamp(26px, 3.6vw, 46px) !important;
  align-items: stretch;
  width: 100%;
  margin-inline: 0 !important;
}
/* The selector is intentionally generic: it covers the HTML
   returned by journal_card() without relying on its class name. */
.jn-grid > * {
  display: flex !important;
  flex-direction: column;
  grid-column: auto !important;
  grid-row: auto !important;
  min-width: 0 !important;
  width: 100% !important;
  max-width: none !important;
  height: 100%;
  margin: 0 !important;
  overflow: hidden;
  border: 1px solid var(--jn-stroke, #e7e4df);
  border-radius: 4px;
  background: var(--jn-paper, #fff);
  box-shadow: 0 6px 25px rgba(33, 31, 27, .035);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.jn-grid > *:hover {
  transform: translateY(-5px);
  border-color: #d5cdc0;
  box-shadow: 0 18px 45px rgba(33, 31, 27, .09);
}

/* Common media wrapper class variants. */
.jn-grid > * :is(.jn-card-img, .jn-card-image, .jn-card-media, .jn-thumb, .jn-image, .jn-media) {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  flex-shrink: 0;
  background: #eeeae4;
}
.jn-grid > * > a:first-child:has(img),
.jn-grid > * > picture:first-child {
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  flex-shrink: 0;
  background: #eeeae4;
}
.jn-grid > * img {
  display: block;
  width: 100% !important;
  aspect-ratio: 16 / 10;
  height: auto;
  object-fit: cover !important;
  object-position: center;
  transition: transform .6s cubic-bezier(.2,.8,.2,1);
}
.jn-grid > * :is(.jn-card-img, .jn-card-image, .jn-card-media, .jn-thumb, .jn-image, .jn-media) img,
.jn-grid > * > a:first-child:has(img) img,
.jn-grid > * > picture:first-child img {
  height: 100% !important;
}
.jn-grid > *:hover img { transform: scale(1.045); }

/* Content wrapper class variants. */
.jn-grid > * :is(.jn-card-body, .jn-card-content, .jn-content, .jn-details, .jn-card-info) {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  padding: 23px 24px 26px !important;
}
/* If journal_card() has no text wrapper, give direct text nodes
   the same breathing room without padding the cover image. */
.jn-grid > * > :is(h2,h3,p,.jn-meta,.jn-cat,.jn-card-meta,time,.jn-card-category) {
  margin-left: 24px;
  margin-right: 24px;
}
.jn-grid > * > :is(.jn-card-body, .jn-card-content, .jn-content, .jn-details, .jn-card-info)
  > :is(h2,h3,p,.jn-meta,.jn-cat,.jn-card-meta,time,.jn-card-category) {
  margin-left: 0;
  margin-right: 0;
}

.jn-grid > * .jn-meta,
.jn-grid > * :is(.jn-card-meta, .jn-card-category) {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
  margin-top: 0;
  margin-bottom: 13px;
  color: #89837b;
  font-size: 11px;
  line-height: 1.55;
}
.jn-grid > * :is(.jn-cat, .jn-card-category) {
  color: #9b8063;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .11em;
  text-decoration: none;
}
.jn-grid > * :is(h2,h3) {
  margin-top: 0 !important;
  margin-bottom: 13px !important;
  color: var(--jn-ink, #252520);
  font-size: clamp(19px, 1.65vw, 23px) !important;
  font-weight: 500;
  letter-spacing: -.025em;
  line-height: 1.36;
  overflow-wrap: anywhere;
}
.jn-grid > * :is(h2,h3) a {
  color: inherit !important;
  text-decoration: none !important;
}
.jn-grid > * :is(h2,h3) a:hover { color: #927557 !important; }
.jn-grid > * p {
  margin-top: 0;
  margin-bottom: 17px;
  color: #77736d;
  font-size: 13px;
  line-height: 1.8;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.jn-grid > * :is(.jn-readmore, .jn-more, .read-more, .jn-card-link, .jn-read, .jn-card-cta) {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: auto;
  color: #755d42;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

/* ---------- empty message ---------- */
.jn-empty {
  padding: clamp(45px, 7vw, 90px) 24px !important;
  border: 1px solid var(--jn-stroke, #e7e4df);
  border-radius: 4px;
  background: var(--jn-subtle, #f8f7f4);
  text-align: center;
}
.jn-empty h2 { font-size: clamp(25px, 3vw, 36px); margin: 0 0 10px; }
.jn-empty p { color: #77736d; margin: 0 0 24px; }

/* ---------- pagination ---------- */
.jn-pager {
  display: flex !important;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px !important;
  margin: clamp(45px, 6vw, 75px) 0 0 !important;
}
.jn-pager > :is(a,span) {
  display: inline-flex !important;
  justify-content: center;
  align-items: center;
  width: 41px;
  height: 41px;
  padding: 0;
  border: 1px solid #e5e1db;
  border-radius: 50%;
  background: #fff;
  color: #5e5a53;
  font-size: 13px;
  text-decoration: none;
  transition: .2s ease;
}
.jn-pager a:hover { border-color: #292824; background: #292824; color: #fff; }
.jn-pager > .on { border-color: #292824; background: #292824; color: #fff; }
.jn-pager > .off { opacity: .38; }

/* ---------- tablet ---------- */
@media (max-width: 1080px) {
  .jn-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .jn-featured-body { padding: 36px !important; }
  .jn-featured-img, .jn-featured-img img { min-height: 350px; }
}

/* ---------- mobile ---------- */
@media (max-width: 700px) {
  .jn-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    row-gap: 22px !important;
  }
  .jn-featured { grid-template-columns: minmax(0, 1fr) !important; }
  .jn-featured-img { height: 245px; min-height: 0; }
  .jn-featured-img img { height: 100% !important; min-height: 0; }
  .jn-featured-body { padding: 25px 22px 29px !important; }
  .jn-featured-body h2 { font-size: clamp(26px, 7vw, 36px) !important; }
  .jn-featured-body > p { font-size: 14px; }
  .jn-badge { margin-bottom: 14px; }
  .jn-filters {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    gap: 8px !important;
    padding-bottom: 16px !important;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
  .jn-filters > a { flex: 0 0 auto; min-height: 38px; padding: 9px 13px !important; }
  .jn-filters .jn-active-tag { flex: 0 0 auto; }
  .jn-grid > * :is(.jn-card-body, .jn-card-content, .jn-content, .jn-details, .jn-card-info) {
    padding: 21px 21px 24px !important;
  }
  .jn-grid > * > :is(h2,h3,p,.jn-meta,.jn-cat,.jn-card-meta,time,.jn-card-category) {
    margin-left: 21px; margin-right: 21px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .jn-grid > *, .jn-grid > * img, .jn-featured-img img,
  .jn-filters > a, .jn-pager > * { transition: none !important; }
}
