@import "./ui.css";

:root {
    --color-blue: #2d9dc9;
    --color-blue-soft: rgb(45, 157, 201, 0.2);
    --color-white: #ffffff;
    --color-offwhite: #f4f0ea;
    --color-offwhite-darker: #dbd7d2;
    --color-darkblue: #00304b;
    --color-beige: #a99b95;
    --color-page-title: #0000002b;
    --color-orange: #f2a74d;
    --color-orange-soft: rgb(242, 167, 77, 0.2);
    --color-red: #e54271;
    --color-red-soft: rgb(229, 66, 113, 0.2);
    --color-green: #209666;
    --color-green-soft: rgb(32, 150, 102, 0.2);
    --color-darkgray: #202020;
    --color-black: #000000;
    --color-bg: var(--color-offwhite);
    --color-bg-alt: var(--color-offwhite-darker);
    --translate-button-color: var(--color-blue);
    --translate-icon-color: var(--color-blue);
    --transition-duration: 0.3s;
    --color-primary-000: var(--color-darkgray);
    --color-primary-100: var(--color-offwhite);
    --color-primary-200: var(--color-white);
    --color-primary-300: var(--color-darkblue);
    --color-primary-400: var(--color-beige);
    --color-accent-100: var(--color-orange);
    --color-accent-200: var(--color-red);
    --color-accent-300: var(--color-blue);
    --color-accent-400: var(--color-green);

    --color-pastel-primary-000: rgba(43, 58, 51, 0.1);
    --color-pastel-accent-100: rgba(255, 211, 53, 0.1);
    --color-pastel-accent-200: rgba(229, 66, 113, 0.1);
    --color-pastel-accent-300: rgba(45, 157, 201, 0.1);
    --color-pastel-accent-400: rgba(32, 150, 102, 0.1);
    --color-text-000: var(--color-darkgray);
    --color-text-100: #aaaaaa;
    --color-text-200: var(--color-white);

    --accent-color: var(--color-blue);
    --gutter-mini: 5px;
    --gutter-tiny: 10px;
    --gutter-smaller: 15px;
    --gutter-small: 20px;
    --gutter: 40px;
    --gutter-large: 80px;
    --font-titles: "InterVariable", sans-serif;
    --font-body: "InterVariable", sans-serif;
    --font-weight-normal: 400;
    --font-weight-bold: 800;
    --radius-small: 8px;
    --radius-large: 20px;
    --radius-larger: 30px;
    --border-size: 2px;
    --border-size-large: 5px;
    --color-border: rgba(0, 0, 0, 0.1);
    --color-border-100: #ffffff;
    --color-border-accent-100: var(--color-darkgray);
    --color-border-accent-200: #d4e6df;
    --button-background: var(--color-bg);

    --button-background-hover: white;
    --color-shadow: rgba(0, 0, 0, 0.5);
    --color-shadow-light: rgba(0, 0, 0, 0.2);
    --skeleton-shine: 0.5;
    --color-global-progress-bar: var(--color-accent-300);
    --nav-drawer-width: 300px;
    --breakpoint-mini: 0;
    --breakpoint-tiny: 576px;
    --breakpoint-small: 768px;
    --breakpoint-normal: 992px;
    --color-panel: var(--color-offwhite);
    --button-face: var(--color-blue);
    --button-color: var(--color-white);
    --color-background: var(--color-offwhite);
    --color-panel: white;
    --color-mask-trans: rgba(100, 100, 100, 0.4);
    --color-mask-trans-alt: rgba(200, 200, 200, 0.4);
    --color-text: var(--color-text-000);
    --color-widget-border: white;
    --side-bg-default: #e7e3de;
    --side-bg: var(--side-bg-default);
}

