/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    color: hsl(222.2 84% 4.9%);
    background-color: hsl(0 0% 100%);
    font-weight: 400;
}

/* Page header for home page */
.page-header {
    text-align: center;
    padding: 3rem 1rem 2rem;
}

.page-header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    color: hsl(222.2 84% 4.9%);
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.page-header p {
    font-size: 1.125rem;
    color: hsl(215.4 16.3% 46.9%);
    font-weight: 400;
}

/* Header styles for category page */
header {
    border-bottom: 1px solid hsl(214.3 31.8% 91.4%);
    background: hsl(0 0% 100%);
    padding: 1.5rem 1rem;
}

header h1 {
    font-size: 1.875rem;
    margin-bottom: 0.25rem;
    font-weight: 700;
    color: hsl(222.2 84% 4.9%);
}

header p {
    font-size: 1rem;
    color: hsl(215.4 16.3% 46.9%);
    font-weight: 400;
}

/* Navigation */
nav {
    margin-bottom: 1rem;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: hsl(215.4 16.3% 46.9%);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid hsl(214.3 31.8% 91.4%);
    background: hsl(0 0% 100%);
}

.back-button:hover {
    background: hsl(210 40% 98%);
    color: hsl(222.2 84% 4.9%);
}

/* Main content */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Categories container */
.categories-container {
    padding-bottom: 2rem;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.category-card {
    background: hsl(0 0% 100%);
    border: 1px solid hsl(214.3 31.8% 91.4%);
    border-radius: 0.5rem;
    padding: 1.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.category-card:hover {
    border-color: hsl(215.4 16.3% 46.9%);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.category-emoji {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
}

.category-card h3 {
    color: hsl(222.2 84% 4.9%);
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
}

.category-card .translated-title {
    color: hsl(215.4 16.3% 46.9%);
    margin-bottom: 1rem;
    font-size: 1.125rem;
    font-weight: 500;
    direction: rtl;
    text-align: right;
    line-height: 1.5;
}

.category-card .word-count {
    background: hsl(221.2 83.2% 53.3%);
    color: hsl(210 40% 98%);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-block;
}

/* Audio Player */
.audio-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: hsl(0 0% 100%);
    padding: 1rem 1.5rem;
    border-top: 1px solid hsl(214.3 31.8% 91.4%);
    z-index: 1000;
    box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.1);
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.control-btn {
    background: hsl(221.2 83.2% 53.3%);
    color: hsl(210 40% 98%);
    border: none;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    font-weight: 500;
}

.control-btn:hover {
    background: hsl(221.2 83.2% 48%);
}

.control-btn:disabled {
    background: hsl(215.4 16.3% 46.9%);
    cursor: not-allowed;
    opacity: 0.5;
}

.stop-btn {
    background: hsl(0 84.2% 60.2%);
}

.stop-btn:hover {
    background: hsl(0 84.2% 55%);
}

.progress-container {
    flex: 1;
}

.progress-bar {
    width: 100%;
    height: 0.25rem;
    background: hsl(214.3 31.8% 91.4%);
    border-radius: 9999px;
    overflow: hidden;
    cursor: pointer;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: hsl(221.2 83.2% 53.3%);
    width: 0%;
    transition: width 0.1s ease;
}

.time-display {
    font-size: 0.75rem;
    color: hsl(215.4 16.3% 46.9%);
    font-weight: 500;
}

.now-playing {
    color: hsl(215.4 16.3% 46.9%);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Words list */
.words-container {
    margin-bottom: 160px; /* Increased space for fixed player */
    padding: 1rem 0;
}

.words-container h2 {
    margin-bottom: 1.5rem;
    color: hsl(222.2 84% 4.9%);
    font-size: 1.5rem;
    font-weight: 700;
}

.words-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.word-card {
    background: hsl(0 0% 100%);
    border: 1px solid hsl(214.3 31.8% 91.4%);
    border-radius: 0.5rem;
    padding: 1.5rem;
    transition: all 0.2s ease;
    scroll-margin-top: 2rem;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.word-card:hover {
    border-color: hsl(215.4 16.3% 46.9%);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.word-card.current-playing {
    border-color: hsl(221.2 83.2% 53.3%);
    box-shadow: 0 0 0 1px hsl(221.2 83.2% 53.3%), 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.word-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.word-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 0; /* Allow text to wrap */
}

.word-source {
    font-size: 1.125rem;
    font-weight: 600;
    color: hsl(222.2 84% 4.9%);
    line-height: 1.4;
    word-wrap: break-word;
}

.word-translation {
    font-size: 1rem;
    color: hsl(215.4 16.3% 46.9%);
    font-weight: 500;
    direction: rtl;
    text-align: right;
    line-height: 1.5;
    word-wrap: break-word;
}

.word-examples {
    padding-top: 1rem;
    border-top: 1px solid hsl(214.3 31.8% 91.4%);
}

.example {
    margin-bottom: 0.75rem;
}

.example:last-child {
    margin-bottom: 0;
}

.example-source {
    color: hsl(222.2 84% 4.9%);
    margin-bottom: 0.25rem;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
}

.example-translation {
    color: hsl(222.2 84% 4.9%);
    font-size: 1rem;
    font-weight: 500;
    direction: rtl;
    text-align: right;
    line-height: 1.5;
}

.play-word-btn {
    background: hsl(221.2 83.2% 53.3%);
    color: hsl(210 40% 98%);
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.play-word-btn:hover {
    background: hsl(221.2 83.2% 48%);
}

.play-word-btn:disabled {
    background: hsl(215.4 16.3% 46.9%);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 3rem;
    color: hsl(215.4 16.3% 46.9%);
    font-size: 1rem;
    font-weight: 500;
}

/* Error state */
.error {
    background: hsl(0 84.2% 97%);
    color: hsl(0 74.4% 42%);
    padding: 1rem;
    border-radius: 0.375rem;
    margin: 1rem 0;
    text-align: center;
    border: 1px solid hsl(0 84.2% 90%);
    font-weight: 500;
}

/* Responsive design */
@media (max-width: 768px) {
    .page-header h1 {
        font-size: 1.875rem;
    }
    
    .page-header p {
        font-size: 1rem;
    }
    
    .categories-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .words-list {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .player-controls {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .progress-container {
        width: 100%;
    }
    
    .word-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .word-source {
        font-size: 1.125rem;
    }
    
    .word-translation {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .page-header {
        padding: 2rem 1rem 1.5rem;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .audio-player {
        padding: 0.75rem 1rem;
    }
    
    .category-card {
        padding: 1.25rem;
    }
    
    .word-card {
        padding: 1.25rem;
    }
    
    .words-list {
        gap: 0.75rem;
    }
}
