/*
 * The proxy's own pages (/sso/**): the UKCEH look on stock Bootstrap 5.
 *
 * It follows eip/catalogue (web/scss/customProperties.scss, bootstrap-configured.scss
 * and base.scss), so moving between the catalogue and the sign-in, profile and admin
 * pages doesn't change the type or colours. Where the catalogue sets a Bootstrap Sass
 * variable, this sets the CSS custom property Bootstrap compiles it to.
 *
 * It replaces the Bootstrap 3 bootstrap-theme-ceh (last released 2016) and the styles
 * that used to be inline in template.ftl. It is not loaded by the navbar fragments
 * injected into proxied applications (_navbar-user.ftl, _navbar-brand.ftl), which
 * style themselves inline because those applications bring their own CSS.
 */

:root {
    /* UKCEH base colours, as eip/catalogue defines them */
    --ukceh-colour-air: rgb(214, 234, 230);
    --ukceh-colour-day: rgb(255, 255, 255);
    --ukceh-colour-data: rgb(219, 254, 82);
    --ukceh-colour-earth: rgb(215, 183, 170);
    --ukceh-colour-land: rgb(144, 169, 104);
    --ukceh-colour-night: rgb(17, 17, 17);
    --ukceh-colour-water: rgb(71, 122, 226);
    /* Water darkened for text: the brand water is 4.08:1 on white, this is 5.34:1
       (WCAG AA needs 4.5:1, dri-one #462) */
    --ukceh-colour-water-text: rgb(60 104 192 / 1);
    --ukceh-colour-water-25: rgb(209 222 248 / 1);

    --ukceh-font-family-SansSerif: 'Inter Variable', system-ui, sans-serif;

    --link-colour: var(--ukceh-colour-water-text);
    --link-hover-colour: var(--ukceh-colour-water-text);

    --header-background-colour: var(--ukceh-colour-night);
    --header-border-bottom-colour: #bbb;
    --header-link-colour: var(--ukceh-colour-day);
    --header-link-hover-colour: var(--ukceh-colour-data);
    --header-link-hover-background-colour: color-mix(in lab, var(--header-background-colour), white 25%);
    --dropdownmenu-background: #eee;
    --dropdownmenu-background-hover: color-mix(in lab, var(--dropdownmenu-background), black 5%);

    /* Bootstrap, configured as the catalogue configures it */
    --bs-body-font-family: var(--ukceh-font-family-SansSerif);
    --bs-body-line-height: 1.6;
    --bs-heading-color: #333;
    --bs-border-color: rgb(140 140 140);
    --bs-link-color-rgb: 60, 104, 192;
    --bs-link-hover-color-rgb: 60, 104, 192;
    --bs-code-color: #c7254e;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    text-wrap: pretty;
}

a {
    text-decoration: none;
    text-underline-offset: 0.25em;
    color: var(--link-colour);

    &:hover,
    &:focus-visible {
        text-decoration: underline;
        color: var(--link-hover-colour);
    }

    @media (prefers-contrast: more) {
        text-decoration: underline;
    }
}

/* Bootstrap 5 dropped the space above headings and below the navbar which these
   pages were laid out with in 3, which runs a heading into whatever precedes it */
h1, h2, h3, h4, h5, h6 {
    font-weight: 300;
    line-height: 1.1;
}

h1, h2, h3 {
    margin-block: 20px 10px;
}

h4, h5, h6 {
    margin-block: 10px;
}

main {
    padding-block-start: 20px;
}

h1 {
    font-weight: 200;
}

h2, h3, h4 {
    /* #999 was 2.85:1 on white; this is 5.33:1 (dri-one #462) */
    color: #6b6b6b;
    font-weight: 200;
}

.form-control,
.form-select {
    border-radius: 4px;
}

.table {
    --bs-table-border-color: #cdc;
}

/* The UKCEH call-to-action button */
.btn-ukceh {
    border-radius: 0;
    --bs-btn-bg: var(--ukceh-colour-night);
    --bs-btn-color: var(--ukceh-colour-day);
    --bs-btn-hover-bg: var(--ukceh-colour-data);
    --bs-btn-hover-color: var(--ukceh-colour-night);
    --bs-btn-active-bg: var(--ukceh-colour-data);
    --bs-btn-active-color: var(--ukceh-colour-night);
    outline: var(--ukceh-btn-outline-colour, transparent) 2px solid;
    outline-offset: 2px;
    border: none;

    &:hover,
    &:focus-visible {
        --ukceh-btn-outline-colour: var(--ukceh-colour-night);
    }
}

