/* Exercise catalogue — /exercises/list/
 *
 * Tokens are declared on the page root (.exc), not :root, so nothing leaks
 * into other pages — matching lessons_schedule_redesign.css and
 * _homework_list_styles.html.
 *
 * The catalogue's one real problem is that nine unrelated kinds of task share
 * one grid.  So type is the organising signal here: every type owns a hue and
 * an icon, carried by the left edge of the card, the icon tile and the filter
 * chip.  Filter and result share one visual key, and the grid becomes
 * scannable without reading a single badge.
 */

.exc {
    --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --bg: #f4f5f8;
    --surface: #fff;
    --surface-2: #f8f9fc;
    --surface-3: #f1f3f8;
    --border: #e6e8ef;
    --border-2: #d9dce6;

    --text: #1a2030;
    --text-2: #5b6577;
    --text-3: #8b94a6;

    --primary: #4f46e5;
    --primary-700: #4338ca;
    --primary-50: #eef0fe;
    --primary-100: #e0e2fb;

    --green: #0a8f53;
    --green-bg: #e6f6ee;
    --amber: #b4690e;
    --amber-bg: #fbf0dd;
    --rose: #d61f49;
    --rose-bg: #fdeaee;
    --sky: #0e7490;
    --sky-bg: #e0f2f7;

    --r-sm: 8px;
    --r: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --r-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(20, 28, 48, .05), 0 1px 1px rgba(20, 28, 48, .04);
    --shadow: 0 2px 8px rgba(20, 28, 48, .06), 0 1px 2px rgba(20, 28, 48, .05);
    --shadow-md: 0 8px 28px rgba(20, 28, 48, .10), 0 2px 6px rgba(20, 28, 48, .06);
    --ease: cubic-bezier(.22, .61, .36, 1);

    font-family: var(--font);
    color: var(--text);
    padding-bottom: 96px;
}

