/* /compare (templates/compare.jinja): the mountain picker, then the stats
   table, distribution charts and hardest-trails table, each one column per
   mountain. */

/* Laid out like the search and rankings pages (panes.css): the picker and
   sidebar ad slot in the left #sidebar pane (filters_sidebar.jinja), the
   comparison in the right #content pane */

/* "Compare Mountains" runs about as wide as "Mountain Rankings", so its
   title shrinks as soon in a narrow pane (see panes.css) */
html {
    --title-ems: 10.2;
}

/* capped like the rankings list (rankings.css), so the two columns stay a
   readable width in a wide pane */
.compare {
    max-width: 1000px;
}

.compare > * {
    margin-bottom: 32px;
}

/* page.css's 3rem h1 and 1.75rem h2; h3 matches the map pages' panel
   headings, which the distribution charts come from */
.compare h2 {
    margin-bottom: 16px;
}

/* the mountain names over the distribution charts: bold (600) like the
   names heading the stats and hardest-trails tables */
.compare h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
}

/* PICKER -- the two boxes stacked in the sidebar, each with its label and
   any "No mountain matches" error, then the button: boxes like the search
   page's search bar (search.css), labels and button like the filters'
   (form.css, panes.css) */
.compare-picker {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.compare-picker label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.picker-label {
    font-size: 1.2rem;
    color: var(--color-primary);
}

.compare-picker input {
    height: 40px;
    padding: 0 16px;
    border-radius: 4px;
    border: 2px solid var(--color-secondary);
    font: inherit;
    font-size: 1.2rem;
}

.compare-picker input[type="search"] {
    min-width: 0;
    background-color: transparent;
    color: var(--color-primary);
}

.compare-picker input[type="search"]::placeholder {
    color: var(--color-tertiary);
}

.compare-picker input[type="submit"] {
    width: 100%;
    font-weight: bold;
    color: white;
    border-color: var(--color-accent-dark);
    cursor: pointer;
}

.picker-error {
    color: red;
}

/* TABLES -- like the trail and lift rankings tables (trail_rankings.css):
   a 2px primary-colored rule under the header, then alternately shaded
   rows rather than grid lines */

/* fixed layout so both mountains' columns are the same width, however
   long one side's values or trail names run */
.compare-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 1.25rem;
    color: var(--color-primary);
}

.compare-table th,
.compare-table td {
    padding: 8px;
    text-align: left;
    vertical-align: middle;
}

/* trail_rankings.css's shade */
.compare-table tbody tr:nth-child(even) {
    background-color: rgb(243, 242, 242);
}

.compare-table thead th {
    font-size: 1.5rem;
    font-weight: 600;
    vertical-align: bottom;
}

.compare-table thead > tr > * {
    border-bottom: 2px solid var(--color-primary);
}

.compare-table tbody th {
    font-weight: 600;
}

.compare-table td {
    font-weight: normal;
}

.compare-table td.better {
    font-weight: bold;
}

.compare-table a {
    color: var(--color-primary);
}

.compare-table tr > :first-child {
    width: 28%;
}

.compare-trails tr > :first-child {
    width: 50%;
}

/* fixed width so the scores after it line up down the column */
.trail-rank {
    display: inline-block;
    min-width: 2em;
    font-weight: 600;
}

/* the mountain names over the hardest trails match the ones over the
   distribution charts (.compare h3) rather than the stats table's larger,
   ruled header; doubled class to win over the phone layout's header size */
.compare-table.compare-trails thead th {
    font-size: 1.25rem;
    font-weight: 600;
}

.compare-table.compare-trails thead > tr > * {
    border-bottom: none;
}

.compare-stats thead a {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none;
}

/* twice the search page's size, shrinking with its column on windows too
   narrow for that. The box is held at 5:4 by aspect-ratio rather than the
   img's width/height attributes: those only set the ratio until the SVG
   loads, after which its own shape takes over, so a narrow mountain
   (Eaglecrest, AK) grew far taller than its column-mate. object-fit then
   fits the map inside the box */
.compare-stats .thumbnail {
    width: 100%;
    max-width: 250px;
    height: auto;
    aspect-ratio: 5 / 4;
    object-fit: contain;
    object-position: left bottom;
}

