/* ============================================================
   v6-ops.css — 실시간 운행정보
   ------------------------------------------------------------
   원본 : 영상 한가운데를 가리는 큰 표(table) 팝업. 5초 뒤 예고 없이 사라진다.
   v6   : 히어로 하단에 가로 "상태 레일"로 도킹.
          · 접힌 상태에서도 상태 · 스카이워크 · 매표/상하행 마감 · 휴장일이 보인다
          · 클릭하면 위로 펼쳐져 안내사항까지 나온다
          · 자동 접힘은 헤어라인 카운트다운으로 예고하고, 손이 닿으면 취소
          · 히어로를 벗어나면 작은 pill 로 축소되어 계속 따라다닌다
                          (모바일은 하단 탭바의 상태 점이 그 역할을 한다)

   ⚠ 데이터 계약은 원본 realtime.js 와 100% 동일하다.
     관리자에서 입력하는 값(자동화/상태/스카이워크/기타1~3/마감시각/휴장일)은
     하나도 버려지지 않는다.
============================================================ */

#realtime-info {
    position: fixed;
    z-index: 110;
    left: 50%;
    bottom: clamp(22px, 4vh, 40px);
    /* 접혔을 때 : 내용 폭 그대로. 고정폭으로 잡으면 가운데가 비어 보인다.
       펼쳤을 때 : 4칸 표 + 안내사항을 한 줄로 눕혀야 하므로 넓어진다. */
    width: fit-content;
    max-width: 92vw;
    transform: translateX(-50%);
    transition: width .55s var(--ease), bottom .55s var(--ease),
        transform .55s var(--ease), left .55s var(--ease);
}

#realtime-info.is-open {
    width: min(1120px, 92vw);
}

/* 히어로를 벗어나면 미니 pill 로.
   우하단은 Top 버튼·고도 레일과 겹치고 본문 위에 계속 떠 있어 거슬린다.
   → 좌하단 구석으로 옮기고 크기를 절반 이하로 줄인다. */
#realtime-info.is-mini {
    left: 20px;
    right: auto;
    bottom: 20px;
    width: auto;
    transform: none;
}

.ops {
    display: flex;
    flex-direction: column-reverse;
    /* 패널이 위로 펼쳐진다 */
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: rgba(6, 10, 18, .62);
    backdrop-filter: blur(22px) saturate(150%);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    box-shadow: 0 26px 70px rgba(0, 0, 0, .55);
}

/* ---------- 접힌 바 ---------- */
.ops-bar {
    display: grid;
    /* 가운데 칸(매표·마감)이 바의 정중앙에 오도록 양옆을 같은 비율로 둔다.
       예전에는 왼쪽이 auto 라 상태 문구 길이에 따라 칩 묶음이 좌우로 밀렸다. */
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 18px;
    width: 100%;
    padding: 11px 18px;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    position: relative;
}

.ops-head {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}

.ops-dot {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--soon);
    position: relative;
}

.ops-dot::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 1px solid currentColor;
    color: inherit;
    opacity: .5;
    animation: opsPing 2.4s ease-out infinite;
}

[data-state="live"] .ops-dot {
    background: var(--live);
    color: var(--live);
    box-shadow: 0 0 14px rgba(55, 211, 153, .7);
}

[data-state="soon"] .ops-dot {
    background: var(--soon);
    color: var(--soon);
    box-shadow: 0 0 14px rgba(251, 191, 36, .6);
}

[data-state="stop"] .ops-dot {
    background: var(--stop);
    color: var(--stop);
    box-shadow: 0 0 14px rgba(248, 113, 113, .6);
}

