/* ── View page tweaks ────────────────────────────────────────────────────
   The viewport is a grid with two auto rows: the wipe (sized in pixels by
   view.js) and the view-info bar (a constant-height block: title row +
   single-line prompt row). view.js sizes the wipe to contain-fit the
   remaining space after subtracting the info bar, so the (wipe + info bar)
   group always fits — and align-content: center keeps the group vertically
   centered in the viewport. */

:root {
    --view-panel-peek: 126px;
    /* Have share.css's wipe-width fallback formula use the View peek too. */
    --share-panel-peek: var(--view-panel-peek);
    /* Follow the community header, which grows to two rows on mobile. */
    --share-header-height: var(--community-header-height);

    --content-max-width: 800px;
}

/* Material Symbols Rounded — the View page's URL exposes the FILL axis
   as a 0..1 range. Default to filled so existing icons (chevrons, etc.)
   keep their previous look; .view-info__icon--outline flips back to 0. */
.material-symbols-rounded {
    font-variation-settings: 'FILL' 1;
}

.share-preview__viewport {
    display: grid;
    grid-template-rows: auto auto;
    grid-template-columns: 1fr;
    align-content: center;
    justify-items: stretch;
    gap: 28px;
    padding: var(--share-preview-gap);
    bottom: var(--view-panel-peek);
}

.share-preview__wipe {
    /* Width/height in pixels are set by view.js (overriding share.js). */
    justify-self: center;
}

.view-info {
    /* No max-height needed — the structure (one title row + one prompt
       line + MORE button) makes the bar a constant height. view.js reads
       offsetHeight to subtract it from the wipe's available area. */
    box-sizing: border-box;
}

/* Cross-fade: when the full info block (below the thumbs) scrolls into
   view, the original (top) info bar fades out. */
#view-info-top {
    transition: opacity 0.25s ease;
}

#view-info-top.view-info--faded {
    opacity: 0;
    pointer-events: none;
}

.view-info__inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: var(--content-max-width);
    margin: 0 auto;
}

.view-info__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.view-info__primary {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
}

