/* ===========================================================================
   ejercicios.css — the exercise catalogue: filter bar, card grid, and the two
   card variants (ours = screenshot, curated = terminal).

   Its own file, loaded only by custom-ejercicios.hbs and custom-ejercicio.hbs,
   for the same reason home-overrides.css exists: home.css stays byte-identical
   to the vendor template.

   Why not reuse Pubzi's .gt-gaming-card-item-5: that card hides the title and
   the whole content block until :hover (opacity 0 + bottom:-30px). Fine for a
   showreel of six things, wrong for a catalogue you scan and filter — and on
   touch there is no hover at all, so every card would read as a blank tile.
   The clipped corner and the gradient sweep are borrowed; the reveal is not.
   =========================================================================== */

/* Bootstrap supplies .visually-hidden and home-shell loads it, but this file
   is meant to survive being linked from the lean shell too, where it is absent
   and the search label would render as loose text. */
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Undo two vendor globals ---------------------------------------------
   Pubzi uppercases body copy and sets `p { margin: 0 }`. Uppercase is fine on
   an English esports headline and wrong for two paragraphs of Spanish prose:
   accented capitals read badly and the block turns into a wall. Same fix, and
   same reasoning, as the text-transform list in home-overrides.css.

   Scoped to this component rather than global — home.css is vendor and the
   homepage still wants the caps where it uses them. */
.ej-intro,
.ej-intro p,
.ej-shelf-head p,
.ej-excerpt,
.ej-temas li,
.ej-ext-meta,
.ej-ext-meta li,
.ej-empty,
.ej-empty p,
.ej-count,
.ej-detail-body,
.ej-detail-body p,
.ej-detail-body li,
.ej-detail-body blockquote {
    text-transform: none;
}
.ej-intro p,
.ej-detail-body p,
.ej-empty p:not(:last-child) { margin-bottom: 1.1em; }

/* --- Shell ----------------------------------------------------------------
   Top padding is left to Pubzi's .section-padding (120px). The site header is
   position:absolute and 90px tall, so anything that zeroes the top padding —
   `pt-0`, or a padding shorthand here — puts the breadcrumbs underneath it. */
.ej-page { padding-bottom: 100px; }
.ej-intro { max-width: 46rem; }
.ej-intro p { color: var(--text); line-height: 1.75; }

/* Clears the sticky site header when a shelf is reached by an anchor or by
   scrollIntoView, which otherwise parks the heading behind it. */
.ej-shelf { margin-top: 64px; scroll-margin-top: 120px; }
.ej-shelf-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: 30px;
}
.ej-shelf-head h2 {
    font-size: clamp(1.5rem, 3vw, 2.1rem);
    margin: 0;
}
.ej-shelf-head p { margin: 0; color: var(--text); font-size: 0.95rem; max-width: 34rem; }

/* --- Filter bar -----------------------------------------------------------
   Sticky so the facets stay reachable while scrolling a long grid. The offset
   clears the sticky site header (#header-sticky), which is ~90px tall once it
   condenses. */
.ej-filters {
    position: sticky;
    top: 92px;
    z-index: 5;
    background: rgba(11, 14, 19, 0.94);
    backdrop-filter: blur(8px);
    padding: 18px 0 16px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
@supports not (backdrop-filter: blur(8px)) {
    .ej-filters { background: var(--bg); }
}

.ej-search {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 420px;
    padding: 11px 16px;
    background: var(--bg-2);
    border: 1px solid rgba(255, 255, 255, 0.14);
    clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
}
.ej-search i { color: var(--text); font-size: 14px; }
.ej-search input {
    flex: 1;
    min-width: 0;
    background: none;
    border: 0;
    color: var(--white);
    font-family: inherit;
    font-size: 0.95rem;
}
.ej-search input::placeholder { color: var(--text); opacity: 0.8; }
.ej-search input:focus { outline: none; }
.ej-search:focus-within { border-color: var(--theme); }

.ej-facets { margin-top: 16px; display: grid; gap: 12px; }
.ej-facet-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.ej-facet-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--text);
    min-width: 62px;
}

