/* ==========================================
   Design System — PromptEngine
   Skills integrated:
     - Frontend Design (distinctive aesthetics)
     - UI/UX Pro Max (accessibility, glassmorphism)
     - Interaction Design (microinteractions, motion)
   ========================================== */

/* ---------- CSS Variables ---------- */
:root {
    --color-bg: #f5f5f7;
    --color-surface: rgba(255, 255, 255, 0.72);
    --color-surface-hover: rgba(255, 255, 255, 0.85);
    --color-apple-blue: #0071e3;
    --color-apple-blue-dark: #0062cc;
    --color-dark: #1d1d1f;
    --color-text-secondary: #86868b;

    /* Shadows */
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.04), 0 1px 4px rgba(0, 0, 0, 0.06);
    --shadow-card-hover: 0 12px 40px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-btn: 0 2px 8px rgba(0, 113, 227, 0.3);
    --shadow-btn-hover: 0 4px 16px rgba(0, 113, 227, 0.4);

    /* Radii */
    --radius-card: 20px;
    --radius-input: 14px;
    --radius-btn: 980px;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;
}

/* ---------- Glassmorphism Base ---------- */
.glass {
    background: var(--color-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    transition: box-shadow var(--duration-normal) var(--ease-out),
                background var(--duration-normal) var(--ease-out);
}

/* Nav glass (stronger blur for fixed element) */
.nav-glass {
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* Nav links */
.nav-link {
    color: #6b7280;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s var(--ease-out);
    text-decoration: none;
}

.nav-link:hover {
    color: #1d1d1f;
    background: rgba(0, 0, 0, 0.04);
}

/* ---------- Input Glass (Form fields) ---------- */
.input-glass {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-input);
    padding: 12px 16px;
    font-size: 0.95rem;
    color: var(--color-dark);
    transition: all var(--duration-fast) var(--ease-out);
    outline: none;
}

.input-glass:hover {
    border-color: rgba(0, 0, 0, 0.15);
    background: rgba(255, 255, 255, 0.9);
}

.input-glass:focus {
    border-color: var(--color-apple-blue);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.input-glass::placeholder {
    color: #aeaeb2;
}

textarea.input-glass {
    line-height: 1.6;
}

/* Form field group animation */
.form-field-group {
    animation: fadeInUp 0.4s var(--ease-out) both;
}

.form-field-group:nth-child(1) { animation-delay: 0.04s; }
.form-field-group:nth-child(2) { animation-delay: 0.08s; }
.form-field-group:nth-child(3) { animation-delay: 0.12s; }
.form-field-group:nth-child(4) { animation-delay: 0.16s; }
.form-field-group:nth-child(5) { animation-delay: 0.20s; }
.form-field-group:nth-child(6) { animation-delay: 0.24s; }

/* Select styling */
select.input-glass {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2386868b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
    cursor: pointer;
}

/* ---------- Primary Button ---------- */
.btn-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-apple-blue);
    color: white;
    border-radius: var(--radius-btn);
    padding: 14px 28px;
    font-weight: 500;
    box-shadow: var(--shadow-btn);
    transition: all var(--duration-normal) var(--ease-out);
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    outline: none;
}

.btn-submit:hover {
    background: var(--color-apple-blue-dark);
    transform: scale(1.02);
    box-shadow: var(--shadow-btn-hover);
}

.btn-submit:active {
    transform: scale(0.98);
}

.btn-submit:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.3);
}

.btn-content {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Ripple Effect ---------- */
.ripple-btn {
    position: relative;
    overflow: hidden;
}

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ---------- Page Enter Animations ---------- */
.page-enter {
    animation: fadeInUp 0.5s var(--ease-out) both;
}

.page-enter-delayed {
    animation: fadeInUp 0.5s var(--ease-out) 0.08s both;
}

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

/* ---------- Slide Down (for flash messages) ---------- */
.animate-slideDown {
    animation: slideDown 0.35s var(--ease-out) both;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Result Card ---------- */
.result-card {
    animation: resultReveal 0.5s var(--ease-out) 0.1s both;
}

@keyframes resultReveal {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ---------- Toast Notification ---------- */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: rgba(29, 29, 31, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: white;
    padding: 12px 24px;
    border-radius: 14px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: all 0.35s var(--ease-out);
    z-index: 999;
    pointer-events: none;
    white-space: nowrap;
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- Skip Link (Accessibility) ---------- */
.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: var(--color-apple-blue);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    z-index: 100;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 16px;
}

/* ---------- Copy Button Feedback ---------- */
#copy-btn.copied {
    background: #34c759;
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.3);
}

#copy-btn.copied:hover {
    background: #28a745;
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .card-template:hover {
        transform: none;
    }

    .btn-submit:hover {
        transform: none;
    }

    .staggered-fade-in > * {
        opacity: 1;
        animation: none;
    }

    .page-enter,
    .page-enter-delayed {
        animation: none;
        opacity: 1;
    }

    .result-card {
        animation: none;
        opacity: 1;
    }
}

