/*
 * Knowledge Center worksheets (Field Modules and similar uploads).
 * Class vocabulary is defined in apps/resources/worksheet_html.py; the
 * sanitizer strips author CSS, so every worksheet look lives here.
 */

.article-content {
    --ws-border: #9ca3af;
    --ws-line: #4b5563;
    --ws-rule: #d1d5db;
    --ws-label: #1f2937;
    --ws-head-bg: #111827;
    --ws-head-fg: #ffffff;
    --ws-rule-gap: 2rem;
    overflow-wrap: break-word;
}

.article-content .lca-intro {
    font-size: 1.0625rem;
    color: #4b5563;
}

/* Sections */

.article-content .lca-group {
    border: 1px solid var(--ws-border);
    border-radius: 0.5rem;
    margin: 1.75rem 0;
    overflow: hidden;
    background: #fff;
}

.article-content .lca-group > h2,
.article-content .lca-group > h3 {
    margin: 0;
    padding: 0.625rem 1rem;
    background: var(--ws-head-bg);
    color: var(--ws-head-fg);
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.4;
}

.article-content .lca-group > :not(h2):not(h3):not(.lca-grid):not(.lca-table-wrap) {
    margin: 1rem;
}

.article-content .lca-legend {
    font-size: 1.25rem;
}

/* Label / write-in grid */

.article-content .lca-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0 -1px -1px 0;
}

.article-content .lca-group > .lca-grid {
    margin-top: 0;
}

.article-content .lca-field {
    display: flex;
    flex-direction: column;
    min-height: 4.5rem;
    padding: 0.5rem 0.75rem 0.625rem;
    border-right: 1px solid var(--ws-border);
    border-bottom: 1px solid var(--ws-border);
    break-inside: avoid;
}

.article-content .lca-field.wide,
.article-content .lca-field.full {
    grid-column: 1 / -1;
}

.article-content .lca-label {
    font-weight: 700;
    color: var(--ws-label);
}

.article-content .lca-write-cell .lca-label,
.article-content p .lca-label {
    font-weight: inherit;
    margin-right: 0.75rem;
}

.article-content .lca-field > .lca-label {
    font-size: 0.8125rem;
    line-height: 1.35;
    letter-spacing: 0.01em;
}

/* Write-in blanks */

.article-content .lca-write {
    display: block;
    min-height: 2rem;
    margin: 0.5rem 0;
    border-bottom: 1px solid var(--ws-line);
}

.article-content .lca-field > .lca-write {
    flex: 1 1 auto;
    min-height: 2.25rem;
    margin: 0.25rem 0 0;
    border-bottom: 1px solid var(--ws-rule);
}

.article-content .lca-write-inline {
    display: inline-block;
    min-width: 10rem;
    max-width: 100%;
    min-height: 1.5em;
    margin: 0 0.25rem;
    vertical-align: bottom;
}

.article-content .lca-write-area,
.article-content .lca-field.wide > .lca-write,
.article-content .lca-field.tall > .lca-write,
.article-content .lca-rec {
    min-height: 6rem;
    border: 0;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent calc(var(--ws-rule-gap) - 1px),
        var(--ws-rule) calc(var(--ws-rule-gap) - 1px),
        var(--ws-rule) var(--ws-rule-gap)
    );
}

.article-content .lca-write-area:not(.lca-field > .lca-write) {
    border: 1px solid var(--ws-border);
    border-radius: 0.25rem;
}

.article-content .lca-write-lg,
.article-content .lca-rec {
    min-height: 10rem;
}

.article-content .lca-check,
.article-content .lca-choice::before,
.article-content .lca-photo::before,
.article-content .lca-checklist > li::before {
    content: "";
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 1.5px solid var(--ws-line);
    border-radius: 2px;
    vertical-align: -0.15em;
    background: #fff;
}

.article-content .lca-check {
    margin-right: 0.35em;
}

.article-content .lca-choices {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
}

.article-content .lca-choice::before {
    margin-right: 0.35em;
}

.article-content .lca-checklist {
    list-style: none;
    padding-left: 0;
}

.article-content .lca-checklist > li::before {
    margin-right: 0.5em;
}

/* Photo checklist */

.article-content .lca-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 0.625rem 1.5rem;
}

.article-content .lca-photo {
    position: relative;
    padding-left: 1.75rem;
    font-size: 1rem;
    line-height: 1.5;
    break-inside: avoid;
}

.article-content .lca-photo::before {
    position: absolute;
    left: 0;
    top: 0.25em;
}

/* Narrative and footer text */

