/* Commander Matchmaker — swipe UI. Shares the chat app's parchment/ink
   tokens but is its own stylesheet: the page has no composer, sidebar,
   or thread, so pulling in styles.css would import far more than it uses.

   Layout: phone-first single column with the taste and matches panels
   as slide-in sheets; from 1000px the same panels sit as static
   columns either side of the card stage (Tinder's desktop layout does
   the same: profile rail left, card centre, keyboard shortcuts). */

:root {
  --parchment-primary:   #FFFAF5;
  --parchment-secondary: #FFF6ED;
  --parchment-tertiary:  #F5EFE4;
  --ink-primary:         #2C3E50;
  --ink-secondary:       #34495E;
  --ink-muted:           rgba(44, 62, 80, 0.55);
  --accent:              #3498DB;
  --accent-soft:         rgba(52, 152, 219, 0.12);
  --border-light:  #DEE2E6;
  --border-strong: #CBD2D9;
  --success: #27AE60;
  --success-soft: rgba(39, 174, 96, 0.12);
  --error:   #E74C3C;
  --error-soft: rgba(231, 76, 60, 0.10);
  --gold:    #B7791F;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  --shadow-lift: 0 6px 18px rgba(44, 62, 80, 0.12);
  --radius: 8px;

  /* Scryfall "normal" images are 488×680 — keep the stack at that ratio. */
  --card-w: min(320px, 82vw);
  --card-h: calc(var(--card-w) * 680 / 488);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--parchment-primary);
  color: var(--ink-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

kbd {
  font-family: 'SF Mono', ui-monospace, 'Menlo', monospace;
  font-size: 0.75em;
  background: var(--parchment-tertiary);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
}

button { font: inherit; }

/* =============================================================== header */

.mm-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--parchment-secondary);
}

.mm-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink-primary);
}

.mm-logo { width: 28px; height: 28px; }

.mm-brand-name {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

.mm-title-wrap { flex: 1; min-width: 0; text-align: center; }

.mm-title {
  font-family: 'Cinzel', serif;
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.mm-tagline {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.mm-header-actions { display: flex; gap: 8px; }

.mm-pill-btn {
  font-weight: 600;
  color: var(--ink-secondary);
  background: var(--parchment-primary);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.mm-pill-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.mm-pill-heart { color: var(--error); }

.mm-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 6px;
}

.mm-link-btn:hover { text-decoration: underline; }
.mm-link-danger { color: var(--error); }

.mm-primary {
  background: var(--ink-primary);
  color: var(--parchment-primary);
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.15s ease;
}

.mm-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); }

/* =============================================================== layout */

.mm-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
}

.mm-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px 8px;
  gap: 12px;
  min-width: 0;
}

/* =============================================================== filters */

