/* ─────────────────────────────────────────────────────────────
   effects.css — Scroll reveal, mobile overlay nav, hover polish
   drbarrywheeler.com
───────────────────────────────────────────────────────────── */

/* ─── Extended tokens ─────────────────────────────────────── */
:root {
  --c-glow:        rgba(154, 111, 45, 0.12);
  --c-glow-strong: rgba(154, 111, 45, 0.20);
  --ease-expo:     cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:       cubic-bezier(0.7, 0, 0.84, 0);
}

/* ─── Grain texture ───────────────────────────────────────── */
/* SVG feTurbulence noise pinned over the entire page — adds
   analogue warmth without changing any layout or colour. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ─── Reading progress bar ────────────────────────────────── */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--c-accent) 0%, #c4892a 100%);
  z-index: 1001;
  transition: width 80ms linear;
  transform-origin: left;
}

/* ─── Header scroll elevation ─────────────────────────────── */
/* z-index 50 keeps header above the mobile-nav overlay (z-index 40)
   so the hamburger/✕ button remains clickable when the menu is open. */
.site-header {
  z-index: 50 !important;
  transition: box-shadow 0.4s ease, background-color 0.4s ease !important;
}
.site-header.is-scrolled {
  background-color: rgba(250, 247, 242, 0.92) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(154, 111, 45, 0.12), 0 2px 24px rgba(31, 27, 22, 0.07);
}

/* ─── Scroll reveal ───────────────────────────────────────── */
/* JS adds .is-visible when element enters the viewport. */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.6s var(--ease-expo),
              transform 0.6s var(--ease-expo);
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}
/* Stagger variants — applied by JS on list items */
.reveal[data-delay='1'] { transition-delay: 0.06s; }
.reveal[data-delay='2'] { transition-delay: 0.12s; }
.reveal[data-delay='3'] { transition-delay: 0.18s; }
.reveal[data-delay='4'] { transition-delay: 0.24s; }
.reveal[data-delay='5'] { transition-delay: 0.30s; }

/* Reduced-motion: skip the animation entirely */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ─── Nav link animated underline ─────────────────────────── */
.site-nav__link {
  position: relative;
}
.site-nav__link::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 0%;
  height: 1.5px;
  background: var(--c-accent);
  transition: width 0.25s var(--ease-expo);
  border-radius: 1px;
}
.site-nav__link:hover::after,
.site-nav__link[aria-current='page']::after { width: 100%; }

/* ─── Homepage hero ambient glow ──────────────────────────── */
.hp-hero {
  position: relative;
  overflow: visible;
}
.hp-hero::before {
  content: '';
  position: absolute;
  right: -20px;
  top: -60px;
  width: min(500px, 100vw);
  height: 500px;
  background: radial-gradient(
    circle at 60% 40%,
    rgba(154, 111, 45, 0.06) 0%,
    rgba(196, 137, 42, 0.04) 30%,
    transparent 70%
  );
  pointer-events: none;
  animation: ambient-drift 9s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes ambient-drift {
  from { transform: translate(0,    0  ) scale(1.00); }
  to   { transform: translate(-18px, 14px) scale(1.06); }
}

/* ─── Portrait hover ──────────────────────────────────────── */
.hp-portrait {
  position: relative;
  z-index: 1;
}
.hp-portrait img {
  transition: transform 0.5s var(--ease-expo),
              box-shadow 0.5s var(--ease-expo),
              filter 0.5s ease !important;
}
.hp-portrait:hover img {
  transform: scale(1.02) rotate(0.4deg);
  box-shadow: 0 16px 56px rgba(154, 111, 45, 0.18) !important;
  filter: saturate(90%) sepia(4%) !important;
}

/* ─── Category card hover lift ────────────────────────────── */
.hp-cat {
  transition: background 0.2s, transform 0.3s var(--ease-expo),
              box-shadow 0.3s var(--ease-expo) !important;
}
.hp-cat:hover {
  background: var(--c-surface) !important;
  transform: translateY(-3px);
  box-shadow: 0 8px 28px var(--c-glow);
}

/* ─── Post list indent-on-hover ───────────────────────────── */
.hp-list__item {
  transition: padding-left 0.2s var(--ease-expo);
}
.hp-list__item:hover { padding-left: 0.5rem; }
.hp-list__item:hover .hp-list__title { color: var(--c-accent); }

/* ─── Article post-list hover ─────────────────────────────── */
.post-list__item {
  transition: padding-left 0.2s var(--ease-expo), border-color 0.2s;
}
.post-list__item:hover { padding-left: 0.5rem; }
.post-list__item:hover .post-list__title a { color: var(--c-accent); }

/* ─── More-articles hover ─────────────────────────────────── */
.more-articles__item {
  transition: padding-left 0.2s var(--ease-expo);
}
.more-articles__item:hover { padding-left: 0.35rem; }
.more-articles__item:hover .more-articles__link { color: var(--c-accent); }

/* ─── Featured badge pulse ────────────────────────────────── */
.hp-featured__badge {
  animation: badge-pulse 3.5s ease-in-out infinite;
}
@keyframes badge-pulse {
  0%,  100% { box-shadow: 0 0 0 0   rgba(154, 111, 45, 0.00); }
  50%        { box-shadow: 0 0 0 4px rgba(154, 111, 45, 0.14); }
}

/* ─── Read-link arrow animation ───────────────────────────── */
.hp-read-link {
  transition: gap 0.2s var(--ease-expo), color 0.15s !important;
}
.hp-read-link:hover { gap: 0.6rem !important; }

/* ─── Blockquote decorative quote mark ────────────────────── */
blockquote {
  position: relative;
}
blockquote::before {
  content: '\201C';
  position: absolute;
  left: -0.25rem;
  top: -0.75rem;
  font-size: 3.5rem;
  line-height: 1;
  font-family: var(--f-body);
  color: var(--c-accent);
  opacity: 0.14;
  pointer-events: none;
  user-select: none;
}

/* ─── About portrait hover ────────────────────────────────── */
.about-portrait {
  transition: transform 0.4s var(--ease-expo), box-shadow 0.4s !important;
}
.about-portrait:hover {
  transform: scale(1.03);
  box-shadow: 0 10px 36px var(--c-glow) !important;
}

/* ─── Hamburger toggle button ─────────────────────────────── */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 8px;
  transition: background 0.15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.nav-toggle:hover { background: var(--c-surface); }
.nav-toggle span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: var(--c-text);
  border-radius: 1px;
  transform-origin: center;
  transition: transform 0.35s var(--ease-expo), opacity 0.2s;
}

