/* ========================================
   똑똑 - 서비스이용약관 페이지 스타일
   ======================================== */

/* 약관 컨테이너 */
.terms-section {
    min-height: calc(100vh - 200px);
    padding-top: 100px;
    padding-bottom: var(--spacing-xxl);
    background: var(--bg-primary);
}

.terms-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

/* 표가 많은 문서(개인정보처리방침)는 본문을 넓게 */
.terms-container--wide {
    max-width: 1040px;
}

/* 헤더 */
.terms-header {
    text-align: center;
    margin-bottom: var(--spacing-xxl);
    padding-bottom: var(--spacing-xl);
    border-bottom: 2px solid var(--border-color);
}

.terms-header h1 {
    font-size: var(--font-4xl);
    margin-bottom: var(--spacing-md);
    background: linear-gradient(135deg, var(--text-primary), var(--brand-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.terms-header .last-updated {
    color: var(--text-tertiary);
    font-size: var(--font-sm);
}

/* 약관 콘텐츠 */
.terms-content {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xxl);
    line-height: 1.8;
    /* 한글은 어절 단위로 줄바꿈하고, URL처럼 긴 단어만 끊는다 */
    word-break: keep-all;
    overflow-wrap: break-word;
}

.terms-container--wide .terms-content {
    padding: var(--spacing-xl);
}

/* 장 제목 (Chapter) */
.terms-content h2 {
    font-size: var(--font-2xl);
    color: var(--text-primary);
    margin-top: var(--spacing-xxl);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid rgba(66, 133, 244, 0.3);
    position: relative;
}

.terms-content h2:first-child {
    margin-top: 0;
}

.terms-content h2::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: var(--brand-blue);
}

/* 조 제목 (Article) */
.terms-content h3 {
    font-size: var(--font-xl);
    color: var(--text-primary);
    margin-top: var(--spacing-xl);
    margin-bottom: var(--spacing-md);
    font-weight: 600;
}

/* 본문 */
.terms-content p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
    font-size: var(--font-base);
}