:root.dark {
    --color-bg: #303030;
    --color-bg-alt: #5a5a5a;
    --form-face: var(--color-darkgray);
    --button-face: var(--color-orange);
    --button-color: var(--color-black);
    --color-panel: var(--color-darkgray);
    --color-background: var(--color-darkgray);
    --color-page-title: rgba(255, 255, 255, 0.4);
    --color-text: #f2f2f2;
    --color-primary-000: var(--color-text);
    --color-primary-200: var(--color-bg);
    --color-panel: #363636;
    --brightness-filter: brightness(80%);
    --color-mask-trans: rgba(255, 255, 255, 0.1);
    --color-mask-trans-alt: rgba(255, 255, 255, 0.4);
    --color-widget-border: var(--color-mask-trans-alt);
    --side-bg-default: #444;
    --side-bg: var(--side-bg-default);
}

@layer reset {
    *,
    *::before,
    *::after {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }

    html,
    body {
        height: 100%;
        width: 100%;
        font-family: -apple-system, "Segoe UI", BlinkMacSystemFont, sans-serif;
        line-height: 1.5;
        background-color: var(--color-background);
        color: var(--color-text);
    }

    img,
    picture,
    video,
    canvas,
    svg {
        display: block;
        max-width: 100%;
    }

    input,
    button,
    textarea,
    select {
        font: inherit;
    }

    a {
        text-decoration: none;
        font-weight: bold;
        color: inherit;

        &:hover {
            color: var(--color-accent);
        }
    }

    aside {
        a{
            font-weight: unset;
        }
    }

    ul,
    ol {
        list-style: none;
    }

    table {
        border-collapse: collapse;
        border-spacing: 0;
    }

    img {
        filter: var(--brightness-filter);
    }
}

body {
    caret-color: var(--color-red);
    background-color: var(--color-bg);

    ::placeholder {
        color: rgba(127, 127, 127, 0.6) !important;
    }

    ::selection {
        background: var(--color-accent-200);
        color: white;
    }
}

html {
    scroll-behavior: smooth;
}

html,
body {
    height: 100%;
    width: 100%;
    font-family: var(--font-body);
    line-height: 1.4;
    font-size: 16px;
    overflow-y: auto;
}

h1 {
    text-transform: uppercase;
    text-align: left;
    font-size: 18px;
    font-weight: 800;
    color: var(--color-page-title);
    letter-spacing: 0.1rem;
    margin-top: -5px;
    margin-bottom: 5px;
    letter-spacing: 0.3rem;
}

p {
    margin: 0 0 var(--gutter-small) 0;

    &:empty {
        display: none;
    }
}

/* TODO: Remove these classes when flex-container will be replaced */
.flex {
    gap: 1rem;
    display: flex;
    align-items: flex-start;
    flex-direction: row;

    &.spread {
        justify-content: space-between;
    }

    &.wrap {
        flex-wrap: wrap;
    }

    &.horizontal {
        flex-direction: row;
    }

    &.vertical {
        flex-direction: column;
    }

    &.middle {
        align-items: center;
    }

    &.right {
        flex-direction: row-reverse;
    }
}

app-ui {
    display: block;
    padding: 10px;
    margin: auto;
    max-width: 900px; /* general setting */
}