.view-info__title {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.3px;
    margin: 0;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.view-info__author {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    flex: 0 0 auto;
}

.view-info__author-link {
    color: var(--text-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    font-weight: 500;
}

.view-info__author-link:hover,
.view-info__author-link:focus-visible {
    border-bottom-color: currentColor;
}

.view-info__stats {
    display: flex;
    align-items: center;
    gap: 18px;
    flex: 0 0 auto;
}

.view-info__stat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1;
    font-weight: 500;
}

.view-info__icon {
    font-size: 20px;
    line-height: 1;
    color: var(--accent);
    transition: transform 0.15s ease, color 0.15s ease;
}

.view-info__stat:hover .view-info__icon {
    transform: scale(1.2);
}

.view-info__icon--outline {
    font-variation-settings: 'FILL' 0;
}

.view-info__icon--liked {
    color: #e53935;
    font-variation-settings: 'FILL' 1;
}

.view-info__count {
    line-height: 1;
    margin-bottom: 3px;
}

.view-info__count--hidden {
    display: none;
}

/* All interactive stats — button or anchor — share the same reset so
   they look identical to the sibling stat spans. */
.view-info__like,
.view-info__comment-btn,
.view-info__download-btn {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
    text-decoration: none;
}

.view-info__like:focus-visible,
.view-info__comment-btn:focus-visible,
.view-info__download-btn:focus-visible {
    outline: none;
}

.view-info__like:focus-visible .view-info__icon,
.view-info__comment-btn:focus-visible .view-info__icon {
    transform: scale(1.2);
}

/* The download button is a primary-style capsule — "DOWNLOAD" text on
   an accent background, with the .btn's hover swap (accent → accent-hover). */
.view-info__download-capsule {
    background-color: var(--accent);
    color: #fff;
    padding: 14px 22px;
    border-radius: 9999px;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    line-height: 1;
    flex: 0 0 auto;
    transition: background-color 0.15s ease;
}

/* Override the .view-info__stat 5px gap with a slightly larger gap so the
   download count sits a little further from the capsule than the other
   stats sit from their icons. */
.view-info__download-btn {
    gap: 8px;
}

.view-info__download-btn:hover .view-info__download-capsule,
.view-info__download-btn:focus-visible .view-info__download-capsule {
    background-color: var(--accent-hover);
}

/* Prompt row — single line of text with MORE button next to it. The
   button always reserves its layout space (visibility:hidden by default)
   so toggling it doesn't shift the prompt's available width. */
.view-info__prompt-row {
    display: flex;
    align-items: baseline;
    gap: 5px;
    overflow: hidden;
}

.view-info__prompt-label {
    /* Lives inside .view-info__prompt so it can lead the wrapped text on
       mobile; the margin stands in for the row's flex gap. */
    margin-right: 5px;
    color: var(--text-color);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    line-height: 1.45;
    opacity: 0.25;
}

.view-info__prompt {
    /* basis:auto so the prompt sizes to its content — MORE sits right after
       the visible text instead of being pushed to the row's right edge.
       flex-shrink:1 + min-width:0 still lets it truncate when the first
       line is wider than the remaining row space. */
    flex: 0 1 auto;
    min-width: 0;
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.45;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
}

/* Ellipsis sibling — appears just after the prompt text whenever MORE
   is visible (either because the prompt has additional lines or its
   first line was width-truncated). JS toggles the --visible class in
   lock-step with the MORE button. Negative margin cancels the
   prompt-row's flex gap so the dots sit flush against the prompt text,
   as if they were part of the prompt string. */
.view-info__prompt-ellipsis {
    flex: 0 0 auto;
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.45;
    margin-left: -5px;
    display: none;
}

.view-info__prompt-ellipsis--visible {
    display: inline;
}

.view-info__more {
    background: transparent;
    border: none;
    color: var(--accent);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.4px;
    cursor: pointer;
    padding: 0;
    /* Reserved-space hide by default; .--visible flips it on. */
    visibility: hidden;
}

.view-info__more--visible {
    visibility: visible;
}

.view-info__more:hover,
.view-info__more:focus-visible {
    color: var(--accent-hover);
    outline: none;
}

.share-panel {
    margin-top: calc(100vh - var(--view-panel-peek));
    /* svh = viewport height with mobile browser toolbars showing. Plain vh
       on iOS Safari is the toolbars-hidden height, which pushed the
       thumbnails below the visible screen at scroll = 0. */
    margin-top: calc(100svh - var(--view-panel-peek));
}

/* ── Full info block (below the thumbnail row in the scrolling panel)
   Shows the entire prompt + optional description + comments. Each piece
   lives in a .view-info__section with a header label on its own line. */
.view-info--full {
    padding: 32px 40px 80px;
}

.view-info--full .view-info__inner {
    gap: 24px;
}

.view-info__section {
    display: block;
    /* scrollIntoView (MORE → Prompt, comment button → Comments) stops below
       the fixed header rather than underneath it. */
    scroll-margin-top: calc(var(--share-header-height) + 16px);
}

.view-info__section-label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    margin: 0 0 8px;
    opacity: 0.5;
}

