/* 서비스 디렉터리 (/services) — Horizon v2 토큰 기반 */

.services-body {
  /*
   * 헤더와 본문이 공유하는 단일 키라인. 브레이크포인트마다 이 값만 바꾸면 둘이 함께 움직여
   * 세로 기준선이 어긋날 수 없다.
   */
  --services-keyline: var(--keyline-x, var(--space-6));
  background: var(--background);
  color: var(--foreground);
}

/*
 * 공용 헤더는 기본적으로 --main-header-max-width(1200px) 밴드에 중앙정렬된다. 이 페이지 본문은
 * full-bleed 라서 그대로 두면 헤더만 안쪽으로 124px씩 들어가 로고가 본문 좌측 기준선과,
 * 로그인 위젯이 그리드 우측 기준선과 어긋난다.
 * (본문이 full-width인 GIS 페이지가 body.gis-body에서 쓰는 것과 같은 방식)
 */
.services-body .block-app-header .header-inner {
  max-width: none;
  padding-inline: var(--services-keyline);
}

.services-content {
  width: min(100%, var(--page-max, 1440px));
  max-width: none;
  margin-inline: auto;
  padding: calc(var(--main-header-height, 56px) + var(--space-8)) var(--services-keyline) var(--space-12);
}

/* Intro and search */
.services-intro {
  display: grid;
  gap: var(--space-6);
  max-width: 48rem;
  padding-block: 0 var(--space-10);
}

.services-intro-copy {
  display: grid;
  gap: var(--space-2);
  max-width: 42rem;
}

.services-intro-eyebrow,
.services-results-label,
.services-category-label {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--fs-2xs);
  line-height: var(--lh-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.services-intro-title {
  margin: 0;
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.services-intro-lead {
  max-width: 40rem;
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--fs-body-lg);
  line-height: var(--lh-body);
}

.services-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-2);
  width: min(100%, 42rem);
  min-height: var(--control-h-l);
  padding-inline: var(--space-4) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.services-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 24%, transparent);
}

.services-search-icon {
  color: var(--muted-foreground);
  font-size: var(--control-icon-m);
}

.services-search input {
  min-width: 0;
  height: calc(var(--control-h-l) - 2px);
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-size: var(--control-font-m);
}

.services-search input::placeholder {
  color: var(--muted-foreground);
  opacity: 1;
}

.services-search input::-webkit-search-cancel-button {
  display: none;
}

.services-search-clear {
  display: inline-grid;
  place-items: center;
  width: var(--control-h-s);
  height: var(--control-h-s);
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
}

.services-search-clear[hidden] {
  display: none;
}

.services-search-clear:hover {
  background: var(--muted);
  color: var(--foreground);
}

.services-search-clear:focus-visible,
.services-category-link:focus-visible,
.services-group-link:focus-visible,
.services-card:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.services-search-shortcut {
  min-width: var(--control-h-s);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--muted);
  color: var(--muted-foreground);
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-2xs);
  line-height: 1;
  text-align: center;
  box-shadow: none;
}

/* Directory shell */
.services-directory {
  border-top: 1px solid var(--border);
  padding-top: var(--space-8);
}

.services-directory-layout {
  display: grid;
  grid-template-columns: 13.5rem minmax(0, 1fr);
  gap: var(--space-8);
  align-items: start;
}

.services-category-rail {
  position: sticky;
  top: calc(var(--main-header-height, 48px) + var(--space-6));
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.services-category-label {
  padding-inline: var(--space-3);
}

.services-category-nav {
  display: grid;
  gap: var(--space-1);
  scroll-padding-inline: var(--space-2);
}

.services-category-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-h-m);
  padding: var(--space-2) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted-foreground);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.services-category-link .hz-icon {
  font-size: var(--control-icon-s);
}

.services-category-link:hover {
  background: var(--muted);
  color: var(--foreground);
}

.services-category-link.is-active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--card));
  color: var(--foreground);
}

.services-category-count {
  min-width: var(--space-6);
  padding-inline: var(--space-1-5);
  border-radius: var(--radius-full);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: var(--fs-2xs);
  line-height: var(--lh-sm);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.services-category-link.is-active .services-category-count {
  background: color-mix(in srgb, var(--primary) 14%, var(--muted));
  color: var(--foreground);
}

.services-results-column {
  min-width: 0;
}

.services-results-head {
  display: grid;
  gap: var(--space-4);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
}

.services-results-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-4);
}

.services-results-heading > div {
  display: grid;
  gap: var(--space-1);
}

.services-results-title {
  margin: 0;
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  font-weight: 700;
  scroll-margin-top: calc(var(--main-header-height, 56px) + var(--space-4));
}

