/* RA0 Edition - 연표형 게시판 스킨 (history_up) */
/* CSS 변수 시스템 사용 */

/* ========== 컨테이너 ========== */
.history-container {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: 60px 20px 100px;
    min-height: 100vh;
}

/* ========== 헤더 ========== */
.timeline-header {
    text-align: center;
}

.timeline-title {
    font-family: var(--title-font-family);
    font-size: 6rem;
    color: var(--accent-color);
    letter-spacing: -1px;
    text-transform: uppercase;
}

.timeline-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.timeline-admin-controls {
    display: flex;
    justify-content: flex-end;
    gap: 5px;
    margin-bottom: 10px;
}

.btn-add-event, .btn-edit-mode, .btn-edit-order {
    display: inline-flex;
    align-items: center;
    padding: 5px;
    font-size: 0.9em;
    font-weight: 500;
    border-radius: var(--card-border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-add-event {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
}

.btn-add-event:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-edit-mode, .btn-edit-order {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: 1px solid var(--border-light);
}

.btn-edit-mode:hover, .btn-edit-order:hover {
    background: var(--card-bg-color);
}

.btn-edit-mode.active {
    background: var(--accent-color);
    color: var(--black);
    border-color: var(--accent-color);
}

.btn-edit-order.active {
    background: var(--warning-color);
    color: var(--black);
    border-color: var(--warning-color);
}

/* 하단 글쓰기 버튼 */
.timeline-footer {
    display: flex;
    justify-content: center;
}

.btn-add-event-bottom {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
    border-radius: var(--card-border-radius);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add-event-bottom:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgb(from var(--primary-color) r g b / 30%);
}

/* ========== 타임라인 구조 ========== */
.timeline-wrapper {
    position: relative;
}

.timeline-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    background: repeating-linear-gradient(
        0deg,
        var(--primary-color),
        var(--primary-color) 20px,
        var(--black) 20px,
        var(--black) 40px
    );
    transform: translateX(-50%);
    z-index: 0;
    box-shadow: 0 0 15px rgb(from var(--primary-color) r g b / 30%);
}

.timeline-events {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
    z-index: 1;
}

/* ========== 이벤트 아이템 ========== */
.timeline-event {
    position: relative;
    display: flex;
    justify-content: space-between;
    margin-bottom: 50px;
    width: 100%;
    transition: opacity 0.3s, transform 0.3s;
}

.timeline-event.left {
    flex-direction: row;
}

.timeline-event.right {
    flex-direction: row-reverse;
}

/* ========== 마커 (번호 표시) ========== */
.event-marker {
    position: absolute;
    top: 20px;
    left: 50%;
    width: 50px;
    height: 45px;
    background: var(--accent-color);
    transform: translateX(-50%);
    z-index: 10;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 3px;
    font-family: "Courier Prime", monospace;
    font-weight: bold;
    color: var(--black);
    font-size: 1.5rem;
    box-shadow: 0 5px 10px rgb(from var(--black) r g b / 50%);
}

/* ========== 이벤트 카드 ========== */
.event-card {
    width: 45%;
    background: rgb(from var(--card-bg-color) r g b / 90%);
    border: 1px solid var(--card-border-color);
    padding: 30px;
    border-radius: var(--card-border-radius);
    backdrop-filter: blur(5px);
    position: relative;
    height: fit-content;
    transition: box-shadow 0.3s ease;
}

.timeline-event.left .event-card {
    border-left: 5px solid var(--accent-color);
}

.timeline-event.right .event-card {
    border-right: 5px solid var(--accent-color);
}

.event-card:hover {
    box-shadow: 0 8px 32px rgb(from var(--black) r g b / 30%);
}

/* 드래그 핸들 - 편집 모드에서만 표시 */
.drag-handle {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.2s;
    color: var(--text-muted);
    padding: 5px;
    display: none;
}

.edit-mode .drag-handle {
    display: block;
}

.edit-mode .event-card:hover .drag-handle,
.edit-mode.editing-order .drag-handle {
    opacity: 1;
}

.drag-handle:active {
    cursor: grabbing;
}

/* 날짜 */
.event-date {
    display: block;
    font-family: "Courier Prime", monospace;
    color: var(--accent-color);
    font-size: 16px;
    letter-spacing: 1px;
    min-height: 1.2em;
}

/* 제목 */
.event-title {
    font-family: var(--title-font-family);
    font-size: var(--title-font-size);
    font-weight: 700;
    margin: 0 0 15px 0;
    line-height: 1.3;
    word-break: keep-all;
    color: var(--content-font-color);
    min-height: 1.3em;
}

/* 부제목 */
.event-subtitle {
    font-size: var(--sub-title-font-size);
    font-weight: 500;
    color: var(--text-muted);
    margin: 0 0 15px 0;
    line-height: 1.4;
    min-height: 1.2em;
}

/* 내용 */
.event-content {
    font-family: var(--content-font-family);
    font-size: var(--content-font-size);
    color: var(--content-font-color);
    line-height: 1.7;
    word-break: keep-all;
    text-align: justify;
    min-height: 3em;
}

.event-content p {
    margin: 0 0 1em 0;
}

.event-content p:last-child {
    margin-bottom: 0;
}

/* 도장 효과 */
.event-stamp {
    position: absolute;
    bottom: 15px;
    right: 15px;
    border: 2px solid rgb(from var(--accent-color) r g b / 40%);
    color: rgb(from var(--accent-color) r g b / 40%);
    padding: 4px 8px;
    font-family: "Courier Prime", monospace;
    font-weight: bold;
    transform: rotate(-15deg);
    pointer-events: none;
    font-size: 0.7rem;
}

/* 관리자 액션 버튼 - 편집 모드에서만 표시 */
.event-admin-actions {
    display: none;
    gap: 8px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-light);
    opacity: 0;
    transition: opacity 0.2s;
}

