@import '../../utils/colors.less';
@import '../../utils/fonts.less';
@import '../../utils/spacing.less';

.daggerheart.chat {
    &.resource-roll {
        .reroll-message {
            text-align: center;
            font-size: 18px;
            margin-bottom: 0;
        }
    }

    /* &.roll {
        .dice-flavor {
            text-align: center;
            font-weight: bold;
        }
        .dice-tooltip {
            .dice-rolls {
                &.duality {
                    display: flex;
                    gap: 0.25rem;

                    > .roll {
                        background-image: none;

                        .reroll-button {
                            border: none;
                            background: initial;
                            width: 42px;

                            &:hover {
                                background: var(--button-background-color);
                                border: 1px solid var(--button-border-color);
                            }
                        }
                    }
                }

                &.rerollable {
                    position: relative;
                    flex: none;

                    .dice-rerolled {
                        z-index: 2;
                        position: absolute;
                        right: 0;
                        font-size: 12px;
                        cursor: help;
                    }

                    .reroll-button {
                        border: none;
                        background: initial;

                        &:hover {
                            background: var(--button-background-color);
                            border: 1px solid var(--button-border-color);
                        }
                    }
                }

                // margin: 0;
                > .roll {
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    gap: 4px;
                    margin-bottom: 4px;

                    .dice-container {
                        display: flex;
                        flex-direction: column;
                        gap: 2px;
                        position: relative;

                        .dice-title {
                            color: var(--color-light-1);
                            text-shadow: 0 0 1px black;
                        }

                        .dice-rerolled {
                            z-index: 2;
                            position: absolute;
                            right: -2px;
                            font-size: 12px;
                            cursor: help;
                        }

                        .dice-inner-container {
                            display: flex;
                            align-items: center;
                            justify-content: center;
                            position: relative;
                            &.hope,
                            &.fear {
                                .dice-wrapper {
                                    clip-path: polygon(
                                        50% 0%,
                                        80% 10%,
                                        100% 35%,
                                        100% 70%,
                                        80% 90%,
                                        50% 100%,
                                        20% 90%,
                                        0% 70%,
                                        0% 35%,
                                        20% 10%
                                    );
                                }
                            }
                            .dice-wrapper {
                                height: 24px;
                                width: 24px;
                                position: relative;
                                display: flex;
                                align-items: center;
                                justify-content: center;

                                .dice {
                                    height: 26px;
                                    width: 26px;
                                    max-width: unset;
                                    position: absolute;
                                }
                            }

                            .dice-value {
                                position: absolute;
                                font-weight: bold;
                                font-size: 16px;
                            }

                            &.hope {
                                .dice-wrapper {
                                    background: black;

                                    .dice {
                                        filter: brightness(0) saturate(100%) invert(79%) sepia(79%) saturate(333%)
                                            hue-rotate(352deg) brightness(102%) contrast(103%);
                                    }
                                }

                                .dice-value {
                                    color: var(--color-dark-1);
                                    text-shadow: 0 0 4px white;
                                }
                            }

                            &.fear {
                                .dice-wrapper {
                                    background: white;

                                    .dice {
                                        filter: brightness(0) saturate(100%) invert(12%) sepia(88%) saturate(4321%)
                                            hue-rotate(221deg) brightness(92%) contrast(110%);
                                    }
                                }

                                .dice-value {
                                    color: var(--color-light-1);
                                    text-shadow: 0 0 4px black;
                                }
                            }

                            &.advantage {
                                .dice-wrapper {
                                    .dice {
                                        filter: brightness(0) saturate(100%) invert(18%) sepia(92%) saturate(4133%)
                                            hue-rotate(96deg) brightness(104%) contrast(107%);
                                    }
                                }
                            }

                            &.disadvantage {
                                .dice-wrapper {
                                    .dice {
                                        filter: brightness(0) saturate(100%) invert(9%) sepia(78%) saturate(6903%)
                                            hue-rotate(11deg) brightness(93%) contrast(117%);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            .damage-resource {
                font-weight: 600;
                margin-top: 5px;
            }
        }

        .dice-total {
            &.duality {
                &.hope {
                    border-color: @hope;
                    border-width: 3px;
                    background: rgba(@hope, 0.5);
                }
                &.fear {
                    border-color: @fear;
                    border-width: 3px;
                    background: rgba(@fear, 0.5);
                }
                &.critical {
                    border-color: @critical;
                    border-width: 3px;
                    background: rgba(@critical, 0.5);
                }
            }

            .dice-total-value {
                .hope {
                    color: @hope;
                }
                .fear {
                    color: @fear;
                }
                .critical {
                    color: @critical;
                }
            }
        }

        .dice-total-label {
            font-size: 12px;
            font-weight: bold;
            font-variant: all-small-caps;
            margin: -@fullMargin 0;
        }

        .target-selection {
            display: flex;
            justify-content: space-around;
            input[type='radio'] {
                display: none;
                &:checked + label {
                    text-shadow: 0px 0px 4px #ce5937;
                }
                &:not(:checked) + label {
                    opacity: 0.75;
                }
            }
            label {
                cursor: pointer;
                opacity: 0.75;
                &.target-selected {
                    text-shadow: 0px 0px 4px #ce5937;
                    opacity: 1;
                }
            }
        }

        .target-section {
            margin-top: 5px;

            .target-container {
                display: flex;
                transition: all 0.2s ease-in-out;

                &:hover {
                    filter: drop-shadow(0 0 3px @secondaryShadow);
                    border-color: gold;
                }

                &.hidden {
                    display: none;
                    border: 0;
                }

                &.hit {
                    background: @hit;
                }

                &.miss {
                    background: @miss;
                }

                img,
                .target-save-container {
                    width: 22px;
                    height: 22px;
                    align-self: center;
                    border-color: transparent;
                }

                img {
                    flex: 0;
                    margin-left: 8px;
                }

                .target-save-container {
                    margin-right: 8px;
                    justify-content: center;
                    display: flex;
                    align-items: center;
                    min-height: unset;
                    border: 1px solid black;
                }

                .target-inner-container {
                    flex: 1;
                    display: flex;
                    justify-content: center;
                    font-size: var(--font-size-16);
                }

                &:not(:has(.target-save-container)) .target-inner-container {
                    margin-right: @hugeMargin;
                }
            }
        }

        .dice-actions {
            display: flex;
            gap: 4px;

            button {
                flex: 1;
                height: 40px;
                font-family: @font-body;
                font-weight: 600;
            }
        }

        .dice-result {
            .roll-damage-button,
            .damage-button,
            .duality-action {
                margin-top: 5px;
            }
        }

        &:not(.expanded) .dice-tooltip {
            grid-template-rows: 0fr;
        }
    } */

    button {
        &.inner-button {
            --button-size: 1.25rem;
            --input-height: 1.25rem;
            padding: 0 0.25rem;
            margin: 5px 1px -4px auto;
            &.inner-button-right {
                margin-left: auto;
            }
        }
    }

    [data-use-perm='false'] {
        pointer-events: none;
        border-color: transparent;
    }
    [data-view-perm='false'] {
        > * {
            display: none;
        }
        &::after {
            content: '??';
        }
    }
}

