:root{
  --p:5px;
  --headerH:40px;
  --dark:#222;
  --darker:#000;
  --bright:#ddd;
  --brighter:#fff;
}
body{
  font:14px/1.2em "jetbrains mono", "liberation", sans-serif;
  color:black;
  background: var(--dark);
  padding-top: var(--headerH);
}

/* fresh install form */

.create_user {
  display: grid;
  place-content: center;
  position: fixed;
  inset: 0;
  z-index: 202;
}

.create_user form {
  border-radius: 10px;
  background: white;
  padding: 2em;
  display: flex;
  flex-direction: column;
  gap: 1em;
}
.create_user fieldset {
  background: white;
  display: flex;
  flex-direction: column;
  gap: .5em;
  border-radius: 5px;
}
.create_user form p {
  display: flex;
  gap: .5em;
}
.create_user form label {
  width: 6em;
}
.overlay {
  position: fixed;
  inset: 0;
  background: var(--dark);
  z-index: 201;
}


header{
  color:var(--bright);
  padding: var(--p);
  position: absolute;
  top:0;
  left:0;
  height: var(--headerH);
  background: var(--dark);
  width:100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}
header .group{
  align-items: center;
  width:clamp(200px, 25%, 500px);
  display: flex;
  justify-content: center;
}
header .group:first-child{justify-content: flex-start;}
header .group:nth-child(4){justify-content: flex-end;}
header .group >:not(:first-child){margin-left: var(--p);}

header .toggle.hidden{
  background:#777;
}
body.menu-opened .menu-btn::after{
  content:" ✕";
  position: relative;
  top:.1em;
}
header input[type="text"],header input[type="password"]{margin-left:var(--p);}
#login-form p:last-of-type{margin-left:var(--p)}
header .fork-btn, header .download-btn{display: none;}
/* existing project, created by someone else, or too old */
body.saved:not(.logged) .save-btn,
body.saved:not(.logged) .fork-btn {background: #777;}
body.saved .save{border:0;}
body.saved .fork-btn, body.saved .download-btn{display: block;}
.mark_as_saved { animation: mark_as_saved 1000ms ease-out 1 alternate forwards; }
@keyframes mark_as_saved {
  0% { background-color: var(--bright);}
  1% { background-color: limegreen;}
  90% { background-color: limegreen;}
  100% { background-color: var(--bright);}  
}
header .menu-container{
  display: none;
  width: max(25%, 300px);
  background: var(--dark);
  position: absolute;
  top: var(--headerH);
  right: 0;
  z-index: 300;
  padding:30px var(--p) var(--p) var(--p);
}
header .menu-container .menu-line{
  margin-bottom: calc(var(--p)*2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.menu-line{
  width: 100%;
  display: flex;
  justify-content: space-between;
}
.menu-line .editable {
  width: 50%;
}

body.menu-opened header .menu-container{
  display: block;
}

.container{
  height: calc(100vh - var(--headerH));
  position: relative;
  display: flex;
}
.pane{
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width:100%;
  height: calc(100vh - var(--headerH));
  transition:all .2s ease-out;
  border-right:1px solid var(--dark);
  flex: 1;
}
.pane.hidden{
  overflow: hidden;
  flex: 0 !important;
}
.pane::before{
  position: absolute;
  right: calc(var(--p) * 3);
  top:2px;
  color: #ccc;
  z-index: 200;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 1px;
}
.html-pane:before{content:"html";}
.css-pane:before{content:"css";}
.js-pane:before{content:"js";}

/* disable transition when resizing */
.resizing .pane { transition: none;}

.pane:first-child{border-left: 0;}
.editor,
.ace_editor{
  background-color: var(--darker); /* avoid white blinking */
  position: absolute;
  inset: 0;
  width: 100%;
}

/* Wrapper for three editors */
#editors {
  display: flex;
  flex-direction: row;
}
.output{
  height: 100%;
  width:100%;
  border:0;
  background: white;
}

/* Layout mode : vertical */
body[data-layout=vertical] #editors { flex: 3; }
body[data-layout=vertical] .output-pane { flex:1}

/* Layout mode : vertical-split */
body[data-layout=vertical-split] #editors { flex: 1; flex-direction: column;}
body[data-layout=vertical-split] .output-pane { flex:1}

/* Layout mode : horizontal */
body[data-layout=horizontal] .container{
  flex-direction: column;
}
body[data-layout=horizontal] .pane.hidden{
  width:auto;
  height:0px;
  flex: 0;
}
body[data-layout=horizontal] #editors {
  flex-direction: column;
  flex: 1;
}
/* Layout mode : horizontal-split */
body[data-layout="horizontal-split"] .container{
  flex-direction: column;
}
body[data-layout="horizontal-split"] .pane{
  height: auto; 
  flex: 1;
}
body[data-layout="horizontal-split"] .pane.hidden{
  width:0;
  height:auto;
  flex: 0;
}
body[data-layout="horizontal-split"] #editors {
  flex: 1;
}
.layout-line button{
  width:var(--p);
  height: var(--p);
  border:0;
  background: no-repeat center/90% 90%;
  opacity: .4;
  cursor:pointer;
}
.layout-line button:hover, .layout-line button.active{
  opacity: 1;
}
button[data-layout="vertical"]{background-image:url(../img/v.svg);}
button[data-layout="vertical-split"]{background-image:url(../img/vs.svg);}
button[data-layout="horizontal"]{background-image:url(../img/h.svg);}
button[data-layout="horizontal-split"]{background-image:url(../img/hs.svg);}