/* ---------- Responsive Fine-Tuning ---------- */
@media (max-width: 640px) {
    .nav-glass {
        padding-left: 16px;
        padding-right: 16px;
    }

    .card-template .p-6 {
        padding: 16px;
    }
}

/* ---------- Selection Color ---------- */
::selection {
    background: rgba(0, 113, 227, 0.2);
    color: var(--color-dark);
}

/* ---------- Line Clamp ---------- */
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- Filter Tabs ---------- */
.filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--color-surface);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    color: #6b7280;
    cursor: pointer;
    transition: all 0.25s var(--ease-out);
    outline: none;
}

.filter-tab:hover {
    background: rgba(255, 255, 255, 0.85);
    color: var(--color-dark);
    border-color: rgba(0, 0, 0, 0.1);
}

.filter-tab:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.3);
}

.filter-tab.active {
    background: white;
    color: var(--color-dark);
    border-color: transparent;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.05);
    color: #9ca3af;
    transition: all 0.25s var(--ease-out);
}

.filter-tab.active .filter-count {
    background: var(--color-apple-blue);
    color: white;
}

/* ---------- Hero Pulse Animation ---------- */
@keyframes pulse-slow {
    0%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.animate-pulse-slow {
    animation: pulse-slow 6s ease-in-out infinite;
}

/* ---------- Card Template Overrides ---------- */
.card-template {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border-radius: var(--radius-card);
    transition: transform var(--duration-normal) var(--ease-out),
                box-shadow var(--duration-normal) var(--ease-out),
                background var(--duration-normal) var(--ease-out);
    will-change: transform;
}

.card-template::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(0, 113, 227, 0.08),
        transparent 40%
    );
    opacity: 0;
    transition: opacity var(--duration-normal) var(--ease-out);
    pointer-events: none;
    z-index: 1;
}

.card-template:hover::before {
    opacity: 1;
}

.card-template:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: var(--shadow-card-hover);
    background: var(--color-surface-hover);
}

.card-template:active {
    transform: translateY(-2px) scale(0.99);
}

/* Card content should be above the glow effect */
.card-template > * {
    position: relative;
    z-index: 2;
}

/* ---------- Staggered Card Entrance ---------- */
.staggered-fade-in > * {
    opacity: 0;
    animation: cardEntrance 0.5s var(--ease-out) forwards;
}

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

/* ---------- Reduced Motion Overrides ---------- */
@media (prefers-reduced-motion: reduce) {
    .animate-pulse-slow {
        animation: none;
        opacity: 0.5;
    }

    .filter-tab {
        transition: none;
    }

    .staggered-fade-in > * {
        opacity: 1;
        animation: none;
    }
}

/* ==========================================
   New: Text Shine / Glow Effects
   ========================================== */

/* Shimmer text — diagonal gradient sweep */
.text-shimmer {
    background: linear-gradient(
        110deg,
        #1d1d1f 0%,
        #1d1d1f 30%,
        #0071e3 50%,
        #6b46c1 60%,
        #1d1d1f 80%,
        #1d1d1f 100%
    );
    background-size: 250% 250%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmerSweep 5s ease-in-out infinite;
}

.dark .text-shimmer {
    background: linear-gradient(
        110deg,
        #ffffff 0%,
        #ffffff 30%,
        #60a5fa 50%,
        #a78bfa 60%,
        #ffffff 80%,
        #ffffff 100%
    );
    background-size: 250% 250%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmerSweep 5s ease-in-out infinite;
}

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

/* Soft glow text — pulse opacity + subtle shadow */
.text-glow {
    animation: glowPulse 3s ease-in-out infinite;
}

.dark .text-glow {
    animation: glowPulseDark 3s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% {
        text-shadow: 0 0 20px rgba(0, 113, 227, 0.15), 0 0 40px rgba(0, 113, 227, 0.05);
    }
    50% {
        text-shadow: 0 0 30px rgba(0, 113, 227, 0.3), 0 0 60px rgba(0, 113, 227, 0.1);
    }
}

@keyframes glowPulseDark {
    0%, 100% {
        text-shadow: 0 0 20px rgba(96, 165, 250, 0.2), 0 0 40px rgba(96, 165, 250, 0.08);
    }
    50% {
        text-shadow: 0 0 30px rgba(96, 165, 250, 0.4), 0 0 60px rgba(96, 165, 250, 0.15);
    }
}

/* Slide-up entrance with staggered support */
.animate-in {
    opacity: 0;
    transform: translateY(24px);
}

