/* ==========================================================
   Magazine page (Seed & Soil) — grid + in-page flipbook reader.
   Loaded only on magazine.php; matches the main site's maroon
   (#b01933 / #8a1327) + Lato/Lora theme, no new palette.
   ========================================================== */

/* The shared #content.page-content-wrap 112px top padding (site-wide,
   css/style.css) suits pages with a tall banner above it - this
   page's breadcrumb is just a flat, short dark bar, so that much gap
   above the intro text reads as empty space. #content beats the
   shared class-only rule on specificity, and this file only loads on
   magazine.php, so no other page is affected. */
#content.page-content-wrap{
  padding-top:40px;
}

.magazine-intro{
  text-align:center;
  max-width:640px;
  margin:0 auto 40px;
  padding:0 20px;
}
.magazine-intro p{
  color:#6b6b6b;
  font-size:15px;
  line-height:1.6;
}

.magazine-year-filter{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:8px;
  margin-bottom:32px;
}
.magazine-year-pill{
  background:#fff;
  border:1px solid #ece2d3;
  color:#6b5a43;
  font-family:'Lato',sans-serif;
  font-weight:700;
  font-size:13px;
  padding:8px 18px;
  border-radius:20px;
  cursor:pointer;
  transition:background .15s ease, color .15s ease, border-color .15s ease;
}
.magazine-year-pill:hover{border-color:#b01933;color:#b01933;}
.magazine-year-pill.active{background:#b01933;border-color:#b01933;color:#fff;}

.magazine-year-section{margin-bottom:40px;}
.magazine-year-section:last-child{margin-bottom:0;}

.magazine-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(230px,1fr));
  gap:28px;
  padding:0 0 20px;
}

.magazine-card{
  background:#fff;
  border:1px solid #ece2d3;
  border-radius:8px;
  overflow:hidden;
  box-shadow:0 10px 24px -18px rgba(20,10,10,.4);
  transition:transform .18s ease, box-shadow .18s ease;
}
.magazine-card:hover{
  transform:translateY(-3px);
  box-shadow:0 16px 30px -16px rgba(20,10,10,.45);
}

