/* ================================================================
   JAMAL & LAYLA THEME — Magical Inner Pages
   Making every page feel alive for little explorers
   ================================================================ */

/* --- Google Fonts (loaded via functions.php too) --- */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Baloo+2:wght@400;500;600;700;800&display=swap');

/* --- Variables --- */
:root {
  --sky: #4A90D9;
  --meadow: #7BC67E;
  --gold: #F5A623;
  --pink: #E8739A;
  --purple: #9B6FCF;
  --orange: #F09D51;
  --teal: #5CBFCF;
  --cream: #FFF8E7;
  --cloud: #F0F7FF;
  --night: #2C3E50;
  --white: #fff;
  --bounce: cubic-bezier(0.34,1.56,0.64,1);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Fredoka', sans-serif;
  background: var(--cream);
  color: var(--night);
  overflow-x: hidden;
  min-height: 100vh;
}
img { max-width: 100%; height: auto; display: block; }
a { text-decoration: none; color: inherit; }

/* --- Animations --- */
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
@keyframes floatSlow { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
@keyframes floatWide { 0%,100%{transform:translate(0,0) rotate(0)} 25%{transform:translate(6px,-10px) rotate(2deg)} 50%{transform:translate(-3px,-14px) rotate(-1deg)} 75%{transform:translate(-8px,-4px) rotate(1deg)} }
@keyframes fadeUp { from{opacity:0;transform:translateY(40px) scale(.96)} to{opacity:1;transform:translateY(0) scale(1)} }
@keyframes popIn { 0%{opacity:0;transform:scale(0) rotate(-15deg)} 60%{transform:scale(1.15) rotate(3deg)} 100%{opacity:1;transform:scale(1) rotate(0)} }
@keyframes wiggle { 0%,100%{transform:rotate(0)} 15%{transform:rotate(5deg)} 30%{transform:rotate(-5deg)} 45%{transform:rotate(3deg)} 60%{transform:rotate(-2deg)} }
@keyframes bounce { 0%,100%{transform:translateY(0)} 40%{transform:translateY(-16px)} 60%{transform:translateY(-8px)} }
@keyframes glow { 0%,100%{box-shadow:0 0 20px rgba(245,166,35,.3)} 50%{box-shadow:0 0 40px rgba(245,166,35,.6)} }
@keyframes sparkleFloat { 0%{opacity:1;transform:translateY(0) scale(1)} 100%{opacity:0;transform:translateY(-50px) scale(0) rotate(360deg)} }
@keyframes shimmer { 0%{background-position:-200% 0} 100%{background-position:200% 0} }
@keyframes rainbowBg { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} }
@keyframes floatEmoji { 0%{transform:translateY(100vh) rotate(0) scale(.5);opacity:0} 10%{opacity:.6} 90%{opacity:.4} 100%{transform:translateY(-10vh) rotate(340deg) scale(.3);opacity:0} }
@keyframes slideUp { from{opacity:0;transform:translateY(30px)} to{opacity:1;transform:translateY(0)} }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.05)} }

/* --- Scroll Reveal --- */
.jl-reveal { opacity:0; transform:translateY(40px); transition:all .8s var(--bounce); }
.jl-reveal.show { opacity:1; transform:translateY(0); }

/* --- Sparkle Layer (site-wide) --- */
.jl-page-sparkles { position:fixed; inset:0; pointer-events:none; z-index:9999; overflow:hidden; }

/* --- Floating Background Emojis --- */
.jl-bg-emoji { position:absolute; pointer-events:none; font-size:28px; opacity:.08; animation:floatWide 10s ease-in-out infinite; z-index:0; }

/* ============================
   ARCHIVE HERO
   ============================ */
