/* =============================================================
   buildlog_gallery.css
   Build page: photo gallery, photo viewer, portrait-aware hero,
   series pager, owner photo manager, share popup tweaks.
   Loaded after the other buildlog*.css files.
   ============================================================= */

:root {
    --bl-accent: #ff7800;
    --bl-focus: #ffbf47;
}

/* ---------------------------------------------------------------
   1. GALLERY (Masonry columns, sized from real photo dimensions)
   --------------------------------------------------------------- */
.bl-gallery {
    --bl-gap: 16px;
    --bl-cols: 3;
    margin: 2rem 0 1.5rem;
}

@media (max-width: 991.98px) {
    .bl-gallery { --bl-cols: 2; }
}

@media (max-width: 575.98px) {
    .bl-gallery { --bl-gap: 10px; }
}

/* Hidden until Masonry has placed the tiles, so nothing visibly jumps. */
.bl-grid {
    position: relative;
    visibility: hidden;
}

.bl-grid.is-ready,
.bl-grid.is-fallback {
    visibility: visible;
}

/* Fallback if the Masonry script is blocked: plain CSS columns. */
.bl-grid.is-fallback {
    column-count: var(--bl-cols);
    column-gap: var(--bl-gap);
}

.bl-grid.is-fallback .bl-sizer,
.bl-grid.is-fallback .bl-gutter {
    display: none;
}

.bl-grid.is-fallback .bl-tile {
    width: auto;
    break-inside: avoid;
}

.bl-sizer,
.bl-tile {
    width: calc((100% - (var(--bl-cols) - 1) * var(--bl-gap)) / var(--bl-cols));
}

.bl-gutter {
    width: var(--bl-gap);
}

.bl-sizer,
.bl-gutter {
    height: 0;
    margin: 0;
    padding: 0;
}

.bl-tile {
    position: relative;
    margin: 0 0 var(--bl-gap);
    border-radius: 12px;
    overflow: hidden;
    background: #e9e9ec;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 8px 22px -12px rgba(0, 0, 0, .35);
    transition: box-shadow .25s ease;
}

.bl-tile:hover {
    box-shadow: 0 1px 2px rgba(0, 0, 0, .1), 0 14px 30px -12px rgba(0, 0, 0, .45);
}

.bl-grid.is-ready .bl-tile {
    animation: blTileIn .45s ease both;
    animation-delay: calc(var(--i, 0) * 45ms);
}

@keyframes blTileIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

.bl-tile__open {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
    position: relative;
    color: inherit;
}

.bl-tile__open:focus-visible {
    outline: 3px solid var(--bl-focus);
    outline-offset: -3px;
}

/* The box reserves the exact space before the photo loads.
   --ar is the real width/height ratio (limited to a sensible range). */
.bl-tile__media {
    display: block;
    position: relative;
    aspect-ratio: var(--ar, 1.5);
    overflow: hidden;
    container-type: size;
}

.bl-tile__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .6s cubic-bezier(.22, 1, .36, 1);
}

.bl-tile__open:hover .bl-tile__img:not([class*="bl-rot-"]) {
    transform: scale(1.035);
}

/* Photos stored sideways (EXIF orientation 6 / 8 / 3) are turned upright. */
.bl-rot-90,
.bl-rot-270 {
    inset: auto;
    top: 50%;
    left: 50%;
    width: 100cqh;
    height: 100cqw;
}

.bl-rot-90  { transform: translate(-50%, -50%) rotate(90deg); }
.bl-rot-270 { transform: translate(-50%, -50%) rotate(270deg); }
.bl-rot-180 { transform: rotate(180deg); }

.bl-tile__zoom {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(10, 10, 14, .62);
    color: #fff;
    opacity: 0;
    transform: scale(.9);
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
}

.bl-tile__open:hover .bl-tile__zoom,
.bl-tile__open:focus-visible .bl-tile__zoom {
    opacity: 1;
    transform: none;
}

@media (hover: none) {
    .bl-tile__zoom { display: none; }
}

/* Captions sit on the photo. The gradient keeps the text readable on bright shots. */
.bl-tile__cap {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1.9rem .9rem .7rem;
    color: #fff;
    font-size: .875rem;
    line-height: 1.35;
    text-align: left;
    background: linear-gradient(to top,
        rgba(8, 8, 12, .9) 0%,
        rgba(8, 8, 12, .82) 60%,
        rgba(8, 8, 12, 0) 100%);
    pointer-events: none;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------------------------------------------------------------
   2. PHOTO VIEWER (full-screen modal)
   --------------------------------------------------------------- */
.bl-lightbox .modal-content {
    background: #0a0a0d;
    color: #fff;
    border: 0;
    border-radius: 0;
    height: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.bl-lb__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .55rem .9rem;
}

.bl-lb__count {
    margin: 0;
    font-size: .9rem;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, .82);
}

.bl-lb__btn {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .22);
    background: rgba(255, 255, 255, .1);
    color: #fff;
    cursor: pointer;
    transition: background .15s ease;
}

.bl-lb__btn:hover {
    background: rgba(255, 255, 255, .22);
}

.bl-lb__btn:focus-visible,
.bl-lb__thumb:focus-visible {
    outline: 3px solid var(--bl-focus);
    outline-offset: 2px;
}

.bl-lb__stage {
    position: relative;
    min-height: 0;
    overflow: hidden;
    container-type: size;
    touch-action: pinch-zoom;
    -webkit-user-select: none;
    user-select: none;
}

.bl-lb__slide {
    position: absolute;
    inset: 0;
    will-change: transform, opacity;
}

.bl-lb__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    -webkit-user-drag: none;
}

.bl-lb__img.bl-rot-90,
.bl-lb__img.bl-rot-270 {
    inset: auto;
}

