/* ===================================
   ClickyBoard — New Animations CSS
   Hero keycap particles, typewriter,
   spotlight category cards
   =================================== */

/* ===== Hero Floating Keycap Particles ===== */
.hero-keys-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}
.hero-key-particle {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Grotesk', monospace;
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(167,139,250,0.8);
    background: rgba(127,90,240,0.09);
    border: 1px solid rgba(127,90,240,0.25);
    border-bottom: 3px solid rgba(127,90,240,0.4);
    border-radius: 6px;
    padding: 4px 9px;
    min-width: 36px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.07);
    animation: riseKey linear infinite;
    opacity: 0;
    user-select: none;
    pointer-events: none;
}
@keyframes riseKey {
    0%   { transform: translateY(0) rotate(0deg);     opacity: 0; }
    8%   { opacity: 1; }
    85%  { opacity: 0.65; }
    100% { transform: translateY(-105vh) rotate(12deg); opacity: 0; }
}

/* ===== Typewriter ===== */
.hero-typewriter {
    display: inline-block;
    color: var(--color-primary-light);
    font-weight: 700;
    border-right: 2px solid var(--color-primary);
    padding-right: 2px;
    animation: twBlink 0.75s step-end infinite;
}
@keyframes twBlink {
    0%,100% { border-color: var(--color-primary); }
    50%      { border-color: transparent; }
}

/* ===== Spotlight Category Cards ===== */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.1rem;
}

.cat-card {
    position: relative;
    padding: 1.75rem;
    border-radius: 1.25rem;
    background: #0f0f1c;
    border: 1px solid rgba(255,255,255,0.07);
    overflow: hidden;
    text-decoration: none;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 210px;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Mouse-tracking spotlight */
.cat-spotlight {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(
        500px circle at var(--sx, 50%) var(--sy, 50%),
        rgba(var(--clr), 0.14),
        transparent 50%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 0;
}
.cat-card:hover .cat-spotlight { opacity: 1; }

/* Glowing top border */
.cat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(var(--clr),0.85), transparent);
    opacity: 0;
    transition: opacity 0.35s ease;
}
.cat-card:hover::before { opacity: 1; }

/* Colored bottom accent bar */
.cat-bottom-bar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: var(--bar-clr);
    border-radius: 0 0 1.25rem 1.25rem;
    opacity: 0;
    transition: opacity 0.35s ease;
}
.cat-card:hover .cat-bottom-bar { opacity: 1; }

.cat-card:hover {
    transform: translateY(-6px);
    border-color: rgba(var(--clr), 0.28);
    box-shadow: 0 20px 50px rgba(0,0,0,0.45),
                0 0 0 1px rgba(var(--clr), 0.12);
}

/* Icon */
.cat-icon-wrap {
    position: relative;
    z-index: 1;
    width: 58px;
    height: 58px;
    border-radius: 14px;
    background: var(--icon-clr);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-stroke);
    transition: transform 0.3s ease, background 0.3s ease;
    flex-shrink: 0;
}
.cat-card:hover .cat-icon-wrap {
    transform: scale(1.1) rotate(-4deg);
    background: rgba(var(--clr), 0.22);
}

/* Text */
.cat-info {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.cat-count {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(var(--clr), 0.9);
}
.cat-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.15;
}
.cat-desc {
    font-size: 0.84rem;
    color: rgba(255,255,255,0.42);
    margin: 0;
    line-height: 1.4;
}

/* Arrow button */
.cat-arrow {
    position: relative;
    z-index: 1;
    color: rgba(var(--clr), 0.65);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(var(--clr), 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    margin-top: auto;
    transition: all 0.25s ease;
}
.cat-card:hover .cat-arrow {
    background: rgba(var(--clr), 0.15);
    border-color: rgba(var(--clr), 0.5);
    color: rgb(var(--clr));
    transform: translateX(4px);
}

/* Responsive */
@media (max-width: 900px) {
    .cat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
    .cat-grid { grid-template-columns: 1fr; }
    .cat-card  { min-height: 160px; }
}

/* ==============================================
   ✦ HERO — Two Column Split Layout
   ============================================== */
.hero-split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 4.5rem 8vw 2.5rem;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}
.hero-split .hero-content {
    flex: 1;
    max-width: 540px;
    text-align: left;
    padding: 0;
}
.hero-split .hero-stats {
    justify-content: flex-start;
}

