/* =======================================================
   RA0 인터랙티브 부품 (js/ra0-interactive.js 짝)
   - 색은 --ri-* 변수만 읽는다. --ri-*는 아래에서 사이트 디자인 변수에 연결된다.
   - 움직임은 default.css.php의 --motion-* 변수를 쓰고, 없으면(관리자) 아래 기본값.
   - 적용은 data-ra0-* 표시가 붙은 요소에만 (JS가 ra0-* 클래스를 붙임)
   ======================================================= */
/* 색: 사이트에서는 default.css.php의 디자인 변수를 그대로 읽고, 없으면(관리자 화면) 괄호 안 기본값.
   :where()라 우선순위가 0이어서 admin.css 등이 :root에 같은 이름을 넣으면 그 값이 이긴다 */
:where(:root) {
    --ri-on: var(--btn-primary-bg, #64748b);
    --ri-on-text: var(--btn-primary-text, #ffffff);
    --ri-surface: var(--card-bg-color, #ffffff);
    --ri-line: var(--card-border-color, #e2e8f0);
    --ri-text: var(--content-font-color, #475569);
    --ri-muted: var(--text-muted, #767676);
    --ri-danger: var(--error-color, #ff6b6b);
    --ri-success: var(--success-color, #54cd9a);
    --ri-focus: var(--accent-color, #137bea);
    --ri-field-bg: var(--form-bg-color, #ffffff);
    --ri-field-line: var(--form-border-color, #e2e8f0);
    --ri-field-text: var(--form-text-color, #374151);
    --ri-radius: var(--form-border-radius, 8px);

    --ri-t-fast: var(--motion-duration-fast, 160ms);
    --ri-t-base: var(--motion-duration-base, 280ms);
    --ri-t-slow: var(--motion-duration-slow, 420ms);
    --ri-ease: var(--motion-ease, cubic-bezier(.16, 1, .3, 1));
    --ri-ease-pop: var(--motion-ease-pop, cubic-bezier(.2, .9, .22, 1.18));
    --ri-press: var(--motion-press, translateY(1px) scale(.985));
}

/* ── 페이지 이동: 새 페이지가 준비될 때까지 이전 화면을 유지하고 짧게 겹쳐 바꿈 (하얗게 비는 순간 없앰) ── */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 180ms; }
/* 바깥 틀의 iframe 안에서는 새 화면을 기다리는 동안 이전 화면이 유지되지 않고 비었다가, 전환이 시작될 때 이전 화면이
   다시 확 나타난 뒤 바뀐다(튀듯 번쩍임). 이전 화면 그림은 쓰지 않고 새 화면만 떠오르게 한다. */
:root.ra0-framed::view-transition-old(root) { display: none; }
:root.ra0-framed::view-transition-new(root) { mix-blend-mode: normal; }
@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
}

/* ── 물방울 스위치: input[type=checkbox][data-ra0-switch] ── */
/* JS가 감싸기 전에도 같은 모양 (첫 화면 깜빡임 방지) */
input[type="checkbox"][data-ra0-switch] {
    -webkit-appearance: none; appearance: none;
    position: relative; display: inline-block; flex-shrink: 0; vertical-align: middle;
    width: 44px; height: 24px; margin: 0; border: 0; border-radius: 99px; cursor: pointer;
    background: rgb(from var(--ri-text) r g b / 18%);
    opacity: 1; z-index: auto; overflow: visible; clip: auto; /* 그누보드 .selec_chk 숨김 해제 */
}
input[type="checkbox"][data-ra0-switch]::before {
    content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
    border-radius: 99px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
input[type="checkbox"][data-ra0-switch]:checked { background: var(--ri-on); }
input[type="checkbox"][data-ra0-switch]:checked::before { transform: translateX(20px); }
input[type="checkbox"][data-ra0-switch="big"] { width: 54px; height: 30px; }
input[type="checkbox"][data-ra0-switch="big"]::before { width: 24px; height: 24px; }
input[type="checkbox"][data-ra0-switch="big"]:checked::before { transform: translateX(24px); }
.ra0-switch {
    --w: 44px; --h: 24px; --pad: 3px;
    position: relative; display: inline-block; flex-shrink: 0; vertical-align: middle;
    width: var(--w); height: var(--h);
}
.ra0-switch.is-big { --w: 54px; --h: 30px; }
.ra0-switch > input[data-ra0-switch] {
    position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
    opacity: 0; cursor: pointer; z-index: 2; background: none;
}
.ra0-switch > input[data-ra0-switch]::before { display: none; }
.ra0-switch > input[data-ra0-switch]:disabled { cursor: not-allowed; }

/* 그누보드 기본 체크 모양(.chk_box의 label span)과 함께 쓸 때: 스위치가 대신 그림 */
.chk_box input[data-ra0-switch] + label span,
.chk_box .ra0-switch + label span { display: none; }
.chk_box input[data-ra0-switch] + label,
.chk_box .ra0-switch + label { padding-left: 0; }
.chk_box:has([data-ra0-switch]) { display: inline-flex; align-items: center; gap: 6px; }
.ra0-switch-track {
    position: absolute; inset: 0; border-radius: 99px;
    background: rgb(from var(--ri-text) r g b / 18%);
    transition: background var(--ri-t-base);
}
.ra0-switch > input:checked ~ .ra0-switch-track { background: var(--ri-on); }
.ra0-switch > input:checked ~ .ra0-switch-knob { transform: translateX(calc(var(--w) - var(--h))); }
.ra0-switch > input:disabled { cursor: not-allowed; }
.ra0-switch > input:disabled ~ .ra0-switch-track { opacity: .5; }
.ra0-switch > input:focus-visible ~ .ra0-switch-track { outline: 2px solid var(--ri-focus); outline-offset: 2px; }
.ra0-switch-knob {
    position: absolute; top: var(--pad); left: var(--pad); z-index: 1;
    width: calc(var(--h) - var(--pad) * 2); height: calc(var(--h) - var(--pad) * 2);
    border-radius: 99px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    pointer-events: none; will-change: transform;
}

/* ── 그 자리에서 확인: [data-ra0-confirm] ── */
.ra0-ic {
    position: relative; display: inline-flex; height: 32px; flex-shrink: 0; vertical-align: middle;
    border-radius: 16px; overflow: hidden; box-sizing: border-box;
    border: 1px solid var(--ri-line); background: var(--ri-surface); color: var(--ri-text);
    font-size: 13px; line-height: 1; font-weight: 400; letter-spacing: 0; text-transform: none;
    transition: width var(--ri-t-base) var(--ri-ease), background var(--ri-t-base), border-color var(--ri-t-base);
}
.ra0-ic[data-state="confirm"] { border-color: rgb(from var(--ri-danger) r g b / 45%); background: rgb(from var(--ri-danger) r g b / 8%); }
.ra0-ic-face {
    position: absolute; top: 0; bottom: 0; left: 0; display: inline-flex; align-items: center; gap: 6px;
    padding: 0 11px; white-space: nowrap;
    opacity: 0; transform: translateY(8px); pointer-events: none;
    transition: opacity var(--ri-t-fast), transform var(--ri-t-base) var(--ri-ease);
}
.ra0-ic-face.is-on { opacity: 1; transform: none; pointer-events: auto; }
.ra0-ic-face.is-leaving { transform: translateY(-8px); }
.ra0-ic button {
    font: inherit; font-size: 13px; line-height: 1; border: 0; background: none; color: inherit; cursor: pointer;
    padding: 0; margin: 0; display: inline-flex; align-items: center; gap: 4px; box-shadow: none; min-height: 0; width: auto; height: auto;
}
.ra0-ic button:focus-visible { outline: 2px solid var(--ri-focus); outline-offset: 2px; border-radius: 6px; }
.ra0-ic .ra0-ic-q { color: var(--ri-danger); font-weight: 600; }
.ra0-ic .ra0-ic-confirm { padding-right: 3px; }
.ra0-ic .ra0-ic-pill { height: 24px; padding: 0 10px; border-radius: 12px; font-weight: 600; font-size: 12px; }
.ra0-ic .ra0-ic-pill:active { transform: var(--ri-press); }
.ra0-ic .ra0-ic-yes { background: var(--ri-danger); color: #fff; }
.ra0-ic .ra0-ic-no { color: var(--ri-muted); }
.ra0-ic .ra0-ic-no:hover { color: var(--ri-text); }
.ra0-ic .ra0-ic-done { color: var(--ri-muted); }
.ra0-ic .ra0-ic-ok { color: var(--ri-success); display: inline-flex; }
.ra0-ic .ra0-ic-undo { color: var(--ri-focus); font-weight: 600; margin-left: 4px; }
.ra0-ic .ra0-ic-bar {
    position: absolute; left: 11px; right: 11px; bottom: 3px; height: 2px; border-radius: 2px;
    background: var(--ri-focus); opacity: .7; transform-origin: left; transform: scaleX(0);
}
.ra0-ic svg { width: 14px; height: 14px; flex-shrink: 0; }
.ra0-ic-hidden { display: none !important; }
.ra0-ic-pending { opacity: .4; filter: grayscale(1); transition: opacity var(--ri-t-base), filter var(--ri-t-base); }

/* ── 따라오는 강조 막대: [data-ra0-tabs] ── */
.ra0-tabs { position: relative; }
.ra0-tabs-ind {
    position: absolute; left: 0; width: 0; border-radius: 99px; pointer-events: none; z-index: 0;
    background: var(--ri-on); box-shadow: 0 4px 6px -1px rgba(100, 116, 139, .12);
}
.ra0-tabs-ind.is-hover { background: rgb(from var(--ri-text) r g b / 10%); box-shadow: none; transition: opacity var(--ri-t-fast); }
.ra0-tabs .ra0-tabs-item { position: relative; z-index: 1; }
.ra0-tabs .ra0-tabs-item:active { transform: var(--ri-press); }

/* ── 펼쳐지는 검색: form[data-ra0-seek] ──
   값 없음: 항상 돋보기로 접힘 / 값 "768": 화면 폭 768px 이하에서만. 검색어가 있으면 펼친 채로 둠 */
/* JS가 돌기 전에도 처음부터 돋보기 모양 (첫 화면 깜빡임 방지) */
.ra0-js form[data-ra0-seek=""]:not(.ra0-seek):not(:has(input:is([type="text"], [type="search"], :not([type]))[value]:not([value=""]))) {
    position: relative; width: var(--ri-seek-size) !important; min-width: 0 !important; height: var(--ri-seek-size); flex: 0 0 var(--ri-seek-size) !important; overflow: hidden; flex-wrap: nowrap !important;
}
.ra0-js form[data-ra0-seek=""]:not(.ra0-seek):not(:has(input:is([type="text"], [type="search"], :not([type]))[value]:not([value=""]))) > * { visibility: hidden; }
.ra0-js form[data-ra0-seek=""]:not(.ra0-seek):not(:has(input:is([type="text"], [type="search"], :not([type]))[value]:not([value=""])))::before,
.ra0-js form[data-ra0-seek=""]:not(.ra0-seek):not(:has(input:is([type="text"], [type="search"], :not([type]))[value]:not([value=""])))::after {
    content: ""; position: absolute; left: 0; top: 0; width: var(--ri-seek-size); height: var(--ri-seek-size); box-sizing: border-box; border-radius: var(--ri-seek-radius);
}
.ra0-js form[data-ra0-seek=""]:not(.ra0-seek):not(:has(input:is([type="text"], [type="search"], :not([type]))[value]:not([value=""])))::before {
    border: 1px solid var(--ri-seek-line); background: var(--ri-seek-bg);
}
.ra0-js form[data-ra0-seek=""]:not(.ra0-seek):not(:has(input:is([type="text"], [type="search"], :not([type]))[value]:not([value=""])))::after {
    background: var(--ri-seek-fg);
    -webkit-mask: var(--ri-seek-icon) center / 16px no-repeat; mask: var(--ri-seek-icon) center / 16px no-repeat;
}
@media (max-width: 768px) {
    .ra0-js form[data-ra0-seek="768"]:not(.ra0-seek):not(:has(input:is([type="text"], [type="search"], :not([type]))[value]:not([value=""]))) {
        width: var(--ri-seek-size) !important; min-width: 0 !important; flex: 0 0 var(--ri-seek-size) !important; overflow: hidden; opacity: 0;
    }
}
:where(:root) {
    /* 돋보기 모양: 스킨에서 form에 지정해 툴바 버튼 등과 맞출 수 있음 */
    --ri-seek-size: 36px;
    --ri-seek-radius: 18px;
    --ri-seek-bg: var(--ri-field-bg);
    --ri-seek-fg: var(--ri-field-text);
    --ri-seek-line: var(--ri-field-line);
    --ri-seek-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
}
.ra0-seek-btn { display: none; }
.ra0-seek.is-collapsible { position: relative; transition: width var(--ri-t-slow) var(--ri-ease-pop); }
.ra0-seek.is-collapsible.is-collapsed {
    width: var(--ri-seek-size) !important; min-width: 0 !important; flex: 0 0 var(--ri-seek-size) !important; overflow: hidden;
    min-height: var(--ri-seek-size); height: var(--ri-seek-size); flex-wrap: nowrap !important; border-radius: var(--ri-seek-radius);
}
.ra0-seek.is-collapsible .ra0-seek-btn {
    display: inline-flex; align-items: center; justify-content: center;
    position: absolute; left: 0; top: 0; width: var(--ri-seek-size); height: 100%; min-height: var(--ri-seek-size); z-index: 2; box-sizing: border-box;
    border: 1px solid var(--ri-seek-line); border-radius: var(--ri-seek-radius); background: var(--ri-seek-bg); color: var(--ri-seek-fg);
    cursor: pointer; padding: 0; transition: opacity var(--ri-t-fast);
}
.ra0-seek.is-collapsible .ra0-seek-btn svg { width: 16px; height: 16px; }
.ra0-seek.is-collapsible:not(.is-collapsed) .ra0-seek-btn { opacity: 0; pointer-events: none; }
.ra0-seek.is-collapsible > :not(.ra0-seek-btn) { transition: opacity var(--ri-t-fast); }
.ra0-seek.is-collapsible.is-collapsed > :not(.ra0-seek-btn) { opacity: 0; pointer-events: none; }
.ra0-seek.is-collapsible.is-opening > :not(.ra0-seek-btn) { transition-delay: calc(var(--ri-t-fast) * .6); }

/* ── 출렁이는 슬라이더: input[type=range][data-ra0-slosh] ── */
.ra0-slosh { position: relative; height: 28px; cursor: pointer; touch-action: none; border-radius: var(--ri-radius); outline: none; }
.ra0-slosh svg { display: block; width: 100%; height: 100%; overflow: visible; }
.ra0-slosh .ra0-slosh-bg { fill: rgb(from var(--ri-text) r g b / 10%); }
.ra0-slosh .ra0-slosh-fill { fill: var(--ri-on); }
.ra0-slosh .ra0-slosh-handle { stroke: var(--ri-on-text); stroke-width: 2.5; stroke-linecap: round; opacity: .9; }
.ra0-slosh:focus-visible { outline: 2px solid var(--ri-focus); outline-offset: 3px; }
input[type="range"].ra0-slosh-input { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; }

@media (prefers-reduced-motion: reduce) {
    :root { --ri-t-fast: 1ms; --ri-t-base: 1ms; --ri-t-slow: 1ms; }
}
