/*
 * UIUX-008R — legacy public surfaces (bounded audit follow-up).
 *
 * Loaded only on 404, brand / ingredient detail and certification / diet
 * term pages (Assets::isLegacyConvergedRoute()), after the surfaces layer
 * and the story card. It composes the existing UIUX-008R system instead of
 * inventing one:
 *   - catalogue identity row scale (product-discovery-header, section C of
 *     uiux-008r-surfaces.css): H1 clamp(1.75rem, 2.6vw, 2.35rem), muted
 *     .9375rem description, count at the opposite side;
 *   - catalogue product grid: the /products/ column scheme at every width
 *     (1 column below 640px, 2 from 640px, auto-fill 15.25rem tracks with a
 *     1rem gap from 900px — 5 at 1440, 3 at 1024);
 *   - section headings at the shared 20–24px section scale, never larger
 *     than the page title;
 *   - one canonical gap after the results (no blank band before the
 *     page-end discovery).
 * The author archive uses the editorial family stylesheet unchanged.
 */

/* ---------------------------------------------------------------------
 * 1. Catalogue product grid (brand, ingredient, certification, diet)
 * ------------------------------------------------------------------- */
body:not(.aanya-admin) .term-product-archive__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

body:not(.aanya-admin) .term-product-archive__grid > li {
    min-width: 0;
    align-self: stretch;
}

body:not(.aanya-admin) .term-product-archive__grid .product-card {
    width: 100%;
    max-width: none;
    height: 100%;
    align-self: stretch;
}

@media (min-width: 640px) {
    body:not(.aanya-admin) .term-product-archive__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 900px) {
    body:not(.aanya-admin) .term-product-archive__grid {
        grid-template-columns: repeat(auto-fill, minmax(15.25rem, 1fr));
    }
}

/* The associated-product grid (brand / ingredient) pins its own track
   widths, gap and breakpoints with !important in
   components/product-card.css; the same catalogue scheme replaces them
   here with the same weight. */
body:not(.aanya-admin) .term-product-archive__grid.associated-product-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 1rem !important;
}

