/* Document catalogue (templates/core/document_constructor.html).
 *
 * A folder tree: sphere in the rail, a deal per folder, its appendices inside.
 * Namespace is dcl-*, deliberately not dc-*: that belongs to the fill-in page
 * (document-constructor.css), and the two are loaded by different views.
 *
 * Tokens are lifted from style.css so no hex literal repeats down the page,
 * matching what catalogue.css does for the specialists listing. Gold is the
 * site's own --nav-accent, used here only for the folder glyph.
 */

.dcl-page {
    --dcl-primary: #8b0000;
    --dcl-primary-hover: #730c0b;
    --dcl-primary-tint: #fdf2f2;
    --dcl-gold: #f2c93e;
    --dcl-gold-lift: #f7d968;
    --dcl-text: #343235;
    --dcl-muted: #6b7280;
    --dcl-faint: #9ca3af;
    --dcl-bg: #f9fafb;
    --dcl-surface: #ffffff;
    --dcl-border: #e5e7eb;
    --dcl-border-soft: #f1f2f4;
    --dcl-radius: 8px;
    --dcl-radius-lg: 12px;

    color: var(--dcl-text);
    padding-bottom: 3rem;
}

.dcl-shell {
    display: grid;
    grid-template-columns: 252px minmax(0, 1fr);
    gap: 0;
    align-items: start;
    background: var(--dcl-surface);
    border: 1px solid var(--dcl-border);
    border-radius: var(--dcl-radius-lg);
    overflow: hidden;
}

/* ------------------------------------------------------------------ rail */

.dcl-rail {
    padding: 20px 14px 32px 18px;
    border-right: 1px solid var(--dcl-border);
    position: sticky;
    /* navbar.js measures the real bar into --app-header-h; never hard-code 64. */
    top: calc(var(--app-header-h, 64px) + 12px);
}

.dcl-rail-title {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 13px;
    padding-left: 6px;
    font-size: .95rem;
    font-weight: 700;
}

.dcl-rail-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dcl-rail-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 9px 11px;
    border-radius: 7px;
    font-size: .875rem;
    line-height: 1.35;
    color: #4b5563;
    text-decoration: none;
}

.dcl-rail-item span {
    flex: 1;
    min-width: 0;
}

.dcl-rail-item em {
    flex: 0 0 auto;
    font-style: normal;
    font-size: .75rem;
    color: var(--dcl-faint);
    font-variant-numeric: tabular-nums;
}

.dcl-rail-item:hover {
    color: var(--dcl-primary);
    background: var(--dcl-bg);
}

.dcl-rail-item.is-active {
    background: var(--dcl-primary-tint);
    color: var(--dcl-primary);
    font-weight: 600;
}

.dcl-rail-item.is-active em {
    color: var(--dcl-primary);
}

/* ------------------------------------------------------------------ main */

.dcl-main {
    padding: 20px 24px 36px;
    min-width: 0;
}

.dcl-search {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 420px;
    height: 38px;
    margin: 0 0 20px;
    padding: 0 4px 0 14px;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    background: var(--dcl-surface);
}

.dcl-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    font-family: inherit;
    font-size: .875rem;
    color: var(--dcl-text);
}

.dcl-search:focus-within {
    border-color: var(--dcl-primary);
    box-shadow: 0 0 0 3px rgba(139, 0, 0, .1);
}

.dcl-search button {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: var(--dcl-primary);
    color: #fff;
    font-size: .8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dcl-search button:hover {
    background: var(--dcl-primary-hover);
}

.dcl-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 14px;
}

.dcl-h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -.01em;
}

.dcl-sub {
    margin: 3px 0 0;
    font-size: .8125rem;
    color: var(--dcl-muted);
}

.dcl-note {
    margin: 14px 0 0;
    font-size: .8125rem;
    color: var(--dcl-muted);
}

.dcl-sort {
    display: flex;
    flex: 0 0 auto;
    gap: 2px;
    padding: 3px;
    background: #eef0f2;
    border-radius: 999px;
}

.dcl-sort-btn {
    width: 38px;
    height: 30px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--dcl-muted);
    text-decoration: none;
    font-size: .9rem;
}

.dcl-sort-btn:hover {
    color: var(--dcl-primary);
}

.dcl-sort-btn.is-active {
    background: var(--dcl-surface);
    color: var(--dcl-text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}

/* ------------------------------------------------------------------ tree */

.dcl-tree,
.dcl-flat {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--dcl-border);
}

.dcl-node {
    border-bottom: 1px solid var(--dcl-border);
}

