/* ============================================
   월간 유레카 - 상품 상세 페이지
   Warm Editorial Bookshop
   ============================================ */

/* Pretendard는 common.css에서 로드 */

:root {
    --eureka-cream: #faf8f3;
    --eureka-warm: #f5f0e8;
    --text-primary: #1a1a1a;
    --text-secondary: #5a5a5a;
    --text-muted: #8a8a8a;
    /* 상세 페이지 전용 컬러 — 따뜻한 네이비 */
    --pd-accent: #2e4a62;
    --pd-accent-hover: #3d6d8f;
    --pd-accent-light: rgba(46, 74, 98, 0.07);
    --pd-bg: #f7f4ee;
    --pd-card-bg: #fff;
    --pd-border: rgba(46, 74, 98, 0.08);
    --pd-border-strong: rgba(46, 74, 98, 0.14);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.04), 0 8px 32px rgba(46,74,98,0.06);
    --shadow-card-hover: 0 12px 40px rgba(46,74,98,0.14);
    --shadow-image: 0 8px 40px rgba(46,74,98,0.12);
    --radius: 12px;
    --radius-lg: 16px;
    --transition: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── 컨테이너 ── */
.product-detail-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 48px 24px 80px;
    background: var(--pd-bg);
    min-height: 60vh;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* ── 2컬럼 레이아웃 ── */
.product-detail {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 56px;
    background: var(--pd-card-bg);
    border-radius: var(--radius-lg);
    padding: 48px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--pd-border);
    margin-bottom: 48px;
    align-items: start;
    min-width: 0;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* ── 이미지 섹션 ── */

/* product-detail ?? section ??? ?? ?? */
.product-detail-container section,
.product-detail-container .product-description,
.product-detail-container .product-toc,
.product-detail-container .product-reviews {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
    overflow-x: hidden;
}

.product-detail-container .product-description,
.product-detail-container .product-toc,
.product-detail-container .product-reviews {
    overflow-x: auto !important;
}

.product-detail-container section * {
    max-width: 100%;
    box-sizing: border-box;
}

.product-detail-container section[style] {
    width: auto !important;
}

.product-detail-container .table-responsive,
.product-detail-container .table-responsive table {
    width: 100%;
    max-width: 100%;
    min-width: 0 !important;
}

.product-detail-container .description-text table {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0 !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.product-image-section {
    position: sticky;
    top: 120px;
    min-width: 0;
    width: 100%;
}

.product-image-wrapper {
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--eureka-warm);
    box-shadow: var(--shadow-image);
}

.product-main-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0;
    transition: transform 0.7s var(--ease-out);
    background: var(--eureka-warm);
}

.product-image-wrapper:hover .product-main-image {
    transform: scale(1.03);
}

/* ── 정보 섹션 ── */
.product-info-section {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* 카테고리 배지 */
.product-category-badge {
    display: inline-block;
    padding: 5px 16px;
    background: var(--pd-accent-light);
    border: 1.5px solid var(--pd-accent);
    color: var(--pd-accent);
    border-radius: 100px;
    font-family: 'Pretendard', sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    margin-bottom: 20px;
    width: fit-content;
}

/* 제목 */
.product-detail-title {
    font-family: 'Pretendard', sans-serif;
    font-size: 28px;
    font-weight: 900;
    line-height: 1.4;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 20px;
}

/* 메타 정보 */
.product-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--pd-border);
}

.meta-item {
    font-family: 'Pretendard', sans-serif;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.meta-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 4px;
}

/* ── 가격 섹션 ── */
.product-price-section {
    padding: 24px 0;
    margin-bottom: 4px;
    border-top: 1px solid var(--pd-border);
}

.original-price {
    font-family: 'Pretendard', sans-serif;
    font-size: 15px;
    color: var(--text-muted);
    text-decoration: line-through;
    margin-bottom: 6px;
    font-weight: 400;
}

.current-price {
    font-family: 'Pretendard', sans-serif;
    font-size: 34px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1;
}

.discount-rate {
    display: inline-block;
    margin-left: 12px;
    padding: 4px 12px;
    background: #c0392b;
    color: #fff;
    border-radius: 100px;
    font-family: 'Pretendard', sans-serif;
    font-size: 14px;
    font-weight: 700;
    vertical-align: middle;
    letter-spacing: 0;
}

/* ── 상품 정보 테이블 ── */
.product-info-table {
    width: 100%;
    margin: 20px 0;
    border-collapse: collapse;
}

