/* web/static/css/style.css */
:root {
    /* 라이트 모드 기본 변수 */
    --color-bg-primary: #ffffff;
    --color-bg-secondary: #f0f0f0;
    --color-bg-accent: #bfdbfe;

    --color-text-primary: #1f2937;
    --color-text-secondary: #4b5563;
    --color-text-accent: #6b7280;

    --color-border-primary: #d1d5db;
    --color-border-secondary: #9ca3af;

    --color-button-primary: #3b82f6;
    --color-button-hover: #2563eb;

    --color-hover-bg: #e5edff;
    --color-shadow: rgba(10, 10, 10, 0.1);

    --color-action-view: #2563eb;
    --color-action-view-hover: #1e40af;
    --color-action-edit: #4f46e5;
    --color-action-edit-hover: #312e81;
    --color-action-delete: #dc2626;
    --color-action-delete-hover: #7f1d1d;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg-primary: #1f2937;
        --color-bg-secondary: #111;
        --color-bg-accent: #3b82f6;

        --color-text-primary: #f9fafb;
        --color-text-secondary: #e5e7eb;
        --color-text-accent: #9ca3af;

        --color-border-primary: #4b5563;
        --color-border-secondary: #6b7280;

        --color-button-primary: #60a5fa;
        --color-button-hover: #93c5fd;

        --color-hover-bg: #2563eb;
        --color-shadow: rgba(255, 255, 255, 0.4);

        --color-action-view: #60a5fa;
        --color-action-view-hover: #93c5fd;
        --color-action-edit: #818cf8;
        --color-action-edit-hover: #a5b4fc;
        --color-action-delete: #f87171;
        --color-action-delete-hover: #fca5a5;
    }
}

/* 수동 다크 모드 클래스 */
.dark {
    --color-bg-primary: #1f2937;
    --color-bg-secondary: #111827;
    --color-bg-accent: #3b82f6;

    --color-text-primary: #f9fafb;
    --color-text-secondary: #e5e7eb;
    --color-text-accent: #9ca3af;

    --color-border-primary: #4b5563;
    --color-border-secondary: #6b7280;

    --color-button-primary: #60a5fa;
    --color-button-hover: #93c5fd;

    --color-hover-bg: #2563eb;
    --color-shadow: rgba(255, 255, 255, 0.4);

    --color-action-view: #60a5fa;
    --color-action-view-hover: #93c5fd;
    --color-action-edit: #818cf8;
    --color-action-edit-hover: #a5b4fc;
    --color-action-delete: #f87171;
    --color-action-delete-hover: #fca5a5;
}

/* 기본 스타일 재정의 */
html {
    scrollbar-gutter: stable;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.5;
}

input,
textarea,
select {
    background-color: var(--color-bg-secondary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-primary);
    border-radius: 0.375rem;
    padding: 0.5rem;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.bg-white {
    background-color: var(--color-bg-primary) !important;
}

.bg-black {
    background-color: var(--color-bg-secondary) !important;
}

.bg-hover {
    background-color: var(--color-hover-accent) !important;
}

.shadow {
    box-shadow: 0 1px 3px var(--color-shadow) !important;
}

.text-action-view {
    color: var(--color-action-view);
}

.text-action-view:hover {
    color: var(--color-action-view-hover);
}

.text-action-edit {
    color: var(--color-action-edit);
}

.text-action-edit:hover {
    color: var(--color-action-edit-hover);
}

.text-action-delete {
    color: var(--color-action-delete);
}

.text-action-delete:hover {
    color: var(--color-action-delete-hover);
}

/* 마크다운 렌더링을 위한 Prose 스타일 설정 */
.prose {
    display: block;
    position: relative;
    color: var(--color-text-primary);
    /* max-width: 65ch; */
    /* margin: 0 10px 0 0px; */
}

.prose p {
    margin-top: 1.25em;
    margin-bottom: 1.25em;
}

.prose a {
    color: var(--color-button-primary);
    text-decoration: underline;
    font-weight: 500;
}

.prose strong {
    font-weight: 600;
    color: var(--color-text-primary);
}

.prose h1 {
    color: var(--color-text-primary);
    font-weight: 800;
    font-size: 2.25em;
    margin-top: 0;
    margin-bottom: 0.8888889em;
    line-height: 1.1111111;
}

.prose h2 {
    color: var(--color-text-primary);
    font-weight: 700;
    font-size: 1.5em;
    margin-top: 2em;
    margin-bottom: 1em;
    line-height: 1.3333333;
}

.prose h3 {
    color: var(--color-text-primary);
    font-weight: 600;
    font-size: 1.25em;
    margin-top: 1.6em;
    margin-bottom: 0.6em;
    line-height: 1.6;
}

.prose ul {
    margin-top: 1.25em;
    margin-bottom: 1.25em;
    list-style-type: disc;
    padding-left: 1.625em;
}

.prose ol {
    margin-top: 1.25em;
    margin-bottom: 1.25em;
    list-style-type: decimal;
    padding-left: 1.625em;
}

.prose li {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

.prose blockquote {
    font-weight: 500;
    font-style: italic;
    color: var(--color-text-primary);
    border-left-width: 0.25rem;
    border-left-color: var(--color-border-primary);
    quotes: "\201C" "\201D" "\2018" "\2019";
    margin-top: 1.6em;
    margin-bottom: 1.6em;
    padding-left: 1em;
}

.prose code {
    color: var(--color-text-primary);
    font-weight: 600;
    font-size: 0.875em;
}

.prose pre {
    color: var(--color-text-secondary);
    background-color: var(--color-bg-secondary);
    overflow-x: auto;
    font-size: 0.875em;
    line-height: 1.7142857;
    margin-top: 1.7142857em;
    margin-bottom: 1.7142857em;
    border-radius: 0.375rem;
    padding: 0.8571429em 1.1428571em;
}

.prose pre code {
    background-color: transparent;
    border-width: 0;
    border-radius: 0;
    padding: 0;
    font-weight: 400;
    color: inherit;
    font-size: inherit;
    font-family: inherit;
    line-height: inherit;
}

/* 테이블 스타일 */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* 페이지네이션 스타일 */
.pagination {
    display: flex;
    justify-content: center;
    list-style: none;
    padding: 0;
    margin: 2rem 0;
}

.pagination li {
    margin: 0 0.25rem;
}

.pagination a {
    display: inline-block;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border-primary);
    border-radius: 0.375rem;
    color: var(--color-text-primary);
    text-decoration: none;
}

.pagination a:hover {
    background-color: var(--color-bg-secondary);
}

.pagination .active a {
    background-color: var(--color-button-primary);
    color: white;
    border-color: var(--color-button-primary);
}

/* Alpine.js 전환 애니메이션 */
[x-cloak] {
    display: none !important;
}

.fade-enter-active,
.fade-leave-active {
    transition: opacity 0.3s;
}

.fade-enter,
.fade-leave-to {
    opacity: 0;
}

/* 게시판 스타일 */
.board-card {
    border: 1px solid var(--color-border-primary);
    transition: all 0.2s ease-in-out;
}

.board-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px var(--color-shadow),
        0 4px 6px -2px var(--color-shadow);
}

