// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <https://www.gnu.org/licenses/>.

/**
 * Styles files for ludilearn format.
 *
 * @package     format_ludilearn
 * @copyright   2025 Pimenko <support@pimenko.com><pimenko.com>
 * @license     https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
@use 'progress-rocket';
.format-ludilearn {

    .btn {
        min-height: 40px;
        font-weight: bold;
    }

    #pills-tab {
        background: linear-gradient(0deg, rgba(0, 0, 0, 0) 28px, var(--primary), rgba(0, 0, 0, 0) 32px);
        height: 60px;
        line-height: 60px;

        .nav-item {
            flex: none;
        }
    }

    .ludilearn-content {
        border: none;
        max-width: 830px;
        margin: 15px auto auto;

        .card-header {
            background: transparent;
        }
    }

    .scoretext {
        font-size: 1em;
        font-weight: 500;
        color: #5c5854;

        .playerscore {
            color: var(--primary);
            filter: brightness(75%);
            font-size: 1.5em;
        }
    }

    .cmname,
    .sectionname {
        color: black;
    }

    .bonuscompletion,
    .penalties {
        position: absolute;
        top: 0;
        right: 0;
        border-radius: 5px;
        background: #fff;
        color: orange;
        font-weight: 500;
        padding: 3px 6px;
        box-shadow: 4px -4px orange;
        width: 50%;

        &.bonuscompletion-cm,
        &.penalties-cm {
            position: relative;
            width: 100%;
            max-width: 200px;
            margin: auto;
            box-shadow: 4px 4px orange;
        }

        span.bonuscompletion-value,
        span.penalties-value {
            display: block;
            text-align: center;
            font-size: 1em;
            line-height: 1em;
        }
        span.bonuscompletion-str,
        span.penalties-str {
            /* width: 60%; */
            display: block;
            text-align: center;
            font-size: 0.8em;
            line-height: 0.8em;
        }
    }

    .badgecompletion {
        position: absolute;
        top: -10px;
        right: 5px;
        padding: 3px 6px;
        width: 50px;

        img {
            width: 100%;
        }

        &.badgecompletion-cm {
            width: 75px;
            margin: auto;
            left: 50%;
            right: unset;
            top: -65px;
        }
    }

    .ranking-text {
        font-size: 1.2rem;
        margin-top: -60px;
    }

    .rightdottedscore {
        border-right: var(--primary) 5px dotted;

        &.rightdottedscore-notsm {
            @media (max-width: 576px) {
                border-right: none;
            }
        }
    }

    .bottomdotted {
        border-bottom: var(--primary) 5px dotted;
    }

    .rightlined {
        border-right: var(--primary) 2px solid;
        border-color: grey;
    }

    a {
        &:hover {
            text-decoration: none;
        }

        &.restricted.nourl {
            pointer-events: none;
            cursor: default;
        }
    }

    .ludilearn-img,
    #pills-activity .ludilearn-img {
        height: 160px;

        &.little-img {
            height: 55px;
        }
    }

    .img-timer {
        margin-top: 32px;
    }

    #pills-activity .scoretext {
        font-size: 1.5em;
    }

    .restricted {
        filter: grayscale(1);
    }

    .maxseriesquare {
        padding: 0;
        margin-top: 10%;
    }
    .notreached {
        opacity: 0.5;
        filter: grayscale(1);
    }

    .block_section {
        height: 180px;
        display: flex;
        align-items: center;
        justify-content: center;

        &.block_section_avatar {
            align-items: end;
        }

        .progression {
            font-size: 48px;
            font-weight: 900;
            color: #f8b334;
        }
    }

    .badge-number {
        position: relative;
        width: 30px;
        height: 30px;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        margin: auto auto 0.25rem;
        border: 2px solid #ddd;
        color: #ddd;

        &.badge-number-bronze {
            color: #fff;
            background: linear-gradient(135deg, #cd7f32, #eee, #cd7f32, #eee, #cd7f32);
            border: 1px solid #cd7f32;
            font-weight: 900;
        }
        &.badge-number-silver {
            color: #fff;
            background: linear-gradient(135deg, #c0c0c0, #eee, #c0c0c0, #eee, #c0c0c0);
            border: 1px solid #c0c0c0;
            font-weight: 900;
        }
        &.badge-number-gold {
            color: #fff;
            background: linear-gradient(135deg, #ffd700, #eee, #ffd700, #eee, #ffd700);
            border: 1px solid #ffd700;
            font-weight: 900;
        }

        &.spinning {
            animation: spinY 2s linear infinite;
        }
    }

    @keyframes spinY {
        0% {
            transform: rotateY(0deg);
        }
        100% {
            transform: rotateY(360deg);
        }
    }

    .progress-image,
    .avatar-image {
        position: relative;
        background-repeat: no-repeat;
        overflow: hidden;
        background-position: center;
        width: 100%;
        height: 0;
        padding-bottom: 100%;
        background-size: cover;

        .progression-steps-component,
        .avatar-slot,
        .avatar-character {
            position: absolute;
            top: 0;
            left: 0;
            max-width: 100%;
            max-height: 100%;
        }
    }

    .avatar-bag {
        display: block;
        max-width: 75px;
        margin: auto;
        cursor: pointer;

        &.avatar-bag-open {
            display: none;
        }
    }
    .modal-dialog {
        max-width: 830px;
        .avatar-inventory {

            .tab-content-inventory {
                display: none;

                &.active {
                    display: block;
                }

                .avatar-slot {
                    display: flex;
                    flex-wrap: nowrap;
                    flex-direction: row;

                    .alert {
                        color: white;
                        padding: 0;
                    }

                    .avatar-item {
                        margin: 10px;
                        text-align: center;
                        cursor: pointer;
                        transition: transform 0.2s;
                        outline: none;
                        max-width: 100px;
                        flex: auto;

                        .avatar-item-img {
                            width: 100px;
                        }

                        &.avatar-item-owned {
                            cursor: pointer;

                            &:hover,
                            &:focus {
                                transform: scale(1.1);
                                border: 2px solid #007bff;
                                border-radius: 10px;
                            }

                            &.selected {
                                border: 2px solid #007bff;
                                padding: 10px;
                                border-radius: 10px;
                            }
                        }

                        .alert-equiped {
                            display: none;
                        }

                        &.avatar-item-equiped {
                            border: 2px solid green;
                            padding: 10px;
                            border-radius: 10px;

                            .alert-equiped {
                                display: block;
                            }
                        }
                    }

                    .equip-button {
                        display: none;
                        margin-top: 10px;
                        padding: 5px 10px;
                        background: green;
                        color: white;
                        border: none;
                        cursor: pointer;
                        border-radius: 5px;
                        transition: background 0.3s;
                        outline: none;

                        &:focus,
                        &:hover {
                            background: darkgreen;
                        }
                    }
                    .alert {
                        margin-top: 10px;
                    }

                    .sr-only {
                        position: absolute;
                        width: 1px;
                        height: 1px;
                        padding: 0;
                        margin: -1px;
                        overflow: hidden;
                        clip: rect(0, 0, 0, 0);
                        border: 0;
                    }
                }
            }

            .tabs {
                display: flex;
                justify-content: space-around;
                margin-bottom: 20px;

                .tab-inventory {
                    padding: 10px 20px;
                    background: #f0f0f0;
                    border: 1px solid orange;
                    border-radius: 2px;
                    cursor: pointer;
                    transition: background 0.3s;
                    outline: none;
                    width: 100%;

                    &:focus,
                    &:hover,
                    &.active {
                        background: orange;
                        color: white;
                    }
                }
            }
        }
    }

    .count-items {
        width: 100%;
        height: 100%;
        display: inline-block;
        position: relative;

        .numerator {
            color: #f7b53c;
            font-size: 48px;
            font-weight: bold;
            position: absolute;
            bottom: 9px;
            left: 0;

            &.two-digits {
                left: -24px;
            }
        }

        .fraction {
            color: #c9beb6;
            font-size: 32px;
            position: absolute;
            left: 32px;
            bottom: 12px;
        }

        .denumerator {
            color: #c9beb6;
            font-size: 32px;
            font-weight: bold;
            position: absolute;
            bottom: 0;
            left: 43px;
        }
    }

    .progression-text {
        width: fit-content;
        border-radius: 8px;
        background-color: #f8b334;
        font-size: 30px;
        font-weight: 900;
        color: #fff;
        margin: auto;
        padding-left: 15px;
        padding-right: 15px;

        &.progression-cm {
            font-size: 20px;
            padding-left: 10px;
            padding-right: 10px;
            p {
                margin-bottom: 0.2rem;
            }
        }
    }

    .progression-bar-component {
        &.rocket {
            position: absolute;
            width: 1200px;
            height: 1200px;
            max-width: unset;
            max-height: unset;
            left: 10%;
            top: 10%;
            animation: percentrocket 0.5333s infinite step-end;
        }
    }

    .circle-progression.biggest {
        float: none;
        margin: auto;
        font-size: 300px;

        span.show {
            max-width: 300px;
            max-height: 300px;
        }

        &::after {
            top: 0.15em;
            left: 0.15em;
            width: 0.7em;
            height: 0.7em;
        }
    }

    .ranking-group-view {
        margin: auto;
        width: 100%;
    }

    .chrono {
        img {
            width: 100%;
            max-width: 80px;
        }
        .current-time {
            font-size: 2rem;
            vertical-align: middle;
        }
    }

    .reference-time {
        font-size: 1.2rem;
        span {
            vertical-align: middle;
        }
    }
    .ranking-summary {
        margin: auto;
        width: 100%;
    }
    .ranking-table {
        td,
        tr {
            border-top: none;
        }
    }
    .ludilearn-world-school {
        @keyframes percentrocket {
            0% {
                left: 10%;
                top: 10%;
            }
            7.1% {
                left: calc(10% - 100%);
                top: 10%;
            }
            14.2% {
                left: calc(10% - 200%);
                top: 10%;
            }
            21.3% {
                left: calc(10% - 300%);
                top: 10%;
            }
            28.4% {
                left: 10%;
                top: calc(10% - 100%);
            }
            35.5% {
                left: calc(10% - 100%);
                top: calc(10% - 100%);
            }
            42.6% {
                left: calc(10% - 200%);
                top: calc(10% - 100%);
            }
            200% {
                left: calc(10% - 300%);
                top: calc(10% - 100%);
            }
            57.1% {
                left: calc(10% - 100%);
                top: calc(10% - 200%);
            }
            64.2% {
                left: calc(10% - 200%);
                top: calc(10% - 200%);
            }
            71.3% {
                left: calc(10% - 300%);
                top: calc(10% - 200%);
            }
            78.4% {
                left: 10%;
                top: calc(10% - 300%);
            }
            85.5% {
                left: calc(10% - 100%);
                top: calc(10% - 300%);
            }
            92.6% {
                left: calc(10% - 200%);
                top: calc(10% - 300%);
            }
            100% {
                left: calc(10% - 300%);
                top: calc(10% - 300%);
            }
        }
    }

    .ludilearn-world-professional {
        // Avatar image.
        .avatar-image {
            background-size: contain;
        }
        .avatar-slot,
        .avatar-character {
            top: 12%;
        }

        // Ranking.
        .ranking-summary {
            display: block;
            max-height: 160px;
            margin-left: auto;
            margin-right: auto;
        }

        // Rocket animation for professional world.
        .section-progress {
            .asteroids {
                display: none;
            }
        }
        .circle-progression.biggest span.show {
            max-width: 210px;
            max-height: 210px;
            left: 45px;
            top: 45px;
        }
        .progression-bar-component.rocket {
            position: absolute;
            width: 1200px;
            height: 210px;
            max-width: unset;
            max-height: unset;
            left: 0;
            top: 0;
            animation: percentrocketprofessional 0.345s infinite step-end;
        }
        @keyframes percentrocketprofessional {
            0% {
                left: -75px;
            }
            25% {
                left: calc(-75px - 100%);
            }
            50% {
                left: calc(-75px - 200%);
            }
            75% {
                left: calc(-75px - 300%);
            }
            100% {
                left: calc(-75px - 400%);
            }
        }
    }

    // Style only for the world highschool.
    .ludilearn-world-highschool {
        // Avatar.
        .avatar-image {
            &:has(.item-equiped) {
                .avatar-character {
                    display: none;
                }
            }
            .avatar-slot,
            .avatar-character {
                width: 100%;
            }
        }

        // Ranking.
        .ranking-summary {
            display: block;
            max-height: 175px;
            margin-left: auto;
            margin-right: auto;
            margin-top: -15px;
        }

        // Progression game element.
        .progression-planet-inprogress {
            background-image: url('[[pix:format_ludilearn|highschool/progress/course-planet-bg]]');
            background-size: contain;
        }
        .progression-planet-max {
            background-image: url('[[pix:format_ludilearn|highschool/progress/course-planet-max-bg]]');
            background-size: contain;
        }

        // Hide asteroid image because not exist in highschool world.
        .section-progress {
            .asteroids {
                display: none;
            }
        }

        // Disable animation for the rocket because not exist in highschool world.
        .c100 > span {
            line-height: 0;
        }
        .progression-bar-component.rocket {
            position: relative;
            width: auto;
            height: auto;
            max-width: unset;
            max-height: unset;
            left: 0;
            top: 0;
            animation: none;
        }
    }

    li.explanation-li {
        height: 50px;
        margin-top: auto;
        margin-bottom: auto;
        .explanation-button {
            width: 50px;
            height: 50px;
            padding: 10px;
            background: var(--primary);
            border-radius: 50%;

            .explanation {
                vertical-align: top;
            }
        }
    }

    /* Largeur d'écran inférieure à 600px. */
    @media screen and (max-width: 600px) {
        table.ranking-table {
            tr,
            td {
                padding-left: 0;
                padding-right: 0;
            }
        }
    }

    /* Settings pages */
    #ludilearn-settings {
        .editsettingssuccess,
        .editsettingsfailed {
            display: none;
        }

        .setting-footer {
            margin-top: 5em;
        }
    }
    /* Questionnaire styles */
    #ludilearn-questionnaire {
        max-width: 800px;
        margin: 0 auto;
        padding: 20px;

        .card {
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            border: 1px solid #dee2e6;
            margin-bottom: 1rem;

            &:hover {
                transform: translateY(-5px);
                box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            }

            &:focus-within {
                box-shadow: 0 0 0 2px var(--primary);
            }
        }

        .hexad-illustration {
            display: block;
            width: 150px;
            margin-left: auto;
            margin-right: auto;
            margin-bottom: 1rem;
        }

        #questionnaire-instructions {
            background-color: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 0.75rem;
            padding: 1.5rem;
            margin-bottom: 2rem;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        }

        .question-text {
            display: block;
            padding: 15px;
            background-color: #f8f9fa;
            border-radius: 0.25rem;
            border-left: 4px solid var(--primary);
            margin-bottom: 1rem;
            color: #1d2125;
        }

        .rating-scale {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin: 1rem 0;
        }

        .rating-option {
            text-align: center;

            input[type="radio"] {
                position: absolute;
                opacity: 0;

                &:focus + .rating-label {
                    outline: 2px solid var(--primary);
                    outline-offset: 2px;
                    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary);
                }

                &:focus:not(:focus-visible) + .rating-label {
                    outline: none;
                    box-shadow: none;
                }

                &:checked + .rating-label {
                    background-color: var(--primary);
                    color: #fff;
                    border-color: var(--primary);
                }
            }

            .rating-label {
                display: flex;
                align-items: center;
                justify-content: center;
                width: 40px;
                height: 40px;
                border-radius: 50%;
                border: 2px solid #dee2e6;
                cursor: pointer;
                transition: all 0.2s ease;
                font-weight: 500;
                margin: 0 5px;
                color: #495057;

                &:hover {
                    border-color: var(--primary);
                    background-color: #f8f9fa;
                }

                &:focus-visible {
                    outline: 2px solid var(--primary);
                    outline-offset: 2px;
                    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary);
                }
            }
        }

        .btn-primary {
            width: 100%;
            padding: 0.75rem;
            font-weight: 500;
            margin-top: 1rem;

            &:focus {
                outline: 2px solid var(--primary);
                box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.5);
            }

            &:focus:not(:focus-visible) {
                outline: none;
                box-shadow: none;
            }
        }

        .invalid-feedback {
            display: none;
            color: #dc3545;
            margin-top: 0.25rem;
            font-size: 1rem;

            &.show {
                display: block;
            }
        }
    }

    /* Hexad Results Styles */
    .hexad-results {
        background-color: #f8f9fa;
        padding: 2rem;
        border-radius: 0.5rem;
        margin-top: 2rem;

        .hexad-title {
            font-size: 1.5rem;
            font-weight: bold;
            margin-bottom: 1.5rem;
            color: #1d2125;
        }

        .hexad-scores-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 1.5rem;
        }

        .score-item {
            background-color: #fff;
            padding: 1.25rem;
            border-radius: 0.5rem;
            border: 1px solid #e9ecef;
            transition: transform 0.2s ease;

            &:hover {
                transform: translateY(-2px);
                box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            }

            .score-header {
                display: flex;
                justify-content: space-between;
                align-items: center;
                margin-bottom: 0.75rem;
                padding-bottom: 0.75rem;
                border-bottom: 1px solid #e9ecef;

                strong {
                    font-size: 1.125rem;
                    color: #1d2125;
                }
            }

            .score-value {
                font-size: 1.5rem;
                font-weight: bold;
                color: var(--primary);
            }

            .score-description {
                color: #495057;
                font-size: 0.95rem;
                line-height: 1.5;
            }
        }
    }

    /* Media Queries */
    @media (max-width: 768px) {
        .hexad-scores-grid {
            grid-template-columns: 1fr;
        }

        .hexad-results {
            padding: 1rem;

            .score-item {
                padding: 1rem;
            }
        }

        #ludilearn-questionnaire {
            .rating-option {
                .rating-label {
                    width: 35px;
                    height: 35px;
                    font-size: 0.75rem;
                }
            }

            .scale-labels {
                font-size: 0.75rem;
            }
        }
    }
}

