/* ============================================================
   melt.graphics experiment — estética Amiga Workbench 1.x
   Paleta clásica 4 colores: azul, blanco, negro, naranja
   ============================================================ */
@font-face {
  font-family: "Topaz";
  src: url("fonts/TopazPlus_a500.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --wb-blue:   #0055AA;
  --wb-white:  #FFFFFF;
  --wb-black:  #000000;
  --wb-orange: #FF8800;
  --titlebar-h: 24px;
  --menubar-h: 24px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--wb-blue);
  font-family: "Topaz", "Courier New", "Lucida Console", monospace;
  font-weight: normal;
  /* Topaz a500 es 8x16px con unitsPerEm=1600 => NÍTIDA solo a 16px
     (o múltiplos: 32, 48). A otros tamaños se "comen" columnas. */
  font-size: 16px;
  line-height: 1;
  -webkit-font-smoothing: none;
  font-smooth: never;
  text-rendering: optimizeSpeed;
  -webkit-user-select: none;
  user-select: none;
  /* evita scroll/zoom por gestos en móvil */
  touch-action: none;
  overscroll-behavior: none;
  position: fixed;
  inset: 0;
}

/* ---------- Barra de menú superior ---------- */
#menubar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--menubar-h);
  background: var(--wb-white);
  color: var(--wb-black);
  border-bottom: 2px solid var(--wb-black);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-size: 16px;
  z-index: 100000;
  white-space: nowrap;
}
#menubar-mem { opacity: 0.85; }

/* ---------- Iconos de programa (escritorio) ---------- */
/* Viven DETRÁS de las ventanas; al cerrar una ventana, su icono la reabre. */
#icons {
  position: fixed;
  top: calc(var(--menubar-h) + 12px);
  right: 14px;
  z-index: 1;                /* por detrás de las ventanas */
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.icon {
  display: flex;
  flex-direction: column;
  align-items: center;      /* glyph y label centrados sobre el mismo eje */
  cursor: pointer;
}
/* glyph inspirado en el logo Melt: rectángulo naranja con agujeros blancos */
.icon-glyph {
  width: 46px; height: 38px;
  background: var(--wb-orange);
  border: 2px solid var(--wb-black);
  border-radius: 3px;
  position: relative;
}
.hole {
  position: absolute;
  width: 8px; height: 8px;
  background: var(--wb-blue);   /* agujeros = se ve el azul del escritorio */
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.icon-label {
  margin-top: 4px;
  font-size: 16px;
  color: var(--wb-white);
  background: var(--wb-blue);
  white-space: nowrap;
  display: inline-block;
  padding: 0 2px;
}
/* icono atenuado cuando su ventana está abierta */
.icon.open { opacity: 0.55; }

/* ---------- Escritorio ---------- */
#desktop {
  position: fixed;
  top: var(--menubar-h);
  left: 0; right: 0; bottom: 0;
  z-index: 2;            /* contexto de apilado SIEMPRE por encima de #icons */
  pointer-events: none;  /* deja pasar los clics al escritorio (iconos) ... */
}
.win { pointer-events: auto; }   /* ... pero las ventanas sí los reciben */

/* ---------- Ventana Workbench ---------- */
.win {
  position: absolute;
  background: var(--wb-blue);
  border: 2px solid var(--wb-black);
  box-shadow: 0 0 0 1px var(--wb-white) inset;
  display: flex;
  flex-direction: column;
  min-width: 120px;
  min-height: 90px;
  touch-action: none;
}

.win-titlebar {
  height: var(--titlebar-h);
  background: var(--wb-white);
  border-bottom: 2px solid var(--wb-black);
  display: flex;
  align-items: stretch;
  flex: 0 0 auto;
  cursor: grab;
}
.win-titlebar:active { cursor: grabbing; }

/* Gadget de cerrar (izquierda) */
.gadget-close {
  width: var(--titlebar-h);
  flex: 0 0 auto;
  background: var(--wb-white);
  border-right: 2px solid var(--wb-black);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.gadget-close::after {
  content: "";
  width: 9px; height: 9px;
  background: var(--wb-blue);
  border: 2px solid var(--wb-black);
}

/* Título (ancho según el texto) */
.win-title {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  padding: 0 6px 0 8px;
  font-size: 16px;
  color: var(--wb-black);
  white-space: nowrap;
  overflow: hidden;
}

/* Zona de arrastre con la banda de 3 líneas horizontales (estilo Amiga).
   Deja aire tras el título y antes del gadget de maximizar. */
.win-dragbar {
  flex: 1 1 auto;
  position: relative;
  min-width: 0;
}
.win-dragbar::before {
  content: "";
  position: absolute;
  left: 6px; right: 6px;          /* aire a ambos lados */
  top: 50%;
  transform: translateY(-50%);
  height: 13px;                   /* 3 líneas (período 5px) */
  background: repeating-linear-gradient(
    to bottom, var(--wb-black) 0 2px, transparent 2px 5px);
}

/* Gadget de profundidad (derecha): dos cuadrados superpuestos */
.gadget-depth {
  width: calc(var(--titlebar-h) + 6px);
  flex: 0 0 auto;
  background: var(--wb-white);
  border-left: 2px solid var(--wb-black);
  position: relative;
  cursor: pointer;
}
.gadget-depth::before,
.gadget-depth::after {
  content: "";
  position: absolute;
  width: 12px; height: 9px;
  border: 2px solid var(--wb-black);
  background: var(--wb-white);
}
.gadget-depth::before { top: 3px;  left: 4px; background: var(--wb-blue); }
.gadget-depth::after  { bottom: 3px; right: 4px; }

/* Contenido = lienzo del OP art */
.win-content {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  background: var(--wb-black);
  min-height: 0;
}
.win-content canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Borde inferior Amiga: slider + gadget de resize ---------- */
.win-footer {
  height: 22px;
  flex: 0 0 auto;
  background: var(--wb-white);
  border-top: 2px solid var(--wb-black);
  display: flex;
  align-items: stretch;
}

/* Slider proporcional Amiga (modifica un parámetro del algoritmo) */
.win-slider {
  flex: 1 1 auto;
  position: relative;
  margin: 3px 4px;
  background: var(--wb-blue);
  border: 2px solid var(--wb-black);
  cursor: pointer;
  touch-action: none;
  overflow: hidden;
}
.slider-knob {
  position: absolute;
  top: 0; bottom: 0;
  left: 0;
  width: 28px;
  background: var(--wb-white);
  border-right: 2px solid var(--wb-black);
  border-left: 2px solid var(--wb-black);
  box-sizing: border-box;
}
.slider-knob::after {       /* franja naranja central del tirador */
  content: "";
  position: absolute;
  top: 2px; bottom: 2px; left: 50%;
  width: 6px; margin-left: -3px;
  background: var(--wb-orange);
}

/* Gadget de redimensionar (esquina inferior derecha del borde) */
.gadget-resize {
  flex: 0 0 auto;
  width: 22px;
  align-self: stretch;
  background: var(--wb-white);
  border-left: 2px solid var(--wb-black);
  position: relative;
  cursor: nwse-resize;
  touch-action: none;
}
.gadget-resize::after {
  content: "";
  position: absolute;
  right: 3px; bottom: 3px;
  width: 9px; height: 9px;
  border-right: 2px solid var(--wb-black);
  border-bottom: 2px solid var(--wb-black);
}
