<!DOCTYPE html>
<!--
  a.rehman — Digital Portfolio & Blog
  
  LAYOUT: default.html (Master template for all pages)
  
  KEY COMPONENTS:
  1. SEO Meta Tags (OG, Twitter Card, descriptions)
  2. Theme System (Dark/Light with localStorage)
  3. Navigation (Sidebar + Top Bar)
  4. Main Content Area
  5. Post Features (if page.date exists):
     - Copy Link & Print Buttons
     - Previous/Next Post Navigation
     - Carousel of All Posts
     - Giscus Comments Section
  6. Footer with Credits
  
  JAVASCRIPT FUNCTIONALITY:
  - Theme Toggle: Switches dark/light theme and persists to localStorage
  - Copy Link Button: Copies page URL to clipboard with visual feedback
  - Print Button: Opens browser print dialog
  - Carousel Navigation: Smooth horizontal scrolling through post collections
  - Keyboard Navigation: h=home, p=perspective, a=about
  - Stagger Animations: Cards fade in with 80ms interval on scroll
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title> | a.rehman</title>
  
  <!-- SEO Meta Tags -->
  <meta name="description" content="Digital Resilience & 'Ilm">
  <meta name="author" content="A. Rehman">
  <meta name="keywords" content="technology, ethics, philosophy">
  
  <!-- Open Graph -->
  <meta property="og:type" content="website">
  <meta property="og:url" content="https://arehman-dev.github.io/assets/css/style.css">
  <meta property="og:title" content="a.rehman">
  <meta property="og:description" content="Digital Resilience & 'Ilm">
  <meta property="og:image" content="https://arehman-dev.github.io/favicon.svg">
  
  <!-- Twitter Card -->
  <meta name="twitter:card" content="summary">
  <meta name="twitter:title" content="a.rehman">
  <meta name="twitter:description" content="Digital Resilience & 'Ilm">
  
  <!-- Favicon -->
  <link rel="icon" type="image/svg+xml" href="/favicon.svg">
  
  <!-- RSS Feed -->
  <link rel="alternate" type="application/rss+xml" title="a.rehman" href="/feed.xml">
  
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Lora:ital,wght@0,400;0,600;1,400&family=Playfair+Display:ital,wght@0,700;1,700&family=Noto+Nastaliq+Urdu:wght@400;700&display=swap" rel="stylesheet">
  <script src="https://unpkg.com/lucide@latest"></script>
  <link rel="stylesheet" href="/assets/css/style.css">
  
  <script>
    // Theme initialization (Prevents flash of white)
    if (localStorage.getItem('theme') === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
      document.documentElement.classList.add('dark');
    } else {
      document.documentElement.classList.remove('dark');
    }
  </script>
</head>
<body class="/assets/css/">

  <aside class="sidebar">
    <div class="sidebar-icons">
      <a href="/" title="Home"><i data-lucide="home"></i></a>
      <a href="/perspective/" title="Perspective"><i data-lucide="book-open"></i></a>
      <a href="/tasweer-kahani/" title="Tasweer Kahani"><i data-lucide="camera"></i></a>
      <a href="/about/" title="About"><i data-lucide="user"></i></a>
      
      <button id="theme-toggle" class="nav-btn" title="Toggle Theme">
        <i data-lucide="moon" class="moon-icon"></i>
        <i data-lucide="sun" class="sun-icon"></i>
      </button>
    </div>
  </aside>

  <div class="main-viewport">
    <header class="top-bar-container">
      <nav class="glass-top-bar">
        <a href="/" class="brand-logo">a.rehman</a>
        <div class="top-links">
            <a href="/perspective/" class="top-link">perspective</a>
            <div class="dropdown">
              <button class="top-link dropdown-toggle">more<i data-lucide="chevron-down" style="width: 16px; height: 16px; margin-left: 0.4rem;"></i></button>
              <div class="dropdown-menu">
                <a href="/poetry/">poetry</a>
                <a href="/collections/">collections</a>
                <a href="/archive/">archive</a>
              </div>
            </div>
            <a href="/about/" class="top-link">about</a>
            <a href="/portfolio/" class="top-link">portfolio</a>
        </div>
      </nav>
    </header>

    <main class="wrapper">
      <!-- Share & Print Buttons (for posts) -->
      

      /* --- 1. SYSTEM VARIABLES & THEMES --- */
