/* ================================================
   Communities Browse Page (/show-communities) - communities.css
   Layout: LOR-style sidebar (current category + switcher) + card grid.
   Look: icrepo mockup (2026-10) - light line-pattern background, dark
   "glass" panels (same values as the search-result items, no
   backdrop-filter), beige heading bar.
   Requirements: WCAG 2.2 AA + responsive.
   ================================================ */

/* ---- Tokens ---- */
.communities-page {
    --cm-orange: #e07b30;
    --cm-beige:  #E5C3A1;
    --cm-beige-alt: #F0DAC2;
    --cm-ink: #3b3633;                          /* page text on the cream bg (~11:1) */
    --cm-ink-dark: #1f1f1f;
    --cm-bg: #fdf5ec;

    /* Glass = search results .resultsSearchTable td, without blur.
       White text on it over the cream bg is ~6:1. */
    --cm-glass-bg: rgba(0, 0, 0, 0.55);
    --cm-glass-bg-alt: rgba(0, 0, 0, 0.55);
    --cm-glass-border: 1.5px solid rgba(255, 255, 255, 0.3);
    --cm-glass-shadow: -6px 8px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    --cm-glass-radius: 14px;
    --cm-shadow-soft: -3px 3px 6px rgba(0, 0, 0, 0.35);
    /* Inner shadow on card / sidebar images (mockup). Drawn by ::after over
       the image: an inset box-shadow on <img> itself, or on a wrapper the
       image covers, is painted UNDER the picture and never shows. */
    --cm-img-inset: inset 0px 0px 10px 3px rgba(0, 0, 0, 0.55);
}

[hidden] { display: none !important; }

/* ---- Page background: line pattern on cream ----
   Scrolls with the page; fixed only on large screens with a real pointer
   (background-attachment: fixed is janky / ignored on iOS and touch). */
#page_content {
    background: #fdf5ec url('../../image/home/new-icreate-imgs/communities_bgr.jpg') center top / cover no-repeat;
    /* WebP (~28 KB) where image-set() with type() is supported, else the JPG
       above (~100 KB): browsers that don't understand this line drop it. */
    background-image: image-set(url('../../image/home/new-icreate-imgs/communities_bgr.webp') type("image/webp"), url('../../image/home/new-icreate-imgs/communities_bgr.jpg') type("image/jpeg"));
}
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
    #page_content { background-attachment: fixed; }
}

#inner_content,
#inner_content.wrap {
    width: 100% !important;
    max-width: none !important;
    display: block !important;
    background-color: transparent !important;
    /* side inset of the breadcrumb, the page head and the content: --page-inset (stylesUGCnew.css) */
    padding: 0 var(--page-inset);
    box-sizing: border-box;
}

.wrap { background-color: transparent; }

/* ---- Page wrapper ---- */
.communities-page {
    padding: 0 0 clamp(32px, 4vw, 64px);
    box-sizing: border-box;
    color: var(--cm-ink);
}

/* Breadcrumb (layout/location-bar.jsp) sits above the page: dark on cream,
   starting at the inset like the title */
p.locationBar {
    margin-left: 0;
    margin-right: 0;
}

.locationBar,
.locationBar a {
    color: #3b3633 !important;
    text-shadow: none !important;
}
.locationBar a {
    text-decoration: none;
    /* underline as an inset shadow: a border made the breadcrumb row 1px taller than on the other pages */
    box-shadow: inset 0 -1px 0 transparent;
    transition: box-shadow 0.2s;
}
.locationBar a:hover {
    box-shadow: inset 0 -1px 0 currentColor;
}

/* ---- Header row: title + view toggle (layout: .page-head in stylesUGCnew.css) ---- */
.communities-title {
    font-weight: 700;
    color: var(--cm-ink);
}

/* ================================================
   Two-column layout
   ================================================ */
.cm-layout {
    display: grid;
    grid-template-columns: minmax(220px, 360px) minmax(0, 1fr);
    gap: clamp(16px, 2vw, 32px);
    align-items: start;
}

/* ---- Sidebar ---- */
.cm-sidebar {
    position: sticky;
    top: 56px;                                  /* below the fixed #sticky-topbar */
    max-height: calc(100vh - 72px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 0 6px 12px 24px;                      /* keep panels off the scrollbar, room for shadows */
    scrollbar-gutter: stable;

    scrollbar-width: thin;
    scrollbar-color: var(--cm-orange) rgba(0, 0, 0, 0.1);
}

.cm-sidebar::-webkit-scrollbar { width: 8px; }
.cm-sidebar::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); border-radius: 8px; }
.cm-sidebar::-webkit-scrollbar-thumb { background: var(--cm-orange); border-radius: 8px; }

