/**
 * 열린마당 게시판(수요자 콘텐츠 관련 공지사항) — 공지 상세·형제 게시판 목록 보정.
 *
 * 열린마당 목록은 공식 퍼블 board/normal_list 클래스를 쓴다.
 * 아래 간격 보정은 그 목록·상세에만 적용한다.
 */

/*
 * 상단 간격 과다 보정
 * - pub #contents{margin-top:var(--row-gap-lg)} → 40~80px
 * - cspLayout #contents:has(> .law_list){padding-top}/* (#contents 위쪽 여백은 pub/css/custom.css 공통 규칙으로 통일) */

.notice-table {
    margin-top: 8px;
}

.notice-table .notice-col-no {
    width: 88px;
}

.notice-table .notice-col-dt {
    width: 120px;
}

.notice-table td.notice-ttl {
    text-align: left;
}

.notice-table td.notice-ttl a {
    color: var(--primary-60);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.notice-table td.notice-empty {
    padding: 48px 20px;
    color: var(--gray-70);
}

/* ── 상세 (공지 UI-A-05-01-02 / 신규 콘텐츠 UI-A-05-02-02) ── */

.notice-detail {
    /*
     * 상세 본문 글자 크기 — 화면 폭에 따라 17px(모바일) ~ 19px(1667px 이상)로 바뀐다.
     * 공용 토큰은 21px 이상만 반응형(--text-21~)이고 20px 이하는 고정이라 여기서 정의한다.
     * rem 기준이라 사이트 화면 크기(확대) 기능에도 함께 커진다.
     */
    --board-body-text: clamp(1.0625rem, calc(0.24vw + 0.9375rem), 1.1875rem);
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 40px;
}

/*
 * 상세 제목 영역(.notice-meta) — 표 칸 대신 "큰 제목 → 정보 한 줄 → 아래 구분선" 형태.
 * 적용 범위: 열린마당 상세(공지·신규 콘텐츠·이벤트·최신 법령뉴스·이용후기) + 서비스 소개 이용안내 상세.
 * 마크업(table·th·td)은 그대로 두고 CSS 로만 배치한다 → 화면·템플릿 수정 없음, 스크린리더는 라벨·값을 그대로 읽는다.
 * '제목' 라벨만 시각적으로 숨기고, 나머지 라벨(등록일자·이름·생활분야·첨부파일)은 작은 회색 글자로 값 앞에 둔다.
 * 개선의견(.opinion-meta)은 기존 표 형태를 유지한다.
 */
.notice-meta table {
    display: block;
    border: 0;
}

.notice-meta colgroup {
    display: none;
}

.notice-meta tbody {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 8px;
    row-gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--alpha-g20);
}

/* 행 구분 없이 셀을 한 흐름으로 배치(제목 → 정보 라벨·값) */
.notice-meta tr {
    display: contents;
}

/* 퍼블 .table_wrap th/td(테두리·가운데 정렬)와 화면별 폭(.review-meta th 등)보다 특정성이 높아야 한다 */
.notice-meta table tbody th,
.notice-meta table tbody td {
    display: block;
    width: auto;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
    font-size: var(--text-17);
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
}

.notice-meta table tbody th {
    color: var(--gray-60);
}

.notice-meta table tbody td {
    margin-right: 4px;
    color: var(--gray-80);
}

/* '제목' 라벨: 화면에서 숨김, 보조기기에는 유지 */
.notice-meta table tbody th:has(+ .notice-meta-ttl) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.notice-meta table tbody td.notice-meta-ttl {
    flex: 0 0 100%;
    margin: 0 0 clamp(4px, 1vw, 12px);
    /* 최소 20px ~ 최대 28px — 이슈 Q&A 상세 제목과 같은 크기(종전 최대 40px 는 본문 대비 과했다) */
    font-size: var(--text-28);
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.02em;
    color: var(--gray-90);
}

/* 정보 항목 사이 세로 구분선(첫 항목·첨부파일 줄 제외) */
.notice-meta table tbody th:not(:has(+ .notice-meta-ttl))::before {
    content: "";
    display: inline-block;
    width: 1px;
    height: 0.8em;
    margin-right: 12px;
    vertical-align: -0.05em;
    background: var(--alpha-g20);
}

.notice-meta table tbody .notice-meta-ttl + th::before,
.notice-meta table tbody tr:has(.notice-meta-file) th::before {
    display: none;
}

/* 첨부파일은 정보 줄 아래 별도 줄 */
.notice-meta tr:has(.notice-meta-file) {
    display: flex;
    flex: 0 0 100%;
    align-items: baseline;
    gap: 8px;
}

