/* ============================================================
   Browse Series — archive grid
   Path: /wp-content/themes/jormuntl/assets/css/archive-grid.css

   ------------------------------------------------------------
   THEMING
   ------------------------------------------------------------
   Every colour in this file resolves through a --jarc-* token. Nothing below
   the token blocks contains a literal colour, so retuning the whole page — or
   adding a third theme — means editing one block, never hunting through rules.

   Dark is the default. Light is applied by any of:
     - the OS preference, when the site hasn't forced a theme
     - an explicit light marker on <html> or <body>

   I don't know which convention your theme uses, so the light selector list
   covers the common ones. DELETE THE LINES THAT DON'T APPLY to keep the
   selector cheap — matching a 10-part list on every element is wasted work.

   ------------------------------------------------------------
   CONTRAST NOTE
   ------------------------------------------------------------
   White on #ff077b is 3.77:1, under the 4.5:1 AA floor for normal-size text.
   It's the default because it's what the colour wants visually. To pass AA,
   swap --jarc-on-accent to the commented value in BOTH token blocks; the
   near-black reads 5.6:1 on the same pink.
   ============================================================ */

.jarc {
    color-scheme: dark;

    /* --- Brand --- */
    --jarc-accent:      #ff077b;
    --jarc-accent-h:    #ff3d96;
    --jarc-accent-soft: rgba(255, 7, 123, .16);
    --jarc-accent-text: #ff8ab8;

    /* White = 3.77:1. Swap to #2b0011 for 5.6:1 and AA compliance. */
    --jarc-on-accent:   #ffffff;

    /* --- Panel --- */
    --jarc-panel-from: #3a0a24;
    --jarc-panel-to:   #24061a;
    --jarc-panel-radius: 16px;

    /* --- Surfaces --- */
    --jarc-card:      #1a1018;
    --jarc-cover-bg:  #251823;
    --jarc-pop:       #221420;
    --jarc-control:   rgba(0, 0, 0, .26);
    --jarc-control-h: rgba(0, 0, 0, .40);
    --jarc-control-border: transparent;
    --jarc-pill:      #2a1d25;
    --jarc-pill-h:    #3a2833;
    --jarc-pill-text: rgba(255, 255, 255, .62);

    /* --- Text --- */
    --jarc-text:   #ffffff;
    --jarc-text-2: rgba(255, 255, 255, .62);
    --jarc-text-3: rgba(255, 255, 255, .40);

    /* --- Lines, hovers, depth --- */
    --jarc-line:  rgba(255, 255, 255, .10);
    --jarc-hover: rgba(255, 255, 255, .06);
    --jarc-scroll: rgba(255, 255, 255, .16);
    --jarc-shadow:     0 14px 32px rgba(0, 0, 0, .45);
    --jarc-shadow-pop: 0 18px 44px rgba(0, 0, 0, .55);

    --jarc-star: #fbbf24;

    --jarc-gap: 18px;
}

/* ------------------------------------------------------------
   LIGHT — OS preference, only when the site hasn't forced dark
   ------------------------------------------------------------ */
@media (prefers-color-scheme: light) {
    html:not([data-theme="dark"]):not(.dark):not(.dark-mode):not(.is-dark) .jarc:not([data-theme="dark"]) {
        color-scheme: light;

        --jarc-accent:      #ff077b;
        --jarc-accent-h:    #e0006b;
        --jarc-accent-soft: rgba(255, 7, 123, .10);
        --jarc-accent-text: #c1005c;   /* 6.1:1 on white */
        --jarc-on-accent:   #ffffff;   /* see contrast note; #2b0011 for AA */

        --jarc-panel-from: #ffe9f2;
        --jarc-panel-to:   #ffdbe9;

        --jarc-card:      #ffffff;
        --jarc-cover-bg:  #f3ecf0;
        --jarc-pop:       #ffffff;
        --jarc-control:   rgba(255, 255, 255, .72);
        --jarc-control-h: #ffffff;
        --jarc-control-border: rgba(26, 16, 23, .10);
        --jarc-pill:      #f4eef1;
        --jarc-pill-h:    #e9dfe5;
        --jarc-pill-text: rgba(26, 16, 23, .66);

        --jarc-text:   #1a1017;
        --jarc-text-2: rgba(26, 16, 23, .66);
        --jarc-text-3: rgba(26, 16, 23, .46);

        --jarc-line:  rgba(26, 16, 23, .12);
        --jarc-hover: rgba(26, 16, 23, .05);
        --jarc-scroll: rgba(26, 16, 23, .20);
        --jarc-shadow:     0 12px 28px rgba(26, 16, 23, .12);
        --jarc-shadow-pop: 0 16px 40px rgba(26, 16, 23, .18);
    }
}

