/* sprite_editor.css -- THE PIXEL EDITOR's own styling (prototype/sprite_editor.js), split out of
   topdown.css (Jon, URGENT, 2026-10-03: "the palette shows as a bunch of enormous colours on
   Windows... totally different layout... pretty fucked up on Mac" -- the editor opened from the
   SPRITE HUB embed, 28cc091).
   REAL ROOT CAUSE (the "CSS not loaded by the hub" hypothesis was wrong -- reproduced live first: the
   SAME giant-swatch layout happens in the real in-game editor too, via its own ?editSprite= deep link,
   before this file existed at all): SpriteEditor.mount() writes canvas/toolbar/palette/full-palette/
   resize-dialog as FLAT SIBLINGS directly into its container, with no internal wrapper separating
   "canvas area" from "sidebar". topdown.html's own .edRight/#edRightPanel div (next to the mount point)
   holds the item-duplication form -- a SEPARATE thing -- so the palette the module itself creates lands
   inside the WIDE canvas column instead, and a 6-column grid dividing ~1000px evenly gives ~170px
   swatches. Fixed with ONE new wrapper the module itself creates, .edSidebar (below), narrow and
   positioned absolute on the canvas's own right edge -- works identically regardless of what the HOST's
   own surrounding markup looks like, so this is the real, structural fix, not a relocation.
   Every editor rule now lives HERE, linked by BOTH topdown.html and sprite_hub.html, so the module looks
   identical wherever it's mounted -- not two near-duplicate rule sets that can drift. design.css's tokens
   (--accent/--panel/--line/--ink/--warm/--bad/--progress/--on-solid) are assumed already loaded by
   whichever page links this. */