/* ==============================================
   ✦ RGB Bloom — Glowing backlight behind keyboard
   ============================================== */
.rgb-bloom {
    position: absolute;
    right: 5%;
    top: 50%;
    transform: translateY(-50%);
    width: 480px;
    height: 480px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        #ff0055, #ff6600, #ffdd00,
        #00ff88, #0099ff, #aa00ff,
        #ff0055
    );
    filter: blur(90px);
    opacity: 0.18;
    animation: rgbSpin 8s linear infinite;
    pointer-events: none;
    z-index: 0;
    will-change: filter, opacity;
}
@keyframes rgbSpin {
    0%   { filter: blur(90px) hue-rotate(0deg);   opacity: 0.18; }
    50%  { filter: blur(110px) hue-rotate(180deg); opacity: 0.22; }
    100% { filter: blur(90px) hue-rotate(360deg);  opacity: 0.18; }
}

/* ==============================================
   ✦ Keyboard Wrapper — Float + 3D perspective
   ============================================== */
.hero-keyboard-wrap {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 900px;
    z-index: 1;
}

.kb3d {
    position: relative;
    animation: kbFloat 5s ease-in-out infinite;
    transform-style: preserve-3d;
}
@keyframes kbFloat {
    0%   { transform: rotateX(22deg) rotateY(-15deg) rotateZ(-2deg) translateY(0); }
    33%  { transform: rotateX(18deg) rotateY(-8deg)  rotateZ(0deg)  translateY(-10px); }
    66%  { transform: rotateX(24deg) rotateY(-20deg) rotateZ(-3deg) translateY(-4px); }
    100% { transform: rotateX(22deg) rotateY(-15deg) rotateZ(-2deg) translateY(0); }
}

/* ==============================================
   ✦ Keyboard Board (the body)
   ============================================== */
.kb3d-board {
    position: relative;
    background: linear-gradient(160deg, #1e1e2e 0%, #16161f 60%, #12121a 100%);
    border-radius: 14px;
    padding: 20px 22px 22px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow:
        0 0 0 1px rgba(0,0,0,0.8),
        0 30px 60px rgba(0,0,0,0.8),
        0 0 80px rgba(127,90,240,0.12),
        inset 0 1px 0 rgba(255,255,255,0.05);
    transform-style: preserve-3d;
    /* 3D physical depth — simulated bottom face */
    border-bottom: 4px solid #0a0a10;
}

/* ==============================================
   ✦ RGB Per-Key Backlight (shimmer wave)
   ============================================== */
.kb3d-backlight {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg,
        rgba(127,90,240,0.08) 0%,
        rgba(6,182,212,0.06) 33%,
        rgba(233,109,230,0.07) 66%,
        rgba(251,191,36,0.06) 100%
    );
    animation: backlightShimmer 4s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}
@keyframes backlightShimmer {
    0%   { filter: hue-rotate(0deg)   brightness(1); }
    50%  { filter: hue-rotate(180deg) brightness(1.3); }
    100% { filter: hue-rotate(360deg) brightness(1); }
}

/* ==============================================
   ✦ Keyboard Rows + Keys
   ============================================== */
.kb3d-row {
    display: flex;
    gap: 7px;
    margin-bottom: 7px;
    position: relative;
    z-index: 1;
}
.kb3d-row:last-child { margin-bottom: 0; }

.kb3d-key {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 7px;
    background: linear-gradient(160deg, #2a2a3e 0%, #1e1e2e 100%);
    border: 1px solid rgba(255,255,255,0.1);
    border-bottom: 4px solid #0a0a12;
    box-shadow:
        0 4px 10px rgba(0,0,0,0.5),
        inset 0 1px 0 rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.75);
    font-family: 'Space Grotesk', monospace;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.08s ease, border-bottom-width 0.08s ease;
    user-select: none;
    will-change: transform;
    /* RGB per-key glow — staggered via nth-child */
    text-shadow: 0 0 6px currentColor;
}

