/* ===================================================
   Brand Modal
   =================================================== */

/* Overlay */
.brand-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 1100;
}

.brand-modal-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

/* Dialog */
.brand-modal {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  z-index: 1101;
  padding: 16px;
}

.brand-modal.is-open {
  display: flex;
}

.brand-modal__inner {
  background: var(--color-bg);
  border-radius: 16px;
  width: 100%;
  max-width: 820px;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  position: relative;
}

/* Close button: sticky so it stays visible when modal content scrolls */
.brand-modal__close {
  display: none;
  position: sticky;
  top: 16px;
  align-self: flex-end;
  margin-top: 16px;
  margin-right: 16px;
  margin-bottom: -52px; /* -(margin-top 16px + height 36px) — pull hero up to cover gap */
  z-index: 1110;
  background: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--color-text-emphasis);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}

.brand-modal.is-open .brand-modal__close {
  display: flex;
}

.brand-modal__close:hover {
  background: #fff;
  color: var(--color-text-emphasis);
}

/* Header: flex column — brand-core (sticky on all) + brand-body (sticky on desktop, scrolls on mobile) */
.brand-modal__header {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  background: var(--color-bg);
  z-index: 10;
  border-bottom: 1px solid var(--color-border);
  border-radius: 16px 16px 0 0;
}

/* Brand core: title row */
.brand-modal__brand-core {
  padding: 16px 24px 8px;
}

/* Brand body: logo + short-desc row */
.brand-modal__brand-body-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 0 24px 16px;
  min-width: 0;
}

.brand-modal__brand-logo {
  width: 130px;
  height: 130px;
  border-radius: 0;
  object-fit: cover;
  flex-shrink: 0;
}

.brand-modal__title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text-emphasis);
  line-height: 1.3;
}

.brand-modal__short-desc {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.4;
}

/* Hero */
.brand-modal__hero {
  position: relative;
  aspect-ratio: 2 / 1;
  overflow: hidden;
  border-radius: 16px 16px 0 0;
  background: var(--color-skeleton);
  flex-shrink: 0;
}

.brand-modal__hero-skeleton {
  position: absolute;
  inset: 0;
  border-radius: 0;
  animation: sk-pulse 1.5s ease-in-out infinite;
}

.brand-modal__hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.3s;
}

.brand-modal__hero-img.is-loaded {
  opacity: 1;
}

/* Shops section */
.brand-modal__shops-section {
  display: flex;
  flex-direction: column;
}

.brand-modal__shops-heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
  padding: 16px 24px 0;
}

/* Purchase Request CTA (0-shop fallback) */
.brand-modal__purchase-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.brand-modal__purchase-link {
  display: inline-flex;
  align-items: center;
  background: var(--color-accent-soft);
  color: #fff;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s;
}

.brand-modal__purchase-link:hover {
  background: var(--color-accent);
  color: #fff;
}

/* Body: shop card grid */
.brand-modal__body {
  padding: 20px 24px 24px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (max-width: 689px) {
  .brand-modal__hero {
    aspect-ratio: 3 / 2; /* Mobile: 現行維持 */
  }

  .brand-modal__body {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  /* Req 3: display:contents removes the header box — brand-core and brand-body
     become direct flex children of brand-modal__inner, so brand-core's sticky
     range is bounded by inner (not by the header's height). */
  .brand-modal__header {
    display: contents;
  }

  .brand-modal__brand-core {
    position: sticky;
    top: 0;
    background: var(--color-bg);
    z-index: 10;
    padding: 16px 24px;
    border-bottom: 1px solid var(--color-border);
  }

  .brand-modal__brand-body-wrapper {
    padding: 24px 24px 16px;
  }
}

/* Empty / error states */
.brand-modal__empty,
.brand-modal__error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 16px;
  color: var(--color-text-subtle);
  font-size: 15px;
}

/* Body scroll lock */
body.brand-modal-open {
  overflow: hidden;
}

/* ===================================================
   Shop Card
   =================================================== */

.shop-card {
  background: var(--color-bg);
  border: 1.5px solid var(--color-surface);
  border-radius: 12px;
  padding: 16px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Top row: info | logo */
.shop-card__top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.shop-card__info {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shop-card__title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
  color: var(--color-text-emphasis);
}

/* Categories */
.shop-card__categories {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.shop-card__category {
  font-size: 13px;
  color: var(--color-text);
  line-height: 1.4;
}

.shop-card__category .fa-folder-open {
  color: var(--color-accent);
  margin-right: 4px;
}

/* Go to Shop button */
.shop-card__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--color-accent-soft);
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
  width: 100%;
  box-sizing: border-box;
  margin-top: auto;
}

.shop-card__btn:hover {
  background: var(--color-accent);
  color: #fff;
}

/* Logo */
.shop-card__logo-wrap {
  flex: 0 0 130px;
  width: 130px;
  height: 130px;
}

.shop-card__logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

/* Description */
.shop-card__desc {
  font-size: 13px;
  line-height: 1.65;
  color: var(--color-text-muted);
  margin: 0;
}

/* ===================================================
   Skeleton
   =================================================== */

@keyframes sk-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

.shop-card--skeleton {
  pointer-events: none;
}

.sk-block {
  background: var(--color-skeleton);
  border-radius: 4px;
  animation: sk-pulse 1.5s ease-in-out infinite;
}

.sk-title {
  height: 20px;
  width: 65%;
}

.sk-chip {
  height: 14px;
  width: 55%;
}

.sk-chip--short {
  width: 38%;
}

.sk-btn {
  height: 38px;
  width: 100%;
  border-radius: 8px;
  margin-top: 4px;
}

.sk-logo {
  flex: 0 0 130px;
  width: 130px;
  height: 130px;
  border-radius: 12px;
}

.sk-line {
  height: 13px;
  width: 100%;
}

.sk-line--short {
  width: 55%;
}