/* 목록 */
.terms-content ul,
.terms-content ol {
    margin-left: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

.terms-content li {
    margin-bottom: var(--spacing-sm);
    line-height: 1.8;
}

/* 중첩 목록 */
.terms-content ul ul,
.terms-content ol ol {
    margin-top: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

/* 강조 */
.terms-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* 항목 번호 스타일 개선 */
/* 1단계: 항 (1. 2. 3. ...) */
.terms-content > ol,
.terms-content h3 + ol,
.terms-content h3 + p + ol {
    counter-reset: item;
    list-style-type: none;
}

.terms-content > ol > li,
.terms-content h3 + ol > li,
.terms-content h3 + p + ol > li {
    counter-increment: item;
    position: relative;
    padding-left: var(--spacing-lg);
}

.terms-content > ol > li::before,
.terms-content h3 + ol > li::before,
.terms-content h3 + p + ol > li::before {
    content: counter(item) ". ";
    position: absolute;
    left: 0;
    color: var(--brand-blue);
    font-weight: 600;
}

/* 2단계: 호 (1) 2) 3) ...) */
.terms-content ol ol {
    counter-reset: subitem;
    list-style-type: none;
    margin-top: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.terms-content ol ol > li {
    counter-increment: subitem;
    position: relative;
    padding-left: var(--spacing-lg);
}

.terms-content ol ol > li::before {
    content: counter(subitem) ") ";
    position: absolute;
    left: 0;
    color: var(--text-secondary);
    font-weight: 500;
}

/* 부칙 */
.terms-content .addendum {
    margin-top: var(--spacing-xxl);
    padding-top: var(--spacing-xl);
    border-top: 2px solid var(--border-color);
}

.terms-content .addendum h2 {
    border-bottom: none;
    color: var(--brand-blue);
}

/* 테이블 */
.terms-content table {
    width: 100%;
    /* collapse에서는 border-radius가 무시되므로 separate로 두고 셀 테두리로 구분선을 그린다 */
    border-collapse: separate;
    border-spacing: 0;
    margin: var(--spacing-md) 0 var(--spacing-lg);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    font-size: 0.9375rem;
    line-height: 1.65;
}

.terms-content th,
.terms-content td {
    padding: 0.875rem 1rem;
    text-align: left;
    vertical-align: top;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    /* 열이 많은 표도 본문 폭 안에 들어오도록 필요하면 단어 중간에서도 끊는다 */
    overflow-wrap: anywhere;
}

.terms-content tr > :last-child {
    border-right: none;
}

.terms-content tbody:last-child > tr:last-child > * {
    border-bottom: none;
}

.terms-content thead th {
    background: rgba(66, 133, 244, 0.1);
    color: var(--text-primary);
    font-weight: 600;
    border-bottom-color: rgba(66, 133, 244, 0.3);
}

.terms-content tbody th {
    color: var(--text-primary);
    font-weight: 600;
}

.terms-content td {
    color: var(--text-secondary);
}

.terms-content td p {
    margin: 0;
    font-size: inherit;
    color: inherit;
}

.terms-content td p + p {
    margin-top: var(--spacing-xs);
}

/* 묶음 행: 법적 근거처럼 아래 여러 행에 공통인 값 */
.terms-content .terms-table-group th {
    background: rgba(255, 255, 255, 0.04);
    font-size: var(--font-sm);
}

.terms-table-group-label {
    display: inline-block;
    margin-right: 0.25rem;
    padding: 0 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(66, 133, 244, 0.15);
    color: var(--brand-blue);
    font-size: var(--font-xs);
    line-height: 1.6rem;
}

/* 처리 목적·항목·보유기간 표: 내용 길이에 맞춰 열 너비 고정 */
.terms-table--processing {
    table-layout: fixed;
}

.terms-table--processing thead th:nth-child(1) { width: 17%; }
.terms-table--processing thead th:nth-child(2) { width: 27%; }
.terms-table--processing thead th:nth-child(3) { width: 38%; }

/* 국외 이전 표: 7열이라 짧은 값(이전국가, 이용 목적) 열을 좁게 */
.terms-table--transfer {
    table-layout: fixed;
}

.terms-table--transfer thead th:nth-child(1) { width: 14%; }
.terms-table--transfer thead th:nth-child(2) { width: 12%; }
.terms-table--transfer thead th:nth-child(3) { width: 19%; }
.terms-table--transfer thead th:nth-child(4) { width: 10%; }
.terms-table--transfer thead th:nth-child(5) { width: 15%; }
.terms-table--transfer thead th:nth-child(6) { width: 10%; }

/* CTA 버튼 섹션 */
.terms-cta {
    text-align: center;
    margin-top: var(--spacing-xxl);
    padding-top: var(--spacing-xl);
    border-top: 1px solid var(--border-color);
}

.terms-cta .btn {
    margin: 0 var(--spacing-sm);
}

/* 반응형 디자인 */
@media (max-width: 1024px) {
    .terms-container--wide .terms-content {
        padding: var(--spacing-lg);
    }
}

@media (max-width: 768px) {
    .terms-section {
        padding-top: 80px;
    }

    .terms-container {
        padding: 0 var(--spacing-md);
    }

    /* 좁은 화면에서는 본문 상자를 없애 글자 폭을 확보 */
    .terms-content,
    .terms-container--wide .terms-content {
        padding: 0;
        background: none;
        border: none;
        border-radius: 0;
    }

    .terms-header h1 {
        font-size: var(--font-3xl);
    }

    .terms-content h2 {
        font-size: var(--font-xl);
    }

    .terms-content h3 {
        font-size: var(--font-lg);
    }

    .terms-content ul,
    .terms-content ol {
        margin-left: var(--spacing-md);
    }

    .terms-content table {
        font-size: var(--font-sm);
    }

    .terms-content th,
    .terms-content td {
        padding: 0.625rem 0.75rem;
    }

    .terms-cta .btn {
        display: block;
        margin: var(--spacing-sm) 0;
        width: 100%;
    }
}

/* 1024px 이하: .terms-table은 행 단위 카드로 (7열인 국외 이전 표는 이보다 좁으면 단어가 끊김). 인쇄 시에는 표 유지 */
@media screen and (max-width: 1024px) {
    .terms-content .terms-table,
    .terms-content .terms-table tbody,
    .terms-content .terms-table tr,
    .terms-content .terms-table th,
    .terms-content .terms-table td {
        display: block;
    }

    .terms-content .terms-table {
        border: none;
        border-radius: 0;
        background: none;
        overflow: visible;
        font-size: 0.9375rem;
    }

    .terms-content .terms-table thead {
        display: none;
    }

    .terms-content .terms-table tr {
        margin-bottom: 0.75rem;
        padding: 1rem 1.125rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        background: rgba(255, 255, 255, 0.03);
    }

    .terms-content .terms-table th,
    .terms-content .terms-table td {
        width: auto;
        padding: 0;
        border: none;
        background: none;
    }

    /* 행 제목(구분)은 카드 제목으로 */
    .terms-content .terms-table tbody th {
        margin-bottom: 0.75rem;
        font-size: var(--font-base);
    }

    .terms-content .terms-table td + td {
        margin-top: 0.75rem;
    }

    /* 열 제목 대신 각 값 위에 붙는 항목명 */
    .terms-content .terms-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.125rem;
        color: var(--text-tertiary);
        font-size: 0.8125rem;
        font-weight: 600;
    }

    /* 묶음 행은 카드가 아니라 아래 카드들의 소제목 */
    .terms-content .terms-table .terms-table-group {
        margin: var(--spacing-md) 0 0.75rem;
        padding: 0;
        border: none;
        background: none;
    }

    .terms-content .terms-table .terms-table-group th {
        margin: 0;
        font-size: var(--font-sm);
    }
}

/* 프린트 스타일 */
@media print {
    .main-nav,
    .main-footer,
    .terms-cta {
        display: none;
    }

    .terms-section {
        padding-top: 0;
    }

    .terms-content {
        background: white;
        border: none;
        box-shadow: none;
        color: black;
    }

    .terms-content h2,
    .terms-content h3,
    .terms-content p,
    .terms-content li,
    .terms-content strong,
    .terms-content th,
    .terms-content td {
        color: black;
    }

    .terms-content table,
    .terms-content th,
    .terms-content td {
        border-color: #ccc;
    }
}
