﻿/**
 * Header search — Nike-style top panel (improved)
 * ------------------------------------------------
 * Full-width white panel slides down from the top.
 * Idle  : popular chips.
 * Typing: loading -> compact product list (image + name + price).
 */

/* ---- Modal shell ---- */
.gg-search-modal {
  position: fixed;
  inset: 0;
  z-index: 2490;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear 0.38s;
}

.gg-search-modal.is-open {
  visibility: visible;
  pointer-events: auto;
  transition: visibility 0s linear 0s;
}

html.gg-search-open,
body.gg-search-open {
  overflow: hidden;
}

html.gg-search-open {
  --gg-scrollbar-gap: 0px;
}

body.gg-search-open {
  padding-right: var(--gg-scrollbar-gap, 0px);
}

body.gg-search-open .site-header {
  right: var(--gg-scrollbar-gap, 0px);
}

body.gg-search-open .announcement,
body.gg-search-open .marquee {
  padding-right: var(--gg-scrollbar-gap, 0px);
}

/* ---- Backdrop ---- */
.gg-search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  transition: opacity 0.32s ease;
}

.gg-search-modal.is-open .gg-search-backdrop {
  opacity: 1;
}

/* ---- Panel ---- */
.gg-search-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: min(86vh, 780px);
  background: #fff;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(-105%);
  transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
  will-change: transform;
}

.gg-search-modal.is-open .gg-search-panel {
  transform: translateY(0);
}

.gg-search-panel__inner {
  display: flex;
  flex-direction: column;
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 14px clamp(16px, 4vw, 36px) 24px;
}

/* ---- Search bar ---- */
.gg-search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0 0 16px;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 16px;
}

.gg-search-form {
  flex: 1 1 auto;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 46px 0 18px;
  border-radius: 999px;
  background: #f5f5f5;
  transition: background 0.18s ease;
}

.gg-search-form:focus-within {
  background: #ececec;
}

.gg-search-icon {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  color: #555;
  pointer-events: none;
}

.gg-search-input {
  flex: 1 1 auto;
  width: 100%;
  min-height: 46px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: #111;
  font-family: var(--font, inherit);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  appearance: none;
  -webkit-appearance: none;
}

.gg-search-input::placeholder {
  color: #aaa;
  font-weight: 400;
}

.gg-search-input::-webkit-search-decoration,
.gg-search-input::-webkit-search-cancel-button,
.gg-search-input::-webkit-search-results-button,
.gg-search-input::-webkit-search-results-decoration {
  display: none;
}

/* Live count badge inside the search pill */
.gg-search-count-badge {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%) scale(0.7);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
}

