/* ============================================================
   LEGISLATIVE LIBRARY  —  "Municipal Records Register"
   Flat civic styling for the public legislative-library page.
   Scoped under `.legislative-library-page` so it can't leak
   into other interior pages. Loads after pages.css (header),
   so selectors are kept specific enough to win the cascade.
   ============================================================ */

.legislative-library-page {
    --ll-green-deep: #0d351f;
    --ll-green: #14532d;
    --ll-green-mid: #1f7a3d;
    --ll-amber: #f08a24;
    --ll-amber-dark: #cf6d09;
    --ll-gold: #ffc72c;
    --ll-ink: #1c2b22;
    --ll-muted: #5c6b62;
    --ll-line: rgba(20, 83, 45, .16);
    --ll-r-sm: 6px;

    background: #ffffff;
    color: var(--ll-ink);
}

.legislative-library-page .ll-hidden {
    display: none !important;
}

/* ============================================================
   Shell
   ============================================================ */
.legislative-library-page .ll-main {
    width: min(1120px, calc(100% - 32px));
    margin: 28px auto 52px;
}

.legislative-library-page .ll-shell {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ============================================================
   Hero — flat chamber-green docket field
   ============================================================ */
.legislative-library-page .ll-hero {
    position: relative;
    background: var(--ll-green-deep);
    border-radius: var(--ll-r-sm);
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}

.legislative-library-page .ll-hero__rule {
    height: 4px;
    background: linear-gradient(90deg, var(--ll-gold) 0 40%, var(--ll-amber) 40% 100%);
}

.legislative-library-page .ll-hero__grille {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(90deg,
            rgba(255, 255, 255, .045) 0 2px,
            transparent 2px 26px);
    pointer-events: none;
}

.legislative-library-page .ll-hero__body {
    position: relative;
    padding: clamp(22px, 3.6vw, 42px);
}

.legislative-library-page .ll-hero__eyebrow {
    display: block;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: #ffd97a;
}

.legislative-library-page .ll-hero__title {
    margin: .4rem 0 .5rem;
    font-size: clamp(1.75rem, 4.6vw, 2.7rem);
    line-height: 1.06;
    font-weight: 800;
    letter-spacing: -.015em;
    color: #ffffff;
    text-wrap: balance;
}

.legislative-library-page .ll-hero__subtitle {
    margin: 0;
    max-width: 720px;
    color: rgba(240, 246, 242, .82);
    line-height: 1.65;
    font-size: .96rem;
}

.legislative-library-page .ll-hero__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.legislative-library-page .ll-hero__meta-item {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .88);
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: var(--ll-r-sm);
}

.legislative-library-page .ll-hero__meta-item strong {
    color: #ffd97a;
    font-weight: 800;
    margin-right: 5px;
}

/* ============================================================
   Filter bar — flat white card overrides (shared .policy-filters)
   ============================================================ */
.legislative-library-page .policy-filters {
    background: #ffffff;
    border: 1px solid var(--ll-line);
    border-radius: var(--ll-r-sm);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
    padding: 16px 18px;
}

.legislative-library-page .pf-search input {
    border-radius: 4px;
    border: 1px solid #d8ddd9;
    background: #ffffff;
    box-shadow: none;
}

.legislative-library-page .pf-search input:focus {
    border-color: var(--ll-amber);
    box-shadow: 0 0 0 3px rgba(240, 138, 36, .14);
    background: #ffffff;
}

.legislative-library-page .pf-group select {
    border-radius: 4px;
    border: 1px solid #d8ddd9;
    background: #ffffff;
    box-shadow: none;
}

.legislative-library-page .pf-group select:hover {
    border-color: #b9c2bc;
    background: #ffffff;
}

.legislative-library-page .pf-group select:focus {
    border-color: var(--ll-amber);
    box-shadow: 0 0 0 3px rgba(240, 138, 36, .14);
    background: #ffffff;
}

.legislative-library-page .pf-label {
    color: var(--ll-muted);
}

.legislative-library-page .pf-search-icon {
    color: #8a958e;
}

.legislative-library-page .pf-mobile-toggle {
    border-radius: 4px;
    border: 1px solid #d8ddd9;
    color: #374151;
}

/* ============================================================
   Table — civic register
   ============================================================ */
.legislative-library-page .ll-table-wrap {
    position: relative;
    background: #ffffff;
    border: 1px solid var(--ll-line);
    border-radius: var(--ll-r-sm);
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}