:root {
    --bg-grad-1: #f8fbff;
    --bg-grad-2: #f4fbf7; 
    --text-main: #071e61;
    --text-muted: #397bc9;
    --accent: #01ac6a;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(7, 30, 97, 0.1);
    --glass-shadow: 0 10px 30px rgba(7, 30, 97, 0.15);
}

.dark {
    --bg-grad-1: #030b1c;
    --bg-grad-2: #05140d;
    --text-main: #f0f9f4;
    --text-muted: #8ed5ab;
    --accent: #00ff9d;
    --glass-bg: rgba(10, 15, 25, 0.6);
    --card-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

/* --- 2. BASE ARCHITECTURE --- */
html, body { min-height: 100vh; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-grad-1);
    background-image: 
        /* Subtle grain overlay */
        repeating-linear-gradient(0deg, rgba(0,0,0,0.05) 0px, rgba(0,0,0,0.05) 1px, transparent 1px, transparent 2px),
        repeating-linear-gradient(90deg, rgba(0,0,0,0.04) 0px, rgba(0,0,0,0.04) 1px, transparent 1px, transparent 2px),
        /* Radial glow - VIBRANT BLUE accent (top-left) */
        radial-gradient(ellipse 900px 700px at 15% 20%, rgba(30, 100, 200, 0.5) 0%, rgba(100, 150, 255, 0.25) 35%, transparent 60%),
        /* Radial glow - VIBRANT GREEN accent (bottom-right) */
        radial-gradient(ellipse 900px 700px at 85% 85%, rgba(20, 150, 100, 0.45) 0%, rgba(100, 200, 150, 0.2) 35%, transparent 60%),
        /* Main gradient */
        linear-gradient(135deg, var(--bg-grad-1) 0%, #f0f8fb 40%, var(--bg-grad-2) 100%);
    background-attachment: fixed;
    background-size: cover;
    display: flex;
    transition: background-color 0.4s ease, color 0.4s ease;
}

h1, h2, h3 { font-family: 'Playfair Display', serif; color: var(--text-main); }
p { font-family: 'Lora', serif; max-width: 70ch; }

a {
    color: var(--text-main);
    text-decoration: none;
}

a:visited {
    color: var(--text-main);
}

a:hover {
    color: var(--accent);
}

/* --- 3. SIDEBAR & TOOLS --- */
.sidebar {
    position: fixed; left: 20px; top: 50%; transform: translateY(-50%);
    width: 56px; height: auto; padding: 30px 0; border-radius: 40px;
    background: var(--glass-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border); box-shadow: var(--glass-shadow); z-index: 1000;
    display: flex; flex-direction: column; justify-content: center;
}

.sidebar-icons { display: flex; flex-direction: column; align-items: center; gap: 1.8rem; width: 100%; }

.sidebar-icons a, .nav-btn {
    display: flex; justify-content: center; align-items: center;
    /* width: 44px; height: 44px; background: transparent; border: none; cursor: pointer; */
    width: 38px; height: 38px; background: transparent; border: none; cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); color: var(--text-muted);
}

.sidebar-icons a svg, .nav-btn svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2; }

.sidebar-icons a:hover, .nav-btn:hover { transform: scale(1.15); color: var(--accent); }

/* Theme Toggle Visibility */
.sun-icon { display: none; }
.dark .moon-icon { display: none; }
.dark .sun-icon { display: block; }

