/* kaleidoscope.css V1.13 2026-06-27 */

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: #111; color: #eee; font-family: sans-serif; display: flex; height: 100vh; overflow: hidden; }

#canvas-area {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #0a0a0a; overflow: hidden; position: relative;
}
canvas { display: block; max-width: 100%; max-height: 100vh; border-radius: 4px; }

#panel {
  /* Responsive width: roomier on big displays, compact on small ones. The
     Wide Panel menu toggle bumps it up another notch (see body.wide-panel). */
  width: clamp(200px, 16vw, 300px); flex-shrink: 0;
  background: #1a1a1a; border-left: 1px solid #2a2a2a;
  display: flex; flex-direction: column; padding: 10px 10px; gap: 4px;
  overflow-y: auto; overflow-x: hidden; height: 100vh;
}
body.wide-panel #panel { width: clamp(280px, 26vw, 460px); }

/* Panel side — flip the whole row so the control panel sits on the left. */
body.panel-left { flex-direction: row-reverse; }
body.panel-left #panel { border-left: none; border-right: 1px solid #2a2a2a; }
#thumb-wrap {
  /* Square thumbnail, capped so the image AND the X/Y controls below always fit
     the viewport: fills the panel column on tall screens, shrinks on short ones
     so nothing is pushed off the bottom. 175px ≈ the panel content width.
     The tracks are sized to --side (not 1fr/auto) so the Y slider sits flush
     against the thumbnail with no gap, and gets a definite height to render. */
  /* Square thumbnail = min(panel-width budget, screen-height budget), using
     only lengths (vw/vh/px) so the column and row stay equal — always square,
     Y slider keeps a definite height. Width budget fills the panel (no dead
     space beside it); height budget shrinks it on short screens so the controls
     below stay on-screen. Wide Panel widens the width budget to match. */
  --wbudget: calc(clamp(200px, 16vw, 300px) - 45px);
  --hbudget: calc(100vh - 500px);
  --side: clamp(110px, min(var(--wbudget), var(--hbudget)), 420px);
  display: grid;
  grid-template-columns: var(--side) 22px;
  grid-template-rows: var(--side) 28px;
  gap: 3px;
  flex-shrink: 0;
}
body.wide-panel #thumb-wrap { --wbudget: calc(clamp(280px, 26vw, 460px) - 45px); }
#thumb-wrap .thumb-cell {
  position: relative; background: #0a0a0a; border-radius: 4px; overflow: hidden;
  cursor: grab;
}
#thumb-wrap .thumb-cell.grabbing { cursor: grabbing; }
h1 { font-size: 0.95rem; font-weight: 300; letter-spacing: 4px; text-transform: uppercase; color: #666; text-align: center; }

#version { font-size: 0.55rem; letter-spacing: 1px; color: #444; vertical-align: super; }

#img-stats { font-size: 0.68rem; color: #555; text-align: center; line-height: 1.4; min-height: 1em; }

#drop-zone {
  border: 2px dashed #333; border-radius: 6px; padding: 16px 8px;
  cursor: pointer; color: #555; text-align: center; font-size: 0.8rem;
  transition: border-color 0.2s; line-height: 1.4;
}
#drop-zone.over { border-color: #88f; color: #aaf; }
#file-input { display: none; }

/* Slider-row containers are render targets only — display: contents keeps
   the rows direct participants in the panel flex layout */
#sliders-top, #sliders-color { display: contents; }