body:has(.exc) { background: var(--bg, #f4f5f8); }

.exc [v-cloak] { display: none; }
.exc *:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── per-type identity ───────────────────────────────────────────────── */
.exc [data-type] { --t: #4f46e5; --t-bg: #eef0fe; }
.exc [data-type="fill-in-the-blank"] { --t: #4f46e5; --t-bg: #eceefe; }
.exc [data-type="multiple-choice"]   { --t: #0e7490; --t-bg: #e0f2f7; }
.exc [data-type="word-order"]        { --t: #7c3aed; --t-bg: #f1e9fe; }
.exc [data-type="puzzle"]            { --t: #b4690e; --t-bg: #fbf0dd; }
.exc [data-type="ai-html"]           { --t: #475569; --t-bg: #eef1f5; }
.exc [data-type="free-answer-ai"]    { --t: #d61f49; --t-bg: #fdeaee; }
.exc [data-type="dictation"]         { --t: #0284c7; --t-bg: #e2f1fc; }
.exc [data-type="speaking"]          { --t: #0a8f53; --t-bg: #e6f6ee; }
.exc [data-type="listening"]         { --t: #9333ea; --t-bg: #f5e9fd; }

/* ── header ──────────────────────────────────────────────────────────── */
.exc-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin: 8px 0 20px;
}
.exc-head__title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -.02em;
    margin: 0;
}
.exc-head__sub {
    margin: 4px 0 0;
    color: var(--text-2);
    font-size: 14px;
}
.exc-head__sub b { color: var(--text); font-weight: 700; }

/* ── buttons ─────────────────────────────────────────────────────────── */
.exc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border: 1px solid var(--border-2);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: 650 14px/1 var(--font);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s var(--ease), border-color .15s var(--ease),
                transform .15s var(--ease), color .15s var(--ease);
}
.exc-btn:hover { background: var(--surface-3); color: var(--text); }
.exc-btn:active { transform: translateY(1px); }
.exc-btn--primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.exc-btn--primary:hover { background: var(--primary-700); color: #fff; }
.exc-btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.exc-btn--ghost:hover { background: var(--surface-3); color: var(--text); }
.exc-btn--danger { color: var(--rose); }
.exc-btn--danger:hover { background: var(--rose-bg); color: var(--rose); }
.exc-btn--sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.exc-btn--icon { width: 40px; padding: 0; }
.exc-btn--sm.exc-btn--icon { width: 32px; }
.exc-btn[disabled] { opacity: .5; pointer-events: none; }

/* ── scope tabs ──────────────────────────────────────────────────────── */
.exc-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface-3);
    border-radius: var(--r);
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 12px;
}
.exc-tabs::-webkit-scrollbar { display: none; }
.exc-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-2);
    font: 650 13.5px/1 var(--font);
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.exc-tab:hover { color: var(--text); }
.exc-tab.is-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
.exc-tab__n {
    font: 600 11.5px/1 var(--mono);
    color: var(--text-3);
    background: var(--surface-2);
    border-radius: var(--r-pill);
    padding: 3px 6px;
}
.exc-tab.is-active .exc-tab__n { background: var(--primary-50); color: var(--primary); }

/* ── toolbar ─────────────────────────────────────────────────────────── */
.exc-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: 10px;
}
.exc-search {
    position: relative;
    flex: 1 1 260px;
    min-width: 200px;
}
.exc-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    font-size: 13px;
    pointer-events: none;
}
.exc-search input {
    width: 100%;
    height: 40px;
    padding: 0 76px 0 36px;
    border: 1px solid var(--border-2);
    border-radius: 10px;
    background: var(--surface-2);
    font: 500 14px/1 var(--font);
    color: var(--text);
}
.exc-search input::placeholder { color: var(--text-3); }
.exc-search input:focus { background: var(--surface); border-color: var(--primary); outline: none; }
.exc-search__kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font: 600 11px/1 var(--mono);
    color: var(--text-3);
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 4px 6px;
}
.exc-search__clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    padding: 6px;
    line-height: 1;
}
.exc-search__clear:hover { color: var(--text); }

.exc-field {
    height: 40px;
    padding: 0 32px 0 12px;
    border: 1px solid var(--border-2);
    border-radius: 10px;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b94a6' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E") no-repeat right 12px center;
    font: 600 13.5px/1 var(--font);
    color: var(--text);
    appearance: none;
    cursor: pointer;
    max-width: 200px;
}
.exc-field:focus { border-color: var(--primary); outline: none; }

.exc-seg {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--surface-3);
    border-radius: 10px;
}
.exc-seg button {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
}
.exc-seg button.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ── type chips ──────────────────────────────────────────────────────── */
.exc-types {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 2px 4px;
}
@media (max-width: 900px) {
    /* nine chips will not wrap into anything readable on a phone, so they
       become one swipeable row instead */
    .exc-types { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .exc-types::-webkit-scrollbar { display: none; }
}
.exc-type {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--text-2);
    font: 650 13px/1 var(--font);
    white-space: nowrap;
    cursor: pointer;
    transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease);
}
.exc-type i { color: var(--t); font-size: 12px; }
.exc-type:hover { border-color: var(--t); color: var(--text); }
.exc-type.is-active {
    background: var(--t-bg);
    border-color: var(--t);
    color: var(--t);
}
.exc-type.is-empty { opacity: .45; }
.exc-type__n { font: 600 11.5px/1 var(--mono); color: var(--text-3); }
.exc-type.is-active .exc-type__n { color: var(--t); }

/* ── active filter chips ─────────────────────────────────────────────── */
.exc-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 2px 0;
}
.exc-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 30px;
    padding: 0 6px 0 12px;
    border: 1px solid var(--primary-100);
    background: var(--primary-50);
    color: var(--primary-700);
    border-radius: var(--r-pill);
    font: 650 12.5px/1 var(--font);
}
.exc-chip button {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 4px 6px;
    line-height: 1;
    border-radius: 50%;
    opacity: .7;
}
.exc-chip button:hover { opacity: 1; background: var(--primary-100); }

/* ── filter drawer ───────────────────────────────────────────────────── */
.exc-drawer {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px;
    margin-top: 10px;
}
.exc-drawer label {
    display: block;
    font: 700 10.5px/1 var(--mono);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 6px;
}
.exc-drawer .exc-field { width: 100%; max-width: none; }