@keyframes opsPing {
    0% {
        transform: scale(.7);
        opacity: .7;
    }

    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.ops-now {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.ops-now b {
    font-size: .98rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-state="live"] .ops-now b {
    color: var(--live);
}

[data-state="stop"] .ops-now b {
    color: var(--stop);
}

.ops-now i {
    font-style: normal;
    font-size: .74rem;
    color: var(--tx-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 접힌 상태에서만 보이는 핵심 수치 칩.
   펼치면 아래 표(운영·마감 / 이달의 휴장일)에 같은 값이 그대로 있어 중복이다. */
[data-open="true"] .ops-chips {
    display: none;
}

/* 펼치면 아래 표가 같은 값을 모두 보여준다 — 바는 2칸으로 줄인다 */
[data-open="true"] .ops-bar {
    grid-template-columns: minmax(0, 1fr) auto;
}

.ops-chips {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: 1px solid var(--line-soft);
}

/* 오른쪽 "자세히" 는 끝에 붙인다 — 가운데 칸이 중앙을 지키게 */
.ops-bar > .ops-chev {
    justify-self: end;
}

.ops-chips .chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 3px 16px;
    border-left: 1px solid var(--line-soft);
    white-space: nowrap;
    min-width: 0;
}

.ops-chips .chip:first-child {
    border-left: 0;
}

.ops-chips em {
    font-style: normal;
    font-size: .58rem;
    line-height: 1.1;
    letter-spacing: .08em;
    color: var(--tx-3);
}

.ops-chips b {
    font-family: 'Bebas Neue', sans-serif;
    font-size: .9rem;
    line-height: 1.15;
    letter-spacing: .04em;
    color: var(--tx-1);
}

/* 토글 — 아이콘만으로는 무슨 버튼인지 읽히지 않아 상태를 글자로 말한다.
   칩이 사라진 자리를 이 버튼이 받아 오른쪽 끝을 잡는다. */
.ops-chev {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 9px 0 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .05);
    color: var(--tx-2);
    transition: background .22s, border-color .22s, color .22s;
}

.ops-chev b {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: -.01em;
    white-space: nowrap;
}

.ops-chev svg {
    width: 14px;
    height: 14px;
    /* 접힘 = 위로 펼침 예고, 펼침 = 아래로 접힘 예고 */
    transform: rotate(180deg);
    transition: transform .4s var(--ease);
}

[data-open="true"] .ops-chev svg {
    transform: rotate(0deg);
}

/* 상태에 맞는 라벨만 남긴다 */
[data-open="true"] .ops-chev-more,
.ops:not([data-open="true"]) .ops-chev-less {
    display: none;
}

.ops-bar:hover .ops-chev,
.ops-bar:focus-visible .ops-chev {
    background: rgba(245, 237, 0, .14);
    border-color: rgba(245, 237, 0, .45);
    color: var(--gold);
}

/* 자동 접힘 카운트다운 헤어라인 */
.ops-timer {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 0;
    background: linear-gradient(90deg, var(--gold), transparent);
    opacity: 0;
}

.ops.is-counting .ops-timer {
    opacity: 1;
    animation: opsCount var(--ops-delay, 6000ms) linear forwards;
}

@keyframes opsCount {
    from {
        width: 100%;
    }

    to {
        width: 0;
    }
}

/* ---------- 펼침 패널 ---------- */
.ops-panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .5s var(--ease);
}

[data-open="true"] .ops-panel {
    grid-template-rows: 1fr;
}

.ops-panel-in {
    overflow: hidden;
    min-height: 0;
}

.ops-body {
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding: 12px 18px 12px;
    border-bottom: 1px solid var(--line-soft);
}

.ops-grid {
    flex: 1 1 auto;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.ops-cell {
    min-width: 0;
    padding: 9px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--line-soft);
}

.ops-cell .k {
    display: block;
    font-size: .6rem;
    letter-spacing: .1em;
    color: var(--gold);
    margin-bottom: 4px;
}

.ops-cell .v {
    font-size: .9rem;
    font-weight: 700;
    color: #fff;
}

.ops-times {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ops-times div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: .7rem;
}

.ops-times span:first-child {
    color: var(--tx-3);
}

.ops-times span:last-child {
    font-family: 'Bebas Neue', sans-serif;
    line-height: 1.2;
    font-size: .88rem;
    letter-spacing: .04em;
    color: var(--tx-1);
}

.ops-notice {
    flex: 0 1 30%;
    min-width: 0;
    padding: 9px 13px;
    border-radius: 12px;
    background: rgba(245, 237, 0, .06);
    border: 1px solid rgba(245, 237, 0, .18);
}

.ops-notice .k {
    display: block;
    font-size: .6rem;
    letter-spacing: .1em;
    color: var(--gold);
    margin-bottom: 4px;
}

.ops-notice ul {
    margin: 0;
    padding-left: 14px;
}

.ops-notice li {
    font-size: .73rem;
    line-height: 1.5;
    color: var(--tx-2);
}

/* ---------- 미니 pill ---------- */
#realtime-info.is-mini .ops {
    flex-direction: column-reverse;
    border-radius: 999px;
}

