/* ============================================================
   PUBLIC RULES LIBRARY
   ============================================================ */

html,
body.rules-page-body {
    min-height: 100%;
}

body.rules-page-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.rules-page-body .site-main {
    flex: 1 0 auto;
}

.rules-page-body .site-footer {
    flex-shrink: 0;
    margin-top: auto;
}

.rules-main {
    width: calc(100% - 30px);
    max-width: 1120px;
    margin: 0 auto;
    padding: 30px 0 54px;
}

.rules-intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 24px;
    align-items: end;
    margin-bottom: 22px;
}

.rules-eyebrow {
    margin: 0 0 6px;
    color: #0b64b5;
    font-size: .78rem;
    font-weight: 900;
    letter-spacing: .15em;
}

.rules-intro h2 {
    margin: 0;
    color: #06396f;
    font-size: clamp(2rem, 4vw, 3.15rem);
    line-height: 1;
}

.rules-intro-copy {
    max-width: 760px;
    margin: 12px 0 0;
    color: #506d88;
    font-size: 1rem;
    line-height: 1.6;
}

.rules-source-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 15px;
    border: 1px solid #91bddb;
    border-radius: 9px;
    color: #075394;
    background: #f5fbff;
    font-size: .88rem;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.rules-source-link:hover,
.rules-source-link:focus-visible {
    border-color: #0b64b5;
    background: #e8f4fc;
}

.rules-tools {
    position: sticky;
    z-index: 20;
    top: 0;
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 12px 20px;
    align-items: center;
    margin-bottom: 18px;
    padding: 15px;
    border: 1px solid #c7dcea;
    border-radius: 14px;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 7px 22px rgba(7, 54, 108, .08);
}

.rules-search-wrap {
    position: relative;
}

.rules-search-wrap label {
    display: block;
    margin-bottom: 6px;
    color: #073f73;
    font-size: .84rem;
    font-weight: 900;
}

.rules-search-wrap input {
    width: 100%;
    min-height: 46px;
    padding: 10px 86px 10px 42px;
    border: 2px solid #aac9df;
    border-radius: 10px;
    color: #082f57;
    background: #fff;
    font: inherit;
}

.rules-search-wrap::after {
    content: "⌕";
    position: absolute;
    left: 14px;
    bottom: 10px;
    color: #0b64b5;
    font-size: 1.35rem;
    line-height: 1;
    pointer-events: none;
}

.rules-search-wrap input:focus {
    border-color: #0b64b5;
    outline: 3px solid rgba(11, 100, 181, .15);
}

.rules-clear {
    position: absolute;
    right: 8px;
    bottom: 7px;
    min-height: 32px;
    padding: 4px 10px;
    border: 0;
    border-radius: 7px;
    color: #355c7c;
    background: #e9f2f8;
    font: inherit;
    font-size: .8rem;
    font-weight: 800;
    cursor: pointer;
}

.rules-filter-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
}

.rules-filter {
    min-height: 40px;
    padding: 8px 13px;
    border: 1px solid #b7d0e2;
    border-radius: 999px;
    color: #124c7f;
    background: #edf6fc;
    font: inherit;
    font-size: .84rem;
    font-weight: 850;
    cursor: pointer;
}

.rules-filter:hover,
.rules-filter:focus-visible {
    border-color: #0b64b5;
}

.rules-filter.active {
    border-color: #0b64b5;
    color: #fff;
    background: #0b64b5;
}

.rules-tool-footer {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-top: 2px;
    color: #60758a;
    font-size: .82rem;
}

.rules-tool-footer p {
    margin: 0;
}

.rules-result-count {
    color: #073f73;
    font-weight: 800;
}

.rules-notice {
    margin: 0 0 18px;
    padding: 13px 15px;
    border-left: 4px solid #e3a315;
    border-radius: 8px;
    color: #654600;
    background: #fff7e6;
    font-size: .9rem;
    line-height: 1.5;
}

.rules-list {
    display: grid;
    gap: 10px;
}