.jl-archive-hero {
  background: linear-gradient(180deg, var(--cloud) 0%, var(--cream) 100%);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.jl-archive-hero::before {
  content: '✨';
  position: absolute;
  top: 20%;
  left: 8%;
  font-size: 28px;
  opacity: .12;
  animation: floatWide 8s ease-in-out infinite;
  pointer-events: none;
}
.jl-archive-hero::after {
  content: '🌟';
  position: absolute;
  bottom: 15%;
  right: 6%;
  font-size: 24px;
  opacity: .1;
  animation: floatWide 10s ease-in-out infinite -3s;
  pointer-events: none;
}

.jl-archive-title {
  font-family: 'Baloo 2', cursive !important;
  background: linear-gradient(135deg, var(--purple), var(--pink), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: fadeUp .8s var(--bounce) both;
  line-height: 1.1 !important;
  margin-bottom: 8px !important;
}

.jl-archive-desc {
  color: #7a8a9a !important;
  max-width: 500px;
  margin: 0 auto !important;
  animation: fadeUp .8s var(--bounce) .1s both;
}

/* ============================
   POST CARD GRID
   ============================ */
.jl-post-grid {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 24px !important;
}

@media (max-width: 900px) {
  .jl-post-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 600px) {
  .jl-post-grid { grid-template-columns: 1fr !important; gap: 18px !important; }
}

/* Post Cards - ALIVE */
.jl-post-card {
  border-radius: 24px !important;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0,0,0,.06) !important;
  transition: all .5s var(--bounce) !important;
  cursor: pointer;
  position: relative;
  animation: fadeUp .6s var(--bounce) both;
}
.jl-post-card:nth-child(1) { animation-delay: .05s; }
.jl-post-card:nth-child(2) { animation-delay: .1s; }
.jl-post-card:nth-child(3) { animation-delay: .15s; }
.jl-post-card:nth-child(4) { animation-delay: .2s; }
.jl-post-card:nth-child(5) { animation-delay: .25s; }
.jl-post-card:nth-child(6) { animation-delay: .3s; }

.jl-post-card:hover {
  transform: translateY(-12px) rotate(-1deg) scale(1.02) !important;
  box-shadow: 0 20px 50px rgba(0,0,0,.12) !important;
}

.jl-post-card .wp-block-post-featured-image {
  overflow: hidden;
  aspect-ratio: 16/10;
}
.jl-post-card .wp-block-post-featured-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s var(--bounce);
}
.jl-post-card:hover .wp-block-post-featured-image img {
  transform: scale(1.08);
}

.jl-post-card .wp-block-post-title {
  font-family: 'Baloo 2', cursive !important;
  line-height: 1.2 !important;
  margin-bottom: 6px !important;
  transition: color .3s;
}
.jl-post-card .wp-block-post-title a {
  color: var(--night) !important;
  transition: color .3s;
}
.jl-post-card:hover .wp-block-post-title a {
  color: var(--purple) !important;
}

.jl-post-card .wp-block-post-excerpt {
  color: #7a8a9a;
  font-size: 14px;
  line-height: 1.6;
}

/* No featured image placeholder */
.jl-post-card .wp-block-post-featured-image:empty {
  background: linear-gradient(135deg, var(--sky), var(--purple));
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.jl-post-card .wp-block-post-featured-image:empty::after {
  content: '📖';
  font-size: 50px;
  animation: floatSlow 3s ease-in-out infinite;
}

/* ============================
   EMPTY STATE
   ============================ */
.jl-empty-state {
  text-align: center;
  animation: fadeUp .8s var(--bounce) both;
}
.jl-empty-state p:first-child {
  animation: bounce 2s ease-in-out infinite;
}

/* ============================
   PAGINATION
   ============================ */
.jl-pagination {
  margin-top: 48px !important;
}
.jl-pagination .wp-block-query-pagination-numbers .page-numbers,
.jl-pagination a,
.jl-pagination span {
  padding: 10px 18px !important;
  border-radius: 14px !important;
  font-family: 'Fredoka', sans-serif !important;
  font-weight: 600 !important;
  font-size: 15px !important;
  transition: all .3s var(--bounce) !important;
  background: var(--white) !important;
  box-shadow: 0 3px 12px rgba(0,0,0,.06) !important;
}
.jl-pagination .page-numbers:hover,
.jl-pagination a:hover {
  transform: translateY(-3px) !important;
  box-shadow: 0 8px 20px rgba(0,0,0,.1) !important;
  color: var(--purple) !important;
}
.jl-pagination .page-numbers.current {
  background: linear-gradient(135deg, var(--purple), var(--pink)) !important;
  color: white !important;
}

/* ============================
   SINGLE POST
   ============================ */
.jl-single-hero {
  background: linear-gradient(180deg, var(--cloud) 0%, var(--cream) 100%);
  position: relative;
}

.jl-single-image {
  border-radius: 28px !important;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,.1);
  animation: fadeUp .8s var(--bounce) both;
  max-height: 500px;
}
.jl-single-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.jl-single-content {
  background: var(--cream);
}

.jl-single-title {
  font-family: 'Baloo 2', cursive !important;
  color: var(--night) !important;
  animation: fadeUp .8s var(--bounce) .1s both;
  line-height: 1.1 !important;
}

.jl-single-meta {
  animation: fadeUp .8s var(--bounce) .2s both;
}
.jl-single-meta .wp-block-post-date {
  color: #999;
}

