/* Headings */
h1, h2, h3 {
    margin: 10px 0;
}
h4 {
    margin: 18px 0 10px 0;
}

/* Body is 100% height */
body {
    background-color: rgb(250,250,230);
    height: 100%;
}
body.warning {
    background-color: rgba(255, 0, 0, 0.35);
    
    div.tabs {
        button {
            background-color: white;
        }
    }
    
    div.tabBook 
    {
        section:not(#tab_inst) {
            display: none;
        }
        section#tab_inst {
            display: flex;
            /*
            p, table, > ol, h4:first-child {
                display:none;
            }*/
            
            h4:not(:first-child) {
                order: -10;
                font-size: larger;
            }
            div#warnings {
               order: -9; 
                font-size: larger;
            }
            div#pr_val {
                order: -8;
            }
            >*:first-child {
                margin-top: 25px;
                padding-top: 25px;
                border-top: 1px solid grey;
            }
            > div#pr_val > hr:last-child {
                display: none;
            }
            table {
                display: none;
            }
                
        }

    }
}

/* clear up sub appearances */
p {
    line-height: 1.25;
}
sub {
    line-height: 0;
}
li {
    margin-bottom: 3px;
}
hr {
    width: 100%;
}

/* Header always visible above main */
header {
    a {
        text-decoration: none;
        color: black;        
    }
}

/* main contains aside and article */
main {
    display: flex;
}

/* aside is the data input bar */
aside {
    display: flex;
    flex-direction: column;
    margin-right: 10px;
    width: 13.5em;
    
    /* form full width */
    > form {
        width: 100%;
        flex-grow: 0;
    }
    
    > div:first-child {
        margin-top: 20px;
    }
    
    /* other divs */
    > div {
        display: flex;
        align-items: baseline;
        width: 100%;
        margin-top: 10px;
        
        * {
            flex-grow: 1;
            margin: auto;
            height: 2.25em;
            text-align: center;
        }
        
        a {
            height: auto;
            text-decoration: none;
        }
    }
}

/* General form appearance */
form {
    display:flex;
    flex-direction: column;

    > div, > div > div {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        align-items: baseline; 
    }
    
    > div {
        > div.options {
            width:100%;
        }
        
        label {
            flex-basis: 1.5em;
            height: 1.5em;  
            margin-right: 3px;
        }
        
    }

    input[type=radio] {
        margin: 0 0 0 2px;
    }     
    
    /* selection exclusion colouring */
    input.radioed:not(.choice), input.choice:not(.radioed) {
        background-color: #e0f0f0;
    }

    input[type=text] {
        flex-grow: 1;
        width: 1px;
        margin: 1px 5px 1px 0px;                    
    }

    p {
        margin: 7px 0;
    }

    hr {
        width: 100%;
    }

    button {
        width: 90%;
        margin: 5%;
        height: 2.5em;
        font-size: large;
        font-weight: bold;
    }
}

/* Specific for .options */
form div.options > select {
    flex-grow: 1;
    margin: 0px 30px 10px 30px;
    height: 2em;
    text-align: center;
}

/* article gows to fit the remaining space */
article {
    display: flex;
    flex-direction: column;
    flex-basis: 100%;
    flex-grow: 1;
}

/* tab marks */
div.tabs {
    display: flex;

    > button {
        flex-grow: 0;
        text-align: center;
        padding: 2px 8px 2px 8px;

        border: 0 black solid;
        border-width: 1px 1px 0px 1px;

        margin-right: 5px;
        border-top-left-radius: 8px;
        border-top-right-radius: 8px;
        border-bottom-left-radius: 1px;
        border-bottom-right-radius: 1px;

        min-width: 6em;
        flex-shrink: 1;

        cursor: pointer;

        display:flex;
    }
    p {
        margin: auto;
        line-height: 1.15;
        padding: 3px 0;
    }
    
    /* works but don't want it yet */
    > button#h_all {
        display: none;
    }

    /* button selection colouring */
    > button.selected {
        background-color: chartreuse;
    }
    > button.selected.all {
        background-color: aquamarine;
    }

}

