/**
 * EDU-01 官方歷年學生數與少子化趨勢折線圖樣式
 * 
 * 版本記錄：
 * - v1.2.0 (2026-10-18): 新增折線圖容器 position relative、十字虛線、高靈敏 hover 圓點放大與浮動數值卡片 (Tooltip) 視覺設計。
 * - v1.1.0 (2026-10-17): 森林綠高對比度樣式修復 (STUDENT-TREND-V11-CONTRAST-FIX)。
 */

.student-trend-v11 {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid #bcd9c9;
  border-radius: 14px;
  background: #f3f9f5;
  color: #183b33;
  color-scheme: light;
}

.student-trend-v11 h4 {
  margin: 0 0 .8rem;
  font-size: 1.03rem;
  color: #183b33;
}

.student-trend__stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
  margin-bottom: 1rem;
}

.student-trend__stats > div {
  padding: .65rem;
  background: #e4f0e8;
  border: 1px solid #cee3d5;
  border-radius: 9px;
  min-width: 0;
  color: #183b33;
}

.student-trend__stats span {
  display: block;
  font-size: .76rem;
  line-height: 1.45;
  color: #496459;
}

.student-trend__stats strong {
  display: block;
  margin: .25rem 0 0;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
  color: #174f40;
}

.student-trend__stats strong small {
  font-size: .65em;
  font-weight: normal;
  color: #174f40;
}

.student-trend__stats > div > small {
  display: block;
  font-size: .8em;
  color: #496459;
}

/* 折線圖與浮動 Tooltip 容器 */
.student-trend__chart-wrap {
  position: relative;
  width: 100%;
  margin: 0.5rem 0;
}

.student-trend-v11 svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 230px;
  overflow: visible;
  color: #42695b; /* 座標軸與網格文字色彩 */
}

/* 垂直對齊引導虛線 */
.student-trend__crosshair {
  transition: opacity .15s ease;
}

/* 數據點互動層級 */
.student-trend__point {
  cursor: pointer;
  outline: none;
}

.student-trend__hit {
  cursor: pointer;
}

.student-trend__halo {
  transition: transform .18s cubic-bezier(0.4, 0, 0.2, 1), opacity .18s ease;
  transform-box: fill-box;
  transform-origin: center;
}

.student-trend__dot {
  transition: transform .18s ease, fill .18s ease, stroke-width .18s ease;
  transform-box: fill-box;
  transform-origin: center;
}

/* Hover / Focus / Active 圓點高亮效果 */
.student-trend__point:hover .student-trend__halo,
.student-trend__point:focus-visible .student-trend__halo,
.student-trend__point.is-active .student-trend__halo {
  opacity: 0.26;
  transform: scale(1.6);
}

.student-trend__point:hover .student-trend__dot,
.student-trend__point:focus-visible .student-trend__dot,
.student-trend__point.is-active .student-trend__dot {
  fill: #14533e;
  stroke: #ffffff;
  stroke-width: 2.5px;
  transform: scale(1.28);
}

/* 浮動數值卡片 (Tooltip) */
.student-trend-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 25;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, calc(-100% - 10px));
  transition: opacity .15s ease, transform .15s ease;
  background: #113328;
  color: #ffffff;
  border: 1px solid #72c7a7;
  border-radius: 9px;
  padding: 0.55rem 0.8rem;
  box-shadow: 0 8px 20px rgba(10, 36, 26, 0.32);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: nowrap;
  min-width: 125px;
  box-sizing: border-box;
}

.student-trend-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
}

/* 靠近頂部時向下展開 */
.student-trend-tooltip.is-flipped {
  transform: translate(-50%, 14px);
}

/* 靠近左側邊界防止溢出 */
.student-trend-tooltip.is-left {
  transform: translate(0, calc(-100% - 10px));
}
.student-trend-tooltip.is-left.is-flipped {
  transform: translate(0, 14px);
}

/* 靠近右側邊界防止溢出 */
.student-trend-tooltip.is-right {
  transform: translate(-100%, calc(-100% - 10px));
}
.student-trend-tooltip.is-right.is-flipped {
  transform: translate(-100%, 14px);
}

/* Tooltip 內部文字與指標排版 */
.student-trend-tooltip__year {
  font-weight: 700;
  color: #a9e8cd;
  font-size: 0.82rem;
  margin-bottom: 0.3rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  padding-bottom: 0.25rem;
}

.student-trend-tooltip__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-top: 0.2rem;
}

.student-trend-tooltip__badge {
  font-size: 0.73rem;
  color: #d0e8dd;
  display: inline-flex;
  align-items: center;
}

.student-trend-tooltip__badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3ecf9a;
  margin-right: 5px;
}

.student-trend-tooltip__badge.is-sub::before {
  background: #8ae2be;
}

.student-trend-tooltip__val {
  font-weight: 700;
  font-size: 0.98rem;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

.student-trend-tooltip__val small {
  font-size: 0.75em;
  font-weight: normal;
  color: #c0ded2;
  margin-left: 2px;
}

/* 備註與歷年折疊表格 */
.student-trend__note {
  font-size: .79rem;
  line-height: 1.6;
  color: #496459;
  margin: .6rem 0;
}

.student-trend-v11 summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .84rem;
  margin: .5rem 0;
  color: #183b33;
}

.student-trend-v11 summary:hover,
.student-trend-v11 a:hover {
  color: #0c5b44;
}

.student-trend-v11 a {
  color: #17654e;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.student-trend-v11 a:focus-visible,
.student-trend-v11 summary:focus-visible {
  outline: 3px solid #256f55;
  outline-offset: 3px;
  border-radius: 3px;
}

.student-trend__tablewrap {
  max-height: 230px;
  overflow: auto;
}

.student-trend-v11 table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
}

.student-trend-v11 th,
.student-trend-v11 td {
  padding: .4rem .55rem;
  text-align: left;
  border-bottom: 1px solid #cedfd5;
}

.student-trend-v11 th {
  position: sticky;
  top: 0;
  background: #deede4;
  color: #25473d;
}

.student-trend-v11 td {
  background: #f3f9f5;
  color: #183b33;
}

.student-trend-v11 tr:nth-child(even) td {
  background: #ebf5ef;
}

@media(max-width: 480px) {
  .student-trend__stats {
    grid-template-columns: 1fr 1fr;
    gap: .4rem;
  }
  .student-trend-v11 {
    padding: .8rem;
  }
  .student-trend__stats strong {
    font-size: 1.05rem;
  }
}