.dcl-flat > li {
    border-bottom: 1px solid var(--dcl-border-soft);
}

.dcl-node > details > summary {
    list-style: none;
}

/* Safari draws its own triangle unless this is suppressed. */
.dcl-node > details > summary::-webkit-details-marker {
    display: none;
}

.dcl-folder {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 14px 6px;
    cursor: pointer;
}

.dcl-folder:hover .dcl-folder-t {
    color: var(--dcl-primary);
}

.dcl-folder:focus-visible {
    outline: 2px solid var(--dcl-primary);
    outline-offset: -2px;
    border-radius: 6px;
}

/* The caret is drawn here rather than taken from the font, so its rotation is
   the same shape in every browser. */
.dcl-caret {
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--dcl-faint);
    border-bottom: 2px solid var(--dcl-faint);
    transform: rotate(-45deg);
    transition: transform .16s ease;
}

.dcl-node > details[open] > summary .dcl-caret {
    transform: rotate(45deg);
}

.dcl-folder-icon {
    flex: 0 0 auto;
    display: block;
}

.dcl-folder-back {
    fill: var(--dcl-gold);
}

.dcl-folder-front {
    fill: var(--dcl-gold-lift);
}

.dcl-folder-icon.is-muted .dcl-folder-back {
    fill: #d1d5db;
}

.dcl-folder-icon.is-muted .dcl-folder-front {
    fill: #e5e7eb;
}

.dcl-folder-t {
    flex: 1;
    min-width: 0;
    font-size: 1rem;
    line-height: 1.3;
}

.dcl-folder-n {
    flex: 0 0 auto;
    font-size: .78rem;
    color: var(--dcl-faint);
    font-variant-numeric: tabular-nums;
}

.dcl-kids {
    list-style: none;
    margin: 0;
    padding: 2px 0 12px 50px;
}

.dcl-kids-note {
    padding: 4px 6px 8px;
    font-size: .78rem;
    color: var(--dcl-muted);
}

/* ------------------------------------------------------------- a document */

.dcl-doc {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 8px 6px;
    text-decoration: none;
    border-radius: 6px;
}

.dcl-doc:hover .dcl-doc-t > span {
    color: var(--dcl-primary);
}

.dcl-doc:focus-visible {
    outline: 2px solid var(--dcl-primary);
    outline-offset: -2px;
}

.dcl-doc.is-lead {
    background: #fbfaf9;
    margin-bottom: 3px;
}

.dcl-doc.is-lead .dcl-doc-t > span {
    font-weight: 650;
}

/* A contract with no appendices sits at folder level, so it carries the same
   height and the same left edge as a folder row. */
.dcl-doc.is-big {
    padding: 14px 6px 14px 22px;
    gap: 16px;
}

.dcl-doc.is-big .dcl-doc-t > span {
    font-size: .9375rem;
}

.dcl-doc-t {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    min-width: 0;
}

.dcl-doc-t > span {
    color: var(--dcl-text);
    font-size: .875rem;
    line-height: 1.35;
}

.dcl-doc-icon {
    flex: 0 0 auto;
    margin-top: 2px;
    color: var(--dcl-faint);
    font-size: .85rem;
}

.dcl-doc-m {
    flex: 0 0 auto;
    font-size: .72rem;
    color: var(--dcl-faint);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.dcl-tag {
    display: inline-block;
    margin-left: 5px;
    padding: 1px 6px;
    border: 1px solid var(--dcl-border);
    border-radius: 5px;
    background: #f3f4f6;
    color: #4b5563;
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
    vertical-align: 1px;
}

.dcl-tag.is-lead {
    background: var(--dcl-primary-tint);
    border-color: rgba(139, 0, 0, .16);
    color: var(--dcl-primary);
    text-transform: uppercase;
    font-size: .6rem;
    letter-spacing: .05em;
}

.dcl-kk {
    display: inline-block;
    margin-left: 5px;
    padding: 0 5px;
    border: 1px solid #c8ece0;
    border-radius: 4px;
    background: #ecfdf5;
    color: #0f7a54;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .05em;
    vertical-align: 1px;
}

/* ----------------------------------------------------------- responsive */

@media (max-width: 991px) {
    .dcl-shell {
        grid-template-columns: 1fr;
    }

    .dcl-rail {
        position: static;
        border-right: 0;
        border-bottom: 1px solid var(--dcl-border);
        padding-bottom: 16px;
    }

    .dcl-rail-list {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .dcl-rail-item {
        border: 1px solid var(--dcl-border);
    }

    .dcl-kids {
        padding-left: 26px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dcl-caret {
        transition: none;
    }
}
