@import url('./style.css');

@property --angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

body {
    background-color: var(--background);
    display: block; /* Override flex column from global if needed */
    overflow-y: auto; /* Landing page scrolls */
    /* Subtle background pattern */
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(56, 189, 248, 0.15) 0px, transparent 50%);
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* Landing Header */
.landing-header {
    background: rgba(15, 23, 42, 0.8); /* Transparent Surface */
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.landing-brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.02em;
}

/* --- Fullscreen Loading Overlay --- */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background-color: #0f172a; /* Slate 900 base */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 1.5s ease-out; /* Slower, smoother fade out */
}

#loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Background Grid Pattern */
.loading-background {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: center center;
    mask-image: radial-gradient(circle at center, black 40%, transparent 90%);
    -webkit-mask-image: radial-gradient(circle at center, black 40%, transparent 90%);
    z-index: 1;
}

/* Gradient Frame around viewport */
.loading-frame {
    position: absolute;
    inset: 0;
    border: 8px solid transparent; /* Thickness */
    border-image: linear-gradient(to right, #005eff, #8000ff) 1;
    mask-image: linear-gradient(black, black), linear-gradient(black, black);
    mask-clip: content-box, border-box;
    /* Only show border: */
    /* mask-composite: exclude; NOT supported everywhere, using simpler approach */
    z-index: 10;
    pointer-events: none;
    box-shadow: inset 0 0 50px rgba(0, 94, 255, 0.2);
}

.loading-content {
    position: relative;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* Logo Animation Container */
.loading-logo-wrapper {
    position: relative;
    width: 90%;
    max-width: 800px;
    aspect-ratio: 800 / 300;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Layer 1: Ghost / Sketch */
.loading-logo-ghost,
.loading-logo-color {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background-image: url(../PixelKit.png);
    background-size: 87.5% auto;
    background-repeat: no-repeat;
    background-position: center;
}

.loading-logo-ghost {
    filter: grayscale(100%) brightness(0.4) contrast(1.2);
    opacity: 0.2; /* Faint backdrop */
    z-index: 1;
}

/* Layer 2: Color Reveal */
.loading-logo-color {
    z-index: 2;
    /* Use mask-image instead of clip-path to avoid hard edges clipping shadows */
    mask-image: linear-gradient(to top, black 50%, transparent 50.5%);
    -webkit-mask-image: linear-gradient(to top, black 50%, transparent 50.5%);
    mask-size: 100% 200%;
    -webkit-mask-size: 100% 200%;
    mask-position: 0 0%; /* Initially hidden (showing top transparent half) */
    -webkit-mask-position: 0 0%;

    filter: drop-shadow(0 0 15px rgba(0, 94, 255, 0.4)); /* Glow */
}

/* Layer 3: Brush Line / Liquid Edge */
.loading-brush-line {
    position: absolute;
    bottom: 0;
    left: 3.125%;
    width: 93.75%;
    height: 4px; /* Line thickness */
    /* Blue/Purple gradient to match theme */
    background: linear-gradient(90deg, transparent, #005eff, #8000ff, #ffffff, #8000ff, #005eff, transparent);
    z-index: 3;
    opacity: 0; /* Hidden initially */
    box-shadow: 0 0 15px #005eff, 0 0 30px #8000ff;
    mix-blend-mode: screen;
}

/* Animation Trigger */
#loading-overlay.play .loading-logo-color {
    animation: liquidReveal 4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

#loading-overlay.play .loading-brush-line {
    animation: brushLineMove 4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

#loading-overlay.play .loading-logo-wrapper {
    animation: deepPulse 4s ease-in-out forwards;
}

@keyframes liquidReveal {
    0% {
        mask-position: 0 0%;
        -webkit-mask-position: 0 0%;
        filter: drop-shadow(0 0 5px rgba(0, 94, 255, 0));
    }
    100% {
        mask-position: 0 100%;
        -webkit-mask-position: 0 100%;
        filter: drop-shadow(0 0 25px rgba(0, 94, 255, 0.6));
    }
}

@keyframes brushLineMove {
    0% { bottom: 0%; opacity: 0; transform: scaleX(0.5); }
    10% { opacity: 1; transform: scaleX(1); }
    90% { opacity: 1; transform: scaleX(1); }
    100% { bottom: 100%; opacity: 0; transform: scaleX(0.8); }
}

@keyframes deepPulse {
    0% { transform: scale(0.95); }
    50% { transform: scale(1.05); } /* Gentle breath */
    100% { transform: scale(1); }
}


.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 6rem 2rem;
    text-align: center;
}

.hero {
    margin-bottom: 6rem;
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.hero-logo-wrapper {
    display: inline-block;
    position: relative;
    height: 100px;
    width: auto;
    margin-bottom: 2rem;
    filter: drop-shadow(0 10px 20px rgba(99, 102, 241, 0.3));
    animation: float 6s ease-in-out infinite;
    cursor: pointer;
    user-select: none;
}

.hero-logo-base {
    height: 100%;
    width: auto;
    display: block;
    /* opacity: 0.2;  Removed: Hero logo should be fully visible normally */
    /* filter: grayscale(100%); Removed */
    transition: opacity 0.3s;
}

/* The hero logo fill is now purely for the RESET shine effect, usually hidden */
.hero-logo-fill {
    display: none; /* Hide by default in hero, only used for effects if needed */
}

/* Reset Shine Effect on Hero Logo */
.hero-logo-wrapper.shine-effect {
    animation: float 6s ease-in-out infinite, shineTrigger 0.8s ease-out;
}

@keyframes shineTrigger {
    0% { filter: drop-shadow(0 10px 20px rgba(99, 102, 241, 0.3)) brightness(1); transform: scale(1); }
    50% { filter: drop-shadow(0 0 40px rgba(255, 255, 255, 0.9)) brightness(2); transform: scale(1.1); }
    100% { filter: drop-shadow(0 10px 20px rgba(99, 102, 241, 0.3)) brightness(1); transform: scale(1); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.hero h1 {
    font-size: 4.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    letter-spacing: -0.04em;
    line-height: 1.1;
    background: linear-gradient(135deg, #ffffff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.25rem;
    max-width: 640px;
    margin: 0 auto;
    line-height: 1.6;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.tool-card {
    background: rgba(30, 41, 59, 0.4); /* Glassy surface */
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: left;
    transition: var(--transition-slow);
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
    z-index: 1; /* Stacking context */
}

/* Ensure content is above the border pseudo-elements */
.tool-card > * {
    position: relative;
    z-index: 2;
}

.tool-card:hover {
    transform: translateY(-8px) scale(1.02);
    background: rgba(30, 41, 59, 0.8);
    border-color: transparent; /* Hide static border to show gradient */
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.15), 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

/* Staggered entrance animation for cards */
.tool-card {
    opacity: 0;
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tool-card:nth-child(1) { animation-delay: 0.1s; }
.tool-card:nth-child(2) { animation-delay: 0.15s; }
.tool-card:nth-child(3) { animation-delay: 0.2s; }
.tool-card:nth-child(4) { animation-delay: 0.25s; }
.tool-card:nth-child(5) { animation-delay: 0.3s; }
.tool-card:nth-child(6) { animation-delay: 0.35s; }
.tool-card:nth-child(7) { animation-delay: 0.4s; }
.tool-card:nth-child(8) { animation-delay: 0.45s; }
.tool-card:nth-child(9) { animation-delay: 0.5s; }
.tool-card:nth-child(10) { animation-delay: 0.55s; }
.tool-card:nth-child(n+11) { animation-delay: 0.6s; }

/* Animated Gradient Border (Card) */
.tool-card::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1; /* Sits on top of card background (which is on element), but behind content (z-2) */
    padding: 2px; /* Border width */
    border-radius: inherit;
    /* Use explicit stops to ensure seamless rotation without browser interpolation artifacts */
    background: conic-gradient(from var(--angle), #005eff 0deg, #8000ff 180deg, #005eff 360deg);
    /* Mask out the center to make it a border */
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    -webkit-mask-composite: xor;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.3s ease;
    animation: rotateGradient 4s linear infinite;
    pointer-events: none;
}

.tool-card:hover::after {
    opacity: 1;
}

@keyframes rotateGradient {
    to {
        --angle: 360deg;
    }
}

/* Icon Wrapper & Image */
.tool-icon-wrapper {
    width: 64px;
    height: 64px;
    margin-bottom: 1.25rem;
    background: rgba(2, 6, 23, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 8px;
    display: block;
    position: relative;
    transition: var(--transition);
    z-index: 2; /* Ensure context for its children/pseudo */
}

.tool-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.3s ease;
}

/* Wrapper Hover Effect (Pulsing/Shimmering Gradient Border) */
.tool-icon-wrapper::before {
    content: '';
    position: absolute;
    inset: -2px; /* Outside border glow */
    border-radius: inherit;
    padding: 2px;
    /* 5-stop gradient ensures seamless loop when sliding 50% width (0-50 matches 50-100) */
    background: linear-gradient(45deg, #005eff, #8000ff, #005eff, #8000ff, #005eff);
    background-size: 200% 200%;
    z-index: -1; /* Behind wrapper background */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tool-card:hover .tool-icon-wrapper {
    border-color: transparent; /* Hide static border */
    background: rgba(2, 6, 23, 0.8); /* Darken slightly or keep same? */
}

.tool-card:hover .tool-icon-wrapper::before {
    opacity: 1;
    /* Removed 'alternate' from pulse to keep it consistent, but shimmer MUST be linear infinite */
    animation: shimmer 3s linear infinite, pulse 2s ease-in-out infinite alternate;
}

.tool-card:hover .tool-icon-img {
    transform: scale(1.1) rotate(3deg);
}

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

@keyframes pulse {
    0% { transform: scale(1); filter: blur(0px); }
    100% { transform: scale(1.05); filter: blur(4px); }
}

.tool-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.tool-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 2rem;
    flex: 1;
    line-height: 1.5;
}

.card-footer {
    margin-top: auto;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-footer span {
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tool-card:hover .card-footer span {
    transform: translateX(6px);
}

@media (max-width: 768px) {
    .hero h1 {
        font-size: 3rem;
    }
}

/* Footer & Gradient */
footer {
    position: relative;
    width: 100%;
    margin-top: 6rem; /* Spacing from content */
    padding: 6rem 0 3rem; /* Height for gradient */
    display: flex;
    justify-content: center;
    align-items: flex-end;
    overflow: hidden;
}

footer::before {
    content: '';
    position: absolute;
    inset: 0;
    /* Blue to Purple horizontal gradient */
    background: linear-gradient(90deg, #005eff, #8000ff);
    /* Fade out upwards mask */
    mask-image: linear-gradient(to top, rgba(0,0,0,1) 0%, transparent 100%);
    -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,1) 0%, transparent 100%);
    z-index: 0;
    opacity: 0.8; /* Adjust intensity for "cool" look without being overwhelming */
    pointer-events: none;
}

.footer-content {
    position: relative;
    z-index: 1;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    letter-spacing: 0.05em;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
    /* Ensure text is readable over the gradient */
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.brand-highlight {
    font-family: 'Michroma', sans-serif;
    /* Gradient text matching the footer theme but brighter */
    background: linear-gradient(90deg, #38bdf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 900;
    text-transform: uppercase;
    /* Cool glow + simulated bold */
    filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.6));
    /* Add subtle stroke to simulate bold */
    -webkit-text-stroke: 1px rgba(255, 255, 255, 0.1);
    letter-spacing: 0.05em;
}

/* Search Container */
.search-container-wrapper {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 2rem;
    padding: 0 0.5rem;
    opacity: 0;
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.05s;
}

.search-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    display: flex;
    align-items: center;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(8px);
    transition: var(--transition);
}

.search-container:focus-within {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
    pointer-events: none;
}

input.search-input {
    width: 100%;
    background: transparent;
    border: none;
    padding: 1rem 3rem 1rem 3.5rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}

.search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.clear-search-btn {
    position: absolute;
    right: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.clear-search-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Empty State */
#no-results-message {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
    background: rgba(30, 41, 59, 0.4);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    margin-bottom: 2rem;
}

.ascii-cat {
    font-family: monospace;
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    line-height: 1.2;
    white-space: pre-wrap;
}

#no-results-message p {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Hero Stats */
.hero-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-top: 3rem;
    padding: 1rem 2rem;
    background: rgba(30, 41, 59, 0.4); /* Glassy dark blue/slate matches cards */
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 9999px;
    backdrop-filter: blur(8px);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s backwards;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

#tool-count-stat {
    flex-direction: row;
    align-items: center; /* Changed from baseline */
    gap: 0.5rem;
}

.stat-number {
    font-family: 'Michroma', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    /* Gradient text */
    background: linear-gradient(135deg, #005eff 0%, #8000ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(0, 94, 255, 0.3));
    line-height: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: #94a3b8; /* Slate 400 */
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-separator {
    width: 1px;
    height: 32px;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.2), transparent);
}

.stat-text {
    font-size: 1rem;
    font-weight: 600;
    color: #f8fafc; /* Slate 50 */
}

@media (max-width: 640px) {
    .hero-stats {
        flex-direction: column;
        gap: 1.25rem;
        border-radius: 1.5rem;
        padding: 1.5rem;
        width: 100%;
        max-width: 320px;
    }

    .stat-separator {
        width: 100%;
        height: 1px;
        background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
    }

    #tool-count-stat {
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
    }
}

/* Card Favorite Button */
.card-fav-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    padding: 0;
}

.card-fav-btn svg {
    display: block;
    width: 20px;
    height: 20px;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card-fav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
    color: #fbbf24; /* Amber 400 */
    border-color: rgba(251, 191, 36, 0.4);
}

.card-fav-btn:hover svg {
    transform: scale(1.1);
}

.card-fav-btn.active {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.3);
}

.card-fav-btn.active svg {
    filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.5));
}