/* ── results meta line ───────────────────────────────────────────────── */
.exc-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 20px 2px 12px;
    font: 600 13px/1 var(--font);
    color: var(--text-2);
}
.exc-meta__count b { color: var(--text); }
.exc-meta__sel {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font: 650 13px/1 var(--font);
    color: var(--text-2);
    cursor: pointer;
}

/* ── grid ────────────────────────────────────────────────────────────── */
.exc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}
.exc-grid--rows { grid-template-columns: 1fr; gap: 8px; }

.exc-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--t);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px 16px 12px;
    transition: box-shadow .18s var(--ease), transform .18s var(--ease),
                border-color .18s var(--ease);
}
.exc-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.exc-card.is-selected { border-color: var(--primary); background: var(--primary-50); }

.exc-card__top { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.exc-card__icon {
    flex: none;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--t-bg);
    color: var(--t);
    font-size: 14px;
}
.exc-card__type {
    font: 700 10.5px/1 var(--mono);
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--t);
}
.exc-card__title {
    margin: 3px 0 0;
    font: 700 15.5px/1.35 var(--font);
    color: var(--text);
    letter-spacing: -.01em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.exc-card__title a { color: inherit; text-decoration: none; }
.exc-card__title a:hover { color: var(--primary); }
.exc-card__desc {
    margin: 8px 0 0;
    font: 400 13px/1.5 var(--font);
    color: var(--text-2);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.exc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.exc-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: 6px;
    background: var(--surface-3);
    color: var(--text-2);
    font: 650 11.5px/1 var(--font);
}
.exc-tag--level { font-family: var(--mono); font-weight: 700; letter-spacing: .04em; }

.exc-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
}
.exc-card__stats {
    font: 500 11.5px/1.5 var(--mono);
    color: var(--text-3);
    padding-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
}
.exc-card__stats .is-done { color: var(--green); font-weight: 600; }

.exc-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--r-pill);
    font: 700 11px/1 var(--font);
}
.exc-pill--draft { background: var(--surface-3); color: var(--text-2); }
.exc-pill--for_students { background: var(--sky-bg); color: var(--sky); }
.exc-pill--public, .exc-pill--published { background: var(--green-bg); color: var(--green); }
.exc-pill--link_only { background: var(--amber-bg); color: var(--amber); }

.exc-card__check {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s var(--ease);
}
.exc-card:hover .exc-card__check,
.exc-card__check:focus-visible,
.exc-card__check:checked { opacity: 1; }
/* no hover to reveal it on touch, and an invisible-but-tappable control is
   worse than a visible one */
@media (hover: none) { .exc-card__check { opacity: 1; } }

.exc-actions { display: flex; align-items: center; gap: 6px; }

/* row density — same markup, tighter geometry */
.exc-grid--rows .exc-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border-radius: var(--r);
}
.exc-grid--rows .exc-card:hover { transform: none; }
.exc-grid--rows .exc-card__top { margin: 0; }
.exc-grid--rows .exc-card__desc,
.exc-grid--rows .exc-card__type { display: none; }
.exc-grid--rows .exc-card__title { -webkit-line-clamp: 1; }
.exc-grid--rows .exc-tags { margin: 0; }
.exc-grid--rows .exc-card__stats { display: none; }
.exc-grid--rows .exc-card__foot { margin: 0; padding: 0; }
.exc-grid--rows .exc-card__check { position: static; opacity: 1; }

/* ── dropdown menu ───────────────────────────────────────────────────── */
.exc-menu { position: relative; }
.exc-menu__list {
    position: absolute;
    right: 0;
    bottom: calc(100% + 6px);
    z-index: 30;
    min-width: 210px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow-md);
    padding: 6px;
}
.exc-menu__list--down { top: calc(100% + 6px); bottom: auto; }
.exc-menu__list button, .exc-menu__list a {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font: 600 13.5px/1 var(--font);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.exc-menu__list button:hover, .exc-menu__list a:hover { background: var(--surface-3); }
.exc-menu__list .is-danger { color: var(--rose); }
.exc-menu__list .is-danger:hover { background: var(--rose-bg); }
.exc-menu__sep { height: 1px; background: var(--border); margin: 6px 4px; }
.exc-menu__label {
    padding: 8px 10px 4px;
    font: 700 10.5px/1 var(--mono);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-3);
}

