/* Stitch Palette - Interactive stitch selection interface */

.crochet-stitch-palette {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.crochet-stitch-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 0.8rem 0.6rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.crochet-stitch-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.crochet-stitch-btn:hover::before {
    left: 100%;
}

.crochet-stitch-btn:hover,
.crochet-stitch-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.crochet-stitch-btn.active {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.crochet-stitch-btn:active {
    transform: translateY(-1px);
}

/* Stitch Icons/Symbols */
.crochet-stitch-icon {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
    display: block;
    line-height: 1;
}

.crochet-stitch-name {
    font-size: 0.75rem;
    opacity: 0.9;
    font-weight: 400;
}

/* Specific Stitch Styles */
.crochet-stitch-btn[data-stitch="single-crochet"] .crochet-stitch-icon::before {
    content: '+';
    color: #4ade80;
}

.crochet-stitch-btn[data-stitch="double-crochet"] .crochet-stitch-icon::before {
    content: '┃';
    color: #fbbf24;
}

.crochet-stitch-btn[data-stitch="chain"] .crochet-stitch-icon::before {
    content: '○';
    color: #60a5fa;
}

.crochet-stitch-btn[data-stitch="slip-stitch"] .crochet-stitch-icon::before {
    content: '•';
    color: #94a3b8;
}

.crochet-stitch-btn[data-stitch="half-double"] .crochet-stitch-icon::before {
    content: '┬';
    color: #f87171;
}

.crochet-stitch-btn[data-stitch="treble"] .crochet-stitch-icon::before {
    content: '┃┃';
    color: #a78bfa;
}

.crochet-stitch-btn[data-stitch="decrease"] .crochet-stitch-icon::before {
    content: '\\';
    color: #ef4444;
}

.crochet-stitch-btn[data-stitch="increase"] .crochet-stitch-icon::before {
    content: '/';
    color: #34d399;
}

.crochet-stitch-btn[data-stitch="front-post"] .crochet-stitch-icon::before {
    content: '⊗';
    color: #10b981;
}

.crochet-stitch-btn[data-stitch="back-post"] .crochet-stitch-icon::before {
    content: '⊙';
    color: #f59e0b;
}

.crochet-stitch-btn[data-stitch="picot"] .crochet-stitch-icon::before {
    content: 'Λ';
    color: #8b5cf6;
}

.crochet-stitch-btn[data-stitch="clear"] .crochet-stitch-icon::before {
    content: '✕';
    color: #94a3b8;
}

/* Advanced Stitches Section */
.crochet-advanced-stitches {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.crochet-advanced-stitches h4 {
    color: white;
    font-size: 1rem;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.crochet-advanced-stitches h4::before {
    content: "⚡";
    font-size: 0.9rem;
}

.crochet-advanced-palette {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.crochet-advanced-palette .crochet-stitch-btn {
    min-height: 45px;
    font-size: 0.75rem;
    padding: 0.5rem 0.3rem;
}

/* Stitch Categories */
.crochet-stitch-category {
    margin-bottom: 1.5rem;
}

.crochet-category-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 0;
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.crochet-category-toggle:hover {
    color: rgba(255, 255, 255, 0.8);
}

.crochet-category-toggle::after {
    content: '▼';
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.crochet-category-toggle.collapsed::after {
    transform: rotate(-90deg);
}

.crochet-category-content {
    max-height: 200px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.crochet-category-content.collapsed {
    max-height: 0;
}

/* Quick Access Bar */
.crochet-quick-access {
    display: flex;
    gap: 0.3rem;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.crochet-quick-btn {
    width: 35px;
    height: 35px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.crochet-quick-btn:hover,
.crochet-quick-btn.active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Recent Stitches */
.crochet-recent-stitches {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.crochet-recent-stitches h5 {
    color: white;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.crochet-recent-list {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.crochet-recent-item {
    width: 30px;
    height: 30px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.crochet-recent-item:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Keyboard Shortcuts Display */
.crochet-shortcuts {
    margin-top: 1rem;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

.crochet-shortcuts h6 {
    color: white;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
}

.crochet-shortcut-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.2rem;
}

.crochet-shortcut-key {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.7rem;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .crochet-stitch-palette {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.6rem;
    }

    .crochet-stitch-btn {
        min-height: 52px;
        font-size: 0.8rem;
        padding: 0.6rem 0.4rem;
    }

    .crochet-advanced-palette {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.6rem;
    }

    .crochet-quick-access {
        justify-content: center;
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .crochet-stitch-palette {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .crochet-stitch-btn {
        min-height: 50px;
        font-size: 0.75rem;
        padding: 0.5rem 0.3rem;
        min-width: 44px;
    }

    .crochet-advanced-palette {
        grid-template-columns: repeat(4, 1fr);
    }

    .crochet-quick-access {
        justify-content: center;
        flex-wrap: wrap;
    }

    .crochet-quick-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .crochet-recent-item {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }

    .crochet-dsl-editor {
        font-size: 0.9rem;
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .crochet-stitch-palette {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
    }

    .crochet-stitch-btn {
        min-height: 48px;
        font-size: 0.7rem;
        padding: 0.4rem 0.2rem;
        min-width: 44px;
    }

    .crochet-advanced-palette {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.4rem;
    }

    .crochet-advanced-palette .crochet-stitch-btn {
        min-height: 44px;
        font-size: 0.65rem;
        padding: 0.3rem 0.1rem;
    }

    .crochet-quick-btn {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }

    .crochet-recent-item {
        width: 40px;
        height: 40px;
        font-size: 0.85rem;
    }

    .crochet-dsl-editor {
        font-size: 0.85rem;
        padding: 0.9rem;
        min-height: 44px;
    }

    .crochet-shortcuts {
        display: none;
    }

    .crochet-category-toggle {
        font-size: 0.9rem;
        padding: 0.6rem 0;
    }
}

/* Dark Mode Adjustments */
@media (prefers-color-scheme: dark) {
    .crochet-stitch-btn {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(255, 255, 255, 0.2);
    }

    .crochet-stitch-btn:hover,
    .crochet-stitch-btn.active {
        background: rgba(255, 255, 255, 0.2);
        border-color: rgba(255, 255, 255, 0.4);
    }
}

/* Accessibility */
.crochet-stitch-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.crochet-stitch-btn[aria-pressed="true"] {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.8);
}

/* Animation for stitch selection feedback */
.crochet-stitch-btn.selected-feedback {
    animation: stitchSelected 0.3s ease;
}

@keyframes stitchSelected {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}