/*
 * 열린마당 상세 메타 테이블 폭 — 개선의견은 라벨:값 = 2:3 (한 줄 20% : 30% : 20% : 30%).
 * 공지·신규 콘텐츠·이벤트·최신 법령뉴스·이용후기 상세(.notice-meta)는 아래에서 라벨 열만 좁힌다.
 *
 * 폭은 반드시 <colgroup> 으로 준다. reset.css 가 table-layout:fixed 를 전역 적용하는데,
 * 이 구성에서는 th/td 에 건 width 가 반영되지 않고 열이 균등 분배된다(실측). col 은 정확히 먹는다.
 * colgroup 이 없는 테이블(서비스 소개 이용안내 등)은 이 규칙의 영향을 받지 않는다.
 *
 * 모바일(<=640px)은 th/td 를 block 으로 쌓으므로 열 폭 자체가 의미를 잃는다.
 */
.opinion-meta colgroup col:nth-child(odd) {
    width: 20%;
}

.opinion-meta colgroup col:nth-child(even) {
    width: 30%;
}

/* 긴 제목·파일명이 고정폭 열을 넘치지 않도록 한다. */
.notice-meta table tbody td,
.opinion-meta table tbody td {
    overflow-wrap: anywhere;
}

.notice-meta .notice-meta-file {
    text-align: left;
}

.notice-meta .notice-meta-file a {
    color: var(--primary-60);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.notice-body {
    border: 1px solid var(--alpha-g20);
    border-radius: var(--radius-08);
    background: var(--gray-0);
    padding: clamp(20px, 3vw, 32px);
    min-height: 200px;
}

.notice-body-inner {
    font-size: var(--board-body-text, var(--text-18));
    color: var(--gray-80);
    line-height: 1.7;
    word-break: break-word;
}

/*
 * 관리자 에디터로 저장된 본문은 글자 크기가 인라인(9.8pt~11pt 등)으로 박혀 있어
 * 위 기본 크기를 무시하고 13~15px 로 작게 보인다. 저장 데이터는 그대로 두고 화면에서만 기본 크기로 맞춘다.
 * 인라인 style 을 이기려면 !important 가 필요하다. 굵게·색상·정렬 등 다른 서식은 유지된다.
 */
.notice-body-inner [style*="font-size"],
.notice-body-inner font[size] {
    font-size: inherit !important;
}

.notice-body-inner img {
    max-width: 100%;
    height: auto;
}

.notice-body-inner table {
    max-width: 100%;
    overflow-x: auto;
}

.notice-actions {
    justify-content: flex-end;
}

.notice-actions .btn.is-disabled {
    --board-disabled-text-color: var(--gray-60);
    color: var(--board-disabled-text-color);
    opacity: 1;
    pointer-events: none;
    cursor: not-allowed;
}

.notice-detail .open-board-actions {
    justify-content: center;
    justify-self: stretch;
}

.notice-detail .open-board-actions :is(button, .is-disabled) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 76px;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--gray-60);
    border-radius: var(--radius-06);
    background: var(--gray-0);
    color: var(--gray-80);
    font-size: var(--text-15);
    font-family: inherit;
}

.notice-detail .open-board-actions button {
    cursor: pointer;
}

.notice-detail .open-board-actions .is-disabled {
    --board-disabled-text-color: var(--gray-60);
    color: var(--board-disabled-text-color);
    opacity: 1;
    pointer-events: none;
    cursor: not-allowed;
}

@media (max-width: 640px) {
    /* .notice-meta 는 위의 흐름 배치가 좁은 폭에서도 그대로 줄바꿈되므로 별도 규칙이 없다. */

    .notice-actions {
        justify-content: stretch;
    }

    .notice-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .notice-detail .open-board-actions :is(button, .is-disabled) {
        min-width: 0;
    }
}


/* 열린마당 목록·상세와 서비스 이용안내의 공통 화면 밀도 */
#container:has(#frm_noticeSearch),
#container:has(#frm_newContentsSearch),
#container:has(#frm_eventSearch),
#container:has(#frm_issueLawSearch),
#container:has(#frm_issueQaSearch),
#container:has(#frm_reviewSearch),
#container:has(#frm_opinionSearch),
#container:has(#frm_guideSearch),
#container:has(> #contents > .notice-detail) {
    padding-bottom: 0;
}

