/* ══════════════════════════════════════════════════════════════════════════════
   MTG HEADER — Top bar, Search, Toolbar, Autocomplete
   ══════════════════════════════════════════════════════════════════════════════ */
:root {
  --mtg-sticky-top: 98px; /* height of the site header above the buylist */
  --mtg-header-height: 57px; /* .mtg-header: 10px padding ×2 + 36px button + 1px border */
}

/* ── Title and subtitle header ────────────────────────────────────────────── */
.mtg-title-header {
  top: 144px;

  gap: calc(var(--spacing) * 2);
  padding-block: calc(var(--spacing) * 5);
  padding-inline: calc(var(--spacing) * 8);
  background-color: #ebe4d5;

  border-bottom: var(--border) solid;
  border-bottom-width: 1px;
}

.mtg-title-header-box {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: calc(var(--spacing) * 3);

  background-color: #f5efe4;
  border-radius: 1rem;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);

  padding-block: calc(var(--spacing) * 6);
  padding-inline: calc(var(--spacing) * 7);
}
.mtg-title-header-h1 {
  color: #2d2418;
  letter-spacing: -0.03em;
  line-height: 1.08;
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: var(--font-weight-bold);
  font-family: var(--font-serif);
}

.mtg-title-header-h2 {
  font-size: 16px;
  font-weight: var(--font-weight-normal);
  color: color-mix(in oklab, #2d2418 65%, transparent);
  line-height: 1.55;
  white-space: pre-line;
}

.mtg-title-header-update {
  color: #8b6721;
  font-weight: var(--font-weight-semibold);
  font-size: 14px;
}

.mtg-title-header-lightningIcon {
  color: #c69e0a;
}

.mtg-title-header-infoIcon {
  color: #707070;
}

.mtg-title-header-buttons {
  display: flex;
  gap: calc(var(--spacing) * 2);
}

.mtg-title-header-btn {
  display: flex;
  transition: all 0.2s ease;
  line-height: 1.5;
  gap: calc(var(--spacing) * 1.5);
  align-items: center;

  background-color: #f5efe4;
  border: #c8b98a 1px solid;
  border-radius: var(--radius);

  padding-block: calc(var(--spacing) * 2);
  padding-inline: calc(var(--spacing) * 4);

  cursor: pointer;
}

.mtg-title-header-btn:hover {
  background: var(--mutedHover);
}
/* ── Top Header bar ───────────────────────────────────────────────────────────── */
.mtg-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: var(--mtg-sticky-top);
  z-index: 100;
}

.mtg-header-left {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.mtg-header-right {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

/* ── Header buttons ───────────────────────────────────────────────────────── */
.mtg-header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  background: var(--muted);
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  cursor: pointer;
  position: relative;
  transition:
    background 0.15s,
    border-color 0.15s;
  white-space: nowrap;
}
.mtg-header-btn:hover:not(:disabled) {
  background: var(--mutedHover);
  border-color: #ccc;
}
.mtg-header-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.mtg-header-btn-icon {
  font-size: 15px;
}

.mtg-header-btn--cart {
  background: var(--darkBrown);
  color: #fff;
  border-color: var(--darkBrown);
}
.mtg-header-btn--cart:hover {
  background: var(--lightBrown) !important;
  border-color: #41392f !important;
}

/* ── Second Header Bar ─────────────────────────────────────────────── */
.mtg-main-header {
  background-color: var(--lightEggshell);
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #bbb;
  position: sticky;
  top: calc(var(--mtg-sticky-top) + var(--mtg-header-height));
  gap: 12px;
  z-index: 10;
}

.mtg-main-header-left,
.mtg-main-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mtg-main-header-left {
  flex: 2;
  justify-content: flex-start;
}

.mtg-main-header-right {
  flex: 1;
  justify-content: flex-end;
}

/* ── Badges on header buttons ─────────────────────────────────────────────── */
.mtg-filter-badge,
.mtg-cart-count {
  background: var(--yellow);
  color: #111;
  font-size: 10px;
  font-weight: 700;
  border-radius: 99px;
  padding: 1px 5px;
  position: absolute;
  top: -6px;
  right: -6px;
  text-align: center;
  line-height: 1.4;
}

/* ── Search bar ───────────────────────────────────────────────────────────── */
.mtg-header-search {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  border: 1.5px solid #ccc;
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  gap: 6px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  max-width: 28rem;
  min-width: 200px;
}
.mtg-header-search:focus-within {
  border-color: #1a1a2e;
  box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.07);
}
.mtg-search-icon {
  font-size: 15px;
  color: #666;
  flex-shrink: 0;
}
.mtg-input {
  flex: 1;
  --has-height: 36px;
  border: none;
  outline: none;
  --theme-form-font-size: 14px;
  background: transparent;
  --theme-form-text-initial-color: #111;
  --theme-form-field-border-style: none;
}
.mtg-input::placeholder {
  color: #bbb;
}
.mtg-clear-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  font-size: 15px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  transition:
    background 0.15s,
    color 0.15s;
}
.mtg-clear-btn:hover {
  background: #f0f0f0;
  color: #333;
}

/* ── Autocomplete dropdown ────────────────────────────────────────────────── */
.mtg-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  list-style: none;
  margin: 0;
  padding: 6px 0;
  max-height: 300px;
  overflow-y: auto;
}
.mtg-dd-item {
  padding: 9px 16px;
  font-size: 14px;
  color: #222;
  cursor: pointer;
  transition: background 0.1s;
}
.mtg-dd-item:hover,
.mtg-dd-item--active {
  background: #f4f4f8;
}
.mtg-dd-item strong {
  color: #1a1a2e;
  font-weight: 700;
}

/* ── Toolbar (view buttons + sort + card count) ───────────────────────────── */
.mtg-header-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.mtg-card-count-label {
  font-size: 13px;
  color: #777;
  white-space: nowrap;
  max-width: 60px;
  font-family: var(--font-sans);
}

.mtg-view-btns {
  display: flex;
  border: none;
  border-radius: 6px;
  background-color: var(--white);
  padding: 1px;
}
.mtg-view-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: #fff;
  color: #888;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
  border-radius: 6px;
}
.mtg-view-btn:last-child {
  border-right: none;
}
.mtg-view-btn:hover {
  background: var(--muted);
  color: #333;
}
.mtg-view-btn--active {
  background: var(--darkBrown);
  color: #fff;
}
.mtg-view-btn--active:hover {
  color: #fff;
}
.mtg-view-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}
.mtg-view-btn svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  width: 15px;
  height: 15px;
}

.mtg-sort-select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: #333;
  cursor: pointer;
  min-width: 130px;
}
.mtg-sort-select:focus {
  outline: none;
  border-color: #1a1a2e;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .mtg-card-count-label {
    display: none;
  }
}

@media (max-width: 600px) {
  .mtg-main-header {
    display: flex;
    flex-direction: column;
  }
}

@media (max-width: 450px) {
  .mtg-title-header-buttons {
    flex-direction: column;
    width: 160px;
  }
}
