/* ===================================================
 * @module vault-table | @vars --vt-*
 * @flow 맨 표·블록 편집기 표 기본 스타일 (래퍼는 inc/table-normalize.php)
 *
 * 사용자 자주 조정 포인트:
 *   - .vault-table --vt-*: 색 (라이트 기본값, 다크는 Color Theme 변수)
 *   - 제목 영역: 라이트 사선 탭 / 다크 빗금 밴드. 높이는 두 모드 모두 46px로 유지
 *   - --vt-col-min: 4열 이상 표의 열당 최소 폭 (모바일 가로 스크롤 기준)
 * =================================================== */

.vault-table {
    --vt-bg:       #ffffff;
    --vt-bg-soft:  #f0f0f3;
    --vt-bg-label: #f8f8fa;
    --vt-border:   #e4e4e9;
    --vt-line:     #ebebef;
    --vt-text:     #1d1d1f;
    --vt-accent:   var(--point-color, #C21807);
    --vt-col-min:  130px;

    width: 100%;
    max-width: 900px;
    margin: 1.5em auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--vt-bg);
    border: 1px solid var(--vt-border);
    border-radius: 10px;
}

html[data-color-scheme="dark"] .vault-table {
    --vt-bg:       var(--bg-panel, #1c1c1e);
    --vt-bg-soft:  var(--bg-soft, #2a2a2e);
    --vt-bg-label: var(--bg-soft, #2a2a2e);
    --vt-border:   var(--border-main, #2e2e36);
    --vt-line:     var(--border-main, #2e2e36);
    --vt-text:     var(--text-main, #e0e0e0);
    --vt-accent:   var(--link-entry, #8be9fd);
}

/* ── 표 ── */
.entry-content .vault-table table {
    width: 100%;
    max-width: none;
    min-width: calc(var(--vt-cols, 0) * var(--vt-col-min));
    margin: 0;
    border: 0;
    border-collapse: collapse;
    background: transparent;
    font-size: 14px;
    line-height: 1.55;
    word-break: keep-all;
}

.entry-content .vault-table table :is(thead, tbody, tfoot) {
    border: 0;
}

.entry-content .vault-table table :is(th, td) {
    padding: 12px 16px;
    border: 0;
    border-bottom: 1px solid var(--vt-line);
    color: var(--vt-text);
    font-size: inherit;
    text-align: left;
    vertical-align: middle;
}

/* 편집기에서 지정한 정렬 유지 */
.entry-content .vault-table table :is(th, td).has-text-align-center { text-align: center; }
.entry-content .vault-table table :is(th, td).has-text-align-right  { text-align: right; }

.entry-content .vault-table table thead th,
.entry-content .vault-table table thead td {
    background: var(--vt-bg-soft);
    border-bottom-color: var(--vt-border);
    font-size: 13px;
    font-weight: 700;
}

/* 항목 열 */
.entry-content .vault-table table tbody th[scope="row"] {
    background: var(--vt-bg-label);
    border-right: 1px solid var(--vt-line);
    font-weight: 600;
}

.entry-content .vault-table table > :last-child > tr:last-child > :is(th, td) {
    border-bottom: 0;
}

.entry-content .vault-table table td :is(strong, mark) {
    color: var(--vt-accent);
}

.entry-content .vault-table table td mark {
    background: transparent;
    font-weight: 700;
}

/* ── 제목: 라이트 = 사선 탭 ── */
.entry-content .vault-table table caption {
    caption-side: top;
    padding: 0;
    border-bottom: 2px solid var(--vt-accent);
    color: var(--vt-text);
    font-size: 14px;
    font-weight: 800;
    line-height: 20px;
    text-align: left;
}

.entry-content .vault-table table caption > span {
    display: block;
    width: max-content;
    max-width: 100%;
    padding: 12px 34px 12px 16px;
    background: var(--vt-accent);
    color: #ffffff;
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 100%, 0 100%);
}

/* ── 제목: 다크 = 빗금 밴드 (색은 변수, 모양이 달라 선언 분리) ── */
html[data-color-scheme="dark"] .entry-content .vault-table table caption {
    position: relative;
    padding: 12px 16px 13px 28px;
    border-bottom: 1px solid var(--vt-border);
    background: repeating-linear-gradient(-45deg, transparent 0 6px, var(--vt-border) 6px 7px);
}

html[data-color-scheme="dark"] .entry-content .vault-table table caption::before {
    content: "";
    position: absolute;
    top: 12px;
    bottom: 13px;
    left: 14px;
    width: 4px;
    border-radius: 2px;
    background: var(--vt-accent);
}

html[data-color-scheme="dark"] .entry-content .vault-table table caption > span {
    padding: 0 9px;
    border-radius: 4px;
    background: var(--vt-bg);
    color: var(--vt-text);
    clip-path: none;
}

/* ── 블록 표 figure: 맨 표와 같은 폭, 본문 가운데 ── */
/* style.css가 figure의 max-width를 100%로 고정하므로 폭은 width로 제한 */
.entry-content figure.wp-block-table:has(> .vault-table) {
    width: min(100%, 900px);
    margin: 1.5em auto;
}

.entry-content figure.wp-block-table > .vault-table {
    margin: 0;
}

/* 표 설명(figcaption) */
.entry-content .wp-block-table > .vault-table + figcaption {
    margin: 0;
    padding: 8px 12px 0;
    font-size: 12px;
    text-align: right;
    opacity: .7;
    overflow-wrap: anywhere;
}

@media (max-width: 640px) {
    .vault-table {
        --vt-col-min: 110px;
    }

    .entry-content .vault-table table {
        font-size: 13px;
    }

    .entry-content .vault-table table :is(th, td) {
        padding: 9px 12px;
    }
}
