/* ==========================================================================
   Emoji Copy & Paste — Custom Styles
   Extends Tailwind CSS with custom properties, animations, and layouts
   ========================================================================== */

/* ---------- Smooth Scrolling ---------- */
html {
    scroll-behavior: smooth;
}

/* ---------- CSS Custom Properties ---------- */
:root {
    --color-primary: #6C63FF;
    --color-primary-light: #8B85FF;
    --color-primary-dark: #5A50E6;
    --color-accent: #3B82F6;
    --color-bg-primary: #0F172A;
    --color-bg-secondary: #1E293B;
    --color-bg-card: rgba(255, 255, 255, 0.05);
    --color-border: rgba(255, 255, 255, 0.1);
    --color-text-primary: #F8FAFC;
    --color-text-secondary: #94A3B8;
    --color-text-muted: #64748B;
    --toast-bg: rgba(108, 99, 255, 0.95);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-blur: 12px;
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light mode variables */
html:not(.dark) {
    --color-bg-primary: #F8FAFC;
    --color-bg-secondary: #F1F5F9;
    --color-bg-card: rgba(0, 0, 0, 0.03);
    --color-border: rgba(0, 0, 0, 0.08);
    --color-text-primary: #0F172A;
    --color-text-secondary: #475569;
    --color-text-muted: #94A3B8;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.08);
}

/* ---------- Theme-Aware Utility Classes ---------- */

/* Page titles - works in both light and dark */
.page-title {
    color: var(--color-text-primary);
}

/* Page subtitles / descriptions */
.page-subtitle {
    color: var(--color-text-secondary);
}

/* Emoji card backgrounds */
.emoji-card-bg {
    background-color: var(--color-bg-card);
}

/* Emoji card borders */
.emoji-card-border {
    border-color: var(--color-border);
}

/* Emoji name text in cards */
.emoji-name-text {
    color: var(--color-text-secondary);
}

/* Kaomoji text */
.kaomoji-text {
    color: var(--color-text-secondary);
}

/* ---------- Light Mode Body ---------- */
html:not(.dark) body {
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
}

/* ---------- Light Mode — Background Overrides ---------- */
html:not(.dark) .bg-dark-950 { background-color: var(--color-bg-primary) !important; }
html:not(.dark) .bg-dark-800 { background-color: var(--color-bg-secondary) !important; }
html:not(.dark) .bg-dark-950\/80 { background-color: rgba(248, 250, 252, 0.92) !important; }
html:not(.dark) .bg-dark-950\/90 { background-color: rgba(248, 250, 252, 0.95) !important; }
html:not(.dark) .bg-dark-950\/98 { background-color: rgba(248, 250, 252, 0.98) !important; }
html:not(.dark) .bg-dark-800\/95 { background-color: rgba(241, 245, 249, 0.95) !important; }

/* Glass backgrounds */
html:not(.dark) .bg-white\/5 { background-color: rgba(0, 0, 0, 0.03) !important; }
html:not(.dark) .bg-white\/8 { background-color: rgba(0, 0, 0, 0.04) !important; }
html:not(.dark) .bg-white\/10 { background-color: rgba(0, 0, 0, 0.06) !important; }

/* ---------- Light Mode — Text Overrides ---------- */
html:not(.dark) .text-white { color: var(--color-text-primary) !important; }
html:not(.dark) .text-gray-200 { color: #334155 !important; }
html:not(.dark) .text-gray-300 { color: #475569 !important; }
html:not(.dark) .text-gray-400 { color: var(--color-text-secondary) !important; }
html:not(.dark) .text-gray-500 { color: var(--color-text-muted) !important; }
html:not(.dark) .text-gray-600 { color: #64748B !important; }
html:not(.dark) .placeholder-gray-500::placeholder { color: #94A3B8 !important; }

/* ---------- Light Mode — Border Overrides ---------- */
html:not(.dark) .border-white\/5 { border-color: rgba(0, 0, 0, 0.06) !important; }
html:not(.dark) .border-white\/10 { border-color: rgba(0, 0, 0, 0.1) !important; }
html:not(.dark) .divide-white\/5 > * + * { border-color: rgba(0, 0, 0, 0.06) !important; }

/* ---------- Light Mode — Navbar ---------- */
html:not(.dark) #main-navbar {
    background-color: rgba(248, 250, 252, 0.92) !important;
    border-bottom-color: rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* ---------- Light Mode — Search Input ---------- */
html:not(.dark) .search-input {
    background-color: rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(0, 0, 0, 0.12) !important;
    color: var(--color-text-primary) !important;
}

html:not(.dark) .search-input:focus {
    background-color: #fff !important;
    border-color: rgba(108, 99, 255, 0.4) !important;
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

html:not(.dark) .search-input::placeholder {
    color: #94A3B8 !important;
}

/* ---------- Light Mode — Search Results Dropdown ---------- */
html:not(.dark) .search-results {
    background-color: #fff !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06) !important;
}

html:not(.dark) .search-results .search-item:hover {
    background-color: rgba(108, 99, 255, 0.06) !important;
}

html:not(.dark) .search-results .search-item .text-white {
    color: var(--color-text-primary) !important;
}

/* ---------- Light Mode — Emoji Cards ---------- */
html:not(.dark) .emoji-card .emoji-btn {
    background-color: #fff !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

html:not(.dark) .emoji-card .emoji-btn:hover {
    background-color: rgba(108, 99, 255, 0.04) !important;
    border-color: rgba(108, 99, 255, 0.3) !important;
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.08);
}

html:not(.dark) .emoji-card .emoji-name {
    color: var(--color-text-secondary) !important;
}

html:not(.dark) .emoji-card .emoji-btn::after {
    background: radial-gradient(circle at center, rgba(108, 99, 255, 0.15), transparent 70%);
}

/* ---------- Light Mode — Theme-Aware Card BG/Border ---------- */
html:not(.dark) .emoji-card-bg {
    background-color: #fff !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

html:not(.dark) .emoji-card-border {
    border-color: rgba(0, 0, 0, 0.08) !important;
}

/* ---------- Light Mode — Sidebar ---------- */
html:not(.dark) #sidebar .bg-white\/5 {
    background-color: #fff !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

html:not(.dark) #sidebar a:hover {
    background-color: rgba(108, 99, 255, 0.06) !important;
}

/* ---------- Light Mode — Hero Section ---------- */
html:not(.dark) #hero {
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.08), rgba(99, 102, 241, 0.06), rgba(59, 130, 246, 0.08)) !important;
    border-color: rgba(108, 99, 255, 0.15) !important;
}

html:not(.dark) #hero h1 {
    background: linear-gradient(135deg, #1E293B, #6C63FF, #3B82F6) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

html:not(.dark) #hero p {
    color: #475569 !important;
}

/* ---------- Light Mode — Mobile Search Bar ---------- */
html:not(.dark) .md\:hidden.px-4.py-2 {
    background-color: rgba(248, 250, 252, 0.95) !important;
    border-bottom-color: rgba(0, 0, 0, 0.06) !important;
}

/* ---------- Light Mode — Mobile Menu ---------- */
html:not(.dark) #mobile-menu {
    background-color: rgba(255, 255, 255, 0.98) !important;
}

html:not(.dark) #mobile-menu a {
    color: #334155 !important;
}

html:not(.dark) #mobile-menu a:hover {
    background-color: rgba(108, 99, 255, 0.06) !important;
    color: #6C63FF !important;
}

