/**
 * 案例站壳层：顶栏 / 登录弹层 / GitHub 式星标 / 案例库主页
 * 色值走 tokens.css
 */

.gh-topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  overflow: visible;
  background: var(--color-text-primary);
  border-bottom: 0;
}

.gh-topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
  min-height: 56px;
  padding: 8px var(--space-lg);
}

.gh-topbar-left,
.gh-topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
}

.gh-topbar-right {
  position: relative;
}

.gh-topbar-search {
  position: relative;
  flex: 1 1 220px;
  max-width: 420px;
  margin-left: auto;
}

.gh-topbar-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 210;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
}

.gh-topbar-suggest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-primary);
  font-size: var(--font-body);
  text-align: left;
  cursor: pointer;
}

.gh-topbar-suggest-item:last-child {
  border-bottom: none;
}

.gh-topbar-suggest-item:hover,
.gh-topbar-suggest-item:focus {
  background: var(--color-bg-muted);
}

.gh-topbar-suggest-type {
  flex-shrink: 0;
  color: var(--color-text-secondary);
  font-size: var(--font-caption);
}

.gh-topbar-input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text-inverse);
  font-size: var(--font-body);
}

.gh-topbar-input::placeholder {
  color: rgba(255, 255, 255, 0.62);
}

.gh-topbar-input:focus {
  outline: 2px solid var(--color-primary);
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.12);
}

.gh-topbar-right {
  position: relative;
}

.gh-logo {
  font-size: var(--font-h3);
  font-weight: 600;
  color: var(--color-text-inverse);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.gh-topbar-link {
  font-size: var(--font-body);
  color: var(--color-text-inverse);
  text-decoration: none;
  opacity: 0.85;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}

.gh-topbar-link.is-on {
  opacity: 1;
  border-bottom-color: var(--color-primary);
}

.gh-topbar-link:hover,
.gh-logo:hover {
  opacity: 1;
  color: var(--color-text-inverse);
}

.gh-header-signin {
  appearance: none;
  border: 1px solid var(--color-text-inverse);
  background: transparent;
  color: var(--color-text-inverse);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: var(--font-body);
  line-height: 20px;
  cursor: pointer;
}

.gh-header-signin:hover {
  background: var(--color-text-primary);
  opacity: 0.9;
}

.gh-btn {
  appearance: none;
  border: 1px solid var(--color-border);
  background: var(--color-bg-muted);
  color: var(--color-text-primary);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: var(--font-body);
  line-height: 20px;
  cursor: pointer;
  text-decoration: none;
}

.gh-btn:hover {
  background: var(--color-bg-page);
}

.gh-btn--primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
}

.gh-btn--primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  color: var(--color-text-inverse);
}

.gh-btn:disabled,
.gh-btn--primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.gh-user-wrap {
  position: relative;
}

.gh-user-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  border: 0;
  background: transparent;
  color: var(--color-text-inverse);
  cursor: pointer;
  padding: 0;
  font-size: var(--font-body);
}

.gh-user-menu-name {
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gh-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 168px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 4px 0;
  z-index: 220;
}

.gh-menu a,
.gh-menu button {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--color-text-primary);
  font-size: var(--font-body);
  cursor: pointer;
  text-decoration: none;
}

.gh-menu a:hover,
.gh-menu button:hover {
  background: var(--color-bg-muted);
}

.gh-avatar,
.gh-star-avatar,
.gh-avatar-lg {
  display: inline-block;
  border-radius: var(--radius-full);
  background: var(--color-bg-muted);
  object-fit: cover;
  flex-shrink: 0;
}

.gh-avatar {
  width: 28px;
  height: 28px;
}

.gh-avatar-lg {
  width: 96px;
  height: 96px;
  border: 1px solid var(--color-border);
}

.gh-avatar.is-letter,
.gh-avatar-lg.is-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.gh-avatar.is-letter {
  font-size: 12px;
}

.gh-avatar-lg.is-letter {
  font-size: 36px;
}

/* —— 登录弹层 —— */
.gh-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--z-h5-sheet);
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

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

.gh-modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--color-mask);
}

.gh-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
}

.gh-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 0;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 22px;
  line-height: 1;
  width: 32px;
  height: 32px;
  cursor: pointer;
}

.gh-modal-dialog h2 {
  margin: 0 0 var(--space-xs);
  font-size: var(--font-h2);
  font-weight: 600;
}

.gh-modal-sub {
  margin: 0 0 var(--space-lg);
  color: var(--color-text-secondary);
  font-size: var(--font-caption);
}

.gh-field {
  display: block;
  width: 100%;
  margin-bottom: var(--space-md);
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-body);
  background: var(--color-bg-card);
  color: var(--color-text-primary);
}

.gh-field:focus {
  outline: 2px solid var(--color-primary-light);
  border-color: var(--color-primary);
}