@layer form {
    form {
        display: block;
        background-color: var(--color-panel);
        padding: var(--gutter-small);
        border-radius: var(--radius-large);
    }

    form:has(ui-widget) {
        background-color: transparent;
        display: unset !important;
    }

    [readonly] {
        cursor: not-allowed;
    }

    fieldset {
        border: none;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    ui-widget {
        fieldset:last-child {
            margin-bottom: 0;
        }

        nav {
            margin-top: 1rem;
        }

        video {
            margin: auto;
        }
    }
    /*
    label:has(span[data-label]) {
        position: relative;

        span[data-label] {
            display: block;
            position: absolute;
            top: 10px;
            left: 10px;
            transition: top 0.1s cubic-bezier(0.42, 0, 0.51, 0.56);
        }

        input::placeholder {
            opacity: 0;
        }

        &:focus-within,
        &:has(input:not(:placeholder-shown)) {
            span[data-label] {
                top: -11px;
                font-size: 12px;
                transition: top 0.1s cubic-bezier(0.42, 0, 0.51, 0.56);
                background-color: var(--color-panel);
                padding-left: 2px;
                padding-right: 2px;
            }

            input::placeholder {
                opacity: 1;
            }
        }
    } */

    legend {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }

    button,
    textarea,
    input[type] {
        outline: none;
        padding: 0.6rem 1.2rem;
        border-radius: 1rem;
        background-color: transparent;
        border: 2px solid var(--color-mask-trans);

        &.filled {
            background-color: var(--button-face);
        }

        &:focus {
            border-color: var(--color-blue) !important;
        }
    }

    textarea {
        resize: vertical;
    }

    button,
    .button {
        user-select: none;
    }
}

@layer containers {
    nav.list {
        > * {
            display: grid;
            padding: 1rem;
            grid-template-columns: 200px 1fr;
            background-color: var(--color-panel);
            margin-bottom: var(--gutter-small);
            border-radius: 1rem;
            transition: all 0.3s cubic-bezier(0.455, 0.03, 0.515, 0.955);

            &:hover {
                color: unset;
                transform: scale(1.02);
                transition: all 0.3s cubic-bezier(0.455, 0.03, 0.515, 0.955);
            }

            [data-details] {
                display: flex;
                flex-direction: column;
            }

            [data-badges] {
                display: flex;
                flex-direction: row;
                gap: 0.5rem;
            }
        }

        img {
            max-height: 140px;
            border-radius: 0.6rem;
        }
    }

    article[data-id] {
        img {
            border-radius: 0.6rem;
        }
    }

    .masonry {
        display: block;
        columns: 260px;
        column-gap: 1rem;
        row-gap: 1rem;
        margin-top: 1rem;
    }
}

@layer view-transitions {
    @keyframes zoom-in {
        from {
            transform: scale(0.5);
            opacity: 0.5;
        }

        to {
            transform: scale(1);
            opacity: 1;
        }
    }

    @keyframes zoom-out {
        from {
            transform: scale(1);
            opacity: 1;
        }

        to {
            transform: scale(0.5);
            opacity: 0.5;
        }
    }

    ::view-transition-old(*) {
        animation: zoom-out 0.2s ease-out;
    }

    ::view-transition-new(*) {
        animation: zoom-in 0.2s ease-out;
    }
}

@media only screen and (min-width: 900px) {
    .masonry {
        columns: 360px;

        > * {
            min-height: 300px;
        }
    }
}

@layer dialogs {
    /* Animation */
    @keyframes dialogAppear {
        from {
            opacity: 0;
            transform: translate(-50%, -55%) scale(0.9);
        }

        to {
            opacity: 1;
            transform: translate(-50%, -50%) scale(1);
        }
    }

    @keyframes dialogDisappear {
        from {
            opacity: 1;
            transform: translate(-50%, -50%) scale(1);
        }

        to {
            opacity: 0;
            transform: translate(-50%, -55%) scale(0.9);
        }
    }

    dialog {
        opacity: 0;
        position: fixed;
        padding: 0;
        border: none;
        outline: none;
        background-color: transparent;
        overflow: visible;

        &&::backdrop {
            background-color: rgba(0, 0, 0, 0.3);
            backdrop-filter: blur(5px);
        }

        h1 {
            margin-top: 2rem;
            margin-bottom: 1.5rem;
            font-size: 1.5rem;
        }

        h2 {
            margin-top: 1.5rem;
            margin-bottom: 1.2rem;
            font-size: 1.3rem;
        }

        h3 {
            margin-top: 1.3rem;
            margin-bottom: 1rem;
            font-size: 1.1rem;
        }

        hr {
            margin: 2rem;
        }

        img {
            max-width: 90%;
        }

        &.large {
            width: 600px;
            min-height: 500px;
        }

        form:not(.no-padding) > div {
            margin-bottom: 1.5rem;
        }

        form.no-padding {
            padding-top: 0;
            padding-left: 0;
            padding-right: 0;

            .jc-end {
                padding-right: 1rem !important;
            }
        }

        &.bottom {
            top: unset;
            bottom: -230px;
            left: 50%;
            transform: translateX(-50%);
        }

        &.center {
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: left !important;
        }
    }

    #msg-container {
        overflow-y: auto;
        max-height: 65vh;
    }

    blockquote {
        margin: 1rem;
        padding-left: 1rem;
        border-left: 6px solid var(--color-blue);
    }

    p {
        margin-bottom: 1rem;
    }

    ul {
        list-style: circle;
    }

    ol {
        list-style: decimal;
    }

    ol,
    ul {
        li {
            margin-left: 2rem;
        }
    }

    @media all and (max-width: 600px) {
        dialog {
            width: 100%;
        }
    }
}

