/* ============================================================================
   draft.css — Draft Board builder (pairs with draft.js)
   Desktop: categories on the left, a sticky board card on the right.
   Phones: one column with the Deal button pinned to the bottom.
   Draft keeps its violet identity. Load after styles.css.
   ============================================================================ */

/* ── Builder replaces the board while it's open ─────────────────────────── */
body.draft-building #boardWrap,
body.draft-building .board-scroll-hint,
body.draft-building #gameHud,
body.draft-building .legend,
body.draft-building .status-row,
body.draft-building #winBanner,
body.draft-building #gameOverBanner,
body.draft-building .m-bar-fwd,
body.draft-building .ctx-panel[data-ctx="draft"] { display: none !important; }

.db[hidden] { display: none; }

.db {
  --v: #e7ba6b;
  --v-2: #dea137;
  --v-hi: #f4dfbb;
  --v-ink: #fbf5ea;
  --v-soft: #a693c8;
  --v-line: rgba(231, 186, 107, 0.22);
  --v-panel: rgba(17, 16, 20, 0.92);

  position: relative;
  margin: 0 0 1.5rem;
  color: var(--v-ink);
  animation: db-in 320ms cubic-bezier(.2, 1, .3, 1) both;
}
@keyframes db-in { from { opacity: 0; transform: translateY(10px); } }

/* Zero-specificity reset so the site-wide pink pill buttons don't leak in. */
:where(.db) button {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* styles.css gives every button:hover a lift, brightness filter and pink
   glow. That's what lit up the category header and slid it over the chips.
   Same specificity as that rule and loaded later, so it wins; the component
   hover rules below are more specific and still apply. */
.db button:where(:hover, :active) { transform: none; filter: none; box-shadow: none; }
.db button:focus-visible,
.db input:focus-visible { outline: 2px solid var(--v-hi); outline-offset: 2px; }
.db button:disabled { cursor: not-allowed; }

.db h3 {
  margin: 0;
  font-family: var(--pixel-font);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffffff;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.db-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}
.db-kicker {
  margin: 0 0 0.3rem;
  font-family: var(--pixel-font);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--v-hi);
}
.db-title {
  margin: 0;
  font-family: var(--pixel-font);
  font-size: clamp(1.2rem, 2.6vw, 1.6rem);
  letter-spacing: 0.03em;
  color: #ffffff;
  text-shadow: none;
}
.db-resume {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0 0.95rem;
  border-radius: 11px;
  font-family: var(--pixel-font);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--v-ink);
  border: 1px solid var(--v-line);
  background: rgba(231, 186, 107, 0.1);
}
.db-resume::before { content: "↩"; font-size: 0.9rem; }
.db .db-resume:hover { background: rgba(231, 186, 107, 0.22); }
.db-resume[hidden] { display: none; }

/* ── Two columns ─────────────────────────────────────────────────────────── */
.db-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: start;
}

.db-main,
.db-card {
  border: 1px solid var(--v-line);
  border-radius: 16px;
  background:
    var(--v-panel);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.db-main { padding: 1.1rem; min-width: 0; }
.db-side {
  position: sticky;
  top: 1rem;
  display: grid;
  gap: 0.8rem;
}
.db-card { padding: 1rem; }

.db-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}
.db-cat-total,
.db-size-read {
  font-family: var(--pixel-font);
  font-size: 0.56rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--v-soft);
  white-space: nowrap;
}
.db-size-read b { color: #ffffff; font-weight: 700; }

/* ── Quick picks ─────────────────────────────────────────────────────────── */
.db-decks {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}
.db-deck {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0 0.5rem;
  border-radius: 11px;
  font-family: var(--pixel-font);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--v-ink);
  border: 1px solid var(--v-line);
  background: rgba(231, 186, 107, 0.05);
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.db-deck span:first-child { font-size: 0.95rem; }
.db .db-deck:hover { background: rgba(231, 186, 107, 0.16); border-color: rgba(244, 223, 187, 0.5); transform: translateY(-1px); }
.db-deck[aria-pressed="true"] {
  color: #ffffff;
  border-color: var(--v);
  background: rgba(231, 186, 107, 0.38);
  box-shadow: none;
}
.db-deck.pop { animation: db-pop 320ms cubic-bezier(.2, .7, .3, 1); }
@keyframes db-pop { 40% { transform: scale(0.94); } }

/* ── Group tabs ──────────────────────────────────────────────────────────── */
.db-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.db-tab {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0.35rem 0.3rem;
  padding: 0.55rem 0.6rem 0.5rem;
  border-radius: 11px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.025);
  transition: background 140ms ease, border-color 140ms ease;
}
.db .db-tab:hover { background: rgba(231, 186, 107, 0.1); }
.db-tab[aria-selected="true"] {
  border-color: rgba(244, 223, 187, 0.55);
  background: rgba(231, 186, 107, 0.16);
}
.db-tab-name {
  min-width: 0;
  font-family: var(--pixel-font);
  font-size: 0.58rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.db-tab-count {
  font-family: var(--pixel-font);
  font-size: 0.5rem;
  color: var(--v-soft);
}
.db-tab-meter {
  grid-column: 1 / -1;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.db-tab-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--v-2);
  transition: width 260ms ease;
}
.db-tab.empty .db-tab-count { color: #f4aba4; }

/* ── Chip panel ──────────────────────────────────────────────────────────── */
.db-panel {
  padding: 0.85rem;
  border-radius: 13px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.04);
  animation: db-in 220ms ease both;
}
.db-loading { margin: 0; font-size: 0.82rem; color: var(--v-soft); }

