/*
 * UI 리프레시 · 선수 상세 (2026-11-14)
 * html.rf-detail 아래에서만 적용. 끄기: templates/_ui_refresh_flags.html 의 'detail'
 *
 * 구성: 프로필(카드·이름·가격·설정) → 바로가기 탭 → 이하 배포판과 같은 순서
 */

html.rf-detail body.player-detail-page {
  background: var(--rf-bg);
}

html.rf-detail body.player-detail-page .container {
  gap: 0;
  padding: 0 0 24px;
  color: var(--rf-ink);
}

/* ---------- 순서 ----------
   구역 순서는 배포판(마크업) 그대로 둔다: 능력치 요약 → 분석 → 평가 → 모든 능력치 → 시세 → 다른 카드 → 특성.
   탭 글자만 그 순서에 맞춘다. */
html.rf-detail .detail-tabs a[href="#sec-rating"] { order: 1; }
html.rf-detail .detail-tabs a[href="#sec-price"] { order: 2; }
html.rf-detail .detail-tabs a[href="#sec-cards"] { order: 3; }

/* ---------- 구역: 흰 면 + 회색 띠 ---------- */
html.rf-detail body.player-detail-page .container > :is(
  .detail-aside, .stat-summary, .stats-title-row, .stats-grid, .detail-traits-title, .detail-traits,
  .player-analysis, .defender-research, .heading-research, .positioning-research, .cadence-research,
  .price-history-section, .price-section, .tier-section, .admin-summary-section, .review-section,
  .alt-cards, .detail-other-title, .other-classes, .club-career-section
) {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-radius: 0;
  background: var(--rf-surface);
  box-shadow: none;
}

/* 구역이 시작되는 요소: 위에 회색 띠 */
html.rf-detail body.player-detail-page .container > :is(
  .stat-summary, .player-analysis, .defender-research, .heading-research, .positioning-research,
  .cadence-research, .price-history-section, .tier-section, .admin-summary-section, .review-section,
  .stats-title-row, .alt-cards, .detail-other-title, .detail-traits-title, .club-career-section
) {
  margin-top: 8px;
  padding-top: 22px;
}

/* 구역이 끝나는 요소 */
html.rf-detail body.player-detail-page .container > :is(
  .detail-aside, .stat-summary, .player-analysis, .defender-research, .heading-research, .positioning-research,
  .cadence-research, .price-section, .tier-section, .admin-summary-section, .review-section,
  .alt-cards, .other-classes, .club-career-section
) {
  padding-bottom: 22px;
}

html.rf-detail body.player-detail-page .container > .stats-grid { padding-bottom: 22px; }
html.rf-detail body.player-detail-page .container > .detail-traits { padding-bottom: 22px; }
html.rf-detail body.player-detail-page .container > .price-history-section { padding-bottom: 8px; }

/* 구역 제목 한 가지 크기 */
html.rf-detail body.player-detail-page :is(
  .detail-section-title, .player-analysis__head h2, .dr2-head h2, .hr-head h2, .pr-head h2,
  .cadence-research-heading h2, .tier-heading h2, .price-history-heading h2, .review-content-title
) {
  margin: 0;
  color: var(--rf-ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -.02em;
  text-align: left;
}

/* ---------- 프로필 ---------- */
html.rf-detail .detail-aside {
  padding-top: 18px !important;
}

html.rf-detail .detail-aside .detail-layout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  margin: 0 0 16px;
}

html.rf-detail .detail-aside .player-card-wrapper {
  width: auto;
  margin: 0;
}

html.rf-detail .detail-aside .player-card {
  zoom: .76;
  box-shadow: 0 6px 16px rgba(15, 23, 42, .16);
}

html.rf-detail .player-id {
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-align: left;
}

html.rf-detail .player-id__class {
  color: var(--rf-accent);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: .01em;
}