/* Resizers */
.flex-resizer {
  flex: 0 0 10px;
  background-color: var(--dark);
  background-repeat: no-repeat;
  background-position: center;
  border: none;
}

.flex-resizer {
  cursor: ew-resize;
  background-image: radial-gradient(circle, gray 3px, transparent 3px);
}
.flex-resizer:hover {
  background-image: radial-gradient(circle, var(--bright) 3px, transparent 3px);
}

body[data-layout=horizontal] .flex-resizer,
body[data-layout=vertical-split] #editors .flex-resizer,
body[data-layout=horizontal-split] #main>.flex-resizer {
  cursor: ns-resize;
}
 
/* hide resizers when… */
.hidden + .flex-resizer, /* following a hiddden pane */
#editors .flex-resizer:last-of-type:has(+ .hidden), /* wtf */
#editors :has(+ .hidden) .flex-resizer:last-of-type, /* is last of #editors and output is hidden */
#editors:has(~ .hidden) + .flex-resizer { display: none;} /* following output and output is hidden */

/* screenshots, the raw way */
input[type=file] {
  background: var(--bright);
}
.screenshot .output-pane {
  position: fixed;
  inset: 0;
  padding: 5vw;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 20000;
  height: 100vh;
  width: 100vw;
  border: none;
}
.screenshot .output-pane .output {
  aspect-ratio: 16/9;
  width: auto;
}
#upload { display: none;}
.screenshot #upload {
  position: absolute;
  display: flex;
  z-index: 20001;
  top: var(--p);
  left: var(--p);
  gap: var(--p);
}

/* login form */
#login-form { display: none;}
.loging #login-form, #login-form p {
  display: flex;
  gap: var(--p);
}
#login-form p {
  display: flex;
  margin: 0;
  gap: var(--p);
  align-items: baseline;
}
#login-form input[type=text], #login-form input[type=password]{ background: var(--bright); padding: 2px 2px; border: 1px solid transparent; color:var(--darker) }
.loging header { justify-content: flex-end; }
.loging header .group > *:not(form) {display: none;}
.button.logout{ background: var(--bright) url(../img/logout.svg) no-repeat center/46%; width:1.4em;}

.logged .login-btn,
.anonymous #logout-form { display: none; }


a{color:inherit; text-decoration: none;}
a:hover{text-decoration:underline;}

/* List page */
main.list{
  min-height: calc(100vh - var(--headerH));
  background: var(--bright);
  color: var(--dark);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  padding: var(--headerH) 20px 20px;
  position: relative;
}
.list-item {
  margin-bottom: var(--p);
  padding: var(--p);
  position: relative;
}
.list-item a:hover {
  background: none;
}
.list-item iframe{
  width:100%;
  height: 100%;
  position: absolute;
  border:0;
  background: white;
  z-index: 3;
  transition: opacity 250ms;
}

