/* Visit Maramureș — Biblioteca digitală V2 / B4.8.9
   Component-only layout and presentation. Shared Design System tokens are the
   single source of truth for fonts, colors and interactive control appearance.
   Load only when the Digital Library module renders.
*/

/* Scoped library presentation, derived from B4.8.7 LIVE-validated styles.
   The page-wide heading background is intentionally absent. */
.digital-library {
    width: 100%;
    min-width: 0;
    color: var(--frontend-design-color-text, #1C2520);
    font-family: var(--type-font-body, var(--frontend-design-font-body, "Manrope", Arial, sans-serif));
    font-size: var(--type-body-size, 1rem);
    line-height: var(--type-body-line-height, 1.7);
    container-type: inline-size;
}
.digital-library *,
.digital-library *::before,
.digital-library *::after { box-sizing: border-box; }
.digital-library[id^="digital-library-"] { scroll-margin-top: 112px; }

/* Toolbar — established Catalog V2 surface and pill anatomy. */
.digital-library .digital-library__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    margin: 0 0 25px;
    padding: clamp(14px, 2.3cqi, 24px);
    border: 1px solid var(--frontend-design-color-border, #DED8CC);
    border-radius: 18px;
    background: var(--frontend-design-color-surface, #FFFFFF);
    box-shadow: 0 9px 28px rgba(23, 32, 25, .045);
}
.digital-library__tabs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}
.digital-library .digital-library__tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 9px 15px;
    border: 1px solid var(--frontend-design-color-border, #DED8CC);
    border-radius: 999px;
    background: var(--frontend-design-color-background, #F7F4ED);
    color: var(--frontend-design-color-text, #1C2520);
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.digital-library .digital-library__tab:hover {
    border-color: var(--frontend-design-color-brand, #174936);
    background: var(--frontend-design-color-surface-muted, #F1ECE2);
    color: var(--frontend-design-color-brand, #174936);
    text-decoration: none;
}
.digital-library .digital-library__tab[aria-current="page"] {
    border-color: var(--frontend-design-color-brand, #174936);
    background: var(--frontend-design-color-brand, #174936);
    color: #FFFFFF;
}
.digital-library .digital-library__tab[aria-current="page"]:hover {
    border-color: var(--frontend-design-color-brand-dark, #0D3327);
    background: var(--frontend-design-color-brand-dark, #0D3327);
    color: #FFFFFF;
}
.digital-library__search {
    display: flex;
    align-items: stretch;
    gap: 10px;
    flex: 1 1 260px;
    max-width: 410px;
    margin: 0;
}
.digital-library .digital-library__search input {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 10px 13px;
    border: 1px solid var(--frontend-design-color-border, #DED8CC);
    border-radius: 10px;
    background: var(--frontend-design-color-surface, #FFFFFF);
    color: var(--frontend-design-color-text, #1C2520);
    font: inherit;
    font-size: .88rem;
    line-height: 1.35;
}
.digital-library .digital-library__search input::placeholder {
    color: var(--frontend-design-color-text-muted, #667069);
    opacity: 1;
}
.digital-library .digital-library__search button,
.digital-library .digital-library__reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    max-width: 100%;
    padding: 10px 17px;
    border: 1px solid var(--frontend-design-color-brand, #174936);
    border-radius: 10px;
    background: var(--frontend-design-color-brand, #174936);
    color: #FFFFFF;
    font-family: var(--frontend-design-button-font-family, var(--type-font-body, "Manrope", Arial, sans-serif));
    font-size: .87rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 160ms ease, border-color 160ms ease;
}
.digital-library .digital-library__search button:hover,
.digital-library .digital-library__reset:hover {
    border-color: var(--frontend-design-color-brand-dark, #0D3327);
    background: var(--frontend-design-color-brand-dark, #0D3327);
    color: #FFFFFF;
}
.digital-library__status {
    margin: 0 0 26px;
    color: var(--frontend-design-color-text-muted, #667069);
    font-size: .86rem;
    line-height: 1.6;
}

/* Section heading — parity with Event Catalog V2 heading structure.
   The icon and h3 are separate direct grid children, as in Catalog.
   The count stays outside h3: it is metadata, not heading text.
   No white title background, no local typography overrides. */
.digital-library__section {
    min-width: 0;
    margin: 0 0 clamp(34px, 4cqi, 54px);
    scroll-margin-top: 112px;
}
.digital-library .digital-library__section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin: 0 0 18px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}
.digital-library__section-heading {
    display: flex;
    flex: 1 1 auto;
    align-items: flex-end;
    flex-wrap: wrap;
    column-gap: 10px;
    row-gap: 4px;
    min-width: 0;
}
.digital-library__heading-copy {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    column-gap: clamp(12px, 1.5cqi, 18px);
    row-gap: 8px;
    align-items: end;
    min-width: 0;
}
.digital-library__heading-icon {
    display: inline-flex;
    grid-column: 1;
    grid-row: 1;
    align-self: end;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    border: 1px solid var(--frontend-design-color-border, #ded8cc);
    border-radius: 12px;
    background: var(--frontend-design-color-surface-muted, #f1ece2);
    color: var(--editorial-eyebrow-color, #8e4a3a);
    font-size: 18px;
    line-height: 1;
}
.digital-library .digital-library__heading {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    margin: 0;
    color: var(--color-text, #192923);
    font-family: var(--type-font-heading, var(--frontend-design-font-heading, "Source Serif 4", Georgia, serif));
    font-size: var(--type-h3-desktop-size, 1.75rem);
    font-weight: var(--type-h2-weight, 700);
    line-height: var(--type-h2-line-height, 1.2);
    letter-spacing: var(--type-h3-letter-spacing, normal);
    text-wrap: balance;
    overflow-wrap: break-word;
}
.digital-library__count {
    align-self: flex-end;
    margin-bottom: 3px;
    color: var(--frontend-design-color-text-muted, #667069);
    font-family: var(--type-font-body, "Manrope", Arial, sans-serif);
    font-size: .77rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}
.digital-library .digital-library__view-all {
    color: var(--frontend-design-color-brand, #174936);
    font-family: var(--type-font-body, "Manrope", Arial, sans-serif);
    font-size: .85rem;
    font-weight: 700;
    line-height: 1.4;
    text-decoration: none;
}
.digital-library .digital-library__view-all:hover {
    color: var(--frontend-design-color-brand-dark, #0D3327);
    text-decoration: underline;
}

/* Cards — shared Design System surfaces and typography. */
.digital-library__grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}
.digital-library__card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--frontend-design-color-border, #DED8CC);
    border-radius: 14px;
    background: var(--frontend-design-color-surface, #FFFFFF);
    box-shadow: 0 4px 18px rgba(23, 32, 25, .05);
}
.digital-library__media {
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: var(--frontend-design-color-surface-muted, #F1ECE2);
}
.digital-library__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.digital-library__media-icon {
    color: var(--frontend-design-color-brand, #174936);
    font-size: 38px;
    line-height: 1;
}
.digital-library__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
    padding: 14px 15px 16px;
}
.digital-library .digital-library__card-title {
    margin: 0;
    color: var(--frontend-design-color-heading, #132A22);
    font-family: var(--type-font-body, var(--frontend-design-font-body, "Manrope", Arial, sans-serif));
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    overflow-wrap: anywhere;
}
.digital-library__description {
    margin: 0;
    color: var(--frontend-design-color-text-muted, #667069);
    font-size: .84rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}
.digital-library__type {
    margin-top: auto;
    padding-top: 5px;
    color: var(--frontend-design-color-brand, #174936);
    font-size: .76rem;
    font-weight: 700;
}

/* BD-04.13 — Lightbox-only galleries must not add vertical space after cards.
   The slider stays in the DOM for shared JS, but is not part of layout.
   Scope applies only to gallery components with the opt-in hidden slider;
   normal accommodation galleries are unaffected. */
.digital-library .media-gallery:has(> .media-gallery-slider[hidden]) {
    display: contents;
}
.digital-library .media-gallery-slider[hidden] {
    display: none !important;
}

/* Empty-state — reused visual contract from Catalog V2. */
.digital-library__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 176px;
    padding: clamp(24px, 4cqi, 42px);
    border: 1px dashed var(--frontend-design-color-border, #DED8CC);
    border-radius: 16px;
    background: var(--frontend-design-color-background, #F7F4ED);
    color: var(--frontend-design-color-text-muted, #667069);
    font-size: .94rem;
    line-height: 1.65;
    text-align: center;
}
.digital-library__empty-symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--frontend-design-color-brand, #174936);
    font-size: 26px;
    line-height: 1;
}
.digital-library__empty p { margin: 0; }
.digital-library__pagination { margin-top: 22px; }

/* Terms note — neutral, platform-owned palette; no blue callout. */
.digital-library__info {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-top: 6px;
    padding: 20px 22px;
    border: 1px solid var(--frontend-design-color-border, #DED8CC);
    border-radius: 14px;
    background: var(--frontend-design-color-surface-muted, #F1ECE2);
    color: var(--frontend-design-color-text, #1C2520);
}
.digital-library__info-icon {
    flex: 0 0 auto;
    color: var(--frontend-design-color-brand, #174936);
    font-size: 26px;
    line-height: 1;
}
.digital-library__info strong {
    color: var(--frontend-design-color-heading, #132A22);
    font-family: var(--type-font-heading, "Source Serif 4", Georgia, serif);
    font-size: 1.1rem;
    line-height: 1.35;
}
.digital-library__info p {
    margin: 6px 0 0;
    color: var(--frontend-design-color-text-muted, #667069);
    font-size: .87rem;
    line-height: 1.65;
}

.digital-library :is(a, button, input, summary):focus-visible {
    outline: 3px solid var(--frontend-design-color-accent, #B88A3B);
    outline-offset: 3px;
}
/* The typography and icon collapse at the same container widths as Catalog V2. */
@container (max-width: 820px) {
    .digital-library .digital-library__heading {
        font-size: var(--type-h3-tablet-size, var(--type-h3-desktop-size, 1.5rem));
    }
}
@container (max-width: 520px) {
    .digital-library__heading-copy {
        grid-template-columns: 36px minmax(0, 1fr);
    }
    .digital-library__heading-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    .digital-library .digital-library__heading {
        font-size: var(--type-h3-mobile-size, 1.35rem);
    }
}
/* Fallback for browsers lacking CSS container queries, as in Catalog V2. */
@supports not (container-type: inline-size) {
    @media (max-width: 767px) {
        .digital-library__heading-copy { grid-template-columns: 36px minmax(0, 1fr); }
        .digital-library__heading-icon { width: 36px; height: 36px; font-size: 16px; }
        .digital-library .digital-library__heading { font-size: var(--type-h3-mobile-size, 1.35rem); }
    }
}
@container (max-width: 1050px) {
    .digital-library__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container (max-width: 730px) {
    .digital-library__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .digital-library__search { max-width: none; }
    .digital-library .digital-library__toolbar { align-items: stretch; }
}
@container (max-width: 460px) {
    .digital-library__grid { grid-template-columns: minmax(0, 1fr); }
    .digital-library .digital-library__toolbar { padding: 12px; }
    .digital-library__tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
    .digital-library .digital-library__tab { padding: 9px 8px; font-size: .78rem; }
    .digital-library__section-head { align-items: flex-start; }
    .digital-library__info { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
    .digital-library .digital-library__tab,
    .digital-library .digital-library__search button { transition: none; }
}

/* BD-03.5 — player video personalizat și dialog YouTube; stiluri scoped. */
.digital-library__video-launch {
    position: relative; display: block; width: 100%; aspect-ratio: 16 / 9;
    overflow: hidden; background: #111; color: #fff; text-decoration: none;
}
.digital-library__video-launch img {
    display: block; width: 100%; height: 100%; object-fit: cover;
}
.digital-library__video-play {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    display: grid; place-items: center; width: 64px; height: 64px;
    border-radius: 50%; background: rgba(255,255,255,.20);
    border: 2px solid rgba(255,255,255,.95); color: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,.35); transition: background-color .18s, transform .18s;
    pointer-events: none; font-size: 23px;
}
.digital-library__video-play i { margin-left: 4px; }
.digital-library__video-launch:hover .digital-library__video-play,
.digital-library__video-launch:focus-visible .digital-library__video-play {
    background: rgba(255,255,255,.36); transform: translate(-50%, -50%) scale(1.06);
}
.digital-library__video-launch:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }
.digital-library__video-dialog {
    position: fixed; inset: 0; width: min(1100px, calc(100vw - 32px));
    max-width: none; max-height: calc(100vh - 32px); margin: auto; padding: 0;
    border: 0; border-radius: 12px; background: #0c1014; overflow: visible;
    box-shadow: 0 20px 70px rgba(0,0,0,.55); color: #fff;
}
.digital-library__video-dialog::backdrop { background: rgba(0,0,0,.82); }
.digital-library__video-dialog-inner { position: relative; }
.digital-library__video-frame { width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 12px; }
.digital-library__video-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.digital-library__video-close {
    position: absolute; right: 0; top: -45px; display: grid; place-items: center;
    width: 38px; height: 38px; padding: 0; border: 1px solid rgba(255,255,255,.6);
    border-radius: 50%; background: #18222b; color: #fff; cursor: pointer;
    font-size: 20px; z-index: 1;
}
.digital-library__video-close:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
@media (max-width: 600px) {
    .digital-library__video-play { width: 54px; height: 54px; font-size: 19px; }
    .digital-library__video-dialog { width: calc(100vw - 16px); }
}
@media (prefers-reduced-motion: reduce) {
    .digital-library__video-play { transition: none; }
}