/* Staggered RGB color per key */
.kb3d-key--lit { color: rgba(167,139,250,0.9); }
.kb3d-row:nth-child(3) .kb3d-key--lit { color: rgba(127,90,240,0.9); }
.kb3d-row:nth-child(4) .kb3d-key--lit { color: rgba(6,182,212,0.9); }
.kb3d-row:nth-child(5) .kb3d-key--lit { color: rgba(233,109,230,0.9); }

/* Pulse animation cycling RGB colors */
.kb3d-key--lit {
    animation: keyRgbPulse 3s ease-in-out infinite;
}
.kb3d-row:nth-child(3) .kb3d-key--lit { animation-delay: -0.5s; }
.kb3d-row:nth-child(4) .kb3d-key--lit { animation-delay: -1s; }
.kb3d-row:nth-child(5) .kb3d-key--lit { animation-delay: -1.5s; }

@keyframes keyRgbPulse {
    0%   { color: rgba(127,90,240,0.9);  text-shadow: 0 0 8px rgba(127,90,240,0.8); }
    25%  { color: rgba(6,182,212,0.9);   text-shadow: 0 0 8px rgba(6,182,212,0.8); }
    50%  { color: rgba(233,109,230,0.9); text-shadow: 0 0 8px rgba(233,109,230,0.8); }
    75%  { color: rgba(251,191,36,0.9);  text-shadow: 0 0 8px rgba(251,191,36,0.8); }
    100% { color: rgba(127,90,240,0.9);  text-shadow: 0 0 8px rgba(127,90,240,0.8); }
}

/* Key size variants */
.kb3d-key--fn    { height: 34px; font-size: 0.58rem; }
.kb3d-key--wide  { width: 78px; }
.kb3d-key--wide2 { width: 68px; font-size: 0.58rem; }
.kb3d-key--wide3 { width: 88px; font-size: 0.58rem; }
.kb3d-key--space { flex: 1; min-width: 160px; }

/* ✦ KEY PRESS EFFECT — hover + active */
.kb3d-key:hover {
    background: linear-gradient(160deg, #33335a 0%, #252538 100%);
    border-color: rgba(var(--key-clr, 127,90,240), 0.5);
    box-shadow:
        0 4px 10px rgba(0,0,0,0.5),
        0 0 16px rgba(127,90,240,0.3),
        inset 0 1px 0 rgba(255,255,255,0.1);
}
.kb3d-key:active,
.kb3d-key.pressed {
    transform: translateY(3px);
    border-bottom-width: 1px;
    box-shadow:
        0 1px 4px rgba(0,0,0,0.6),
        0 0 20px rgba(127,90,240,0.5),
        inset 0 2px 4px rgba(0,0,0,0.4);
}

/* ==============================================
   ✦ Keyboard Shadow (base/ground)
   ============================================== */
.kb3d-shadow {
    position: absolute;
    bottom: -30px;
    left: 10%;
    right: 10%;
    height: 30px;
    background: radial-gradient(ellipse, rgba(0,0,0,0.6) 0%, transparent 70%);
    filter: blur(10px);
    pointer-events: none;
}

/* ==============================================
   ✦ Responsive — hide keyboard on small screens
   ============================================== */
@media (max-width: 1024px) {
    .hero-split {
        flex-direction: column;
        text-align: center;
        padding: 5rem 2rem 3rem;
    }
    .hero-split .hero-content { max-width: 100%; text-align: center; }
    .hero-split .hero-stats   { justify-content: center; }
    .hero-keyboard-wrap { transform: scale(0.75); margin-top: -1rem; }
}
@media (max-width: 640px) {
    .hero-keyboard-wrap { display: none; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .kb3d, .rgb-bloom, .kb3d-backlight, .kb3d-key--lit {
        animation: none !important;
    }
}