.product-info-table tr {
    border-bottom: 1px solid var(--pd-border);
}

.product-info-table tr:first-child {
    border-top: 1px solid var(--pd-border);
}

.product-info-table th {
    padding: 12px 16px;
    text-align: left;
    background: rgba(247, 244, 238, 0.6);
    font-family: 'Pretendard', sans-serif;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    width: 110px;
    vertical-align: top;
}

.product-info-table td {
    padding: 12px 16px;
    font-family: 'Pretendard', sans-serif;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.product-subscription-badge {
    color: var(--pd-accent);
    font-weight: 600;
}

/* ── 구매 버튼 ── */
.product-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    width: 100%;
}

.btn-add-cart {
    flex: 1;
    padding: 16px 20px;
    background: transparent;
    color: var(--pd-accent);
    border: 2px solid var(--pd-accent);
    border-radius: 100px;
    font-family: 'Pretendard', sans-serif;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s var(--ease-out);
    letter-spacing: 0.2px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-add-cart:hover {
    background: var(--pd-accent);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(46, 74, 98, 0.25);
}

.btn-admin-edit {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background: linear-gradient(160deg, #b46419 0%, #8f4813 100%);
    border-color: #8f4813;
    color: #fff;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-admin-edit:hover {
    background: linear-gradient(160deg, #9f5516 0%, #74380f);
    border-color: #74380f;
    color: #fff;
}

.btn-buy-now {
    flex: 1;
    padding: 16px 20px;
    background: linear-gradient(160deg, var(--pd-accent-hover) 0%, var(--pd-accent) 100%);
    color: #fff;
    border: none;
    border-radius: 100px;
    font-family: 'Pretendard', sans-serif;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s var(--ease-out);
    letter-spacing: 0.2px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    text-align: center;
}

.btn-buy-now:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(46, 74, 98, 0.35);
}

/* main-btn / secondary-color 오버라이드 (common.css 충돌 방지) */
.product-actions .main-btn.secondary-color {
    background: transparent !important;
    border: 2px solid var(--pd-accent) !important;
    color: var(--pd-accent) !important;
    border-radius: 100px !important;
}

.product-actions .main-btn.secondary-color:hover {
    background: var(--pd-accent) !important;
    color: #fff !important;
}

.product-actions .main-btn:not(.secondary-color) {
    background: linear-gradient(160deg, var(--pd-accent-hover) 0%, var(--pd-accent) 100%) !important;
    border: none !important;
    border-radius: 100px !important;
    color: #fff !important;
}

/* ── 상품 설명 ── */
.product-description {
    background: var(--pd-card-bg);
    border-radius: var(--radius-lg);
    padding: 40px 48px;
    margin-bottom: 48px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--pd-border);
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.description-title {
    font-family: 'Pretendard', sans-serif;
    font-size: 20px;
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--text-primary);
    letter-spacing: -0.02em;
}

.description-text {
    font-family: 'Pretendard', sans-serif;
    font-size: 15px;
    line-height: 1.9;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.description-text * {
    max-width: 100%;
    box-sizing: border-box;
}

.description-text p {
    margin-top: 0;
    margin-bottom: 0.3em;
}

.description-text img,
.description-text video,
.description-text iframe,
.description-text embed,
.description-text object {
    max-width: 100%;
    height: auto;
    display: block;
}

.description-text pre {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
}

.description-text table {
    max-width: 100%;
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
}

.description-text table table {
    width: 100%;
}

.description-text td,
.description-text th {
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
}

.description-text h1,
.description-text h2,
.description-text h3,
.description-text h4 {
    font-family: 'Pretendard', sans-serif;
    color: var(--text-primary);
    line-height: 1.35;
    letter-spacing: -0.02em;
    margin: 28px 0 14px;
    white-space: normal;
}

.description-text h1 {
    font-size: 30px;
    font-weight: 900;
}

.description-text h2 {
    font-size: 24px;
    font-weight: 850;
}

.description-text h3 {
    font-size: 20px;
    font-weight: 800;
}

.description-text h4 {
    font-size: 18px;
    font-weight: 750;
}

.description-text h1:first-child,
.description-text h2:first-child,
.description-text h3:first-child,
.description-text h4:first-child {
    margin-top: 0;
}

/* Quill 에디터 정렬 클래스 — 관리자 에디터에서 지정한 정렬을 프론트 상품설명에 반영 */
.description-text .ql-align-center { text-align: center; }
.description-text .ql-align-right { text-align: right; }
.description-text .ql-align-justify { text-align: justify; }

/* ── 관련 상품 ── */
.related-products-section {
    margin-top: 8px;
}

.section-title {
    font-family: 'Pretendard', sans-serif;
    font-size: 22px;
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--text-primary);
    letter-spacing: -0.02em;
}

.related-products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.related-product-card {
    background: var(--pd-card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.5s var(--ease-out), box-shadow 0.5s var(--ease-out);
    cursor: pointer;
    border: 1px solid var(--pd-border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.related-product-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-card-hover);
    border-color: rgba(46, 74, 98, 0.12);
}

.related-product-card:hover .related-product-img {
    transform: none;
}

.related-img-wrapper {
    overflow: hidden;
    background: var(--eureka-warm);
    aspect-ratio: 3 / 4;
}

.related-product-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
    display: block;
    margin: 0;
    background: var(--eureka-warm);
    transition: transform 0.7s var(--ease-out);
}

.related-product-body {
    padding: 14px 16px 16px;
}

.related-product-title {
    font-family: 'Pretendard', sans-serif;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 42px;
}

.related-product-price {
    font-family: 'Pretendard', sans-serif;
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

/* ── 등장 애니메이션 ── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.product-detail {
    animation: fadeUp 0.6s var(--ease-out) both;
}

.product-description {
    animation: fadeUp 0.5s var(--ease-out) 0.1s both;
}

.related-products-section {
    animation: fadeUp 0.5s var(--ease-out) 0.15s both;
}

/* ── 반응형: 태블릿 ── */
@media (max-width: 1024px) {
    .product-detail {
        gap: 40px;
        padding: 36px;
        min-width: 0;
    }

    .product-detail-title {
        font-size: 24px;
    }

    .related-products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ── 반응형: 모바일 ── */
@media (max-width: 768px) {
    .product-detail-container {
        padding: 20px 14px 60px;
    }

    .product-detail {
        grid-template-columns: 1fr;
        gap: 28px;
        padding: 24px;
        margin-bottom: 28px;
        border-radius: var(--radius);
        min-width: 0;
    }

    .product-image-section {
        position: static;
    }

    .product-detail-title {
        font-size: 22px;
    }

    .current-price {
        font-size: 28px;
    }

    .product-actions {
        flex-direction: column;
        gap: 10px;
    }

    .btn-add-cart,
    .btn-buy-now {
        padding: 14px 20px;
        font-size: 16px;
        width: 100%;
    }

    .btn-add-cart,
    .btn-admin-edit {
        width: 100%;
    }

    .related-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    .product-description {
        padding: 24px;
        margin-bottom: 28px;
        border-radius: var(--radius);
    }

    .meta-item {
        font-size: 13px;
    }

    .product-info-table th,
    .product-info-table td {
        font-size: 13px;
        padding: 10px 12px;
    }

    .product-description {
        padding: 20px;
    }

    .description-text {
        font-size: 14px;
        line-height: 1.8;
    }

    .description-text table {
        font-size: 14px;
    }

    .description-text table td,
    .description-text table th {
        min-width: 140px;
    }
}

/* ── 반응형: 소형 모바일 ── */
@media (max-width: 480px) {
    .product-detail-container {
        padding: 16px 10px 48px;
    }

    .product-detail {
        padding: 18px;
        overflow: hidden;
    }

    .product-detail-title {
        font-size: 20px;
    }

    .current-price {
        font-size: 26px;
    }

    .related-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .product-description {
        padding: 18px;
    }

    .description-text {
        font-size: 14px;
    }

    .description-text table td,
    .description-text table th {
        min-width: 120px;
    }
}

/* ── 호버 없는 환경 (터치 디바이스) ── */
@media (hover: none) {
    .product-image-wrapper:hover .product-main-image {
        transform: none;
    }

    .related-product-card:hover {
        transform: none;
        box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    }

    .related-product-card:hover .related-product-img {
        transform: none;
    }

    .btn-add-cart:hover,
    .btn-buy-now:hover {
        transform: none;
        box-shadow: none;
    }
}

/* ── 모션 축소 선호 ── */
@media (prefers-reduced-motion: reduce) {
    .product-detail,
    .product-description,
    .related-products-section {
        animation: none;
    }

    .product-main-image,
    .related-product-card,
    .related-product-img,
    .btn-add-cart,
    .btn-buy-now {
        transition-duration: 0.01s;
    }
}
