@import url(./material.css);

* {
  box-sizing: border-box;
}

:root {
  --panels-row: 2;
  --panel-width: 475px;
  --panel-height: 200px;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.enigma {
  display: grid;
  align-content: center;
  justify-content: center;
  align-items: center;
  justify-items: center;
  grid-template-columns: repeat(var(--panels-row), var(--panel-width));
  gap: 50px 20px;
}

.board {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  align-items: center;
  justify-items: center;
  width: var(--panel-width);
  height: var(--panel-height);
  padding: 2rem 1rem;
  border-radius: 0.5em;
  position: relative;
}

.board-row {
  display: flex;
  justify-content: center;
}

.port {
  width: 0px;
  height: 0px;
  position: absolute;
}

.port-bottom {
  bottom: 0;
  left: 50%;
}

.port-top {
  top: 0;
  left: 50%;
}

.port-bottom-right {
  bottom: 0;
  right: 0;
}

.port-top-right {
  top: 0;
  right: 0;
}

.port-top-left {
  top: 0;
  left: 0;
}

svg {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.rotor {
  position: relative;
  width: 30px;
  margin: 20px;
  height: 100%;
  transform-style: preserve-3d;
  perspective: 300px;
  z-index: 3;
}

.rotor-backface {
  position: relative;
  top: 50%;
  transform-style: preserve-3d;
}

.rotor-letter {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 30px;
  background: var(--material-color-grey-800);
  border-left: 5px solid var(--material-color-blue-grey-800);
  border-right: 5px solid var(--material-color-blue-grey-800);
}

.rotor-letter span {
  height: 17px;
  width: 20px;
  line-height: 17px;
  font-size: 12px;
  text-align: center;
  background: var(--material-color-grey-50);
  color: var(--material-color-grey-800);
  box-shadow: inset 0 0 1px 1px var(--material-color-grey-400);
  text-shadow: var(--material-color-yellow-100) 0 0 2px;
  font-family: sans-serif;
}

.rotor-marker {
  position: relative;
  width: 0;
  height: 0;
}
.rotor-marker::after {
  content: "▬";
  font-size: 12px;
  line-height: 12px;
  height: 17px;
  width: 0;
  position: relative;
  top: -9px;
  left: 6px;
  background-color: var(--material-color-red);
  font-family: sans-serif;
  background-clip: text;
  -webkit-background-clip: text;
  -moz-background-clip: text;
  color: transparent;
  text-shadow: rgba(13, 13, 13, 0.3) 0px 0.3px 0.3px;
}

.rotor-side {
  position: absolute;
  background: var(--material-color-blue-grey-200);
  border-radius: 50%;
  /* backface-visibility: hidden; */
}

.rotor-side {
  transform: rotateY(90deg);
}

.rotor-side-contact {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  background: var(--material-color-brown-800);
}

.reflector {
  position: relative;
  height: 100%;
  width: 80px;
  margin-right: 30px;
  transform-style: preserve-3d;
  perspective: 300px;
  z-index: 3;
}

.reflector-surface {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 80px;
  /* background: linear-gradient(
    to left,
    var(--material-color-grey-400) 10%,
    var(--material-color-grey-300),
    var(--material-color-grey-400) 90%
  ); */
  background: linear-gradient(
    to left,
    #d5d7e5,
    #eee 20%,
    #d5d7e5 60%,
    #dfdfdf 80%,
    #d5d7e5 95%
  );
  border-left: 0.15px solid var(--material-color-grey-400);
  border-right: 0.15px solid var(--material-color-grey-400);
}

.reflector-label {
  background-color: var(--material-color-red);
  font-family: sans-serif;
  font-size: 15px;
  background-clip: text;
  -webkit-background-clip: text;
  -moz-background-clip: text;
  color: transparent;
  text-shadow: rgba(13, 13, 13, 0.3) 0px 0.3px 0.3px;
}

.rotorboard {
  background: var(--material-color-blue-grey-50);
}

.lamp {
  background: var(--material-color-blue-grey-50);
  color: var(--material-color-blue-grey-800);
  font-family: sans-serif;
  font-weight: bold;
  font-size: 16px;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  margin: 10px;
  z-index: 3;
}

.lamp-on {
  background: var(--material-color-amber-200);
  box-shadow: 0 0 10px var(--material-color-amber-600);
}

.lampboard {
  background: var(--material-color-grey-700);
  padding: 5px;
}

.key {
  position: relative;
  height: 40px;
  width: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  border: 2px solid var(--material-color-blue-grey-100);
  background: var(--material-color-grey-800);
  color: var(--material-color-grey-50);
  font-family: sans-serif;
  font-weight: bold;
  font-size: 26px;
  text-shadow: var(--material-color-lime-900) 2px 2px 5px;
  margin: 10px 5px;
  z-index: 3;
}

.key:hover, .key[clicked="true"] {
  background: var(--material-color-lime-900);
  cursor: pointer;
}

.key:active, .key[clicked="true"] {
  color: var(--material-color-grey-300);
}

.keyboard {
  background: var(--material-color-grey-700);
}

.socket {
  border: 3px solid var(--material-color-grey-300);
  background: var(--material-color-grey-900);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  position: relative;
  top: 10px;
  width: 16px;
  height: 16px;
  margin: 18px;
  z-index: 3;
}

.socket-label {
  position: relative;
  top: -25px;
  color: white;
  font-family: sans-serif;
  font-weight: bold;
  font-size: 1rem;
}

.plugboard {
  background: var(--material-color-grey-700);
}

.plugboard svg {
  z-index: 3;
  overflow: visible;
}

.plug {
  fill: var(--material-color-grey-800);
  stroke: var(--material-color-grey-700);
  stroke-width: 0.5;
}

.switch-cable {
  fill: none;
  stroke: var(--material-color-grey-800);
  filter: drop-shadow(0 2px 10px var(--material-color-grey-500)) sepia(40%)
    blur(0.5px);
  stroke-linejoin: round;
  stroke-width: 7;
}

.wire {
  fill: none;
  stroke-linecap: round;
  stroke-width: 0;
  stroke: var(--material-color-amber-700);
}


.electron {
  position: absolute;
  top: 0;
  left: 0;
  width: 1.5rem;
  height: 1.5rem;
  font-size: 1.2rem;
  background-color: var(--material-color-amber-700);
  color: var(--material-color-grey-50);
  vertical-align: baseline;
  text-align: center;
  font-family: monospace;
  border-radius: 100%;
  z-index: 2;
}

.plugboard .electron {
  z-index: 4;
}

@keyframes followwire {
  0% {
    transform: scale(0);
    offset-distance: 0%;
  }
  20% {
    transform: scale(1);
    offset-distance: 20%;
  }
  80% {
    transform: scale(1);
    offset-distance: 80%;
  }
  to {
    transform: scale(0);
    offset-distance: 100%;
  }
}

.legend {
  text-align: center;
  width: 100%;
  padding: 1rem 1rem;
  order: 5;
  grid-column: 1 / span var(--panels-row);
  font-family: monospace;
  font-size: 1em;
  color: var(--material-color-grey-600);
}

.legend kbd {
  padding: 0.1875em 0.475em;
  font-size: .75em;
  color: #fff;
  background-color: var(--material-color-grey-600);
  border-radius: 0.1rem;
  vertical-align: middle;
}

@media (max-width: 950px) {
  :root {
    --panels-row: 1;
  }

  .rotorboard {
    order: 1;
  }

  .lampboard {
    order: 2;
  }

  .keyboard {
    order: 3;
  }

  .plugboard {
    order: 4;
  }

  .lampboard .port-bottom-right {
    left: 0;
    right: unset;
  }
}

@media (min-width: 1300px) {
  :root {
    --panel-width: 600px;
    --panel-height: 270px;
  }

  .enigma {
    gap: 75px 50px;
  }

  .lamp {
    font-size: 24px;
    width: 40px;
    height: 40px;
    line-height: 40px;
    margin: 10px;
  }

  .key {
    height: 50px;
    width: 50px;
    font-size: 30px;
  }

  .socket {
    top: 20px;
    width: 20px;
    height: 20px;
    margin: 23px;
  }
  
  .socket-label {
    top: -30px;
    font-size: 1.5rem;
  }

  .rotor {
    width: 45px;
    margin: 25px;
  }
}