/* ------------------------------------------------------------
   LIGHT — explicit marker. Keep only the selector your theme uses.
   ------------------------------------------------------------ */
html[data-theme="light"] .jarc,
html[data-color-scheme="light"] .jarc,
html.light .jarc,
html.light-mode .jarc,
html.is-light .jarc,
body[data-theme="light"] .jarc,
body.light .jarc,
body.light-mode .jarc,
.jarc[data-theme="light"] {
    color-scheme: light;

    --jarc-accent:      #ff077b;
    --jarc-accent-h:    #e0006b;
    --jarc-accent-soft: rgba(255, 7, 123, .10);
    --jarc-accent-text: #c1005c;
    --jarc-on-accent:   #ffffff;

    --jarc-panel-from: #ffe9f2;
    --jarc-panel-to:   #ffdbe9;

    --jarc-card:      #ffffff;
    --jarc-cover-bg:  #f3ecf0;
    --jarc-pop:       #ffffff;
    --jarc-control:   rgba(255, 255, 255, .72);
    --jarc-control-h: #ffffff;
    --jarc-control-border: rgba(26, 16, 23, .10);
    --jarc-pill:      #f4eef1;
    --jarc-pill-h:    #e9dfe5;
    --jarc-pill-text: rgba(26, 16, 23, .66);

    --jarc-text:   #1a1017;
    --jarc-text-2: rgba(26, 16, 23, .66);
    --jarc-text-3: rgba(26, 16, 23, .46);

    --jarc-line:  rgba(26, 16, 23, .12);
    --jarc-hover: rgba(26, 16, 23, .05);
    --jarc-scroll: rgba(26, 16, 23, .20);
    --jarc-shadow:     0 12px 28px rgba(26, 16, 23, .12);
    --jarc-shadow-pop: 0 16px 40px rgba(26, 16, 23, .18);
}

/* ------------------------------------------------------------
   DARK — explicit marker, so a site-wide light default can still
   force this section dark.
   ------------------------------------------------------------ */
html[data-theme="dark"] .jarc,
html.dark .jarc,
html.dark-mode .jarc,
body[data-theme="dark"] .jarc,
body.dark .jarc,
body.dark-mode .jarc,
.jarc[data-theme="dark"] {
    color-scheme: dark;

    --jarc-accent:      #ff077b;
    --jarc-accent-h:    #ff3d96;
    --jarc-accent-soft: rgba(255, 7, 123, .16);
    --jarc-accent-text: #ff8ab8;
    --jarc-on-accent:   #ffffff;

    --jarc-panel-from: #3a0a24;
    --jarc-panel-to:   #24061a;

    --jarc-card:      #1a1018;
    --jarc-cover-bg:  #251823;
    --jarc-pop:       #221420;
    --jarc-control:   rgba(0, 0, 0, .26);
    --jarc-control-h: rgba(0, 0, 0, .40);
    --jarc-control-border: transparent;
    --jarc-pill:      #2a1d25;
    --jarc-pill-h:    #3a2833;
    --jarc-pill-text: rgba(255, 255, 255, .62);

    --jarc-text:   #ffffff;
    --jarc-text-2: rgba(255, 255, 255, .62);
    --jarc-text-3: rgba(255, 255, 255, .40);

    --jarc-line:  rgba(255, 255, 255, .10);
    --jarc-hover: rgba(255, 255, 255, .06);
    --jarc-scroll: rgba(255, 255, 255, .16);
    --jarc-shadow:     0 14px 32px rgba(0, 0, 0, .45);
    --jarc-shadow-pop: 0 18px 44px rgba(0, 0, 0, .55);
}

/* ============================================================
   PANEL
   ============================================================ */

.jarc-panel {
    background: linear-gradient(160deg, var(--jarc-panel-from), var(--jarc-panel-to));
    border-radius: var(--jarc-panel-radius);
    padding: 26px 28px 24px;
    margin-bottom: 28px;
}