/* Glass panels */
.cm-current,
.cm-switcher-nav,
.cm-card-link,
.cm-sub-btn {
    background: var(--cm-glass-bg);
    border: var(--cm-glass-border);
    box-shadow: var(--cm-glass-shadow);
    color: #fff;
}
.cm-current,
.cm-switcher-nav,
.cm-sub-btn {
    background: var(--cm-glass-bg-alt);
    border: var(--cm-glass-border);
    box-shadow: var(--cm-glass-shadow);
    color: #fff;
}
/* Current category: image + title */
.cm-current {
    border-radius: var(--cm-glass-radius);
    padding: 14px;
}

.cm-current-thumb {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 14px;
    background: #fff;
}

.cm-current-img {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 2;                        /* category images are 3:2 (600x400) - shown whole */
    object-fit: cover;
}

/* Placeholder logo (category without an image): whole, not cropped */
.cm-current-img.is-default {
    object-fit: contain;
    padding: 8%;
    box-sizing: border-box;
}

.cm-current-title {
    margin: 0 0 4px;
    font-size: clamp(17px, 1.4vw, 21px);
    font-weight: 700;
    line-height: 1.3;
    text-align: left;
    color: #fff;
    overflow-wrap: anywhere;
    hyphens: auto;
}

.cm-current-intro {
    margin: 8px 0 0;
    font-size: 14px;
    line-height: 1.5;
    color: #fff;
}

/* Category switcher */
.cm-switcher-nav {
    border-radius: var(--cm-glass-radius);
    padding: 14px 10px;
}

.cm-switcher-title {
    margin: 0 0 8px;
    padding: 0 8px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #fff;
}

.cm-switcher {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cm-switch-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 8px 10px 8px 12px;
    border-radius: 8px;
    color: #fff !important;
    text-decoration: none !important;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.3;
    transition: background 0.15s;
}

.cm-switch-link:hover {
    background: rgba(255, 255, 255, 0.12);
}

.cm-switch-link:hover .cm-switch-name {
    text-decoration: underline;
}

.cm-switch-name {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
    hyphens: auto;
}

/* Category title split into lines (set by setTitleLines in communities.jsp) */
.cm-title-line {
    display: block;
}

/* Number of collections in the category */
.cm-switch-count {
    flex: 0 0 auto;
    min-width: 32px;
    padding: 5px 6px;
    box-sizing: border-box;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.4;
    text-align: center;
}

/* Active category: darker block + orange edge (not colour alone: also aria-current) */
.cm-switch-item.is-active .cm-switch-link {
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.cm-switch-item.is-active .cm-switch-count {
    background: rgba(255, 255, 255, 0.22);
}

/* ================================================
   Main area
   ================================================ */
.cm-main {
    min-width: 0;
}

/* Beige heading bar above the grid */
.cm-heading {
    margin: 0 0 clamp(16px, 1.6vw, 24px);
    padding: 10px 18px;
    background: var(--cm-beige-alt);
    border-radius: 6px;
    box-shadow: var(--cm-shadow-soft);
    font-size: clamp(16px, 1.3vw, 19px);
    font-weight: 700;
    color: var(--cm-ink-dark);
    overflow-wrap: anywhere;
    hyphens: auto;
}

.cm-heading:focus {
    outline: none;                              /* programmatic focus target only */
}

.cm-message {
    margin: 0 0 16px;
    padding: 12px 16px;
    background: var(--cm-beige);
    border-radius: 6px;
    color: var(--cm-ink-dark);
}

/* ---- Cards grid ----
   With the sidebar (>= 900px): 3 / 4 / 5 columns, keeping cards >= ~185px wide.
   Without it (< 900px): auto-fill from 190px; one column on phones (<= 480px). */
.cm-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: clamp(20px, 2vw, 32px) clamp(12px, 1.5vw, 24px);
}

