/* dotart — 1-bit retro-Mac aesthetic. Hard pixels everywhere: no radius,
   no blur, dithered patterns instead of gradients. */

:root {
  --ink: #111111;
  --paper: #ffffff;
  --bone: #f4f2ea;
  --accent: #2b4ff0;
  --accent-ink: #ffffff;
  --desk-a: #c9c9c4;
  --desk-b: #dededa;
  --dither-2: repeating-conic-gradient(var(--ink) 0% 25%, transparent 0% 50%);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --pixel: "Silkscreen", var(--mono);
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--mono);
  color: var(--ink);
  /* System-7 style 50% dither desktop */
  background: repeating-conic-gradient(var(--desk-a) 0% 25%, var(--desk-b) 0% 50%) 0 0 / 4px 4px;
  -webkit-font-smoothing: antialiased;
}

.desk {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px 16px;
}

/* ---------- window chrome ---------- */

.window {
  width: min(1560px, 94%);
  background: var(--paper);
  border: 2px solid var(--ink);
  position: relative;
  animation: window-in 0.35s steps(6) both;
}

/* dithered drop shadow */
.window::after {
  content: "";
  position: absolute;
  inset: 10px -12px -12px 10px;
  background: var(--dither-2) 0 0 / 4px 4px;
  z-index: -1;
}

@keyframes window-in {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
  user-select: none;
}

.stripes {
  flex: 1;
  height: 12px;
  background: repeating-linear-gradient(to bottom, var(--ink) 0 1px, transparent 1px 3px);
}

.title {
  font-family: var(--pixel);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1;
  padding: 0 6px;
}

.closebox, .zoombox {
  width: 13px;
  height: 13px;
  border: 2px solid var(--ink);
  background: var(--paper);
  flex: none;
}
.zoombox { position: relative; }
.zoombox::after {
  content: "";
  position: absolute;
  inset: 0 3px 3px 0;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}

/* ---------- split panes ---------- */

.split {
  display: grid;
  grid-template-columns: 1fr 320px;
}

.pane-image {
  position: relative;
  min-height: max(440px, 66vh);
  border-right: 2px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  /* checkerboard = "transparent canvas" */
  background: repeating-conic-gradient(#ececec 0% 25%, var(--paper) 0% 50%) 0 0 / 16px 16px;
  overflow: hidden;
}

.pane-image.dragging { outline: 4px dashed var(--accent); outline-offset: -10px; }

#preview {
  max-width: 100%;
  max-height: max(560px, 78vh);
  image-rendering: pixelated;
  border: 2px solid var(--ink);
  background: var(--paper);
}
#preview.original { filter: none; }

.pane-tools {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
}

/* drop hint */
.drop-hint {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px;
}