.mountain-location {
    font-size: 1.25rem;
    font-weight: normal;
    color: var(--color-tertiary);
}

.compare-table .icon {
    margin: 0 0 0 .4em;
}

/* rank / "None" stay regular weight and muted, even in a bolded cell --
   p.copy's tertiary text */
.compare-table .rank {
    display: block;
    font-size: 1rem;
    font-weight: normal;
    color: var(--color-tertiary);
}

/* how far ahead this side is, beside its value; smaller and regular
   weight, so the bolded value still reads first. Green (the site's
   beginner green) where it marks the better side, muted grey in a row
   where neither side is better (hike-tos) */
.compare-table .difference {
    margin-left: .5em;
    font-size: 1rem;
    font-weight: normal;
    color: var(--color-tertiary);
}

.compare-table td.better .difference {
    color: green;
}

.compare-table .pass {
    display: block;
}

/* a little air between a mountain's passes when it has several */
.compare-table .pass + .pass {
    margin-top: 6px;
}

/* exactly one line height (1lh), as in trail_rankings.css, so it sits in
   the row like the text beside it and never makes the line taller */
.compare-table .pass-icon {
    width: 1lh;
    height: 1lh;
    vertical-align: top;
    margin-right: .4em;
}

.trail-difficulty {
    display: inline-block;
    min-width: 4.5em;
}

.compare-note {
    margin-top: -16px;
}

/* DISTRIBUTION */

/* inset and split to match the hardest-trails table below it (two 50%
   columns whose cells pad their content 8px), so each mountain's chart
   lines up with its trails: the columns start 8px in and 8px past the
   middle */
.compare-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
    padding: 0 8px;
}

/* PHONES -- panes.css's breakpoint, where the panes stack */

@media screen and (max-width: 700px) {
    /* the joined panes reach the bottom of the screen even when there's
       too little to fill it (nothing picked yet), as panes.css does on
       desktop: the body fills the screen's height, main takes what the
       nav leaves, and the content pane's row takes what the picker
       leaves. dvh so it tracks the phone's browser bars */
    body {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        min-height: 100dvh;
    }
    main {
        flex: 1;
        /* page.css centers main with auto margins, which would shrink it
           to its content's width as a flex item */
        margin: 0;
        grid-template-rows: auto 1fr;
    }

    .compare > * {
        margin-bottom: 24px;
    }

    /* the stacked panes join here (panes.css), so the picker's bottom
       margin would double the sidebar's own bottom padding */
    .compare-picker {
        margin-bottom: 0;
    }

    /* stacked; inset like the table cells' 4px here */
    .compare-columns {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
        padding: 0 4px;
    }

    /* sized like the trail rankings page's phone cards (trail_rankings.css):
       1.1rem table text, labels included (the mountain names over the
       stats are brought down to match below, to fit their columns) */
    .compare-table {
        font-size: 1.1rem;
    }

    .compare-table th,
    .compare-table td {
        padding: 8px 4px;
    }

    /* wide enough for the longest unbreakable label word ("Difficulty";
       "Friendliness" can hyphenate, see compare.jinja), leaving the most
       room for the mountains' names and values */
    .compare-stats tr > :first-child {
        width: 32%;
    }

    /* under the value rather than squeezed in beside it */
    .compare-table .difference {
        display: block;
        margin-left: 0;
    }

    /* fit within the column but no taller than the search page's: a
       portrait map at the column's full width would be several times taller */
    .compare-stats .thumbnail {
        width: 100%;
        max-width: none;
        height: 100px;
        object-fit: contain;
        object-position: left bottom;
    }

    /* the columns are too narrow for 1.5rem names ("Killington" overran
       its column): table-sized, and a word that still doesn't fit wraps
       rather than running into the other mountain's name */
    .compare-stats thead th {
        font-size: 1.1rem;
        overflow-wrap: break-word;
    }

    .mountain-location {
        font-size: 1rem;
    }

    /* the trails line up by row anyway; the numbers just crowd the narrow
       columns */
    .trail-rank {
        display: none;
    }

    /* rank and score on one line, the trail name (and its icons) under
       them rather than squeezed in beside */
    .trail-difficulty {
        min-width: 0;
    }

    .trail-name {
        display: block;
    }
}