@media (max-width: 1600px) {
  .cm-layout { grid-template-columns: minmax(220px, 320px) minmax(0, 1fr); }
  .cm-switch-link { font-size: 15px; }
}
@media (min-width: 2000px) {
    .cm-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (min-width: 1300px) and (max-width: 1999px) {
    .cm-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1000px) and (max-width: 1299px) {
    .cm-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 900px) and (max-width: 999px) {
    .cm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 888px) and (max-width: 899px) {
    .cm-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.cm-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Card = glass panel with an inset image and the title */
.cm-card-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;                                 /* above its tab */
    top: 0;
    padding: 16px 16px 10px;
    border-radius: var(--cm-glass-radius);
    color: #fff !important;
    text-decoration: none !important;
    transition: top 0.2s, background 0.2s;
}

.cm-card-link:hover {
    background: rgba(0, 0, 0, 0.7);
}

.cm-card-link:hover .cm-card-title {
    text-decoration: underline;
}

/* Fixed 4:3 frame; the image is absolute so its own ratio never stretches it */
.cm-card-thumb {
    display: block;
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #fff;
    border-radius: 6px;
}

.cm-card-img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.cm-card-thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: var(--cm-img-inset);
    pointer-events: none;
}

.cm-card-img.is-default {
    object-fit: contain;
    padding: 12%;
    box-sizing: border-box;
}

.cm-card-title {
    display: block;
    padding: 12px 4px 4px;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.35;
    text-align: center;
    overflow-wrap: anywhere;
    hyphens: auto;
}

/* "Subcollections N" = tab hanging under the card (separate link) */
.cm-sub-btn {
    display: flex;
    flex-wrap: wrap;                            /* narrow cards: count drops under the label, never mid-word breaks */
    align-items: center;
    justify-content: center;
    gap: 4px 10px;
    min-height: 48px;
    margin: 0 7%;
    padding: 6px 10px;
    box-sizing: border-box;
    border-top: 0;
    border-radius: 0;
    color: #fff !important;
    font-size: clamp(14px, 1.3vw, 17px);
    font-weight: 400;
    text-decoration: none !important;
    transition: background 0.15s;
}

.cm-sub-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.cm-sub-btn:hover .cm-sub-label {
    text-decoration: underline;
}

/* 2x2 tiles icon (decorative, CSS-drawn) */
.cm-sub-icon {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(2, 11px);
    grid-auto-rows: 7px;
    gap: 3px;
}
.cm-sub-icon i {
    display: block;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 1px;
}

.cm-sub-label {
    white-space: nowrap;
}

.cm-sub-count {
    flex: 0 0 auto;
    min-width: 32px;
    padding: 4px 6px;
    box-sizing: border-box;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 16px;
    line-height: 1.4;
    text-align: center;
}

/* ================================================
   Loading skeleton (server-rendered, aria-hidden; JS replaces it).
   The real loading text is in #cmMessage (role=status, sr-only).
   ================================================ */
.cm-skel {
    display: block;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.16);
    animation: cm-skel-pulse 1.2s ease-in-out infinite alternate;
}

@keyframes cm-skel-pulse {
    from { opacity: 1; }
    to   { opacity: 0.45; }
}

.cm-skel-line {
    height: 12px;
    width: 85%;
    margin: 10px auto 0;
}
.cm-skel-short { width: 55%; }

.cm-skel-img {
    aspect-ratio: 3 / 2;
    border-radius: 8px;
    margin-bottom: 14px;
}
.cm-skel-current .cm-skel-line { height: 16px; }

.cm-skel-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 8px 10px 8px 12px;
}
.cm-skel-item .cm-skel-line {
    flex: 1;
    margin: 0;
}
.cm-skel-count {
    flex: 0 0 auto;
    width: 32px;
    height: 28px;
}

.cm-skel-card {
    pointer-events: none;
}
.cm-skel-card .cm-card-link {
    min-height: 0;
    padding-bottom: 18px;
}
.cm-skel-card .cm-card-thumb::after {
    box-shadow: none;
}
.cm-skel-card .cm-sub-btn .cm-skel-line {
    width: 60%;
    margin: 0;
}

/* Heading bar keeps its height while empty */
.cm-heading:empty::before {
    content: "";
    display: block;
    height: 1.3em;
    width: 45%;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.08);
}

/* ================================================
   Responsive
   ================================================ */

.cm-drawer-toggle,
.cm-drawer-close,
.cm-drawer-backdrop {
    display: none;
}