.daggerheart,
#chat-notifications {
    .chat-message {
        --text-color: light-dark(@dark-blue, @golden);
        --bg-color: light-dark(@dark-blue-40, @golden-40);

        &.duality {
            &.hope {
                --text-color: @golden;
                --bg-color: @golden-40;
                .message-header,
                .message-content {
                    background-color: @golden-bg;
                }
            }

            &.fear {
                --text-color: @chat-blue;
                --bg-color: @chat-blue-40;
                .message-header,
                .message-content {
                    background-color: @chat-blue-bg;
                }
            }

            &.critical {
                --text-color: @chat-purple;
                --bg-color: @chat-purple-40;
                .message-header,
                .message-content {
                    background-color: @chat-purple-bg;
                }
            }
        }

        .chat-roll {
            font-size: var(--font-size-12);
            padding: 0 20px;

            > .roll-part-header {
                font-size: var(--font-size-14);
            }

            .roll-part-header {
                display: grid;
                grid-template-columns: 1fr auto 1fr;
                align-items: center;
                color: light-dark(@dark, @beige);
                margin: 5px 0;

                span {
                    display: flex;
                    align-items: center;
                    gap: 5px;
                    text-transform: capitalize;
                    padding: 0 10px;
                }

                &:before,
                &:after {
                    content: ' ';
                    height: 1px;
                }

                &:before {
                    background: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, var(--text-color) 100%);
                }

                &:after {
                    background: linear-gradient(90deg, var(--text-color) 0%, rgba(0, 0, 0, 0) 100%);
                }
            }

            .roll-part-extra {
                display: flex;
                justify-content: center;
                align-items: center;
                gap: 10px;
                margin-top: 8px;
            }

            .roll-part-content {
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: 5px;
                padding: 5px 0;

                .dice-tooltip {
                    width: 100%;

                    .wrapper {
                        display: flex;
                        flex-direction: column;
                        gap: 10px;

                        > :first-child:not(.target-selector) {
                            margin-top: 5px;
                        }

                        > :last-child {
                            margin-bottom: 5px;
                        }
                    }
                }

                .roll-result-container {
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    gap: 10px;
                    color: var(--text-color);
                    font-weight: 700;
                    font-family: 'Cinzel', sans-serif;

                    .roll-result-value {
                        font-size: var(--font-size-24);
                    }

                    .roll-result-desc {
                        font-size: var(--font-size-16);
                        margin-top: 2px;
                    }
                }

                .roll-difficulty {
                    margin-top: -5px;
                }
            }
        }

        .roll-dice {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 5px;
            font-weight: 700;
            font-family: 'Cinzel', sans-serif;
            flex-wrap: wrap;

            .roll-die {
                display: flex;
                flex-direction: column;
                gap: 3px;

                label {
                    text-align: center;
                    height: var(--font-size-12);
                }

                > div {
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    gap: 5px;
                    // font-size: var(--font-size-20);
                }
            }
        }

        fieldset {
            display: flex;
            flex-direction: column;
            // gap: 10px;
            border-color: var(--text-color);
            border-radius: 5px;

            legend {
                display: flex;
                align-items: center;
                gap: 10px;
                padding: 0 5px;
                color: var(--text-color);
            }
        }

        .target-selector {
            + .roll-part-extra {
                margin: 0;
            }

            .target-choice {
                display: flex;
                font-size: var(--font-size-14);
                color: var(--text-color);
                padding: 5px 0;

                .button-target-selection {
                    flex: 1;
                    text-align: center;
                }

                .button-target-selection:hover,
                .target-selected {
                    font-weight: bold;
                    text-shadow: 0px 0px 8px var(--text-color);
                }
            }
        }

        i {
            text-align: center;
        }

        .roll-target {
            display: flex;
            width: 100%;
            gap: 10px;
            align-items: center;

            .target-img {
                border-radius: 50%;
                width: 40px;
                height: 40px;
                object-fit: cover;
            }

            .target-data {
                flex: 1;
            }

            .target-save {
                display: flex;
                align-items: center;
                justify-content: center;
                width: 22px;
                height: 22px;
                &:hover > i {
                    scale: 1.2;
                }

                i {
                    &.fa-check {
                        color: @green;
                    }
                    &.fa-xmark {
                        color: @medium-red;
                    }
                }
            }
        }

        .roll-formula {
            background-color: var(--bg-color);
            color: var(--text-color);
            border-radius: 4px;
            padding: 3px 5px;
            width: fit-content;
            margin: auto;
        }

        .roll-difficulty,
        .target-hit-status {
            color: @green;
            background-color: @green-10;
            border: 1px solid currentColor;
            border-radius: 4px;
            padding: 3px 5px;
            text-transform: uppercase;
            font-weight: 600;

            &.is-miss {
                color: @medium-red;
                background-color: @medium-red-10;
            }
        }

        .target-hit-status {
            width: fit-content;
            margin-top: 2px;
        }

        div[data-action='expandRoll'] {
            .roll-part-header > div > span {
                &:before,
                &:after {
                    content: '\f078';
                    font-family: var(--font-awesome);
                    color: var(--text-color);
                    transition: all 0.3s ease;
                }
            }

            .on-reduced {
                display: grid;
                overflow: hidden;
                grid-template-rows: 1fr;
                transition: grid-template-rows 250ms ease;

                .wrapper {
                    display: flex;
                    gap: 10px;
                    overflow: hidden;
                }
            }

            &.expanded {
                .roll-part-header > div > span {
                    &:before,
                    &:after {
                        transform: rotate(180deg);
                    }
                }

                .on-reduced {
                    grid-template-rows: 0fr;
                }
            }
        }

        .roll-part + .roll-part {
            margin-top: 0;
        }

        .target-section {
            .roll-part-content {
                gap: 10px;
            }

            .roll-part-extra {
                position: relative;

                .target-pending-saves {
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    height: 25px;
                    width: 25px;
                    &.is-absolute {
                        position: absolute;
                        bottom: 0;
                        right: 0;
                    }
                }
            }
        }

        .roll-buttons {
            display: flex;
            gap: 5px;
            margin-top: 8px;
            button {
                flex: 1;
            }
        }

        .font-20 {
            font-size: var(--font-size-20);
        }

        .dice-roll .dice-tooltip fieldset {
            margin-bottom: 5px;
            .roll-dice {
                gap: 10px;
            }
        }
    }
}