/* ---------- Light Mode — Cookie Banner ---------- */
html:not(.dark) #cookie-banner {
    background-color: rgba(255, 255, 255, 0.98) !important;
    border-top-color: rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
}

html:not(.dark) #cookie-banner p {
    color: #475569 !important;
}

/* ---------- Light Mode — Footer ---------- */
html:not(.dark) footer {
    background-color: #fff !important;
    border-top-color: rgba(0, 0, 0, 0.08) !important;
}

html:not(.dark) footer h3 {
    color: #1E293B !important;
}

html:not(.dark) footer a {
    color: #64748B !important;
}

html:not(.dark) footer a:hover {
    color: #6C63FF !important;
}

/* ---------- Light Mode — Breadcrumbs ---------- */
html:not(.dark) nav[aria-label="Breadcrumb"] a {
    color: #64748B !important;
}

html:not(.dark) nav[aria-label="Breadcrumb"] a:hover {
    color: #6C63FF !important;
}

html:not(.dark) nav[aria-label="Breadcrumb"] span.text-gray-300 {
    color: #334155 !important;
}

/* ---------- Light Mode — FAQ Details ---------- */
html:not(.dark) details {
    background-color: #fff !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

html:not(.dark) details summary {
    color: #334155 !important;
}

html:not(.dark) details[open] summary {
    border-bottom-color: rgba(0, 0, 0, 0.06) !important;
}

html:not(.dark) details .text-gray-400 {
    color: #64748B !important;
}

/* ---------- Light Mode — Language Dropdown ---------- */
html:not(.dark) #lang-dropdown {
    background-color: #fff !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12) !important;
}

