/*
 * Content tables (tables added by editors in posts, projects, units, pages and
 * city descriptions). inc/content_tables.php wraps each one in .imic-table-wrap
 * so it scrolls sideways on small screens instead of overflowing the page.
 * Template tables (Bootstrap .table) are not wrapped and not affected.
 */

/* Grid items default to min-width:auto, so a wide table used to stretch the
   whole article column past the screen (text got clipped too). Let the
   columns shrink so the table wrapper scrolls instead. */
.project-details-grid > * {
    min-width: 0;
}

.imic-table-wrap {
    --imic-tbl-gold: #8e7744;
    --imic-tbl-gold-soft: #faf7f1;
    --imic-tbl-gold-hover: #f3ecdf;
    --imic-tbl-border: #e6dccb;
    --imic-tbl-line: #eee7da;
    position: relative;
    max-width: 100%;
    margin: 1.5rem 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border: 1px solid var(--imic-tbl-border);
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(33, 37, 41, 0.06);
    /* Edge shadows that appear only while more columns are hidden off-side. */
    background:
        linear-gradient(to right, #fff 30%, rgba(255, 255, 255, 0)) left center / 32px 100% no-repeat local,
        linear-gradient(to left, #fff 30%, rgba(255, 255, 255, 0)) right center / 32px 100% no-repeat local,
        radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0)) left center / 12px 100% no-repeat scroll,
        radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0)) right center / 12px 100% no-repeat scroll,
        #fff;
    scrollbar-width: thin;
    scrollbar-color: var(--imic-tbl-gold) transparent;
}

.imic-table-wrap::-webkit-scrollbar {
    height: 6px;
}

.imic-table-wrap::-webkit-scrollbar-thumb {
    background: var(--imic-tbl-gold);
    border-radius: 6px;
}

.imic-table-wrap::-webkit-scrollbar-track {
    background: transparent;
}

.imic-table-wrap:focus-visible {
    outline: 2px solid var(--imic-tbl-gold);
    outline-offset: 2px;
}

.imic-table-wrap table {
    width: 100%;
    margin: 0;
    border: 0;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
    font-size: 0.95rem;
    line-height: 1.7;
    color: #212529;
}

.imic-table-wrap th,
.imic-table-wrap td {
    padding: 12px 16px;
    border: 0;
    border-bottom: 1px solid var(--imic-tbl-line);
    text-align: start;
    vertical-align: top;
}

.imic-table-wrap th + th,
.imic-table-wrap td + td,
.imic-table-wrap th + td,
.imic-table-wrap td + th {
    border-inline-start: 1px solid var(--imic-tbl-line);
}

/* Header row: <thead>, or a first row made of <th> cells. */
.imic-table-wrap thead th,
.imic-table-wrap thead td,
.imic-table-wrap table > tbody:first-child > tr:first-child > th,
.imic-table-wrap table > tr:first-child > th {
    padding: 14px 16px;
    background: var(--imic-tbl-gold);
    color: #fff;
    font-weight: 700;
    white-space: nowrap;
    border-bottom: 0;
    border-inline-start-color: rgba(255, 255, 255, 0.18);
}

.imic-table-wrap tbody tr:nth-child(even) > td {
    background: var(--imic-tbl-gold-soft);
}

.imic-table-wrap tbody tr:hover > td {
    background: var(--imic-tbl-gold-hover);
}

.imic-table-wrap tbody tr:last-child > td,
.imic-table-wrap tbody tr:last-child > th {
    border-bottom: 0;
}

.imic-table-wrap tbody td:first-child,
.imic-table-wrap tbody th:first-child:not(:only-child) {
    font-weight: 600;
}

.imic-table-wrap td p,
.imic-table-wrap th p {
    margin: 0;
}

/* Swipe hint, shown by assets/js/content-tables.js only when the table overflows. */
.imic-table-hint {
    display: none;
    margin: -1rem 0 1.5rem;
    font-size: 0.8rem;
    color: #8a8f98;
    text-align: center;
}

.imic-table-hint.is-visible {
    display: block;
}

@media (max-width: 575.98px) {
    /* main.css turns every table row/cell into blocks on phones; keep real
       table layout for content tables and let the wrapper scroll instead. */
    .imic-table-wrap table tr {
        display: table-row;
        margin: 0;
    }

    .imic-table-wrap table th,
    .imic-table-wrap table td {
        display: table-cell;
        width: auto;
        min-width: 9.5rem;
        padding: 10px 12px !important;
        font-size: 0.875rem;
    }

    .imic-table-wrap thead th,
    .imic-table-wrap table > tbody:first-child > tr:first-child > th {
        white-space: normal;
    }
}

@media print {
    .imic-table-wrap {
        overflow: visible;
        box-shadow: none;
        background: none;
    }

    .imic-table-hint {
        display: none !important;
    }
}