.jarc-panel-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.jarc-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}
.jarc-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--jarc-text);
    margin: 0;
    line-height: 1.1;
}
.jarc-count {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 10px;
    border-radius: 7px;
    background: var(--jarc-accent);
    color: var(--jarc-on-accent);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

/* ---------- Search ---------- */

.jarc-search {
    position: relative;
    flex: 0 1 340px;
    min-width: 220px;
}
.jarc-search svg {
    position: absolute;
    left: 14px; top: 50%;
    width: 16px; height: 16px;
    transform: translateY(-50%);
    color: var(--jarc-text-3);
    pointer-events: none;
}
.jarc-search input {
    width: 100%;
    height: 46px;
    padding: 0 16px 0 40px;
    border-radius: 10px;
    border: 1px solid var(--jarc-control-border);
    background: var(--jarc-control);
    color: var(--jarc-text);
    font-size: 14.5px;
    outline: none;
    transition: background .15s, border-color .15s;
}
.jarc-search input::placeholder { color: var(--jarc-text-3); }
.jarc-search input:hover { background: var(--jarc-control-h); }
.jarc-search input:focus { background: var(--jarc-control-h); border-color: var(--jarc-accent); }

/* ---------- Filter row ---------- */

.jarc-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.jarc-dd { position: relative; }

.jarc-dd-btn,
.jarc-toggle {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 46px;
    padding: 0 18px;
    border-radius: 10px;
    border: 1px solid var(--jarc-control-border);
    background: var(--jarc-control);
    color: var(--jarc-text);
    font-size: 14.5px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
    font-family: inherit;
}
.jarc-dd-btn:hover,
.jarc-toggle:hover { background: var(--jarc-control-h); }

.jarc-dd-btn svg,
.jarc-toggle svg { width: 16px; height: 16px; flex-shrink: 0; }

.jarc-dd-btn .jarc-chev { transition: transform .18s ease; opacity: .7; }
.jarc-dd.is-open .jarc-dd-btn { background: var(--jarc-control-h); border-color: var(--jarc-line); }
.jarc-dd.is-open .jarc-chev { transform: rotate(180deg); }

.jarc-dd-btn.is-active,
.jarc-toggle.is-active {
    background: var(--jarc-accent);
    border-color: transparent;
    color: var(--jarc-on-accent);
}
.jarc-dd-btn.is-active:hover,
.jarc-toggle.is-active:hover { background: var(--jarc-accent-h); }

.jarc-dd-value {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Dropdown panel ---------- */

.jarc-dd-panel {
    position: absolute;
    z-index: 60;
    top: calc(100% + 8px);
    left: 0;
    width: 280px;
    background: var(--jarc-pop);
    border: 1px solid var(--jarc-line);
    border-radius: 12px;
    box-shadow: var(--jarc-shadow-pop);
    overflow: hidden;
}
.jarc-dd-panel[hidden] { display: none; }

/* Flip to the right edge when the button sits near the viewport edge. */
.jarc-dd-panel.is-right { left: auto; right: 0; }

.jarc-dd-search {
    padding: 10px;
    border-bottom: 1px solid var(--jarc-line);
}
.jarc-dd-search input {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--jarc-line);
    background: var(--jarc-hover);
    color: var(--jarc-text);
    font-size: 13.5px;
    outline: none;
}
.jarc-dd-search input::placeholder { color: var(--jarc-text-3); }
.jarc-dd-search input:focus { border-color: var(--jarc-accent); }

.jarc-dd-options {
    max-height: 264px;
    overflow-y: auto;
    padding: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--jarc-scroll) transparent;
}
.jarc-dd-options::-webkit-scrollbar { width: 6px; }
.jarc-dd-options::-webkit-scrollbar-thumb { background: var(--jarc-scroll); border-radius: 3px; }

.jarc-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--jarc-text);
    transition: background .12s;
}
.jarc-opt:hover { background: var(--jarc-hover); }
.jarc-opt.is-hidden { display: none; }
.jarc-opt input {
    accent-color: var(--jarc-accent);
    width: 15px; height: 15px;
    flex-shrink: 0;
    cursor: pointer;
}
.jarc-opt-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jarc-opt-count { color: var(--jarc-text-3); font-size: 12.5px; }

.jarc-dd-actions {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--jarc-line);
}
.jarc-dd-actions button {
    flex: 1;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--jarc-line);
    background: transparent;
    color: var(--jarc-text-2);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, color .15s;
}
.jarc-dd-actions button:hover { background: var(--jarc-hover); color: var(--jarc-text); }
.jarc-dd-actions button[data-act="apply"] {
    background: var(--jarc-accent);
    border-color: transparent;
    color: var(--jarc-on-accent);
}
.jarc-dd-actions button[data-act="apply"]:hover { background: var(--jarc-accent-h); }

.jarc-dd-empty {
    padding: 18px 12px;
    text-align: center;
    color: var(--jarc-text-3);
    font-size: 13.5px;
}

/* ============================================================
   ACTIVE FILTER CHIPS
   ============================================================ */

.jarc-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 22px;
}
.jarc-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    background: var(--jarc-accent-soft);
    border: 1px solid var(--jarc-accent-soft);
    color: var(--jarc-accent-text);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.jarc-chip:hover {
    background: var(--jarc-accent);
    border-color: transparent;
    color: var(--jarc-on-accent);
}
.jarc-chip svg { width: 12px; height: 12px; opacity: .8; }
.jarc-chip-clear {
    background: transparent;
    border-color: var(--jarc-line);
    color: var(--jarc-text-2);
}
.jarc-chip-clear:hover { background: var(--jarc-hover); border-color: var(--jarc-line); color: var(--jarc-text); }

