/* Shared dice rolls: the share button in the roller's header, its dialog, and
   the two things it adds to the roll log. See src/scripts/share.js.

   The button lives in #roller-toggles, the header's evenly spaced row of
   buttons, after the sound toggle (dice-lists.css).

   Colours only through theme tokens: lintColours() in build.js fails the build
   on a literal. */

/* Drawn to match Tia's speaker disc beside it (diceroller.css .sound-toggle):
   a 36px disc, 2px accent ring, and a one-colour icon masked in the theme
   colour. Like the speaker it overhangs the 30px row by 3px top and bottom
   rather than growing it. #roller-toggles does the side spacing.

   Unlike the speaker it is never dimmed: the speaker is a preference that is
   off, this is an action waiting to be pressed, and a faded button reads as
   one that does not work. */
.share-btn {
    position: relative;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    margin: -3px 0;
    padding: 0;
    border: var(--theme-primary) solid 2px;
    border-radius: 50%;
    background-color: var(--bg-input);
    line-height: 0;
    cursor: pointer;
}

/* 24px inside the 36px disc, matching the speaker (diceroller.css). */
.share-ico {
    width: 24px;
    height: 24px;
    background-color: var(--theme-primary);
    -webkit-mask: url("/assets/icons/people.svg") center / contain no-repeat;
            mask: url("/assets/icons/people.svg") center / contain no-repeat;
    pointer-events: none;
}

.share-btn:hover {
    background-color: var(--bg-secondary);
}

.share-btn:focus-visible {
    outline: 3px solid var(--theme-primary);
    outline-offset: 2px;
}

/* Sharing: the disc fills with the accent and the people turn light. */
.share-btn.share-on,
.share-btn.share-on:hover {
    background-color: var(--theme-primary-bg);
    border-color: var(--theme-primary-dark);
}

.share-btn.share-on .share-ico {
    background-color: var(--text-on-accent);
}

.share-btn.share-wait {
    opacity: 0.6;
}

/* How many are in, as a badge on the disc's shoulder rather than text beside
   it, so the disc keeps its size and the column keeps its width. */
.share-count {
    position: absolute;
    top: -6px;
    right: -9px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    box-sizing: border-box;
    border: var(--bg-input) solid 1.5px;
    border-radius: 8px;
    background-color: var(--theme-primary);
    color: var(--text-on-accent);
    font-size: 10px;
    font-weight: 700;
    line-height: 13px;
    text-align: center;
    pointer-events: none;
}

.share-count:empty {
    display: none;
}

/* ── the dialog (framed by .cd-dialog in confirm-dialog.css) ── */

.share-dialog {
    max-width: 420px;
}

.share-field {
    margin: 0 0 14px;
    font-size: 0.92em;
}

.share-field label {
    display: block;
    margin: 0 0 4px;
    font-weight: 700;
}

.share-field[hidden],
.share-people[hidden],
.share-lock[hidden],
.share-dialog .cd-btn[hidden] {
    display: none;
}

.share-input {
    box-sizing: border-box;
    width: 100%;
    padding: 6px 8px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    background-color: var(--bg-input);
    color: var(--text-primary);
    font-size: 1em;
    line-height: 1.3;
}

.share-input:focus-visible {
    outline: 3px solid var(--theme-primary);
    outline-offset: 1px;
}

.share-link-row {
    display: flex;
    gap: 8px;
}

.share-link-row .share-input {
    flex: 1 1 auto;
    min-width: 0;
}

.share-people {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
    max-height: 40vh;
    overflow-y: auto;
}

.share-people li {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.92em;
    line-height: 1.3;
    list-style: none;
}

.share-person {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.share-tag {
    padding: 1px 6px;
    border: 1px solid var(--theme-primary);
    border-radius: 8px;
    color: var(--theme-primary);
    font-size: 0.75em;
    font-weight: 700;
}

.share-here,
.share-away {
    font-size: 0.8em;
    color: var(--text-secondary);
}

.share-here {
    color: var(--ok);
}

.share-dialog .share-remove {
    padding: 3px 8px;
    font-size: 0.8em;
}

.share-lock {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 14px;
    font-size: 0.92em;
    cursor: pointer;
}

.share-msg {
    min-height: 1.2em;
    margin: 0 0 12px;
    font-size: 0.88em;
    line-height: 1.35;
    color: var(--text-secondary);
}

.share-msg.share-bad {
    color: var(--theme-primary);
    font-weight: 700;
}

.share-streak {
    width: 100%;
    accent-color: var(--theme-primary);
}

/* A share's cooldown between rolls (the DM sets 1 to 10 seconds): every Roll
   button and Roll All greys out and stops taking clicks until it ends.
   share.js toggles the class. */
#dice-roller.share-cooldown .roll,
#dice-roller.share-cooldown #roll-all {
    opacity: 0.4;
    filter: grayscale(1);
    pointer-events: none;
    cursor: default;
}

/* ── the roll log ── */

.share-who {
    font-weight: 700;
    color: var(--theme-primary);
}

.log-text.share-note {
    font-style: italic;
    color: var(--text-secondary);
}
