/*
 * The course catalog (`[turgee_courses]`) - a plain card grid.
 *
 * ITS OWN STYLESHEET, NOT course-page.css
 *
 * course-page.css is enqueued only on the four post types that carry
 * LearnDash's widget markup (course/lesson/topic/quiz), because that markup
 * only ever appears there. This shortcode is meant to go on ANY page - that
 * is the whole point of a shortcode - so it needs its own conditional
 * enqueue keyed on the shortcode actually being present, not on post type.
 *
 * INHERITS RATHER THAN DECLARES, same rule as course-page.css: no font
 * family, no font size, no colour on body text - only currentColor at
 * reduced opacity, so this reads correctly inside whatever theme it lands
 * in rather than looking like a plugin bolted on top of one.
 */

.tg-catalog {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
    padding: 0;
    list-style: none;
}

.tg-catalog__card {
    display: flex;
    flex-direction: column;
    border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
    border-radius: 6px;
    overflow: hidden;
}

.tg-catalog__link {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    text-decoration: none;
    color: inherit;
}

.tg-catalog__thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.tg-catalog__title {
    margin: 0.9rem 0.9rem 0.4rem;
    font-size: 1.05em;
}

.tg-catalog__excerpt {
    margin: 0 0.9rem 0.9rem;
    opacity: 0.75;
    font-size: 0.9em;
}

.tg-catalog__price {
    margin: 0 0.9rem 0.6rem;
    font-size: 0.9em;
}

.tg-catalog__price-original {
    text-decoration: line-through;
    opacity: 0.6;
}

.tg-catalog__price-offer {
    font-weight: 600;
}

.tg-catalog__cta {
    display: block;
    margin: 0 0.9rem 0.9rem;
    padding: 0.5rem 0.9rem;
    text-align: center;
    border: 1px solid currentColor;
    border-radius: 4px;
    text-decoration: none;
    color: inherit;
}

.tg-catalog__empty {
    opacity: 0.75;
}

@supports not (color: color-mix(in srgb, currentColor 12%, transparent)) {
    .tg-catalog__card {
        border-color: rgba(128, 128, 128, 0.2);
    }
}

/* ---------------------------------------------------------------
   Accent layer
   ---------------------------------------------------------------
   One accent colour, taken from the theme where it declares one.
   Resolution order:
     1. --tg-brand, set by a site owner on :root (or any ancestor)
     2. the theme's --wp--preset--color--primary
     3. Astra's or Kadence's primary colour, for themes that declare
        their palette under their own names
     4. a neutral blue
   To go back to the plain, colour-free look this stylesheet used to have,
   set  --tg-brand: currentColor;  on :root. :where() keeps every rule here
   at zero specificity so a theme or Customizer rule always wins. */

/* Values a site or add-on may set once on :root. Declared on :where(:root)
   (zero specificity) rather than on the containers below, so that a
   :root rule of any specificity overrides them instead of being shadowed. */

:where(:root) {
    --tg-ok: #1e8e3e;
    --tg-danger: #b3261e;
    --tg-radius: 10px;
}

:where(.tg-course-page, .tg-catalog, .tg-step-chrome, .tg-step-sticky, .tg-quiz, .tg-profile, .tg-locked) {
    --tg-accent: var(--tg-brand, var(--wp--preset--color--primary, var(--ast-global-color-0, var(--global-palette1, #2563eb))));
    --tg-on-accent: var(--tg-brand-contrast, #fff);
    /* An add-on can set --tg-font; unset, the theme's own font is kept. */
    font-family: var(--tg-font, inherit);
    /* For TEXT: pulled toward the theme's own text colour, so it keeps its
       contrast on a light theme and a dark one without detecting either. */
    --tg-accent-text: color-mix(in srgb, var(--tg-accent) 70%, currentColor);
    --tg-ok-text: color-mix(in srgb, var(--tg-ok) 65%, currentColor);
    --tg-danger-text: color-mix(in srgb, var(--tg-danger) 65%, currentColor);
}


/* Cards */

.tg-catalog__card {
	border-radius: 12px;
	background: color-mix(in srgb, currentColor 3%, transparent);
	transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.tg-catalog__card:hover,
.tg-catalog__card:focus-within {
	transform: translateY(-2px);
	border-color: color-mix(in srgb, var(--tg-accent) 55%, transparent);
	box-shadow: 0 8px 22px rgba(0, 0, 0, 0.1);
}

@media (prefers-reduced-motion: reduce) {
	.tg-catalog__card {
		transition: none;
	}

	.tg-catalog__card:hover,
	.tg-catalog__card:focus-within {
		transform: none;
	}
}

.tg-catalog__thumb {
	background: color-mix(in srgb, var(--tg-accent) 12%, transparent);
}

.tg-catalog__title {
	line-height: 1.3;
}

.tg-catalog__result {
	display: inline-block;
	padding: 0.1em 0.6em;
	border-radius: 999px;
	color: var(--tg-ok-text);
	background: color-mix(in srgb, var(--tg-ok) 14%, transparent);
	font-weight: 600;
}

.tg-catalog__cta {
	border: 0;
	border-radius: 8px;
	background: var(--tg-accent);
	color: var(--tg-on-accent);
	font-weight: 700;
	transition: filter 0.15s ease;
}

.tg-catalog__cta:hover,
.tg-catalog__cta:focus-visible {
	filter: brightness(1.1);
	color: var(--tg-on-accent);
}

.tg-catalog__link:focus-visible,
.tg-catalog__cta:focus-visible {
	outline: 2px solid var(--tg-accent);
	outline-offset: 2px;
}

.tg-catalog__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tg-catalog__chip {
    padding: 0.1em 0.65em;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
    font-size: 0.85em;
}

/* ---------------------------------------------------------------
   Themes that underline links
   ---------------------------------------------------------------
   Some themes underline every link inside post content with a rule like
   `.single .entry-content a` (two classes and an element). That outranks
   the plain resets above and puts an underline through buttons and tiles
   that are links only in markup. Repeating the reset with `body` in front
   wins over such rules without !important; hover underlines that are part
   of this design are restated at the same weight. */

body .tg-catalog a.tg-catalog__link,
body .tg-catalog a.tg-catalog__link:is(:hover, :focus-visible),
body .tg-catalog a.tg-catalog__cta,
body .tg-catalog a.tg-catalog__cta:is(:hover, :focus-visible) {
    text-decoration: none;
}
