/* =========================================
   1. CSS 변수 설정
   ========================================= */
:root {
    --timeline-bg: #e5e8eb;
    --timeline-point: #ff5a2b;
    --timeline-text: #212121;

    --btn-orange: #ff9800;
    --btn-orange-hover: #e68a00;
    --btn-blue: #2196f3;
    --btn-blue-hover: #0b7dda;
    --btn-mint: #10a37f;
    --btn-mint-hover: #0b6f72;
    --btn-navy: #5663a7;
    --btn-navy-hover: rgba(86, 99, 167, 0.8);

    --review-bg: #f8f9fa;
    --review-border: #e9ecef;
    --review-highlight: #fff0b3;
}

.content {
    padding-bottom: 30px !important;
}

.mybook {
    /* display: inline-block; */
    float: right;
    border-radius: 5px;
    width: 100px;
}

.mybook:hover {
    box-shadow: 0 0 2px 1px rgba(0, 140, 186, 0.5);
}

/* 박스 사이징 초기화 */
.timeline *,
.timeline *::before,
.timeline *::after,
#best-reviews * {
    box-sizing: border-box;
}

/* =========================================
   2. 타임라인 (Timeline) 구조
   ========================================= */
.timeline {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
}

/* 수직 기둥 (중앙선) */
.timeline::after {
    content: "";
    position: absolute;
    width: 6px;
    background-color: var(--timeline-bg);
    top: 20px;
    bottom: 10px;
    left: 50%;
    margin-left: -3px;
}

/* 컨테이너 공통 */
.container {
    padding: 10px 40px;
    position: relative;
    background-color: inherit;
    width: 50%;
}

/* =========================================
   [핵심 변경] 자동 지그재그 배치 로직
   ========================================= */

/* 1) 홀수 번째 요소 (Left) : 1, 3, 5... */
.container:nth-child(odd) {
    left: 0;
}

/* 홀수(왼쪽) 컨테이너 화살표 (오른쪽을 향함) */
.container:nth-child(odd)::before {
    content: " ";
    height: 0;
    width: 0;
    position: absolute;
    top: 22px;
    z-index: 1;
    right: 30px; /* 오른쪽 끝에 붙임 */
    border: medium solid white;
    border-width: 10px 0 10px 10px;
    border-color: transparent transparent transparent var(--timeline-bg);
}

/* 홀수(왼쪽) 컨테이너 동그라미 (오른쪽 선 위에) */
.container:nth-child(odd)::after {
    content: "";
    position: absolute;
    width: 25px;
    height: 25px;
    right: -13px; /* 정중앙 정렬값 */
    background-color: white;
    border: 4px solid var(--timeline-point);
    top: 15px;
    border-radius: 50%;
    z-index: 1;
}

/* 2) 짝수 번째 요소 (Right) : 2, 4, 6... */
.container:nth-child(even) {
    left: 50%;
}

/* 짝수(오른쪽) 컨테이너 화살표 (왼쪽을 향함) */
.container:nth-child(even)::before {
    content: " ";
    height: 0;
    width: 0;
    position: absolute;
    top: 22px;
    z-index: 1;
    left: 30px; /* 왼쪽 끝에 붙임 */
    border: medium solid white;
    border-width: 10px 10px 10px 0;
    border-color: transparent var(--timeline-bg) transparent transparent;
}

/* 짝수(오른쪽) 컨테이너 동그라미 (왼쪽 선 위에) */
.container:nth-child(even)::after {
    content: "";
    position: absolute;
    width: 25px;
    height: 25px;
    left: -13px; /* 정중앙 정렬값 */
    background-color: white;
    border: 4px solid var(--timeline-point);
    top: 15px;
    border-radius: 50%;
    z-index: 1;
}

/* =========================================
   3. 책 콘텐츠 및 스타일
   ========================================= */
.content {
    padding: 20px 30px 60px 20px;
    background-color: var(--timeline-bg);
    position: relative;
    border-radius: 6px;
}

.mybook {
    width: 100px;
}

.bookname {
    font-size: 1rem;
    font-weight: bold;
    padding-bottom: 10px;
    margin-top: 10px;
    line-height: 1.4;
}

/* 리스트 스타일 */
.timeline ul li {
    font-size: 0.9rem;
    color: var(--timeline-text);
    margin-bottom: 5px;
}

.timeline ul li::before {
    content: "\2022";
    color: red;
    display: inline-block;
    width: 1em;
    margin-left: 0.5em;
}

/* =========================================
   4. 버튼 스타일
   ========================================= */
.dnbtn {
    border: none;
    color: white;
    padding: 4px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.3s;
}

.orange {
    background-color: var(--btn-orange);
}
.orange:hover {
    background-color: var(--btn-orange-hover);
}
.blue {
    background-color: var(--btn-blue);
}
.blue:hover {
    background-color: var(--btn-blue-hover);
}
.mint {
    background-color: var(--btn-mint);
}
.mint:hover {
    background-color: var(--btn-mint-hover);
}
.navy {
    background-color: var(--btn-navy);
}
.navy:hover {
    background-color: var(--btn-navy-hover);
}

/* =========================================
   5. 베스트 리뷰 섹션
   ========================================= */
#best-reviews {
    max-width: 1000px;
    margin: 0 auto 40px auto;
    padding: 25px;
    background-color: var(--review-bg);
    border-radius: 12px;
    border: 1px solid var(--review-border);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}

.review-title {
    font-size: 1.3em;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 10px;
    text-align: center;
}

.review-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.review-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #eee;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.review-text {
    font-size: 0.95em;
    color: #444;
    line-height: 1.6;
    margin-bottom: 15px;
    font-style: italic;
}

.review-source {
    font-size: 0.85em;
    color: #666;
    font-weight: bold;
    text-align: right;
    border-top: 1px solid #f1f1f1;
    padding-top: 10px;
}

.source-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background-color: #eef2ff;
    color: var(--btn-navy);
}

.source-tag.gpt {
    background-color: #fff0f0;
    color: #e03131;
}
.source-tag.orange {
    background-color: var(--review-highlight);
    color: #e67e22;
}

/* =========================================
   6. 반응형 (Media Queries) - 중요!
   ========================================= */

@media screen and (max-width: 768px) {
    /* 타임라인 기둥 왼쪽 이동 */
    .timeline::after {
        left: 31px;
    }

    /* 모바일에서는 홀수/짝수 구분 없이 모두 같은 스타일 적용 */
    .container {
        width: 100%;
        padding-left: 70px;
        padding-right: 25px;
    }

    /* 모바일에서 짝수 번째 요소의 위치 강제 초기화 (왼쪽 정렬) */
    .container:nth-child(even) {
        left: 0;
    }

    /* 화살표: 홀수/짝수 모두 왼쪽을 향하도록 통일 */
    .container:nth-child(odd)::before,
    .container:nth-child(even)::before {
        left: 60px;
        right: auto; /* 기존 right 값 초기화 */
        border: medium solid white;
        border-width: 10px 10px 10px 0;
        border-color: transparent white transparent transparent;
    }

    /* 동그라미: 홀수/짝수 모두 왼쪽 기둥 위에 위치하도록 통일 */
    .container:nth-child(odd)::after,
    .container:nth-child(even)::after {
        left: 15px; /* 모바일 기둥 위치에 맞춤 */
        right: auto; /* 기존 right 값 초기화 */
    }

    .review-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 500px) {
    .mybook {
        width: 60px;
    }
    .container {
        padding-left: 60px;
        padding-right: 15px;
    }
}