@layer waiting {
    @keyframes progress {
        50% {
            left: 0;
        }

        100% {
            left: 100vw;
        }
    }

    html {
        body::before {
            content: "";
            position: fixed;
            top: 0;
            left: -100vw;
            width: 100vw;
            height: 6px;
            background-color: var(--color-accent-300);
            z-index: 999;
        }

        &.busy {
            body {
                overflow-x: hidden;

                &::before {
                    animation: progress 1s linear infinite;
                }
            }
        }
    }
}

@media only screen and (min-width: 601px) {
    h1 {
        font-size: 32px;
    }

    [data-menu-appearance="minimal"] {
        app-ui {
            padding-left: 80px;
        }
    }

    [data-menu-appearance="full"] {
        app-ui {
            padding-left: 270px;
            transition: padding-left 0.2s ease-in-out;
            will-change: padding-left;
        }
    }
}

#watermark {
    --icon-fill-color: rgba(0, 0, 0, 0.02);
    --icon-size: 70vmax;
    pointer-events: none;
}

.abs-middle {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

html {
    #watermark {
        --icon-size: 70vh;
    }

    &.vw-landscape {
        #watermark {
            --icon-size: 70vw;
        }
    }
}

@layer functional {
    html:not(.is-mobile) {
        .if-mobile {
            display: none;
        }
    }

    html.is-mobile {
        .if-not-mobile {
            display: none;
        }
    }
}

/* glossary */

dfn {
    border-bottom: 2px dotted var(--color-accent-300);
    cursor: help;
    position: relative;
}

.environment {
    position: fixed;
    font-size: 8px;
    right: 5px;
    padding: 2px 5px;
    min-height: unset;
    line-height: 0.8rem;
    top: 52px;
    z-index: 9999;
    transform: rotate(90deg);
    transform-origin: bottom;
}

.pull-to-refresh {
    z-index: 9999;
    width: 100%;
    padding: 0;

    display: flex;
    justify-content: center;
    align-items: center;
    transition: all var(--transition-duration) ease-in-out;
    visibility: hidden;
    height: 0;

    &.visible {
        visibility: visible;
        padding: var(--gutter-small) 0;
        height: 60px;
    }
}

.round {
    aspect-ratio: 1/1;
}

#global-close {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

[data-flow-ui-type="full-page"] {
    global-menu {
        position: fixed;
        left: -9000px;
    }

    app-ui {
        padding-left: 20px !important;
        margin: auto;
    }

    #global-close {
        display: block;
    }
}

/* ACCESSIBILITY */
radio-group {
    .radio-group {
        flex-wrap: wrap;
    }
    &.horizontal {
        flex-wrap: wrap;
        justify-content: center;
        margin: 0;
    }

    label {
        cursor: pointer;
        span {
            line-height: 1.1rem;
            background: var(--color-primary-100);
            appearance: none;
            -webkit-appearance: none;
            border-radius: 100px;
            font-family: var(--font-body);
            font-weight: 400;
            font-size: 1rem;
            width: 100%;
            color: var(--color-primary-000);
            opacity: 1;
            margin: 0;
            display: inline-flex;
            align-items: center;
            justify-content: flex-start;

            &::before {
                aspect-ratio: 1/1 !important;
            }
        }
    }

    input[type="radio"] {
        display: block !important;
        position: absolute;
        opacity: 0;

        &:checked + span {
            background: var(--color-accent-300);
            color: var(--color-primary-200);
        }
    }
    input:focus + span {
        outline: 1px dotted #ccc;
    }
}

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--tile-width, 198px), 1fr));
    gap: 0.5rem;

    > * {
        display: block;

        &:is(a) {
            text-decoration: none;
            color: inherit;
        }

        > .card {
            height: 200px;
        }
    }
}