.edit-mode .event-admin-actions {
    display: flex;
}

.edit-mode .event-card:hover .event-admin-actions {
    opacity: 1;
}

.event-admin-actions button,
.event-admin-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    background: var(--card-bg-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.event-admin-actions button:hover,
.event-admin-actions a:hover {
    background: var(--accent-color);
    color: var(--black);
    border-color: var(--accent-color);
}

.btn-delete:hover {
    background: var(--error-color) !important;
    border-color: var(--error-color) !important;
    color: var(--white) !important;
}

/* ========== 이미지 영역 ========== */
.event-image-zone {
    width: 45%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    perspective: 1000px;
}

/* 사진 래퍼 */
.photo-wrapper {
    position: relative;
    display: inline-block;
    transform: rotate(-4deg) rotateY(-9deg) rotateX(13deg);
    transition: transform 0.4s ease;
}

.timeline-event:nth-child(even) .photo-wrapper {
    transform: rotate(2deg);
}

.timeline-event:hover .photo-wrapper {
    transform: rotate(0deg) scale(1.03);
}

/* 이미지 */
.event-img {
    display: block;
    max-width: 100%;
    width: 400px;
    height: auto;
    max-height: 320px;
    object-fit: contain;
    box-shadow: 0 8px 30px rgb(0 0 0 / 40%);
    filter: brightness(0.5) blur(1px);
}

.timeline-event:hover .event-img {
    filter: brightness(1) blur(0px);
}

/* 스포트라이트 - 사진 위에 탁 켜지는 빛 */
.photo-spotlight {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse 50% 100% at 70% 0%, rgb(255 255 255 / 60%) 0%, rgb(255 255 255 / 25%) 50%, transparent 60%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    mix-blend-mode: plus-lighter;
}

.timeline-event:hover .photo-spotlight {
    opacity: 1;
}

/* 이미지 없음 - 편집 모드에서만 표시 */
.no-image {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 200px;
    height: 150px;
    border: 2px dashed var(--border-light);
    border-radius: var(--card-border-radius);
    color: var(--text-muted);
}

.edit-mode .no-image {
    display: flex;
}

.btn-add-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
    font-size: 0.85rem;
}

.btn-add-image:hover {
    color: var(--accent-color);
}

/* ========== 편집 가능한 필드 - 편집 모드에서만 ========== */
.editable {
    border-radius: 4px;
    transition: background 0.2s, box-shadow 0.2s;
    outline: none;
}

.edit-mode .editable {
    cursor: text;
}

.edit-mode .editable:hover {
    background: rgb(from var(--primary-color) r g b / 10%);
}