/* Dark theme background enhancement */
html.dark body {
    background-image: 
        /* Subtle grain overlay */
        repeating-linear-gradient(0deg, rgba(255,255,255,0.03) 0px, rgba(255,255,255,0.03) 1px, transparent 1px, transparent 2px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 2px),
        /* Radial glow - cyan/blue accent (top-left) */
        radial-gradient(ellipse 800px 600px at 15% 20%, rgba(0, 255, 157, 0.12) 0%, transparent 50%),
        /* Radial glow - teal accent (bottom-right) */
        radial-gradient(ellipse 900px 700px at 85% 85%, rgba(0, 200, 200, 0.1) 0%, transparent 50%),
        /* Main gradient */
        linear-gradient(135deg, var(--bg-grad-1) 0%, #051410 40%, var(--bg-grad-2) 100%);
    background-attachment: fixed;
}

/* --- 4. TOP BAR (CENTERED WITHIN VIEWPORT) --- */
.main-viewport {
    flex: 1;
    margin-left: 88px;
    margin-right: 88px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center; /* Ensures header/footer center within this space */
}

.top-bar-container {
    position: sticky;
    top: 20px;
    z-index: 900;
    width: 100%;
    max-width: 1400px;
    padding: 0 40px;
    display: flex;
    justify-content: center;
    box-sizing: border-box;
}

.glass-top-bar {
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 0.8rem 2.5rem;
    border-radius: 20px;
    border: 1px solid var(--card-border);
    box-shadow: 0 15px 35px rgba(7, 30, 97, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.brand-logo { 
    font-family: 'Playfair Display', serif; 
    font-weight: 700; font-style: italic; 
    font-size: 1.4rem; text-decoration: none; 
    color: var(--text-main); 
}
.top-links { display: flex; gap: 2rem; align-items: center; }

.top-links a { 
    text-decoration: none; 
    font-family: 'Lora', serif;
    font-weight: 400; 
    font-style: italic;
    font-size: 1.05rem;
    transition: all 0.2s ease;
}

.top-links a[href] {
    color: var(--text-muted);
}

/* Dropdown Menu Styling */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'Lora', serif;
    font-weight: 400;
    font-style: italic;
    font-size: 1.05rem;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.dropdown-toggle:hover {
    color: var(--accent);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(7, 30, 97, 0.1);
    padding: 0.8rem 0;
    margin-top: 0.5rem;
    min-width: 160px;
    opacity: 1;
    visibility: hidden;
    transform: translateY(-5px);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 1001;
}

.dropdown:hover .dropdown-menu {
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu a {
    padding: 0.8rem 2rem;
    text-decoration: none;
    color: var(--text-muted);
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: 1.05rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.dropdown-menu a:hover {
    color: var(--accent);
    background: rgba(255, 255, 255, 0.05);
    padding-left: 1.4rem;
}

/* --- 5.5 PORTRAIT WITH GRADIENT BORDER --- */
.about-portrait-wrapper {
    position: relative;
    width: 100%;
    max-width: 320px;
    margin: 2rem auto;
}

.about-portrait {
    aspect-ratio: 4 / 3;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(1, 172, 106, 0.3), rgba(0, 255, 157, 0.2));
    padding: 3px;
    box-shadow: 0 15px 40px rgba(1, 172, 106, 0.15);
}

.about-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 13px;
    display: block;
}

.glass-top-bar:hover { transform: translateY(-3px); box-shadow: var(--glass-shadow); }

/* --- 5. CARDS & GRID REFINEMENT --- */
.wrapper { 
    width: 100%;
    max-width: 1100px; 
    padding: 3rem 2rem 4rem 2rem; 
    box-sizing: border-box; 
}

.card-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); 
    gap: 4rem; 
    margin: 2.5rem 0;
}

.content-card {
    background: var(--glass-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 2.5rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: 0 10px 30px rgba(7, 30, 97, 0.08); /* Increased Shadow */
}

.content-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 25px 60px rgba(1, 172, 106, 0.2);
    border-color: var(--accent);
}

/* --- 6. TASWEER-KAHANI GRID & HOVER --- */
.photo-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); 
    gap: 1.5rem; 
    margin-top: 2rem;
}

.photo-card {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    transition: all 0.4s ease;
    cursor: pointer;
}

