/* Level design, the picker bar (levelpicker.js). Everything lives under .lp-.
   It is a grid of big cards, scrolled vertically, that stands in for the atlas strip. */

.lp-root {
  --lp-card: 170px;                 /* the header slider overrides this inline */
  --lp-shadable: var(--accent);
  --lp-tiled: #3cc8b4;
  position: relative;
  display: flex; flex-direction: column; flex: 1 1 0;
  min-height: 0; width: 100%; height: 100%;
  background: var(--panel); color: var(--text);
}
/* A class that sets display would otherwise beat the hidden attribute the script uses. */
.lp-root [hidden] { display: none !important; }

/* ---------------------------------------------------------------- header */
.lp-head {
  flex: none; display: flex; align-items: center; gap: 10px;
  min-height: 34px; padding: 5px 12px; border-bottom: 1px solid var(--line);
}
.lp-title { font-weight: 600; flex: none; }
.lp-counts {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--dim); font-size: 12px;
}
.lp-grow { flex: 1 1 auto; }
.lp-size { flex: none; display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 11px; }
.lp-size input[type=range] { width: 110px; margin: 0; }
.lp-help {
  flex: none; width: 18px; height: 18px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--panel-2); color: var(--dim);
  font-family: inherit; font-size: 11px; font-weight: 600; line-height: 1; cursor: help;
}
.lp-help:hover, .lp-help:focus-visible { color: var(--text); border-color: var(--accent); outline: none; }

/* In <body>, not in the root, so the short host cannot clip it. Above the row menu (60). */
.lp-tip {
  position: fixed; z-index: 70; max-width: 300px; padding: 8px 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .55);
  color: var(--text); font-size: 12px; pointer-events: none;
}
.lp-tip p { margin: 0 0 5px; }
.lp-tip p:last-child { margin-bottom: 0; }
.lp-tip b { color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------------------ body */
.lp-body {
  position: relative; flex: 1 1 0; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 6px 10px 14px;
  scrollbar-width: thin; scrollbar-color: #4a4d55 transparent;
}
.lp-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--dim); text-align: center; padding: 12px;
}

/* ---------------------------------------------------------------- sections */
.lp-sec + .lp-sec { margin-top: 12px; }
.lp-sec-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 2px; margin-bottom: 8px; border-bottom: 1px solid var(--line);
}
.lp-sec-title { flex: none; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 12px; }
.lp-sec-meta { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); font-size: 11px; }

/* A hidden group is off the bar at the start, so it sits apart in a warm dashed box. */
.lp-sec-group {
  padding: 0 8px 8px; border: 1px dashed rgba(224, 163, 62, .32); border-radius: 8px;
  background: rgba(224, 163, 62, .035);
}
.lp-sec-group .lp-sec-head { cursor: pointer; border-bottom-color: rgba(224, 163, 62, .2); }
.lp-sec-group .lp-sec-title { color: var(--warn); }
.lp-sec-hide { flex: none; display: flex; align-items: center; gap: 5px; color: var(--dim); font-size: 11px; cursor: pointer; }
.lp-sec-hide input { margin: 0; accent-color: var(--warn); cursor: pointer; }

.lp-twist { flex: none; position: relative; width: 16px; height: 16px; padding: 0; border: 0; background: none; cursor: pointer; }
.lp-twist::before {
  content: ''; position: absolute; left: 5px; top: 3px;
  border-left: 6px solid var(--dim); border-top: 5px solid transparent; border-bottom: 5px solid transparent;
  transform: rotate(90deg); transform-origin: 3px 5px; transition: transform .12s;
}
.lp-twist:hover::before { border-left-color: var(--text); }
.lp-collapsed .lp-twist::before { transform: none; }
.lp-collapsed .lp-grid { display: none; }
.lp-collapsed .lp-sec-head { margin-bottom: 0; border-bottom-color: transparent; }

.lp-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(var(--lp-card), 1fr));
}

/* ------------------------------------------------------------------ cards */
.lp-card {
  position: relative; min-width: 0; overflow: hidden;
  display: flex; flex-direction: column; gap: 4px; padding: 6px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; user-select: none;
}
.lp-card:hover { border-color: #4b4e56; }
.lp-card.lp-shadable { border-color: var(--lp-shadable); }
.lp-card.lp-tiled { border-color: var(--lp-tiled); }

/* The default, not a decision: no colour, dimmer text. */
.lp-card.lp-auto { background: transparent; border-color: rgba(255, 255, 255, .07); }
.lp-card.lp-auto:hover { border-color: #4b4e56; }
.lp-card.lp-auto .lp-name { color: var(--dim); }
.lp-card.lp-auto .lp-parts { opacity: .75; }

.lp-card.lp-selected { background: #212a38; box-shadow: 0 0 0 1px var(--accent); }
.lp-card.lp-auto.lp-selected { border-color: var(--accent); }
.lp-card.lp-auto.lp-selected .lp-name { color: var(--text); }
.lp-card.lp-primary { box-shadow: 0 0 0 2px var(--accent), 0 0 14px rgba(78, 161, 255, .35); }

.lp-prev {
  position: relative; flex: none; width: 100%; aspect-ratio: 1 / 1;
  border-radius: 5px; overflow: hidden;
  /* Flat panel colour with a faint checker, so a transparent preview still reads. */
  background-color: var(--panel-2);
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, .04) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .04) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, .04) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .04) 75%);
  background-size: 14px 14px; background-position: 0 0, 7px 7px;
}
.lp-img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }

.lp-badges { position: absolute; top: 4px; left: 4px; right: 26px; display: flex; flex-wrap: wrap; gap: 3px; pointer-events: none; }
.lp-badge {
  padding: 1px 6px; border-radius: 9px; background: rgba(16, 18, 22, .8);
  font-size: 10px; line-height: 15px; white-space: nowrap;
}
.lp-b-tiled { color: var(--lp-tiled); }
.lp-b-skin { color: #c9a8ff; }

.lp-warn {
  position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--warn); color: #10151c; font-size: 12px; font-weight: 700; line-height: 18px; text-align: center;
  cursor: help;
}
.lp-tag {
  position: absolute; left: 4px; bottom: 4px; max-width: calc(100% - 8px);
  padding: 1px 6px; border-radius: 4px; background: rgba(16, 18, 22, .8); border: 1px solid var(--line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--warn); font-size: 10px; line-height: 14px; pointer-events: none;
}

.lp-name { font-weight: 600; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-sum { color: var(--dim); font-size: 11px; }
.lp-parts { margin: 0; padding: 0; list-style: none; font-size: 11px; color: var(--dim); }
.lp-parts li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.5; }
.lp-parts .lp-special { color: var(--lp-tiled); font-weight: 600; }
.lp-parts .lp-more { font-style: italic; opacity: .8; cursor: pointer; text-decoration: underline dotted; }
.lp-parts .lp-more:hover { opacity: 1; color: var(--text); }
/* Opened: every part, scrolling inside the card rather than growing the whole grid row. */
.lp-card.lp-open .lp-parts { max-height: 220px; overflow-y: auto; }

/* ------------------------------------------------------------------ grab
   While a grab is set (picker.setGrab, "Làm xám") the cards can be taken. The root carries
   .lp-grab; each card carries its state, and .lp-grabbing while it is being dragged. */
/* Only a card that can be dragged takes the finger away from scrolling the picker. */
.lp-grab .lp-card.lp-ready { touch-action: none; }
.lp-grab .lp-card.lp-ready { cursor: grab; }
.lp-grab .lp-card.lp-grabbing { cursor: grabbing; opacity: .55; }
/* A card you cannot take is dimmed, not hidden: it can still be looked at and selected. */
.lp-grab .lp-card.lp-placed:not(.lp-selected),
.lp-grab .lp-card.lp-locked:not(.lp-selected),
.lp-grab .lp-card.lp-off:not(.lp-selected) { background: transparent; border-color: rgba(255, 255, 255, .07); }
.lp-grab .lp-card.lp-placed > :not(.lp-prev),
.lp-grab .lp-card.lp-locked > :not(.lp-prev),
.lp-grab .lp-card.lp-off > :not(.lp-prev) { opacity: .5; }
.lp-grab .lp-card.lp-placed .lp-img,
.lp-grab .lp-card.lp-locked .lp-img,
.lp-grab .lp-card.lp-off .lp-img { opacity: .38; filter: grayscale(.6); }
.lp-grab .lp-tag { max-width: calc(100% - 36px); }

/* The tick on a placed card and the lock on one whose group is not open yet. */
.lp-mark {
  position: absolute; right: 4px; bottom: 4px; width: 20px; height: 20px; box-sizing: border-box;
  border-radius: 50%; background: rgba(16, 18, 22, .85); border: 1px solid var(--line);
  display: grid; place-items: center; pointer-events: none;
}
.lp-mark-placed { color: #6fcf8a; font-size: 12px; font-weight: 700; line-height: 1; }
.lp-mark-lock::before {
  content: ''; position: absolute; left: 5px; top: 2px; width: 8px; height: 7px; box-sizing: border-box;
  border: 2px solid var(--warn); border-bottom: 0; border-radius: 4px 4px 0 0;
}
.lp-mark-lock::after {
  content: ''; position: absolute; left: 4px; top: 8px; width: 10px; height: 8px;
  border-radius: 2px; background: var(--warn);
}

/* While a card is in the air the cursor says so wherever it is, and nothing gets selected on the way. */
body.lp-dragging, body.lp-dragging * { cursor: grabbing !important; user-select: none; }