.db-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.db-tools-label {
  font-family: var(--pixel-font);
  font-size: 0.52rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--v-soft);
}
.db-search {
  flex: 1 1 12rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  padding: 0 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--v-line);
  background: rgba(0, 0, 0, 0.3);
  color: var(--v-soft);
}
.db-search:focus-within { border-color: var(--v-hi); }
.db-search input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-size: 0.84rem;
}
.db-bulk-wrap { display: inline-flex; gap: 0.3rem; }
.db-bulk {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 0.7rem;
  border-radius: 9px;
  font-family: var(--pixel-font);
  font-size: 0.52rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--v-ink);
  border: 1px solid var(--v-line);
}
.db .db-bulk:hover { background: rgba(231, 186, 107, 0.16); }

/* Text chips line up in an even grid; long names wrap inside the chip. */
.db-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.4rem;
  max-height: 22rem;
  overflow-y: auto;
  padding: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(231, 186, 107, 0.45) transparent;
}
.db-chips-types { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); max-height: none; }

.db-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  min-height: 38px;
  padding: 0.35rem 0.6rem;
  border-radius: 10px;
  font-family: var(--pixel-font);
  font-size: 0.56rem;
  line-height: 1.35;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  color: #ffffff;
  background: rgba(231, 186, 107, 0.2);
  box-shadow: inset 0 0 0 1px rgba(241, 214, 168, 0.5);
  animation: db-in 240ms ease both;
  animation-delay: calc(var(--i, 0) * 10ms);
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}
.db-chip[hidden] { display: none; }
.db .db-chip:hover { background: rgba(231, 186, 107, 0.3); }
.db-chip.pop { animation: db-pop 280ms cubic-bezier(.2, .7, .3, 1); }

.db-chip-check {
  flex: none;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: var(--v);
  box-shadow: none;
}
.db-chip-check::after {
  content: "";
  width: 4px;
  height: 8px;
  margin-top: -2px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.db-chip-label { min-width: 0; }

.db-chip[aria-pressed="false"] {
  color: var(--v-soft);
  background: rgba(255, 255, 255, 0.02);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.db .db-chip[aria-pressed="false"]:hover { background: rgba(255, 255, 255, 0.06); color: var(--v-ink); }
.db-chip[aria-pressed="false"] .db-chip-check { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.25); }
.db-chip[aria-pressed="false"] .db-chip-check::after { display: none; }

/* Types: their own colours, faded out when switched off */
.db-chip-type {
  justify-content: center;
  gap: 0.35rem;
  font-weight: 700;
  color: var(--t-fg);
  background: var(--t-bg);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}
.db .db-chip-type:hover { background: var(--t-bg); filter: brightness(1.1); }
.db-chip-type[aria-pressed="false"] {
  color: var(--v-soft);
  background: transparent;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--t-bg) 55%, transparent);
  opacity: 0.75;
}
.db .db-chip-type[aria-pressed="false"]:hover { background: color-mix(in srgb, var(--t-bg) 14%, transparent); filter: none; }
.db-chip-icon { font-size: 0.85rem; }

/* ── Size card ───────────────────────────────────────────────────────────── */
.db-size-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 4px;
  padding: 8px;
  margin-bottom: 0.7rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--v-line);
  touch-action: none;           /* lets you drag-paint the size on phones */
  user-select: none;
}
.db-sq {
  aspect-ratio: 1;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  transition: background 160ms ease var(--d, 0ms), box-shadow 160ms ease var(--d, 0ms), transform 160ms ease;
}
.db-sq.on {
  background: #edca8f;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.db-sq.corner {
  transform: scale(1.08);
  box-shadow: inset 0 0 0 2px #ffffff;
}
.db-size-grid.previewing .db-sq.on:not(.pv) { background: rgba(231, 186, 107, 0.25); box-shadow: none; transition-delay: 0ms; }
.db-size-grid.previewing .db-sq.pv:not(.on) {
  background: rgba(231, 186, 107, 0.22);
  box-shadow: inset 0 0 0 1px rgba(244, 223, 187, 0.6);
  transition-delay: 0ms;
}