/* ============================================================
   GRID
   ============================================================ */

.jarc-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: var(--jarc-gap);
}
@media (max-width: 1279px) { .jarc-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1023px) { .jarc-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px)  { .jarc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); --jarc-gap: 12px; } }

.jarc-grid.hide-bookmarked .jarc-card[data-bookmarked="1"] { display: none; }

/* ---------- Card ---------- */

.jarc-card {
    background: var(--jarc-card);
    border: 1px solid var(--jarc-control-border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .18s ease, box-shadow .18s ease;
    /* Off-screen cards skip layout until scrolled near. */
    content-visibility: auto;
    contain-intrinsic-size: auto 520px;
}
.jarc-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--jarc-shadow);
}

.jarc-cover {
    position: relative;
    display: block;
    aspect-ratio: 3 / 4;
    background: var(--jarc-cover-bg);
    overflow: hidden;
}
.jarc-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .35s ease;
}
.jarc-card:hover .jarc-cover img { transform: scale(1.04); }

/* Sits on artwork in both modes, so it stays dark either way. */
.jarc-rating {
    position: absolute;
    top: 8px; right: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 24px;
    padding: 0 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, .72);
    backdrop-filter: blur(3px);
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1;
}
.jarc-rating svg { width: 12px; height: 12px; color: var(--jarc-star); }

.jarc-body {
    padding: 12px 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.jarc-name {
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--jarc-text);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color .15s;
}
.jarc-name:hover { color: var(--jarc-accent-text); }

.jarc-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.jarc-tag {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 9px;
    border-radius: 6px;
    background: var(--jarc-pill);
    color: var(--jarc-pill-text);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.jarc-tag-status {
    background: var(--jarc-accent-soft);
    color: var(--jarc-accent-text);
}
a.jarc-tag:hover { color: var(--jarc-text); }

.jarc-bookmark {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 42px;
    border: none;
    border-radius: 9px;
    background: var(--jarc-accent);
    color: var(--jarc-on-accent);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, color .15s;
}
.jarc-bookmark:hover { background: var(--jarc-accent-h); }
.jarc-bookmark svg { width: 16px; height: 16px; }

/* Already bookmarked reads as a quiet, secondary state. */
.jarc-bookmark[data-is-favorite="1"] {
    background: var(--jarc-pill);
    color: var(--jarc-pill-text);
}
.jarc-bookmark[data-is-favorite="1"]:hover { background: var(--jarc-pill-h); color: var(--jarc-text); }
.jarc-bookmark[data-is-favorite="1"] svg { fill: currentColor; }

/* ============================================================
   LOAD MORE + EMPTY
   ============================================================ */

.jarc-more { display: flex; justify-content: center; margin-top: 34px; }
.jarc-more button {
    height: 48px;
    padding: 0 30px;
    border: none;
    border-radius: 10px;
    background: var(--jarc-accent);
    color: var(--jarc-on-accent);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, opacity .15s;
}
.jarc-more button:hover { background: var(--jarc-accent-h); }
.jarc-more button[disabled] { opacity: .55; cursor: default; }

.jarc-empty {
    text-align: center;
    padding: 72px 20px;
    color: var(--jarc-text-2);
}
.jarc-empty h2 { color: var(--jarc-text); font-size: 20px; font-weight: 700; margin: 14px 0 8px; }
.jarc-empty p { margin-bottom: 24px; }
.jarc-empty a {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 10px;
    background: var(--jarc-accent);
    color: var(--jarc-on-accent);
    font-weight: 600;
    text-decoration: none;
}
.jarc-empty a:hover { background: var(--jarc-accent-h); }

/* ============================================================
   ACCESSIBILITY
   ============================================================ */

.jarc :focus-visible {
    outline: 2px solid var(--jarc-accent);
    outline-offset: 2px;
}

.screen-reader-text {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    .jarc-card,
    .jarc-cover img,
    .jarc-chev { transition: none; }
    .jarc-card:hover { transform: none; }
    .jarc-card:hover .jarc-cover img { transform: none; }
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 700px) {
    .jarc-panel { padding: 20px 16px; border-radius: 12px; }
    .jarc-title { font-size: 21px; }
    .jarc-search { flex-basis: 100%; }
    .jarc-filters { gap: 8px; }
    .jarc-dd-btn, .jarc-toggle { height: 42px; padding: 0 14px; font-size: 13.5px; }
    /* Keep panels inside the viewport instead of overflowing it. */
    .jarc-dd-panel { width: min(280px, calc(100vw - 40px)); }
}