/* Photo and voice comments (Phase 8) — the composer's photo and mic
 * buttons, the bar under the composer (preview, recorder, problems), and a
 * comment's photo and voice note in the thread, the replies and the Watch
 * drawer. Markup: comments/partials/commentMediaButtons.php,
 * commentMediaBar.php, commentAttachment.php; behaviour:
 * comments/js/comment_media.js. Light and dark follow sb_theme.css. */

:root, body {
    --cm-accent: var(--sb-accent, #0073b7);
    --cm-accent-soft: rgba(0, 115, 183, .10);
    --cm-surface: var(--sb-surface, #fff);
    --cm-sunken: #f0f2f5;
    --cm-border: var(--sb-border, #e6e6e6);
    --cm-text: #1c1e21;
    --cm-muted: #65676b;
    --cm-danger: var(--sb-danger, #c0392b);
    --cm-danger-soft: rgba(192, 57, 43, .10);
    --cm-wave: #c4c9d2;
}
body.theme-dark {
    --cm-accent: #4aa8e8;
    --cm-accent-soft: rgba(74, 168, 232, .16);
    --cm-sunken: #2a2f3d;
    --cm-text: #e4e6eb;
    --cm-muted: #a8adb8;
    --cm-danger-soft: rgba(226, 94, 77, .16);
    --cm-wave: #4a5164;
}

/* ---------- Composer buttons ---------- */
.cm-tools {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    vertical-align: middle;
    margin-right: 2px;
}
.cm-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--cm-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, transform .1s ease;
}
.cm-tool:hover,
.cm-tool:focus-visible {
    background: var(--cm-accent-soft);
    color: var(--cm-accent);
    outline: none;
}
.cm-tool:focus-visible { box-shadow: 0 0 0 2px var(--cm-accent); }
.cm-tool:active { transform: scale(.92); }
.cm-tool.is-recording {
    background: var(--cm-danger);
    color: #fff;
    animation: cmRing 1.4s ease-out infinite;
}
.cm-tool[disabled] { opacity: .45; cursor: default; }

/* ---------- The bar under the composer ---------- */
.cm-media-bar {
    margin: 8px 0 2px 40px;
    max-width: 440px;
}
.replycomment .cm-media-bar { margin-left: 0; }

.cm-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 40px 8px 8px;
    background: var(--cm-surface);
    border: 1px solid var(--cm-border);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
    animation: cmIn .18s ease-out;
}
.cm-preview-thumb {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--cm-sunken);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cm-accent);
    font-size: 24px;
}
.cm-preview-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-preview-body { min-width: 0; flex: 1 1 auto; }
.cm-preview-title { font-weight: 600; font-size: 14px; color: var(--cm-text); }
.cm-preview-meta { font-size: 12px; color: var(--cm-muted); margin-top: 1px; }
.cm-preview-body .cm-voice { margin-top: 6px; }
.cm-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 50%;
    background: var(--cm-sunken);
    color: var(--cm-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
}
.cm-remove:hover { background: var(--cm-danger-soft); color: var(--cm-danger); }