.db-presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.35rem; }
.db-preset {
  min-height: 34px;
  border-radius: 9px;
  text-align: center;
  line-height: 34px;
  font-family: var(--pixel-font);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  color: var(--v-ink);
  border: 1px solid var(--v-line);
  background: rgba(231, 186, 107, 0.05);
}
.db .db-preset:hover { background: rgba(231, 186, 107, 0.16); }
.db-preset[aria-pressed="true"] { color: #ffffff; border-color: var(--v-hi); background: rgba(231, 186, 107, 0.32); }

/* ── Rules card ──────────────────────────────────────────────────────────── */
.db-rules-card { display: grid; gap: 0.5rem; }
.db-rules-card h3 { margin-bottom: 0.2rem; }
.db-switch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.65rem;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.db .db-switch:hover { background: rgba(231, 186, 107, 0.08); }
.db-switch-text { display: grid; gap: 0.2rem; min-width: 0; }
.db-switch-text strong {
  font-family: var(--pixel-font);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ffffff;
}
.db-switch-text small { font-size: 0.72rem; line-height: 1.35; color: var(--v-soft); }
.db-switch-track {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 150ms ease;
}
.db-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 180ms cubic-bezier(.2, .7, .3, 1);
}
.db-switch[aria-checked="true"] .db-switch-track { background: var(--v); box-shadow: none; }
.db-switch[aria-checked="true"] .db-switch-knob { transform: translateX(18px); }

/* ── Deal ────────────────────────────────────────────────────────────────── */
.db-deal { display: grid; gap: 0.5rem; }
.db-summary {
  margin: 0;
  text-align: center;
  font-family: var(--pixel-font);
  font-size: 0.56rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--v-soft);
}
.db-summary.warn { color: #fbbf6a; }
.db-error {
  margin: 0;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #f5b6b0;
  background: rgba(233, 88, 74, 0.08);
  border: 1px solid rgba(233, 88, 74, 0.35);
}
.db-error[hidden] { display: none; }

.db-go {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 54px;
  border-radius: 14px;
  overflow: hidden;
  font-family: var(--pixel-font);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffffff;
  background: #eac380;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}
/* A light sweep every few seconds draws the eye to the one action that matters. */
.db-go::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.28) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: db-sheen 3.6s ease-in-out 1s infinite;
}
@keyframes db-sheen { 0%, 70% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
.db .db-go:hover:not(:disabled) { transform: translateY(-2px); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25); }
.db-go:disabled { opacity: 0.45; box-shadow: none; }
.db-go:disabled::after { display: none; }
.db-go-icon { font-size: 1.1rem; }
.db.dealing .db-go-icon { animation: db-flip 600ms linear infinite; }
@keyframes db-flip { to { transform: rotateY(360deg); } }

/* ── Board sizing: small boards stop stretching to full width ─────────────
   Columns cap at ~132px, so a 3×3 is a compact centred board instead of
   three giant tiles. A 9×9 is wider than the cap allows, so it's unchanged. */
.board-grid {
  max-width: calc(var(--board-header-max, 118px) + var(--board-cols, 9) * 136px);
  margin-inline: auto;
}

/* Long draft seeds were running off the context bar on phones. */
.ctx-meta { overflow-wrap: anywhere; }

/* ── Tablet: board card moves above the categories ──────────────────────── */
@media (max-width: 980px) {
  .db-cols { grid-template-columns: minmax(0, 1fr); }
  .db-side {
    position: static;
    order: -1;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .db-deal { grid-column: 1 / -1; }
  .db-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ── Phones ──────────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .db-head { margin-bottom: 0.7rem; }
  .db-cols { gap: 0.7rem; }
  /* Flatten the side column so its pieces can sit around the categories:
     size first, categories, rules, then the Deal bar pinned at the bottom. */
  .db-side { display: contents; }
  .db-size-card { order: 1; }
  .db-main { order: 2; padding: 0.85rem; border-radius: 14px; }
  .db-rules-card { order: 3; }
  .db-card { padding: 0.85rem; border-radius: 14px; }

  .db-size-grid { max-width: 15.5rem; margin-inline: auto; gap: 3px; padding: 6px; }
  .db-presets { max-width: 15.5rem; margin-inline: auto; }

  .db-decks { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.35rem; }
  .db-tabs {
    display: flex;
    gap: 0.35rem;
    margin: 0 -0.85rem 0.7rem;
    padding: 0 0.85rem 0.2rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .db-tabs::-webkit-scrollbar { display: none; }
  .db-tab { flex: none; min-width: 6.4rem; scroll-snap-align: start; }

  .db-panel { padding: 0.65rem; }
  .db-chips { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); max-height: 19rem; }
  .db-chips-types { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .db-search input { font-size: 16px; }      /* stops iOS zooming into the field */

  .db-deal {
    order: 4;
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 0 -0.8rem;
    padding: 0.7rem 0.8rem calc(0.7rem + env(safe-area-inset-bottom, 0px));
    background: rgba(14, 13, 16, 0.6);
    
    border-top: 1px solid var(--v-line);
  }
}

/* Touch screens keep :hover after a tap; don't leave a tapped chip looking lit. */
@media (hover: none) {
  .db .db-chip[aria-pressed="false"]:hover { background: rgba(255, 255, 255, 0.02); color: var(--v-soft); }
  .db .db-chip:not([aria-pressed="false"]):not(.db-chip-type):hover { background: rgba(231, 186, 107, 0.2); }
  .db .db-deck:hover, .db .db-go:hover:not(:disabled) { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .db, .db *, .db *::before, .db *::after { animation: none !important; transition: none !important; }
}