* {
  box-sizing:border-box;
}

html {
  height:100%;
}

body {
  padding:0;
  margin:0;
  height:100%;
}

/* Styling the scrollbar of the website */
body::-webkit-scrollbar {
  width:5px;
}

body::-webkit-scrollbar-track {
  background:#f1f1f1;
}

body::-webkit-scrollbar-thumb {
  background:#888;
}

body::-webkit-scrollbar-thumb:hover {
  background:#111;
}

.headingandlogo {
  display:grid;
  grid-template-rows:auto;
  grid-template-columns:repeat(20, 1fr);
  gap:8px;
  background:#d1ccc0;
  margin:0;
  padding:0;
}

.hamburgermenu {
  grid-area:1 / 1 / 2 / 2;
  margin:0;
  padding:0.5rem;
  display:none;
  z-index:2;
}

.hamburgermenu div {
  width:1.5rem;
  border:2px solid black;
  margin:2px 0;
}

.calculatorlogo {
  grid-area:1 / 1 / 2 / 2;
  z-index:2;
}

.calculatorlogo img {
  width:3rem;
  height:100%;
}

.heading {
  grid-area:1 / 1 / 2 / -1;
  align-self:center;
}

h1 {
  text-align:center;
  margin:0;
}

.navbar {
  display:flex;
  flex-wrap:wrap;
  flex-direction:row;
  background:#555;
  text-align:center;
  font-size:1rem;
  width:100%;
}

.navbar a.closenav {
  display:none;
}

.navbar a {
  display:block;
  padding:0.5rem;
  text-decoration:none;
  color:white;
}

.navbar a:hover {
  background:#333;
}

.activeLink {
  background:#333;
}

.calculator {
  display:flex;
  flex-direction:column;
  height:100%;
  font-size:2rem;
  margin:0;
  border:2px solid grey;
  text-align:center;
}

#result {
  position:-webkit-sticky;
  position:sticky;
  top:0;
  width:100%;
  height:5rem;
  background:rgba(0,200,0,0.5);
  border-bottom:2px solid grey;
  overflow:auto;
  text-align:right;
}

.simplebuttons {
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  grid-template-rows:repeat(7, 1fr);
  gap:0.5rem;
  padding:1rem;
  flex-grow:1; /* Since buttons class div is a flex item of flex container calculator class div*/
}

.button {
  font-size:2rem;
  padding:1rem;
  border:1px solid grey;
}

.button:not(:disabled):hover {
  background:#111;
  color:white;
}

/* This class is used in js code for keydown eventlistener */
.buttonhover {
  background:#111;
  color:white;
}

.lastbutton {
  background:rgba(0,0,255,0.7);
  color:white;
}

.lastbuttonhover {
  background:darkblue;
}

#equal:hover {
  background:darkblue;
}

@media screen and (max-width:600px) {
  .hamburgermenu {
    display:block;
  }

  .calculatorlogo {
    display:none;
  }

  .navbar {
    position:fixed;
    flex-direction:column;
    height:100%;
    z-index:2;
    width:0;
    overflow:hidden;
  }

  .navbar:target {
    width:calc(100vw - 1rem);
  }
  
  .navbar:not(:target) {
    width:0;
  }

  .navbar a.closenav {
    display:block;
    text-align:right;
  }

  .closenav:hover {
    color:red;
    background:black;
  }

  .simplebuttons {
    grid-template-columns:repeat(3, 1fr);
    grid-template-rows:repeat(10, 1fr);
  }
  
  .button {
    font-size:1rem;
  }

  .simplebuttons .button#equal {
    grid-column-start:1;
    grid-column-end:4;
  }

  .simplebuttons .button:nth-of-type(16) {
   grid-area:4 / 1 / 5 / 2;
  }

  .simplebuttons .button:nth-of-type(20) {
    grid-area:4 / 2 / 5 / 3;
  }

  .simplebuttons .button:nth-of-type(24) {
    grid-area:4 / 3 / 5 / 4;
  }
}

/* CSS for programmer.html webpage */

