/* 펀드 홈(P13 "펀드 요약") 모양 (소유자 요청 2026-10-14, FeatureId fund.home).
   수익이 먼저: 평가금액·누적 수익을 맨 위에 크게, 그 아래 수익률 그래프·핵심 숫자·자산 구성·보유 종목·운용 상태·최근 기록.
   모바일 먼저: 360px에서 카드가 한 줄로 쌓이고 가로 스크롤이 없다. 960px 이상은 2열 격자다.
   기존 디자인 변수(styles.css의 :root)를 쓰고, 색은 뜻에만 쓴다: 오르면 빨강 ▲, 내리면 파랑 ▼, 0은 회색.
   사이트 CSP가 인라인 스타일을 막으므로 모든 모양은 이 파일의 클래스로 준다. 선택자는 모두 fund-home 접두어다. */

.fund-home {
  --fund-home-up: #f87171;
  --fund-home-down: #60a5fa;
  --fund-home-flat: #aab2ad;
  display: grid; gap: 14px; min-width: 0;
  grid-template-areas: "hero" "chart" "stats" "alloc" "holdings" "status" "recent" "info";
}
.fund-home p { margin: 0; line-height: 1.6; }

/* 카드: 중립 배경과 얇은 선. 그림자 없이 차분하게. */
.fund-home-card {
  display: grid; gap: 12px; min-width: 0; padding: 16px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel);
}
.fund-home-title { margin: 0; font-size: 15px; font-weight: 800; }
.fund-home-body { display: grid; gap: 12px; min-width: 0; }
.fund-home-hero { grid-area: hero; gap: 8px; }
.fund-home-chart { grid-area: chart; }
.fund-home-stats { grid-area: stats; }
.fund-home-alloc { grid-area: alloc; }
.fund-home-holdings { grid-area: holdings; }
.fund-home-status { grid-area: status; }
.fund-home-recent { grid-area: recent; }
.fund-home-info { grid-area: info; }
.fund-home-loading { font-size: 13px; }
.fund-home-footnote { color: var(--faint); font-size: 11px; }