@media (min-width: 640px) {
    body:not(.aanya-admin) .term-product-archive__grid.associated-product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (min-width: 900px) {
    body:not(.aanya-admin) .term-product-archive__grid.associated-product-grid {
        grid-template-columns: repeat(auto-fill, minmax(15.25rem, 1fr)) !important;
    }
}

/* ---------------------------------------------------------------------
 * 2. Certification and diet term pages: catalogue identity row, one note
 *    stating what the label means, the grid, one canonical end gap.
 * ------------------------------------------------------------------- */
body:not(.aanya-admin) .term-product-archive {
    padding-bottom: clamp(2.5rem, 4vw, 3.5rem);
}

body:not(.aanya-admin) .term-product-archive .product-discovery-header {
    margin-bottom: .5rem;
}

/* Label names are long ("… (Fictional Demo)"): the title keeps its line
   and the description wraps beneath it instead of squeezing the H1 into
   three lines. */
body:not(.aanya-admin) .term-product-archive .product-discovery-header h1 {
    flex-shrink: 0;
    max-width: 100%;
}

body:not(.aanya-admin) .term-product-archive__note {
    max-width: 72ch;
    margin: 0 0 1.25rem;
    color: var(--u8r-muted);
    font-size: .875rem;
    line-height: 1.5;
}

body:not(.aanya-admin) .term-product-archive__note a {
    color: var(--u8r-ink);
    font-weight: 650;
    text-decoration: underline;
    text-underline-offset: .18em;
}

body:not(.aanya-admin) .term-product-archive :is(.pagination, .navigation.pagination) {
    margin: 1.5rem 0 0;
}

/* Empty state: the shared content-state, not a 42rem padded column. */
body:not(.aanya-admin) .term-product-archive :is(.certification-taxonomy__state, .diet-taxonomy__state) {
    max-width: none;
    padding: clamp(1.5rem, 4vw, 2.5rem);
}

body:not(.aanya-admin) .term-product-archive .aanya-content-state h2 {
    margin: 0 0 .5rem;
    font-size: clamp(1.25rem, 1.6vw, 1.5rem);
    line-height: 1.25;
}

body:not(.aanya-admin) .term-product-archive .aanya-content-state p {
    margin: 0;
}

body:not(.aanya-admin) .term-product-archive .aanya-content-state__actions {
    margin-top: 1rem;
}

/* ---------------------------------------------------------------------
 * 3. Brand and ingredient detail: compact entity identity row
 *    [logo / image] H1 · summary · facts ........ count (the type
 *    eyebrow stays hidden, as the catalogue row carries none)
 *    replaces the boxed hero; products follow at the section scale.
 * ------------------------------------------------------------------- */
body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) {
    padding-bottom: clamp(2.5rem, 4vw, 3.5rem);
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: .9rem;
    min-height: 0;
    margin: clamp(1rem, 2vw, 1.5rem) 0 1.25rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-hero--media {
    grid-template-columns: auto minmax(0, 1fr);
}

/* A real logo or ingredient image is an identity mark beside the name,
   not a hero panel. */
body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-hero img {
    width: 64px;
    height: 64px;
    max-height: none;
    padding: 6px;
    border: 1px solid var(--u8r-rule);
    border-radius: var(--u8r-radius-tile);
    background: #fff;
    box-shadow: none;
    object-fit: contain;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-hero > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 1rem;
    align-items: baseline;
    min-width: 0;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-hero > div > * {
    grid-column: 1;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-hero h1 {
    max-width: none;
    margin: 0;
    font-size: clamp(1.75rem, 2.6vw, 2.35rem);
    line-height: 1.1;
    letter-spacing: -.01em;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-hero .entity-hero__summary {
    max-width: 60ch;
    margin: .35rem 0 0;
    color: var(--u8r-muted);
    font-size: .9375rem;
    line-height: 1.45;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-hero .entity-result-count {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    margin: 0;
    color: var(--u8r-muted);
    font-size: .9375rem;
    font-weight: 620;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
}

/* Recorded facts: one quiet inline row, not a card lattice. */
body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-facts {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem 1.5rem;
    margin: .6rem 0 0;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-facts > div {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .15rem .45rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-facts dt {
    color: var(--u8r-muted);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-facts dd {
    margin: 0;
    color: var(--u8r-ink);
    font-size: .9375rem;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-facts a {
    color: var(--u8r-ink);
    text-decoration: underline;
    text-underline-offset: .18em;
}

/* Sections: open layout at the shared section scale (20–24px). */
body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-section {
    margin: 0;
    padding: 0 0 1.5rem;
    border: 0;
    border-radius: 0;
    background: transparent;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-section--products {
    padding-bottom: 0;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-section > h2,
body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-section__heading h2 {
    max-width: none;
    margin: 0 0 1rem;
    font-size: clamp(1.25rem, 1.6vw, 1.5rem);
    line-height: 1.25;
    letter-spacing: -.01em;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-section__heading {
    margin: 0;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .aanya-content-state h2 {
    margin: 0 0 .5rem;
    font-size: clamp(1.25rem, 1.6vw, 1.5rem);
    line-height: 1.25;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .aanya-content-state p {
    margin: 0;
}

body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .aanya-content-state__actions {
    margin-top: 1rem;
}

@media (max-width: 899px) {
    /* Stacked copy grows taller than the mark: keep the mark beside the name. */
    body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-hero--media {
        align-items: start;
    }

    body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-hero h1 {
        font-size: clamp(1.6rem, 7vw, 2rem);
    }

    body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-hero > div {
        grid-template-columns: minmax(0, 1fr);
    }

    body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-hero .entity-result-count {
        grid-column: 1;
        grid-row: auto;
        margin-top: .35rem;
    }
}

@media (max-width: 639px) {
    body:not(.aanya-admin) .entity-experience:is(.brand-detail, .ingredient-detail) .entity-hero img {
        width: 56px;
        height: 56px;
    }
}

/* ---------------------------------------------------------------------
 * 4. 404: one compact recovery surface (header search is the only
 *    search; H1 at the catalogue scale; primary + outline actions).
 * ------------------------------------------------------------------- */
body:not(.aanya-admin) .error-404 {
    padding: clamp(1.5rem, 4vw, 3rem) 0 clamp(2.5rem, 4vw, 3.5rem);
}

body:not(.aanya-admin) .error-404__panel {
    max-width: 45rem;
}

body:not(.aanya-admin) .error-404 h1 {
    margin: 0;
    font-size: clamp(1.75rem, 2.6vw, 2.35rem);
    line-height: 1.1;
    letter-spacing: -.01em;
}

body:not(.aanya-admin) .error-404__message {
    max-width: 60ch;
    margin: .6rem 0 0;
    color: var(--u8r-muted);
    font-size: 1rem;
    line-height: 1.55;
}

body:not(.aanya-admin) .error-404__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: 1.25rem;
}
