/* Title, featured image, map and venue line are one grid — the markup order is
   fixed and the two layouts want different ones, so `grid-template-areas` does
   the reordering. See the comment in single-mg_event.php.

   Phone: the image takes half the row with the title and the venue line beside
   it, and the map drops below at full width and 60vh tall — a map read by
   pinching needs room to be worth pinching.
   From 40em: exactly what this page has always been — title across the top,
   the small square image beside a wide map, venue line under both. */
.mg-exhibit__intro {
    display: grid;
    /* 42%, not half: at half the row the photograph outweighed the title next
       to it, and the title is what the reader came for. */
    grid-template-columns: 42% minmax(0, 1fr);
    grid-template-areas:
        "image title"
        "image subtitle"
        "map   map";
    align-items: start;
    column-gap: 1rem;
    /* No row-gap, deliberately: an exhibition with no map — or no venue line —
       leaves that area empty, and a row gap would hold its space open anyway.
       Every gap here is an item's own bottom margin instead. */
    row-gap: 0;
    margin: 0 0 1.75rem;
}

.mg-exhibit__title    { grid-area: title; }
.mg-exhibit__image    { grid-area: image; }
.mg-exhibit__map      { grid-area: map; }
.mg-exhibit__subtitle { grid-area: subtitle; }

/* Nothing to sit beside: the text goes back to the full width it has at every
   other size, and the map keeps the row below to itself. */
.mg-exhibit__intro--no-image {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
        "title"
        "subtitle"
        "map";
}

.mg-exhibit__intro .mg-exhibit__title {
    margin: 0 0 .45rem;
    font-size: clamp(1.2rem, 5vw, 2.4rem);
}

/* Beside the image, both read as a caption block — centring half a column
   against a square photograph reads as a mistake. */
.mg-exhibit__intro:not(.mg-exhibit__intro--no-image) .mg-exhibit__title,
.mg-exhibit__intro:not(.mg-exhibit__intro--no-image) .mg-exhibit__subtitle {
    text-align: left;
}

@media (min-width: 40em) {
    .mg-exhibit__intro {
        grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
        grid-template-areas:
            "title    title"
            "image    map"
            "subtitle subtitle";
        align-items: stretch;
    }

    /* One of the pair is missing: a single centred column, as before. */
    .mg-exhibit__intro--no-image {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "title"
            "map"
            "subtitle";
    }

    .mg-exhibit__intro--no-map {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "title"
            "image"
            "subtitle";
    }

    /* Whole shorthand, not `margin-inline` — the base rule below sets `margin`
       and mixing a logical longhand with a physical shorthand is a cascade
       question nobody should have to answer twice. */
    .mg-exhibit__intro--no-image .mg-exhibit__map,
    .mg-exhibit__intro--no-map .mg-exhibit__image {
        width: 100%;
        max-width: 28rem;
        margin: 0 auto 1.25rem;
    }

    .mg-exhibit__intro .mg-exhibit__title {
        margin: 0 0 1.5rem;
        font-size: clamp(1.6rem, 6vw, 2.4rem);
        text-align: center;
    }

    .mg-exhibit__intro .mg-exhibit__subtitle {
        margin: 0;
        text-align: center;
    }

    /* Both present: the square is dropped so the map fills the row's full
       width and takes its height from the image beside it. */
    .mg-exhibit__intro:not(.mg-exhibit__intro--no-image):not(.mg-exhibit__intro--no-map) .mg-exhibit__map {
        aspect-ratio: auto;
        height: 100%;
    }
}

.mg-exhibit__image {
    aspect-ratio: 1 / 1;
    border-radius: 4px;
    overflow: hidden;
    margin: 0 0 1.25rem;
}

.mg-exhibit__image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mg-exhibit__map {
    /* Phone: full width, 40vh. Restored to a square at 40em by the block
       above, where it shares a row with the image again. */
    height: 40vh;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--mg-line);
    margin: 0 0 1.25rem;
}

@media (min-width: 40em) {
    .mg-exhibit__map {
        aspect-ratio: 1 / 1;
        height: auto;
    }
}

.mg-exhibit__map iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.mg-exhibit__meta {
    text-align: center;
    margin-bottom: 1.75rem;
}

/* Not flex: the flag has to sit inline right after the place name and wrap
   with it, rather than being pushed to the end of the line as its own item. */
.mg-exhibit__subtitle {
    margin: 0 0 1.25rem;
    text-align: center;
    color: var(--mg-ink);
    font-family: var(--mg-serif);
    font-style: italic;
    font-size: clamp(1.05rem, 3vw, 1.35rem);
}

/* The run of dates sits on its own line, under the venue. */
.mg-exhibit__dates {
    display: block;
    margin-top: .35rem;
}

/* A single-month run is unambiguous on the timeline, and above the phone
   breakpoint the subtitle does not repeat it. The exact complement of the rule
   that hides the timeline in css/exhibitions.css — move one, move the other,
   or a March show on a phone states no dates at all. */
@media (min-width: 768px) {
    .mg-exhibit__dates--phone-only {
        display: none;
    }
}

