/* --------------------------------------------------------------
# Grammar Practice — Enhanced Page Styles
# Depends on tokens defined in styles.css (:root)
-------------------------------------------------------------- */

/*--------------------------------------------------------------
# Layout
--------------------------------------------------------------*/
.grammar-container {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
    margin-bottom: 4rem;
}

/*--------------------------------------------------------------
# Filters sidebar — Enhanced
--------------------------------------------------------------*/
.filters-container {
    flex: 0 0 17.5rem;
    background: linear-gradient(160deg, #1a1b2e, #17182a);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    position: sticky;
    top: 2rem;
    height: fit-content;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: var(--shadow-md);
}

.audience-toggle {
    display: flex;
    margin-bottom: 1.5rem;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 0.5rem;
    padding: 0.25rem;
    overflow: hidden;
}

.audience-btn {
    flex: 1;
    border: none;
    padding: 0.5rem 0.75rem;
    background: transparent;
    color: var(--body-3);
    font-family: 'Plus Jakarta Sans', 'Poppins', sans-serif;
    font-size: var(--text-sm);
    cursor: pointer;
    border-radius: 0.375rem;
    transition: all 0.25s ease;
    text-align: center;
    text-decoration: none;
    font-weight: 500;
}

.audience-btn.active {
    background: linear-gradient(135deg, var(--accent-color), #818cf8);
    color: #fff;
    box-shadow: 0 2px 8px rgba(124, 127, 245, 0.3);
}

.level-filters,
.topic-filters,
.exercise-filters {
    margin-bottom: 1.5rem;
}

.filters-container h3 {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.875rem;
    color: var(--body-3);
}

.level-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.level-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    color: var(--body-3);
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Plus Jakarta Sans', 'Poppins', sans-serif;
    letter-spacing: 0.02em;
}

.level-btn:hover {
    border-color: rgba(124, 127, 245, 0.4);
    color: var(--body-1);
    background: rgba(124, 127, 245, 0.08);
}

.level-btn.active {
    background: linear-gradient(135deg, rgba(124, 127, 245, 0.2), rgba(167, 139, 250, 0.15));
    border-color: rgba(124, 127, 245, 0.5);
    color: var(--accent-color);
    box-shadow: 0 0 12px rgba(124, 127, 245, 0.15);
}

/* Divider between filter sections */
.level-filters + .topic-filters,
.topic-filters + .exercise-filters {
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.topic-list,
.exercise-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.topic-item,
.exercise-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    cursor: pointer;
    transition: color 0.2s ease;
    color: var(--body-3);
    font-size: var(--text-sm);
    font-weight: 400;
    padding: 0.25rem 0;
    border-radius: 0.375rem;
}

.topic-item:hover,
.exercise-item:hover {
    color: var(--body-1);
}

.topic-checkbox,
.exercise-checkbox {
    appearance: none;
    width: 1rem;
    height: 1rem;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.25rem;
    background-color: transparent;
    cursor: pointer;
    position: relative;
    min-width: 1rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.topic-checkbox:checked,
.exercise-checkbox:checked {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 6px rgba(124, 127, 245, 0.3);
}

.topic-checkbox:checked::after,
.exercise-checkbox:checked::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/*--------------------------------------------------------------
# Grammar content area
--------------------------------------------------------------*/
.grammar-content {
    flex: 1;
    min-width: 0;
}

.search-container {
    margin-bottom: 1.5rem;
}

.search-input {
    width: 100%;
    padding: 0.875rem 1.25rem;
    background: linear-gradient(145deg, #1a1b2e, #17182a);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-lg);
    color: var(--body-1);
    font-family: 'Plus Jakarta Sans', 'Poppins', sans-serif;
    font-size: var(--text-sm);
    font-weight: 400;
    transition: all 0.25s ease;
    box-shadow: var(--shadow-sm);
}

.search-input:focus {
    outline: none;
    border-color: rgba(124, 127, 245, 0.4);
    box-shadow: 0 0 0 3px rgba(124, 127, 245, 0.1), var(--shadow-sm);
    background: #1e1f38;
}

.search-input::placeholder {
    color: var(--body-3);
}

/*--------------------------------------------------------------
# Grammar categories — Enhanced accordion
--------------------------------------------------------------*/
.grammar-topics {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.grammar-category {
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: linear-gradient(160deg, #1a1b2e 0%, #17182a 100%);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.grammar-category:hover {
    border-color: rgba(124, 127, 245, 0.15);
}

.category-header {
    padding: 1.125rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
}

/* Subtle left indicator */
.category-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    bottom: 20%;
    width: 3px;
    background: linear-gradient(180deg, var(--accent-color), #a78bfa);
    border-radius: 0 2px 2px 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.grammar-category:has(.category-content.active) .category-header::before {
    opacity: 1;
}

.category-header:hover {
    background-color: rgba(124, 127, 245, 0.04);
}

.category-header h2 {
    font-size: var(--text-base);
    color: var(--body-1);
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
}

.toggle-icon {
    font-size: 0.7rem;
    color: var(--body-3);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
}

.category-header:hover .toggle-icon {
    color: var(--accent-color);
}

.category-content {
    display: none;
    padding: 0.5rem 1rem 1.5rem;
    grid-template-columns: repeat(auto-fill, minmax(18.75rem, 1fr));
    gap: 0.875rem;
}

.category-content.active {
    display: grid;
}

.grammar-category:not(.active) .toggle-icon {
    transform: rotate(-90deg);
}

/*--------------------------------------------------------------
# Grammar cards — Significantly enhanced
--------------------------------------------------------------*/
.grammar-card {
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: linear-gradient(145deg, #1e1f35 0%, #1b1c30 100%);
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    position: relative;
}

/* Subtle shimmer line on hover */
.grammar-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(124, 127, 245, 0.6) 50%,
        transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.grammar-card:hover {
    transform: translateY(-4px);
    border-color: rgba(124, 127, 245, 0.25);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(124, 127, 245, 0.08),
        0 4px 0 rgba(124, 127, 245, 0.1) inset;
}

.grammar-card:hover::before {
    opacity: 1;
}

.card-header {
    padding: 1rem 1.125rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.card-header h3 {
    font-size: var(--text-sm);
    color: var(--body-1);
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
    letter-spacing: -0.01em;
}

.level-tags {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.level-tag {
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 0.1875rem 0.5rem;
    border-radius: 0.3rem;
    color: var(--accent-color);
    background: rgba(124, 127, 245, 0.1);
    border: 1px solid rgba(124, 127, 245, 0.2);
    letter-spacing: 0.04em;
}

.card-body {
    padding: 0.875rem 1.125rem;
}

.card-body p {
    margin: 0 0 0.75rem;
    color: var(--body-2);
    font-size: var(--text-sm);
    line-height: 1.6;
}

.example {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-top: 0.75rem;
    border-left: 2px solid rgba(124, 127, 245, 0.3);
}

.example p {
    margin: 0.5rem 0;
    color: var(--body-2);
    font-size: var(--text-xs);
    font-style: italic;
}

.card-footer {
    padding: 0.875rem 1.125rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* Exercise buttons — distinct colored pills */
.exercise-btn {
    background: rgba(255, 255, 255, 0.04);
    color: var(--body-3);
    text-decoration: none;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: var(--text-xs);
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: 1px solid transparent;
    letter-spacing: 0.01em;
}

.exercise-btn:hover {
    color: #fff;
    background: rgba(124, 127, 245, 0.15);
    border-color: rgba(124, 127, 245, 0.3);
    transform: translateY(-1px);
}

.exercise-btn[data-exercise="multiple-choice"] {
    border-left: 2px solid #2dd4bf;
}

.exercise-btn[data-exercise="multiple-choice"]:hover {
    background: rgba(45, 212, 191, 0.12);
    border-left-color: #2dd4bf;
    border-color: rgba(45, 212, 191, 0.3);
    color: #99f6e4;
}

.exercise-btn[data-exercise="fill-gaps"] {
    border-left: 2px solid var(--accent-color);
}

.exercise-btn[data-exercise="fill-gaps"]:hover {
    background: rgba(124, 127, 245, 0.15);
    border-color: rgba(124, 127, 245, 0.4);
    color: #c7d2fe;
}

.exercise-btn[data-exercise="matching"] {
    border-left: 2px solid var(--accent-gold);
}

.exercise-btn[data-exercise="matching"]:hover {
    background: rgba(245, 200, 66, 0.12);
    border-color: rgba(245, 200, 66, 0.3);
    color: #fde68a;
}

.exercise-btn[data-exercise="sentence-building"] {
    border-left: 2px solid #f472b6;
}

.exercise-btn[data-exercise="sentence-building"]:hover {
    background: rgba(244, 114, 182, 0.12);
    border-color: rgba(244, 114, 182, 0.3);
    color: #fbcfe8;
}

.exercise-btn[data-exercise="word-order"] {
    border-left: 2px solid #38bdf8;
}

.exercise-btn[data-exercise="word-order"]:hover {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.3);
    color: #bae6fd;
}

.exercise-btn[data-exercise="test"] {
    border-left: 2px solid #a78bfa;
}

.exercise-btn[data-exercise="test"]:hover {
    background: rgba(167, 139, 250, 0.12);
    border-color: rgba(167, 139, 250, 0.3);
    color: #ddd6fe;
}

.grammar-card.hidden {
    display: none;
}

/*==============================================================
  RESPONSIVE BREAKPOINTS
==============================================================*/

/* ---- 1920px ---- */
@media (min-width: 120rem) {
    .filters-container {
        flex: 0 0 20rem;
    }
    .filters-container h3 {
        font-size: var(--text-sm);
    }
    .category-header h2 {
        font-size: var(--text-md);
    }
    .card-header h3 {
        font-size: var(--text-base);
    }
    .exercise-btn {
        font-size: var(--text-sm);
        padding: 0.5rem 1rem;
    }
    .category-content {
        grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
    }
}

/* ---- 1600px ---- */
@media (max-width: 100rem) {
    .card-header h3 {
        font-size: var(--text-sm);
    }
}

/* ---- 1280px ---- */
@media (max-width: 80rem) {
    .filters-container {
        flex: 0 0 16rem;
    }
    .category-content {
        grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
    }
}

/* ---- 1024px — collapse sidebar ---- */
@media (max-width: 64rem) {
    .grammar-container {
        flex-direction: column;
    }
    .filters-container {
        flex: none;
        width: 100%;
        position: static;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
        gap: 1rem;
    }
    .level-btn {
        flex: 1;
        min-width: 3.75rem;
    }
    .category-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ---- 768px ---- */
@media (max-width: 48rem) {
    .grammar-container {
        gap: 1.25rem;
        margin-bottom: 2.5rem;
    }
    .filters-container {
        grid-template-columns: 1fr;
        padding: 1.25rem;
    }
    .category-content {
        grid-template-columns: 1fr;
    }
    .category-header {
        padding: 0.875rem 1.25rem;
    }
    .category-header h2 {
        font-size: var(--text-sm);
    }
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* ---- 414px ---- */
@media (max-width: 25.875rem) {
    .grammar-container {
        gap: 1rem;
    }
    .filters-container {
        padding: 1rem;
    }
}

/* ---- 375px ---- */
@media (max-width: 23.4375rem) {
    .level-btn {
        font-size: var(--text-xs);
        padding: 0.25rem 0.5rem;
    }
}

/* ---- 360px ---- */
@media (max-width: 22.5rem) {
    .category-content {
        padding: 0.5rem 0.75rem 1rem;
    }
}

/* ---- 320px ---- */
@media (max-width: 20rem) {
    .filters-container {
        padding: 0.75rem;
    }
    .card-footer {
        padding: 0.75rem;
        gap: 0.25rem;
    }
    .exercise-btn {
        font-size: 0.6875rem;
        padding: 0.1875rem 0.4375rem;
    }
}