/**
 * SPC managed pages — 본문 레이아웃 보강 (wrapper-agnostic 버전).
 *
 * wp_kses의 safecss_filter_attr이 inline style의 display·flex·grid 등을
 * 무음으로 stripping해서, PHP에서 inline으로 작성된 카드/네비게이션 레이아웃이
 * 브라우저에서 인라인 컨텍스트로 깨지는 문제(카드 겹침)가 발생한다.
 *
 * 본 사이트 테마는 본문 wrapper로 `.entry-content`가 아닌 `.page__body`를 쓰는 경우가 있어,
 * wrapper class에 의존하지 않고 inline style의 marker 속성으로 셀렉터를 잡는다.
 * (specificity는 attribute selector 2개 이상으로 확보됨)
 *
 * 이 파일은 _spc_managed 메타가 있는 page/magazine_article에만 로드된다.
 */

/* ========================================================
 *  /law/parking-lot-act/* — 사례 카드, 조문 카드
 * ======================================================== */

/* 사례 카드 (배경 #fefce8 + border-left #ca8a04, 노란색) — 모든 페이지 통용 */
a[href^="/law/parking-lot-act/cases/"][style*="background:#fefce8"],
a[href^="/law/parking-lot-act/cases/"][style*="border-left:3px solid #ca8a04"] {
    display: block;
    margin: 8px 0;
}

/* 조문 섹션 카드 (배경 #eff6ff + border-left #2563eb, 파란색) — 사례 페이지 내 "관련 조문" */
a[href^="/law/parking-lot-act/"][style*="background:#eff6ff"][style*="border-left:3px solid #2563eb"] {
    display: block;
    margin: 8px 0;
}

/* 카드 내부 자식 요소들은 anchor가 inline-context로 떨어져도 줄바꿈 보장 */
a[href^="/law/parking-lot-act/"] > strong,
a[href^="/law/parking-lot-act/"] > p,
a[href^="/law/parking-lot-act/"] > span {
    display: block;
}

/* ========================================================
 *  prev/next 네비게이션 행 — 본문에 inline style로 justify-content + border-top만 남고
 *  display가 stripping된 div를 attribute selector로 매칭하여 flex 강제
 * ======================================================== */

div[style*="justify-content:space-between"][style*="border-top:1px solid #e2e8f0"],
div[style*="justify-content:space-between"][style*="border-top:1px solid#e2e8f0"],
div[style*="justify-content: space-between"][style*="border-top: 1px solid #e2e8f0"] {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* nav 자식 anchor — flex:1 inline이 stripping된 경우 보강 */
div[style*="justify-content:space-between"][style*="border-top:1px solid #e2e8f0"] > a,
div[style*="justify-content:space-between"][style*="border-top:1px solid#e2e8f0"] > a,
div[style*="justify-content: space-between"][style*="border-top: 1px solid #e2e8f0"] > a {
    flex: 1 1 200px;
    min-width: 0;
}

/* 빈 placeholder span (이전 또는 다음이 없는 경계 페이지) */
div[style*="justify-content:space-between"][style*="border-top:1px solid #e2e8f0"] > span,
div[style*="justify-content:space-between"][style*="border-top:1px solid#e2e8f0"] > span,
div[style*="justify-content: space-between"][style*="border-top: 1px solid #e2e8f0"] > span {
    flex: 1 1 200px;
}

/* ========================================================
 *  양식 다운로드 버튼 행 (/templates/*/) — 클래스 기반이라 wrapper 무관
 * ======================================================== */

.template-downloads {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* ========================================================
 *  안전망 — aside 블록은 기본 block이지만 일부 테마에서 inline으로 떨어질 가능성 대비
 * ======================================================== */

aside.summary60,
aside.callout,
aside.legal-disclaimer,
aside.tldr {
    display: block;
}

/* ========================================================
 *  모바일 (≤640px) — prev/next nav 세로 스택
 * ======================================================== */

@media (max-width: 640px) {
    div[style*="justify-content:space-between"][style*="border-top:1px solid #e2e8f0"],
    div[style*="justify-content:space-between"][style*="border-top:1px solid#e2e8f0"],
    div[style*="justify-content: space-between"][style*="border-top: 1px solid #e2e8f0"] {
        flex-direction: column;
    }
    div[style*="justify-content:space-between"][style*="border-top:1px solid #e2e8f0"] > a,
    div[style*="justify-content:space-between"][style*="border-top:1px solid #e2e8f0"] > span {
        flex: 1 1 auto;
        text-align: left !important;
    }
}