.ej-chip {
    font: inherit;
    font-size: 0.86rem;
    line-height: 1;
    padding: 9px 15px;
    color: var(--white);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
    clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
}
.ej-chip:hover { border-color: var(--theme); color: var(--theme); }
.ej-chip[aria-pressed="true"] {
    background: var(--theme);
    border-color: var(--theme);
    color: var(--header);
    font-weight: 600;
}
.ej-chip:focus-visible { outline: 2px solid var(--theme); outline-offset: 3px; }

.ej-filter-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 14px;
}
.ej-count { font-size: 0.9rem; color: var(--text); margin: 0; }
.ej-count b { color: var(--white); font-weight: 600; }
.ej-reset {
    font: inherit;
    font-size: 0.86rem;
    background: none;
    border: 0;
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    padding: 4px;
}
.ej-reset:hover { color: var(--theme); }
.ej-reset[hidden] { display: none; }

/* --- Grid ----------------------------------------------------------------- */
.ej-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
    gap: 26px;
    margin-top: 26px;
}
.ej-card.is-out { display: none; }

/* --- Card: ours ----------------------------------------------------------- */
.ej-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--bg-2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: border-color 0.3s ease, transform 0.3s ease;
    clip-path: polygon(22px 0, 100% 0, 100% calc(100% - 22px), calc(100% - 22px) 100%, 0 100%, 0 22px);
}
.ej-card:hover { border-color: var(--theme); transform: translateY(-4px); }
.ej-card:focus-within { border-color: var(--theme); }

.ej-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--header);
}
.ej-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}
.ej-card:hover .ej-thumb img { transform: scale(1.05); }

/* No screenshot yet: a generated tile rather than a broken image or a stock
   photo of someone else's game. The exercise number carries it. */
.ej-thumb-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background:
        radial-gradient(120% 90% at 15% 0%, rgba(203, 254, 28, 0.16) 0%, transparent 60%),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 2px, transparent 2px 9px),
        var(--header);
}
.ej-thumb-fallback span {
    font-family: "Days One", sans-serif;
    font-size: 3.4rem;
    line-height: 1;
    color: rgba(255, 255, 255, 0.16);
    letter-spacing: -0.03em;
}

