/* free-drills.css — public /drills/free listing.
   Diagram-forward card grid + category sidebar (off-canvas drawer on mobile).
   Built on the Elite Tactician v3 tokens (--et-*, --shadow-ambient,
   --ghost-border). Mobile-first. */

.free-drills-page {
    padding-top: 1.5rem;
    padding-bottom: 3rem;
}

.free-drills-intro {
    max-width: 60ch;
}

/* "Browse Categories" toggle: only while the category sidebar is collapsed to a
   drawer (< 1024px). ID-scoped so it beats `.btn { display: inline-flex }`,
   which Tailwind's `lg:hidden` (equal specificity) can't reliably override. */
#free-drills-category-toggle { display: inline-flex; }
@media (min-width: 1024px) {
    #free-drills-category-toggle { display: none; }
}

/* ---- Category sidebar --------------------------------------------------- */

.free-drills-sidebar__inner {
    background: var(--et-surface-container-lowest, #fff);
    border-radius: 1rem;
    box-shadow: var(--shadow-ambient, 0 12px 32px -4px rgba(25, 28, 30, 0.06));
    padding: 0.75rem;
}

.free-drills-catnav {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

/* ID-scoped so these beat the global `.main-content-v3 a:not(.btn)` crimson
   link color (typography-v3.css), which is more specific than a bare class and
   would otherwise render the active name crimson-on-crimson (illegible). */
#free-drills-sidebar .free-drills-catnav__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.625rem;
    font-size: 0.9375rem;
    color: var(--et-on-surface, #1a1c1e);
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

#free-drills-sidebar .free-drills-catnav__item:hover {
    background: var(--et-surface-container-low, #f2f4f6);
    color: var(--et-on-surface, #1a1c1e);
}

#free-drills-sidebar .free-drills-catnav__item.is-active,
#free-drills-sidebar .free-drills-catnav__item.is-active:hover {
    background: var(--et-secondary, #b6152e);
    color: #fff;
    font-weight: 600;
}

.free-drills-catnav__count {
    flex-shrink: 0;
    min-width: 1.75rem;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    background: var(--et-surface-container, #ebedf0);
    color: var(--et-on-surface-variant, #44474a);
}

.free-drills-catnav__item.is-active .free-drills-catnav__count {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

/* Sticky on desktop. */
@media (min-width: 1024px) {
    .free-drills-sidebar {
        position: sticky;
        top: 5rem;
        align-self: start;
    }
    .free-drills-sidebar__backdrop { display: none; }
}

/* ---- Mobile: off-canvas drawer ----------------------------------------- */

@media (max-width: 1023px) {
    .free-drills-sidebar {
        position: fixed;
        inset: 0;
        z-index: 60;
        pointer-events: none;
        visibility: hidden;
    }
    .free-drills-sidebar.is-open { pointer-events: auto; visibility: visible; }

    .free-drills-sidebar__inner {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(80vw, 320px);
        border-radius: 0;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 2;
    }
    .free-drills-sidebar.is-open .free-drills-sidebar__inner { transform: translateX(0); }

    .free-drills-sidebar__backdrop {
        position: absolute;
        inset: 0;
        background: rgba(4, 14, 33, 0.45);
        opacity: 0;
        transition: opacity 0.25s ease;
        z-index: 1;
    }
    .free-drills-sidebar.is-open .free-drills-sidebar__backdrop { opacity: 1; }
}

.free-drills-sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
    border-bottom: var(--ghost-border, 1px solid rgba(197, 198, 205, 0.2));
}

.free-drills-sidebar__close {
    border: none;
    background: transparent;
    font-size: 1.125rem;
    color: var(--et-on-surface-variant, #44474a);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

/* ---- Diagram card grid -------------------------------------------------- */

.free-drills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

@media (min-width: 640px) {
    .free-drills-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

.free-drill-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--et-surface-container-lowest, #fff);
    border-radius: 0.875rem;
    box-shadow: var(--shadow-ambient, 0 12px 32px -4px rgba(25, 28, 30, 0.06));
    border-bottom: 3px solid transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

/* Raise the card whose menu is open so the dropdown isn't covered by siblings. */
.free-drill-card.menu-open {
    z-index: 20;
}

.free-drill-card:hover,
.free-drill-card:focus-within {
    transform: translateY(-2px);
    border-bottom-color: var(--et-secondary, #b6152e);
    box-shadow: 0 16px 40px -6px rgba(25, 28, 30, 0.16);
}

/* ---- Top action row (checkbox · status badges · kebab) ----------------- */
.free-drill-card__topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    /* Light navy tint — a literal cool blue (the near-black ET primary reads as
       neutral gray at low opacity), so the header strip is clearly distinct
       from the gray page. */
    background: #e3e9f5;
    border-bottom: var(--ghost-border, 1px solid rgba(197, 198, 205, 0.2));
    border-top-left-radius: 0.875rem;
    border-top-right-radius: 0.875rem;
}

.free-drill-card__topbar-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.fd-select-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    cursor: pointer;
}
.fd-select {
    width: 1.05rem;
    height: 1.05rem;
    cursor: pointer;
    accent-color: var(--et-secondary, #b6152e);
}
.fd-select-spacer { width: 1.75rem; height: 1.75rem; }

/* The inner anchor is the "View" target covering the diagram + body. */
.free-drill-card__link {
    display: flex;
    flex-direction: column;
    flex: 1;
    text-decoration: none;
    color: inherit;
}

.free-drill-card__thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    /* White so the contained diagram (drawn on white) blends seamlessly and the
       letterbox gaps don't read as odd gray bands. */
    background: #fff;
    overflow: hidden;
}

/* contain (not cover) so the full diagram shows without cropped edges. */
.free-drill-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.free-drill-card__thumb-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--et-on-surface-variant, #9aa0a6);
}

/* Status badges now live inline in the top row, not over the diagram. */
.free-drill-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.375rem;
    font-size: 0.6875rem;
    color: #fff;
}

.free-drill-badge--info { background: var(--et-info, #0891b2); }
.free-drill-badge--success { background: var(--et-success, #059669); }

/* Favorite star — only shown once the card is favorited. */
.free-drill-badge--fav { background: var(--et-warning, #d97706); display: none; }
.free-drill-card.is-favorited .free-drill-badge--fav { display: inline-flex; }

/* Selected (bulk) state. */
.free-drill-card.is-selected {
    outline: 2px solid var(--et-secondary, #b6152e);
    outline-offset: 1px;
}

/* ---- Per-card action menu (kebab) -------------------------------------- */

.free-drill-card__menu-btn {
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--et-on-surface-variant, #44474a);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.free-drill-card__menu-btn:hover {
    background: var(--et-surface-container-low, #f2f4f6);
    color: var(--et-on-surface, #1a1c1e);
}

.free-drill-card__menu {
    position: absolute;
    top: 2.75rem;
    right: 0.5rem;
    z-index: 25;
    min-width: 200px;
    padding: 0.375rem;
    background: var(--et-surface-container-lowest, #fff);
    border-radius: 0.75rem;
    box-shadow: 0 16px 40px -6px rgba(25, 28, 30, 0.28);
    border: var(--ghost-border, 1px solid rgba(197, 198, 205, 0.2));
}

.fdc-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: none;
    background: transparent;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    text-align: left;
    color: var(--et-on-surface, #1a1c1e);
    text-decoration: none;
    cursor: pointer;
}

.fdc-menu-item:hover {
    background: var(--et-surface-container-low, #f2f4f6);
    color: var(--et-on-surface, #1a1c1e);
}

.fdc-menu-item:disabled {
    opacity: 0.6;
    cursor: default;
}

.fdc-menu-item i {
    color: var(--et-on-surface-variant, #44474a);
}

.fdc-menu-sep {
    height: 1px;
    margin: 0.375rem 0.25rem;
    background: var(--et-surface-container, #ebedf0);
}

/* ---- Toast ------------------------------------------------------------- */

.fd-toast {
    position: fixed;
    /* Clear the fixed site header (z-index 1030, ~4rem tall) — sit above it. */
    top: 4.75rem;
    right: 1rem;
    z-index: 1100;
    padding: 0.75rem 1.25rem;
    border-radius: 0.625rem;
    box-shadow: 0 12px 32px -4px rgba(25, 28, 30, 0.24);
    font-size: 0.9375rem;
    transform: translateX(120%);
    transition: transform 0.3s ease;
}

.fd-toast.is-visible { transform: translateX(0); }
.fd-toast--success { background: var(--et-success, #059669); color: var(--et-on-success, #fff); }
.fd-toast--error { background: var(--et-error, #dc2626); color: #fff; }
.fd-toast--info { background: var(--et-info, #0891b2); color: #fff; }

/* ---- Modals (email + send-to-coach) ------------------------------------ */

.fd-modal[hidden] { display: none; }

.fd-modal {
    position: fixed;
    inset: 0;
    /* Above the fixed header (z-index 1030); toasts (1100) still sit above. */
    z-index: 1060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.fd-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 14, 33, 0.5);
}

.fd-modal-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    background: var(--et-surface-container-lowest, #fff);
    border-radius: 1rem;
    box-shadow: 0 24px 60px -8px rgba(25, 28, 30, 0.4);
    padding: 1.5rem;
}

.fd-modal-dialog h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--et-on-surface, #1a1c1e);
}

.fd-modal-subtitle {
    margin-top: 0.25rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--et-on-surface-variant, #44474a);
}

.fd-modal-dialog label {
    display: block;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--et-on-surface-variant, #44474a);
}

.fd-modal-dialog input,
.fd-modal-dialog textarea {
    width: 100%;
}

.fd-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.fd-modal-hint {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    min-height: 1.1em;
}
.fd-modal-hint.is-error { color: var(--et-error, #dc2626); }
.fd-modal-hint.is-success { color: var(--et-success, #059669); }

.free-drill-card__body {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    flex: 1;
    background: #fff;
    border-bottom-left-radius: 0.875rem;
    border-bottom-right-radius: 0.875rem;
}

/* ---- Bulk action bar --------------------------------------------------- */
.fd-bulk-bar {
    position: sticky;
    top: 4.5rem; /* clear the fixed header while scrolling the grid */
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.625rem 0.875rem;
    background: var(--et-primary-container, #1a2437);
    color: #fff;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-ambient, 0 12px 32px -4px rgba(25, 28, 30, 0.12));
}
.fd-bulk-bar[hidden] { display: none; }
.fd-bulk-bar__count { font-size: 0.9375rem; }
.fd-bulk-bar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.free-drill-card__title {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--et-on-surface, #1a1c1e);
    /* Clamp to two lines so cards stay uniform. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.free-drill-card__category {
    margin-top: auto;
    align-self: flex-start;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.1875rem 0.5rem;
    border-radius: 999px;
    background: var(--et-surface-container-low, #f2f4f6);
    color: var(--et-on-surface-variant, #44474a);
}