html:not(.dark) #lang-dropdown a:hover {
    background-color: rgba(108, 99, 255, 0.06) !important;
}

/* ---------- Light Mode — Tools Dropdown ---------- */
html:not(.dark) #tools-dropdown {
    background-color: #fff !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12) !important;
}

html:not(.dark) #tools-dropdown a:hover {
    background-color: rgba(108, 99, 255, 0.06) !important;
}

html:not(.dark) #tools-dropdown .border-white\/5 {
    border-color: rgba(0, 0, 0, 0.06) !important;
}

/* ---------- Light Mode — Back to Top ---------- */
html:not(.dark) #back-to-top {
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.2);
}

/* ---------- Light Mode — Combo/Collection/Kaomoji Cards ---------- */
html:not(.dark) .combo-card,
html:not(.dark) .kaomoji-card,
html:not(.dark) .collection-card {
    background-color: #fff !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

html:not(.dark) .combo-card:hover,
html:not(.dark) .kaomoji-card:hover,
html:not(.dark) .collection-card:hover {
    border-color: rgba(108, 99, 255, 0.3) !important;
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.08);
}

/* ---------- Light Mode — Category Tabs ---------- */
html:not(.dark) .category-tab.text-gray-400 {
    color: #64748B !important;
}

html:not(.dark) .category-tab:hover {
    background-color: rgba(108, 99, 255, 0.06) !important;
    color: #6C63FF !important;
}

/* ---------- Light Mode — Detail Table ---------- */
html:not(.dark) .detail-table-wrapper {
    background-color: #fff !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

html:not(.dark) .detail-table-wrapper tbody tr + tr {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* ---------- Light Mode — Static Pages ---------- */
html:not(.dark) .static-page-card {
    background-color: #fff !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

html:not(.dark) .static-page-section {
    background-color: #fff !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

/* ---------- Light Mode — Toast ---------- */
html:not(.dark) .toast {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

/* ---------- Light Mode — Selection ---------- */
html:not(.dark) ::selection {
    background: rgba(108, 99, 255, 0.15);
    color: #1E293B;
}

/* ---------- Light Mode — Scrollbar ---------- */
html:not(.dark) ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}

html:not(.dark) ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* ---------- Light Mode — Skeleton Loading ---------- */
html:not(.dark) .skeleton {
    background: linear-gradient(90deg, rgba(0,0,0,0.03) 25%, rgba(0,0,0,0.06) 50%, rgba(0,0,0,0.03) 75%);
    background-size: 400% 100%;
}

/* ---------- Light Mode — Recently Used (Home) ---------- */
html:not(.dark) #recent-grid button {
    background-color: #fff !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

html:not(.dark) #recent-grid button:hover {
    background-color: rgba(108, 99, 255, 0.04) !important;
    border-color: rgba(108, 99, 255, 0.3) !important;
}

/* ==========================================================================
   DARK MODE (default) — Shared Styles
   ========================================================================== */

/* ---------- Smooth Scrolling ---------- */
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

/* ---------- Custom Scrollbar ---------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.3);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.5);
}

/* Hide scrollbar for category nav */
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ---------- Emoji Card Animations ---------- */
.emoji-card {
    position: relative;
    transform: translateZ(0);
    will-change: transform;
}

.emoji-card .emoji-btn {
    position: relative;
    overflow: hidden;
}

.emoji-card .emoji-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(108, 99, 255, 0.3), transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.emoji-card .emoji-btn:active::after {
    opacity: 1;
}

/* Copy ripple effect */
.emoji-card.copied .emoji-btn {
    animation: copyPulse 0.4s ease-out;
}

@keyframes copyPulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.92); }
    100% { transform: scale(1); }
}