.editorPanel { position: fixed; inset: 0; background: #0d0a12ee; z-index: 40; display: flex; flex-direction: column; font: 13px/1.4 "Atkinson Hyperlegible", system-ui, sans-serif; color: var(--ink); }
.editorPanel.hint .edCanvasWrap { outline: 2px dashed var(--warm); outline-offset: 4px; }
.edHeader { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 2px solid var(--line); }
.edHeader b { font-family: "Silkscreen", monospace; color: var(--accent); }
.edHeader .grow { flex: 1; }
/* close X (Jon, 2026-10-03: every dialog's close text becomes the X): the editor's own exit control was
   already pushed top-right by .grow, just styled as "Close" text -- this is purely the look, same button,
   same id, same closeEditor() handler. */
#edName { width: 160px; font: 400 10px "Silkscreen", monospace; background: var(--panel); color: var(--ink); border: 2px solid var(--line); padding: 3px 6px; }
.edSaveDot { width: 8px; height: 8px; border-radius: 50%; background: #6c6478; }
.edSaveDot.saving { background: var(--warm); }
.edSaveDot.saved { background: var(--progress); }
.edSaveDot.nodb { background: var(--bad); }
.edSaveMsg { font: 400 10px "Silkscreen", monospace; color: var(--bad); }
.edBody { flex: 1; display: flex; min-height: 0; }
/* the canvas wrap fills .edCenter by ABSOLUTE positioning against it (inset:0), not a percentage
   height -- a flex column child sized via width/height:100% can resolve to 0x0 depending on how the
   browser treats the ancestor chain's height as "definite", silently killing every click in Edit mode
   (Jon: "I clicked... and nothing happened"). inset:0 against a sized, position:relative parent has no
   such ambiguity. */
.edCenter { flex: 1; min-width: 0; min-height: 0; position: relative; }

/* LAYOUT (Planner's editor_layout.txt, Jon's corrections 1-3, 2026-10-03): "the bottom looks cluttered" --
   13 equal buttons used to sit ON the canvas. Fixed, four places around it, nothing overlapping: a LEFT
   TOOL RAIL, a TOP BAR over the canvas column, a BOTTOM TIMELINE ROW under it, and the right palette --
   .edMain fills whatever position:relative box the host hands SpriteEditor.mount (.edCenter in-game,
   #spriteEdEngine in the hub), so the same three rules work in both without the host doing anything. */
.edMain { position: absolute; inset: 0; display: flex; min-height: 0; }
.edLeftRail { flex: 0 0 auto; width: 56px; display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 6px 4px; background: var(--panel); border-right: 2px solid var(--line); overflow-y: auto; }
.edRailDivider { height: 2px; background: var(--line); margin: 4px 2px; flex: 0 0 auto; }
/* every rail button shows icon + a visible NAME label + a small KEY BADGE in the corner (Jon's correction
   3: "You need to be able to look at those icons and see what does what" -- not just a hover title). */
.edRailBtn { position: relative; width: 100%; height: 50px; padding: 3px 0 2px; font-size: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; background: var(--panel); border: 1px solid transparent; }
/* Jon, 2026-10-03: "look at those icons and see what does what" -- badges/labels were readable only up
   close. Bumped a size across the board (rail/top bar/timeline alike). */
.edRailBtn .lbl { font-size: 9px; line-height: 1.1; text-transform: uppercase; letter-spacing: .02em; opacity: .9; }
.edRailBtn.active { background: var(--accent-wash); border-color: var(--accent); }
.edKeyBadge { position: absolute; top: 1px; right: 2px; font: 700 9px "Silkscreen", monospace; color: var(--soft); background: #0006; border-radius: 2px; padding: 0 3px; line-height: 1.3; pointer-events: none; }
.edTopBtn .edKeyBadge { position: static; margin-left: 2px; background: none; padding: 0; }

.edCenterCol { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.edTopBar { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; padding: 4px 8px; background: var(--panel); border-bottom: 2px solid var(--line); }
.edTopBar .grow { flex: 1; }
.edTopBtn { width: 32px; height: 32px; padding: 0; font-size: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; position: relative; }
#edKeysBtn, #edChecker, #edRulers, #edGuidesBtn, #edMirror { width: auto; height: 32px; padding: 0 7px; flex-direction: row; gap: 4px; font-size: 11px; }
.edTopBar button.active { background: var(--accent); color: var(--on-solid); }
.edTopBar .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .02em; }
.edZoomReadout { font: 400 11px "Silkscreen", monospace; color: var(--soft); padding: 0 6px; cursor: pointer; white-space: nowrap; }

.edCanvasWrap { flex: 1 1 auto; position: relative; min-height: 0; overflow: hidden; cursor: crosshair; }
.edCanvasWrap canvas { position: absolute; image-rendering: pixelated; }

/* BOTTOM TIMELINE ROW: line 1 (animation controls, only when the open set has a usable animation) + line
   2 (frame strip). A single-frame sprite shows no edFrameRow/edAnimLine1 at all -- #edTimelineRow itself
   collapses to 0 height via its children's own [hidden], never an empty bar. */
.edTimelineRow { flex: 0 0 auto; background: var(--panel); border-top: 2px solid var(--line); }
.edTimelineLine1 { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; font-size: 11px; }
.edTimelineLine2 { display: flex; align-items: center; gap: 8px; padding: 4px 8px; flex-wrap: wrap; }
#edFrameRow { display: flex; gap: 3px; align-items: stretch; flex: 0 0 auto; }
/* every timeline button shows icon + a visible NAME label (correction 3 applies here too, 2026-10-03) --
   same compact two-line shape as .edRailBtn, just wide enough for a short word instead of square. */
.edTimelineBtn { position: relative; width: auto; min-width: 38px; height: 38px; padding: 2px 6px 1px; font-size: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; background: var(--panel); border: 1px solid transparent; }
.edTimelineBtn .lbl { font-size: 9px; line-height: 1.1; text-transform: uppercase; letter-spacing: .02em; opacity: .9; }
.edTimelineBtn.active { background: var(--accent); color: var(--on-solid); }
.edTimelineBtn .edKeyBadge { position: static; margin: 0; background: none; padding: 0; }
.edFrameStrip { display: flex; gap: 4px; flex-wrap: wrap; flex: 1 1 auto; align-items: flex-end; }
.edFrameSlot { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.edFrameThumb { border: 2px solid var(--line); image-rendering: pixelated; background: #1e1826; cursor: pointer; }
.edFrameThumb.active { border-color: var(--accent); }
/* FRAME NUMBERS ARE EDITABLE (Jon's correction 1): small --soft text under each thumbnail; clicking turns
   it into an inline number input (decimals ok), Enter/blur commits and the strip re-sorts. */
.edFrameNum { font: 400 9px "Silkscreen", monospace; color: var(--soft); cursor: text; min-width: 14px; text-align: center; }
.edFrameNum input { width: 30px; font: 400 9px "Silkscreen", monospace; background: #1a1420; color: var(--ink); border: 1px solid var(--accent); text-align: center; }
.edAnimChip { font: 400 11px "Silkscreen", monospace; background: #1a1420; color: var(--ink); border: 1px solid var(--line); padding: 2px 6px; }
/* ANIMATION PICKER on the frame row itself (Jon, via Dispatcher, 2026-10-04) -- pushed to the row's right
   end with margin-left:auto, same visual weight as the other timeline buttons so it reads as part of the
   row, not a bolted-on afterthought. */
.edFrameRowAnimPicker { display: flex; align-items: stretch; gap: 3px; margin-left: auto; }
#edFrameAnimSelect { height: 38px; font: 400 11px "Silkscreen", monospace; background: #1a1420; color: var(--ink); border: 1px solid var(--line); padding: 0 6px; max-width: 160px; }
#edFrameAnimSelect:disabled { opacity: .6; cursor: default; }
.edAnimNote { font-size: 11px; color: var(--soft); font-style: italic; }
/* TIMELINE ALWAYS VISIBLE (Jon, via Dispatcher, 2026-10-03): disabled now means a sprite kind that
   genuinely can't animate/grow frames yet, not hidden -- readably dimmed, same shape every other disabled
   control in the game uses (topdown.css's own button:disabled). */
.edTimelineBtn:disabled, .edAnimChip:disabled { opacity: .4; cursor: default; }

.edTopBar button.active, .edTopBtn.active { background: var(--accent); color: var(--on-solid); border-color: var(--accent); }
.edRight { width: 200px; background: var(--panel); border-left: 2px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.edRight h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--soft); margin: 4px 0 2px; }
/* the palette is now a normal flex child of .edMain (after the centre column), not absolutely positioned
   against the canvas -- .edMain's own flex row already reserves this space, so nothing ever overlaps. */
.edPaletteSection { flex: 0 0 200px; box-sizing: border-box; background: var(--panel); border-left: 2px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
/* POP-OUT (Jon's spec, item 2.2, bcb86bd): edApplyPalettePopState toggles this class and sets left/top
   inline -- the CSS here only needs to stop anchoring to the canvas edge and look like a floating panel. */
.edPaletteSection.popped { position: fixed; top: auto; right: auto; bottom: auto; width: 220px; max-height: 70vh; border: 2px solid var(--accent); box-shadow: 0 8px 24px #000a; z-index: 10; }
.edPaletteHeader { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: move; padding: 2px 6px; margin: -10px -10px 4px; background: var(--accent-wash); }
.edPaletteHeader span { font: 400 11px "Silkscreen", monospace; color: var(--accent); }
.edPaletteHeader button { padding: 2px 6px; }
.edPaletteSection h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--soft); margin: 4px 0 2px; display: flex; align-items: center; gap: 4px; }
.edSmallBtn { font-size: 9px; padding: 2px 5px; }
.edTransparentSwatch { cursor: pointer; margin-left: auto; }
.edPalette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
.edPalette span { aspect-ratio: 1; border: 2px solid transparent; cursor: pointer; border-radius: 2px; }
.edPalette span.sel { border-color: var(--warm); }
.edFullPalette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; opacity: .8; }
.edFullPalette span { aspect-ratio: 1; cursor: pointer; border: 2px solid transparent; border-radius: 2px; }
.edFullPalette span.sel { border-color: var(--warm); }
.edCurColor { display: flex; align-items: center; gap: 8px; }
.edCurColor .sw { width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 3px; }
/* RULERS + GUIDES (Jon, via Dispatcher, 2026-10-03): the ruler strips are overlay canvases (own 2D
   context, drawn in edDrawRulers) -- the CSS here only positions/hides them, it never draws anything. */
.edRulerOverlay { position: absolute; top: 0; left: 0; image-rendering: pixelated; pointer-events: none; }
.edGuideWrap { position: relative; display: inline-flex; }
.edGuidePopover { position: absolute; bottom: 100%; left: 0; margin-bottom: 4px; background: var(--panel); border: 2px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 4px; white-space: nowrap; z-index: 3; font-size: 11px; }
.edGuidePopover label { display: flex; align-items: center; gap: 6px; color: var(--ink); cursor: pointer; }
.edGuidePopover input[type=checkbox] { accent-color: var(--accent); }
/* KEYS & MOUSE (editor_layout.txt §5, Jon's correction 2/3, 2026-10-03): a design.css card dialog, three
   keyboard sections + a mouse section of segmented chips (not <select>s), click a key chip to capture the
   next keydown, or just hover ANY action button/row elsewhere and press a key -- both rebind the same way. */
.edKeysDlg { width: 420px; max-width: 92vw; max-height: 86vh; overflow-y: auto; background: var(--panel); border: 2px solid var(--line); color: var(--ink); padding: 14px 16px; }
.edKeysDlg h3 { font: 700 13px "Pixelify Sans", monospace; color: var(--accent); margin: 0 0 8px; }
.edKeySection { margin-bottom: 10px; }
.edKeySectionTitle { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--soft); margin-bottom: 4px; }
.edKeyRow { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.edKeyRowLabel { flex: 1; font-size: 12px; }
.edKeyChip { font: 700 10px "Silkscreen", monospace; min-width: 54px; padding: 3px 6px; background: #1a1420; border: 1px solid var(--line); color: var(--ink); }
.edKeyChip.capturing { border-color: var(--warm); color: var(--warm); }
.edKeyConflict { font-size: 10px; color: var(--bad); }
.edMouseRow { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.edSeg { display: flex; flex-wrap: wrap; gap: 2px; }
.edSegBtn { font-size: 10px; padding: 3px 6px; background: #1a1420; border: 1px solid var(--line); color: var(--ink); }
.edSegBtn.active { background: var(--accent); color: var(--on-solid); border-color: var(--accent); }
.edToast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #0d0a12ee; border: 1px solid var(--accent); color: var(--ink); padding: 6px 12px; font-size: 12px; border-radius: 4px; z-index: 50; }
.edNoDbNote { font-size: 11px; color: var(--bad); }
.edItemForm { display: flex; flex-direction: column; gap: 6px; }
.edItemForm input[type=text], .edItemForm select, .edItemForm textarea { font: 12px "Atkinson Hyperlegible", sans-serif; background: #1a1420; color: var(--ink); border: 1px solid var(--line); padding: 4px 6px; box-sizing: border-box; width: 100%; }
.edItemForm textarea { resize: vertical; min-height: 40px; }
.edItemForm .row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.edItemRegions label { white-space: nowrap; }
.edSaveDot.saved { box-shadow: 0 0 0 2px rgba(127,214,184,.25); }
#edRetry { background: var(--bad); color: #1a1420; }
.edPaletteSection { position: relative; }
.edPaletteSection.popped { position: fixed; }
.edPaletteGrip { position: absolute; top: 0; bottom: 0; left: 0; width: 6px; cursor: ew-resize; z-index: 2; }
.edPaletteGrip:hover { background: var(--accent-wash); }
.edPaletteSection.popped .edPaletteGrip { left: auto; right: 0; }
.edPalSize { display: flex; align-items: center; gap: 6px; }
.edPalSizeLbl { font: 400 10px "Silkscreen", monospace; color: var(--soft); }
