/* SpawnCrate - Dino Color Palette (/colors/). Loads after wl-skin.css and uses its tokens. */

.pal-main { --gut: 20px; padding-top: 18px; padding-bottom: 24px; }
@media (max-width: 768px) { .pal-main { --gut: 15px; } }   /* style.css sets the container to 15px sides here */

/* ── Header ───────────────────────────────────────────────────────── */
.pal-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.pal-nav .btn, .pal-footer .btn { max-width: 100%; min-height: var(--tap); }   /* .btn-small is 32px: too small to tap */
.pal-head { margin: 0 0 16px; }
.pal-head h1 {
  font: 800 clamp(22px, 5vw, 32px)/1.1 var(--font-head);
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text); margin: 0 0 6px;
}
.pal-head p { color: var(--text-dim); margin: 0; font-size: 1rem; }

/* ── Layout: one column on phones, side panel + grid from 900px ──── */
/* Phones: a flex column, not grid - a grid item's containing block is its own row, which would stop
   the slot bar sticking. display:contents lifts the bar out of .pal-side for the same reason. The
   output moves under the grid so the colours start on the first screen; "Done" jumps to it. */
.pal-layout { display: flex; flex-direction: column; gap: 16px; }
.pal-side { display: contents; }
@media (max-width: 899px) {
  .pal-step + .pal-slotbar { margin-top: -10px; }
  .pal-pick { order: 1; }
  .pal-out { order: 2; scroll-margin-top: 150px; }   /* clear the sticky slot bar */
}
.pal-jump { display: none; }
@media (max-width: 899px) { .pal-jump { display: inline-flex; } }
@media (min-width: 900px) {
  .pal-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
  .pal-side {
    display: flex; flex-direction: column; gap: 16px;
    position: sticky; top: 12px;
  }
}

/* ── Region slots ─────────────────────────────────────────────────── */
.pal-slotbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  margin-left: calc(-1 * var(--gut)); margin-right: calc(-1 * var(--gut));
  padding: 6px var(--gut) 8px;
  border-bottom: 1px solid var(--panel-border);
}
@media (min-width: 900px) {
  .pal-slotbar {
    position: static; margin: 0; padding: 12px;
    background: var(--panel); border: 0;
    box-shadow: inset 0 0 0 1px var(--panel-border);
  }
}
.pal-step {                              /* outside the sticky bar so the bar stays short */
  font: 700 11px var(--font-head); letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-dim); margin: 0;
}
@media (min-width: 900px) { .pal-step { margin: 0 0 -10px; } }
.pal-slots { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.pal-slot {
  display: flex; flex-direction: column; align-items: stretch; gap: 4px;
  min-width: 0; min-height: var(--tap); padding: 4px;
  background: var(--bg-card); color: var(--text-dim);
  border: 0; border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--border);
  cursor: pointer; font-family: var(--font-head);
}
.pal-slot:hover { box-shadow: inset 0 0 0 1px var(--accent-dim); }
.pal-slot.is-active { color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-glow); }
.pal-slot-r {
  font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
}
.pal-slot-sw {
  display: grid; place-items: center;
  height: 40px; border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.35);
}
.pal-slot-num { font: 800 18px/1 var(--font-head); }
.pal-slot-sw.is-unset { background: transparent; color: var(--text-muted); box-shadow: inset 0 0 0 1px var(--border); }
.is-none {                                /* colour 0 = no colour: hatched, like the token's ⊘ */
  background: repeating-linear-gradient(45deg, #2a2f2a 0 5px, #3a403a 5px 10px) !important;
  color: #e8f0e0 !important;
}
.pal-active {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 6px; min-width: 0;
}
.pal-active-name {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); font-weight: 600;
}
.pal-active .btn { flex: none; min-height: var(--tap); }
.pal-active .btn + .btn { margin-left: -2px; }

/* Regions the picked dino does not use: dimmed, still tappable */
.pal-slot-note {                         /* 9px fits a 46px slot at 360px; wraps rather than clips if not */
  display: none; font-size: 9px; font-weight: 700; line-height: 1.05;
  text-align: center; color: var(--warn);
}
.pal-slots.has-dino .pal-slot-note { display: block; visibility: hidden; }   /* keeps every slot the same height */
.pal-slot.is-unused .pal-slot-note { visibility: visible; }
.pal-slot.is-unused .pal-slot-sw, .pal-slot.is-unused .pal-slot-r { opacity: .4; }
.pal-unused { margin-top: 6px; color: var(--warn); font-size: .9rem; font-weight: 600; }

