/* Custom layout for "How to resize an IKEA picture frame" and
   "Mortar iPad Dock" — step-by-step grids inside raw `html` blocks
   (see docs/CONTENT_FORMAT.md, section 2.9). Served via customCssFile: "ikea".
   content.ts wraps consecutive <p class="img"> runs in a .tiles div at
   render time, so headings/intro text/<br> breaks stay plain block
   siblings and never interleave with the tile grid's auto-placement. */

.layout {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto 60px;
}

main.posting .layout h2 {
    max-width: 640px;
    width: 100%;
    margin: 0 auto 24px;
}

main.posting .layout > p:not(.img) {
    max-width: 640px;
    width: 100%;
    font-size: 18px;
    font-weight: 300;
    line-height: 1.8;
    letter-spacing: 0.5px;
    opacity: 0.8;
    margin: 0 auto 16px;
}

.layout br {
    display: none;
}

.layout .tiles {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
}

/* Quantity queries (CSS-only, no JS/resize-listener needed): for groups
   whose item count doesn't divide evenly into the default 4-per-row basis,
   widen the basis so 3 wrap per row instead, avoiding a lone odd last row
   (5 items -> 3+2, 9 items -> 3+3+3). */
.layout .tiles:has(> p.img:nth-child(5):last-child) > p.img,
.layout .tiles:has(> p.img:nth-child(9):last-child) > p.img {
    flex-basis: 340px;
}

.layout p.img {
    position: relative;
    flex: 1 1 260px;
    max-width: 590px;
    aspect-ratio: 1;
    overflow: hidden;
    background: #ececec;
    margin: 0;
}

.layout p.img img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.layout p.img span {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 20px 10px 8px;
    background: linear-gradient(to top, rgba(0,0,0,0.75), rgba(0,0,0,0));
    color: #fff;
    font-size: 12px;
    font-weight: 300;
    line-height: 1.5;
    letter-spacing: 0.3px;
}

.layout p.img strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    margin-right: 4px;
    border-radius: 8px;
    border: 1px solid #fff;
    background: none;
    color: #fff;
    font-size: 10px;
    font-weight: 400;
}