/* Animate to ✕ when open */
.nav-open .nav-toggle span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-open .nav-toggle span:nth-child(2) { opacity: 0; transform: scaleX(0.1); }
.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* ─── Mobile nav overlay ──────────────────────────────────── */
.mobile-nav {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding: 6rem var(--s-lg) var(--s-xl);
  background-color: var(--c-bg);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0.3s;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-open .mobile-nav {
  visibility: visible;
  opacity: 1;
}

.mobile-nav__links {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--s-xl);
}
.mobile-nav__links > li {
  border-bottom: 1px solid var(--c-border);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.45s var(--ease-expo),
              transform 0.45s var(--ease-expo);
}
.nav-open .mobile-nav__links > li { opacity: 1; transform: none; }
/* Stagger each link */
.nav-open .mobile-nav__links > li:nth-child(1) { transition-delay: 0.04s; }
.nav-open .mobile-nav__links > li:nth-child(2) { transition-delay: 0.09s; }
.nav-open .mobile-nav__links > li:nth-child(3) { transition-delay: 0.14s; }
.nav-open .mobile-nav__links > li:nth-child(4) { transition-delay: 0.19s; }
.nav-open .mobile-nav__links > li:nth-child(5) { transition-delay: 0.24s; }

.mobile-nav__links > li > a {
  display: flex;
  align-items: center;
  padding: 1.125rem 0;
  font-family: var(--f-body);
  font-size: clamp(1.375rem, 5vw, 1.75rem);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.2;
  color: var(--c-text);
  text-decoration: none;
  min-height: 56px;
  transition: color 0.15s;
}
.mobile-nav__links > li > a:hover { color: var(--c-accent); }

/* Sub-links (writing categories) */
.mobile-nav__sub {
  list-style: none;
  padding: 0 0 0.75rem 1rem;
  margin: 0;
  display: flex;
  flex-direction: column;
}
.mobile-nav__sub li { border: none; opacity: 1 !important; transform: none !important; width: 100%; }
.mobile-nav__sub a {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0;
  font-family: var(--f-ui);
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--c-muted);
  text-decoration: none;
  min-height: 36px;
  transition: color 0.15s;
  width: 100%;
}
.mobile-nav__sub a:hover { color: var(--c-text); }

.mobile-nav__footer {
  margin-top: auto;
  padding-top: var(--s-lg);
  font-family: var(--f-ui);
  font-size: 0.75rem;
  color: var(--c-muted);
}
.mobile-nav__footer a { color: var(--c-accent); text-decoration: none; }

/* ─── Breakpoint: show toggle, hide desktop nav ───────────── */
@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .site-nav    { display: none; }

  /* Prevent body scroll while menu is open */
  body.nav-open { overflow: hidden; }

  /* Better touch targets in lists */
  .hp-list__item  { padding: 1.125rem 0; }
  .post-list__item { padding: 1.125rem 0; }
}

@media (min-width: 721px) {
  .mobile-nav { display: none; }
}

/* ─── Focus improvements ──────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: 3px;
}
