/* ================================================================
   plugin/editor/editor.css
   간단 에디터 — 입력폼(.ed-wrap) + 본문 출력 공용 스타일(.ed-content)
   색상은 layout/(kr|en)/css/global.css 변수 사용
   ※ 주석 안에 "*" 바로 뒤에 "/" 가 오면 주석이 거기서 끝나버리므로 경로에 별표를 쓰지 말 것
   ================================================================ */

/* ── 입력폼 ───────────────────────────────────────────────────── */
.ed-wrap {
    position: relative;
    border: 1px solid var(--border-color-1, #ccc);
    border-radius: 6px;
    background: var(--white-color-1, #fff);
    overflow: hidden;
}
.ed-wrap:focus-within {border-color: var(--point-color-1, #333);}

.ed-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-color-1, #e5e5e5);
    background: #f8f9fb;
}
.ed-sep {width: 1px; height: 20px; margin: 0 6px; background: var(--border-color-1, #ddd);}

.ed-size {
    height: 32px; padding: 0 26px 0 10px;
    border: 1px solid var(--border-color-1, #ddd); border-radius: 4px;
    background: var(--white-color-1, #fff) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E") no-repeat right 9px center;
    font-size: 13px; font-family: inherit; color: var(--black-color-1, #222);
    cursor: pointer;
}

.ed-btn {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; flex-direction: column;
    width: 32px; height: 32px; padding: 0;
    border: 0; border-radius: 4px; background: transparent;
    color: var(--black-color-1, #222); cursor: pointer;
    transition: background .15s, color .15s;
}
.ed-btn svg {width: 18px; height: 18px; fill: currentColor;}
.ed-btn:hover {background: #e9edf3;}
.ed-btn.is-on {background: var(--point-color-1, #333); color: var(--white-color-1, #fff);}

/* 글자 색: "A" + 아래 색 막대, 실제 color input 은 투명하게 덮어둠 */
.ed-color .ed-color-a {font-size: 15px; font-weight: 700; line-height: 1; margin-top: 2px;}
.ed-color .ed-color-bar {width: 16px; height: 4px; margin-top: 2px; border-radius: 1px; background: #222;}
.ed-color input[type="color"] {position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0;}

.ed-area {
    min-height: 300px; max-height: 70vh; overflow-y: auto;
    padding: 14px 16px;
    outline: none;
    font-size: 16px; color: var(--black-color-1, #222);
}
.ed-area:empty::before {content: '내용을 입력해주세요.'; color: #aaa; pointer-events: none;}

/* JS 가 동작하지 않을 때는 원래 textarea 로 입력 */
.ed-source {display: block; width: 100%; min-height: 300px; padding: 12px; border: 0; font: inherit; resize: vertical;}
.ed-source[hidden] {display: none;}

/* 유튜브 주소 입력창 (툴바 아래) */
.ed-panel {
    display: flex; gap: 6px; align-items: center;
    padding: 8px; border-bottom: 1px solid var(--border-color-1, #e5e5e5); background: #f8f9fb;
}
.ed-panel[hidden] {display: none;}
.ed-panel input {
    flex: 1; min-width: 0; height: 34px; padding: 0 10px;
    border: 1px solid var(--border-color-1, #ddd); border-radius: 4px;
    background: var(--white-color-1, #fff); font: inherit; font-size: 14px; color: var(--black-color-1, #222);
}
.ed-panel input:focus {outline: none; border-color: var(--point-color-1, #333);}
.ed-panel button {
    flex-shrink: 0; height: 34px; padding: 0 14px; border-radius: 4px; cursor: pointer;
    font: inherit; font-size: 13px;
}
.ed-panel .ed-panel-ok {border: 0; background: var(--point-color-1, #333); color: var(--white-color-1, #fff);}
.ed-panel .ed-panel-cancel {border: 1px solid var(--border-color-1, #ddd); background: var(--white-color-1, #fff); color: var(--black-color-1, #222);}

/* 링크 버튼 입력창: 버튼명 + 주소 (좁은 화면에서는 줄바꿈) */
.ed-link-panel {flex-wrap: wrap;}
.ed-link-panel .ed-link-text {flex: 1 1 160px;}
.ed-link-panel .ed-link-url {flex: 2 1 240px;}
.ed-panel button[hidden] {display: none;}
/* 편집영역 안 링크 버튼: 누르면 수정 입력창 */
.ed-area a.ed-link {cursor: pointer;}
.ed-area a.ed-link:hover {outline: 2px dashed #b9c2cf; outline-offset: 2px;}

/* 편집영역 안 영상: 재생 대신 위치 확인용 (클릭이 iframe 으로 빠지지 않게) + 삭제 버튼 */
.ed-area .ed-video {position: relative; outline: 2px dashed transparent; outline-offset: 2px;}
.ed-area .ed-video {cursor: pointer;}
.ed-area .ed-video:hover {outline-color: #b9c2cf;}
/* 클릭해서 선택한 영상 — 이 상태에서 정렬 버튼을 누르면 영상이 정렬됨 */
.ed-area .ed-video.is-selected {outline: 3px solid var(--point-color-1, #333);}
.ed-area .ed-video iframe {pointer-events: none;}
.ed-video-del {
    position: absolute; top: 8px; right: 8px; z-index: 1;
    width: 30px; height: 30px; border: 0; border-radius: 50%;
    background: rgba(0, 0, 0, .7); color: #fff; font-size: 20px; line-height: 30px; cursor: pointer;
}
.ed-video-del:hover {background: #e04545;}

/* 이미지 크기 조절: 클릭한 이미지 위에 테두리 + 손잡이(모서리 4개, 좌우 2개) */
.ed-area img {cursor: pointer;}
.ed-img-box {
    position: absolute; z-index: 2; pointer-events: none;
    box-sizing: border-box; border: 2px solid var(--point-color-1, #333);
}
.ed-img-box[hidden] {display: none;}
.ed-img-box .ed-h {
    position: absolute; width: 12px; height: 12px; margin: -7px 0 0 -7px;
    border: 2px solid var(--point-color-1, #333); border-radius: 2px; background: #fff;
    pointer-events: auto; touch-action: none;
}
.ed-img-box .ed-h[data-h="nw"] {left: 0;    top: 0;    cursor: nwse-resize;}
.ed-img-box .ed-h[data-h="ne"] {left: 100%; top: 0;    cursor: nesw-resize;}
.ed-img-box .ed-h[data-h="sw"] {left: 0;    top: 100%; cursor: nesw-resize;}
.ed-img-box .ed-h[data-h="se"] {left: 100%; top: 100%; cursor: nwse-resize;}
.ed-img-box .ed-h[data-h="w"]  {left: 0;    top: 50%;  cursor: ew-resize;}
.ed-img-box .ed-h[data-h="e"]  {left: 100%; top: 50%;  cursor: ew-resize;}
.ed-img-size {
    position: absolute; right: 4px; bottom: 4px;
    padding: 2px 6px; border-radius: 3px; background: rgba(0, 0, 0, .7);
    color: #fff; font-size: 11px; line-height: 1.4; white-space: nowrap;
}
.ed-wrap.is-resizing, .ed-wrap.is-resizing * {user-select: none; cursor: inherit;}

.ed-msg {margin: 0; padding: 8px 14px; border-top: 1px solid var(--border-color-1, #eee); color: #e04545; font-size: 13px; line-height: 1.5;}
.ed-msg[hidden] {display: none;}

/* 업로드 중 표시 */
.ed-wrap.is-uploading .ed-img-btn {pointer-events: none; opacity: .4;}
.ed-wrap.is-uploading::after {
    content: '이미지 업로드 중…';
    position: absolute; right: 10px; top: 12px;
    font-size: 12px; color: var(--point-color-1, #333);
}

/* ── 본문 출력 (편집영역 + 글보기 공용) ──────────────────────────── */
.ed-content {line-height: 1.8; word-break: break-word; overflow-wrap: break-word;}
.ed-content p, .ed-content div {margin: 0; min-height: 1em;}
.ed-content img {max-width: 100%; height: auto; vertical-align: top;}
.ed-content b, .ed-content strong {font-weight: 700;}
.ed-content u {text-decoration: underline;}
/* 유튜브 영상: 폭에 맞춰 16:9 */
.ed-content .ed-video {width: 100%; max-width: 860px; aspect-ratio: 16 / 9; margin: 10px 0; background: #000;}
.ed-content .ed-video iframe {display: block; width: 100%; height: 100%; border: 0;}
/* 영상 정렬 (툴바 정렬 버튼 → data-align) */
.ed-content .ed-video[data-align="center"] {margin-left: auto; margin-right: auto;}
.ed-content .ed-video[data-align="right"] {margin-left: auto; margin-right: 0;}

/* 링크 버튼 (에디터 링크 버튼으로 넣은 것 — 누르면 새 창) */
.ed-content a.ed-link {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 42px; padding: 8px 20px; margin: 4px 2px;
    border-radius: 6px; background: var(--point-color-1, #333);
    color: var(--white-color-1, #fff); font-size: 15px; font-weight: 600; line-height: 1.3;
    text-decoration: none; vertical-align: middle; transition: opacity .15s;
}
.ed-content a.ed-link::after {content: '\2197'; font-size: .9em; line-height: 1;}
.ed-content a.ed-link:hover {opacity: .85; color: var(--white-color-1, #fff);}

@media (max-width: 720px) {
    .ed-area {min-height: 220px; padding: 12px;}
    .ed-sep {margin: 0 3px;}
}
