/* Fonts Assets — typography library browsing */

.mp-fonts-stack {
  margin-bottom: clamp(20px, 3vw, 36px);
}

.mp-fonts-stack[hidden] {
  display: none !important;
}

.mp-fonts-market {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(360px, 34vw);
  gap: clamp(20px, 3vw, 40px);
  align-items: start;
}

.mp-fonts-market__main {
  min-width: 0;
}

.mp-fonts-market__list {
  display: flex;
  flex-direction: column;
  gap: 0;
  --mp-font-preview-size: 48px;
}

/* —— Font rows (Google Fonts–style flat list) —— */
.mp-fonts-item {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  content-visibility: auto;
  contain-intrinsic-size: auto 72px;
}

.mp-fonts-item__card {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 14px 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.mp-fonts-item:hover .mp-fonts-item__card {
  transform: none;
  border: none;
  background: transparent;
  box-shadow: none;
}

.mp-fonts-item:not(:last-child) .mp-fonts-item__card {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mp-fonts-item__head {
  margin: 0;
  padding: 0;
  min-width: 0;
}

.mp-fonts-item__title-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.mp-fonts-item__name {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-body, inherit);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-transform: none;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-fonts-item__designer {
  margin: 3px 0 0;
  font-family: var(--font-body, inherit);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-fonts-item__commerce {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 5px;
  margin: 0;
  flex-shrink: 0;
}

.mp-fonts-item__actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
}

.mp-fonts-item__price {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--accent);
  opacity: 0.9;
}

.mp-fonts-item--free .mp-fonts-item__price--free {
  color: #7dffb2;
  opacity: 1;
}

.mp-fonts-item__actions--free {
  justify-content: flex-end;
}

.mp-fonts-item__actions--free .mp-fonts-item__btn--dl:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.mp-fonts-item__btn {
  --bh: auto;
  height: auto;
  min-height: 0;
  padding: 3px 8px;
  gap: 0;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.02em;
  border-radius: 5px;
  white-space: nowrap;
  overflow: visible;
}

.mp-fonts-item__btn svg {
  display: none;
}

.mp-fonts-item__showcase {
  margin: 6px 0 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.mp-fonts-item:hover .mp-fonts-item__showcase {
  background: transparent;
  border: none;
}

.mp-fonts-item__sample {
  display: block;
  margin: 0;
  padding: 0;
  line-height: 1.15;
  min-height: 0;
  color: rgba(255, 255, 255, 0.94);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--mp-font-preview-size, 48px);
}

.mp-fonts-empty {
  padding: 40px 0;
  text-align: center;
}

.mp-fonts-count {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Sticky preview panel (desktop) */
.mp-fonts-market__aside {
  position: sticky;
  top: calc(var(--header-h, 72px) + 20px);
  align-self: start;
  z-index: 2;
}

.mp-fonts-market__panel {
  position: relative;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(165deg, rgba(18, 18, 20, 0.95) 0%, rgba(10, 10, 12, 0.98) 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.mp-fonts-panel__backdrop {
  display: none;
}

.mp-fonts-panel__inner {
  padding: clamp(18px, 2.4vw, 24px);
}

.mp-fonts-panel__mobile-head {
  display: none;
}

.mp-fonts-panel__block + .mp-fonts-panel__block {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.mp-fonts-panel__label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.mp-fonts-panel__label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mp-fonts-panel__label-row .mp-fonts-panel__label {
  margin-bottom: 0;
}

.mp-fonts-panel__size-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.mp-fonts-panel__input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: var(--font-body, inherit);
  font-size: 15px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.mp-fonts-panel__input:focus {
  outline: none;
  border-color: rgba(230, 195, 137, 0.45);
  box-shadow: 0 0 0 3px rgba(230, 195, 137, 0.08);
}

.mp-fonts-panel__hint {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.45;
}

.mp-fonts-panel__range {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.mp-fonts-panel__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mp-fonts-panel__pills--scroll {
  max-height: 180px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(230, 195, 137, 0.35) transparent;
  -webkit-overflow-scrolling: touch;
}

.mp-fonts-filter {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 9px 14px;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 12, 14, 0.8);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.3s ease, background 0.3s ease, transform 0.3s ease;
}

.mp-fonts-filter:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.mp-fonts-filter.is-active {
  color: #e6c389;
  border-color: rgba(230, 195, 137, 0.45);
  background: rgba(230, 195, 137, 0.08);
}

/* Mobile filter FAB + slide panel */
.mp-fonts-market__fab {
  display: none;
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 4500;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid rgba(230, 195, 137, 0.35);
  background: rgba(12, 12, 14, 0.92);
  backdrop-filter: blur(12px);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(230, 195, 137, 0.15);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.mp-fonts-market__fab:hover {
  transform: translateY(-2px);
  border-color: rgba(230, 195, 137, 0.55);
}

.mp-fonts-market__fab[hidden] {
  display: none !important;
}

@media (max-width: 1024px) {
  .page-marketplace .mp-fonts-stack,
  .page-free-marketplace .mp-fonts-stack {
    margin-bottom: 14px;
    width: 100%;
  }

  .page-marketplace .mp-fonts-market,
  .page-free-marketplace .mp-fonts-market {
    width: 100%;
  }

  .mp-fonts-market {
    grid-template-columns: 1fr;
  }

  /* Desktop sidebar hidden on mobile — use FAB + bottom drawer */
  .mp-fonts-market__aside {
    display: none !important;
  }

  .mp-fonts-market__fab {
    display: inline-flex;
    cursor: pointer !important;
  }

  .mp-fonts-panel__mobile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .mp-fonts-panel__mobile-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
  }

  .mp-fonts-panel__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: var(--text);
    cursor: pointer;
  }

  .mp-fonts-market__list {
    gap: 0;
  }

  .mp-fonts-count {
    margin-bottom: 10px;
  }

  .mp-fonts-stack {
    margin-bottom: 14px;
  }

  .mp-fonts-item__card {
    padding: 12px 0;
  }

  .mp-fonts-item__name {
    font-size: 13px;
  }

  .mp-fonts-item__designer {
    font-size: 11px;
  }

  .mp-fonts-item__price {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-bright);
  }

  .mp-fonts-item__btn {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 9px;
    letter-spacing: 0.08em;
    border-radius: 8px;
  }

  .mp-fonts-market__fab {
    padding: 10px 16px;
    font-size: 9px;
    border-color: rgba(255, 106, 0, 0.35);
    background: linear-gradient(135deg, rgba(22, 22, 26, 0.94) 0%, rgba(14, 14, 16, 0.9) 100%);
  }
}

body.mp-fonts-panel-open {
  overflow: hidden;
}

/* Mobile-only filter drawer (body level — always on top) */
.mp-fonts-mdrawer {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mp-fonts-mdrawer[hidden] {
  display: none !important;
}

.mp-fonts-mdrawer.is-open {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
}

.mp-fonts-mdrawer__backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  pointer-events: auto;
}

.mp-fonts-mdrawer__sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: min(92vh, 720px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 20px 20px 0 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: none;
  background: linear-gradient(165deg, rgba(22, 22, 26, 0.99) 0%, rgba(10, 10, 12, 1) 100%);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.55);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateY(100%);
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: auto;
}

.mp-fonts-mdrawer.is-open .mp-fonts-mdrawer__sheet {
  transform: translateY(0);
}

.mp-fonts-mdrawer .mp-fonts-panel__backdrop {
  display: none !important;
}

.mp-fonts-mdrawer .mp-fonts-panel__inner {
  padding: 20px 18px 24px;
}

.mp-fonts-mdrawer .mp-fonts-panel__mobile-head {
  display: flex;
}

.mp-fonts-mdrawer .mp-fonts-panel__input,
.mp-fonts-mdrawer .mp-fonts-panel__range,
.mp-fonts-mdrawer .mp-fonts-filter,
.mp-fonts-mdrawer .mp-fonts-panel__close {
  cursor: pointer !important;
}

@media (min-width: 1025px) {
  .mp-fonts-mdrawer {
    display: none !important;
  }
}

@media (min-width: 1025px) {
  .mp-main__content:has(.mp-fonts-stack:not([hidden])) .mp-grid[hidden] {
    display: none;
  }

  .mp-fonts-market {
    grid-template-columns: minmax(0, 1fr) min(300px, 28vw);
    gap: clamp(36px, 5vw, 72px);
  }

  .mp-fonts-market__fab {
    display: none !important;
  }

  .mp-fonts-market__aside {
    display: block;
    position: sticky;
    top: calc(var(--header-h, 72px) + 20px);
    align-self: start;
    margin-left: clamp(24px, 4vw, 56px);
    margin-right: clamp(0px, 1vw, 12px);
    width: 100%;
    max-width: min(300px, 28vw);
    pointer-events: auto;
    visibility: visible;
    z-index: 2;
  }

  .mp-fonts-panel__backdrop {
    display: none !important;
  }

  .mp-fonts-market__panel {
    position: relative;
    transform: none;
    width: auto;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: visible;
  }

  .mp-fonts-panel__inner {
    overflow: visible;
  }

  .mp-fonts-panel__pills--scroll {
    max-height: 200px;
  }

  /* Slightly roomier rows on large screens */
  .mp-fonts-item__card {
    padding: 16px 0;
  }

  .mp-fonts-item__name {
    font-size: 15px;
  }

  .mp-fonts-item__designer {
    font-size: 12px;
  }

  .mp-fonts-item__btn {
    padding: 4px 10px;
    font-size: 11px;
  }
}