.magazine-cover{
  position:relative;
  aspect-ratio:3/4;
  background:#f4efe6;
  overflow:hidden;
  cursor:pointer;
}
.magazine-cover:focus-visible{
  outline:2px solid #b01933;
  outline-offset:2px;
}
.magazine-cover-fallback{
  position:absolute;
  inset:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  color:#6b5a43;
  text-align:center;
  padding:22px;
  transition:opacity .15s ease;
}
.magazine-cover-fallback svg{width:32px;height:32px;margin-bottom:10px;opacity:.55;color:#b01933;}
.magazine-cover-fallback .series{
  font-family:'Lora',serif;
  font-style:italic;
  font-size:13px;
  letter-spacing:.04em;
  opacity:.8;
}
.magazine-cover-fallback .issue-title{
  font-family:'Lora',serif;
  font-weight:700;
  font-size:21px;
  margin-top:6px;
}
/* While the real cover is being rendered from the PDF's first page,
   hide the placeholder text and show a spinner instead - a failed
   render just leaves the placeholder visible (is-loading removed). */
.magazine-cover.is-loading .magazine-cover-fallback{ opacity:0; }
.magazine-cover.is-loading::after{
  content:"";
  position:absolute;
  top:50%;left:50%;
  width:22px;height:22px;
  margin:-11px 0 0 -11px;
  border-radius:50%;
  border:3px solid rgba(176,25,51,.2);
  border-top-color:#b01933;
  animation:magazine-spin .8s linear infinite;
}
.magazine-cover-thumb{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

.magazine-card-body{padding:16px 18px 18px;}
.magazine-card-body .meta{
  display:flex;
  justify-content:space-between;
  gap:10px;
  font-size:12.5px;
  color:#8a8a8a;
  margin-bottom:12px;
}

.magazine-read-btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  width:100%;
  justify-content:center;
  background:#b01933;
  color:#fff;
  border:none;
  border-radius:6px;
  font-family:'Lato',sans-serif;
  font-weight:700;
  font-size:14px;
  padding:11px 14px;
  cursor:pointer;
  transition:background .15s ease;
}
.magazine-read-btn:hover{background:#8a1327;color:#fff;}
.magazine-read-btn svg{width:16px;height:16px;flex:none;}

.magazine-empty{
  text-align:center;
  color:#8a8a8a;
  padding:40px 20px;
  font-size:15px;
}

/* ---------------- overlay reader ---------------- */
/* The topbar/footer float ON TOP of the scrolling page stack as their
   own overlay layer (position:absolute, high z-index) rather than
   reserving dedicated space in normal document flow - the reader body
   underneath just scrolls behind them. */
.magazine-reader-overlay{
  position:fixed;inset:0;
  background:#0c0908;
  z-index:9999;
  opacity:0;
  pointer-events:none;
  transition:opacity .2s ease;
  overflow:auto; /* safety net for panning a zoomed-in book beyond the viewport */
}
.magazine-reader-overlay.open{opacity:1;pointer-events:auto;}

.magazine-reader-topbar{
  position:absolute;
  top:0;left:0;right:0;
  z-index:3;
  background:linear-gradient(to bottom, rgba(0,0,0,.78), rgba(0,0,0,0));
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px 30px;
  color:#f3ece1;
  font-family:'Lato',sans-serif;
}
.magazine-reader-topbar .issue-name{font-weight:700;font-size:14px;letter-spacing:.02em;}
.magazine-close-btn{
  background:rgba(255,255,255,.14);
  border:1px solid rgba(255,255,255,.3);
  color:#fff;
  width:36px;height:36px;
  border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;
  font-size:16px;
  line-height:1;
  flex:none;
}
.magazine-close-btn:hover{background:rgba(255,255,255,.26);}

.magazine-reader-body{
  position:absolute;
  inset:0;
  overflow-y:auto;
  overflow-x:hidden;
  padding:64px 12px 48px;
}

.magazine-reader-status{
  display:none;
  flex-direction:column;
  color:#e9dfd1;
  font-family:'Lato',sans-serif;
  font-size:13px;
  text-align:center;
  max-width:280px;
  align-items:center;
  justify-content:center;
  gap:16px;
  margin:80px auto 0;
}
.magazine-reader-status a{color:#ffd98a;}
.magazine-spinner-big{
  display:inline-block;
  width:44px;height:44px;
  border-radius:50%;
  border:4px solid rgba(176,25,51,.3);
  border-top-color:#b01933;
  background:#f4efe6;
  animation:magazine-spin .8s linear infinite;
}
.magazine-status-progress{
  font-variant-numeric:tabular-nums;
  letter-spacing:.02em;
  color:#c9bfae;
}

.magazine-reader-footer{
  position:absolute;
  bottom:0;left:0;right:0;
  z-index:3;
  background:linear-gradient(to top, rgba(0,0,0,.78), rgba(0,0,0,0));
  padding:26px 16px 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  pointer-events:none;
}
.magazine-page-indicator{
  color:#e9dfd1;
  font-family:'Lato',sans-serif;
  font-size:12.5px;
  font-variant-numeric:tabular-nums;
  letter-spacing:.03em;
  min-width:78px;
  text-align:center;
}

/* ---------------- continuous-scroll pages ---------------- */
/* Each page is a plain stacked block, sized to the PDF's own aspect
   ratio up front (via a CSS aspect-ratio placeholder) so the page
   doesn't jump/reflow once its image finishes rendering in - scrolling
   past an unrendered page just shows its correctly-shaped cream
   rectangle with a small spinner until it's rendered lazily. */
.magazine-scroll-pages{
  width:100%;
  max-width:760px;
  margin:0 auto;
  display:flex;
  flex-direction:column;
  gap:14px;
}
.magazine-scroll-page{
  position:relative;
  width:100%;
  background:#f4efe6;
  box-shadow:0 6px 22px rgba(0,0,0,.35);
  overflow:hidden;
}
.magazine-scroll-page img{
  display:block;
  width:100%;
  height:100%;
  object-fit:contain;
  opacity:0;
  transition:opacity .2s ease;
}
.magazine-scroll-page img.loaded{opacity:1;}
.magazine-scroll-page::after{
  content:"";
  position:absolute;
  top:50%;left:50%;
  width:26px;height:26px;
  margin:-13px 0 0 -13px;
  border-radius:50%;
  border:3px solid rgba(176,25,51,.2);
  border-top-color:#b01933;
  animation:magazine-spin .8s linear infinite;
}
.magazine-scroll-page.rendered::after{display:none;}
@keyframes magazine-spin{to{transform:rotate(360deg);}}

@media (prefers-reduced-motion: reduce){
  .magazine-card,
  .magazine-reader-overlay,
  .magazine-cover.is-loading::after,
  .magazine-spinner-big{
    transition:none;
    animation:none;
  }
}