.gg-search-count-badge.is-visible {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.gg-search-cancel {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: #111;
  font-family: var(--font, inherit);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.gg-search-cancel:hover {
  opacity: 0.5;
}

/* ---- Popular chips ---- */
.gg-search-chips {
  width: 100%;
  padding: 0 0 4px;
}

.gg-search-chips.is-hidden {
  display: none;
}

.gg-search-chips__label {
  display: block;
  margin: 0 0 10px;
  color: #aaa;
  font-family: var(--font, inherit);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gg-search-chips__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gg-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid #e8e8e8;
  background: #fafafa;
  color: #333;
  font-family: var(--font, inherit);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.gg-chip:hover,
.gg-chip:focus-visible {
  background: #111;
  border-color: #111;
  color: #fff;
}

/* ---- Results body ---- */
.gg-search-body {
  width: 100%;
  min-height: 0;
}

.gg-search-live[hidden] {
  display: none !important;
}

/* ---- Loading indicator ---- */
.gg-search-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 0;
}

.gg-search-loading__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #e5e5e5;
  border-top-color: #111;
  border-radius: 50%;
  animation: gg-search-spin 0.6s linear infinite;
  flex-shrink: 0;
}

.gg-search-loading__text {
  margin: 0;
  color: #aaa;
  font-family: var(--font, inherit);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

@keyframes gg-search-spin {
  to { transform: rotate(360deg); }
}

/* ---- Empty / error state ---- */
.gg-search-empty {
  padding: 28px 0 8px;
  color: #888;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
}

/* ---- Results wrapper & header ---- */
.gg-search-results {
  animation: gg-results-in 0.22s ease both;
}

@keyframes gg-results-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.gg-search-results__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 14px;
}

.gg-search-results__count {
  margin: 0;
  color: #aaa;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gg-search-results__view-all-link {
  font-size: 12px;
  font-weight: 600;
  color: #111;
  text-decoration: none;
  letter-spacing: 0.02em;
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
  transition: opacity 0.15s ease;
}

.gg-search-results__view-all-link:hover {
  opacity: 0.55;
}

/* ---- Compact product list (2-col default) ---- */
.gg-search-product-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* Compact product card for search */
.gg-search-product-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 10px;
  background: #fafafa;
  border: 1px solid #f0f0f0;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}

.gg-search-product-item:hover {
  background: #f4f4f4;
  border-color: #ddd;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}

.gg-search-product-item__img {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 7px;
  overflow: hidden;
  background: #efefef;
}

.gg-search-product-item__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gg-search-product-item__info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.gg-search-product-item__cat {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #bbb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gg-search-product-item__name {
  font-size: 13px;
  font-weight: 600;
  color: #111;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gg-search-product-item__price {
  font-size: 13px;
  font-weight: 700;
  color: #111;
  margin-top: 2px;
  line-height: 1;
}

.gg-search-product-item__price ins {
  text-decoration: none;
  color: #c00;
}

.gg-search-product-item__price del {
  font-size: 11px;
  color: #bbb;
  font-weight: 400;
  margin-left: 3px;
}

/* ---- View all footer ---- */
.gg-search-results__more {
  display: flex;
  justify-content: center;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}

.gg-search-results__more .btn {
  min-height: 44px;
  padding: 10px 32px;
  font-size: 14px;
  letter-spacing: 0.04em;
}

/* ---- Screen reader text ---- */
.gg-search-modal .screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Tablet ---- */
@media (min-width: 720px) {
  .gg-search-panel__inner {
    padding-top: 16px;
    padding-bottom: 28px;
  }

  .gg-search-bar {
    padding-bottom: 18px;
    margin-bottom: 18px;
  }

  .gg-search-form {
    min-height: 50px;
    padding: 0 50px 0 20px;
  }

  .gg-search-input {
    min-height: 50px;
    font-size: 16px;
  }

  /* 3-column compact grid */
  .gg-search-product-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .gg-search-product-item__img {
    flex: 0 0 72px;
    width: 72px;
    height: 72px;
  }
}

@media (min-width: 1080px) {
  /* Wide desktop: 4-column */
  .gg-search-product-list {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }
}

/* ---- Mobile ---- */
@media (max-width: 560px) {
  .gg-search-panel {
    max-height: 90vh;
  }

  .gg-search-panel__inner {
    padding: 12px 14px 18px;
  }

  .gg-search-bar {
    gap: 10px;
    padding-bottom: 12px;
    margin-bottom: 12px;
  }

  .gg-search-form {
    min-height: 42px;
    padding: 0 42px 0 14px;
  }

  .gg-search-input {
    min-height: 42px;
    font-size: 14px;
  }

  .gg-search-cancel {
    font-size: 13px;
  }

  .gg-chip {
    min-height: 32px;
    padding: 6px 13px;
    font-size: 12px;
  }

  /* Mobile: horizontal scroll row of cards */
  .gg-search-product-list {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 10px;
    padding-bottom: 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .gg-search-product-list::-webkit-scrollbar {
    display: none;
  }

  .gg-search-product-item {
    flex: 0 0 200px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    scroll-snap-align: start;
    padding: 10px;
  }

  .gg-search-product-item__img {
    flex: 0 0 auto;
    width: 100%;
    height: 110px;
    border-radius: 7px;
  }

  .gg-search-product-item__info {
    gap: 4px;
  }
}