.legislative-library-page .ll-table-wrap::before {
    content: '';
    display: block;
    height: 3px;
    background: linear-gradient(90deg,
            var(--ll-green-mid) 0 55%,
            var(--ll-amber) 55% 85%,
            var(--ll-gold) 85% 100%);
}

.legislative-library-page .ll-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
    color: #243028;
}

.legislative-library-page .ll-table thead th {
    background: var(--ll-green);
    color: #ffffff;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    text-align: left;
    padding: 12px 12px;
    border-bottom: 3px solid var(--ll-gold);
    white-space: nowrap;
}

.legislative-library-page .ll-table thead th.ll-sort {
    cursor: pointer;
    user-select: none;
}

.legislative-library-page .ll-table thead th.ll-sort:hover {
    background: var(--ll-green-deep);
}

.legislative-library-page .ll-table thead th.ll-sort::after {
    content: '\2195';
    margin-left: 6px;
    font-size: .75em;
    opacity: .5;
}

.legislative-library-page .ll-table thead th.ll-sort[aria-sort="asc"]::after {
    content: '\2191';
    opacity: 1;
}

.legislative-library-page .ll-table thead th.ll-sort[aria-sort="desc"]::after {
    content: '\2193';
    opacity: 1;
}

.legislative-library-page .ll-table tbody td {
    padding: 13px 14px;
    border-top: 1px solid rgba(20, 83, 45, .08);
    vertical-align: top;
    white-space: normal;
    overflow-wrap: break-word;
}

/* Column widths via <colgroup> — standard table mechanics, no fixed layout */
.legislative-library-page .ll-col-document { width: 18%; min-width: 180px; }
.legislative-library-page .ll-col-title { width: 34%; min-width: 250px; }
.legislative-library-page .ll-col-author { width: 11%; min-width: 120px; }
.legislative-library-page .ll-col-type { width: 13%; min-width: 140px; }
.legislative-library-page .ll-col-category { width: 9%; min-width: 100px; }
.legislative-library-page .ll-col-approved { width: 8%; min-width: 100px; }
.legislative-library-page .ll-col-attachments { width: 7%; min-width: 90px; }

.legislative-library-page .ll-table tbody tr:nth-child(even) td {
    background: #fafafa;
}

.legislative-library-page .ll-table tbody tr:hover td {
    background: #f1f5f9;
}

/* Document number (docket) */
.legislative-library-page .ll-doc-link,
.legislative-library-page .ll-doc-no {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
}

.legislative-library-page .ll-doc-link {
    color: var(--ll-green);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color .18s ease, border-color .18s ease;
}

.legislative-library-page .ll-doc-link:hover {
    color: var(--ll-amber-dark);
    border-bottom-color: var(--ll-amber-dark);
}

.legislative-library-page .ll-doc-no {
    color: #9aa3a0;
}

.legislative-library-page .ll-cell-title {
    color: var(--ll-ink);
    font-weight: 600;
    line-height: 1.45;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Type chip */
.legislative-library-page .ll-type-chip {
    display: inline-block;
    padding: 3px 9px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
    border: 1px solid rgba(75, 85, 99, .28);
    border-radius: 3px;
    color: #4b5563;
    background: rgba(75, 85, 99, .05);
}

.legislative-library-page .ll-type-chip--ordinance {
    color: var(--ll-green);
    border-color: rgba(20, 83, 45, .35);
    background: rgba(20, 83, 45, .06);
}

.legislative-library-page .ll-type-chip--resolution {
    color: var(--ll-amber-dark);
    border-color: rgba(207, 109, 9, .4);
    background: rgba(240, 138, 36, .08);
}

/* File link */
.legislative-library-page .ll-file-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ll-green);
    text-decoration: none;
    border: 1px solid rgba(20, 83, 45, .25);
    border-radius: 3px;
    white-space: nowrap;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}

.legislative-library-page .ll-file-link:hover {
    background: rgba(20, 83, 45, .08);
    border-color: rgba(20, 83, 45, .45);
    color: var(--ll-green-deep);
}

.legislative-library-page .ll-file-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.legislative-library-page .ll-file-none {
    color: #9aa3a0;
    font-size: .8rem;
}

/* Column visibility helpers (used by page JS) */
.legislative-library-page .column-author {
    display: none;
}