html.rf-detail .player-id__name {
  margin-top: 2px;
  color: var(--rf-ink);
  font-size: 23px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -.03em;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

html.rf-detail .player-id__meta {
  margin-top: 4px;
  color: var(--rf-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

html.rf-detail .player-id__price {
  display: flex;
  flex-direction: column;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--rf-line);
}

html.rf-detail .player-id__price small {
  color: var(--rf-muted);
  font-size: 11px;
  font-weight: 600;
}

html.rf-detail .player-id__price b {
  color: var(--rf-ink);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 도구 버튼 두 개: 같은 무게의 조용한 버튼 */
html.rf-detail .detail-aside .player-primary-actions {
  margin: 0 0 14px;
  gap: 8px;
}

html.rf-detail .detail-aside .player-primary-action,
html.rf-detail .detail-aside .player-primary-action.primary {
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: var(--rf-soft);
  color: var(--rf-ink-2);
  font-size: 13px;
  font-weight: 700;
  box-shadow: none;
}

html.rf-detail .detail-aside .player-primary-action i {
  color: var(--rf-muted);
}

@media (hover: hover) {
  html.rf-detail .detail-aside .player-primary-action:hover {
    background: var(--rf-line-soft);
    color: var(--rf-ink);
  }
}

/* 진화·훈련 설정 */
html.rf-detail .detail-aside .player-config-panel {
  margin: 0;
  padding: 14px 0 0;
  border: 0;
  border-top: 1px solid var(--rf-line);
  border-radius: 0;
  background: transparent;
}

html.rf-detail .detail-aside .config-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

html.rf-detail .detail-aside .config-field label {
  color: var(--rf-muted);
  font-size: 12px;
  font-weight: 600;
}

html.rf-detail .detail-aside .config-field select {
  min-height: 44px;
  border: 1px solid var(--rf-line);
  border-radius: 10px;
  background-color: var(--rf-surface);
  color: var(--rf-ink);
  font-size: 15px;
  font-weight: 700;
}

html.rf-detail .detail-aside .skill-config {
  margin-top: 16px;
}

html.rf-detail .detail-aside .skill-config-title {
  color: var(--rf-ink);
  font-size: 13px;
  font-weight: 700;
}

html.rf-detail .detail-aside .skill-card {
  border: 0;
  border-radius: 10px;
  background: var(--rf-soft);
}

/* ---------- 바로가기 탭 ---------- */
html.rf-detail .detail-tabs {
  position: sticky;
  top: var(--rf-header-h);
  z-index: 30;
  display: flex;
  box-sizing: border-box;
  width: 100%;
  padding: 0 6px;
  border-top: 1px solid var(--rf-line-soft);
  border-bottom: 1px solid var(--rf-line);
  background: var(--rf-surface);
  overflow-x: auto;
  scrollbar-width: none;
}

html.rf-detail .detail-tabs::-webkit-scrollbar { display: none; }

html.rf-detail .detail-tabs a {
  flex: 1 0 auto;
  position: relative;
  padding: 13px 10px 12px;
  color: var(--rf-muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

html.rf-detail .detail-tabs a::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  background: transparent;
}

html.rf-detail .detail-tabs a[aria-current="true"] {
  color: var(--rf-ink);
}

html.rf-detail .detail-tabs a[aria-current="true"]::after {
  background: var(--rf-ink);
}

html.rf-detail .detail-tabs a:focus-visible {
  outline: 2px solid var(--rf-accent);
  outline-offset: -3px;
  border-radius: 6px;
}

html.rf-detail body.player-detail-page :is(#sec-stats, #sec-analysis, #sec-price, #sec-rating, #sec-cards) {
  scroll-margin-top: calc(var(--rf-header-h) + 12px);
}

/* ---------- 능력치 ---------- */
html.rf-detail body.player-detail-page .stat-summary .stat-spec {
  margin-top: 14px;
}

html.rf-detail body.player-detail-page .stat-summary .stat-spec dt {
  color: var(--rf-muted);
}

html.rf-detail body.player-detail-page .stat-summary .stat-spec dd {
  color: var(--rf-ink);
}

html.rf-detail body.player-detail-page .container > .stats-title-row {
  padding-bottom: 12px;
}

html.rf-detail body.player-detail-page .stats-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

html.rf-detail body.player-detail-page .max-level-stat {
  padding: 4px 10px;
  border: 0;
  border-radius: 999px;
  background: var(--rf-accent-soft);
  color: var(--rf-accent-ink);
  font-size: 12px;
  font-weight: 700;
}

html.rf-detail body.player-detail-page .container > .detail-traits-title {
  padding-bottom: 12px;
}

/* ---------- 시세 ---------- */
html.rf-detail body.player-detail-page .container > .price-section {
  padding-top: 6px;
}

html.rf-detail body.player-detail-page .price-section-head {
  padding: 0 0 6px;
  color: var(--rf-ink);
  font-size: 14px;
  font-weight: 700;
}

html.rf-detail body.player-detail-page .price-section-note {
  display: none;
}

html.rf-detail body.player-detail-page .price-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

html.rf-detail body.player-detail-page .price-chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  column-gap: 8px;
  min-width: 0;
  padding: 6px 10px 7px;
  border: 1px solid var(--rf-line);
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

html.rf-detail body.player-detail-page .price-chip-level {
  grid-column: 1;
  color: var(--rf-muted);
  font-size: 11.5px;
  font-weight: 700;
}

html.rf-detail body.player-detail-page .price-chip-kor {
  grid-column: 2;
  grid-row: 1;
  color: var(--rf-ink);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

html.rf-detail body.player-detail-page .price-chip-price {
  grid-column: 1 / -1;
  min-width: 0;
  color: var(--rf-ink);
  font-size: 12.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 한글 금액이 있으면 전체 숫자는 아래에 작게 */
html.rf-detail body.player-detail-page .price-chip.has-kor .price-chip-price {
  color: var(--rf-muted);
  font-size: 10.5px;
  font-weight: 600;
  text-align: right;
}

html.rf-detail body.player-detail-page .price-chip.is-selected-price {
  border-color: var(--rf-accent);
  background: var(--rf-accent-soft);
}

html.rf-detail body.player-detail-page .price-chip.is-selected-price :is(.price-chip-level, .price-chip-price, .price-chip-kor) {
  color: var(--rf-accent-ink);
}

/* ---------- 평가 ---------- */
html.rf-detail body.player-detail-page .tier-section .tier-heading {
  padding: 0;
}

html.rf-detail body.player-detail-page .review-section .review-content-heading,
html.rf-detail body.player-detail-page .admin-summary-section .review-content-heading,
html.rf-detail body.player-detail-page .club-career-section .review-content-heading {
  padding-left: 0;
  padding-right: 0;
}

/* ---------- 다른 카드 ---------- */
html.rf-detail body.player-detail-page .container > .detail-other-title {
  padding-bottom: 12px;
}

html.rf-detail body.player-detail-page .container > .alt-cards + .detail-other-title {
  margin-top: 0;
  padding-top: 4px;
}

/* ---------- 넓은 화면 ---------- */
@media (max-width: 899px) {
  /* 구역을 화면 끝까지: body 좌우 여백만큼 밖으로 */
  html.rf-detail body.player-detail-page .main-content {
    max-width: none;
    padding: 0;
    overflow: visible;
  }

  html.rf-detail body.player-detail-page .container {
    width: 100vw;
    max-width: none;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
  }
}

@media (min-width: 560px) and (max-width: 899px) {
  html.rf-detail body.player-detail-page .container > * {
    padding-left: max(16px, calc(50vw - 340px)) !important;
    padding-right: max(16px, calc(50vw - 340px)) !important;
  }

  html.rf-detail .detail-aside .player-card { zoom: .9; }
  html.rf-detail .player-id__name { font-size: 28px; }
}

@media (min-width: 900px) {
  html.rf-detail body.player-detail-page .main-content {
    max-width: 1120px;
    padding: 8px 0 40px;
  }

  html.rf-detail body.player-detail-page .container {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    column-gap: 20px;
    align-items: start;
    max-width: none;
    width: 100%;
  }

  html.rf-detail body.player-detail-page .container > * {
    grid-column: 2;
  }

  html.rf-detail body.player-detail-page .container > :is(h1, p.visually-hidden) {
    grid-column: 1 / -1;
  }

  html.rf-detail body.player-detail-page .container > .detail-aside {
    grid-column: 1;
    grid-row: 1 / span 40;
    position: sticky;
    top: calc(var(--rf-header-h) + 16px);
    max-height: calc(100vh - var(--rf-header-h) - 32px);
    padding: 22px 20px !important;
    border: 1px solid var(--rf-line);
    border-radius: 16px;
    overflow-y: auto;
    scrollbar-width: thin;
  }

  html.rf-detail .detail-aside .detail-layout {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 16px;
    text-align: center;
  }

  html.rf-detail .detail-aside .player-card { zoom: 1; }

  html.rf-detail .player-id {
    align-items: center;
    width: 100%;
    text-align: center;
  }

  html.rf-detail .player-id__name { font-size: 26px; }

  html.rf-detail .player-id__price {
    align-items: center;
    align-self: stretch;
  }

  html.rf-detail .player-id__price b { font-size: 20px; }

  html.rf-detail .detail-aside .skill-card-grid {
    grid-template-columns: 1fr;
  }

  html.rf-detail .detail-aside .skill-card > div {
    grid-template-columns: minmax(0, 1fr) 128px;
  }

  html.rf-detail .detail-aside .skill-card .skill-point-control {
    grid-row: 1 / span 2;
  }

  html.rf-detail .detail-aside .skill-card .skill-stat-list {
    grid-column: 1 / -1;
    margin-top: 6px;
  }

  html.rf-detail .detail-tabs {
    grid-column: 2;
    grid-row: 1;
    top: var(--rf-header-h);
    padding: 0 10px;
    border: 1px solid var(--rf-line);
    border-radius: 14px;
  }

  html.rf-detail .detail-tabs a {
    flex: 0 0 auto;
    padding: 14px 14px 13px;
  }

  html.rf-detail .detail-tabs a::after { left: 14px; right: 14px; bottom: 0; }

  /* 오른쪽 열: 구역마다 한 장의 판 */
  html.rf-detail body.player-detail-page .container > :is(
    .stat-summary, .stats-title-row, .stats-grid, .detail-traits-title, .detail-traits,
    .player-analysis, .defender-research, .heading-research, .positioning-research, .cadence-research,
    .price-history-section, .price-section, .tier-section, .admin-summary-section, .review-section,
    .alt-cards, .detail-other-title, .other-classes, .club-career-section
  ) {
    padding-left: 24px;
    padding-right: 24px;
    border-left: 1px solid var(--rf-line);
    border-right: 1px solid var(--rf-line);
  }

  html.rf-detail body.player-detail-page .container > :is(
    .stat-summary, .player-analysis, .defender-research, .heading-research, .positioning-research,
    .cadence-research, .price-history-section, .tier-section, .admin-summary-section, .review-section,
    .stats-title-row, .alt-cards, .detail-other-title, .detail-traits-title, .club-career-section
  ) {
    margin-top: 12px;
    padding-top: 24px;
    border-top: 1px solid var(--rf-line);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
  }

  html.rf-detail body.player-detail-page .container > :is(
    .stat-summary, .stats-grid, .player-analysis, .defender-research, .heading-research, .positioning-research,
    .cadence-research, .price-section, .tier-section, .admin-summary-section, .review-section,
    .alt-cards, .other-classes, .club-career-section, .detail-traits
  ) {
    padding-bottom: 24px;
    border-bottom: 1px solid var(--rf-line);
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
  }

  html.rf-detail body.player-detail-page .container > .alt-cards:has(+ .detail-other-title) {
    border-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  html.rf-detail body.player-detail-page .container > .alt-cards + .detail-other-title {
    border-top: 0;
    border-radius: 0;
  }

  html.rf-detail body.player-detail-page .price-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

}

/* ---------- 다크: theme.css 의 !important 배경을 새 구성에 맞춘다 ---------- */
html.rf-detail[data-theme="dark"] body.player-detail-page .container > :is(
  .detail-aside, .detail-tabs, .stat-summary, .stats-title-row, .stats-grid, .detail-traits-title, .detail-traits,
  .player-analysis, .defender-research, .heading-research, .positioning-research, .cadence-research,
  .price-history-section, .price-section, .tier-section, .admin-summary-section, .review-section,
  .alt-cards, .detail-other-title, .other-classes, .club-career-section
) {
  border-color: var(--rf-line) !important;
  background: var(--rf-surface) !important;
}

html.rf-detail[data-theme="dark"] .detail-aside .player-config-panel {
  border-color: var(--rf-line) !important;
  background: transparent !important;
}

html.rf-detail[data-theme="dark"] .detail-aside :is(.player-primary-action, .skill-card) {
  border-color: transparent !important;
  background: var(--rf-soft) !important;
}

html.rf-detail[data-theme="dark"] body.player-detail-page .price-chip {
  border-color: var(--rf-line-soft) !important;
  background: transparent !important;
}

html.rf-detail[data-theme="dark"] body.player-detail-page .price-chip.is-selected-price {
  border-color: var(--rf-accent) !important;
  background: var(--rf-accent-soft) !important;
}

html.rf-detail[data-theme="dark"] body.player-detail-page .price-chip.is-selected-price :is(.price-chip-level, .price-chip-price, .price-chip-kor) {
  color: var(--rf-accent) !important;
}

/* ---------- 특성: 좁은 목록 대신 넉넉한 칩으로 ---------- */
html.rf-detail body.player-detail-page .container > ul.detail-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0 16px 22px;
  list-style: none;
}

html.rf-detail body.player-detail-page .container > ul.detail-traits > li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin: 0;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--rf-accent-soft);
  color: var(--rf-ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

html.rf-detail body.player-detail-page ul.detail-traits .trait-icon {
  order: -1;
  width: 24px;
  height: 24px;
  margin: 0;
  box-shadow: none;
}

/* 다크: 스킬부스트 '상승 스탯 보기' 버튼이 밝은 바탕으로 남던 것 */
html.rf-detail[data-theme="dark"] body.player-detail-page .skill-stat-toggle {
  border-color: rgba(125, 211, 252, .35) !important;
  background: rgba(56, 189, 248, .12) !important;
  color: #7dd3fc !important;
}