.animate-in.visible {
    animation: slideUpReveal 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUpReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scroll reveal — triggers via Intersection Observer */
.reveal {
    opacity: 0;
    transform: translateY(32px);
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================
   New: Hero Premium Styles
   ========================================== */

.hero-gradient-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.hero-gradient-bg .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: orbFloat 12s ease-in-out infinite;
}

.hero-gradient-bg .orb:nth-child(1) {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #0071e3, transparent);
    top: -15%;
    left: -10%;
    animation-delay: 0s;
}

.hero-gradient-bg .orb:nth-child(2) {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #7c3aed, transparent);
    bottom: -20%;
    right: -10%;
    animation-delay: -4s;
}

.hero-gradient-bg .orb:nth-child(3) {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, #06b6d4, transparent);
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -8s;
}

.dark .hero-gradient-bg .orb {
    opacity: 0.15;
}

@keyframes orbFloat {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(30px, -20px) scale(1.05);
    }
    50% {
        transform: translate(-20px, 30px) scale(0.95);
    }
    75% {
        transform: translate(20px, 10px) scale(1.02);
    }
}

/* Hero badge */
.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px 6px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 0.8125rem;
    color: #6b7280;
    font-weight: 500;
    transition: all 0.3s ease;
}

.dark .hero-badge {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.08);
    color: #9ca3af;
}

.hero-badge:hover {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 113, 227, 0.2);
    transform: translateY(-1px);
}

/* ==========================================
   New: Premium Card Redesign
   ========================================== */

.card-premium {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.04);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}

.dark .card-premium {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.15);
}

.card-premium::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        800px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(0, 113, 227, 0.06),
        transparent 50%
    );
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.card-premium:hover::before {
    opacity: 1;
}

.card-premium:hover {
    transform: translateY(-8px) scale(1.015);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
    background: rgba(255, 255, 255, 0.82);
}

.dark .card-premium:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.card-premium:active {
    transform: translateY(-4px) scale(0.99);
}

.card-premium > * {
    position: relative;
    z-index: 2;
}

/* Template ID badge on card */
.card-tid-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    background: rgba(0, 113, 227, 0.08);
    color: #0071e3;
    transition: all 0.3s ease;
}

.dark .card-tid-badge {
    background: rgba(96, 165, 250, 0.12);
    color: #60a5fa;
}

.card-premium:hover .card-tid-badge {
    background: rgba(0, 113, 227, 0.15);
}

/* Use case on card — cleaner inline */
.card-example-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.6875rem;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.04);
    color: #9ca3af;
    transition: all 0.3s ease;
}

.dark .card-example-tag {
    background: rgba(255, 255, 255, 0.06);
    color: #6b7280;
}

/* Category chips */
.cat-chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 0.6875rem;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.03);
    color: #9ca3af;
    transition: all 0.2s ease;
}

.dark .cat-chip {
    background: rgba(255, 255, 255, 0.04);
    color: #6b7280;
}

.card-premium:hover .cat-chip {
    background: rgba(0, 0, 0, 0.05);
    color: #6b7280;
}

.dark .card-premium:hover .cat-chip {
    background: rgba(255, 255, 255, 0.08);
    color: #9ca3af;
}

/* ==========================================
   New: Filter Tab Redesign
   ========================================== */

.filter-tab-alt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 500;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
}

.filter-tab-alt:hover {
    color: #6b7280;
    background: rgba(0, 0, 0, 0.03);
}

.dark .filter-tab-alt:hover {
    color: #d1d5db;
    background: rgba(255, 255, 255, 0.04);
}

.filter-tab-alt:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.3);
}

.filter-tab-alt.active {
    color: #0071e3;
    background: rgba(0, 113, 227, 0.08);
    border-color: rgba(0, 113, 227, 0.15);
}

.dark .filter-tab-alt.active {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.1);
    border-color: rgba(96, 165, 250, 0.2);
}

.filter-tab-alt .filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 0.625rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.04);
    color: #d1d5db;
    transition: all 0.3s ease;
}

.dark .filter-tab-alt .filter-count {
    background: rgba(255, 255, 255, 0.06);
    color: #6b7280;
}

.filter-tab-alt.active .filter-count {
    background: rgba(0, 113, 227, 0.15);
    color: #0071e3;
}

.dark .filter-tab-alt.active .filter-count {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
}

/* ==========================================
   New: Scroll-triggered count-up for stats
   ========================================== */

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.03em;
    color: #1d1d1f;
}

.dark .stat-number {
    color: #ffffff;
}

.stat-label {
    font-size: 0.8125rem;
    color: #9ca3af;
    margin-top: 4px;
    font-weight: 400;
}

/* ==========================================
   New: Responsive refinements
   ========================================== */

@media (max-width: 640px) {
    .hero-badge {
        font-size: 0.6875rem;
        padding: 4px 12px 4px 6px;
    }

    .card-premium {
        border-radius: 18px;
    }

    .stat-number {
        font-size: 1.75rem;
    }
}