#realtime-info.is-mini .ops {
    background: rgba(6, 10, 18, .78);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
}

#realtime-info.is-mini .ops-bar {
    grid-template-columns: auto auto;
    padding: 7px 11px 7px 12px;
    gap: 7px;
}

#realtime-info.is-mini .ops-head {
    gap: 7px;
}

#realtime-info.is-mini .ops-chips,
#realtime-info.is-mini .ops-now i {
    display: none;
}

#realtime-info.is-mini .ops-dot {
    width: 8px;
    height: 8px;
}

#realtime-info.is-mini .ops-now b {
    font-size: .72rem;
    font-weight: 600;
    max-width: 170px;
}

#realtime-info.is-mini .ops-chev {
    width: 22px;
    height: 22px;
    padding: 0;
    gap: 0;
    justify-content: center;
    border-radius: 50%;
}

#realtime-info.is-mini .ops-chev b {
    display: none;
}

#realtime-info.is-mini .ops-chev svg {
    width: 12px;
    height: 12px;
}

#realtime-info.is-mini .ops-grid {
    grid-template-columns: repeat(2, 1fr);
}

/* 미니 모드에서는 패널을 pill 밖으로 띄운다.
   패널이 flex 흐름 안에 있으면 접혀 있어도 그 폭이 pill 폭을 잡아당겨
   "작은 pill" 이 되지 않는다. */
#realtime-info.is-mini .ops {
    overflow: visible;
    position: relative;
}

#realtime-info.is-mini .ops-panel {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: min(420px, 90vw);
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: rgba(6, 10, 18, .92);
    backdrop-filter: blur(22px) saturate(150%);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    box-shadow: 0 22px 56px rgba(0, 0, 0, .55);
}

#realtime-info.is-mini .ops-body {
    flex-direction: column;
    gap: 8px;
    border-bottom: 0;
}

#realtime-info.is-mini .ops-notice {
    flex: none;
}

/* 접혀 있을 땐 패널의 테두리가 pill 위에 가는 선으로 남는다 — 지운다 */
#realtime-info.is-mini .ops:not([data-open="true"]) .ops-panel {
    border-color: transparent;
    box-shadow: none;
    background: transparent;
}

/* ============================================================
   미니 pill 위의 케이블 — 상태를 "움직임" 으로 보여준다
   ------------------------------------------------------------
   헤더 브랜드 마크와 같은 곤돌라가, 케이블의 처짐(catenary)을 따라
   좌 → 우로 천천히 이동한다. CSS motion path 를 쓴다.
   ⚠ offset-path 의 좌표는 ops6.js 의 CABLE_PATH 와 반드시 같아야 한다.

     정상 운행중 → 곤돌라가 케이블을 왕복하듯 흐른다
     준비 · 대기 → 왼쪽 승강장에 서서 천천히 흔들린다
     휴장 · 점검 → 케이블이 점선으로 끊기고 곤돌라는 멈춘다
============================================================ */
.ops-cable {
    display: none;
}

/* 위치·폭을 접힌 패널이 남기던 그 선(min(420px,90vw))에 정확히 맞춘다 —
   사용자가 "로프처럼 그어져 있는 선" 으로 본 바로 그 자리다. */
#realtime-info.is-mini .ops-cable {
    display: block;
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    width: min(420px, 90vw);
    pointer-events: none;
    z-index: 2;
}

/* 패널이 열리면 자리를 비켜준다 */
#realtime-info.is-mini .ops[data-open="true"] .ops-cable {
    display: none;
}

.ops-cable svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.oc-line {
    stroke: rgba(255, 255, 255, .34);
    stroke-width: 1.2;
    stroke-linecap: round;
}

.oc-arm {
    stroke: rgba(255, 255, 255, .8);
    stroke-width: 1.5;
    stroke-linecap: round;
}

.oc-cab {
    fill: rgba(26, 96, 201, .38);
    stroke: #fff;
    stroke-width: 1.6;
}

.oc-win {
    stroke: rgba(255, 255, 255, .7);
    stroke-width: 1.1;
    stroke-linecap: round;
}

/* 케이블을 따라 이동 */
.oc-car {
    offset-path: path('M4 11 Q210 23 416 11');
    offset-rotate: 0deg;
    offset-distance: 6%;
}

/* 매달린 채 흔들림(rotate) + 위아래 둥둥(translateY) — 주기를 달리해 자연스럽게 */
.oc-sway,
.oc-bob {
    transform-box: fill-box;
}