.legislative-library-page .column-author.is-shown {
    display: table-cell;
}

/* ============================================================
   Empty state
   ============================================================ */
.legislative-library-page .ll-empty {
    text-align: center;
    padding: 44px 20px;
}

.legislative-library-page .ll-empty__title {
    margin: 0 0 16px;
    color: #4b5563;
    font-size: .95rem;
}

.legislative-library-page .ll-empty__reset {
    display: inline-flex;
    align-items: center;
    padding: 9px 18px;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--ll-green);
    text-decoration: none;
    border: 1px solid rgba(20, 83, 45, .3);
    border-radius: var(--ll-r-sm);
    transition: background-color .18s ease, color .18s ease;
}

.legislative-library-page .ll-empty__reset:hover {
    background: rgba(20, 83, 45, .08);
    color: var(--ll-green-deep);
}

/* ============================================================
   Pagination — flat, squared
   ============================================================ */
.legislative-library-page .ll-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 12px;
    border-top: 1px solid var(--ll-line);
}

.legislative-library-page .ll-page-link {
    min-width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--ll-ink);
    text-decoration: none;
    background: #ffffff;
    border: 1px solid rgba(20, 83, 45, .22);
    border-radius: var(--ll-r-sm);
    transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}

.legislative-library-page .ll-page-link:hover {
    background: rgba(20, 83, 45, .06);
    border-color: rgba(20, 83, 45, .45);
}

.legislative-library-page .ll-page-link--active,
.legislative-library-page .ll-page-link--active:hover {
    background: var(--ll-green);
    border-color: var(--ll-green);
    color: #ffffff;
}

.legislative-library-page .ll-page-ellipsis {
    padding: 0 2px;
    color: #9aa3a0;
}

/* ============================================================
   Document actions dropdown
   ============================================================ */
.doc-actions-dropdown {
    position: fixed;
    z-index: 10000;
    min-width: 190px;
    max-width: 240px;
    background: #ffffff;
    border: 1px solid rgba(20, 83, 45, .18);
    border-radius: 6px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .16);
    padding: 8px;
    display: none;
}

.doc-actions-dropdown.active {
    display: block;
}

.doc-actions-title {
    margin: 0 0 6px;
    padding: 4px 6px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #6b7280;
}

.doc-actions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
}

.doc-action-btn {
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 9px 10px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--ll-ink);
    background: #ffffff;
    cursor: pointer;
    text-align: left;
    transition: background-color .15s ease, border-color .15s ease;
}

.doc-action-btn:hover:not(:disabled) {
    border-color: rgba(20, 83, 45, .2);
    background: rgba(20, 83, 45, .05);
    color: var(--ll-green-deep);
}

.doc-action-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

/* ============================================================
   Book / PDF viewer modal — flat civic
   ============================================================ */
.book-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(6, 20, 12, .78);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility .3s ease;
}

.book-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.book-modal-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 96vw;
    max-height: 96vh;
    transform: scale(.96) translateY(10px);
    transition: transform .3s ease;
}

.book-modal-overlay.active .book-modal-shell {
    transform: scale(1) translateY(0);
}

.book-cover-wrap {
    background: var(--ll-green-deep);
    border-radius: 6px;
    padding: 10px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}

.book-cover-wrap::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: var(--ll-gold);
    z-index: 2;
}

.book-flipbook {
    background: #f5f5f5;
    border-radius: 3px;
    box-shadow: inset 0 0 24px rgba(0, 0, 0, .12);
    overflow: visible;
    position: relative;
    cursor: grab;
    user-select: none;
    touch-action: pan-y;
}

.book-flipbook:active {
    cursor: grabbing;
}

.book-flipbook::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, transparent,
            rgba(0, 0, 0, .12) 20%,
            rgba(0, 0, 0, .16) 50%,
            rgba(0, 0, 0, .12) 80%,
            transparent);
    pointer-events: none;
    z-index: 5;
}

.book-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 14px;
    user-select: none;
}

.book-controls button {
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(13, 53, 31, .25);
    border-radius: 4px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ll-green-deep);
    font-size: 19px;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}

.book-controls button:hover:not(:disabled) {
    background: var(--ll-green);
    border-color: var(--ll-green);
    color: #ffffff;
}

.book-controls button:disabled {
    opacity: .35;
    cursor: default;
}