/* Emoji hover scale */
.emoji-card:hover .emoji-char {
    transform: scale(1.3);
}

/* ---------- Toast Notifications ---------- */
.toast {
    animation: toastSlideIn 0.3s ease-out forwards;
    backdrop-filter: blur(12px);
}

.toast.toast-exit {
    animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
}

/* ---------- Hero Section ---------- */
#hero {
    position: relative;
}

#hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 80%;
    height: 200%;
    background: radial-gradient(ellipse, rgba(108, 99, 255, 0.08), transparent 60%);
    pointer-events: none;
}

/* ---------- Search ---------- */
.search-input:focus {
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

.search-results:not(.hidden) {
    animation: fadeInDown 0.2s ease-out;
}

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

/* ---------- Back to Top Button ---------- */
#back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ---------- Mobile Menu ---------- */
#mobile-menu {
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#mobile-menu:not(.hidden) {
    animation: fadeIn 0.2s ease-out;
}

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

/* ---------- Details/Summary (FAQ) ---------- */
details summary {
    list-style: none;
}
details summary::-webkit-details-marker {
    display: none;
}

details[open] summary {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* ---------- Cookie Banner Animation ---------- */
#cookie-banner:not(.hidden) {
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- RTL Support ---------- */
[dir="rtl"] .category-tab svg {
    transform: scaleX(-1);
}

[dir="rtl"] .emoji-card .emoji-name {
    direction: rtl;
}

/* ---------- Focus Styles (Accessibility) ---------- */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- Selection ---------- */
::selection {
    background: rgba(108, 99, 255, 0.3);
    color: white;
}

/* ---------- Loading Skeleton ---------- */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 400% 100%;
    animation: shimmer 1.5s infinite;
}

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

/* ---------- Static Page Styles ---------- */
.static-page-card {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.static-page-card:hover {
    border-color: rgba(108, 99, 255, 0.3);
    box-shadow: 0 4px 16px rgba(108, 99, 255, 0.06);
}

.static-page-section {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    padding: 2rem;
}

.static-page-content h2 {
    color: var(--color-text-primary);
    font-weight: 700;
    font-size: 1.25rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.static-page-content h2:first-child {
    margin-top: 0;
}

.static-page-content p {
    color: var(--color-text-secondary);
    line-height: 1.75;
    margin-bottom: 1rem;
}

.static-page-content ul {
    color: var(--color-text-secondary);
    line-height: 1.75;
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.static-page-content ul li {
    margin-bottom: 0.5rem;
    position: relative;
}

.static-page-content ul li::before {
    content: '';
    position: absolute;
    left: -1rem;
    top: 0.625rem;
    width: 6px;
    height: 6px;
    background-color: var(--color-primary);
    border-radius: 50%;
}

[dir="rtl"] .static-page-content ul {
    padding-left: 0;
    padding-right: 1.5rem;
}

[dir="rtl"] .static-page-content ul li::before {
    left: auto;
    right: -1rem;
}

.static-page-content a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.static-page-content a:hover {
    color: var(--color-primary-light);
    text-decoration: underline;
}

/* ---------- Contact Page ---------- */
.contact-email-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.1), rgba(59, 130, 246, 0.1));
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: 0.75rem;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 1.125rem;
    text-decoration: none;
    transition: all 0.3s ease;
}

.contact-email-link:hover {
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.15), rgba(59, 130, 246, 0.15));
    border-color: rgba(108, 99, 255, 0.4);
    box-shadow: 0 4px 16px rgba(108, 99, 255, 0.15);
    text-decoration: none;
}

/* ---------- Print Styles ---------- */
@media print {
    nav, footer, #sidebar, #cookie-banner, #back-to-top, .ad-container {
        display: none !important;
    }
    body {
        background: white !important;
        color: black !important;
    }
    .emoji-card {
        border: 1px solid #ddd !important;
    }
}

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