.hint-title { font-family: var(--pixel); font-size: 16px; letter-spacing: 1px; }
.hint-sub { font-size: 12px; color: #555; }
.hint-note { font-size: 11px; color: #777; line-height: 1.6; margin-top: 8px; }

/* pixel-art down arrow, drawn from box-shadows */
.pixel-arrow {
  width: 6px;
  height: 6px;
  background: transparent;
  /* the arrow is box-shadow pixels spanning 36x36px from this 6x6 box;
     reserve the overhang so flex centering aligns the visual shape */
  margin-right: 30px;
  margin-bottom: 30px;
  animation: bob 1.2s steps(2) infinite;
  box-shadow:
    12px 0 var(--ink), 18px 0 var(--ink),
    12px 6px var(--ink), 18px 6px var(--ink),
    12px 12px var(--ink), 18px 12px var(--ink),
    0 18px var(--ink), 6px 18px var(--ink), 12px 18px var(--ink),
    18px 18px var(--ink), 24px 18px var(--ink), 30px 18px var(--ink),
    6px 24px var(--ink), 12px 24px var(--ink), 18px 24px var(--ink), 24px 24px var(--ink),
    12px 30px var(--accent), 18px 30px var(--accent);
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

/* ---------- controls ---------- */

.pane-controls {
  padding: 22px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--bone);
}

.control { display: flex; flex-direction: column; gap: 8px; }
.control.disabled { opacity: 0.35; pointer-events: none; }

.control-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.control-head label, .control-head > label, .tint-color label, .tint-auto {
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 1px;
}

.control-head output {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  background: var(--paper);
  border: 2px solid var(--ink);
  padding: 0 6px;
  min-width: 34px;
  text-align: center;
}

/* sliders: square thumb, dithered filled track */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  --fill: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border: 2px solid var(--ink);
  background:
    linear-gradient(var(--accent), var(--accent)) 0 0 / var(--fill) 100% no-repeat,
    repeating-conic-gradient(#d6d3c6 0% 25%, var(--paper) 0% 50%) 0 0 / 4px 4px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 22px;
  margin-top: -8px;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: inset -3px -3px 0 #c9c6b8;
}
input[type="range"]::-moz-range-track {
  height: 10px;
  border: 2px solid var(--ink);
  background:
    linear-gradient(var(--accent), var(--accent)) 0 0 / var(--fill) 100% no-repeat,
    repeating-conic-gradient(#d6d3c6 0% 25%, var(--paper) 0% 50%) 0 0 / 4px 4px;
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 18px;
  border-radius: 0;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: inset -3px -3px 0 #c9c6b8;
}

/* segmented buttons */
.segmented { display: flex; }
.segmented button {
  flex: 1;
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 1px;
  padding: 7px 0 5px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-left-width: 0;
  cursor: pointer;
  color: var(--ink);
}
.segmented button:first-child { border-left-width: 2px; }
.segmented button.on {
  background: var(--ink);
  color: var(--paper);
}
.segmented button:not(.on):hover { background: var(--bone); }

/* tint pickers */
.tint { flex-direction: row; align-items: flex-end; gap: 12px; }
.tint-color { display: flex; flex-direction: column; gap: 6px; }
.tint-color.disabled { opacity: 0.35; pointer-events: none; }
.tint-auto { display: flex; align-items: center; gap: 6px; padding-bottom: 6px; cursor: pointer; }
.tint-auto input { accent-color: var(--accent); }

input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 46px;
  height: 30px;
  border: 2px solid var(--ink);
  background: var(--paper);
  padding: 2px;
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; }
input[type="color"]::-moz-color-swatch { border: none; }

/* palette swatches */
.palette {
  display: flex;
  flex-wrap: wrap;
  min-height: 18px;
}
.swatch {
  width: 18px;
  height: 18px;
  border: 1px solid var(--ink);
  margin: 0 -1px -1px 0;
  cursor: copy;
  padding: 0;
}
.swatch:hover { transform: scale(1.35); position: relative; z-index: 1; }

/* buttons */
.btn {
  font-family: var(--pixel);
  font-size: 12px;
  letter-spacing: 1px;
  padding: 9px 16px 7px;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--bone); }
.btn:active:not(:disabled), .btn.on {
  transform: translate(3px, 3px);
  box-shadow: none;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.btn-small { font-size: 10px; padding: 6px 10px 4px; box-shadow: 2px 2px 0 var(--ink); }
.btn-small:active:not(:disabled), .btn-small.on { transform: translate(2px, 2px); }

.btn-export {
  margin-top: auto;
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--ink);
  padding: 12px 16px 10px;
  font-size: 13px;
}
.btn-export:hover:not(:disabled) { background: #1d3fd6; }

/* ---------- status bar ---------- */

.statusbar {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 2px solid var(--ink);
  padding: 7px 12px;
  font-size: 11px;
  letter-spacing: 0.5px;
  background: var(--paper);
  min-height: 32px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border: 2px solid var(--ink);
  flex: none;
}
.status-dot[data-mode="busy"] { background: var(--dither-2) 0 0 / 4px 4px; animation: blink 0.6s steps(2) infinite; }
.status-dot[data-mode="ok"], .status-dot[data-mode="idle"] { background: var(--accent); }
.status-dot[data-mode="err"] { background: #d22; }

@keyframes blink { 50% { opacity: 0.2; } }

.status-right { margin-left: auto; color: #666; }
.status-right a { color: var(--accent); text-decoration: none; }
.status-right a:hover { text-decoration: underline; }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .split { grid-template-columns: 1fr; }
  .pane-image { border-right: none; border-bottom: 2px solid var(--ink); min-height: 300px; }
  .statusbar { flex-wrap: wrap; }
}