.center-page {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

hr {
    &[data-content] {
        min-width: 200px;
        font-size: large;
        position: relative;
        margin-top: 0;
        margin-bottom: var(--gutter-small);
        outline: 0;
        border: 0;
        color: var(--color-text-000);
        text-align: center;
        opacity: 0.8;
        width: 100%;

        &:before {
            content: "";
            background: linear-gradient(to right, transparent, #818078, transparent);
            position: absolute;
            left: 0;
            top: 50%;
            width: 100%;
            height: 1px;
            min-width: 200px;
        }

        &:after {
            content: attr(data-content);
            position: relative;
            display: inline-block;
            padding: 0 0.5em;
            line-height: 1.5em;
            color: #818078;
            background-color: #fcfcfa;
        }
    }
}

.badges {
    margin-top: 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

dl {
    display: grid;
    grid-template-columns: 150px 1fr;

    dt {
        font-weight: bold;
        text-align: right;
        overflow: hidden;
        white-space: pre;
        text-overflow: ellipsis;
        color: var(--color-primary-000, currentColor);

        &:after {
            content: ": ";
        }
    }

    dd {
        font-weight: 600;
    }
}

#feedback {
    position: fixed;
    bottom: 160px;
    font-weight: 200;
    right: 10px;
    padding: 0;
    border-radius: var(--radius-small, 0.5rem);
    transform: rotate(-90deg);
    transform-origin: 100%;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    padding: 0;
    width: 85px;
    height: 30px;
    transition: all 0.2s ease-in-out;
    z-index: 100;

    &:hover {
        color: var(--color-accent);
        filter: unset;
    }

    &.highlighted{
        animation: highlight 0.5s ease-in-out infinite alternate;
    }
}

@keyframes highlight {
    from {
        transform: scale(1.05) rotate(-90deg);
    }
    to {
        transform: scale(1) rotate(0deg);
    }
}


[data-truncate] {
    overflow: scroll;
    text-overflow: ellipsis;
    max-height: 3.5em; /* Adjust based on line-height */
    line-height: 1.75; /* Ensure line height matches max-height calculation */
}

radio-group {
    .radio-group {
        flex-wrap: wrap;
    }
    &.horizontal {
        flex-wrap: wrap;
        justify-content: center;
        margin: 0;
    }

    label {
        cursor: pointer;
        span {
            line-height: 1.1rem;
            background: var(--color-primary-100);
            appearance: none;
            -webkit-appearance: none;
            border-radius: 100px;
            font-family: var(--font-body);
            font-weight: 400;
            font-size: 1rem;
            width: 100%;
            color: var(--color-primary-000);
            opacity: 1;
            margin: 0;
            display: inline-flex;
            align-items: center;
            justify-content: flex-start;

            &::before {
                aspect-ratio: 1/1 !important;
            }
        }
    }

    input[type="radio"] {
        display: block !important;
        position: absolute;
        opacity: 0;

        &:checked + span {
            background: var(--color-accent-300);
            color: var(--color-primary-200);
        }
    }
    input:focus + span {
        outline: 1px dotted #ccc;
    }
}

[data-flow-ui-type="full-page"] {
    global-menu {
        display: none;
    }
}

@media all and (max-width: 600px) {
    .hide-on-mobile {
        display: none;
    }
    .wide-on-mobile {
        label {
            width: 100% !important;
        }
    }

    [data-flow-ui-type="full-page"] {
        app-ui {
            padding-left: 0px !important;
        }
    }

    label:has(input.variant2[type="radio"]) {
        margin: 0;
        span {
            padding: 8px 10px;
        }
    }
}

* {
    -webkit-tap-highlight-color: transparent;
}

.ac-suggestion {
    --accent-color: #ddd;

    .ac-itm {
        padding: 0.2rem 0.5rem;

        img {
            border-radius: 50%;
        }
    }
}

.invisible {
    visibility: hidden;
}

.listening {
    .speech-enabled {
        background-color: var(--color-primary-100) !important;
    }
    .enable-speech {
        background-color: var(--color-red) !important;

        svg-icon {
            --icon-fill-color: white;
        }
    }
}

.clamp-text {
    display: -webkit-box;
    line-clamp: 3;
    -webkit-line-clamp: 3; /* Limit to 3 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.3s ease;
}

.clamp-text.expanded {
    line-clamp: unset;
    -webkit-line-clamp: unset;
    overflow: visible;
    display: block;
}

.toggle-link {
    font-size: small;
    color: var(--color-blue) !important;
    margin-bottom: 0.5rem;
    margin-top: 0.5rem;
    display: block;
    text-align: right;
}

article.quiz {
    button.primary {
        background-color: transparent;
        border-color: var(--color-blue);
        color: var(--color-blue);
    }
}

post-entry nav {
    opacity: 1;
}

html:not(.is-mobile) {
    .hover {
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    article:has(.hover) {
        &:hover {
            .hover {
                opacity: 1;
            }
        }
    }
}

@keyframes zoom {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#add-nav {
    display: block;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease-in-out;
    position: absolute;
    bottom: 70px;
    right: 0px;

    > a {
        margin-bottom: 0.4rem;
        animation: zoom 0.5s ease;
        display: flex;
        aspect-ratio: 1/1;
        padding: 0.5rem;
        border-radius: 100%;
        box-shadow: 1px 1px 10px rgba(127, 127, 127, 0.6);

        cursor: pointer;

        svg-icon {
            --icon-size: 16px;
            --icon-fill-color: white;
        }

        &:hover {
            filter: brightness(110%);
        }
    }

    &.open {
        max-height: 1000px;
        transition: max-height 0.3s ease-in-out;
    }
}

[data-viewport="mobile"] {
    #add-nav {
        left: 50%;
        bottom: 80px;
        right: unset;
        transform: translateX(-50%);
    }
}

button,
.button {
    &.x-small {
        font-size: 12px;
        padding: 0.3rem 0.6rem;
    }
}

.install-banner {
    position: fixed;
    display: flex;
    transition: bottom 0.2s ease-out;
    bottom: -500px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 1px 1px 10px rgba(127, 127, 127, 0.8);
    padding: 0.4rem;
    border-radius: 1rem;
    background-color: #c7ebdd;
    width: 80%;
    max-width: 600px;
    text-align: center;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-weight: 600;
}

.is-mobile {
    &[data-scroll="down"] {
        .install-banner {
            bottom: 10px;
        }
    }
}

html:not(.is-mobile) {
    .install-banner {
        bottom: 10px;
    }
}
[data-flow-ui-type] {
    fieldset[data-flow-continue] {
        margin-top: 1rem;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        gap: 1rem;

        [name=back]{
            background-color: transparent;
            color: inherit
        }
        [name=continue]{
            background-color: var(--color-green);
        }
    }

}


.icon-enriched-list {
    list-style: none;

    li {
        margin-left: 0;
        margin-top: 1.5rem;
        display: flex;
        flex-direction: row;
        gap: 1rem;
    }
}

.svg-icon-container {
    display: inline-block;
    padding: 1rem;
    border-radius: 100%;
    aspect-ratio: 1/1;
    height: min-content;
}

flow-ui-step {
    fieldset {
        .legend {
            font-weight: 200;
            font-size: 1.3rem;
            margin-bottom: 1rem;
            text-transform: uppercase;
            opacity: .5;
        }
    }


}