.bl-lb__nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    margin-top: -22px;
}

.bl-lb__nav--prev { left: .75rem; }
.bl-lb__nav--next { right: .75rem; }

.bl-lb__caption {
    margin: 0 auto;
    padding: .6rem 1rem .4rem;
    max-width: 60ch;
    text-align: center;
    font-size: .95rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, .92);
}

.bl-lb__caption[hidden] {
    display: none;
}

.bl-lb__strip {
    display: flex;
    gap: 8px;
    padding: .55rem .9rem 1rem;
    overflow-x: auto;
    justify-content: safe center;
    scrollbar-width: thin;
}

.bl-lb__strip:empty {
    display: none;
}

.bl-lb__thumb {
    flex: 0 0 auto;
    width: 68px;
    height: 50px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    background: #222;
    opacity: .55;
    cursor: pointer;
    transition: opacity .15s ease, border-color .15s ease;
}

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

.bl-lb__thumb:hover { opacity: .85; }

.bl-lb__thumb.is-active {
    opacity: 1;
    border-color: var(--bl-accent);
}

@media (max-width: 575.98px) {
    .bl-lb__strip { display: none; }
    .bl-lb__nav--prev { left: .4rem; }
    .bl-lb__nav--next { right: .4rem; }
    .bl-lb__btn { width: 40px; height: 40px; }
    .bl-lb__nav { margin-top: -20px; }
}

@media (prefers-reduced-motion: reduce) {
    .bl-grid.is-ready .bl-tile { animation: none; }
    .bl-tile__img,
    .bl-tile__zoom,
    .bl-lb__thumb { transition: none; }
}

/* ---------------------------------------------------------------
   3. HERO: portrait covers are shown whole instead of cropped
   --------------------------------------------------------------- */
.build-hero__bg {
    display: none;
}

.build-hero--portrait .build-hero__bg {
    display: block;
    position: absolute;
    top: -30px;
    left: -30px;
    width: calc(100% + 60px);
    height: calc(100% + 60px);
    object-fit: cover;
    filter: blur(26px) brightness(.55) saturate(1.2);
}

.build-hero--portrait .build-hero__img {
    position: relative;
    z-index: 1;
    object-fit: contain;
    object-position: center;
}

.build-hero--portrait .build-hero__overlay {
    z-index: 2;
}

/* ---------------------------------------------------------------
   4. SERIES PAGER (previous / next part)
   --------------------------------------------------------------- */
.bl-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 1.5rem 0;
}

.bl-pager__link {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: .9rem 1.1rem;
    border: 1px solid #d3d3d9;
    border-radius: 12px;
    background: #fff;
    color: #14141a;
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.bl-pager__link:hover,
.bl-pager__link:focus-visible {
    border-color: var(--bl-accent);
    box-shadow: 0 6px 18px -10px rgba(0, 0, 0, .35);
    color: #14141a;
    text-decoration: none;
}

.bl-pager__link:focus-visible {
    outline: 3px solid var(--bl-focus);
    outline-offset: 2px;
}

.bl-pager__link--next {
    grid-column: 2;
    text-align: right;
}

.bl-pager__label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #5a5a64;
}

.bl-pager__title {
    font-weight: 600;
    line-height: 1.3;
}

@media (max-width: 575.98px) {
    .bl-pager { grid-template-columns: 1fr; }
    .bl-pager__link--next { grid-column: 1; }
}

/* ---------------------------------------------------------------
   5. EDITOR: sticky save bar, status, toast
   --------------------------------------------------------------- */
#buildsubmission .bed-actions {
    position: sticky;
    bottom: 0;
    z-index: 30;
    background: rgba(255, 255, 255, .96);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px));
}

.bed-status {
    font-size: 13px;
    color: #4a4a47;
}

.bed-status.is-dirty::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 7px;
    border-radius: 50%;
    background: #c26a00;
}

.bed-status.is-error {
    color: #a02a1e;
    font-weight: 600;
}

.bed-discard {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a18;
}

.bed-discard[hidden] {
    display: none;
}

.bed-discard .bed-btn-cancel {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 13px;
}

.bl-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    z-index: 2000;
    max-width: calc(100vw - 32px);
    padding: 11px 18px;
    border-radius: 10px;
    background: #14141a;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

/* ---------------------------------------------------------------
   7. SHARE POPUP
   --------------------------------------------------------------- */
.new-build-modal .modal-header .modal-title {
    color: #fff;
}

.new-build-modal .modal-footer {
    flex-direction: column;
    gap: .6rem;
}

.new-build-modal .btn-maybe-later {
    min-height: 44px;
    padding: .5rem 1.4rem;
}

/* Facebook blue #1877f2 gives white text only 4.2:1; this shade passes AA (4.5:1). */
.new-build-modal .btn-facebook { background: #1664d9; }
.new-build-modal .btn-facebook:hover { background: #0c4fb0; }

/* Next steps inside the "Your build is live" popup */
.new-build-modal .next-steps {
    margin: 16px 0 18px;
    padding: 14px 16px;
    border: 1px solid #d1cfc9;
    border-radius: 10px;
    background: #f7f6f3;
    text-align: left;
}
.new-build-modal .next-steps__title { font-size: 1rem; font-weight: 700; margin: 0 0 4px; }
.new-build-modal .next-steps__text  { margin: 0 0 10px; font-size: 14px; color: #3d3d3a; }
.new-build-modal .next-steps__buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.new-build-modal .btn-email { background: #c5221f; }          /* white on #ea4335 was 3.6:1 */
.new-build-modal .btn-email:hover { background: #a61b19; }
.new-build-modal .btn-copy.copied { background: #1e7e34; }     /* white on #28a745 was 3.3:1 */
.new-build-modal .skip-text { color: #55575c; }