@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Serif:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap');

html{
    font-family: "IBM Plex Serif", serif;
}

body{
    font-family: inherit;
}

html, body{
    margin: 0;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

.main-wrapper{
    min-height: 100vh;
    box-sizing: border-box;
}

/* nav */
.nav-wrapper{
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1000;
    width: 70px;
    padding: 30px 20px;
    border: 1px solid black;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #535353;
}

.nav{
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.nav a{
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    color: #000000;
    border: 1px solid black;
    border-radius: 15px;
    font-size: 1.3rem;
    text-decoration: none;
    font-weight: 600;
    background: #d6d6d6;
    height: 30px;
    width: 30px;
    transition: transform 0.3s ease;
}

.nav a:hover{
    transform: scale(1.05);
}

.nav a:active{
    transform: scale(0.98);
}

.nav a svg{
    width: 30px;
    height: 30px;
}

.nav a[href='calc.html']{
    background: black;
    color: rgb(209, 209, 209);
    border-color: rgb(128, 128, 128);
}

/* wrapper */
.main{
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
    margin-left: 110px;
    padding: 30px 20px;
}

/* calculator */
.calc{
    padding: 15px 20px;
    border: 3px solid rgb(32, 32, 32);
    border-radius: 25px;
    box-shadow: 0 15px 30px black;
    background-color: #2f2f2f;
    width: fit-content;
    max-width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

.calcheader{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 0 7px 15px 5px;
    justify-content: center;
    align-items: center;
}

.calctitle{
    margin: 0;
    font-size: 1.3rem;
    color: white;
}

.calcdesc{
    margin: 0;
    font-size: 0.8rem;
    color: white;
    font-weight: 500;
    text-align: right;
}

/* how to use popup */
.header-row{
    display: flex;
    align-items: center;
    gap: 5px;
}

.how-to-use{
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-top: 3px;
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: white;
    font-weight: 700;
    cursor: pointer;
}

.how-popup{
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    animation: popup 0.5s ease;
}

.how-popup.active{
    display: flex;
}

.how-content{
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.how-header{
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 40px;
    flex-shrink: 0;
}

.how-header-left{
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.how-header-left h2{
    margin: 0;
    font-size: 2rem;
}

.how-header-left p{
    margin: 0;
}

.close-how{
    display: flex;
    background: none;
    border: none;
    color: white;
    font-size: 1.7rem;
    transition: all 0.3s ease;
}

.close-how:hover{
    transform: scale(1.2);
}

.close-how:active{
    transform: scale(1);
}

.how-sections{
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.how-section{
    display: flex;
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    background: rgb(73, 73, 73);
    padding: 20px;
}

.how-section h3{
    margin: 0;
}

.how-section p{
    margin: 0;
    line-height: 1.7;
}

.how-section kbd{
    display: inline-block;
    padding: 2px 8px;
    background: #2e2e2e;
    border: 1px solid black;
}

@keyframes popup {
    from{
        opacity: 0;
        transform: translateY(20px) scale(0.7);
    }
    to{
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* green display */
.display{
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    min-height: 70px;
    margin: 20px 0;
    padding: 20px;
    border: 1px solid black;
    background-color: #8e9f80c9;
    justify-content: space-between;
    box-shadow: inset 2px 2px 2px black;
    border: 1px solid black;
}

.expression{
    width: 100%;
    overflow-wrap: anywhere;
    color: #000000;
    font-size: 1.1rem;
    font-weight: 500;
}

.result{
    width: 100%;
    text-align: right;
    overflow-wrap: anywhere;
    color: #000000;
    font-size: 1.4rem;
    font-weight: 500;
}

/* settings */
.settings-menu{
    display: none;
    width: 100%;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    gap: 10px;
    align-self: center;
}

.settings-menu.active{
    display: flex;
}

.settings-main, .angle-menu{
    display: none;
    flex-direction: column;
    gap: 8px;
}

.settings-main.active, .angle-menu.active{
    display: flex;
}

.settings-menu h3{
    margin: 0;
    font-size: 1.3rem;
}

.setting-option{
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    border: 1px solid rgba(0, 0, 0, 0.513);
}

.setting-option.selected{
    border-color: rgba(0, 0, 0, 0.93);
}

.setting-option p{
    margin: 0;
}

.angle-options{
    display: flex;
    gap: 10px;
}

#angleOption{
    font-weight: 600;
}

.angle-option{
    flex: 1;
    margin: 0;
    padding: 5px 10px;
    border: 1px solid rgba(0, 0, 0, 0.674);
    font-weight: 800;
    text-align: center;
}

.angle-option.selected{
    border: 1px solid black;
    background-color: rgba(0, 0, 0, 0.25);
}

.display:has(.settings-menu.active) > .expression,
.display:has(.settings-menu.active) > .result{
    display: none;
}

/* calculator buttons */
.calcbuttons{
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.row{
    display: grid;
    grid-template-columns: repeat(6, minmax(0,1fr));
    grid-template-rows: auto;
    gap: 6px;
}

.row button, .numrow button{
    min-width: 0;
    min-height: 0;
    padding: 3px;
    border: none;
    border-radius: 50%;
    aspect-ratio: 1 / 1 ;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    width: 100%;
    height: auto;
}

.on{
    background: #000000;
    color: white;
    font-size: 1.2rem;
}

.home, .settings{
    background: #000000;
    color: white;
    font-size: 1.2rem;
}

.row button.shiftbtn{
    background: black;
    color: white;
    border: none;
    font-size: 1.2rem;
    transition: all 0.2s ease;
}

.row button.shiftbtn.active{
    background: #ffcc00df;
    border: 2px solid #8e7203;
    border-radius: 50%;
    color: #695502;
}

.top-controls{
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 40px;
    align-items: center;
    width: 100%;
    margin: 0 0 20px;
    justify-content: space-between;
}

.top-controls > .row:first-child{
    display: grid;
    grid-template-columns: repeat(2, 50px);
    grid-template-rows: repeat(2, 50px);
    gap: 15px;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    padding-left: 10px;
}

.top-controls > .arrow-row{
    width: max-content;
    justify-self: center;
    margin: 0;
}

.top-controls > .row:first-child button{
    width: 50px;
    height: 50px;
    min-height: 0;
    padding: 10px;
    aspect-ratio: auto;
    justify-self: center;
    box-sizing: border-box;
}

.arrow-row{
    display: grid;
    grid-template-columns: repeat(3, 38px);
    grid-template-rows: repeat(3, 38px);
    gap: 8px;
    align-items: center;
    justify-items: center;
    justify-content: center;
    padding-right: 10px;
}

.arrow-row button{
    width: 38px;
    height: 38px;
    min-width: 0;
    aspect-ratio: auto;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #454545;
    color: white;
    border: 1px solid #777777;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.arrow-row button:hover{
    background: #626262;
}

.arrow-row button:active{
    background: #777777;
}

#uparrow{
    grid-column: 2;
    grid-row: 1;
}

#leftarrow{
    grid-column: 1;
    grid-row: 2;
}

#ok{
    grid-column: 2;
    grid-row: 2;
    font-size: 1rem;
}

#rightarrow{
    grid-column: 3;
    grid-row: 2;
}

#downarrow{
    grid-column: 2;
    grid-row: 3;
}

.fractions,
.roots,
.powers,
.square,
.logs,
.sine,
.cosine,
.tangent{
    position: relative;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fractions > button:first-child,
.roots > button:first-child,
.powers > button:first-child,
.square > button:first-child,
.logs > button:first-child,
.sine > button:first-child,
.cosine > button:first-child,
.tangent > button:first-child{
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    padding: 5px;
    color: #f2f2f2;
    background: #454545;
    border: 1px solid #777777;
    font-size: 1rem;
}

.fractions > .shift,
.roots > .shift,
.powers > .shift,
.square > .shift,
.logs > .shift,
.sine > .shift,
.cosine > .shift,
.tangent > .shift{
    display: none;
}

.fractions::before,
.roots::before,
.powers::before,
.square::before,
.logs::before,
.sine::before,
.cosine::before,
.tangent::before{
    position: absolute;
    top: -15px;
    left: 70%;
    z-index: 2;
    color: #f3dc79;
    font-family: inherit;
    font-size: 0.75em;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
}

.fractions::before{
    content: 'a x/y';
}

.roots::before{
    content: 'ⁿ√x';
}

.powers::before{
    content: 'x⁻¹';
}

.square::before{
    content: 'lg';
}

.logs::before{
    content: 'ln';
}

.sine::before{
    content: 'sin⁻¹';
}

.cosine::before{
    content: 'cos⁻¹';
}

.tangent::before{
    content: 'tan⁻¹';
}

.calcbuttons > .row:not(.arrow-row){
    margin-top: 10px;
}

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

.numrow{
    display: grid;
    grid-template-columns: repeat(5, 55px);
    column-gap: 10px;
    row-gap: 8px;
    align-items: center;
}

.numrow button{
    width: 100%;
    min-width: 0;
    min-height: 0;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    border: 1px solid #717171;
    border-radius: 50%;
    color: #f4f4f4;
    background-color: #454545;
    font-size: 1.2rem;
    line-height: 1;
    justify-self: center;
    align-self: center;
}

.row .openbracket, .row .closebracket{
    width: 100%;
    min-width: 0;
    min-height: 9;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    border: 1px solid #717171;
    border-radius: 50%;
    color: #f4f4f4;
    background-color: #454545;
}

.row .pi, .row .e{
    width: 100%;
    min-width: 0;
    min-height: 9;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    border: 1px solid #717171;
    border-radius: 50%;
    color: #f4f4f4;
    background-color: #454545;
    font-size: 1.4rem;
    justify-content: center;
}

.numrow button.tenpower{
    font-size: 1rem;
}

.numrow button.format{
    font-size: 0.75rem;
}

/* fractions */
.fraction-expression{
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin: 0 5px;
    min-width: 25px;
}

.fraction-field{
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 25px;
    min-height: 25px;
    padding: 2px 5px;
}

.fraction-line{
    width: 100%;
    height: 1px;
    min-width: 25px;
    background: black;
}

.mixed-expression{
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.mixed-whole{
    display: inline-flex;
    align-items: center;
}

.editor-cursor, .cursor{
    display: inline-block;
    width: 2px;
    height: 20px;
    background: black;
    vertical-align: middle;
}

/* power on and off styles for display and button */
.off-display{
    display: none;
    width: 100%;
    min-height: 70px;
    box-sizing: border-box;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #8e9f80c9;
    text-align: center;
    animation: displayFade 0.5s ease;
}

.off-display h2{
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    opacity: 1;
    color: black;
}

.off-display p{
    margin: 0;
    font-size: 1rem;
    opacity: 1;
    color: black;
}

@keyframes displayFade {
    from{
        opacity: 0;
        scale: 0.9;
    }
    to{
        opacity: 1;
        scale: 1;
    }
}

.calc.off .expression,
.calc.off .result,
.calc.off .settings-menu{
    display: none;
}

.calc.off .off-display{
    display: flex;
}

.calc.off .calcbuttons button{
    opacity: 0.5;
    pointer-events: none;
}

.calc.off .calcbuttons .on{
    opacity: 1;
    pointer-events: auto;
    background: #ffcc00df;
    border: 2px solid #8e7203;
    border-radius: 50%;
    color: #695502;
}