.oc-sway {
    transform-origin: 50% 0%;
}

.oc-bob {
    transform-origin: 50% 50%;
}

/* 왕복하지 않는다. 오른쪽 끝에서 사라지고 왼쪽에서 다시 나타난다. */
@keyframes ocRide {
    0% {
        offset-distance: 0%;
        opacity: 0;
    }

    7% {
        opacity: 1;
    }

    93% {
        opacity: 1;
    }

    100% {
        offset-distance: 100%;
        opacity: 0;
    }
}

@keyframes ocSway {

    0%,
    100% {
        transform: rotate(-3.4deg);
    }

    50% {
        transform: rotate(3.4deg);
    }
}

/* 둥둥 — 위아래 */
@keyframes ocBob {

    0%,
    100% {
        transform: translateY(-1.6px);
    }

    50% {
        transform: translateY(1.8px);
    }
}

@keyframes ocIdle {

    0%,
    100% {
        transform: rotate(-1.6deg);
    }

    50% {
        transform: rotate(1.6deg);
    }
}

/* ---- 정상 운행중 ---- */
[data-state="live"] .oc-car {
    animation: ocRide 34s linear infinite;
}

[data-state="live"] .oc-sway {
    animation: ocSway 4.6s ease-in-out infinite;
}

[data-state="live"] .oc-bob {
    animation: ocBob 2.9s ease-in-out infinite;
}

[data-state="live"] .oc-line {
    stroke: rgba(55, 211, 153, .42);
}

/* ---- 준비 · 대기 ---- */
[data-state="soon"] .oc-car {
    offset-distance: 5%;
}

[data-state="soon"] .oc-sway {
    animation: ocIdle 4.2s ease-in-out infinite;
}

[data-state="soon"] .oc-bob {
    animation: ocBob 3.6s ease-in-out infinite;
}

[data-state="soon"] .oc-line {
    stroke: rgba(251, 191, 36, .4);
}

/* ---- 휴장 · 점검 ---- */
[data-state="stop"] .oc-car {
    offset-distance: 5%;
}

[data-state="stop"] .oc-line {
    stroke: rgba(248, 113, 113, .42);
    stroke-dasharray: 5 6;
}

[data-state="stop"] .oc-cab {
    fill: rgba(120, 130, 150, .3);
    stroke: rgba(255, 255, 255, .55);
}

[data-state="stop"] .oc-arm,
[data-state="stop"] .oc-win {
    stroke: rgba(255, 255, 255, .45);
}

@media (prefers-reduced-motion: reduce) {

    .oc-car,
    .oc-sway,
    .oc-bob {
        animation: none !important;
    }
}

/* motion path 미지원 브라우저 폴백 — 케이블만 보이고 곤돌라는 숨긴다 */
@supports not (offset-path: path('M0 0 L1 1')) {
    .oc-car {
        display: none;
    }
}

/* ============================================================
   반응형 — 모바일은 하단 탭바 위에 얹히는 시트가 된다
============================================================ */
@media (max-width: 980px) {
    .ops-chips .chip {
        padding: 3px 12px;
    }
}

@media (max-width: 900px) {

    #realtime-info,
    #realtime-info.is-open {
        left: 0;
        right: 0;
        bottom: var(--tab-h);
        width: 100%;
        transform: none;
        border-radius: 0;
    }

    #realtime-info.is-mini {
        left: 0;
        right: 0;
        width: 100%;
        bottom: var(--tab-h);
    }

    /* 모바일에서 미니 모드는 탭바의 상태 점이 대신한다 → 숨긴다 */
    #realtime-info.is-mini:not(.is-forced) {
        transform: translateY(120%);
        pointer-events: none;
    }

    .ops {
        border-radius: 18px 18px 0 0;
        border-bottom: 0;
    }

    .ops-bar {
        padding: 13px 16px;
        gap: 12px;
    }

    .ops-chips {
        display: none;
    }

    /* 칩이 없으니 바는 2칸이면 된다 */
    .ops-bar {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 12px;
    }

    .ops-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .ops-body {
        flex-direction: column;
        gap: 8px;
        padding: 14px 14px 14px;
        max-height: 58vh;
        overflow-y: auto;
    }

    .ops-notice {
        flex: none;
    }

    .ops-cell {
        padding: 11px 13px;
    }
}
