/**
 * 制作物アーカイブ
 * 制作物プレビューモーダル専用スタイル
 */

/* ========================================
   モーダル全体
======================================== */

.preview-modal {
    position: fixed;
    z-index: 1200;
    inset: 0;
    display: grid;
    padding: 28px;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.18s ease,
        visibility 0.18s ease;
    place-items: center;
}

.preview-modal[hidden] {
    display: none;
}

.preview-modal.is-open {
    opacity: 1;
    visibility: visible;
}

.preview-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgb(24 22 20 / 62%);
    backdrop-filter: blur(2px);
}

.preview-modal__panel {
    position: relative;
    z-index: 1;
    overflow: hidden;
    width: min(1080px, 94vw);
    max-height: min(860px, 90vh);
    border: 1px solid rgb(244 122 36 / 18%);
    border-radius: 22px;
    background: #fffdf9;
    box-shadow: 0 30px 90px rgb(0 0 0 / 30%);
    opacity: 0;
    transform: translateY(12px) scale(0.99);
    transition:
        opacity 0.18s ease,
        transform 0.18s ease;
}

.preview-modal.is-open
.preview-modal__panel {
    opacity: 1;
    transform: none;
}

.preview-modal__panel.is-changing
.preview-modal__content {
    opacity: 0.45;
    transform: translateY(3px);
}

body.is-preview-modal-open {
    overflow: hidden;
}

/* ========================================
   閉じるボタン
======================================== */

.preview-modal__close {
    position: absolute;
    z-index: 4;
    top: 14px;
    right: 14px;
    display: grid;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgb(255 255 255 / 92%);
    color: #4a4a4a;
    font: inherit;
    font-size: 1.45rem;
    cursor: pointer;
    box-shadow: 0 5px 16px rgb(0 0 0 / 12%);
    transition:
        background-color 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease;
    place-items: center;
}

.preview-modal__close:hover {
    background: #ffffff;
    color: #e66f28;
    transform: rotate(4deg);
}

.preview-modal__close:focus-visible {
    outline: 3px solid rgb(244 122 36 / 28%);
    outline-offset: 3px;
}

/* ========================================
   通常版：左右2カラム
   PC・横向きタブレット・横向きスマートフォン
======================================== */

.preview-modal__content {
    display: grid;
    grid-template-columns:
        minmax(320px, 44%)
        minmax(0, 1fr);
    gap: 34px;
    align-items: stretch;
    min-height: 620px;
    padding: 34px;
    transition:
        opacity 0.12s ease,
        transform 0.12s ease;
}

.preview-modal__visual {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
}

.preview-modal__image-area {
    position: relative;
    overflow: hidden;
    width: min(100%, 430px);
    aspect-ratio: 7 / 9.9;
    border-radius: 14px;
    background: #f0f0f0;
    box-shadow: 0 16px 38px rgb(35 35 35 / 18%);
}

.preview-modal__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-modal__new {
    position: absolute;
    z-index: 2;
    top: 12px;
    left: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgb(244 122 36 / 90%);
    color: #ffffff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.08em;
}

.preview-modal__new[hidden] {
    display: none;
}

/* ========================================
   右側情報
======================================== */

.preview-modal__information {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    padding: 20px 10px 6px 0;
}

.preview-modal__header-information {
    flex: 0 0 auto;
    max-height: none;
    padding-right: 52px;
    overflow: visible;
}

.preview-modal__date {
    margin: 0 0 10px;
    color: #8a8179;
    font-size: 0.82rem;
    line-height: 1.6;
}

.preview-modal__title {
    margin: 0;
    color: #252525;
    font-size: clamp(1.18rem, 1.65vw, 1.62rem);
    font-weight: 750;
    line-height: 1.36;
    letter-spacing: 0.015em;
    overflow-wrap: anywhere;
}

.preview-modal__category {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    min-height: 24px;
    margin-top: 14px;
    padding: 2px 8px;
    border: 1px solid #e8b98f;
    border-radius: 999px;
    background: #fff4ea;
    color: #915528;
    font-size: 0.68rem;
    font-weight: 700;
}

.preview-modal__category[hidden] {
    display: none;
}

.preview-modal__brands,
.preview-modal__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.preview-modal__brands[hidden],
.preview-modal__badges[hidden] {
    display: none;
}

.preview-modal__brand,
.preview-modal__badge {
    padding: 3px 7px;
    border: 1px solid #e5e2df;
    border-radius: 7px;
    background: #f8f7f6;
    color: #666666;
    font-size: 0.66rem;
    line-height: 1.3;
}

.preview-modal__badge {
    border-color: #e5e2df;
    background: #f8f7f6;
    color: #666666;
}

.preview-modal__badge--interview {
    border-color: transparent;
    background: #fff0cc;
    color: #8f5a00;
}

.preview-modal__badge--status {
    border-color: transparent;
    background: #eaf4ff;
    color: #286b9e;
}

.preview-modal__badge--cover {
    border-color: transparent;
    background: #f1ecff;
    color: #6743a2;
}

