/* a area de trabalho de mentira: papel de parede em pixel e a barra embaixo; a Caixa abre sozinha */
@font-face {
  font-family: "Pixelify";
  src: url("../arte/fontes/PixelifyVisita.ttf");
}

:root {
  --barra: 40px;
  --madeira: #3b2618;
  --madeira2: #4a3020;
  --madeira3: #5d3d29;
  --contorno: #1c120b;
  --clara: #f3e6cc;
  --apagada: #c2ab88;
  --realce: #f0c77a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #9fd3e8;
  font: 14px/1.2 "Pixelify", "Segoe UI", sans-serif;
  color: var(--clara);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  font-variant-ligatures: none;
}
button { font: inherit; color: inherit; }
body.ocupado, body.ocupado * { cursor: progress !important; }
html.sem-ponteiro, html.sem-ponteiro * { cursor: none !important; }

#papel {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#mesa {
  position: fixed;
  left: 0; top: 0; right: 0;
  bottom: calc(var(--barra) + env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}

/* ─── a Caixa: transparente, por cima de tudo; o mouse atravessa onde nao tem nada ─── */
#caixa {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0;
  background: transparent;
  pointer-events: none;
  z-index: 50;
  color-scheme: normal;
}
#caixa.saindo { visibility: hidden; }