/* ── Dino (optional) ──────────────────────────────────────────────── */
.pal-dino { min-width: 0; }
.pal-dino .pal-label { margin: 0 0 6px; }
.pal-dino-find { min-width: 0; }
.pal-dino-list {                         /* in the flow, not a pop-over: nothing can run off the screen */
  display: flex; flex-direction: column;
  margin-top: 6px; max-height: min(60vh, 440px);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--panel-border);
}
.pal-dino-opt {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: var(--tap); padding: 6px 12px;
  border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  background: transparent; color: var(--text);
  font: 600 15px var(--font-body); text-align: left; cursor: pointer;
}
.pal-dino-opt:last-child { border-bottom: 0; }
.pal-dino-opt:hover, .pal-dino-opt:focus-visible { background: var(--accent-glow); }
.pal-dino-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-dino-name small, .pal-dino-text small {
  display: block; color: var(--text-muted); font-size: .78rem; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pal-dino-uses { flex: none; color: var(--accent); font: 700 12px var(--font-head); letter-spacing: 1px; }
.pal-dino-msg { padding: 12px; color: var(--text-dim); }
.pal-dino-chip {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 6px 6px 6px 12px;
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--panel-border);
  border-left: 3px solid var(--accent);
}
.pal-dino-text { flex: 1 1 auto; min-width: 0; color: var(--text-dim); overflow-wrap: anywhere; }
.pal-dino-text b { color: var(--text); font-weight: 700; }
.pal-dino-x { flex: none; min-width: var(--tap); min-height: var(--tap); padding: 0 !important; font-size: 22px !important; }

/* ── Output ───────────────────────────────────────────────────────── */
.pal-out {
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--panel-border);
  padding: 12px; display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.pal-out-block { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.pal-label {
  font: 700 11px var(--font-head); letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--accent); display: flex; align-items: center; gap: 8px;
}
.pal-label::before { content: ""; width: 6px; height: 6px; background: var(--accent); flex: none; }
.pal-code {
  align-self: stretch; min-width: 0;
  background: var(--bg-input); box-shadow: inset 0 0 0 1px var(--border);
  border-left: 2px solid var(--accent);
  padding: 10px 12px;
  font: 600 14px/1.5 var(--font-code); color: #b9e07f;
  overflow-wrap: anywhere; word-break: break-word;
  user-select: all; -webkit-user-select: all;
}
.pal-numbers { font-family: var(--font-head); font-size: 15px; color: var(--text); white-space: pre-line; }
.pal-code.is-empty { color: var(--text-muted); user-select: none; -webkit-user-select: none; }
.pal-hint { color: var(--text-muted); font-size: .85rem; }
.pal-out .btn { min-height: var(--tap); }
.pal-out .btn.copied { --btn-c: var(--accent); background: var(--accent) !important; color: #0a0e0a !important; }
.pal-out .btn:disabled { --btn-c: var(--text-muted); opacity: .55; cursor: not-allowed; }
.pal-out-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Search + swatch grid ─────────────────────────────────────────── */
.pal-pick { min-width: 0; }
.pal-search-row { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.pal-search {
  -webkit-appearance: none; appearance: none;
  flex: 1 1 auto; min-width: 0; width: 100%;
  min-height: var(--tap); padding: 10px 12px;
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important; border-radius: var(--radius) !important;
  color: var(--text) !important;
  font: 500 16px var(--font-body) !important;   /* 16px: iOS Safari zooms below it */
}
.pal-search:focus { outline: none; border-color: var(--accent) !important; box-shadow: 0 0 0 1px var(--accent); }
.pal-count { flex: none; color: var(--text-muted); font: 600 12px var(--font-head); letter-spacing: .5px; }
.pal-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 4px;
}
.pal-sw {
  min-width: 0; height: var(--tap);
  border: 0; border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.35);
  font: 700 13px/1 var(--font-head);
  cursor: pointer; padding: 0;
  transition: transform .08s ease;
}
.pal-sw:hover { transform: scale(1.06); position: relative; z-index: 1; }
.pal-sw.is-on {
  outline: 2px solid var(--text); outline-offset: 1px;
  box-shadow: inset 0 0 0 2px #0a0e0a;
  position: relative; z-index: 2;
}
.pal-sw[hidden] { display: none; }
.pal-empty { color: var(--text-dim); margin: 12px 0 0; }

/* ── Toast ────────────────────────────────────────────────────────── */
.pal-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50;
  transform: translate(-50%, 120px); opacity: 0;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  font: 600 14px var(--font-head); letter-spacing: .5px;
  transition: transform .2s ease, opacity .2s ease;
  pointer-events: none;
}
.pal-toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ── Footer: links are buttons ────────────────────────────────────── */
.pal-footer a.btn { color: var(--btn-c) !important; text-decoration: none !important; vertical-align: middle; }
.pal-footer a.btn:hover { color: color-mix(in srgb, var(--btn-c) 70%, #fff) !important; }
.pal-footer p { margin: 0 0 10px; line-height: 2.4; }

@media (max-width: 600px) {
  .pal-head p { font-size: .95rem; }
  .pal-slot-num { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .pal-sw, .pal-toast { transition: none; }
}