.mg-exhibit__flag {
    display: inline-block;
    font-size: 1.2em;
    line-height: 1;
    vertical-align: -.08em;
    font-style: normal;
}

.mg-exhibit__timeline {
    max-width: 100%;
    margin: 0 auto;
    text-align: left;
    border-bottom: 0;
}

/* Scroll stays, its bar doesn't — the pills already signal the overflow. */
.mg-exhibit__timeline .mg-ex-timeline__scroll {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.mg-exhibit__timeline .mg-ex-timeline__scroll::-webkit-scrollbar {
    display: none;
}

.mg-exhibit__timeline .mg-ex-pill.is-current {
    cursor: default;
}

.mg-exhibit__timeline .mg-ex-pill.is-adjacent {
    background: var(--mg-field);
    color: var(--mg-ink-soft);
    border-color: var(--mg-field);
    text-decoration: none;
}

.mg-exhibit__timeline .mg-ex-pill.is-adjacent:hover {
    color: var(--mg-ink);
    background: var(--mg-line);
}

.mg-exhibit__body {
    margin: 0 0 1.75rem;
}

.mg-exhibit__actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 3rem 0 0;
    text-align: center;
}

/* Mirrors the rule above the products heading, so the buttons read as their own block. */
.mg-exhibit-products + .mg-exhibit__actions {
    margin-top: 0;
    padding-top: 3rem;
    border-top: 1px solid var(--mg-line);
}

.mg-exhibit__link {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .8rem 1.8rem;
    border: 1px solid var(--mg-ink);
    background: var(--mg-ink);
    color: var(--mg-paper);
    font-family: var(--mg-fell);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.mg-exhibit__link:hover {
    background: var(--mg-paper);
    color: var(--mg-ink);
}

.mg-exhibit__link-icon {
    width: .9em;
    height: .9em;
}

.mg-exhibit-leave__actions {
    display: flex;
    gap: .75rem;
    margin-top: 1.5rem;
}

.mg-exhibit-leave__continue,
.mg-exhibit-leave__cancel {
    flex: 1 1 0;
    padding: .7rem 1rem;
    font-family: var(--mg-fell);
    text-transform: uppercase;
    letter-spacing: .1em;
    font-size: .8rem;
    cursor: pointer;
    border-radius: 0;
}

.mg-exhibit-leave__continue {
    background: var(--mg-ink);
    color: var(--mg-paper);
    border: 1px solid var(--mg-ink);
}

.mg-exhibit-leave__continue:hover {
    background: transparent;
    color: var(--mg-ink);
}

.mg-exhibit-leave__cancel {
    background: none;
    border: 1px solid var(--mg-line);
    color: var(--mg-ink-soft);
}

.mg-exhibit-leave__cancel:hover {
    border-color: var(--mg-ink);
    color: var(--mg-ink);
}

.mg-exhibit-products {
    margin: 3rem 0 0;
    padding-top: 3rem;
    border-top: 1px solid var(--mg-line);
}

.mg-exhibit-products__heading {
    margin: 0 0 1.75rem;
    font-size: .8rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: .18em;
    text-indent: .18em;
    color: var(--mg-ink-soft);
    text-align: center;
}

.woocommerce ul.products.mg-exhibit-products__grid {
    display: grid;
    /* Two up on phones. */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: center;
    gap: 1.25rem;
    margin: 0 0 3rem;
    padding: 0;
    list-style: none;
}

/* Woo's clearfix becomes a grid ITEM and eats a column. */
.woocommerce ul.products.mg-exhibit-products__grid::before,
.woocommerce ul.products.mg-exhibit-products__grid::after {
    content: none;
}

.woocommerce ul.products.mg-exhibit-products__grid li.product {
    width: auto;
    margin: 0;
    float: none;
}

@media (min-width: 48em) {
    /* Tracks sized, not 1fr: a one- or two-item show centres its partial row
       instead of stretching those tiles across the full width. */
    .woocommerce ul.products.mg-exhibit-products__grid {
        grid-template-columns: repeat(auto-fit, minmax(12rem, 15rem));
        gap: 3%;
    }
}

.woocommerce ul.products.mg-exhibit-products__grid li.product img {
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

/* The phone, last in the file on purpose: every rule in here is one class
   deep and so is the rule it overrides — source order is the only thing
   deciding between them. Keep this block at the bottom. */
@media (max-width: 767px) {
    /* The mini timeline is all this wrapper holds, and css/exhibitions.css
       takes the timeline off the phone — without this its margin is all that
       is left. */
    .mg-exhibit__meta {
        margin-bottom: 0;
    }

    /* No rules across the page. On a wide screen a hairline separates three
       roomy blocks; on a phone the same three blocks are already one column
       apart, and the lines only chop a short page into shorter pieces. The
       padding they were holding open becomes plain margin. */
    .mg-exhibit-products,
    .mg-exhibit-products + .mg-exhibit__actions {
        margin-top: 2.25rem;
        padding-top: 0;
        border-top: 0;
    }
}