/* Tablet / mobile: sidebar = off-canvas drawer from the left (JS: openDrawer) */
@media (max-width: 899px) {
    .cm-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Button that opens the drawer: "Ενότητες" with a layers icon (not ☰: next to
       the ≡ list icon and the header hamburger it would look the same). Left,
       under the title; the current category is in the heading below it.
       Same button logic as the view toggle (--sw-* in stylesUGCnew.css). */
    .cm-drawer-toggle {
        display: flex;
        align-items: center;
        gap: 10px;
        width: fit-content;
        min-height: 44px;
        margin: 0 0 14px;
        padding: 6px 16px;
        border: 0;
        border-radius: 8px;
        background: var(--sw-btn-bg);
        box-shadow: none;
        color: #fff;
        font: inherit;
        font-size: 15px;
        font-weight: 700;
        text-align: left;
        cursor: pointer;
        position: relative;
        top: 0;
        transition: background 0.15s, top 0.15s;
    }
    .cm-drawer-toggle:hover {
        background: var(--sw-btn-hover-bg);
        top: -2px;
    }
    .cm-drawer-toggle[aria-expanded="true"] {
        background: var(--sw-selected-bg-alt);
        box-shadow: var(--sw-selected-shadow);
    }
    .cm-drawer-toggle-icon {
        flex: 0 0 auto;
        font-size: 17px;
    }
    .cm-drawer-toggle-label {
        flex: 0 0 auto;
    }

    /* The sidebar as an off-canvas panel: same cream + pattern as the page */
    .cm-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 2001;
        width: min(85vw, 360px);
        max-height: none;
        padding: 12px 12px 24px;
        box-sizing: border-box;
        background: #f6ece0 url('../../image/home/new-icreate-imgs/communities_bgr.jpg') left top / 720px auto repeat-y;
        background-image: image-set(url('../../image/home/new-icreate-imgs/communities_bgr.webp') type("image/webp"), url('../../image/home/new-icreate-imgs/communities_bgr.jpg') type("image/jpeg"));
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
        overflow-y: auto;
        overscroll-behavior: contain;
        transform: translateX(-105%);
        visibility: hidden;                     /* closed = not focusable / not read */
        transition: transform 0.25s ease, visibility 0s linear 0.25s;
    }
    .cm-sidebar.is-open {
        transform: none;
        visibility: visible;
        transition: transform 0.25s ease, visibility 0s;
    }

    .cm-drawer-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        align-self: flex-end;
        flex: 0 0 auto;
        width: 44px;
        height: 44px;
        padding: 0;
        border: var(--cm-glass-border);
        border-radius: 8px;
        background: var(--cm-glass-bg);
        color: #fff;
        font-size: 28px;
        line-height: 1;
        cursor: pointer;
    }

    .cm-drawer-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 2000;
        background: rgba(0, 0, 0, 0.55);
    }
    .cm-drawer-backdrop[hidden] { display: none !important; }

    html.cm-drawer-lock,
    html.cm-drawer-lock body {
        overflow: hidden;
    }

    /* #page_content (z-index 1) is a stacking context below #header (z-index 2):
       while the drawer is open, lift it over the site header and sticky bar. */
    html.cm-drawer-lock #page_content {
        z-index: 3000;
    }

    .cm-current {
        display: grid;
        grid-template-columns: 96px minmax(0, 1fr);
        column-gap: 14px;
        align-items: center;
    }
    .cm-current[hidden] { display: none !important; }
    .cm-current-thumb {
        grid-row: 1 / span 2;
        margin: 0;
    }
    .cm-current-img {
        aspect-ratio: 3 / 2;
    }
    .cm-skel-current .cm-skel-img {
        grid-row: 1 / span 2;
        aspect-ratio: 3 / 2;
        margin: 0;
    }
    .cm-current-title {
        text-align: left;
        font-size: 17px;
    }
}

/* Icon only where the tab has room for icon + label + count */
@media (max-width: 1799px) and (min-width: 900px), (max-width: 640px) and (min-width: 481px) {
    .cm-sub-icon { display: none; }
}

@media (max-width: 480px) {
    .cm-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    .cm-sidebar,
    .cm-sidebar.is-open,
    .cm-card-link,
    .cm-sub-btn,
    .cm-drawer-toggle {
        transition: none;
    }
    .cm-card-link:hover,
    .cm-drawer-toggle:hover {
        top: 0;
    }
    .cm-skel {
        animation: none;
    }
}

/* Windows High Contrast / forced colours: keep panel edges visible */
@media (forced-colors: active) {
    .cm-card-thumb::after {
        box-shadow: none;
    }
    .cm-current,
    .cm-switcher-nav,
    .cm-card-link,
    .cm-sub-btn,
    .cm-heading {
        border: 1px solid CanvasText;
    }
    .cm-switch-item.is-active .cm-switch-link {
        outline: 2px solid Highlight;
    }
}