.programmerbuttons {
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  grid-template-rows:auto;
  gap:0.5rem;
  padding:1rem;
}

.calculator:has(.programmerbuttons) {
  height:auto;
}

.programmerbuttons .button:first-child, .programmerbuttons .button:nth-child(2) {
  grid-column:span 2;
}

#programmerresult {
  padding:0 1rem;
}

#programmerresult > div:not(:first-child) {
  display:flex;
}

#finalresult {
  text-align:center;
  overflow-x:auto;
  overflow-y:hidden;
}

#programmerresult > div:not(:first-child) :last-child {
  flex:1;
  text-align:right;
  overflow-x:auto;
  overflow-y:hidden;
}

#programmerresult > div:not(:first-child) :first-child {
  cursor:pointer;
}

#programmerresult > div:not(:first-child):hover {
  background-color:lightblue;
}

.leftborderstyle {
  border-width:0 0 0 5px;
  border-color:blue;
  border-style:solid;
}

@media screen and (max-width:600px) {
  #programmerresult {
    font-size:1rem;
  }
}

/* CSS for unit.html webpage */

.display {
  display:flex;
  width:100%;
  flex-direction:row;
  flex-wrap:wrap;
}

.chooseunit {
  display:flex;
  flex-direction:row;
  flex-wrap:nowrap;
  position:relative;
  width:100%;
  margin:0;
  padding:0;
  background-color:#555;
  overflow-x:auto;
}

.chooseunit::-webkit-scrollbar {
  display:none;
}

.chooseunit a {
  text-decoration:none;
  padding:0.5rem 1rem;
  margin:0;
  color:white;
  font-size:1rem;
}

.chooseunit a:hover {
  background-color:#111;
}

.chooseunit button {
  position:fixed;
  display:none;
  font-size:1.5rem;
  padding:0.1rem 1rem;
  z-index:1;
  background-color:rgba(0,0,0,0.5);
  font-weight:bold;
  color:white;
}

.chooseunit button:hover {
  background-color:rgba(0,0,0,1.0);
}
  
.chooseunit button:first-child {
  left:0;
}

.chooseunit button:last-child {
  right:0;
}

.display select {
  width:100%;
  border:none;
  font-size:clamp(1rem, 1vw + 1rem, 2rem);
  background:none;
}

.display select option {
  text-align:center;
}

#firstunitparameter, #secondunitparameter {
  width:50%;
  height:auto;
  border:2px solid #333;
}

.display select:not(:first-child) {
  display:none;
}

#unit1, #unit2 {
  width:50%;
  height:5rem;
  background:rgba(0,200,0,0.5);
  border:2px solid grey;
  overflow-y:hidden;
  overflow-x:auto;
  text-align:right;
  vertical-align:middle;
  line-height:4rem;
}

.unitbuttons {
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  grid-template-rows:repeat(4, 1fr);
  gap:0.5rem;
  padding:1rem;
}

.unitbuttons button:last-child {
  grid-column:2 / 4;
}

@media screen and (max-width:600px) {
  .chooseunit {
    padding:0 2.5rem;
  }

  .chooseunit button {
    display:block;
  }
    
  .unitbuttons {
    grid-template-columns:repeat(3, 1fr);
    grid-template-rows:repeat(5, 1fr);
  }

  .unitbuttons button:last-child {
    grid-area:4 / 1 / 5 / 2;
  }

  .unitbuttons button:nth-of-type(4) {
    grid-area:4 / 3 / 5 / 4;
  }

  .unitbuttons button:nth-of-type(12) {
    grid-area:4 / 2 / 5 / 3;
  }

  .unitbuttons button:nth-of-type(8) {
    grid-area:5 / 1 / 6 / 4;
  }
}

@media only screen and (max-width:400px) {
  .display {
    flex-direction:column;
  }

  #firstunitparameter {
    order:1;
    width:100%;
  }

  #secondunitparameter {
    order:3;
    width:100%;
  }

  #unit1 {
    order:2;
    width:100%;
  }

  #unit2 {
    order:4;
    width:100%;
  }
}