div.tabBook {
    border: 1px black solid;
    padding: 5px;
    max-width: 750px;
    background-color: white;
    
    flex-basis: 40em;
    
    display: flex;
    flex-direction: column;
    
    > section {
        display: flex;
        flex-direction: column;
        
        flex-grow: 1;
        max-width: 700px;
        padding: 10px 20px 0 20px;;
        min-height: 40em;
        
        canvas {
            margin: 5px 0;
        }
        
        canvas:first-child {
            margin-top: 15px;
        }
        
        .expand {
            flex-grow: 1;
        }
                
        p {
            margin: 0.5em 0;
        }
        
        table {
            margin: 1.25em auto;
        }
        
        ol, ul {
            margin: 0;
        }
        
        li {
            padding-left: 10px;
            margin: 5px 0;
        }
        
        div#warnings {
            li::after {
                content: ".";
            }
        }
        
    }    
    
    /* For hidden sections */
    > section:not(.selected) {
        display: none;
    }
    
    /* When all sections visible */
    > section.all {
        min-height: 0;
        margin-bottom: 9px;
    }
    
    > section.all:not(:first-child) {
        margin-top: 9px;
        border-top: 1px solid grey;
    }
}

footer {
    padding: 0 5px;
    margin-top: 17px;
    color: dimgrey;
    font-size: small;
    
    hr {
        margin: 0;
    }
    
    p {
        margin: 5px 0; 
    }
    
}

h1, h2, h3 {
    margin: 0;
    margin-bottom: 0.5em;
}

h2 {
    min-height: 1.3em;
}

.hidden {
    display: none;
}

div.maths {
    display: flex;
    > * {
        margin: auto !important;
        margin-top: 0.25em !important;
        margin-bottom: 0.25em !important;
    }
    
    overflow-x: auto;
    overflow-y: hidden;
}
mjx-container {
    pointer-events: none;
}


table.windings {
    margin: auto;
    border-collapse: collapse;
    
    th, td {
        border: 1px solid black;
        padding: 4px 8px;
    }
    
    th:first-child {
        background-color: unset;
        border-left: none;
        border-top: none;
    }
    
    td:first-child, th {
        font-weight: bold;
    }
    td[colspan] {
        background-color: unset;
        font-weight: normal;
    }
    
    td:first-child,
    th:first-child {
        width: 6em;
    }
        
    td:not(:first-child),
    th:not(:first-child),
    td[colspan]
    {
        width: 3em;   
        text-align: center;
    }  
    
    tr:nth-child(16) {
        border-top: 3px double black;
        background-color: rgb(245, 255, 250);
        
        td:not(:first-child){
            padding: 0;
        }
    
        div {
            display: flex;
            margin: 2px;
        }
        
        button {
            flex-grow: 1;
            margin: 5px;
            padding: 3px;
        }    
        
    }
    
}


@media (max-width: 650px) {
    main {
        flex-direction: column;
    }
    
    aside {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        margin-bottom: 20px;
        
        > div {
            width: 45%;
            flex-grow: 1;
        }
    }

    form {
        flex-direction: row;
        flex-wrap: wrap;

        button {

        }

        > div {
            min-width: 20%;
            flex-basis: 37%;
            flex-grow: 1;
            padding-left: 5px;
            padding-right: 5px;
            border-left: 1px solid grey;
            border-right: 1px solid grey;
            margin-right: -1px;
            border-collapse: collapse;
            padding-bottom: 4px;
        }

        > div:not(:first-child) {

            padding-left: 5px;
            border-left: 1px solid grey;
        }

        button {
            margin-top: 5px;
            margin-bottom: 10px;
        }
    }
}



/* Loading block */
#loader {
    position:fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    background-color: rgba(150,100,100,0.3);
    pointer-events: none;
    display: none;
    z-index: 1;

    > div {
        display: flex;
        align-items: center;
        pointer-events: auto;
        padding: 5px 15px;
        border: 2px solid grey;
        width: calc(110px + 7em);
        height: 80px;
        margin: auto; 
        background-color: white;
        outline: 1px solid green;

        > div {
            border: 10px solid yellow;
            border-top: 10px solid blue;
            border-bottom: 10px solid blue;           
            border-radius: 50%;
            outline: 1px black solid;
            background-color: grey;
            width: 40px;
            height: 40px;
            animation: spin 1.3s linear infinite;
        }

        > span {
            display: block;
            margin: auto;
            font-size: x-large;
            font-weight: bold;
        }
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}