.mm-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.mm-filters-label,
.mm-filters-hint {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.mm-color {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  font-weight: 700;
  cursor: pointer;
  background: var(--parchment-tertiary);
  color: var(--ink-muted);
  transition: all 0.15s ease;
}

.mm-color[aria-pressed="true"] {
  border-color: var(--ink-secondary);
  color: var(--ink-primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

/* MTG pie colors only light up when selected. */
.mm-color[data-color="W"][aria-pressed="true"] { background: #F8F6D8; }
.mm-color[data-color="U"][aria-pressed="true"] { background: #C1D7E9; }
.mm-color[data-color="B"][aria-pressed="true"] { background: #CAC5C0; }
.mm-color[data-color="R"][aria-pressed="true"] { background: #E49977; }
.mm-color[data-color="G"][aria-pressed="true"] { background: #A3C095; }

.mm-reshuffle {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--parchment-primary);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.mm-reshuffle:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

/* =============================================================== stack */

.mm-stage {
  position: relative;
  width: var(--card-w);
  /* image + caption + reasons strip below it */
  height: calc(var(--card-h) + 92px);
}

.mm-stack { position: absolute; inset: 0; }

.mm-card {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: var(--parchment-secondary);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  display: flex;
  flex-direction: column;
  will-change: transform;
}

/* Cards behind the top one peek out slightly, undragged. */
.mm-card[data-depth="1"] { transform: translateY(10px) scale(0.97); }
.mm-card[data-depth="2"] { transform: translateY(20px) scale(0.94); }
.mm-card[data-depth="1"], .mm-card[data-depth="2"] { pointer-events: none; }

.mm-card.mm-settling { transition: transform 0.25s ease; }
.mm-card.mm-flinging { transition: transform 0.35s ease-out, opacity 0.35s ease-out; }

.mm-card-face {
  position: relative;
  height: var(--card-h);
  flex-shrink: 0;
}

.mm-card-img {
  width: 100%;
  height: var(--card-h);
  object-fit: cover;
  border-radius: 12px 12px 0 0;
  background: var(--parchment-tertiary);
  pointer-events: none;
  display: block;
}

/* Info face: oracle text over the art, toggled with the i button. */
.mm-card-text {
  position: absolute;
  inset: 0;
  background: rgba(255, 250, 245, 0.96);
  padding: 16px 16px 12px;
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.5;
  border-radius: 12px 12px 0 0;
}

.mm-card-text[hidden] { display: none; }
.mm-card-text h3 { font-family: 'Cinzel', serif; font-size: 1rem; margin: 0 0 2px; }
.mm-card-text .mm-card-text-type { color: var(--ink-muted); font-size: 0.75rem; margin: 0 0 10px; }
.mm-card-text .mm-card-text-cost { float: right; font-weight: 600; font-size: 0.8rem; color: var(--ink-secondary); }
.mm-card-text p { margin: 0 0 8px; white-space: pre-wrap; }
.mm-card-text .mm-card-text-traits { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }

.mm-card-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px 4px;
}

.mm-card-name {
  font-weight: 600;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mm-card-type {
  font-size: 0.72rem;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mm-card-rank {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-muted);
  background: var(--parchment-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* "Because you kept…" strip. */
.mm-card-reasons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow: hidden;
  padding: 0 12px 8px;
  font-size: 0.72rem;
  color: var(--ink-muted);
  min-height: 24px;
}

.mm-card-reasons .mm-reason-label { flex-shrink: 0; }

.mm-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--parchment-tertiary);
  color: var(--ink-secondary);
  white-space: nowrap;
}

.mm-tag-reason { background: var(--success-soft); border-color: rgba(39, 174, 96, 0.35); color: #1E8449; }
.mm-tag-wild { background: var(--accent-soft); border-color: rgba(52, 152, 219, 0.35); color: #1F6FA0; }

/* Verdict stamps fade in as the card is dragged. */
.mm-stamp {
  position: absolute;
  top: 24px;
  font-family: 'Cinzel', serif;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 14px;
  border: 3px solid;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  background: rgba(255, 250, 245, 0.85);
  z-index: 2;
}

.mm-stamp-keep { left: 18px; color: var(--success); border-color: var(--success); transform: rotate(-12deg); }
.mm-stamp-pass { right: 18px; color: var(--error); border-color: var(--error); transform: rotate(12deg); }

/* =============================================================== actions */

.mm-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.mm-action {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--parchment-primary);
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mm-action:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.mm-action:disabled { opacity: 0.35; cursor: default; }

.mm-action-pass { color: var(--error); }
.mm-action-keep { color: var(--success); }
.mm-action-undo, .mm-action-info { width: 44px; height: 44px; font-size: 1.1rem; color: var(--ink-secondary); }
.mm-action-info { font-family: 'Cinzel', serif; font-weight: 700; font-style: italic; }
.mm-action-info[aria-pressed="true"] { background: var(--ink-primary); color: var(--parchment-primary); border-color: var(--ink-primary); }

.mm-hint {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: var(--ink-muted);
  text-align: center;
}

.mm-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  color: var(--ink-muted);
  border: 2px dashed var(--border-strong);
  border-radius: 16px;
  padding: 20px;
}

/* =============================================================== why */

.mm-why {
  width: var(--card-w);
  background: var(--parchment-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  animation: mm-rise 0.2s ease-out;
}

@keyframes mm-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.mm-why-q { margin: 0 0 8px; font-size: 0.82rem; }
.mm-why-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }

.mm-chip {
  border: 1px solid var(--border-strong);
  background: var(--parchment-primary);
  color: var(--ink-secondary);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
}

.mm-chip:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.mm-chip[aria-pressed="true"], .mm-chip-pinned { background: var(--success-soft); border-color: var(--success); color: #1E8449; }
.mm-chip-muted { background: var(--error-soft); border-color: var(--error); color: #B03A2E; text-decoration: line-through; }
.mm-chip-count { font-weight: 400; color: var(--ink-muted); font-size: 0.7rem; }
.mm-chip .mm-chip-key { font-size: 0.65rem; color: var(--ink-muted); font-weight: 400; }

/* =============================================================== panels */

.mm-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  width: min(360px, 92vw);
  background: var(--parchment-secondary);
  box-shadow: var(--shadow-lift);
  z-index: 30;
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow-y: auto;
  gap: 10px;
}

.mm-panel-likes { right: 0; border-left: 1px solid var(--border-light); }
.mm-panel-taste { left: 0; border-right: 1px solid var(--border-light); }

.mm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 62, 80, 0.35);
  z-index: 25;
}

.mm-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mm-panel-header h2 {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  margin: 0;
}

.mm-panel-h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin: 8px 0 0;
}

.mm-panel-close {
  background: none;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
}

.mm-panel-sub { font-size: 0.8rem; color: var(--ink-muted); margin: 0; }

.mm-taste-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mm-taste-chips:empty::after {
  content: 'No preferences yet.';
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.mm-taste-tools { display: flex; gap: 8px; }

.mm-vocab { display: flex; flex-direction: column; gap: 6px; }

.mm-vocab-search {
  font: inherit;
  font-size: 0.85rem;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--parchment-primary);
  color: var(--ink-primary);
}

.mm-vocab-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 240px; overflow-y: auto; }

.mm-segmented {
  display: inline-flex;
  align-self: flex-start;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  overflow: hidden;
  background: var(--parchment-primary);
}

.mm-segmented button {
  border: none;
  background: none;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
}

.mm-segmented button + button { border-left: 1px solid var(--border-light); }
.mm-segmented-sm button { padding: 4px 9px; font-size: 0.74rem; }
.mm-filters-sep { margin-left: 6px; }
.mm-scry-form { display: flex; gap: 6px; }
.mm-scry-form .mm-vocab-search { flex: 1; min-width: 0; }
.mm-scry-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.mm-scry-presets .mm-chip { font-weight: 500; }
.mm-chip-required { background: var(--ink-primary); border-color: var(--ink-primary); color: var(--parchment-primary); }
.mm-chip-required .mm-chip-count { color: inherit; opacity: 0.8; }
.mm-taste-chips#mm-scry-chips:empty { display: none; }
.mm-chip-error { border-style: dashed; color: var(--error); }
.mm-chip-x { margin-left: 2px; opacity: 0.6; }
.mm-chip-x:hover { opacity: 1; }
.mm-panel-sub a { color: var(--accent); }
.mm-setup-note { margin: 6px 0 0; font-size: 0.75rem; color: var(--ink-muted); }
.mm-setup-more { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.mm-setup-more .mm-vocab-search { max-width: 380px; }
.mm-segmented button[aria-checked="true"] { background: var(--ink-primary); color: var(--parchment-primary); }

.mm-taste-footer { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.78rem; }
.mm-confirm { color: var(--ink-muted); }

/* ---- matches */

.mm-likes-empty { font-size: 0.85rem; color: var(--ink-muted); margin: 0; }

.mm-likes-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mm-like {
  display: flex;
  gap: 10px;
  background: var(--parchment-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
}

.mm-like-thumb {
  width: 52px;
  height: 72px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--parchment-tertiary);
}

.mm-like-body { flex: 1; min-width: 0; }

.mm-like-name {
  font-weight: 600;
  font-size: 0.85rem;
  margin: 0 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mm-like-type {
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin: 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mm-like-why { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }

.mm-like-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  flex-wrap: wrap;
}

.mm-like-actions a { color: var(--accent); text-decoration: none; font-weight: 600; }
.mm-like-actions a:hover { text-decoration: underline; }

.mm-like-remove {
  font-size: 0.78rem;
  background: none;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0;
}

.mm-like-remove:hover { color: var(--error); }

.mm-likes-footer { margin-top: 4px; }
.mm-compare {
  display: block;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 8px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.mm-compare:hover { background: var(--accent-soft); }

/* =============================================================== setup */

.mm-setup {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(44, 62, 80, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.mm-setup-card {
  background: var(--parchment-primary);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: var(--shadow-lift);
  width: min(560px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 20px 22px;
}

.mm-setup-card h2 { font-family: 'Cinzel', serif; margin: 0 0 4px; font-size: 1.2rem; }
.mm-setup-sub { margin: 0 0 14px; font-size: 0.85rem; color: var(--ink-muted); }
.mm-setup-card h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); margin: 14px 0 8px; }
.mm-chip-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.mm-setup-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 18px; }

/* =============================================================== footer */

.mm-footer {
  padding: 10px 16px 14px;
  font-size: 0.68rem;
  color: var(--ink-muted);
  text-align: center;
  border-top: 1px solid var(--border-light);
}

.mm-footer p { margin: 2px 0; max-width: 46rem; margin-inline: auto; }
.mm-build { opacity: 0.7; }

/* Author display rules on classes would otherwise beat the UA's
   [hidden] { display: none } — restate it late so hidden means hidden. */
[hidden] { display: none; }

/* =============================================================== responsive */

@media (max-width: 560px) {
  .mm-brand-name { display: none; }
  .mm-tagline { display: none; }
  .mm-pill-btn { padding: 6px 10px; }
}

/* Desktop: panels become static columns; the sheet toggles hide. */
@media (min-width: 1000px) {
  .mm-layout {
    flex-direction: row;
    align-items: stretch;
    max-width: 1280px;
    margin: 0 auto;
  }
  .mm-panel {
    position: static;
    width: 300px;
    flex-shrink: 0;
    box-shadow: none;
    background: transparent;
    border: none;
    padding: 18px 14px;
    z-index: auto;
  }
  .mm-panel-taste { border-right: 1px solid var(--border-light); }
  .mm-panel-likes { border-left: 1px solid var(--border-light); }
  .mm-panel[hidden] { display: flex; }
  .mm-panel-close { display: none; }
  .mm-sheet-toggle { display: none; }
  .mm-backdrop { display: none !important; }
  .mm-main { padding-top: 20px; }
}
