/*
 * 참여(engagement) 모듈 겉모습 — 앱 `ka-app` engagement_theme.dart 에 해당한다.
 *
 * 값을 변수로 빼 두는 이유: 참여 UI 안쪽은 어디서든 같지만 그것이 놓이는 면은 기능이
 * 정하기 때문이다. 캘린더가 이 모듈을 쓰게 될 때 자기 색을 입히는 자리가 여기다 —
 * `.eng-root` 를 감싼 쪽에서 변수만 덮어쓰면 된다.
 */
.eng-root {
    --eng-accent:        #5E76E6;
    --eng-text:          #212529;
    --eng-text-muted:    #868e96;
    --eng-text-faint:    #999;
    --eng-border:        #ededed;
    --eng-border-strong: #a9a9a9;
    --eng-surface:       #fff;
    --eng-surface-sunk:  rgba(240, 240, 240, 0.3);
    /* 링크·영상 카드 면과 그 자리표시 — 서비스마다 다른 색을 쓸 수 있게 변수로 둔다. */
    --eng-surface-card:  #F0F0F5;
    --eng-surface-ph:    #E5E5EA;
    --eng-radius:        3px;

    /* 앱과 같은 크기 — 뿌리 34, 답글 28. 메달은 사진의 46%. */
    --eng-avatar:        34px;
    --eng-medal:         16px;
    --eng-indent:        39px;   /* 답글을 사진 너비만큼 들여쓴다 (34 + 5) */
}

/* ── 입력창 ─────────────────────────────────────────────── */
.eng-compose {
    border: solid 1px var(--eng-border-strong);
    border-radius: var(--eng-radius);
}

.eng-compose textarea,
.eng-modal textarea {
    width: 100%;
    min-height: 60px;
    border: none;
    background: none;
    resize: none;
    font-size: 15px;
    color: var(--eng-text);
}

.eng-compose textarea:focus,
.eng-modal textarea:focus {
    outline: none;
    box-shadow: none;
}

.eng-compose-foot {
    border-top: solid 1px var(--eng-border);
}

.eng-count {
    font-size: 13px;
    color: var(--eng-text-faint);
}

.eng-submit {
    background-color: var(--eng-accent);
    color: #fff;
    opacity: .7;
}

.eng-submit:not(:disabled):hover,
.eng-submit.is-active {
    opacity: 1;
    color: #fff;
}

.eng-submit:disabled {
    cursor: default;
}

/* 로그인 전 입력창 — 눌리는 자리로 보이되 글은 못 쓰게 한다. */
.eng-compose.is-locked {
    cursor: pointer;
}

.eng-compose.is-locked textarea {
    pointer-events: none;
    background: none;
}

/* ── 퀵 이모지 ──────────────────────────────────────────── */
/*
 * 좁은 화면에서는 이모지가 줄을 넘어 잘린다. 끝을 흐리게 해 더 있다는 것을 알린다 —
 * 잘린 자리가 딱 떨어져 보이면 그것이 전부인 줄 안다.
 *
 * 켜고 끄는 것은 engagement-comments.js 의 `v-eng-fade` 가 한다. 끝에 닿으면 그쪽을
 * 끄므로, 다 본 뒤에도 마지막 이모지가 흐린 채로 남지 않는다.
 */
.eng-emoji-wrap {
    position: relative;
}

.eng-emoji-wrap::before,
.eng-emoji-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 28px;
    pointer-events: none;   /* 흐림 위로도 이모지가 눌려야 한다 */
    opacity: 0;
    transition: opacity .15s ease;
}

.eng-emoji-wrap::before {
    left: 0;
    background: linear-gradient(to right, var(--eng-surface), transparent);
}

.eng-emoji-wrap::after {
    right: 0;
    background: linear-gradient(to left, var(--eng-surface), transparent);
}

.eng-emoji-wrap.has-more-left::before,
.eng-emoji-wrap.has-more-right::after {
    opacity: 1;
}