.services-results-summary {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  text-align: right;
}

.services-filterbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.services-filterbar-label {
  flex: 0 0 auto;
  color: var(--muted-foreground);
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  font-weight: 600;
}

.services-access-filters {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
}

.services-access-filter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  flex: 0 0 auto;
  min-height: var(--control-h-s);
  padding-inline: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--card);
  color: var(--muted-foreground);
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.services-access-filter:hover {
  background: var(--muted);
  color: var(--foreground);
}

.services-access-filter[aria-pressed="true"] {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--card));
  color: var(--foreground);
}

.services-access-filter:focus-visible,
.services-filters-clear:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.services-access-count {
  min-width: var(--space-5);
  color: var(--muted-foreground);
  font-size: var(--fs-2xs);
  line-height: var(--lh-xs);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.services-access-filter[aria-pressed="true"] .services-access-count {
  color: var(--foreground);
}

.services-filters-clear {
  flex: 0 0 auto;
  margin-left: auto;
}

.services-filters-clear[hidden] {
  display: none;
}

.services-results {
  display: grid;
  gap: var(--space-10);
  padding-top: var(--space-6);
}

.services-group {
  display: grid;
  gap: var(--space-4);
}

.services-group-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-4);
}

.services-group-copy {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.services-group-title {
  margin: 0;
  font-size: var(--fs-h3);
  line-height: var(--lh-h3);
  font-weight: 700;
}

.services-group-tagline {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
}

.services-group-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  flex: 0 0 auto;
  min-height: var(--control-h-s);
  padding-inline: var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--muted-foreground);
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  font-weight: 600;
  text-decoration: none;
}

.services-group-link:hover {
  background: var(--muted);
  color: var(--foreground);
}

.services-group-link .hz-icon {
  font-size: var(--control-icon-s);
}

/* Service cards */
/*
 * 열 수는 카드 최소 가독폭(20rem)으로 정한다. 2열 고정이면 넓은 화면에서 카드가 과도하게
 * 늘어나고, 3열 고정이면 좁은 화면에서 제목이 배지와 충돌한다. auto-fill이라 카테고리 레일이
 * 사라지는 폭에서도 자동으로 맞는다. auto-fit이 아닌 auto-fill이어야 항목이 적은 그룹에서도
 * 카드 폭이 다른 그룹과 같게 유지된다.
 */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: var(--space-3);
}

.services-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: start;
  min-width: 0;
  /*
   * 그리드가 행 단위로 높이를 맞추므로 하한선은 카드가 비정상적으로 납작해지는 것만 막으면 된다.
   * 9rem(144px)이면 실제 콘텐츠(130px)보다 커서 모든 카드 하단에 빈 띠가 생겼다.
   */
  min-height: 8rem;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--card-foreground);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.services-card:hover {
  border-color: color-mix(in srgb, var(--primary) 62%, var(--border));
  background: color-mix(in srgb, var(--primary) 3%, var(--card));
  box-shadow: var(--shadow-sm);
}

.services-card-icon {
  display: grid;
  place-items: center;
  width: var(--control-h-m);
  height: var(--control-h-m);
  border-radius: var(--radius);
  background: var(--muted);
  color: var(--foreground);
}

.services-card-icon .hz-icon {
  font-size: var(--control-icon-m);
}

.services-card-content {
  display: grid;
  gap: var(--space-1-5);
  min-width: 0;
}

.services-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.services-card-heading > div {
  min-width: 0;
}

.services-card-title {
  min-width: 0;
  margin: 0;
  font-size: var(--fs-body-lg);
  line-height: var(--lh-body);
  font-weight: 700;
}

.services-card-name {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
}

.services-card-desc {
  display: -webkit-box;
  overflow: hidden;
  margin: var(--space-1) 0 0;
  color: var(--foreground);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.services-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin-top: var(--space-1);
}

.services-card-tag {
  color: var(--muted-foreground);
  font-size: var(--fs-2xs);
  line-height: var(--lh-xs);
}

/*
 * 태그는 카드 앵커 안의 비인터랙티브 메타데이터다. `#`를 프라이머리 색으로 두면 링크처럼
 * 보이지만 클릭할 수 없다(카드 전체가 이미 <a>라 중첩 인터랙티브를 만들 수도 없다).
 * 실제 성격에 맞춰 수동 메타데이터로 표기한다.
 */
.services-card-tag::before {
  content: "#";
  color: var(--muted-foreground);
  opacity: 0.65;
}