.book-page-info {
    color: #eaf3ee;
    font-size: .82rem;
    font-weight: 600;
    letter-spacing: .02em;
    min-width: 120px;
    text-align: center;
}

.book-close-btn {
    position: absolute;
    top: -16px;
    right: -16px;
    z-index: 10;
    background: #ffffff;
    border: 1px solid rgba(13, 53, 31, .2);
    border-radius: 4px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #374151;
    transition: background-color .18s ease, color .18s ease;
}

.book-close-btn:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #ffffff;
}

.book-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(246, 243, 236, .94);
    z-index: 10;
    border-radius: 3px;
}

.book-loading.hidden {
    display: none;
}

.book-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(13, 53, 31, .15);
    border-top-color: var(--ll-green);
    border-radius: 50%;
    animation: ll-book-spin .8s linear infinite;
}

@keyframes ll-book-spin {
    to {
        transform: rotate(360deg);
    }
}

.book-loading span {
    margin-top: 12px;
    font-size: .82rem;
    color: #4b5563;
    font-weight: 600;
}

.book-loading-progress {
    margin-top: 6px;
    font-size: .8rem;
    font-weight: 800;
    color: var(--ll-green);
}

.book-download-btn {
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(13, 53, 31, .25);
    border-radius: 4px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ll-green-deep);
    text-decoration: none;
    transition: background-color .18s ease, color .18s ease;
}

.book-download-btn:hover {
    background: var(--ll-green);
    color: #ffffff;
}

/* Flipbook pages */
.bf-page {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fffef9;
    overflow: hidden;
}

.bf-page img {
    display: block;
    max-width: 96%;
    max-height: 96%;
}

.bf-left {
    left: 0;
}

.bf-right {
    left: 50%;
}

.bf-single {
    left: 0;
    width: 100%;
}

.bf-blank {
    background: #f5f2ec;
}

.bf-flip-page {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    z-index: 10;
    transform-style: preserve-3d;
    transition: transform .5s ease-in-out;
}

.bf-flip-fwd {
    left: 50%;
    transform-origin: left center;
}

.bf-flip-fwd.bf-flipping {
    transform: perspective(1800px) rotateY(-180deg);
}

.bf-flip-bwd {
    left: 0;
    transform-origin: right center;
}

.bf-flip-bwd.bf-flipping {
    transform: perspective(1800px) rotateY(180deg);
}

.bf-flip-fwd-single {
    left: 0;
    width: 100%;
    transform-origin: left center;
}

.bf-flip-fwd-single.bf-flipping {
    transform: perspective(1800px) rotateY(-180deg);
}

.bf-flip-bwd-single {
    left: 0;
    width: 100%;
    transform-origin: right center;
}

.bf-flip-bwd-single.bf-flipping {
    transform: perspective(1800px) rotateY(180deg);
}

.bf-flip-front,
.bf-flip-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fffef9;
    overflow: hidden;
}

.bf-flip-front img,
.bf-flip-back img {
    display: block;
    max-width: 96%;
    max-height: 96%;
}

.bf-flip-back {
    transform: rotateY(180deg);
}

.bf-flip-page::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
            rgba(0, 0, 0, .1) 0%,
            transparent 40%,
            transparent 60%,
            rgba(0, 0, 0, .07) 100%);
    pointer-events: none;
    z-index: 1;
}

.ll-viewer-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 14px;
    padding: 24px;
    text-align: center;
    color: #b91c1c;
    font-weight: 600;
}

.ll-viewer-error a {
    display: inline-block;
    padding: 9px 20px;
    background: var(--ll-green);
    color: #ffffff;
    border-radius: 4px;
    text-decoration: none;
    font-size: .85rem;
    font-weight: 700;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
    .legislative-library-page .ll-table thead th {
        white-space: normal;
    }

    /* Keep the author column correct in the mobile card layout */
    .legislative-library-page .responsive-table thead .column-author.is-shown {
        display: none;
    }

    .legislative-library-page .responsive-table tbody .column-author.is-shown {
        display: block;
    }

    .book-cover-wrap {
        padding: 8px;
    }
}

@media (max-width: 640px) {
    .legislative-library-page .ll-main {
        width: calc(100% - 20px);
        margin: 18px auto 36px;
    }

    .legislative-library-page .ll-hero__meta-item {
        font-size: .66rem;
        padding: 5px 9px;
    }

    .book-controls button,
    .book-download-btn {
        width: 38px;
        height: 38px;
    }
}
