/* EasyPlan Image Gallery
   Q&A/게시판의 공통 UI를 유지하면서 이미지 원본 비율 기반 Masonry 보드를 구성합니다. */

body.gallery-page {
    --gallery-text: #111827;
    --gallery-muted: #697386;
    --gallery-border: #e3e8ef;
    --gallery-surface: #ffffff;
    --gallery-soft: #f7f9fc;
    --gallery-accent: #2563eb;
}

body.gallery-page .navbar-brand::before {
    content: "G";
}

body.gallery-page > .container {
    width: min(100% - 32px, 1280px);
    max-width: 1280px;
}

.gallery-kicker {
    margin-bottom: 8px;
    color: #6d7f98;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .17em;
}

.gallery-hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    overflow: hidden;
    padding: 28px 30px;
    border: 1px solid #dfe7f1;
    border-radius: 18px;
    background:
        radial-gradient(circle at 88% 20%, rgba(37, 99, 235, .11), transparent 28%),
        radial-gradient(circle at 72% 90%, rgba(6, 182, 212, .08), transparent 32%),
        linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 15px 36px rgba(15, 23, 42, .06);
}

.gallery-hero::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, #2563eb, #06b6d4);
}

.gallery-hero h1,
.gallery-compose h1,
.gallery-view h1 {
    margin: 0;
    color: #101a2d;
    font-weight: 820;
    letter-spacing: -.035em;
}

.gallery-hero h1 {
    font-size: clamp(28px, 3vw, 38px);
}

.gallery-hero p {
    max-width: 760px;
    margin: 10px 0 0;
    color: #637086;
    font-size: 14px;
    line-height: 1.75;
}

.gallery-hero-action {
    min-width: 122px;
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.gallery-search-panel,
.gallery-form-card,
.gallery-view {
    border: 1px solid #e0e7f0;
    border-radius: 16px;
    background: rgba(255, 255, 255, .99);
    box-shadow: 0 10px 28px rgba(15, 23, 42, .045);
}

.gallery-search-panel {
    padding: 14px;
}

/*
 * 갤러리 목록의 기본 레이아웃은 JavaScript 실패 시에도 사용할 수 있는 Grid fallback입니다.
 * gallery-masonry.js가 활성화되면 각 카드의 실제 높이를 측정하여 현재 가장 짧은 열에
 * 순서대로 배치하는 shortest-column Masonry로 전환합니다.
 */
.gallery-masonry {
    --gallery-masonry-gap: 18px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--gallery-masonry-gap);
    align-items: start;
    width: 100%;
}

.gallery-masonry.gallery-masonry-ready {
    display: block;
    position: relative;
}

.gallery-masonry.gallery-masonry-ready .gallery-card {
    position: absolute;
    margin: 0;
}

.gallery-card {
    display: block;
    width: 100%;
    margin: 0;
    break-inside: auto;
    overflow: hidden;
    border: 1px solid #e1e7ef;
    border-radius: 15px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .055);
    transform: translateZ(0);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.gallery-card:hover {
    border-color: #c8d7ea;
    box-shadow: 0 15px 34px rgba(15, 23, 42, .10);
    transform: translateY(-3px);
}

.gallery-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.gallery-card-media {
    position: relative;
    overflow: hidden;
    background: #eef2f7;
}

.gallery-card-media img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform .28s ease;
}

.gallery-card:hover .gallery-card-media img {
    transform: scale(1.018);
}

.gallery-image-count {
    position: absolute;
    top: 10px;
    right: 10px;
    min-width: 30px;
    padding: 5px 8px;
    border: 1px solid rgba(255, 255, 255, .45);
    border-radius: 999px;
    color: #fff;
    background: rgba(15, 23, 42, .72);
    backdrop-filter: blur(8px);
    font-size: 11px;
    font-weight: 800;
    text-align: center;
}

.gallery-no-image {
    display: grid;
    min-height: 210px;
    place-items: center;
    color: #9aa6b6;
    background: linear-gradient(135deg, #f3f6fa, #e8eef6);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .14em;
}

.gallery-card-body {
    padding: 15px 16px 14px;
}

.gallery-card-body h2 {
    margin: 0;
    color: #172033;
    font-size: 15px;
    font-weight: 760;
    line-height: 1.45;
    letter-spacing: -.015em;
}

.gallery-card-body p {
    margin: 8px 0 0;
    color: #6e7a8d;
    font-size: 12.5px;
    line-height: 1.6;
}

.gallery-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 12px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #eef2f6;
    color: #8793a3;
    font-size: 11px;
}

.gallery-empty {
    padding: 72px 24px;
    border: 1px dashed #cfdae7;
    border-radius: 18px;
    background: #fbfcfe;
    text-align: center;
}