.jl-term-pills a {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 100px;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: white !important;
  font-size: 12px !important;
  font-weight: 700;
  transition: all .3s var(--bounce);
}
.jl-term-pills a:hover {
  transform: translateY(-2px) scale(1.05);
}

/* Article body */
.jl-article-body {
  animation: fadeUp .8s var(--bounce) .3s both;
}
.jl-article-body p {
  font-size: 17px;
  line-height: 1.8;
  color: #4a5568;
  margin-bottom: 1.5em;
}
.jl-article-body h2,
.jl-article-body h3,
.jl-article-body h4 {
  font-family: 'Baloo 2', cursive;
  color: var(--night);
  margin-top: 2em;
  margin-bottom: .5em;
}
.jl-article-body h2 { font-size: 28px; }
.jl-article-body h3 { font-size: 22px; }
.jl-article-body img {
  border-radius: 20px;
  box-shadow: 0 8px 28px rgba(0,0,0,.08);
  margin: 2em auto;
}
.jl-article-body blockquote {
  border-left: 4px solid var(--gold);
  background: var(--cloud);
  padding: 20px 24px;
  border-radius: 0 16px 16px 0;
  margin: 2em 0;
  font-style: italic;
}
.jl-article-body ul, .jl-article-body ol {
  padding-left: 1.5em;
  margin-bottom: 1.5em;
}
.jl-article-body li {
  margin-bottom: .5em;
  line-height: 1.7;
}

/* Post navigation */
.jl-post-nav a {
  padding: 12px 24px;
  border-radius: 14px;
  background: var(--white);
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 15px;
  transition: all .3s var(--bounce);
}
.jl-post-nav a:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  color: var(--purple);
}

/* ============================
   404 PAGE
   ============================ */
.jl-404 {
  background: var(--cream);
  text-align: center;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.jl-404 > p:first-child {
  animation: bounce 2s ease-in-out infinite;
}
.jl-404 h2 {
  font-family: 'Baloo 2', cursive !important;
  background: linear-gradient(135deg, var(--gold), var(--orange), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: fadeUp .8s var(--bounce) both;
}

/* ============================
   BUTTONS (site-wide)
   ============================ */
.jl-btn-primary .wp-block-button__link,
.wp-block-button.jl-btn-primary .wp-block-button__link {
  background: linear-gradient(135deg, var(--gold), var(--orange)) !important;
  color: white !important;
  font-family: 'Fredoka', sans-serif !important;
  font-weight: 700 !important;
  border-radius: 100px !important;
  box-shadow: 0 6px 20px rgba(245,166,35,.3);
  transition: all .4s var(--bounce) !important;
}
.jl-btn-primary .wp-block-button__link:hover {
  transform: translateY(-4px) scale(1.05) !important;
  box-shadow: 0 10px 30px rgba(245,166,35,.4) !important;
}

/* ============================
   FOOTER (block theme)
   ============================ */
.jl-footer {
  font-family: 'Fredoka', sans-serif;
}
.jl-footer h3, .jl-footer h4 {
  font-family: 'Baloo 2', cursive !important;
}
.jl-footer-nav .wp-block-navigation-item a {
  color: rgba(255,255,255,.5) !important;
  transition: all .3s var(--bounce);
}
.jl-footer-nav .wp-block-navigation-item a:hover {
  color: var(--gold) !important;
  transform: translateX(4px);
}
.jl-footer .wp-block-navigation__container {
  flex-direction: column !important;
  gap: 6px;
}

/* ============================
   SHARED CARD STYLES
   ============================ */
.jl-card {
  background: white;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,.06);
  transition: all .5s var(--bounce);
  cursor: pointer;
}
.jl-card:hover {
  transform: translateY(-10px) rotate(-1deg);
  box-shadow: 0 18px 44px rgba(0,0,0,.1);
}

/* Horizontal scroll container */
.jl-h-scroll {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding: 8px 4px 20px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.jl-h-scroll::-webkit-scrollbar { display: none; }

/* ============================
   ACCESSIBILITY & MOTION
   ============================ */
:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .2s !important;
  }
}

/* ============================
   JOIN BUTTON (jl-navigation)
   ============================ */
.jl-nav-cta {
  animation: glow 3s ease-in-out infinite;
}

/* ============================
   RESPONSIVE TWEAKS
   ============================ */
@media (max-width: 768px) {
  .jl-archive-hero { padding-top: 40px !important; padding-bottom: 40px !important; }
  .jl-single-image { border-radius: 20px !important; }
}
