/* Custom styles to complement Tailwind CSS */

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Smooth scrolling for the entire page */
html {
    scroll-behavior: smooth;
}

/* Custom animations for interactive elements */
.feature-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Focus-visible styles for better accessibility */
:focus-visible {
    outline: 2px solid #3B82F6;
    outline-offset: 2px;
}
:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

/* Custom gradient animations */
.gradient-animate {
    background-size: 200% 200%;
    animation: gradient 3s ease infinite;
}

@keyframes gradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Custom loading spinner */
.spinner {
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3B82F6;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Custom scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #3B82F6;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #2563EB;
}

/* What I Do card interactions */
.whatido-card {
    border-left: 3px solid transparent;
    background: transparent;
    transform: translateY(0);
    box-shadow: none;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.25s ease,
                border-color 0.25s ease,
                background-color 0.25s ease;
    cursor: pointer;
    text-decoration: none;
}

.whatido-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.7);
}

.whatido-card:active {
    transform: translateY(-1px);
}

/* Accent-colored shadows and borders per variant */
.whatido-card--primary:hover {
    border-left-color: #3B82F6;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.18), 0 2px 8px rgba(0, 0, 0, 0.06);
}
.whatido-card--primary:active {
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.14), 0 1px 4px rgba(0, 0, 0, 0.04);
}

.whatido-card--secondary:hover {
    border-left-color: #10B981;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.18), 0 2px 8px rgba(0, 0, 0, 0.06);
}
.whatido-card--secondary:active {
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.14), 0 1px 4px rgba(0, 0, 0, 0.04);
}

.whatido-card--accent:hover {
    border-left-color: #06B6D4;
    box-shadow: 0 8px 24px rgba(6, 182, 212, 0.18), 0 2px 8px rgba(0, 0, 0, 0.06);
}
.whatido-card--accent:active {
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.14), 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* Icon scale on hover */
.whatido-card__icon {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.whatido-card:hover .whatido-card__icon {
    transform: scale(1.12);
}

/* Title color on hover */
.whatido-card__title {
    transition: color 0.25s ease;
}
.whatido-card--primary:hover .whatido-card__title { color: #3B82F6; }
.whatido-card--secondary:hover .whatido-card__title { color: #10B981; }
.whatido-card--accent:hover .whatido-card__title { color: #06B6D4; }

/* Arrow slide-in on hover */
.whatido-card__arrow {
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.whatido-card:hover .whatido-card__arrow {
    opacity: 1;
    transform: translateX(0);
}
.whatido-card--primary .whatido-card__arrow { color: #3B82F6; }
.whatido-card--secondary .whatido-card__arrow { color: #10B981; }
.whatido-card--accent .whatido-card__arrow { color: #06B6D4; }

/* Tech stack tile glow */
.tech-stack-tile {
    transition: box-shadow 0.3s ease, background-color 0.3s ease;
}
.tech-stack-tile:hover {
    box-shadow: 0 0 16px rgba(255, 255, 255, 0.3);
    background-color: rgba(255, 255, 255, 0.3);
}

/* Terminal typing animation */
.terminal-line {
    opacity: 0;
    animation: terminalFadeIn 0.4s ease forwards;
}

.terminal-line:nth-child(2) { animation-delay: 0.5s; }
.terminal-line:nth-child(3) { animation-delay: 1.0s; }
.terminal-line:nth-child(4) { animation-delay: 1.5s; }
.terminal-line:nth-child(5) { animation-delay: 2.0s; }
.terminal-line:nth-child(6) { animation-delay: 2.4s; }
.terminal-line:nth-child(7) { animation-delay: 2.8s; }
.terminal-line:nth-child(8) { animation-delay: 3.3s; }
.terminal-line:nth-child(9) { animation-delay: 3.8s; }
.terminal-line:nth-child(10) { animation-delay: 4.2s; }
.terminal-line:nth-child(11) { animation-delay: 4.6s; }
.terminal-line:nth-child(12) { animation-delay: 5.0s; }
.terminal-line:nth-child(13) { animation-delay: 5.4s; }
.terminal-line:nth-child(14) { animation-delay: 5.8s; }
.terminal-line:nth-child(15) { animation-delay: 6.2s; }

@keyframes terminalFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.terminal-cursor {
    animation: blink-caret 0.8s step-end infinite;
}

@keyframes blink-caret {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Article prose overrides */
.prose pre code {
    font-size: 0.875rem;
}

.prose img {
    margin-left: auto;
    margin-right: auto;
}

.prose figcaption {
    text-align: center;
    color: #6b7280;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* ============================================
   Phase 1A: Scroll Reveal System
   ============================================ */

.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.reveal-left {
    opacity: 0;
    transform: translateX(-24px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal-left.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(24px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal-right.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal-scale.is-visible {
    opacity: 1;
    transform: scale(1);
}

/* Stagger children */
.reveal-stagger > .reveal:nth-child(1) { transition-delay: 0ms; }
.reveal-stagger > .reveal:nth-child(2) { transition-delay: 80ms; }
.reveal-stagger > .reveal:nth-child(3) { transition-delay: 160ms; }
.reveal-stagger > .reveal:nth-child(4) { transition-delay: 240ms; }
.reveal-stagger > .reveal:nth-child(5) { transition-delay: 320ms; }
.reveal-stagger > .reveal:nth-child(6) { transition-delay: 400ms; }

/* ============================================
   Phase 1B: Page Transition Overlay
   ============================================ */

.page-transition {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #F0F9FF;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.page-transition.is-active {
    opacity: 1;
    pointer-events: all;
}

/* ============================================
   Phase 2A: Animated Link Underlines
   ============================================ */

.link-underline {
    position: relative;
    text-decoration: none;
}
.link-underline::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 0;
    height: 2px;
    background: currentColor;
    transition: width 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.link-underline:hover::after {
    width: 100%;
}

/* ============================================
   Phase 2B: Button Press Effect
   ============================================ */

.btn-press {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-press:active {
    transform: scale(0.97);
}

/* ============================================
   Phase 2C: Scroll-Aware Navigation
   ============================================ */

.nav-scrolled {
    box-shadow: 0 1px 12px rgba(0, 0, 0, 0.08);
    border-bottom-color: transparent;
}

/* ============================================
   Phase 3B: Image Lazy-Load Fade-In
   ============================================ */

img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.5s ease;
}
img[loading="lazy"].loaded {
    opacity: 1;
}

/* ============================================
   Phase 4A: Skeleton Loading Shimmer
   ============================================ */

.skeleton {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease infinite;
    border-radius: 0.5rem;
}
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   Phase 4B: Scroll-to-Top Button
   ============================================ */

.scroll-top-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 40;
    background: #3B82F6;
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
    pointer-events: none;
}
.scroll-top-btn.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.scroll-top-btn:hover {
    background: #2563EB;
}

/* ============================================
   Series Timeline
   ============================================ */

.series-timeline-line {
    width: 2px;
    flex: 1;
    min-height: 24px;
    background: #d1fae5;
    margin-top: 4px;
}

.series-timeline-item .flex-1 a:hover .series-timeline-line {
    background: #10B981;
}

/* Series badge on article cards */
.series-badge {
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}