.eng-emoji-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 2px;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.eng-emoji-row::-webkit-scrollbar {
    display: none;
}

.eng-emoji {
    flex: 0 0 auto;
    border: none;
    background: none;
    font-size: 18px;
    line-height: 1;
    padding: 4px 5px;
    cursor: pointer;
    border-radius: var(--eng-radius);
}

.eng-emoji:hover {
    background: var(--eng-surface-sunk);
}

/* ── 목록 ───────────────────────────────────────────────── */
.eng-item {
    display: flex;
    padding: 15px 0 10px;
    border-bottom: 1px solid var(--eng-border);
}

.eng-avatar {
    position: relative;
    flex: 0 0 var(--eng-avatar);
    width: var(--eng-avatar);
    height: var(--eng-avatar);
    margin-right: 5px;
}

.eng-avatar > img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    background: #f1f3f5;
}

.eng-body {
    width: calc(100% - var(--eng-avatar) - 5px);
    padding-left: 8px;
}

.eng-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--eng-text);
}

.eng-time {
    font-size: 11px;
    color: var(--eng-text-faint);
}

/*
 * 등급 메달 — 프로필 사진 오른쪽 아래.
 *
 * 원 밖으로 조금 나가야 사진을 덜 가린다. 테두리를 흰 그림자로 두르는 이유는 어두운
 * 프로필 사진 위에서 메달이 묻히기 때문이다. (앱 _GradeMark 와 같은 규칙)
 *
 * badge_url 이 주소면 그림을, 아니면 글자 그대로 그린다 — 뱃지 이미지를 만들기 전에도
 * 이모지 한 자로 운영할 수 있다.
 */
.eng-grade {
    position: absolute;
    right: -2px;
    bottom: -2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--eng-medal);
    height: var(--eng-medal);
    border-radius: 50%;
    background: var(--eng-surface);
    box-shadow: 0 0 0 1.5px var(--eng-surface);
    font-size: calc(var(--eng-medal) * 0.66);
    line-height: 1;
    overflow: hidden;
}

.eng-grade > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.eng-text {
    font-weight: 400;
    font-size: 15px;
    line-height: 1.5;
    color: var(--eng-text);
    white-space: pre-line;
    word-wrap: break-word;
    text-align: justify;
}

/* 접힌 상태 — 네 줄까지만 보인다. 넘치는지는 JS 가 실제 높이로 판단한다. */
.eng-text.is-clamped {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
}

.eng-text.is-deleted {
    color: var(--eng-text-muted);
    font-style: italic;
}

.eng-more {
    color: var(--eng-text-faint);
    cursor: pointer;
    text-decoration: underline;
    font-size: 14px;
}

.eng-meta {
    display: flex;
    align-items: center;
    margin-top: 4px;
    font-size: 12px;
}

.eng-meta-btn {
    cursor: pointer;
    color: var(--eng-text);
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
}

.eng-like {
    display: flex;
    align-items: center;
    margin-left: auto;
    cursor: pointer;
    color: var(--eng-text);
}

.eng-like.is-on {
    color: var(--eng-accent);
}

.eng-like img {
    width: 12px;
    height: 12px;
    margin: 0 1px;
}

/*
 * 댓글에 붙은 그림 — 앱에서 올린 것을 보여 준다(웹은 올리지 못한다).
 *
 * 한 장이면 원본 비율 그대로, 여러 장이면 정사각 타일을 옆으로 늘어놓는다. 비율이
 * 제각각인 그림을 나란히 두려면 칸을 고르게 맞춰야 줄이 들쭉날쭉해지지 않는다 —
 * 원본 비율은 눌러서 크게 볼 때 지킨다. (앱 _MediaStrip 과 같은 규칙)
 */
.eng-media {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.eng-media::-webkit-scrollbar {
    display: none;
}

.eng-media-item {
    flex: 0 0 auto;
    display: block;
    width: 148px;
    height: 148px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--eng-surface-sunk);
}