.ej-nivel {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 2;
    font-size: 0.72rem;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    padding: 5px 10px;
    background: rgba(11, 14, 19, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: var(--white);
}
.ej-nivel[data-nivel="hash-nivel-1"] { border-color: #6ee7a8; color: #6ee7a8; }
.ej-nivel[data-nivel="hash-nivel-2"] { border-color: var(--theme); color: var(--theme); }
.ej-nivel[data-nivel="hash-nivel-3"] { border-color: #ff8a5c; color: #ff8a5c; }

.ej-body { padding: 20px 22px 22px; display: flex; flex-direction: column; flex: 1; }
.ej-title { font-size: 1.15rem; line-height: 1.3; margin: 0 0 10px; }
.ej-title a {
    color: var(--white);
    text-decoration: none;
}
.ej-title a::after { content: ""; position: absolute; inset: 0; }
.ej-card:hover .ej-title a { color: var(--theme); }
.ej-excerpt { font-size: 0.92rem; line-height: 1.6; color: var(--text); margin: 0 0 16px; }

.ej-temas { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 16px; padding: 0; list-style: none; }
.ej-temas li {
    font-size: 0.74rem;
    letter-spacing: 0.4px;
    padding: 4px 9px;
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

/* Pushed to the bottom so cards of different copy length still line up. */
.ej-actions {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.86rem;
}
/* Above the ::after stretched link, or these are unclickable. */
.ej-actions a { position: relative; z-index: 1; color: var(--theme); text-decoration: none; }
.ej-actions a:hover { text-decoration: underline; text-underline-offset: 3px; }
.ej-actions .ej-muted { color: var(--text); }

/* --- Card: curated -------------------------------------------------------
   Deliberately a different object. These leave the site, they are other
   people's work, and most are in English — the terminal treatment says so
   before anyone reads the label. */
.ej-card-ext {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 40%),
        var(--header);
}
.ej-ext-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px 0;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.82rem;
    color: var(--text);
}
.ej-ext-head i { color: var(--theme); font-size: 1rem; }
.ej-ext-repo { overflow-wrap: anywhere; }
/* Stacked, not wrapped: with flex-wrap the language chip and the two text
   lines break differently on every card depending on how long the license
   string is, and the shelf reads as ragged. */
.ej-ext-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
    font-size: 0.76rem;
    color: var(--text);
}
.ej-ext-meta li { display: flex; align-items: center; gap: 5px; }
.ej-ext-meta .ej-warn { color: #ff8a5c; }
.ej-lang {
    font-size: 0.72rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 3px 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--text);
}

/* --- Empty state ---------------------------------------------------------- */
.ej-empty {
    grid-column: 1 / -1;
    padding: 54px 30px;
    text-align: center;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    color: var(--text);
}
.ej-empty p { margin: 0 0 8px; }
.ej-empty a { color: var(--theme); }
.ej-empty[hidden] { display: none; }

/* --- Exercise detail page ------------------------------------------------- */
.ej-detail { padding-bottom: 90px; }
.ej-detail-head { max-width: 48rem; }
.ej-detail-title { font-size: clamp(1.9rem, 4vw, 3rem); line-height: 1.1; margin: 0 0 16px; }
.ej-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 0 0 26px;
    padding: 0;
    list-style: none;
}
.ej-detail-meta li {
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    padding: 5px 11px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--text);
}
.ej-detail-meta .ej-nivel-inline { border-color: var(--theme); color: var(--theme); }

.ej-links { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 40px; }
.ej-links .gt-theme-btn { margin: 0; }

.ej-detail-body { max-width: 48rem; font-size: 1.05rem; line-height: 1.8; }
.ej-detail-body h2 {
    font-size: 1.45rem;
    margin: 42px 0 14px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.ej-detail-body h3 { font-size: 1.12rem; margin: 26px 0 10px; }
/* Pubzi strips list markers globally (its lists are all nav). In an exercise
   the bullets carry meaning — these are the things you have to build. */
.ej-detail-body ul { list-style: disc; }
.ej-detail-body ol { list-style: decimal; }
.ej-detail-body ul, .ej-detail-body ol { padding-left: 1.3em; margin: 0 0 20px; }
.ej-detail-body li::marker { color: var(--theme); }
.ej-detail-body li { margin-bottom: 9px; }
.ej-detail-body a { color: var(--theme); }
.ej-detail-body pre {
    background: var(--bg-2);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 18px 20px;
    overflow-x: auto;
    font-size: 0.92rem;
    line-height: 1.6;
}
.ej-detail-body code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.ej-detail-body :not(pre) > code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    font-size: 0.9em;
}
.ej-detail-body blockquote {
    margin: 26px 0;
    padding: 4px 0 4px 22px;
    border-left: 3px solid var(--theme);
    color: var(--text);
}

/* --- Motion --------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .ej-card,
    .ej-thumb img { transition: none; }
    .ej-card:hover { transform: none; }
    .ej-card:hover .ej-thumb img { transform: none; }
}

/* --- Small screens -------------------------------------------------------- */
@media (max-width: 767px) {
    /* The header is not sticky on mobile in this theme, and a sticky filter
       bar on a short viewport eats the grid. */
    .ej-filters { position: static; padding-top: 0; }
    .ej-grid { grid-template-columns: 1fr; gap: 20px; }
    .ej-facet-label { min-width: 100%; }
}