.preview-modal__description {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    margin: 20px 0 0;
    padding-right: 10px;
    color: #666666;
    font-size: 0.92rem;
    line-height: 1.9;
    white-space: pre-wrap;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

/* ========================================
   前後移動・詳細ボタン
======================================== */

.preview-modal__actions {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        minmax(150px, 1.2fr)
        minmax(0, 1fr);
    gap: 10px;
    margin-top: 16px;
    padding-top: 0;
}

.preview-modal__navigation-button {
    display: inline-flex;
    gap: 9px;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 10px 16px;
    border: 1px solid #ded9d4;
    border-radius: 12px;
    background: #ffffff;
    color: #555555;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 650;
    cursor: pointer;
    box-shadow: 0 5px 14px rgb(55 45 35 / 6%);
    transition:
        border-color 0.18s ease,
        background-color 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

@media (hover: hover) and (pointer: fine) {
    .preview-modal__navigation-button:hover:not(:disabled) {
        border-color: #e7a87a;
        background: #fff7f0;
        color: #b95f1d;
        box-shadow: 0 8px 18px rgb(201 119 55 / 13%);
        transform: translateY(-1px);
    }
}

.preview-modal__navigation-button:active:not(:disabled) {
    box-shadow: none;
    transform: none;
}

@media (hover: none), (pointer: coarse) {
    .preview-modal__navigation-button {
        -webkit-tap-highlight-color: transparent;
    }

    .preview-modal__navigation-button:active:not(:disabled),
    .preview-modal__navigation-button.is-tapped:not(:disabled) {
        border-color: #e7a87a;
        background: #fff7f0;
        color: #b95f1d;
        box-shadow: none;
        transform: none;
    }

    .preview-modal__navigation-button:not(:active):not(.is-tapped):not(:disabled),
    .preview-modal__navigation-button:focus:not(:focus-visible):not(.is-tapped):not(:disabled) {
        border-color: #ded9d4;
        background: #ffffff;
        color: #555555;
        box-shadow: 0 5px 14px rgb(55 45 35 / 6%);
        outline: none;
        transform: none;
    }
}

.preview-modal__navigation-button:focus-visible {
    outline: 3px solid rgb(244 122 36 / 22%);
    outline-offset: 3px;
}

.preview-modal__navigation-button:disabled {
    border-color: #e9e7e5;
    background: #f5f4f3;
    color: #b4b1ae;
    cursor: default;
    box-shadow: none;
}

.preview-modal__detail-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 52px;
    padding: 8px 14px;
    border: 1px solid #e98748;
    border-radius: 10px;
    background: #ed965d;
    color: #ffffff;
    font-size: 0.86rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 7px 16px rgb(226 139 83 / 19%);
    transition:
        border-color 0.18s ease,
        background-color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
}

.preview-modal__detail-button:hover {
    border-color: #df7e40;
    background: #df8750;
    box-shadow: 0 9px 20px rgb(226 139 83 / 24%);
    transform: translateY(-1px);
}

.preview-modal__detail-button:active {
    box-shadow: none;
    transform: none;
}

.preview-modal__detail-button:focus-visible {
    outline: 3px solid rgb(244 122 36 / 25%);
    outline-offset: 3px;
}

.preview-modal__detail-button.is-disabled,
.preview-modal__detail-button[aria-disabled="true"] {
    border-color: #d8d5d2;
    background: #efeeec;
    color: #999591;
    cursor: default;
    box-shadow: none;
    pointer-events: none;
    transform: none;
}

/* ========================================
   横向きの小型画面調整
   横向きスマートフォン・小型タブレット
======================================== */

@media screen and (orientation: landscape) and (max-height: 760px) {
    .preview-modal {
        padding: 14px;
    }

    .preview-modal__panel {
        width: min(980px, 96vw);
        max-height: 94dvh;
    }

    .preview-modal__content {
        grid-template-columns:
            minmax(220px, 38%)
            minmax(0, 1fr);
        gap: 24px;
        min-height: min(560px, calc(94dvh - 28px));
        max-height: 94dvh;
        padding: 24px;
    }

    .preview-modal__image-area {
        width: min(100%, 350px);
    }

    .preview-modal__information {
        padding-top: 8px;
    }

    .preview-modal__description {
        margin-top: 14px;
        font-size: 0.86rem;
        line-height: 1.75;
    }

    .preview-modal__navigation-button {
        min-height: 46px;
    }
}

/* ========================================
   縦型画面版
   スマートフォン・縦向きタブレット
======================================== */

@media screen and (orientation: portrait) and (max-width: 1024px) {
    .preview-modal {
        align-items: center;
        padding:
            max(10px, env(safe-area-inset-top))
            max(10px, env(safe-area-inset-right))
            max(10px, env(safe-area-inset-bottom))
            max(10px, env(safe-area-inset-left));
    }

    .preview-modal__panel {
        width: 100%;
        max-height:
            calc(
                100dvh -
                max(20px, env(safe-area-inset-top)) -
                max(20px, env(safe-area-inset-bottom))
            );
        border-radius: 16px;
    }

    .preview-modal__content {
        display: grid;
        grid-template-columns:
            minmax(120px, 40%)
            minmax(0, 1fr);
        grid-template-rows:
            auto
            minmax(100px, 1fr)
            auto;
        gap: 14px 16px;
        width: 100%;
        height:
            min(
                760px,
                calc(100dvh - 40px)
            );
        min-height: 0;
        max-height: none;
        padding: 44px 16px 16px;
        overflow: hidden;
    }

    .preview-modal__visual {
        grid-column: 1;
        grid-row: 1;
        align-self: start;
        min-width: 0;
    }

    .preview-modal__image-area {
        width: 100%;
        max-width: none;
        border-radius: 10px;
        box-shadow:
            0 8px 20px
            rgb(35 35 35 / 14%);
    }

    .preview-modal__information {
        display: contents;
        min-width: 0;
        min-height: 0;
        padding: 0;
    }

    .preview-modal__header-information {
        grid-column: 2;
        grid-row: 1;
        align-self: start;
        min-width: 0;
        max-height: none;
        padding: 0 34px 0 0;
        overflow: visible;
    }

    .preview-modal__date {
        margin-bottom: 6px;
        font-size: 0.72rem;
        line-height: 1.4;
    }

    .preview-modal__title {
        font-size: clamp(
            0.94rem,
            3.2vw,
            1.2rem
        );
        line-height: 1.4;
    }

    .preview-modal__category {
        min-height: 20px;
        margin-top: 8px;
        padding: 2px 6px;
        font-size: 0.58rem;
    }

    .preview-modal__brands,
    .preview-modal__badges {
        gap: 4px;
        margin-top: 6px;
    }

    .preview-modal__brand,
    .preview-modal__badge {
        padding: 2px 5px;
        font-size: 0.56rem;
        line-height: 1.25;
    }

    .preview-modal__description {
        grid-column: 1 / -1;
        grid-row: 2;
        min-width: 0;
        min-height: 0;
        margin: 2px 0 0;
        padding:
            12px
            8px
            12px
            0;
        border-top:
            1px solid
            rgb(0 0 0 / 8%);
        overflow-x: hidden;
        overflow-y: auto;
        font-size: 0.84rem;
        line-height: 1.75;
        white-space: pre-wrap;
        overscroll-behavior: contain;
        scrollbar-gutter: auto;
        -webkit-overflow-scrolling: touch;
    }

    .preview-modal__actions {
        grid-column: 1 / -1;
        grid-row: 3;
        grid-template-columns:
            minmax(0, 0.8fr)
            minmax(138px, 1.4fr)
            minmax(0, 0.8fr);
        gap: 7px;
        margin-top: 0;
    }

    .preview-modal__detail-button {
        min-width: 0;
        min-height: 44px;
        padding: 7px 8px;
        font-size: 0.72rem;
    }

    .preview-modal__navigation-button {
        min-height: 44px;
        padding: 7px 6px;
        font-size: 0.72rem;
    }

    .preview-modal__close {
        top: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }

    .preview-modal__new {
        top: 7px;
        left: 7px;
        min-height: 20px;
        padding: 3px 7px;
        font-size: 0.58rem;
    }
}

/* ========================================
   縦型スマートフォン微調整
======================================== */

@media screen and (orientation: portrait) and (max-width: 700px) {
    .preview-modal {
        align-items: center;
        padding:
            max(10px, env(safe-area-inset-top))
            max(10px, env(safe-area-inset-right))
            max(10px, env(safe-area-inset-bottom))
            max(10px, env(safe-area-inset-left));
    }

    .preview-modal__panel {
        width: 100%;
        max-height:
            calc(
                100dvh -
                max(20px, env(safe-area-inset-top)) -
                max(20px, env(safe-area-inset-bottom))
            );
        border: 1px solid rgb(244 122 36 / 18%);
        border-radius: 18px;
    }

    .preview-modal__content {
        grid-template-columns:
            minmax(105px, 39%)
            minmax(0, 1fr);
        gap: 12px 14px;
        height:
            min(
                760px,
                calc(
                    100dvh -
                    max(20px, env(safe-area-inset-top)) -
                    max(20px, env(safe-area-inset-bottom))
                )
            );
        padding:
            44px
            max(16px, env(safe-area-inset-right))
            max(16px, env(safe-area-inset-bottom))
            max(16px, env(safe-area-inset-left));
    }

    .preview-modal__title {
        font-size: clamp(
            0.9rem,
            4vw,
            1.08rem
        );
    }

    .preview-modal__description {
        font-size: 0.82rem;
    }
}

/* ========================================
   極小画面
======================================== */

@media screen and (orientation: portrait) and (max-width: 380px) {
    .preview-modal__content {
        grid-template-columns:
            minmax(96px, 37%)
            minmax(0, 1fr);
        gap: 10px 12px;
        padding-right: 12px;
        padding-left: 12px;
    }

    .preview-modal__header-information {
        padding-right: 30px;
    }

}

/* ========================================
   アニメーション抑制
======================================== */

@media (prefers-reduced-motion: reduce) {
    .preview-modal,
    .preview-modal__panel,
    .preview-modal__content,
    .preview-modal__close,
    .preview-modal__navigation-button,
    .preview-modal__detail-button {
        transition: none;
    }
}