/* ── bulk bar ────────────────────────────────────────────────────────── */
.exc-bulk {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100vw - 24px);
    padding: 10px 12px;
    background: #10162a;
    color: #fff;
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(16, 22, 42, .35);
    flex-wrap: wrap;
}
.exc-bulk__n { font: 700 13px/1 var(--font); padding: 0 4px; }
.exc-bulk .exc-btn {
    background: rgba(255, 255, 255, .10);
    border-color: rgba(255, 255, 255, .16);
    color: #fff;
}
.exc-bulk .exc-btn:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.exc-bulk .exc-menu__list { background: #1b2237; border-color: rgba(255,255,255,.12); }
.exc-bulk .exc-menu__list button { color: #fff; }
.exc-bulk .exc-menu__list button:hover { background: rgba(255,255,255,.1); }
.exc-bulk .exc-menu__label { color: rgba(255,255,255,.5); }
.exc-bulk .exc-menu__sep { background: rgba(255,255,255,.12); }

/* ── empty + loading ─────────────────────────────────────────────────── */
.exc-empty {
    text-align: center;
    padding: 64px 24px;
    background: var(--surface);
    border: 1px dashed var(--border-2);
    border-radius: var(--r-xl);
}
.exc-empty__icon {
    width: 54px;
    height: 54px;
    margin: 0 auto 16px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: var(--primary-50);
    color: var(--primary);
    font-size: 20px;
}
.exc-empty h3 { font: 800 18px/1.3 var(--font); margin: 0 0 6px; }
.exc-empty p { color: var(--text-2); font-size: 14px; margin: 0 0 18px; }

.exc-skel {
    height: 148px;
    border-radius: var(--r-lg);
    background: linear-gradient(100deg, var(--surface-3) 30%, var(--surface-2) 50%, var(--surface-3) 70%);
    background-size: 220% 100%;
    animation: exc-shimmer 1.2s infinite linear;
}
@keyframes exc-shimmer { to { background-position: -220% 0; } }

.exc-grid.is-loading { opacity: .55; transition: opacity .2s var(--ease); }

/* ── pager ───────────────────────────────────────────────────────────── */
.exc-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 28px 0 8px;
    font: 600 13px/1 var(--font);
    color: var(--text-2);
}

/* ── modal ───────────────────────────────────────────────────────────── */
.exc-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(16, 22, 42, .45);
    display: grid;
    place-items: center;
    padding: 16px;
}
.exc-modal__box {
    width: min(520px, 100%);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
.exc-modal__head {
    padding: 18px 20px 12px;
    border-bottom: 1px solid var(--border);
}
.exc-modal__head h3 { font: 800 17px/1.3 var(--font); margin: 0; }
.exc-modal__head p { margin: 4px 0 0; color: var(--text-2); font-size: 13.5px; }
.exc-modal__body { padding: 8px; overflow-y: auto; }
.exc-modal__foot {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.exc-hw {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: var(--r);
    background: transparent;
    text-align: left;
    cursor: pointer;
    font: 650 14px/1.3 var(--font);
    color: var(--text);
}
.exc-hw:hover { background: var(--surface-3); }
.exc-hw span { font: 500 12px/1 var(--mono); color: var(--text-3); }

/* ── responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .exc-head__title { font-size: 23px; }
    .exc-grid { grid-template-columns: 1fr; }
    .exc-grid--rows .exc-card {
        grid-template-columns: auto minmax(0, 1fr) auto;
        row-gap: 8px;
    }
    .exc-grid--rows .exc-tags { grid-column: 1 / -1; }
    .exc-search__kbd { display: none; }
    .exc-toolbar { padding: 8px; }
    .exc-field { flex: 1 1 140px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    .exc *, .exc *::before, .exc *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
    .exc-card:hover { transform: none; }
}