#contents:has(#frm_noticeSearch),
#contents:has(#frm_newContentsSearch),
#contents:has(#frm_eventSearch),
#contents:has(#frm_issueLawSearch),
#contents:has(#frm_issueQaSearch),
#contents:has(#frm_reviewSearch),
#contents:has(#frm_opinionSearch),
#contents:has(#frm_guideSearch),
#contents:has(> .notice-detail) {
    padding-bottom: 36px;
}

#contents:has(.board_page) .board_page {
    gap: 28px;
    padding-bottom: 0;
}

#contents:has(.board_page) .board_filter {
    padding: 16px 24px;
}

#contents:has(.board_page) .board_filter_row {
    gap: 16px;
}

#contents:has(.board_page) :is(.board_filter_select, .board_filter input[type="search"], .board_filter_btn) {
    height: 44px;
    font-size: var(--text-17);
}

#contents:has(.board_page) .board_filter_divider {
    height: 44px;
}

#contents:has(.board_page) .board_result_head {
    min-height: 56px;
}

#contents:has(.board_page) .board_table :is(th, td) {
    height: 52px;
    padding-block: 0;
}

/* 화면크기를 키워도 답변 상태와 날짜가 한 줄에 들어가도록 열 너비를 본문 글자 크기에 맞춘다. */
.open-board-list {
    --board-meta-padding: clamp(4px, 1vw, 16px);
}

.open-board-list .board_col_reply {
    width: calc(4 * var(--text-17) + 2 * var(--board-meta-padding));
}

.open-board-list .board_col_date {
    width: calc(6 * var(--text-17) + 2 * var(--board-meta-padding));
}

.open-board-list :is(.cell_reply, .cell_date) {
    padding-inline: var(--board-meta-padding);
    white-space: nowrap;
}

#contents:has(.board_page) .board_table tbody td,
#contents:has(.board_page) .improve_list .board_table tbody .cell_no {
    font-size: var(--text-17);
}

#contents:has(.board_page) .board_subject_link {
    height: 52px;
    padding-block: 0;
    line-height: 32px;
}

#contents:has(.board_page) .paging,
#contents:has(.board_page) .board_paging_row {
    margin-top: 20px;
}

#contents > .notice-detail {
    gap: 20px;
    padding-bottom: 0;
}

@media (max-width: 640px) {
    #contents:has(.board_page),
    #contents:has(> .notice-detail) {
        padding-bottom: 28px;
    }

    #contents:has(.board_page) .board_page {
        gap: 20px;
    }
}

#contents:has(.board_page) .board_subject_link {
    box-sizing: border-box;
}

@media (max-width: 640px) {
    #contents:has(#frm_noticeSearch),
    #contents:has(#frm_newContentsSearch),
    #contents:has(#frm_eventSearch),
    #contents:has(#frm_issueLawSearch),
    #contents:has(#frm_issueQaSearch),
    #contents:has(#frm_reviewSearch),
    #contents:has(#frm_opinionSearch),
    #contents:has(#frm_guideSearch),
    #contents:has(> .notice-detail) {
        padding-bottom: 28px;
    }
}

/* 열린마당 목록 제목을 행의 수직 중앙에 정렬 */
#contents:has(.board_page) .board_table td.cell_subject {
    vertical-align: middle;
}

#contents:has(.board_page) .board_subject_link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    line-height: 1.45;
}

/* 이용후기 및 개선의견 */
#contents .board_page:has(.feedback-board-heading) {
    gap: 16px;
}

#contents .board_page:has(.feedback-board-heading) .board_list_section {
    margin-block-start: 12px;
}

.feedback-board-heading {
    display: grid;
    gap: clamp(16px, 2vw, 28px);
}

.feedback-board-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-bottom: 1px solid var(--alpha-g20, #d0d5dd);
}

.feedback-board-tab {
    display: grid;
    place-items: center;
    min-height: 52px;
    margin-bottom: -1px;
    padding: 8px 12px;
    border-bottom: 4px solid transparent;
    color: var(--gray-70, #475467);
    font-size: var(--text-20, 20px);
    font-weight: 700;
    text-align: center;
    word-break: keep-all;
}

.feedback-board-tab:is(:hover, :focus-visible, [aria-current="page"]) {
    color: var(--secondary-50, #2b64c4);
}

.feedback-board-tab[aria-current="page"] {
    border-bottom-color: var(--secondary-50, #2b64c4);
}

.feedback-board-tab:focus-visible {
    outline: 3px solid var(--primary-60, #155eef);
    outline-offset: 2px;
}

@media (forced-colors: active) {
    .feedback-board-tab[aria-current="page"] {
        border-bottom-color: LinkText;
        text-decoration: underline;
    }
}