.view-info__section-content {
    margin: 0;
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* ── Comment form ─────────────────────────────────────────────────────── */

.comment-form {
    margin-bottom: 18px;
}

.comment-form__field {
    position: relative;
}

.comment-form__input {
    box-sizing: border-box;
    width: 100%;
    /* Leave room on the right for the absolutely-positioned Post button. */
    padding: 12px 72px 12px 16px;
    border: 1px solid var(--input-border);
    border-radius: 12px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease;
}

.comment-form__input::placeholder {
    color: var(--text-muted);
}

.comment-form__input:focus {
    border-color: var(--input-border-focus);
}

.comment-form__post {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.4px;
    color: var(--accent);
    padding: 6px 10px;
    transition: color 0.15s ease;
}

.comment-form__post:hover,
.comment-form__post:focus-visible {
    color: var(--accent-hover);
    outline: none;
}

.comment-form__post:disabled {
    color: var(--text-muted);
    cursor: default;
    pointer-events: none;
}

/* ── Comment list ─────────────────────────────────────────────────────── */

.comments {
    list-style: none;
    margin: 0;
    padding: 5px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.comment {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

/* Mirrors .profile-avatar from account.css — circular monogram on a
   deterministic color background (seeded on the commenter's email). */
.comment__avatar {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    user-select: none;
    line-height: 1;
    text-box-trim: trim-both;
    text-box-edge: cap alphabetic;
}

.comment__main {
    flex: 1 1 auto;
    min-width: 0;
}

.comment__body {
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.5;
}

.comment__author {
    font-weight: 600;
    margin-right: 1px;
    /* The author is a link to the author's page — keep it visually
       matching the surrounding comment text (no default blue/underline). */
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s ease;
}

.comment__author:hover,
.comment__author:focus-visible {
    border-bottom-color: currentColor;
    outline: none;
}

.comment__content {
    color: var(--text-color);
    word-wrap: break-word;
    overflow-wrap: anywhere;
    opacity: 0.8;
}

.comment__age {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0.65;
}

/* The inline MORE inside the prompt is only used by the mobile layout below. */
.view-info__more--inline {
    display: none;
}

/* ── Mobile ──────────────────────────────────────────────────────────────
   • Title row: the author line and the download/comment/like buttons can
     wrap onto their own lines instead of overflowing.
   • Prompt: wraps and is clipped to 2 lines, with "… more" pinned to the
     bottom-right corner whenever there's more to see. */
@media (max-width: 640px) {
    :root {
        --share-preview-gap: 16px;
    }

    /* Tighter wipe ↔ info bar gap; view.js reads this when sizing the wipe. */
    .share-preview__viewport {
        gap: 16px;
    }

    .view-info__top {
        flex-wrap: wrap;
        row-gap: 10px;
        column-gap: 16px;
    }

    /* Author always drops under the title (wrapping first); the stats then
       stay beside the title/author block and only wrap to their own line
       if that block is still too wide for them. */
    .view-info__primary {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        max-width: 100%;
    }

    /* Stats wrapped under the title/author (flagged by view.js): centre the
       title, author and stats. */
    .view-info__top--wrapped {
        justify-content: center;
        /* More room between the author line and the wrapped stats. */
        row-gap: 16px;
    }

    .view-info__top--wrapped .view-info__primary {
        align-items: center;
    }

    .view-info__title {
        font-size: 22px;
        max-width: 100%;
    }

    .view-info__stats {
        gap: 16px;
    }

    .view-info__download-capsule {
        padding: 12px 18px;
    }

    .view-info__prompt-row {
        /* Extra breathing room (on top of the inner's 8px gap) between the
           wrapped title/author/stats block and the prompt. */
        margin-top: 8px;
        display: block;
    }

    /* The external ellipsis/MORE are replaced by the inline MORE. */
    .view-info__prompt-row > .view-info__prompt-ellipsis,
    .view-info__prompt-row > .view-info__more {
        display: none !important;
    }

    /* Plain block clipped to 2 lines — vertical space on phones goes to the
       preview image first. (Not -webkit-box/line-clamp: iOS
       Safari lays that out as a legacy flexbox, which ignores floats and
       hid the text entirely.) */
    .view-info__prompt {
        display: block;
        position: relative;
        white-space: normal;
        overflow-wrap: anywhere;
        max-height: calc(2 * 1.45em);
        overflow: hidden;
    }

    /* "… more" pinned to the bottom-right of the visible lines. Its opaque
       page-coloured background covers the clipped tail of the last line. */
    .view-info__more--inline {
        display: none;
        position: absolute;
        right: 0;
        bottom: 0;
        padding-left: 4px;
        line-height: 1.45;
        background-color: var(--bg-color);
    }

    .view-info__more--inline::before {
        content: "\2026\00a0";
        color: var(--text-color);
        font-weight: 400;
    }

    .view-info__more--inline.view-info__more--visible {
        display: block;
    }
}
