/* Server rules: the public page, the editor's preview and the editor (see docs/rules.md) */

/* Table of contents, styled by bootstrap-toc like the laws page */
.rules-toc {
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}
.rules-toc-title {
    margin: 0 0 0.5rem 20px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #767676;
}
@media (max-width: 767.98px) {
    /* A plain list above the rules on small screens */
    .rules-toc {
        position: static;
        max-height: none;
        margin-bottom: 2rem;
    }
}

/* Anchors land a little below the top of the window */
.rules-document [id] {
    scroll-margin-top: 1rem;
}
.rules h3 {
    font-size: 1.4rem;
}
.rules-recent {
    margin-left: 0.5rem;
    font-size: 0.6em;
    font-weight: normal;
    vertical-align: middle;
}

/* Rendered rule Markdown */
.rule-body p {
    margin-bottom: 0.75rem;
}
.rule-body > :last-child,
.rule-body li > p {
    margin-bottom: 0;
}
.rule-body ul,
.rule-body ol {
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
}
.rule-link-unknown {
    color: #b7791f;
    text-decoration: underline dotted;
    cursor: help;
}

/* Hover previews of linked terms, sections and rules */
.rules-popover {
    max-width: 24rem;
}
.rules-popover .popover-body {
    max-height: 20rem;
    overflow-y: auto;
}
.rules-popover .rule-body p:last-child {
    margin-bottom: 0;
}

/* The editor */
.rules-editor-toolbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    background-color: #fff;
    border-bottom: 1px solid #dee2e6;
    padding: 0.75rem 0;
    margin-bottom: 1rem;
}
.rules-card {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.75rem;
    background-color: #fff;
}
.rules-card + .rules-card {
    margin-top: 0.75rem;
}
.rules-card-nested {
    background-color: #f8f9fa;
}
.rules-card-removed {
    opacity: 0.6;
}
.rules-card-removed > .rules-card-header .rules-card-title {
    text-decoration: line-through;
}
.rules-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.rules-card-title {
    font-weight: 600;
    word-break: break-word;
}
.rules-card-actions .btn {
    margin-left: 0.25rem;
    margin-bottom: 0.25rem;
}
.rules-children {
    border-left: 2px solid #dee2e6;
    padding-left: 0.75rem;
    margin-top: 0.75rem;
}
.rules-editor-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.5rem;
    margin: 1.5rem 0 0.75rem;
}
.rules-editor-heading h2 {
    font-size: 1.25rem;
    margin: 0;
}
.rules-preview-frame {
    width: 100%;
    height: calc(100vh - 12rem);
    min-height: 30rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

/* The Markdown editor in the forms */
.rules-md-toolbar {
    border: 1px solid #ced4da;
    border-bottom: 0;
    border-radius: 0.25rem 0.25rem 0 0;
    padding: 0.25rem;
    background-color: #f8f9fa;
}
.rules-md-toolbar + textarea {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.85rem;
}
.rules-md-preview {
    border: 1px dashed #ced4da;
    border-radius: 0.25rem;
    padding: 0.5rem 0.75rem;
    min-height: 2.5rem;
}
.rules-link-picker {
    width: 22rem;
    max-height: 20rem;
    overflow-y: auto;
    padding-top: 0;
}
.rules-link-picker .rules-link-search {
    position: sticky;
    top: 0;
    background-color: #fff;
    padding: 0.5rem;
}
.rules-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    height: auto;
    min-height: calc(1.5em + 0.75rem + 2px);
    gap: 0.25rem;
}
.rules-tags input {
    flex: 1;
    min-width: 8rem;
    border: 0;
    outline: 0;
    padding: 0;
}
.rules-tags .badge button {
    border: 0;
    background: none;
    padding: 0 0 0 0.25rem;
    color: inherit;
    line-height: 1;
}

/* The history side panel */
.rules-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background-color: rgba(0, 0, 0, 0.4);
}
.rules-sheet {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1045;
    width: 36rem;
    max-width: 100%;
    overflow-y: auto;
    background-color: #fff;
    box-shadow: -0.5rem 0 1rem rgba(0, 0, 0, 0.15);
    padding: 1rem;
}

/* Toasts */
.rules-toasts {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1060;
    width: 22rem;
    max-width: calc(100% - 2rem);
}
.rules-toasts .alert {
    white-space: pre-line;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1);
}
