/* ============================================
   EDITORIAL SERENITY - 2025-2026 TRENDING EFFECTS
   ============================================ */

/* --- NOISE / GRAIN TEXTURE OVERLAY --- */
.grain-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* --- CUSTOM CURSOR --- */
.cursor-dot {
  position: fixed;
  top: 0; left: 0;
  width: 8px; height: 8px;
  background: #43664d;
  border-radius: 50%;
  pointer-events: none;
  z-index: 10000;
  transition: transform 0.1s ease;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
}
.cursor-ring {
  position: fixed;
  top: 0; left: 0;
  width: 40px; height: 40px;
  border: 1.5px solid #43664d;
  border-radius: 50%;
  pointer-events: none;
  z-index: 10000;
  transition: width 0.3s ease, height 0.3s ease, border-color 0.3s ease;
  transform: translate(-50%, -50%);
  opacity: 0.5;
}
.cursor-ring.hovering {
  width: 60px; height: 60px;
  border-color: #84a98c;
  opacity: 0.8;
}
@media (pointer: coarse), (max-width: 768px) {
  .cursor-dot, .cursor-ring { display: none !important; }
}

/* --- SCROLL PROGRESS BAR --- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  background: linear-gradient(90deg, #43664d, #84a98c, #aad0b1);
  z-index: 9999;
  width: 0%;
  transition: width 0.05s linear;
}

/* --- SCROLL REVEAL ANIMATIONS --- */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}
.reveal-left {
  opacity: 0;
  transform: translateX(-60px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal-left.revealed {
  opacity: 1;
  transform: translateX(0);
}
.reveal-right {
  opacity: 0;
  transform: translateX(60px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal-right.revealed {
  opacity: 1;
  transform: translateX(0);
}
.reveal-scale {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal-scale.revealed {
  opacity: 1;
  transform: scale(1);
}

/* Stagger delays for cards */
.stagger-1 { transition-delay: 0.05s; }
.stagger-2 { transition-delay: 0.1s; }
.stagger-3 { transition-delay: 0.15s; }
.stagger-4 { transition-delay: 0.2s; }
.stagger-5 { transition-delay: 0.25s; }
.stagger-6 { transition-delay: 0.3s; }

/* --- TEXT REVEAL ANIMATION --- */
.text-reveal {
  overflow: hidden;
  display: inline-block;
}
.text-reveal span {
  display: inline-block;
  transform: translateY(110%);
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.text-reveal.revealed span {
  transform: translateY(0);
}
.text-reveal-line {
  overflow: hidden;
}
.text-reveal-line .line-inner {
  display: block;
  transform: translateY(105%);
  transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.text-reveal-line.revealed .line-inner {
  transform: translateY(0);
}

/* --- IMAGE REVEAL (CLIP-PATH) --- */
.img-reveal {
  clip-path: inset(100% 0 0 0);
  transition: clip-path 1s cubic-bezier(0.16, 1, 0.3, 1);
}
.img-reveal.revealed {
  clip-path: inset(0 0 0 0);
}
.img-reveal-left {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 1s cubic-bezier(0.16, 1, 0.3, 1);
}
.img-reveal-left.revealed {
  clip-path: inset(0 0 0 0);
}

/* --- MARQUEE TEXT TICKER --- */
.marquee-container {
  overflow: hidden;
  white-space: nowrap;
  padding: 2rem 0;
  border-top: 1px solid #c2c8c020;
  border-bottom: 1px solid #c2c8c020;
}
.marquee-track {
  display: inline-flex;
  animation: marquee 30s linear infinite;
}
.marquee-track:hover {
  animation-play-state: paused;
}
.marquee-item {
  display: inline-flex;
  align-items: center;
  gap: 2rem;
  padding: 0 2rem;
  font-family: 'Noto Serif', serif;
  font-size: 1.5rem;
  color: #424842;
  font-style: italic;
  opacity: 0.6;
}
.marquee-item .dot {
  width: 6px; height: 6px;
  background: #43664d;
  border-radius: 50%;
  flex-shrink: 0;
}
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* --- ANIMATED GRADIENT MESH --- */
.gradient-mesh {
  position: relative;
  overflow: hidden;
}
.gradient-mesh::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background:
    radial-gradient(ellipse at 20% 50%, #c5eccc40 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, #cfe6f240 0%, transparent 50%),
    radial-gradient(ellipse at 60% 80%, #e9e2cf40 0%, transparent 50%);
  animation: meshMove 15s ease-in-out infinite alternate;
  z-index: 0;
}
@keyframes meshMove {
  0% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(30px, -20px) rotate(3deg); }
  66% { transform: translate(-20px, 15px) rotate(-2deg); }
  100% { transform: translate(10px, -10px) rotate(1deg); }
}

/* --- MAGNETIC BUTTON --- */
.magnetic-btn {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}
.magnetic-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255,255,255,0.15) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.magnetic-btn:hover::after {
  opacity: 1;
}

/* --- BUTTON RIPPLE --- */
.ripple-btn {
  position: relative;
  overflow: hidden;
}
.ripple-btn .ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0);
  animation: ripple 0.6s ease-out;
  pointer-events: none;
}
@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* --- PARALLAX --- */
.parallax-container {
  overflow: hidden;
  position: relative;
}
.parallax-bg {
  position: absolute;
  inset: -20%;
  width: 140%;
  height: 140%;
  object-fit: cover;
  will-change: transform;
}

/* --- DARK MODE --- */
.dark body,
.dark .bg-surface,
.dark .bg-background { background-color: #121212 !important; }
.dark .bg-surface-container-low,
.dark .bg-\[\#f6f3f2\] { background-color: #1e1e1e !important; }
.dark .bg-surface-container-lowest,
.dark .bg-\[\#ffffff\] { background-color: #252525 !important; }
.dark .bg-surface-container,
.dark .bg-\[\#f0eded\] { background-color: #1a1a1a !important; }
.dark .bg-surface-container-high,
.dark .bg-\[\#eae8e7\] { background-color: #2a2a2a !important; }
.dark .bg-\[\#fbf9f8\]\/80 { background-color: rgba(18,18,18,0.85) !important; }
.dark .bg-\[\#fbf9f8\]\/95 { background-color: rgba(18,18,18,0.95) !important; }

.dark .text-on-surface,
.dark .text-\[\#1b1c1c\] { color: #e4e2e1 !important; }
.dark .text-on-surface-variant,
.dark .text-\[\#424842\] { color: #a0a8a0 !important; }
.dark h1, .dark h2, .dark h3, .dark h4 { color: #e4e2e1; }

.dark .text-primary,
.dark .text-\[\#43664d\] { color: #aad0b1 !important; }
.dark .border-\[\#43664d\] { border-color: #aad0b1 !important; }

.dark .bg-primary { background-color: #2c4e36 !important; }
.dark .bg-primary-container { background-color: #1c3e27 !important; }
.dark .bg-secondary-container { background-color: #344a53 !important; }
.dark .bg-tertiary-container { background-color: #4b4739 !important; }
.dark .bg-tertiary-container\/10 { background-color: rgba(75,71,57,0.2) !important; }

.dark .border-outline-variant\/10 { border-color: rgba(114,121,114,0.2) !important; }
.dark .border-outline-variant\/30 { border-color: rgba(114,121,114,0.3) !important; }

.dark .grain-overlay { opacity: 0.04; filter: invert(1); }
.dark .cursor-dot { background: #aad0b1; }
.dark .cursor-ring { border-color: #aad0b1; }
.dark .marquee-item { color: #a0a8a0; }
.dark .marquee-item .dot { background: #aad0b1; }

/* Dark mode toggle button */
.dark-toggle {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: #f0eded;
  border: 1px solid #c2c8c020;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9998;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.dark-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}
.dark .dark-toggle {
  background: #2a2a2a;
  border-color: rgba(170,208,177,0.2);
}
.dark-toggle .icon-sun,
.dark .dark-toggle .icon-moon { display: none; }
.dark .dark-toggle .icon-sun { display: block; }
.dark-toggle .icon-moon { display: block; }

/* --- SMOOTH LOADING TRANSITION --- */
.page-loading {
  opacity: 0;
  transform: translateY(10px);
  /* Fallback: auto-reveal after 1.5s even if JS fails to fire DOMContentLoaded */
  animation: page-fallback-reveal 0.6s ease 1.5s forwards;
}
.page-loaded {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.6s ease, transform 0.6s ease;
  animation: none;
}
@keyframes page-fallback-reveal {
  to { opacity: 1; transform: translateY(0); }
}

/* --- VIEW TRANSITION NAMES --- */
::view-transition-old(root) {
  animation: fade-out 0.3s ease-in-out;
}
::view-transition-new(root) {
  animation: fade-in 0.3s ease-in-out;
}
@keyframes fade-out {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.98); }
}
@keyframes fade-in {
  from { opacity: 0; transform: scale(1.02); }
  to { opacity: 1; transform: scale(1); }
}

/* Logo view transition */
nav a[href="/"] {
  view-transition-name: brand-logo;
}

/* --- SKELETON LOADING --- */
.skeleton {
  background: linear-gradient(90deg, #e4e2e1 25%, #f0eded 37%, #e4e2e1 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: 0.5rem;
}
.dark .skeleton {
  background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 37%, #2a2a2a 63%);
  background-size: 400% 100%;
}
@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* --- HOVER CARD LIFT --- */
.card-lift {
  border-radius: 32px;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease;
}
.card-lift:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px -8px rgba(27, 28, 28, 0.1);
  border-radius: 32px;
}
.card-lift:hover > a {
  border-radius: 32px;
  overflow: hidden;
  display: block;
}

/* --- GLOW EFFECT ON CTA --- */
.glow-cta {
  position: relative;
}
.glow-cta::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, #c5eccc, #43664d, #84a98c, #aad0b1);
  border-radius: inherit;
  z-index: -1;
  opacity: 0;
  filter: blur(12px);
  transition: opacity 0.5s ease;
}
.glow-cta:hover::before {
  opacity: 0.6;
}

/* --- BREATHING ANIMATION (for favicon visual cue) --- */
.breathing {
  animation: breathe 4s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 1; }
}

/* --- LINK HOVER UNDERLINE ANIMATION --- */
.link-hover {
  position: relative;
  text-decoration: none;
}
.link-hover::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1.5px;
  background: #43664d;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.link-hover:hover::after {
  width: 100%;
}
.dark .link-hover::after {
  background: #aad0b1;
}

/* --- KEYBOARD FOCUS VISIBLE --- */
.keyboard-nav *:focus {
  outline: 2px solid #43664d !important;
  outline-offset: 2px !important;
}
.keyboard-nav .dark *:focus {
  outline-color: #aad0b1 !important;
}

/* --- SKIP TO CONTENT --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 99999;
  background: #43664d;
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.875rem;
  transition: top 0.2s ease;
  text-decoration: none;
}
.skip-link:focus {
  top: 1rem;
}

/* --- LAZY IMAGE FADE IN --- */
img[data-src] {
  opacity: 0;
  transition: opacity 0.5s ease;
}
img.loaded, img:not([data-src]) {
  opacity: 1;
}

/* --- FLOATING ELEMENTS --- */
.float {
  animation: floating 6s ease-in-out infinite;
}
@keyframes floating {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-15px); }
}
.float-slow {
  animation: floating 8s ease-in-out infinite;
}
.float-delay {
  animation: floating 7s ease-in-out infinite;
  animation-delay: 2s;
}
