/* Public Formats & Banlist page. Loaded via layout's extraStyles when
   views/pages/legality.ejs renders. All class names are prefixed `.leg-`. */

.page-container { max-width: 1100px; margin: 0 auto; padding: 24px; }
.leg-intro {
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 0 0 20px 0;
  max-width: 720px;
}

.leg-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.leg-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 10px 18px;
  cursor: pointer;
  font-size: 0.92rem;
  font-family: inherit;
  margin-bottom: -1px;
}
.leg-tab:hover { color: var(--text); }
.leg-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.leg-loading, .leg-empty, .leg-error {
  padding: 20px;
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
}
.leg-error { color: #e55; font-style: normal; }

.leg-section { margin-bottom: 32px; }
.leg-section-title {
  font-size: 0.88rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px 0;
  font-weight: 600;
}
.leg-count {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-left: 6px;
  font-weight: normal;
}
.leg-sublabel {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-dim);
  font-weight: 600;
  margin: 14px 0 6px 0;
}
.leg-sublabel:first-child { margin-top: 0; }

/* Legal sets grid */
.leg-sets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 6px;
}
.leg-set {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 3px;
  /* `<a class="leg-set">` should look like the row (no underline / text color
     change) but invite a click via subtle hover. */
  text-decoration: none;
  color: inherit;
  transition: background 0.1s, border-color 0.1s;
}
a.leg-set:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}
.leg-set-name {
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leg-set-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--accent);
}
.leg-set-date {
  color: var(--text-muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

/* Banned cards list */
.leg-banned-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 4px 16px;
}
.leg-banned-list li {
  padding: 4px 8px 4px 10px;
  color: var(--text);
  font-size: 0.86rem;
  border-radius: 3px;
  border-left: 2px solid rgba(244, 67, 54, 0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s;
}
.leg-banned-list li:hover {
  background: var(--bg-secondary);
}
.leg-banned-list .card-name-search {
  cursor: pointer;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leg-banned-list .card-name-search:hover { color: var(--accent); }
.leg-zone-tag {
  flex-shrink: 0;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(244, 67, 54, 0.12);
  color: #e66;
  border: 1px solid rgba(244, 67, 54, 0.35);
  font-weight: 600;
  white-space: nowrap;
}
.leg-sub-count {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 4px;
  text-transform: none;
  letter-spacing: normal;
}

/* Banned combos */
.leg-combos {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.leg-combos li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 2px solid rgba(244, 67, 54, 0.5);
  border-radius: 3px;
  font-size: 0.86rem;
}
.leg-combos .card-name-search,
.leg-combos .card-name {
  cursor: pointer;
  color: var(--text);
}
.leg-combos .card-name-search:hover,
.leg-combos .card-name:hover { color: var(--accent); }
.leg-combo-x {
  color: var(--text-muted);
  font-weight: 600;
}

/* Custom rules list */
.leg-rules {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.leg-rules li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid rgba(230, 161, 0, 0.6);
  border-radius: 3px;
  font-size: 0.86rem;
}
.leg-rule-field {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-dim);
  font-weight: 600;
  min-width: 72px;
}
.leg-rule-op {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  color: #e6a100;
}
.leg-rule-value {
  color: var(--text);
  font-weight: 600;
}
.leg-rule-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* View toggle (text vs visual) */
.leg-view-toggle {
  display: inline-flex;
  gap: 2px;
  margin-left: auto;
  align-self: center;
}
.leg-view-btn {
  background: var(--bg-tertiary);
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
}
.leg-view-btn:first-child { border-radius: 4px 0 0 4px; }
.leg-view-btn:last-child { border-radius: 0 4px 4px 0; border-left: none; }
.leg-view-btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* Image rendering — hidden by default, shown in visual mode.
   Each banned-card <li> ships BOTH representations; CSS toggles which one
   is visible so common.js's .card-name hover preview + modal fire naturally
   in list mode. Same pattern as .leg-combo-visual / .leg-combo-text. */
.leg-card-img { display: none; }
.leg-banned-card { display: none; text-decoration: none; color: inherit; }
.leg-card-text {
  cursor: pointer;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.leg-card-text:hover { color: var(--accent); }
.leg-combo-visual { display: none; }

/* Visual mode: show images, swap layout */
body.leg-visual .leg-banned-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
body.leg-visual .leg-banned-list li {
  background: none;
  border: none;
  padding: 0;
  flex-direction: column;
  display: flex;
  align-items: center;
}
body.leg-visual .leg-banned-list li:hover { background: none; }
body.leg-visual .leg-banned-card { display: flex; flex-direction: column; align-items: center; gap: 4px; }
body.leg-visual .leg-card-text { display: none; }
body.leg-visual .leg-banned-list .leg-card-img { display: block; width: 160px; height: auto; border-radius: 6px; }
body.leg-visual .leg-banned-list .card-name-search,
body.leg-visual .leg-banned-list .leg-card-label {
  font-size: 0.78rem;
  text-align: center;
  max-width: 160px;
}

/* Narrow phones: scale tiles down so the grid still produces 2
   columns on ~320-380px viewports instead of one-tall-column. */
@media (max-width: 480px) {
  body.leg-visual .leg-banned-list {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
  }
  body.leg-visual .leg-banned-list .leg-card-img { width: 130px; }
  body.leg-visual .leg-banned-list .card-name-search,
  body.leg-visual .leg-banned-list .leg-card-label { max-width: 130px; }
}

body.leg-visual .leg-combos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
body.leg-visual .leg-combos li {
  background: none;
  border: none;
  padding: 0;
  flex-direction: column;
  display: flex;
  align-items: center;
}
body.leg-visual .leg-combo-text { display: none; }
body.leg-visual .leg-combo-visual {
  display: block;
  position: relative;
  width: 140px;
  height: 200px;
}
body.leg-visual .leg-combo-card {
  position: absolute;
  width: 120px;
  transition: transform 0.2s, z-index 0s;
}
body.leg-visual .leg-combo-card:first-child {
  top: 0; left: 0;
  z-index: 1;
}
body.leg-visual .leg-combo-card-b {
  top: 24px; left: 20px;
  z-index: 2;
}
body.leg-visual .leg-combo-card:hover {
  transform: scale(1.3);
  z-index: 3;
}
body.leg-visual .leg-combo-visual .leg-card-img { display: block; width: 100%; border-radius: 5px; box-shadow: 0 2px 6px rgba(0,0,0,0.5); }
