:root {
    color-scheme: light dark;
    --theme-transition-duration: 0.3s;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --nav-height: 72px;
}

html {
  visibility: visible;
  opacity: 1;
}
#loading-overlay {
  display: flex;
  visibility: visible;
  opacity: 1;
  transition: opacity 0.8s ease-out;
  z-index: 9999;
}
body {
  visibility: hidden; /* Hide content initially */
}

/* Base transitions */
* {
    transition: background-color 0.3s ease,
                border-color 0.3s ease,
                fill 0.3s ease;
}

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

/* Theme transition specific styles */
.theme-transition * {
    transition: background-color 0.3s ease,
                border-color 0.3s ease,
                color 0.3s ease !important;
}

/* Remove transition for loading overlay */
#loading-overlay * {
    transition: none !important;
}

.theme-transition {
  transition: background-color var(--theme-transition-duration) ease-in-out,
              color var(--theme-transition-duration) ease-in-out,
              border-color var(--theme-transition-duration) ease-in-out;
}
.custom-bg {
  background-image: url('https://images.unsplash.com/photo-1672858460787-fb29ed7352f8');
}

/* Keyframes and utility animations */
@keyframes rise-in {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes scale-in {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

.reveal-up {
    animation: rise-in 700ms var(--ease-out) both;
    will-change: transform, opacity;
}

.animate-card-in {
    animation: rise-in 500ms var(--curve, var(--ease-out)) both;
    will-change: transform, opacity;
}

.reveal-scale {
    animation: scale-in 500ms var(--ease-out) both;
    will-change: transform, opacity;
}

section {
    scroll-margin-top: calc(var(--nav-height) + 16px);
}

/* Mobile menu animations */
#mobileMenu {
    display: flex;
    pointer-events: none;
}

#mobileMenu.hidden {
    display: none;
}

#mobileMenu:not(.hidden) {
    pointer-events: auto;
}

#mobileMenu .menu a {
    transform: translateX(0);
    opacity: 1;
    transition: transform 0.3s ease, opacity 0.3s ease, background-color 0.3s ease;
}

#mobileMenu.opacity-0 .menu a {
    transform: translateX(-1rem);
    opacity: 0;
}

/* Stagger animation delays for menu items */
#mobileMenu .menu li:nth-child(1) a { transition-delay: 0.1s; }
#mobileMenu .menu li:nth-child(2) a { transition-delay: 0.15s; }
#mobileMenu .menu li:nth-child(3) a { transition-delay: 0.2s; }
#mobileMenu .menu li:nth-child(4) a { transition-delay: 0.25s; }
#mobileMenu .menu li:nth-child(5) a { transition-delay: 0.3s; }

.nav-link-active {
    background: linear-gradient(120deg, rgba(59, 130, 246, 0.16), rgba(236, 72, 153, 0.12));
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
    transform: translateY(-2px);
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), background 0.25s ease;
}

.nav-link-active:not(.btn) {
    border-radius: 9999px;
    padding-inline: 0.65rem;
}

@font-face {
    font-family: 'LINESeedSansTH';
    src: url('../fonts/LINESeedSansTH_W_Rg.woff2') format('woff2'),
         url('../fonts/LINESeedSansTH_W_Rg.woff') format('woff'),
         url('../fonts/LINESeedSansTH_W_Rg.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* You can add additional @font-face declarations for different weights */
@font-face {
    font-family: 'LINESeedSansTH';
    src: url('../fonts/LINESeedSansTH_W_Bd.woff2') format('woff2'),
         url('../fonts/LINESeedSansTH_W_Bd.woff') format('woff'),
         url('../fonts/LINESeedSansTH_W_Bd.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
}

/* Certificate filter styles */
.tag-filter {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-width: 120px;
    font-weight: 600;
    transform-origin: center;
    opacity: 1;
    width: auto;
    margin: 0;
    flex-shrink: 0;
}

.tag-filter.hidden {
    transform: scale(0.8) translateY(-20px);
    width: 0;
    padding: 0;
    margin: 0;
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

.tag-filter::after {
    content: '';
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0.1;
}

.tag-filter:hover {
    transform: translateY(-4px);
    filter: brightness(1.15);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

.tag-filter.active {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    font-weight: 700;
}

/* Tag-specific styles */
.tag-filter[data-tag="all"].active {
    background: #374151;
    color: white;
    transform: translateY(-2px) scale(1.05);
}

.tag-filter[data-tag="robotics"] i { color: rgb(239, 68, 68); }
.tag-filter[data-tag="coding"] i { color: rgb(59, 130, 246); }
.tag-filter[data-tag="camp"] i { color: rgb(34, 197, 94); }
.tag-filter[data-tag="contest"] i { color: rgb(234, 179, 8); }
.tag-filter[data-tag="ai"] i { color: rgb(6, 182, 212); }
.tag-filter[data-tag="stem"] i { color: rgb(168, 85, 247); }

.tag-filter i {
    margin-right: 0.5rem;
    transition: transform 0.3s ease;
}

.tag-filter:hover i {
    transform: scale(1.2);
}

/* Add badge counts */
.tag-filter .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: rgba(0,0,0,0.2);
    color: white;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.certificates-grid {
    transition: opacity 0.5s ease;
}

.certificates-grid.filtering {
    opacity: 0.3;
}

/* Tag-specific hover effects */
.tag-filter i {
    margin-right: 0.5rem;
    transition: transform 0.3s ease;
}

.tag-filter:hover i {
    transform: scale(1.2);
}

.tag-filter.btn-primary {
    border-width: 2px;
}

/* Active tag display styles */
#activeTagDisplay {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#activeTagDisplay .badge {
    font-size: 1rem;
    padding: 0.5rem 1rem;
    min-width: 120px;
    justify-content: center;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

#activeTagDisplay i {
    font-size: 1.1em;
}

#activeTagDisplay.updating .badge {
    transform: scale(1.05);
}

/* Active tag icon colors */
#currentTag i {
    transition: color 0.3s ease;
}

#currentTag.border-red-500 i { color: rgb(239, 68, 68); }
#currentTag.border-blue-500 i { color: rgb(59, 130, 246); }
#currentTag.border-green-500 i { color: rgb(34, 197, 94); }
#currentTag.border-yellow-500 i { color: rgb(234, 179, 8); }
#currentTag.border-cyan-500 i { color: rgb(6, 182, 212); }
#currentTag.border-purple-500 i { color: rgb(168, 85, 247); }

/* Clear filter button hover effect */
#clearFilter {
    transition: all 0.3s ease;
}

#clearFilter:hover {
    background-color: rgba(var(--color-error-base), 0.1);
    color: var(--color-error);
    color: rgb(239, 68, 68);
    transform: scale(1.05);
}

/* Tag filter container */
.filter-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.5rem; /* Maintain consistent height */
    padding: 0.25rem;
    transition: height 0.3s ease;
}

/* Theme toggle micro-interaction */
.theme-toggle i {
    transition: transform 0.4s ease;
}
.theme-toggle.spin i {
    transform: rotate(180deg) scale(1.05);
}

/* Scroll-to-top button */
#scrollTop {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 40;
}
#scrollTop.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