/* 게시물 내용 스타일 */
.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.375rem;
    margin: 1.5rem 0;
}

/* 갤러리 스타일 */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px var(--color-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 6px var(--color-shadow);
}

.gallery-image-container {
    position: relative;
    padding-bottom: 75%;
    /* 4:3 비율 */
    background-color: var(--color-bg-secondary);
}

.gallery-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-info {
    padding: 0.75rem;
    background-color: var(--color-bg-primary);
}

.gallery-title {
    margin-bottom: 0.5rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--color-text-accent);
}

/* 이미지 */
p img {
    display: inline-block;
    max-width: 920px;
    min-width: 320px;
    height: auto;
    padding: 0.5rem;
}

/* 비디오 */
p video {
    width: 90%;
    max-width: 800px;
    height: auto;
    border-radius: 4px;
    display: block;
    margin: 1em 0;
}

#comments-container p img,
#answers-container p img {
    max-width: 480px;
}

@media (max-width: 640px) {
    p img {
        position: relative;
        width: 100%;
    }

    #comments-container p img,
    #answers-container p img {
        width: unset;
        height: unset;
        min-width: 240px;
        max-width: 290px;
    }
}

/* 동영상 */
p iframe.video {
    display: inline-block;
    max-width: 920px;
    min-width: 640px;
    min-height: 360px;
}

p iframe.sound {
    max-width: 920px;
    min-width: 640px;
    min-height: unset;
    height: 125px;
}

p iframe.vertical {
    min-width: 360px;
    aspect-ratio: 9/19;
}

@media (max-width: 640px) {

    p iframe.video,
    p iframe.sound {
        max-width: unset;
        min-width: unset;
        min-height: unset;

        width: 100%;
    }

    p iframe.video {
        height: auto;
        aspect-ratio: 16/9;
    }

    p iframe.vertical {
        aspect-ratio: 10/25;
    }
}

/* 이미지 뷰어 스타일 */

/* 포스트 내용 이미지 스타일 */
p img {
    max-width: 100%;
    height: auto;
    cursor: pointer;
    transition: opacity 0.2s;
}

p img:hover {
    opacity: 0.9;
}

/* 이미지 뷰어 애니메이션 */
.image-viewer-enter {
    opacity: 0;
}

.image-viewer-enter-active {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.image-viewer-leave {
    opacity: 1;
}

.image-viewer-leave-active {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* 썸네일 이미지 스타일 */
.thumbnail-image {
    object-fit: cover;
    width: 100%;
    height: 100%;
    transition: transform 0.3s ease;
}

.thumbnail-container:hover .thumbnail-image {
    transform: scale(1.05);
}

/* ip 리스트 */
.ip-list-container {
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid var(--color-border-primary);
    padding: 0.5rem;
    border-radius: 0.25rem;
}

.ip-list-item {
    margin-bottom: 0.25rem;
    padding: 0.25rem;
}

.ip-list-item:hover {
    background-color: var(--color-bg-secondary);
}