.gallery-empty-icon {
    margin-bottom: 12px;
    color: #8da0ba;
    font-size: 42px;
}

.gallery-empty h3 {
    margin-bottom: 8px;
    color: #28364b;
    font-size: 19px;
    font-weight: 760;
}

.gallery-empty p {
    color: #7b8797;
}

.gallery-compose {
    max-width: 980px;
    margin: 0 auto;
}

.gallery-compose-head {
    margin-bottom: 18px;
}

.gallery-compose h1 {
    font-size: 30px;
}

.gallery-compose-head p {
    margin: 8px 0 0;
    color: var(--gallery-muted);
    font-size: 14px;
}

.gallery-form-card {
    padding: 26px;
}

.gallery-description {
    min-height: 150px;
    resize: vertical;
    line-height: 1.7;
}

.gallery-required-badge {
    padding: 5px 8px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    color: #1d4ed8;
    background: #eff6ff;
    font-size: 11px;
    font-weight: 750;
}

.gallery-upload-zone {
    padding: 18px;
    border: 1px dashed #c7d3e1;
    border-radius: 14px;
    background: linear-gradient(180deg, #fbfdff 0%, #f7faff 100%);
}

.gallery-upload-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 12px;
    color: #4d5d72;
    font-size: 12px;
}

.gallery-upload-copy strong {
    color: #24334a;
    font-size: 13px;
}

.gallery-edit-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.gallery-edit-item {
    position: relative;
    overflow: hidden;
    min-width: 0;
    border: 1px solid #e0e6ed;
    border-radius: 12px;
    background: #f7f9fc;
}

.gallery-edit-item img {
    display: block;
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.gallery-delete-check {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    color: #556276;
    background: #fff;
    font-size: 12px;
    cursor: pointer;
}

.gallery-view {
    padding: 26px;
}

.gallery-view-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.gallery-view h1 {
    font-size: clamp(26px, 3vw, 36px);
    line-height: 1.3;
}

.gallery-view-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-top: 10px;
    color: #7b8797;
    font-size: 12px;
}

.gallery-detail-masonry {
    column-count: 3;
    column-gap: 16px;
}

.gallery-detail-item {
    display: inline-block;
    width: 100%;
    margin: 0 0 16px;
    break-inside: avoid;
}

.gallery-detail-item a {
    display: block;
    overflow: hidden;
    border-radius: 13px;
    background: #eef2f6;
}

.gallery-detail-item img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform .22s ease;
}

.gallery-detail-item a:hover img {
    transform: scale(1.012);
}

.gallery-story {
    margin-top: 26px;
    padding: 22px 24px;
    border: 1px solid #e3e8ef;
    border-radius: 14px;
    background: #fafbfd;
}

.gallery-story-label {
    margin-bottom: 10px;
    color: #8290a4;
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .16em;
}

.gallery-story-text {
    color: #334155;
    font-size: 14.5px;
    line-height: 1.85;
    word-break: break-word;
}

body.gallery-page .pagination .page-link {
    color: #526071;
    border-color: #d8dee7;
}

body.gallery-page .pagination .page-item.active .page-link {
    color: #fff;
    background: #2563eb;
    border-color: #2563eb;
}

@media (max-width: 1199.98px) {
    .gallery-masonry:not(.gallery-masonry-ready) {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .gallery-detail-masonry {
        column-count: 2;
    }
}

@media (max-width: 991.98px) {
    .gallery-masonry:not(.gallery-masonry-ready) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .gallery-edit-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    body.gallery-page > .container {
        width: min(100% - 24px, 1280px);
    }

    .gallery-hero {
        align-items: flex-start;
        flex-direction: column;
        padding: 23px 22px;
    }

    .gallery-hero-action {
        width: 100%;
    }

    .gallery-form-card,
    .gallery-view {
        padding: 18px;
    }

    .gallery-view-head {
        flex-direction: column;
    }

    .gallery-edit-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

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

    .gallery-masonry:not(.gallery-masonry-ready) {
        grid-template-columns: 1fr;
    }

    .gallery-detail-masonry {
        column-count: 1;
    }

    .gallery-edit-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .gallery-edit-item img {
        height: 130px;
    }
}

/* EasyPlan masonry image/card boundary: make adjacent gallery items visually distinct */
body.gallery-page .gallery-card {
    border-color: #cbd5e1;
    box-shadow: 0 7px 22px rgba(15, 23, 42, .075);
}

body.gallery-page .gallery-card-media {
    position: relative;
    background: #f8fafc;
}

body.gallery-page .gallery-card-media::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    border: 1px solid #cbd5e1;
    pointer-events: none;
    box-sizing: border-box;
}

body.gallery-page .gallery-card:hover {
    border-color: #aebdce;
    box-shadow: 0 15px 34px rgba(15, 23, 42, .12);
}