/* 1) 평가금액·수익 */
.fund-home-hero-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.fund-home-name { margin: 0; font-size: 18px; font-weight: 850; overflow-wrap: anywhere; }
.fund-home-chip {
  display: inline-flex; align-items: center; min-height: 24px; padding: 3px 10px;
  border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--muted);
}
.fund-home-chip.is-active { color: var(--green); border-color: rgba(184,255,95,.3); background: rgba(184,255,95,.06); }
.fund-home-chip.is-waiting { color: var(--amber); border-color: rgba(255,203,102,.3); }
.fund-home-label { margin-top: 6px; color: var(--muted); font-size: 12px; }
.fund-home-equity {
  font-size: 32px; font-weight: 850; letter-spacing: -.02em; line-height: 1.15;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.fund-home-changes { display: grid; gap: 4px; margin: 2px 0 0; }
.fund-home-change-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.fund-home-change-row dt { min-width: 64px; color: var(--muted); font-size: 13px; }
.fund-home-change-row dd { margin: 0; font-size: 15px; font-weight: 750; }
.fund-home-change { font-variant-numeric: tabular-nums; }
.fund-home-change.is-up, .fund-home-tile-value.is-up { color: var(--fund-home-up); }
.fund-home-change.is-down, .fund-home-tile-value.is-down { color: var(--fund-home-down); }
.fund-home-change.is-flat { color: var(--fund-home-flat); }
.fund-home-note { color: var(--muted); font-size: 12px; }
.fund-home-stamp {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px;
  font-size: 11px;
}

/* 2) 수익률 그래프: 기간 탭·비교 지수 켜기·읽기 줄·캔버스 */
.fund-home-chart-controls {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
}
.fund-home-tabs, .fund-home-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.fund-home-tab, .fund-home-toggle {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 5px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2);
  color: var(--muted); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.fund-home-tab[aria-pressed="true"] { color: var(--bg); background: var(--ink); border-color: var(--ink); }
.fund-home-toggle[aria-pressed="true"] { color: var(--ink); border-color: #465249; }
.fund-home-toggle[aria-pressed="false"] svg { opacity: .35; }
.fund-home-toggle:disabled { cursor: not-allowed; opacity: .5; }
.fund-home-readout {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; min-height: 22px;
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.fund-home-readout-date { color: var(--muted); }
.fund-home-readout-bench { color: var(--muted); }
.fund-home-canvas { position: relative; width: 100%; height: 240px; min-width: 0; }

/* 빈 상태·못 읽음: 친절한 안내 상자 */
.fund-home-empty {
  display: grid; gap: 6px; padding: 18px 16px; border: 1px dashed var(--line); border-radius: 12px;
  color: var(--muted); font-size: 13px; text-align: center; justify-items: center;
}
.fund-home-empty strong { color: var(--ink); font-size: 14px; }

/* 3) 핵심 숫자 4칸: 모바일 2×2, 넓으면 한 줄 */
.fund-home-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; min-width: 0; }
.fund-home-tile {
  display: grid; gap: 4px; min-width: 0; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
}
.fund-home-tile-label { color: var(--muted); font-size: 12px; }
.fund-home-tile-value {
  font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.fund-home-tile small { font-size: 11px; line-height: 1.4; }

/* 4) 자산 구성 도넛 */
.fund-home-alloc-body { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; min-width: 0; }
.fund-home-donut { flex: 0 0 auto; width: 132px; height: 132px; }
.fund-home-donut-text { fill: var(--ink); font-size: 11px; font-weight: 750; }
.fund-home-legend { flex: 1 1 180px; display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; min-width: 0; }
.fund-home-legend li {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 2px 8px; font-size: 13px;
}
.fund-home-legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fund-home-legend-weight { font-weight: 750; font-variant-numeric: tabular-nums; }
.fund-home-legend-value { grid-column: 2 / 4; font-size: 11px; font-variant-numeric: tabular-nums; }

/* 5) 보유 종목 표: 좁은 화면에서는 표 상자 안에서만 밀어 본다 */
.fund-home-table-wrap { overflow-x: auto; max-width: 100%; }
.fund-home-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.fund-home-table th, .fund-home-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.fund-home-table th { color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.fund-home-table .is-number { text-align: right; white-space: nowrap; }
.fund-home-symbol a { color: var(--ink); font-weight: 700; text-decoration: none; }
.fund-home-symbol a:hover { text-decoration: underline; }
.fund-home-symbol small { display: block; font-size: 11px; }
.fund-home-gain-money { display: block; font-size: 11px; font-weight: 500; opacity: .85; }
/* 종목별 최근 흐름(60분봉 종가 작은 선). 한국 관례: 오름 빨강·내림 파랑 */
.fund-home-spark-col { width: 80px; }
.fund-home-spark { display: block; width: 72px; height: 22px; }
.fund-home-spark polyline { fill: none; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.fund-home-spark.is-up polyline { stroke: var(--fund-home-up); }
.fund-home-spark.is-down polyline { stroke: var(--fund-home-down); }
.fund-home-spark.is-flat polyline { stroke: var(--fund-home-flat); }
/* 업종·시장 비중(2026-10-18): 보유 종목 표 아래 두 개의 작은 표. 넓은 화면에서는 나란히, 좁으면 위아래. */
.fund-home-sector { margin-top: 14px; }
.fund-home-sector-title { margin: 0 0 8px; font-size: 14px; }
.fund-home-sector-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) {
  .fund-home-sector-body { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .fund-home-spark-col { display: none; }
}

/* 6) 지금 운용 상태 */
.fund-home-status-list { display: grid; gap: 10px; margin: 0; }
.fund-home-status-row { display: grid; gap: 2px; }
.fund-home-status-row dt { color: var(--muted); font-size: 12px; }
.fund-home-status-row dd { display: grid; gap: 2px; margin: 0; font-size: 14px; font-weight: 700; }
.fund-home-status-row dd small { font-size: 12px; font-weight: 400; line-height: 1.5; }

/* 7) 최근 거래·이벤트 */
.fund-home-recent-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.fund-home-recent-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.fund-home-recent-list li:last-child { border-bottom: 0; }
.fund-home-recent-text { display: grid; gap: 2px; min-width: 0; font-size: 13px; }
.fund-home-recent-text strong { overflow-wrap: anywhere; }
.fund-home-recent-text small { font-size: 11px; }
.fund-home-flow {
  flex: 0 0 auto; color: var(--ink); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* 8) 펀드 정보·이름 바꾸기(접힘) */
.fund-home-info-summary { cursor: pointer; font-size: 14px; font-weight: 800; }
.fund-home-info[open] { gap: 14px; }
.fund-home-info-list {
  display: grid; grid-template-columns: minmax(96px, max-content) minmax(0, 1fr); gap: 4px 14px; margin: 0;
  font-size: 13px;
}
.fund-home-info-list dt { color: var(--muted); }
.fund-home-info-list dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.fund-home-links { display: flex; flex-wrap: wrap; gap: 8px; }
.fund-home-expert summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.fund-home-expert-body { margin-top: 10px; min-width: 0; }

/* 버튼 모양 링크: 글자색·밑줄을 버튼과 맞추고, 격자 안에서 한 줄 전체로 늘어나지 않게 한다. */
.fund-home a.button { color: var(--ink); text-decoration: none; }
.fund-home-body > a.button { justify-self: start; }

/* 키보드 초점 */
.fund-home button:focus-visible, .fund-home a:focus-visible, .fund-home summary:focus-visible {
  outline: 2px solid var(--green); outline-offset: 2px;
}

/* 넓은 화면: 핵심 숫자 한 줄, 그래프 키우기 */
@media (min-width: 720px) {
  .fund-home-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .fund-home-canvas { height: 280px; }
  .fund-home-equity { font-size: 40px; }
}

/* 데스크톱 2열 격자: 수익(위 세 줄)은 넓게, 자산 구성|운용 상태, 보유 종목(칸이 많아 한 줄 전체), 최근 기록 */
@media (min-width: 960px) {
  .fund-home {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "hero hero" "chart chart" "stats stats" "alloc status" "holdings holdings" "recent recent" "info info";
    align-items: start;
  }
  .fund-home-card { padding: 20px; }
  .fund-home-canvas { height: 320px; }
}

/* 아주 좁은 화면(360px): 여백을 줄여 가로 스크롤이 생기지 않게 */
@media (max-width: 400px) {
  .fund-home-card { padding: 14px; }
  .fund-home-equity { font-size: 28px; }
  .fund-home-tile { padding: 10px 12px; }
  .fund-home-tile-value { font-size: 15px; }
  .fund-home-info-list { grid-template-columns: 1fr; }
  .fund-home-links .button { flex: 1 1 auto; }
}