.gh-code-row {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.gh-code-row .gh-field {
  flex: 1;
  margin-bottom: 0;
}

.gh-code-row .gh-btn {
  flex: 0 0 108px;
}

.gh-modal-err,
.gh-modal-hint {
  margin: 0 0 var(--space-sm);
  font-size: var(--font-caption);
}

.gh-modal-err {
  color: var(--color-danger);
}

.gh-modal-hint {
  color: var(--color-text-secondary);
}

.gh-modal-dialog .gh-btn--primary {
  width: 100%;
  padding: 8px 12px;
}

/* —— 星标（GitHub BtnGroup） —— */
.gh-repo-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-md);
}

.gh-repo-head .h5-title {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.gh-star {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
  flex-shrink: 0;
}

.gh-star-list {
  display: flex;
  align-items: center;
  margin-top: 0;
  padding-left: 2px;
}

.gh-star-btns {
  display: inline-flex;
  vertical-align: middle;
}

.gh-star-action,
.gh-star-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  color: var(--color-text-secondary);
  font-size: var(--font-caption);
  font-weight: 500;
  line-height: 20px;
}

.gh-star-action {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  cursor: pointer;
}

.gh-star-count {
  border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  min-width: 36px;
  font-variant-numeric: tabular-nums;
}

.gh-star-action:hover,
.gh-star-count:hover {
  background: var(--color-bg-page);
}

.gh-star-icon {
  width: 16px;
  height: 16px;
  fill: var(--color-text-secondary);
}

.gh-star-action.is-on {
  background: var(--color-bg-card);
}

.gh-star-action.is-on .gh-star-icon {
  fill: var(--color-primary);
}

.gh-star-avatar {
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-bg-card);
  margin-left: -6px;
}

.gh-star-list .gh-star-avatar:first-child,
.gh-star-list a:first-child .gh-star-avatar {
  margin-left: 0;
}

.gh-star-hint {
  margin: var(--space-xs) 0 0;
  font-size: var(--font-caption);
  color: var(--color-text-tertiary);
}

/* —— 案例库主页 —— */
.gh-profile {
  max-width: var(--max-width-library);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg) 64px;
  display: grid;
  grid-template-columns: 256px 1fr;
  gap: 32px;
}

.gh-profile-name {
  margin: var(--space-md) 0 var(--space-xs);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
}

.gh-profile-meta {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: var(--font-body);
}

.gh-tabs {
  display: flex;
  gap: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-lg);
}

.gh-tab {
  padding: var(--space-sm) 0;
  border-bottom: 2px solid transparent;
  color: var(--color-text-primary);
  font-size: var(--font-body);
  text-decoration: none;
}

.gh-tab.is-on {
  border-bottom-color: var(--color-primary);
  font-weight: 600;
  color: var(--color-primary);
}

.gh-repo {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: var(--space-md);
  align-items: center;
  padding: var(--space-lg) 0;
  border-bottom: 1px solid var(--color-border);
  color: inherit;
  text-decoration: none;
}

a.gh-repo:hover .gh-repo-title {
  color: var(--color-primary);
}

.gh-repo-title {
  color: var(--color-text-primary);
}

.gh-repo-thumb {
  width: 64px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-muted);
  border: 1px solid var(--color-border);
  object-fit: cover;
}

.gh-tabs .gh-tab {
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.gh-repo h2 {
  margin: 0 0 var(--space-xs);
  font-size: var(--font-h3);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.gh-repo h2 a {
  color: var(--color-primary);
}

.gh-label {
  display: inline-block;
  padding: 0 7px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-caption);
  color: var(--color-text-secondary);
  font-weight: 500;
}

.gh-repo-meta {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: var(--font-caption);
}

.gh-blankslate {
  max-width: 540px;
  margin: 72px auto;
  padding: 0 var(--space-lg);
  text-align: center;
}

.gh-blankslate h1 {
  margin: 0 0 var(--space-sm);
  font-size: 24px;
}

.gh-blankslate p {
  margin: 0 0 var(--space-lg);
  color: var(--color-text-secondary);
}

.gh-empty {
  padding: 40px 0;
  text-align: center;
  color: var(--color-text-secondary);
}

.gh-err {
  color: var(--color-danger);
  font-size: var(--font-body);
}

@media (max-width: 768px) {
  .gh-profile {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .gh-repo-head {
    flex-direction: column;
    align-items: stretch;
  }

  .gh-topbar-search {
    flex: 1 1 100%;
    max-width: none;
    order: 3;
    margin-left: 0;
  }
}

.gh-profile-label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: var(--font-caption);
  color: var(--color-text-secondary);
}

.gh-profile-form .gh-btn {
  margin-top: var(--space-sm);
}

.gh-profile-store-block {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border);
}

.gh-profile-store-block h2 {
  margin: 0 0 var(--space-sm);
  font-size: var(--font-h3);
}

.gh-profile-store {
  margin: 0 0 var(--space-sm);
  color: var(--color-text-secondary);
  font-size: var(--font-body);
  line-height: 1.6;
}
.gh-profile[hidden],
.gh-blankslate[hidden],
.gh-modal-err[hidden],
.gh-modal-hint[hidden],
.gh-menu[hidden] {
  display: none !important;
}