.photo-card img { 
    width: 100%; 
    height: 400px; 
    object-fit: cover; 
    border-radius: 16px; 
    display: block;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.photo-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.photo-card:hover img {
    transform: scale(1.08); /* Re-implemented zoom effect */
}

/* --- PHOTO MODAL --- */
.photo-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.photo-modal.active {
    display: flex;
}

.photo-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-modal-image {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 12px;
    animation: slideIn 0.3s ease;
}

.photo-modal-close {
    position: absolute;
    top: -45px;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.photo-modal-close:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.dark .photo-modal-close {
    background: rgba(50, 50, 50, 0.9);
    color: #f0f9f4;
}

.dark .photo-modal-close:hover {
    background: rgba(50, 50, 50, 1);
}

.photo-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
}

.photo-modal-nav:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(-50%) scale(1.1);
}

.photo-modal-nav.prev {
    left: 20px;
}

.photo-modal-nav.next {
    right: 20px;
}

.photo-modal-caption {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-style: italic;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.photo-modal.active .photo-modal-caption {
    opacity: 1;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        transform: scale(0.9);
        opacity: 0;
    }
    to { 
        transform: scale(1);
        opacity: 1;
    }
}

/* --- 7. POST ACTIONS (SHARE & PRINT) --- */
.post-actions {
    display: flex;
    gap: 1rem;
    margin: 2rem 0 1rem 0;
    flex-wrap: wrap;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--card-border);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
    transform: scale(1.05);
}

.action-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

/* --- 9. POST NAVIGATION (PREV/NEXT) --- */
.post-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin: 3rem 0 2rem 0;
    padding-top: 2rem;
    border-top: 1px solid var(--card-border);
}

.post-nav-link {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

.post-nav-link:hover {
    background: rgba(1, 172, 106, 0.05);
    border-color: var(--accent);
    transform: translateX(5px);
}

.post-nav-link.next:hover {
    transform: translateX(-5px);
}

.nav-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.nav-title {
    font-family: 'Lora', serif;
    font-size: 1rem;
    color: var(--text-main);
    font-weight: 600;
}

/* --- 10. POSTS CAROUSEL --- */
.posts-section {
    margin: 3rem 0;
}

.posts-section h3 {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
}

.posts-carousel {
    position: relative;
    margin: 0 -1.5rem 2rem -1.5rem;
    padding: 0 1.5rem;
}

/* --- 10. CAROUSEL HEADER & CONTROLS --- */
.carousel-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 1.5rem;
}

.carousel-controls {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.carousel-track {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding-bottom: 0.5rem;
    /* Hide scrollbar but keep functionality */
    scrollbar-width: none;
}

.carousel-track::-webkit-scrollbar {
    display: none;
}

.carousel-card {
    flex: 0 0 280px;
    padding: 1.2rem;
    background: var(--glass-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    text-decoration: none;
    color: inherit;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    display: flex;
    flex-direction: column;
}

.carousel-card:hover {
    border-color: var(--accent);
    box-shadow: 0 20px 50px rgba(1, 172, 106, 0.15);
}

.carousel-card .card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.carousel-card h4 {
    font-size: 1rem;
    margin: 0.5rem 0;
    line-height: 1.3;
}

.carousel-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
    flex-grow: 1;
}

.carousel-nav {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0.6;
    color: var(--text-muted);
}

.carousel-nav:hover {
    opacity: 1;
    background: var(--glass-bg);
    border-color: var(--accent);
    color: var(--accent);
}

.carousel-nav.prev {
}

.carousel-nav.next {
}

/* --- 11. COMMENTS SECTION --- */
.comments-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--card-border);
}

.comments-section h3 {
    margin-bottom: 1.5rem;
}

/* --- 12. FOOTER CREDITS --- */
.site-footer {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
    margin-top: 2rem;
    padding-bottom: 2rem;
}

.site-footer p {
    font-style: italic;
    margin: 0;
}

.footer-credits {
    font-size: inherit;
    margin: 0;
    opacity: 0.7;
    font-style: italic;
}

.footer-credits a {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    text-decoration: underline;
    transition: color 0.2s ease;
}

.footer-credits a:hover {
    color: var(--accent);
}