.list-item article:before{
  display: block;
  content:"preview";
  font-family: monospace;
  pointer-events: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: white;
  display: grid;
  place-content: center;
  z-index: 1;
  aspect-ratio: 16/9;
}
.list-item nav {
  display: flex;
  margin-bottom: var(--p);
  align-items: baseline;
}
.list-item article {
  aspect-ratio: 16/9;
  position: relative;
  box-shadow: 0 0 4px gray;
}
.list-item article img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}
.list-item article:hover img {
  opacity: 0;
  pointer-events: none;
}
.list-item .title{
  display: block;
  font-size:1.5em;
  line-height: 1.5em;
  position: relative;
  padding-inline: 1.2em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .title:before{
  content: "";
  width:.8em;
  height: .8em;
  left:0;
  top:0.4em;
  position: absolute;
  background: var(--dark);
  border-radius: 1em;
}
.list-item .rm-btn{
  display: none;
  font-size: 2em;
  line-height: .5;
}
body[data-cansave="1"] .list-item:hover .rm-btn{
  display: block;
}
.line {
  position: absolute;
  z-index: 10;
  pointer-events: none; 
  transform: translateY(calc(.22em + var(--p))) rotate(var(--rotate, 0deg));
}
path {
  fill: none;
  stroke: var(--dark);
  stroke-width: 2px;
  stroke-linecap: round;
  /* stroke-dasharray: 1em var(--p);  */
  /* filter: url("../img/noise.svg#noise") */
}

/* Player */
body.player{
  background: var(--bright);
  min-height: calc(100vh - var(--headerH));
}
body.player #version-frame{
  background: white;
  border:0;
  width:100%;
  height: calc(100vh - var(--headerH));
}

.button{
  color:var(--dark);
  background: var(--bright);
  padding:3px 10px 4px;
  border-radius: 10px;
  border: 0px;
  cursor: pointer;
}

.button:hover, .button:focus{
  background-color: var(--brighter);
  text-decoration: none;
}
.button:active{background: #ccc;}
.title{
  color:var(--dark);
  background: var(--bright);
  padding:2px 2px;
  border:1px solid transparent;
  width: 70%;
}
.title:hover, .title:focus{background:var(--brighter);}
.handle {background-color: var(--dark); }
.handle:hover {background-color: #000; }
::selection{background:yellow;}
header::selection{color:black;}

/* group of buttons */
.buttons-group {
  display: flex;
  gap: 1px;
}
.buttons-group .button { 
  border-radius: 0;
}
.buttons-group .button:first-child{
  border-radius: 10px 0 0 10px
}
.buttons-group .button:last-child{
  border-radius: 0 10px 10px 0;
}

svg.icon {
  display: block;
  width: 1em;
  height: 1em;
  margin: 0 -.1em 0 -.3em;
}
svg.icon path {
  stroke: black;
  stroke-width: 1px;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.templates-container {
  display: none;
  position: absolute;
  top: var(--headerH);
  right: 0;
  z-index: 300;padding: 0;
  flex-direction: column;
  gap: var(--p);
  align-items: end;
}
.templates-opened .templates-container { display: flex; }

/* monaco theme select */
select { 
  color: var(--dark); 
  padding: 3px 10px 4px; 
  border:none; 
  border-radius: 10px;
}

/* Editors */
.ace_gutter-cell.ace_error, .ace_gutter-cell.ace_warning{
  background: none;
}
.ace_gutter-cell.ace_error:before, .ace_gutter-cell.ace_warning:before{
  position: absolute;
  left: .1em;
  font-size: 1.5em;
}
.ace_gutter-cell.ace_error:before{
  content: "×";
  color: tomato;
}
.ace_gutter-cell.ace_warning:before{
  content: "!";
  left: .5em;
  font-size: 1em;
  color: orange;
}
.ace_gutter{
  background: #000!important;
  color:#444!important;
}
.ace_gutter-active-line, .ace_active-line{
  background: #131313!important;
  color:#aaa;
}
.ace_scrollbar-h {
  overflow: hidden;
}

/* Poster */
body.poster{
  background: white;
  padding-top:0;
}
body.poster main{
  display:flex;
  flex-wrap:wrap;
  height: 100vh;
}
body.poster #version-frame{
  background: white;
  width:25%;
  height:25vw;
  border:0;
}

@media (max-width: 810px) {
  :root{
    --headerH:80px;
  }
  header{
    justify-content: space-between;
  }
}
@media (max-width: 600px) {
  :root{
    --headerH:100px;
  }
  header .group{width:100%; justify-content: space-between;}
}