.article-content .lca-narrative p {
    line-height: 2.1;
}

.article-content .lca-narrative p:last-child {
    margin-bottom: 0;
}

.article-content .lca-related {
    font-size: 0.9375rem;
    border-top: 1px solid #e5e7eb;
    padding-top: 0.75rem;
}

.article-content footer {
    margin-top: 2rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
    font-size: 0.8125rem;
    color: #6b7280;
    text-align: center;
}

/* Tables */

.article-content .lca-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.article-content .lca-table-wrap > table {
    margin: 0;
}

.article-content .lca-group > .lca-table-wrap {
    margin: 0;
}

.article-content .lca-group > .lca-table-wrap > table {
    border-style: hidden;
}

.article-content .lca-worksheet-table th,
.article-content .lca-worksheet-table td {
    border: 1px solid var(--ws-border);
    padding: 0.5rem 0.75rem;
    vertical-align: top;
}

.article-content .lca-worksheet-table th {
    background: var(--ws-head-bg);
    color: var(--ws-head-fg);
    font-size: 0.9375rem;
}

.article-content .lca-worksheet-table td:not(.lca-write-cell) {
    background: #f9fafb;
    color: var(--ws-label);
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1.35;
}

.article-content .lca-worksheet-table td.lca-write-cell {
    height: 2.75rem;
    min-width: 8rem;
    background: #fff;
}

.article-content .lca-write-cell > .lca-write-inline:only-child {
    display: block;
    width: 100%;
    margin: 0;
    border-bottom-color: transparent;
}

.article-content .lca-write-cell > .lca-write:only-child {
    margin: 0;
}

/* Phones: one column, label above its write-in area, no sideways scrolling. */

@media (max-width: 640px) {
    .article-content .lca-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .article-content .lca-group > :not(h2):not(h3):not(.lca-grid):not(.lca-table-wrap) {
        margin: 0.75rem;
    }

    .article-content .lca-photo-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .article-content .lca-write-inline {
        min-width: 6rem;
    }

    .article-content .lca-worksheet-table,
    .article-content .lca-worksheet-table > caption,
    .article-content .lca-worksheet-table > thead,
    .article-content .lca-worksheet-table > tbody,
    .article-content .lca-worksheet-table > tfoot,
    .article-content .lca-worksheet-table tr,
    .article-content .lca-worksheet-table th,
    .article-content .lca-worksheet-table td {
        display: block;
        width: 100%;
    }

    .article-content .lca-worksheet-table {
        border: 1px solid var(--ws-border);
    }

    .article-content .lca-group > .lca-table-wrap > .lca-worksheet-table {
        border: 0;
    }

    .article-content .lca-worksheet-table th,
    .article-content .lca-worksheet-table td {
        border: 0;
        border-bottom: 1px solid var(--ws-border);
    }

    .article-content .lca-worksheet-table td:not(.lca-write-cell) {
        border-bottom: 0;
        padding-bottom: 0.25rem;
        background: #fff;
    }

    .article-content .lca-worksheet-table td.lca-write-cell {
        min-width: 0;
        min-height: 2.75rem;
        height: auto;
    }
}

/* Print: page chrome is hidden, header bars switch to ink-light rules. */

@media print {
    @page {
        margin: 0.5in;
    }

    .lca-no-print,
    .admin-ribbon,
    body > nav,
    body > footer {
        display: none !important;
    }

    body {
        background: #fff !important;
    }

    main {
        max-width: none !important;
        padding: 0 !important;
    }

    main > article {
        box-shadow: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    main > article > div {
        padding: 0 !important;
    }

    .article-content {
        --ws-border: #000;
        --ws-line: #000;
        --ws-rule: #6b7280;
        --ws-head-bg: #fff;
        --ws-head-fg: #000;
        font-size: 11pt;
        line-height: 1.45;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .article-content a {
        color: #000;
    }

    .article-content .lca-group {
        border-radius: 0;
    }

    .article-content .lca-group > h2,
    .article-content .lca-group > h3 {
        border-bottom: 2px solid #000;
        break-after: avoid;
    }

    .article-content .lca-worksheet-table th {
        border-bottom-width: 2px;
    }

    .article-content .lca-worksheet-table td:not(.lca-write-cell) {
        background: #fff;
    }

    .article-content tr,
    .article-content .lca-field,
    .article-content .lca-photo,
    .article-content .lca-rec,
    .article-content .lca-write-area {
        break-inside: avoid;
    }

    .article-content .lca-table-wrap {
        overflow: visible;
    }
}