.eng-media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 한 장뿐이면 자르지 않는다 — 자를 이유가 줄맞춤인데, 맞출 상대가 없다. */
.eng-media.is-single .eng-media-item {
    width: auto;
    height: auto;
    max-width: min(100%, 320px);
    max-height: 320px;
}

.eng-media.is-single .eng-media-item img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 320px;
    object-fit: contain;
}

/* ── 답글 ───────────────────────────────────────────────── */
.eng-replies {
    background-color: var(--eng-surface-sunk);
}

.eng-reply {
    display: flex;
    padding-left: var(--eng-indent);
}

/* 답글은 사진과 메달을 한 치수 줄인다 — 뿌리와 같은 크기면 어느 쪽이 답인지 흐려진다. */
.eng-reply .eng-item {
    --eng-avatar: 28px;
    --eng-medal:  13px;
}

.eng-reply-to {
    color: var(--eng-accent);
    font-weight: 500;
}

/* ── 더보기·빈 상태 ─────────────────────────────────────── */
.eng-more-row {
    text-align: center;
    padding: 8px 0;
}

.eng-more-row a {
    color: var(--eng-text);
    cursor: pointer;
}

.eng-empty {
    text-align: center;
    padding: 28px 0;
    font-size: 16px;
    color: var(--eng-text-muted);
}

/* ── 신고 사유 ──────────────────────────────────────────── */
.eng-reason {
    display: flex;
    align-items: center;
    width: 100%;
    border: none;
    background: none;
    padding: 13px 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--eng-text);
    text-align: left;
    cursor: pointer;
    border-bottom: 1px solid var(--eng-border);
}

.eng-reason:last-of-type {
    border-bottom: none;
}

.eng-reason:hover {
    background: var(--eng-surface-sunk);
}

.eng-reason i {
    margin-left: auto;
    color: var(--eng-text-muted);
}

.eng-reason-note {
    margin: 12px 0 0;
    font-size: 13px;
    color: var(--eng-text-muted);
    text-align: center;
}

/* ── 참여 반응 줄 (앱 EngagementBar) ─────────────────────────────
   회색 면에 앉은 알약 버튼. 켜졌을 때 아이콘만 색이 바뀌고 글자는 그대로다 —
   글자까지 물들이면 한 줄에서 그 칸만 튀어, 옆 아이콘 버튼이 꺼진 것처럼 보인다. */
.eng-bar { margin-top: 22px; }

.eng-bar-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.eng-bar-row + .eng-bar-row { margin-top: 20px; }

.eng-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border: 0;
    border-radius: 10px;
    background: #F0F0F5;
    color: #56565F;
    font: inherit;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: -0.3px;
    cursor: pointer;
    transition: transform 80ms ease;
}
.eng-pill.has-label { padding: 10px 18px; }
.eng-pill:active { transform: scale(0.96); }
.eng-pill svg { width: 17px; height: 17px; flex-shrink: 0; }
.eng-pill span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 내가 누른 것은 채운 아이콘과 색으로 함께 말한다 — 12~17px 짜리라 둘 중 하나만으로는
   눈에 안 걸린다. 좋아요는 빨강, 저장은 액센트: 둘 다 켜지는 자리라 색이 같으면
   무엇이 눌린 상태인지 아이콘 모양만으로 가려야 한다.
   글자는 물들이지 않는다 — 한 줄에서 그 칸만 튀어 옆 버튼이 꺼진 것처럼 보인다. */
