/* P3-010A: approved R7 paper homepage. Fullscreen retains the existing controls. */
/* Native fullscreen owns the entire viewport; restore the shared stable gutter on exit. */
html:has([data-home-gallery]:fullscreen) { scrollbar-gutter: auto; }

.home-main {
    display: grid;
    min-height: calc(100dvh - var(--aper-header-clearance) - var(--aper-footer-clearance));
    padding: 26px var(--aper-page-gutter, 120px) calc(var(--aper-footer-clearance) + 14px);
    place-items: center;
}

.home-gallery:not(:fullscreen) {
    position: relative;
    inset: auto;
    width: 100%;
    overflow: visible;
    background: transparent;
}

.home-gallery:not(:fullscreen) .home-gallery__slides { position: relative; height: auto; }
.home-gallery:not(:fullscreen) .home-slide {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    align-items: start;
    gap: clamp(36px, 3.4vw, 120px);
    height: auto;
    padding: 0;
}
.home-gallery:not(:fullscreen) .home-slide.is-active { position: relative; }
.home-gallery:not(:fullscreen) .home-slide__media {
    display: block;
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    margin: 0;
    text-align: right;
}
.home-slide__frame { position: relative; width: fit-content; margin-left: auto; line-height: 0; }
/* Owner-approved portrait A: center the visible text/photo pair, not empty tracks. */
.home-gallery:not(:fullscreen) .home-slide.is-portrait-pair {
    grid-template-columns: var(--aper-home-portrait-copy-width) var(--aper-home-portrait-media-width);
    column-gap: clamp(36px, 3.4vw, 56px);
    justify-content: center;
}
.home-gallery:not(:fullscreen) .home-slide.is-portrait-pair .home-slide__frame { margin-left: 0; }
.home-gallery:not(:fullscreen) .home-slide__media img {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 62dvh;
    border: 1px solid var(--aper-color-divider);
    border-radius: 0;
    box-shadow: none;
    object-fit: contain;
}
.home-gallery:not(:fullscreen) .home-slide__target { inset: 0; cursor: pointer; touch-action: pan-y; }
.home-slide__place {
    margin-top: 6px;
    color: var(--aper-color-text-muted);
    font: 100 13.6px/20.4px var(--aper-font-caption);
    font-synthesis: none;
    letter-spacing: .5px;
    overflow-wrap: anywhere;
    text-align: right;
}
.home-gallery:not(:fullscreen) .home-slide__caption {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    /* Approved panorama exception: keep one body line and its controls usable. */
    min-height: var(--aper-home-min-caption-height, 0px);
    height: var(--aper-home-media-height, auto);
    padding: 0;
    margin: 0;
    overflow: hidden;
    text-align: left;
}
.home-gallery:not(:fullscreen) .home-slide__caption h1,
.home-gallery:not(:fullscreen) .home-slide__caption p {
    color: var(--aper-color-text);
    font-family: var(--aper-font-caption);
    font-weight: 100;
    font-synthesis: none;
    text-align: left;
}
.home-gallery:not(:fullscreen) .home-slide__caption .home-slide__kicker {
    margin: 0 0 10px;
    color: var(--aper-color-accent, #9f3225);
    font: 300 12px/18px var(--aper-font-ui);
    letter-spacing: 1px;
    text-transform: uppercase;
}
.home-gallery:not(:fullscreen) .home-slide__caption h1 {
    display: -webkit-box;
    margin: 0 0 12px;
    overflow: hidden;
    font-size: 13.6px;
    line-height: 20.4px;
    letter-spacing: .5px;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.home-gallery:not(:fullscreen) .home-slide__caption .home-slide__body {
    display: -webkit-box;
    margin: 0 0 10px;
    overflow: hidden;
    font-size: 12px;
    line-height: 18px;
    letter-spacing: normal;
    text-align: justify;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--aper-home-copy-lines, 7);
}
.home-gallery:not(:fullscreen) .home-slide__caption .home-slide__translation {
    display: -webkit-box;
    margin: 0 0 14px;
    overflow: hidden;
    color: var(--aper-color-text-muted);
    font-size: 12px;
    line-height: 18px;
    letter-spacing: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.home-slide__controls-slot { height: 32px; }
.home-gallery:not(:fullscreen) .home-gallery__controls {
    position: absolute;
    top: var(--aper-home-controls-top, 0px);
    left: var(--aper-home-controls-left, 0px);
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 32px;
}
.home-gallery:not(:fullscreen) .gallery-control {
    position: relative;
    inset: auto;
    width: 32px;
    height: 32px;
    color: var(--aper-color-text);
    border: 1px solid rgba(34, 29, 22, .5);
    border-radius: 50%;
    opacity: 1;
    transform: none;
}
.home-gallery__count {
    color: var(--aper-color-text-muted);
    font: 300 12px/18px var(--aper-font-ui);
    letter-spacing: 1px;
    white-space: nowrap;
}
.home-gallery:not(:fullscreen) .gallery-actions {
    position: absolute;
    top: var(--aper-active-media-actions-top, 8px);
    left: var(--aper-active-media-actions-right, calc(100% - 8px));
    gap: 7px;
    opacity: 1;
    pointer-events: auto;
}
.home-gallery:not(:fullscreen) .gallery-action {
    width: 30px;
    height: 30px;
    color: #f4efe7;
    background: rgba(23, 20, 16, .3);
    border: 1px solid rgba(244, 239, 231, .58);
    border-radius: 50%;
    opacity: 1;
}
.home-gallery:not(:fullscreen) .gallery-action svg { width: 17px; height: 17px; }
.home-gallery.is-single .home-gallery__controls { display: none; }
.home-gallery:fullscreen .home-slide__media { margin: 0; }
.home-gallery:fullscreen .home-slide__frame { display: contents; }
.home-gallery:fullscreen .home-slide__place,
.home-gallery:fullscreen .home-slide__kicker,
.home-gallery:fullscreen .home-slide__controls-slot,
.home-gallery:fullscreen .home-gallery__count { display: none; }
.home-gallery:fullscreen .home-slide__caption { color: #f4efe7; }
.home-gallery:fullscreen .home-slide__caption p { color: inherit; }
.home-gallery:fullscreen .gallery-actions {
    top: calc(var(--aper-top-clearance, env(safe-area-inset-top, 0px)) + 12px);
    right: var(--aper-page-gutter, 24px);
}

@media (min-width: 701px) and (max-width: 1200px) and (orientation: landscape) {
    .home-gallery:not(:fullscreen) .home-slide { gap: 32px; }
    .home-gallery:not(:fullscreen) .home-slide__media img { max-height: 56dvh; }
}
@media (max-width: 1100px) and (orientation: portrait) {
    .home-main { padding: 26px var(--aper-page-gutter, 40px) 92px; }
    .home-gallery:not(:fullscreen) .home-slide { display: flex; flex-direction: column; gap: 0; }
    .home-gallery:not(:fullscreen) .home-slide__media { order: -1; }
    .home-gallery:not(:fullscreen) .home-slide__frame { width: 100%; margin: 0; }
    .home-gallery:not(:fullscreen) .home-slide__media img {
        width: 100%;
        height: clamp(150px, calc((100svh - 320px - var(--aper-top-clearance, 0px)) / 2), 30svh);
        max-height: none;
        object-fit: cover;
    }
    .home-gallery:not(:fullscreen) .home-slide__caption { margin-top: 18px; }
}
@media (max-width: 700px) and (orientation: portrait) {
    .home-main { padding: 24px var(--aper-page-gutter, 18px) 94px; }
    .home-gallery:not(:fullscreen) .home-slide__media img {
        height: clamp(144px, calc((100svh - 312px - var(--aper-top-clearance, 56px)) / 2), 24svh);
    }
    .home-gallery:not(:fullscreen) .home-slide__caption { margin-top: 14px; }
    .home-gallery:not(:fullscreen) .home-slide__caption .home-slide__translation { display: none; }
    .home-slide__controls-slot { height: 26px; }
    .home-gallery:not(:fullscreen) .home-gallery__controls { height: 26px; gap: 7px; }
    .home-gallery:not(:fullscreen) .gallery-control { width: 26px; height: 26px; }
}
@media (max-width: 940px) and (orientation: landscape) and (max-height: 520px) {
    .home-main { padding: 18px var(--aper-page-gutter, 22px) 52px; }
    .home-gallery:not(:fullscreen) .home-slide { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 20px; }
    .home-gallery:not(:fullscreen) .home-slide__media img { max-height: calc(100svh - var(--aper-top-clearance, 24px) - 150px); }
    .home-gallery:not(:fullscreen) .home-slide__caption .home-slide__kicker { margin-bottom: 5px; }
    .home-gallery:not(:fullscreen) .home-slide__caption h1 { margin-bottom: 6px; }
    .home-gallery:not(:fullscreen) .home-slide__caption .home-slide__body { margin-bottom: 6px; }
    .home-gallery:not(:fullscreen) .home-slide__caption .home-slide__translation { display: none; }
    .home-slide__controls-slot { height: 24px; }
    .home-gallery:not(:fullscreen) .home-gallery__controls { height: 24px; gap: 6px; }
    .home-gallery:not(:fullscreen) .gallery-control { width: 24px; height: 24px; }
}
@media (prefers-reduced-motion: reduce) {
    .home-slide { transition: none; }
}