.services-card-arrow {
  margin-top: var(--space-1);
  color: var(--muted-foreground);
  font-size: var(--control-icon-s);
  transition: color 0.16s ease, transform 0.16s ease;
}

.services-card:hover .services-card-arrow {
  color: var(--primary);
  transform: translateX(var(--space-0-5));
}

.services-card-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  flex: 0 0 auto;
  min-height: var(--space-6);
  padding-inline: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: var(--fs-2xs);
  line-height: var(--lh-xs);
  font-weight: 600;
  white-space: nowrap;
}

.services-card-badges {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-1);
}

.services-card-badge .hz-icon {
  font-size: var(--control-icon-s);
}

.services-card-badge--login {
  border-color: color-mix(in srgb, var(--warning) 42%, var(--border));
  background: color-mix(in srgb, var(--warning) 10%, var(--card));
  color: color-mix(in srgb, var(--warning) 52%, var(--foreground));
}

.services-card-badge--admin {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--card));
  color: color-mix(in srgb, var(--accent) 52%, var(--foreground));
}

.services-card-badge--beta {
  border-color: color-mix(in srgb, var(--warning) 42%, var(--border));
  background: color-mix(in srgb, var(--warning) 10%, var(--card));
  color: color-mix(in srgb, var(--warning) 52%, var(--foreground));
}

/* Loading, empty and error */
.services-loading,
.services-state {
  min-height: 16rem;
  place-content: center;
  justify-items: center;
  gap: var(--space-3);
  padding: var(--space-8);
  text-align: center;
}

.services-loading {
  display: flex;
  align-items: center;
  color: var(--muted-foreground);
  font-size: var(--fs-sm);
}

.services-loading[hidden],
.services-state[hidden] {
  display: none;
}

.services-state {
  display: grid;
}

.services-state-icon {
  color: var(--muted-foreground);
  font-size: var(--control-icon-l);
}

.services-state h3,
.services-state p {
  margin: 0;
}

.services-state h3 {
  font-size: var(--fs-h3);
  line-height: var(--lh-h3);
}

.services-state p {
  max-width: 28rem;
  color: var(--muted-foreground);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
}

@media (max-width: 1024px) {
  /* 키라인만 옮기면 헤더(header-inner)와 본문이 같이 따라온다. */
  .services-body {
    --services-keyline: var(--space-6);
  }

  .services-directory-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
  }

  .services-category-rail {
    position: static;
    display: block;
    overflow: hidden;
  }

  .services-category-label {
    display: none;
  }

  .services-category-nav {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding: var(--space-1) var(--space-px) var(--space-2);
    scroll-snap-type: inline proximity;
    scrollbar-width: thin;
  }

  .services-category-link {
    display: inline-flex;
    flex: 0 0 auto;
    min-height: var(--control-h-s);
    padding: var(--space-1-5) var(--space-3);
    border-color: var(--border);
    border-radius: var(--radius-full);
    background: var(--card);
    scroll-snap-align: start;
  }

  .services-category-count {
    background: transparent;
    padding-inline: 0;
  }

}

@media (max-width: 640px) {
  .services-body {
    --services-keyline: var(--space-4);
  }

  .services-content {
    padding-block: calc(var(--main-header-height, 56px) + var(--space-5)) var(--space-10);
  }

  .services-intro {
    gap: var(--space-5);
    padding-block: 0 var(--space-8);
  }

  .services-intro-title {
    font-size: var(--fs-h1);
    line-height: var(--lh-h1);
  }

  .services-intro-lead {
    font-size: var(--fs-body);
    line-height: var(--lh-body);
  }

  .services-search {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .services-search-shortcut {
    display: none;
  }

  .services-directory {
    padding-top: var(--space-6);
  }

  .services-results-heading,
  .services-group-head {
    align-items: flex-start;
  }

  .services-results-heading {
    flex-direction: column;
    gap: var(--space-2);
  }

  .services-results-summary {
    text-align: left;
  }

  .services-filterbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .services-access-filters {
    grid-column: 1 / -1;
    grid-row: 2;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding-bottom: var(--space-1);
    scroll-padding-inline: var(--space-2);
    scroll-snap-type: inline proximity;
    scrollbar-width: thin;
  }

  .services-access-filter {
    scroll-snap-align: start;
  }

  .services-filters-clear {
    grid-column: 3;
    grid-row: 1;
  }

  .services-results {
    gap: var(--space-8);
  }

  .services-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .services-card {
    min-height: 0;
  }

  .services-group-link-label {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .services-search,
  .services-category-link,
  .services-access-filter,
  .services-card,
  .services-card-arrow {
    transition: none;
  }
}