.eng-pill--like.is-on { color: #F04452; }
.eng-pill--bookmark.is-on { color: #4338CA; }
.eng-pill.is-on svg,
.eng-pill.is-on svg * { fill: currentColor; stroke: currentColor; }
.eng-pill.is-on span { color: #56565F; }

.eng-bar-promo {
    margin: 20px 0 10px;
    text-align: center;
    font-size: 12.5px;
    font-weight: 700;
    color: #4338CA;
    letter-spacing: -0.2px;
}

.eng-bar-toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translate(-50%, 8px);
    padding: 10px 16px;
    border-radius: 10px;
    background: #1A1A1E;
    color: #fff;
    font-size: 13px;
    opacity: 0;
    transition: opacity 200ms ease, transform 200ms ease;
    z-index: 1000;
}
.eng-bar-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ── 카드 각주의 참여 지표 (앱 EngagementStats) ──────────────────
   면도 테두리도 두지 않는다 — 각주 한 줄에 칩을 세우면 그 자체가 눌러야 할 버튼처럼 보인다. */
.eng-stats { display: flex; align-items: center; gap: 14px; }
.eng-stat { display: inline-flex; align-items: center; gap: 4px; color: #56565F; }
.eng-stat svg { width: 14px; height: 14px; }
.eng-stat b { font-size: 12px; font-weight: 600; letter-spacing: -0.2px; }
/* 각주 줄은 반대다 — 아이콘도 숫자도 함께 물들인다. 12픽셀 각주라 아이콘 모양 차이
   하나에 기대면 눌렀는지 아닌지가 안 읽힌다(앱 _Stat 과 같은 규칙). */
.eng-stat.is-mine-like { color: #F04452; }
.eng-stat.is-mine-bookmark { color: #4338CA; }
.eng-stat.is-mine-like svg *,
.eng-stat.is-mine-bookmark svg * { fill: currentColor; stroke: currentColor; }

/* ── 의견 시트 (앱 EngagementFeedbackSheet) ─────────────────────
   아래에서 올라온다. 무엇에 대한 의견인지 대상을 다시 세우고, 갈래를 고른 뒤
   쓴 말이 있어야 보낼 수 있다. */
.eng-sheet {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(22,22,31,0.45);
    /* 붙이는 화면이 '본문 기둥이 화면 한가운데보다 얼마나 왼쪽인지'를 건네면 그만큼
       비켜 선다(그 두 배를 오른쪽에 물린다). 안 건네면 0 — 화면 한가운데 그대로다. */
    padding-right: var(--eng-layer-side, 0px);
    /* 어둠을 제 합성 레이어로 올린다 — 화면에 틀어 둔 영상(iframe)이 있으면 그쪽이 따로
       합성돼 z-index 를 무시하고 어둠 위로 그려진다. 자식은 정적 배치라 배치는 그대로다. */
    transform: translateZ(0);
}
.eng-sheet[hidden] { display: none; }

.eng-sheet-panel {
    width: 100%;
    max-width: 520px;
    max-height: 86vh;
    overflow-y: auto;
    padding: 10px 20px 24px;
    border-radius: 20px 20px 0 0;
    background: #fff;
    animation: eng-sheet-up 220ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes eng-sheet-up { from { transform: translateY(16px); opacity: 0.6; } to { transform: none; opacity: 1; } }

.eng-sheet-grip { display: block; width: 44px; height: 4px; margin: 0 auto 18px; border-radius: 2px; background: #E5E5EA; }
.eng-sheet-title { margin: 0 0 6px; font-size: 19px; font-weight: 800; color: #16161F; letter-spacing: -0.5px; }
.eng-sheet-sub { margin: 0 0 16px; font-size: 13.5px; color: #9A9AA3; letter-spacing: -0.3px; }

.eng-sheet-target {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #F0F0F5;
    font-size: 13px;
    font-weight: 600;
    color: #56565F;
}
.eng-sheet-target svg { width: 16px; height: 16px; flex-shrink: 0; color: #9A9AA3; }
.eng-sheet-target span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.eng-sheet-cats { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.eng-cat {
    padding: 10px 16px;
    border: 0;
    border-radius: 999px;
    background: #F0F0F5;
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: #56565F;
    cursor: pointer;
}
.eng-cat.is-on { background: #4338CA; color: #fff; }

.eng-sheet-input {
    width: 100%;
    min-height: 120px;
    padding: 14px;
    border: 1px solid #EAECF0;
    border-radius: 12px;
    font: inherit;
    font-size: 14px;
    line-height: 1.6;
    color: #16161F;
    resize: none;
}
.eng-sheet-input:focus { outline: 0; border-color: #C7C7D9; }
.eng-sheet-input::placeholder { color: #9A9AA3; }

.eng-sheet-submit {
    width: 100%;
    margin-top: 16px;
    padding: 15px;
    border: 0;
    border-radius: 12px;
    background: #4338CA;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
}
/* 쓴 말이 없으면 눌린 티를 내지 않는다. */
.eng-sheet-submit[disabled] { background: #F0F0F5; color: #9A9AA3; cursor: default; }

/*
 * 넓은 화면에서는 아래에 붙일 이유가 없다.
 *
 * 바텀시트는 엄지가 닿는 자리를 노린 조판이라, 마우스로 보는 1000px 짜리 화면에서는
 * 눈이 보던 자리(가운데 카드)에서 한참 아래 구석에 나타나 어디서 뭐가 열렸는지 놓친다.
 * 창 높이가 얕으면 아래 끝이 잘려 '보내기'가 화면 밖으로 나가기도 한다.
 * 좁은 화면은 앱과 같은 바텀시트 그대로 둔다.
 *
 * 이 덩어리는 반드시 위 `.eng-sheet-*` 기본값 **뒤**에 온다 — 미디어 쿼리는 우선순위를
 * 올려 주지 않아서, 앞에 두면 뒤따르는 기본값이 그대로 이겨 아무 일도 일어나지 않는다.
 */
@media (min-width: 768px) {
    .eng-sheet { align-items: center; padding: 24px; padding-right: calc(24px + var(--eng-layer-side, 0px)); }

    .eng-sheet-panel {
        max-width: 460px;
        max-height: calc(100vh - 48px);
        border-radius: 18px;
    }

    /* 손잡이(그립)는 끌어내리라는 표시다 — 끌 수 없는 자리에서는 세우지 않는다. */
    .eng-sheet-grip { display: none; }
}


/* ── 본문에 붙은 링크 카드 (앱 EngagementEmbedCard) ────────────── */
.eng-embed {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin-top: 8px;
    border-radius: 10px;
    background: var(--eng-surface-card);
    overflow: hidden;
    text-decoration: none;
}
.eng-embed-thumb { flex: 0 0 96px; width: 96px; background: var(--eng-surface-ph); }
.eng-embed-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.eng-embed-text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 10px 12px 10px 0;
}
.eng-embed-text b {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--eng-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.eng-embed-text span { font-size: 11.5px; color: var(--eng-text-muted); }
.eng-embed-thumb:empty { display: none; }
.eng-embed-thumb + .eng-embed-text { padding-left: 0; }
.eng-embed:not(:has(.eng-embed-thumb)) .eng-embed-text { padding-left: 12px; }

/* 영상은 16:9 한 장으로 — 썸네일 위에 재생 표시를 얹고 제목을 아래에 깐다. */
.eng-embed.is-video { position: relative; display: block; }
.eng-embed.is-video .eng-embed-thumb { width: 100%; aspect-ratio: 16 / 9; background: #000; }
.eng-embed.is-video .eng-embed-thumb::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-width: 9px 0 9px 15px;
    border-color: transparent transparent transparent rgba(255,255,255,0.95);
    filter: drop-shadow(0 1px 4px rgba(0,0,0,0.5));
}
.eng-embed.is-video .eng-embed-text {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 24px 12px 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.75));
}
.eng-embed.is-video .eng-embed-text b { color: #fff; }
.eng-embed.is-video .eng-embed-text span { color: rgba(255,255,255,0.75); }

/* 그 자리에서 트는 영상 — 카드가 있던 자리를 그대로 쓴다. */
.eng-embed-player {
    margin-top: 8px;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 16 / 9;
}
.eng-embed-player iframe { display: block; width: 100%; height: 100%; border: 0; }
