/*
 * Layout adjustments on top of mini.css.
 *
 * mini.css caps every table at 400px and makes it scroll
 * (table:not(.horizontal){overflow:auto;max-height:400px}), which turns both
 * the download table and the business detail view into small scrolled frames
 * inside an otherwise empty page. These tables are short and want to be read as
 * a whole, so that behaviour is undone here rather than by adding mini.css's
 * "horizontal" class, which restyles them as a card grid instead.
 */

:root {
    --measure: 62rem;
}

/* Give the page a readable column rather than letting it span the viewport. */
body > header,
main {
    max-width: var(--measure);
    margin-left: auto;
    margin-right: auto;
}

main {
    padding: 0 1rem 3rem;
}

/* ---- Tables ------------------------------------------------------------ */

table {
    overflow: visible;
    max-height: none;
    width: 100%;
    display: table;
    border-collapse: collapse;
    margin: 0 0 1.5rem;
}

table thead,
table tbody,
table tr {
    display: table-row-group;
}

table tr {
    display: table-row;
}

table th,
table td {
    display: table-cell;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    padding: 0.5rem 0.75rem;
    border: 0;
    border-bottom: 1px solid var(--secondary-border-color, #ddd);
    text-align: left;
    vertical-align: top;
}

table th {
    font-weight: 600;
    border-bottom-width: 2px;
}

table tbody tr:hover {
    background: var(--secondary-back-color, #f0f0f0);
}

/* Numeric columns read better right-aligned. */
table td.numeric,
table th.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---- Definition-style detail table ------------------------------------- */

/*
 * The business detail view is a list of labelled values, not a grid, so the
 * label column is held narrow and the value column takes the rest.
 */
.detail th[scope="row"] {
    width: 14rem;
    font-weight: 600;
    color: var(--secondary-fore-color, #444);
    border-bottom: 1px solid var(--secondary-border-color, #eee);
}

.detail caption {
    text-align: left;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 1rem 0 0.5rem;
}

/* ---- Cards ------------------------------------------------------------- */

/*
 * The "newest businesses" listing was nine bordered boxes laid out by counting
 * to three in PHP. A grid handles the wrapping, and without the heavy border
 * the list reads as a list.
 */
.listing {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 1rem;
    margin: 0 0 2rem;
    padding: 0;
    list-style: none;
}

.listing li {
    padding: 0.75rem 0 0;
    border-top: 2px solid var(--secondary-border-color, #ddd);
}

.listing .name {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.listing .meta {
    color: var(--secondary-fore-color, #444);
    font-size: 0.9rem;
    margin: 0;
}

/* ---- Header, search, misc ---------------------------------------------- */

/*
 * mini.css fixes the header at 3.1875rem with overflow-y:hidden, and styles
 * nav links as display:block. Inside a header the nav therefore stacks below
 * the title and is clipped away, leaving a bordered strip with nothing in it.
 * Release the height and lay the header out as a row instead.
 */
body > header {
    height: auto;
    overflow: visible;
    white-space: normal;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1.5rem;
    padding: 0.75rem 1rem;
}

body > header h1 {
    font-size: 1.5rem;
    margin: 0;
    flex: 0 0 auto;
}

body > header nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
}

body > header nav a,
body > header nav a:visited {
    display: inline-block;
    padding: 0.25rem 0;
    margin: 0;
    border-radius: 0;
    background: none;
}

body > header nav a:hover,
body > header nav a:focus {
    background: none;
    text-decoration: underline;
}

#search {
    margin: 0 0 2rem;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: none;
}

#search form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

#search input[type="text"] {
    flex: 1 1 20rem;
    max-width: 100%;
}

#search label {
    font-weight: 600;
}

main > h1 {
    margin: 1rem 0;
}

/* An empty <h1> should not reserve vertical space. */
main > h1:empty {
    display: none;
    margin: 0;
}

footer.wrapper {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--secondary-border-color, #ddd);
    font-size: 0.85rem;
    color: var(--secondary-fore-color, #444);
}

@media (max-width: 40rem) {
    .detail th[scope="row"] {
        width: auto;
    }
}

/* ---- Locator map ------------------------------------------------------- */

/*
 * Shown on business pages that have a geocoded address. Leaflet needs an
 * explicit height on its container or it renders zero pixels tall.
 */
#map {
    height: 20rem;
    margin: 0 0 1.5rem;
    border: 1px solid var(--secondary-border-color, #ddd);
    border-radius: var(--universal-border-radius, 2px);
    background: var(--secondary-back-color, #f0f0f0);
}

@media (max-width: 40rem) {
    #map {
        height: 14rem;
    }
}

/* ---- Document structure ------------------------------------------------ */

/*
 * The site name is branding, not the heading of the page's content, so it is a
 * paragraph styled to look like a title rather than a second <h1> competing
 * with the one that names the business.
 */
.sitename {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.sitename a {
    text-decoration: none;
}

/*
 * A one-line answer to "is it active, what is it, where is it", directly under
 * the business name.
 */
.summary {
    font-size: 1.05rem;
    color: var(--secondary-fore-color, #444);
    margin: -0.25rem 0 1.5rem;
}

main section {
    margin: 0 0 2rem;
}

main section h2 {
    font-size: 1.15rem;
    margin: 0 0 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid var(--secondary-border-color, #ddd);
}

/*
 * Each table keeps a caption so it is labelled when read in isolation, but the
 * <h2> above it already says the same thing on screen.
 */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/*
 * The search form now follows the content rather than leading it.
 */
#search h2 {
    font-size: 1.15rem;
    margin: 0 0 0.5rem;
}

/*
 * The other businesses at one address. Often a few dozen of them, so they are
 * set in columns: a single column of fifty names pushes everything below the
 * fold for a list most readers only skim.
 */
ul.related {
    margin: 0;
    padding: 0;
    list-style: none;
    columns: 18rem;
    column-gap: 2rem;
}

ul.related li {
    margin: 0 0 0.25rem;
    /* Keeps a name from being split across the foot of one column and the head
     * of the next. */
    break-inside: avoid;
}

.truncated {
    margin: 0.75rem 0 0;
    font-size: 0.9rem;
    color: var(--secondary-fore-color, #444);
}

/* ---- Statewide map ----------------------------------------------------- */

#statewide-map {
    height: 32rem;
    margin: 0 0 1rem;
    border: 1px solid var(--secondary-border-color, #ddd);
    border-radius: var(--universal-border-radius, 2px);
    background: var(--secondary-back-color, #f0f0f0);
}

/*
 * The home page carries a preview rather than a working map, so it is shorter
 * and its pointer indicates that the whole thing is a link.
 */
.map-preview-link {
    display: block;
    text-decoration: none;
}

.map-preview-link #statewide-map {
    height: 22rem;
    cursor: pointer;
    margin-bottom: 0.5rem;
}

#map-status {
    margin: 0 0 2rem;
}

@media (max-width: 40rem) {
    #statewide-map {
        height: 20rem;
    }

    .map-preview-link #statewide-map {
        height: 15rem;
    }
}

/* ---- Map popups -------------------------------------------------------- */

/*
 * A location can hold hundreds of registrations -- one Fairfax address has 265
 * -- so the list scrolls rather than growing a popup taller than the map.
 */
.map-popup {
    max-width: 18rem;
}

.map-popup-count {
    margin: 0 0 0.5rem;
    font-weight: 600;
}

.map-popup ul {
    max-height: 14rem;
    overflow-y: auto;
    margin: 0;
    padding: 0 0 0 1rem;
}

.map-popup li {
    margin: 0 0 0.35rem;
    line-height: 1.3;
}

.map-popup .meta {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: var(--secondary-fore-color, #444);
}