.ctrl-row { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.ctrl-row .lbl { color: #777; font-size: 0.75rem; min-width: 52px; flex-shrink: 0; }
.ctrl-row input[type=range] { flex: 1; accent-color: #88f; min-width: 0; }
.ctrl-row .val { color: #ccc; font-size: 0.8rem; min-width: 30px; text-align: right; flex-shrink: 0; }

.step-btn {
  background: #252525; border: 1px solid #444; color: #aaa;
  width: 22px; height: 22px; border-radius: 3px; cursor: pointer;
  font-size: 0.75rem; line-height: 1; padding: 0; flex-shrink: 0; user-select: none;
}
.step-btn:hover { background: #333; color: #fff; }
.step-btn:active { background: #444; }

.divider { border: none; border-top: 1px solid #2a2a2a; }
.divider-tight { margin: 2px 0; }

.action-btn {
  width: 100%; background: #252525; border: 1px solid #444; color: #ccc;
  padding: 8px; border-radius: 4px; cursor: pointer; font-size: 0.82rem; text-align: center;
}
.action-btn:hover { background: #333; color: #fff; }

/* Choose button + mode toggle share one row under the title */
#top-row { display: flex; gap: 6px; align-items: stretch; }
#top-row #file-btn { flex: 0 0 auto; width: auto; padding: 6px 10px; font-size: 1rem; line-height: 1; white-space: nowrap; }
#top-row #mode-toggle { flex: 1; }

/* Muted row — a slider that has no effect in the current mode (e.g. Segments
   in Tile): visible for context but faded and inert. */
.ctrl-row.muted { opacity: 0.35; pointer-events: none; }

/* Mode toggle */
#mode-toggle {
  display: flex; border: 1px solid #333; border-radius: 4px; overflow: hidden;
}
#mode-toggle button {
  flex: 1; background: #222; border: none; color: #666;
  padding: 6px 4px; cursor: pointer; font-size: 0.75rem; transition: background 0.15s;
}
#mode-toggle button.active { background: #383858; color: #aaf; }
#mode-toggle button:hover:not(.active) { background: #2a2a2a; color: #999; }

/* Thumbnail + X/Y slider grid */
#thumb { width: 100%; height: 100%; display: block; }
#thumb-box { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }

#y-col { display: flex; flex-direction: column; align-items: center; gap: 2px; }
#y-slider-wrap { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#oy { writing-mode: vertical-lr; accent-color: #88f; height: 100%; width: 20px; transform: scaleY(-1); }

#x-row { display: flex; align-items: center; gap: 3px; }
#ox { flex: 1; min-width: 0; accent-color: #88f; }

#xy-vals { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
#xy-vals .val { color: #ccc; font-size: 0.65rem; min-width: 30px; text-align: right; flex-shrink: 0; }

/* Paired button rows (B&W/Reset, Save/upscale) */
.btn-row { display: flex; gap: 6px; align-items: center; }
.btn-row .action-btn { flex: 1; }

#upscale {
  background: #252525; border: 1px solid #444; color: #ccc;
  padding: 6px 4px; border-radius: 4px; font-size: 0.82rem; cursor: pointer;
}

/* Preset hover menu — list reveals on hover, opens upward to stay in-panel */
.preset-menu { position: relative; flex: 1; min-width: 0; }
#preset-label { font-size: 0.82rem; padding: 8px 4px; }
#preset-list {
  display: none; position: absolute; bottom: 100%; left: 0; right: 0;
  background: #252525; border: 1px solid #444; border-radius: 4px;
  z-index: 10; overflow: hidden;
}
.preset-menu:hover #preset-list { display: block; }
.preset-item { padding: 7px 8px; font-size: 0.8rem; color: #ccc; cursor: pointer; }
.preset-item:hover { background: #383858; color: #aaf; }

#save-size { font-size: 0.68rem; color: #555; text-align: center; line-height: 1.4; min-height: 1em; }

#panel > * { flex-shrink: 0; }

:fullscreen #panel { display: none; }
:-webkit-full-screen #panel { display: none; }

/* Hamburger menu (top-right of the canvas area) */
#menu-btn {
  position: absolute; top: 10px; right: 10px; z-index: 50;
  width: 34px; height: 34px; border-radius: 4px; line-height: 1;
  background: rgba(26,26,26,0.85); border: 1px solid #444; color: #ccc;
  font-size: 1.1rem; cursor: pointer;
}
#menu-btn:hover { background: #333; color: #fff; }
#menu-panel {
  position: absolute; top: 50px; right: 10px; z-index: 50;
  background: #1f1f1f; border: 1px solid #3a3a3a; border-radius: 6px;
  display: flex; flex-direction: column; min-width: 160px; overflow: hidden;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.menu-item {
  background: none; border: none; color: #ccc; text-align: left;
  padding: 10px 14px; font-size: 0.85rem; cursor: pointer;
  text-decoration: none; font-family: inherit;
}
.menu-item:hover { background: #383858; color: #aaf; }

/* About modal */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: #1a1a1a; border: 1px solid #333; border-radius: 8px;
  max-width: 360px; width: 90%; padding: 22px 24px; color: #ccc;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  max-height: 86vh; overflow-y: auto;
}
.modal-box h2 {
  font-size: 1.1rem; font-weight: 400; letter-spacing: 2px;
  text-transform: uppercase; color: #aaf; margin-bottom: 4px;
}
.modal-box .tagline { color: #888; font-style: italic; margin-bottom: 14px; font-size: 0.85rem; }
.modal-box p { font-size: 0.82rem; line-height: 1.55; margin-bottom: 10px; color: #bbb; }
.modal-box a { color: #aaf; text-decoration: none; }
.modal-box a:hover { text-decoration: underline; }
.modal-meta { font-size: 0.75rem; color: #666; margin: 12px 0 4px; line-height: 1.6; }
.modal-close {
  margin-top: 14px; width: 100%; background: #252525; border: 1px solid #444;
  color: #ccc; padding: 9px; border-radius: 4px; cursor: pointer; font-size: 0.82rem;
}
.modal-close:hover { background: #333; color: #fff; }

.hidden { display: none !important; }