/* Header: the user menu (or sign-up link) on the night background */
header {
    background-color: var(--header-background-colour);
    border-block-end: 1px solid var(--header-border-bottom-colour);

    .navbar {
        min-height: 50px;
        padding-block: 0;
    }

    .navbar-nav {
        align-items: stretch;

        > li {
            list-style: none;
            display: flex;
        }

        > li > a,
        > li > form > .btn-link {
            display: flex;
            align-items: center;
            padding-inline: 1em;
            color: var(--header-link-colour);
            text-decoration: none;

            &:hover,
            &:focus-visible {
                background-color: var(--header-link-hover-background-colour);
                color: var(--header-link-hover-colour);
            }
        }

        /* _navbar-user.ftl also carries a Bootstrap 3 caret, which 5 draws itself */
        .caret {
            display: none;
        }

        .dropdown-menu {
            background-color: var(--dropdownmenu-background);
            padding: 0;

            li {
                border-block-end: 1px solid lightgray;

                &:last-child {
                    border: none;
                }
            }

            .dropdown-item {
                color: black;

                &:hover,
                &:focus-visible {
                    background-color: var(--dropdownmenu-background-hover);
                }
            }

            form.dropdown-item {
                padding: .75em 1em;
            }
        }
    }
}

/* The sign-in, sign-up and password pages: a framed form under the UKCEH logo */
.framework {
    margin: 0 auto;
    padding: 1rem 2rem;
    max-width: min(620px, 100vw);
    min-height: calc(100dvh - 70px);
    align-content: center;

    .ukcehLogo {
        padding: 1.6rem;
        align-content: center;
        text-align: center;

        img {
            max-height: 100px;
            width: auto;
        }
    }

    .frame {
        outline: 2px solid #ddd;
        padding: 1.6em;
        border-radius: 5px;
        box-shadow: 8px 8px 5px #eee;

        /* Clear the button's hover/focus outline (2px, offset 2px) */
        form + .alert {
            margin-block-start: 1rem;
        }
    }
}

.form-gp {
    margin-block-end: .6em;
}

/* The sign-up form's honeypot field */
.hp {
    visibility: hidden;
    margin: 0;
    padding: 0;
}

.flexLinks {
    display: flex;
    flex-direction: row;
    gap: 0.5em 2em;
    padding: 1em 0;

    a {
        font-weight: 600;
    }
}

/* Profile page */
#profile {
    .profileHeader {
        margin: 0.25em 0.25em 2em 0.25em;
    }

    .list-group {
        margin-block-end: 3em;
    }

    .list-group-item {
        padding: 1.35em 1em;

        &:hover .list-group-item-heading {
            color: #000;
        }
    }

    .list-group-item-heading {
        font-weight: bold;
        color: #555;
        font-size: 1.1em;
        margin-block: 0 .25em;
    }

    .list-group-item-text {
        color: #6b6b6b;
        font-size: .9em;
        margin: 0;
    }
}

/* The profile page's admin cards, as bootstrap-theme-ceh drew them */
.carddeck {
    margin-block: 1.5em;
    display: grid;
    gap: 3em;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));

    .card {
        border: none;
        border-radius: 0;
        box-shadow: 0 0 1em 0.5em #e6e6e6;

        &:hover {
            box-shadow: 0 0 1em 0.5em #ccc;
        }

        > div {
            width: 100%;
            box-sizing: border-box;
            padding: 1em;
        }
    }

    .card--header {
        background-color: #337085;
        min-height: 8rem;
        display: flex;
        align-items: flex-end;

        * {
            padding: 0;
            margin: 0;
            color: white;
        }
    }

    .card--body {
        --lineheight: 1.2em;

        a {
            line-height: var(--lineheight);
            display: block;
            padding: 1em;

            &:hover {
                background-color: #cce3eb;
            }

            &:first-child {
                margin-block-start: var(--lineheight);
            }

            &:last-child {
                margin-block-end: var(--lineheight);
            }
        }
    }
}

/* The admin tables' drag handle (manage-proxy-endpoints) */
[data-drag-handle] {
    cursor: move;
}

/* A dialog's title sits in its header, without the space headings get above */
.modal-title {
    margin-block: 0;
}