/* --- ANIMATIONS --- */
.has-animation { 
    /* OLD: animation delay index * 100ms */
    /* Now using stagger with reduced delay for smoother effect */
    opacity: 0; 
    transform: translateY(30px); 
    transition: all 0.8s ease-out; 
}

.has-animation.is-visible { 
    opacity: 1; 
    transform: translateY(0); 
}

      <!-- Previous / Next Post Navigation -->
      

      <!-- Giscus Comments Section - TEMPORARILY DISABLED -->
      

    </main>

    <footer class="site-footer">
      <p>&copy; 2026 — a digital window to my life. handcrafted with precision.</p>
      <p class="footer-credits">
        inspired by 
        <a href="https://paulstamatiou.com" target="_blank" rel="noopener noreferrer">paul stamatiou</a>, 
        <a href="https://darioamodei.com" target="_blank" rel="noopener noreferrer">dario amodei</a>
      </p>
    </footer>
  </div>

  <script>
    lucide.createIcons();

    // Theme Toggle Logic
    const themeToggleBtn = document.getElementById('theme-toggle');
    themeToggleBtn.addEventListener('click', () => {
      document.documentElement.classList.toggle('dark');
      const isDark = document.documentElement.classList.contains('dark');
      localStorage.setItem('theme', isDark ? 'dark' : 'light');
    });

    // Copy Link Button
    const copyLinkBtn = document.getElementById('copy-link-btn');
    if (copyLinkBtn) {
      copyLinkBtn.addEventListener('click', () => {
        navigator.clipboard.writeText(window.location.href).then(() => {
          const originalText = copyLinkBtn.innerHTML;
          copyLinkBtn.innerHTML = '<i data-lucide="check"></i> Copied!';
          lucide.createIcons();
          setTimeout(() => {
            copyLinkBtn.innerHTML = originalText;
            lucide.createIcons();
          }, 2000);
        });
      });
    }

    // Print Button
    const printBtn = document.getElementById('print-btn');
    if (printBtn) {
      printBtn.addEventListener('click', () => {
        window.print();
      });
    }

    // Carousel Navigation
    const carousels = document.querySelectorAll('.posts-carousel');
    carousels.forEach(carousel => {
      const track = carousel.querySelector('.carousel-track');
      
      // Find buttons in the preceding .carousel-header element
      const header = carousel.previousElementSibling;
      const prevBtn = header ? header.querySelector('.carousel-nav.prev') : null;
      const nextBtn = header ? header.querySelector('.carousel-nav.next') : null;
      
      const scroll = (direction) => {
        const cardWidth = track.querySelector('.carousel-card').offsetWidth + 20; // card width + gap
        track.scrollBy({ left: direction * cardWidth * 2, behavior: 'smooth' });
      };
      
      if (prevBtn) prevBtn.addEventListener('click', () => scroll(-1));
      if (nextBtn) nextBtn.addEventListener('click', () => scroll(1));
    });

    // Keyboard Navigation
    document.addEventListener('keydown', (e) => {
      // Skip if user is typing in an input
      if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
      
      // 'h' key - go home
      if (e.key === 'h' || e.key === 'H') window.location.href = '/';
      
      // 'p' key - go to perspective
      if (e.key === 'p' || e.key === 'P') window.location.href = '/perspective/';
      
      // 'a' key - go to about
      if (e.key === 'a' || e.key === 'A') window.location.href = '/about/';
    });

    // Content Animation - Stagger effect for cards
    document.addEventListener("DOMContentLoaded", () => {
      const observer = new IntersectionObserver((entries) => {
        entries.forEach((entry, index) => {
          if (entry.isIntersecting) {
            /* Stagger animation - each card appears with delay */
            setTimeout(() => entry.target.classList.add('is-visible'), index * 80);
            observer.unobserve(entry.target);
          }
        });
      }, { threshold: 0.1 });

      document.querySelectorAll('.content-card, .photo-card').forEach(el => {
        el.classList.add('has-animation');
        observer.observe(el);
      });
    });
  </script>

  <!-- Photo Modal -->
  <div id="photo-modal" class="photo-modal">
    <div class="photo-modal-content">
      <button id="modal-close" class="photo-modal-close">&times;</button>
      <img id="modal-image" class="photo-modal-image" src="" alt="">
      <button id="modal-prev" class="photo-modal-nav prev">❮</button>
      <button id="modal-next" class="photo-modal-nav next">❯</button>
      <div id="modal-caption" class="photo-modal-caption"></div>
    </div>
  </div>

  <script>
    // Photo Gallery Modal
    const modal = document.getElementById('photo-modal');
    const modalImage = document.getElementById('modal-image');
    const modalCaption = document.getElementById('modal-caption');
    const modalClose = document.getElementById('modal-close');
    const prevBtn = document.getElementById('modal-prev');
    const nextBtn = document.getElementById('modal-next');

    let currentGallery = [];
    let currentIndex = 0;

    // Build galleries from data attributes
    const galleries = {};
    const photoCards = document.querySelectorAll('.photo-card[data-gallery]');

    photoCards.forEach(card => {
      const galleryKey = card.dataset.gallery;
      const imageSrc = card.dataset.image;
      const imageAlt = card.dataset.alt;

      if (!galleries[galleryKey]) {
        galleries[galleryKey] = [];
      }

      galleries[galleryKey].push({
        src: imageSrc,
        alt: imageAlt,
        element: card
      });
    });

    // Attach click listeners to all photo cards
    Object.keys(galleries).forEach(galleryKey => {
      galleries[galleryKey].forEach((image, imageIndex) => {
        image.element.addEventListener('click', () => {
          currentGallery = galleries[galleryKey];
          currentIndex = imageIndex;
          showImage();
          modal.classList.add('active');
          document.body.style.overflow = 'hidden';
        });

        image.element.addEventListener('keydown', (e) => {
          if (e.key === 'Enter' || e.key === ' ') {
            e.preventDefault();
            currentGallery = galleries[galleryKey];
            currentIndex = imageIndex;
            showImage();
            modal.classList.add('active');
            document.body.style.overflow = 'hidden';
          }
        });
      });
    });

    function showImage() {
      if (!currentGallery || currentGallery.length === 0) return;
      const image = currentGallery[currentIndex];
      modalImage.src = image.src;
      modalImage.alt = image.alt;
      modalCaption.textContent = image.alt;
    }

    function closeModal() {
      modal.classList.remove('active');
      document.body.style.overflow = '';
    }

    function nextImage() {
      if (!currentGallery || currentGallery.length === 0) return;
      currentIndex = (currentIndex + 1) % currentGallery.length;
      showImage();
    }

    function prevImage() {
      if (!currentGallery || currentGallery.length === 0) return;
      currentIndex = (currentIndex - 1 + currentGallery.length) % currentGallery.length;
      showImage();
    }

    // Event listeners
    if (modalClose) modalClose.addEventListener('click', closeModal);
    if (nextBtn) nextBtn.addEventListener('click', nextImage);
    if (prevBtn) prevBtn.addEventListener('click', prevImage);

    // Keyboard controls
    document.addEventListener('keydown', (e) => {
      if (e.key === 'Escape' && modal.classList.contains('active')) {
        closeModal();
      }
      if (modal.classList.contains('active')) {
        if (e.key === 'ArrowRight') nextImage();
        if (e.key === 'ArrowLeft') prevImage();
      }
    });

    // Close on background click
    modal.addEventListener('click', (e) => {
      if (e.target === modal) closeModal();
    });
  </script>

  <!-- Photo Modal -->
  <div id="photo-modal" class="photo-modal">
    <div class="photo-modal-content">
      <button id="modal-close" class="photo-modal-close">&times;</button>
      <img id="modal-image" class="photo-modal-image" src="" alt="">
      <button id="modal-prev" class="photo-modal-nav prev">❮</button>
      <button id="modal-next" class="photo-modal-nav next">❯</button>
      <div id="modal-caption" class="photo-modal-caption"></div>
    </div>
  </div>
</body>
</html>