.rule-card {
    scroll-margin-top: 124px;
    border: 1px solid #c9dce9;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(7, 54, 108, .045);
    overflow: hidden;
}

.rule-card[hidden] {
    display: none;
}

.rule-card:target {
    border-color: #e1a11a;
    box-shadow: 0 0 0 3px rgba(225, 161, 26, .14);
}

.rule-card details {
    margin: 0;
}

.rule-card summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    min-height: 72px;
    padding: 13px 15px;
    color: #06396f;
    cursor: pointer;
    list-style: none;
}

.rule-card summary::-webkit-details-marker {
    display: none;
}

.rule-card summary::after {
    content: "+";
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #0b64b5;
    background: #e7f3fb;
    font-size: 1.3rem;
    font-weight: 900;
}

.rule-card details[open] summary::after {
    content: "−";
}

.rule-reference {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    min-height: 34px;
    padding: 5px 9px;
    border-radius: 8px;
    color: #fff;
    background: #0a4b88;
    font-size: .78rem;
    font-weight: 900;
    white-space: nowrap;
}

.rule-heading-text {
    min-width: 0;
}

.rule-section {
    display: block;
    margin-bottom: 3px;
    color: #678096;
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.rule-title {
    display: block;
    color: #062f63;
    font-size: 1.04rem;
    line-height: 1.25;
}

.rule-search-preview {
    margin: -3px 56px 13px 95px;
    padding: 9px 11px;
    border-radius: 8px;
    color: #49677f;
    background: #eef6fb;
    font-size: .85rem;
    line-height: 1.45;
}

.rule-card details[open] + .rule-search-preview {
    display: none;
}

.rule-body-wrap {
    padding: 0 18px 19px 95px;
    border-top: 1px solid #e1ebf1;
}

.rule-body {
    max-width: 850px;
    padding-top: 16px;
    color: #183f60;
    font-size: .96rem;
    line-height: 1.65;
}

.rule-body ol,
.rule-body ul {
    margin: 0;
    padding-left: 1.45rem;
}

.rule-body li + li {
    margin-top: 10px;
}

.rule-card-tools {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
}

.rule-copy-link {
    padding: 7px 10px;
    border: 1px solid #b7d0e2;
    border-radius: 7px;
    color: #0a4b88;
    background: #f6fbfe;
    font: inherit;
    font-size: .78rem;
    font-weight: 800;
    cursor: pointer;
}

.rules-empty,
.rules-no-results {
    margin-top: 14px;
    padding: 24px;
    border: 1px dashed #9ebdd2;
    border-radius: 12px;
    color: #4c6c84;
    background: #f6fbfe;
    text-align: center;
}

.rules-empty h3,
.rules-no-results h3 {
    margin: 0 0 6px;
    color: #073f73;
}

.rules-empty p,
.rules-no-results p {
    margin: 0;
    line-height: 1.5;
}

@media (max-width: 760px) {
    .rules-intro {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .rules-source-link {
        justify-self: start;
    }

    .rules-tools {
        position: static;
        grid-template-columns: 1fr;
    }

    .rules-filter-group {
        justify-content: flex-start;
    }

    .rules-tool-footer {
        grid-column: 1;
        flex-direction: column;
        gap: 4px;
    }
}

@media (max-width: 520px) {
    .rules-main {
        width: calc(100% - 22px);
        padding-top: 22px;
    }

    .rules-filter-group {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
    }

    .rules-filter {
        min-width: 0;
        padding-inline: 6px;
        font-size: .76rem;
    }

    .rule-card summary {
        grid-template-columns: auto minmax(0, 1fr) 28px;
        gap: 9px;
        padding: 12px;
    }

    .rule-reference {
        min-width: 54px;
        padding-inline: 6px;
    }

    .rule-section {
        font-size: .65rem;
    }

    .rule-title {
        font-size: .94rem;
    }

    .rule-search-preview {
        margin: -1px 12px 12px 75px;
    }

    .rule-body-wrap {
        padding: 0 14px 17px;
    }
}