/* Recording */
.cm-recording { padding-right: 8px; }
.cm-rec-dot {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--cm-danger);
    animation: cmPulse 1s ease-in-out infinite;
}
.cm-rec-timer {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 14px;
    color: var(--cm-text);
    min-width: 36px;
}
.cm-rec-bars { display: inline-flex; align-items: center; gap: 3px; height: 22px; flex: 1 1 auto; }
.cm-rec-bars i {
    display: block;
    width: 3px;
    height: 30%;
    border-radius: 2px;
    background: var(--cm-danger);
    opacity: .75;
    animation: cmLevel 1s ease-in-out infinite;
}
.cm-rec-bars i:nth-child(2n) { animation-delay: -.25s; }
.cm-rec-bars i:nth-child(3n) { animation-delay: -.5s; }
.cm-rec-bars i:nth-child(5n) { animation-delay: -.75s; }
.cm-rec-actions { display: inline-flex; gap: 6px; flex: 0 0 auto; }
.cm-pill {
    border: 0;
    border-radius: 16px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.cm-pill-ghost { background: var(--cm-sunken); color: var(--cm-text); }
.cm-pill-ghost:hover { background: var(--cm-border); }
.cm-pill-accent { background: var(--cm-accent); color: #fff; }
.cm-pill-accent:hover { filter: brightness(1.08); }

/* A problem with the file */
.cm-error {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 10px;
    background: var(--cm-danger-soft);
    color: var(--cm-danger);
    font-size: 13px;
}

/* ---------- In the thread ---------- */
.cm-attachment { margin-top: 6px; }
.cm-photo {
    position: relative;
    display: inline-block;
    max-width: 260px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--cm-border);
    background: var(--cm-sunken);
    line-height: 0;
    cursor: zoom-in;
}
.cm-photo img {
    display: block;
    max-width: 260px;
    max-height: 260px;
    width: auto;
    height: auto;
    object-fit: cover;
    transition: transform .25s ease;
}
.cm-photo:hover img { transform: scale(1.03); }
/* The comment thread squares and floats every image as an avatar (sb.css). */
.box-comments .box-comment .cm-photo img,
.box-comments .box-comment .cm-preview-thumb img {
    float: none;
    width: auto;
    height: auto;
}
.box-comments .box-comment .cm-preview-thumb img { width: 100%; height: 100%; }
.cm-photo-zoom {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    opacity: 0;
    transition: opacity .15s ease;
}
.cm-photo:hover .cm-photo-zoom,
.cm-photo:focus-visible .cm-photo-zoom { opacity: 1; }

/* Voice note player */
.cm-voice {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
    max-width: 300px;
    padding: 6px 12px 6px 6px;
    border-radius: 22px;
    background: var(--cm-surface);
    border: 1px solid var(--cm-border);
}
.comment-text-wrap .cm-voice,
.wt-cmt-bubble .cm-voice { background: var(--cm-surface); }
/* Without comment_media.js (no html.cm-js) the browser's own player shows. */
.cm-voice audio { display: block; width: 100%; height: 36px; }
.cm-voice-play, .cm-wave, .cm-voice-time { display: none !important; }
html.cm-js .cm-voice audio { display: none; }
html.cm-js .cm-voice-play, html.cm-js .cm-wave { display: flex !important; }
html.cm-js .cm-voice-time { display: inline !important; }
.cm-voice-play {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: var(--cm-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
}
.cm-voice-play .feather-play { margin-left: 2px; }
.cm-voice-play:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--cm-surface), 0 0 0 4px var(--cm-accent); }
.cm-wave {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 2px;
    height: 26px;
    cursor: pointer;
}
.cm-wave i {
    display: block;
    flex: 1 1 0;
    min-width: 2px;
    max-width: 4px;
    border-radius: 2px;
    background: var(--cm-wave);
    transition: background-color .1s linear;
}
.cm-wave i.on { background: var(--cm-accent); }
.cm-voice-time {
    flex: 0 0 auto;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--cm-muted);
    min-width: 30px;
    text-align: right;
}
.cm-voice.is-playing .cm-voice-time { color: var(--cm-accent); }

/* Full-screen photo */
.cm-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(10, 12, 16, .92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    cursor: zoom-out;
    animation: cmFade .15s ease-out;
}
.cm-lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.cm-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}
.cm-lightbox-close:hover { background: rgba(255, 255, 255, .28); }

@keyframes cmPulse { 50% { opacity: .3; } }
@keyframes cmLevel { 0%, 100% { height: 25%; } 50% { height: 95%; } }
@keyframes cmRing { 0% { box-shadow: 0 0 0 0 rgba(192, 57, 43, .45); } 100% { box-shadow: 0 0 0 10px rgba(192, 57, 43, 0); } }
@keyframes cmIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes cmFade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    .cm-tool.is-recording, .cm-rec-dot, .cm-rec-bars i, .cm-card, .cm-lightbox { animation: none; }
    .cm-photo img { transition: none; }
}

@media (max-width: 480px) {
    .cm-media-bar { margin-left: 0; }
    .cm-photo, .cm-photo img { max-width: 200px; }
    .cm-voice { min-width: 0; width: 100%; }
    .cm-rec-hint { display: none; }
}