/* ─── as janelas (o atelie) ─── */
#janelas { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.janela {
  position: absolute;
  display: flex; flex-direction: column;
  min-width: 260px; min-height: 160px;
  background: var(--madeira);
  border: 2px solid var(--contorno);
  box-shadow: 4px 4px 0 rgba(28, 18, 11, 0.38);
  pointer-events: auto;
}
.janela[hidden] { display: none; }
.janela.cheia { box-shadow: none; border-width: 0; }
.janela .titulo {
  flex: none;
  height: 30px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 0 0 8px;
  background: var(--madeira2);
  border-bottom: 2px solid var(--contorno);
  box-shadow: inset 0 2px 0 var(--madeira3);
  color: var(--apagada);
  touch-action: none;
}
.janela.ativa .titulo { background: #6b4528; box-shadow: inset 0 2px 0 #87593a; color: var(--clara); }
.janela .titulo img { width: 18px; height: 18px; image-rendering: pixelated; pointer-events: none; }
.janela .titulo h2 { flex: 1; margin: 0; font-size: 15px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.janela .botoes { display: flex; height: 100%; }
.janela .botoes button {
  width: 40px; height: 100%;
  display: grid; place-items: center;
  background: none; border: 0; border-left: 2px solid rgba(28, 18, 11, 0.5);
  padding: 0;
  cursor: pointer;
}
.janela .botoes button:hover { background: rgba(255, 240, 210, 0.14); }
.janela .botoes button.fecha:hover { background: #a3442c; }
.janela .botoes canvas { width: 10px; height: 10px; image-rendering: pixelated; pointer-events: none; }
.janela .corpo { position: relative; flex: 1; overflow: hidden; background: #4a2f1d; }
.janela .corpo iframe {
  position: absolute; left: 0; top: 0;
  border: 0;
  transform-origin: 0 0;
  background: #4a2f1d;
}
.janela .borda { position: absolute; z-index: 2; touch-action: none; }
.janela.cheia .borda { display: none; }
.borda.n { top: -5px; left: 6px; right: 6px; height: 8px; cursor: ns-resize; }
.borda.s { bottom: -5px; left: 6px; right: 6px; height: 8px; cursor: ns-resize; }
.borda.o { left: -5px; top: 6px; bottom: 6px; width: 8px; cursor: ew-resize; }
.borda.l { right: -5px; top: 6px; bottom: 6px; width: 8px; cursor: ew-resize; }
.borda.no { left: -5px; top: -5px; width: 12px; height: 12px; cursor: nwse-resize; }
.borda.se { right: -5px; bottom: -5px; width: 12px; height: 12px; cursor: nwse-resize; }
.borda.ne { right: -5px; top: -5px; width: 12px; height: 12px; cursor: nesw-resize; }
.borda.so { left: -5px; bottom: -5px; width: 12px; height: 12px; cursor: nesw-resize; }

/* ─── a barra de baixo ─── */
#barra {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--barra) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex; align-items: stretch;
  background: var(--madeira);
  border-top: 2px solid var(--contorno);
  box-shadow: inset 0 2px 0 var(--madeira3);
  z-index: 60;
}
#tarefas { flex: 1; display: flex; gap: 4px; padding: 5px 6px 4px; min-width: 0; overflow: hidden; }
.tarefa {
  display: flex; align-items: center; gap: 6px;
  min-width: 0; max-width: 200px;
  padding: 0 10px 0 7px;
  background: var(--madeira2);
  border: 2px solid var(--contorno);
  box-shadow: inset 0 2px 0 var(--madeira3);
  cursor: pointer;
}
.tarefa:hover { background: #57392a; }
.tarefa.ativa { background: #6b4528; box-shadow: inset 0 -2px 0 var(--realce); }
.tarefa img { width: 18px; height: 18px; image-rendering: pixelated; flex: none; }
.tarefa span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#bandeja { display: flex; align-items: center; gap: 2px; padding: 0 10px 0 6px; border-left: 2px solid rgba(28, 18, 11, 0.6); }
#bandejaCaixa {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  padding: 0;
  background: none; border: 1px solid transparent;
  cursor: pointer;
}
#bandejaCaixa:hover, #bandejaCaixa[aria-expanded="true"] { background: rgba(255, 240, 210, 0.12); border-color: rgba(255, 240, 210, 0.2); }
#bandejaCaixa img { width: 22px; height: 22px; image-rendering: pixelated; pointer-events: none; }
#relogio {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center;
  min-width: 52px; padding-left: 8px;
  color: var(--clara);
}
#hora { font-size: 15px; line-height: 15px; }
#data { font-size: 11px; line-height: 13px; color: var(--apagada); }

/* ─── o menu da bandeja ─── */
.menu {
  position: fixed;
  min-width: 220px;
  padding: 4px;
  background: var(--madeira2);
  border: 2px solid var(--contorno);
  box-shadow: inset 0 2px 0 var(--madeira3), 4px 4px 0 rgba(28, 18, 11, 0.4);
  z-index: 70;
}
.menu[hidden] { display: none; }
.menu button {
  display: block; width: 100%;
  padding: 7px 12px 8px;
  text-align: left;
  background: none; border: 0;
  cursor: pointer;
}
.menu button:hover, .menu button:focus-visible { background: #8a5a2e; outline: none; }
.menu hr { border: 0; border-top: 2px solid rgba(28, 18, 11, 0.55); margin: 4px 2px; }

#recado {
  position: fixed;
  right: 12px; bottom: calc(var(--barra) + 12px + env(safe-area-inset-bottom, 0px));
  max-width: min(320px, calc(100vw - 24px));
  padding: 9px 12px 10px;
  background: var(--madeira2);
  border: 2px solid var(--contorno);
  box-shadow: inset 0 2px 0 var(--madeira3), 4px 4px 0 rgba(28, 18, 11, 0.4);
  z-index: 70;
}
#recado[hidden] { display: none; }

#veu { position: fixed; inset: 0; z-index: 80; }
#veu[hidden] { display: none; }

#ponteiro {
  position: fixed; left: 0; top: 0;
  width: 12px; height: 19px;
  pointer-events: none;
  z-index: 90;
  image-rendering: pixelated;
}
#ponteiro[hidden] { display: none; }

@media (pointer: coarse) {
  :root { --barra: 46px; }
  .janela .titulo { height: 38px; }
  .janela .botoes button { width: 46px; }
  .menu button { padding: 11px 14px 12px; }
}