.edit-mode .editable:focus,
.edit-mode .editable.editing {
    background: rgb(from var(--primary-color) r g b / 15%);
    box-shadow: 0 0 0 2px var(--accent-color);
}

.edit-mode .editable.saving {
    opacity: 0.6;
}

.edit-mode .editable.saved {
    animation: savedPulse 0.5s ease;
}

@keyframes savedPulse {
    0% { box-shadow: 0 0 0 2px var(--success-color); }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* ========== 정렬 모드 ========== */
.editing-order .timeline-event {
    cursor: move;
}

.editing-order .event-card {
    box-shadow: 0 0 0 2px var(--warning-color);
}

.editing-order .drag-handle {
    opacity: 1;
    color: var(--warning-color);
}

.ui-sortable-helper {
    transform: rotate(2deg);
    box-shadow: 0 10px 40px rgb(from var(--black) r g b / 40%);
}

.ui-sortable-placeholder {
    visibility: visible !important;
    background: rgb(from var(--primary-color) r g b / 20%);
    border: 2px dashed var(--accent-color);
    border-radius: var(--card-border-radius);
    min-height: 200px;
}

/* ========== 빈 상태 ========== */
.timeline-empty {
    text-align: center;
    padding: 100px 20px;
    color: var(--text-muted);
}

.timeline-empty p {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.btn-add-first {
    display: inline-block;
    padding: 15px 30px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    text-decoration: none;
    border-radius: var(--card-border-radius);
    font-weight: 500;
    transition: transform 0.2s;
}

.btn-add-first:hover {
    transform: translateY(-2px);
}

/* ========== 모달 ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgb(from var(--black) r g b / 80%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--card-bg-color);
    border-radius: var(--card-border-radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgb(from var(--black) r g b / 50%);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--content-font-color);
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--container-bg-color);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid var(--border-light);
}

/* 탭 */
.upload-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--accent-color);
    color: var(--black);
    border-color: var(--accent-color);
}

/* 업로드 영역 */
.upload-area {
    border: 2px dashed var(--border-light);
    border-radius: var(--card-border-radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent-color);
    background: rgb(from var(--primary-color) r g b / 10%);
}

.upload-area i {
    margin-bottom: 10px;
    color: var(--accent-color);
    font-size: 2rem;
    pointer-events: none;
}

.upload-area p {
    margin: 0;
    font-size: 0.9rem;
    pointer-events: none;
}

/* URL 입력 */
#image-url-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    background: var(--container-bg-color);
    color: var(--content-font-color);
    font-size: 0.95rem;
}

#image-url-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* 이미지 미리보기 */
.image-preview {
    margin-top: 20px;
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--card-border-radius);
    margin-bottom: 10px;
}

.btn-remove-preview {
    padding: 8px 16px;
    background: var(--error-color);
    color: var(--white);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

/* 모달 버튼 */
.btn-cancel {
    padding: 10px 20px;
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    cursor: pointer;
}

.btn-save-image {
    padding: 10px 20px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-save-image:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========== 반응형 ========== */
@media screen and (max-width: 900px) {
    .timeline-line {
        left: 20px;
        width: 3px;
    }

    .event-marker {
        left: 20px;
        width: 40px;
        height: 36px;
        font-size: 1rem;
    }

    .timeline-event,
    .timeline-event.left,
    .timeline-event.right {
        flex-direction: column;
        padding-left: 50px;
    }

    .event-card,
    .event-image-zone {
        width: 100%;
    }

    .event-image-zone {
        order: -1;
        margin-bottom: 20px;
        min-height: 180px;
    }

    .timeline-event.left .event-card,
    .timeline-event.right .event-card {
        border-left: none;
        border-right: none;
        border-top: 4px solid var(--accent-color);
    }

    .event-stamp {
        bottom: auto;
        top: 10px;
        right: 10px;
        transform: rotate(-10deg);
    }

    .timeline-title {
        font-size: 1.8rem;
    }

    .timeline-admin-controls {
        flex-direction: column;
        align-items: stretch;
    }
}

@media screen and (max-width: 480px) {
    .history-container {
        padding: 40px 10px 60px;
    }

    .timeline-header {
    }

    .event-card {
        padding: 20px;
    }

    .event-title {
        font-size: 1.2rem;
    }

    .event-admin-actions {
        opacity: 1;
    }
}
