/* ==========================================================
   pages/school.css — 학교 상세 (/school/{코드})
   0. 히어로 (.shero · .scard 점수 카드 · .gauge 점수 링)
   1. 섹션 바로가기 (.snav)
   2. 본문 격자 (.sgrid)
   3. ① 성적표 (.insight · .prow)
   4. ② 오늘 급식 (.meal · .menu)
   5. ③ 이번 주 식단 (.week-tabs · .week-grid · .wday)
   6. ④ 순위 흐름 (.trend-cmp · .trend-chart)
   7. ⑤ 운영 정보 (.stats)
   8. ⑥ 지역 비교 (.vs-bars · .vs-table)
   9. ⑦ 함께 보기 (.rel-tabs)
   ========================================================== */

/* ---------- 0. 히어로 ---------- */
.shero {
  background:
    radial-gradient(640px 320px at 100% -10%, var(--glow-brand) 0%, transparent 62%),
    linear-gradient(180deg, var(--cream) 0%, #fff 100%);
  border-bottom: 1px solid var(--line-2);
}
.shero-inner { padding-top: 14px; padding-bottom: 22px; }
.shero-grid { display: grid; gap: 16px; margin-top: 0; }

.shero-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.shero-name { margin-top: 10px; font-size: 28px; font-weight: 900; line-height: 1.22; letter-spacing: -.05em; }
.shero-loc { display: flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 14.5px; font-weight: 600; color: var(--ink-2); }
.shero-loc .ico { width: 16px; height: 16px; color: var(--ink-4); }

/* 내 학교 저장 */
.my-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; margin-top: 14px; padding: 0 14px 0 11px;
  border-radius: 999px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line);
  font-size: 13.5px; font-weight: 700; color: var(--ink-2); transition: all .15s;
}
.my-toggle .ico { width: 17px; height: 17px; color: var(--ink-4); }
.my-toggle:hover { box-shadow: inset 0 0 0 1.5px var(--line-hover); }
.my-toggle[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-deep); box-shadow: inset 0 0 0 1.5px var(--brand-line); }
.my-toggle[aria-pressed="true"] .ico { color: var(--brand); fill: currentColor; stroke-width: 1.5; }

/* 점수 카드 */
.scard {
  position: relative; padding: 18px; border-radius: var(--r-xl);
  background: #fff; border: 1px solid rgba(232, 235, 241, .9); box-shadow: var(--shadow-2);
}
.scard-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.scard-label { font-size: 13px; font-weight: 800; color: var(--ink-3); }
.scard-score .pts { font-size: 54px; line-height: 1; letter-spacing: -.055em; }
.scard-score .pts small { font-size: 17px; }
.scard-hl { margin-top: 10px; }

/* 점수 링 */
.gauge { --sz: 84px; position: relative; width: var(--sz); height: var(--sz); flex: none; }
.gauge .ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge .trk { fill: none; stroke: var(--line-2); stroke-width: 9; }
.gauge .val { fill: none; stroke: var(--brand); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease); }
.gauge .ico { position: absolute; inset: 0; margin: auto; width: 28px; height: 28px; color: var(--brand); }

/* 순위 두 칸 */
.scard-ranks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.srank {
  display: block; padding: 12px 14px; border-radius: 16px; background: var(--surface-2); transition: background .15s;
}
.srank:hover { background: var(--surface-3); }
.srank-l { display: flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 800; color: var(--ink-3); }
.srank-l .ico { width: 13px; height: 13px; color: var(--ink-4); }
.srank b { display: block; margin-top: 2px; font-size: 30px; font-weight: 900; letter-spacing: -.05em; color: var(--navy); line-height: 1.15; font-variant-numeric: tabular-nums; }
.srank b small { margin-left: 1px; font-size: 16px; font-weight: 800; }
.srank-of { font-size: 12px; font-weight: 600; color: var(--ink-4); }
.scard-delta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin-top: 12px; font-size: 13.5px; font-weight: 700; color: var(--ink-2); }

/* 정식 순위 제외 */
.scard-excluded { margin-top: 16px; }

.shero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.shero-actions .btn { padding: 0 12px; }
.shero-basis { margin-top: 14px; }
/* 기획서 최소 폭(360px)보다 좁은 화면에서는 버튼을 세로로 */
@media (max-width: 359px) { .shero-actions { grid-template-columns: 1fr; } }

@media (min-width: 768px) {
  .shero-inner { padding-top: 22px; padding-bottom: 30px; }
  .shero-grid { grid-template-columns: minmax(0, 1fr) 400px; align-items: center; gap: 32px; }
  .shero-name { font-size: 40px; }
  .scard { padding: 22px; }
  .shero-actions { display: flex; }
  .shero-actions .btn { padding: 0 20px; }
}
@media (min-width: 1024px) {
  .shero-grid { grid-template-columns: minmax(0, 1fr) 440px; }
  .shero-name { font-size: 46px; }
  .scard-score .pts { font-size: 64px; }
  .gauge { --sz: 96px; }
}

/* ---------- 1. 섹션 바로가기 ---------- */
.snav {
  position: sticky; top: calc(var(--hdr-h) + var(--nav-h)); z-index: 30;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.snav-chips { padding-top: 8px; padding-bottom: 8px; gap: 6px; }
.snav .chip { height: 34px; padding: 0 13px; font-size: 13.5px; box-shadow: none; background: transparent; color: var(--ink-3); }
.snav .chip:hover { background: var(--surface-2); color: var(--ink); }
.snav .chip[aria-current="true"] { background: var(--navy); color: #fff; }
html:has(.snav) { scroll-padding-top: calc(var(--hdr-h) + var(--nav-h) + 64px); }

/* ---------- 2. 본문 격자 ---------- */
.sbody { display: grid; gap: 16px; padding-top: 20px; padding-bottom: 40px; }
.sgrid { display: grid; gap: 16px; }
.sblock { min-width: 0; }
@media (min-width: 1024px) {
  .sbody { gap: 20px; padding-top: 28px; }
  .sgrid { gap: 20px; }
  .sgrid-a { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; }
  .sgrid-b { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
}
.sfoot { margin-top: 4px; }

/* ---------- 3. 성적표 ---------- */
.insight {
  display: flex; gap: 10px; padding: 14px 16px; border-radius: 16px;
  background: linear-gradient(135deg, var(--brand-soft) 0%, var(--cream) 100%); border: 1px solid var(--brand-line);
}
.insight > .ico { width: 20px; height: 20px; margin-top: 2px; color: var(--brand); }
.insight p { font-size: 15px; font-weight: 800; letter-spacing: -.02em; line-height: 1.5; color: var(--ink); }
.insight p + p { margin-top: 2px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.insight em { font-style: normal; color: var(--brand-deep); }

.prows { display: grid; gap: 16px; margin-top: 18px; }
.prow { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; align-items: start; }
.prow-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.prow-label { font-size: 14.5px; font-weight: 800; letter-spacing: -.02em; }
.prow-val { font-size: 12.5px; font-weight: 700; color: var(--ink-4); font-variant-numeric: tabular-nums; white-space: nowrap; }
.prow-val b { font-size: 16px; font-weight: 800; color: var(--navy); }
.prow-sub { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.prow-sub .top { font-weight: 800; color: var(--brand-deep); }

/* ---------- 4. 오늘 급식 ---------- */
.meal-score { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: 16px; background: var(--surface-2); }
.meal-score-l { font-size: 12.5px; font-weight: 800; color: var(--ink-3); }
.meal-score .pts { font-size: 32px; line-height: 1.1; color: var(--brand-deep); }
.meal-tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }

.menu { margin-top: 14px; }
.menu li { display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 10px; padding: 9px 2px; }
.menu li + li { border-top: 1px dashed var(--line); }
.mcat {
  justify-self: start; height: 22px; padding: 0 7px; border-radius: 7px; display: inline-grid; place-items: center;
  background: var(--surface-2); font-size: 11.5px; font-weight: 800; color: var(--ink-3);
}
.mcat.main { background: var(--brand-soft); color: var(--brand-deep); }
.mcat.dessert { background: var(--spc-soft); color: var(--spc); }
.mname { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 15.5px; font-weight: 700; letter-spacing: -.02em; }
.mname .algs { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.mname .tag { height: 20px; padding: 0 7px; font-size: 11px; }

.meal-foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
/* gap 을 쓰면 "145 g" 처럼 숫자와 단위가 벌어진다. 여백은 요소별로 준다 */
.nut {
  display: inline-flex; align-items: center; height: 30px; padding: 0 11px; border-radius: 999px;
  background: var(--surface-2); font-size: 12.5px; font-weight: 700; color: var(--ink-2); white-space: nowrap;
}
.nut b { margin: 0 1px 0 4px; color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.nut .ico { width: 15px; height: 15px; color: var(--ink-4); }
.nut .ico + b { margin-left: 5px; }

.alg-help { margin-top: 12px; font-size: 12.5px; color: var(--ink-3); }
.alg-help summary { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; font-weight: 700; color: var(--ink-2); cursor: pointer; list-style: none; }
.alg-help summary::-webkit-details-marker { display: none; }
.alg-help summary .ico { width: 15px; height: 15px; }
.alg-list { display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 10px 12px; margin-top: 4px; border-radius: 12px; background: var(--surface-2); }
.alg-list span { display: inline-flex; align-items: center; gap: 4px; }

/* 급식 없는 날 */
.no-meal { display: grid; justify-items: center; gap: 6px; padding: 26px 16px; text-align: center; border-radius: 16px; background: var(--surface-2); }
.no-meal .empty-ico { width: 52px; height: 52px; }
.no-meal b { font-size: 16px; font-weight: 800; }
.no-meal p { font-size: 14px; color: var(--ink-3); }
.no-meal .link { margin-top: 4px; }

/* ---------- 5. 이번 주 식단 ---------- */
.week-tabs { display: flex; width: 100%; margin-bottom: 14px; }
.week-tabs button { display: grid; align-content: center; justify-items: center; gap: 4px; height: 62px; padding: 7px 4px; line-height: 1.25; }
.week-tabs button small { font-size: 12px; font-weight: 600; color: var(--ink-4); }
.week-tabs button.is-today { color: var(--brand-deep); }
.week-grid { display: grid; gap: 12px; }
.wday {
  display: flex; flex-direction: column; min-width: 0; padding: 16px; border-radius: 18px;
  background: #fff; border: 1px solid var(--line);
}
.wday.is-today { border-color: var(--brand-line); background: linear-gradient(180deg, var(--brand-soft) 0%, #fff 55%); box-shadow: 0 0 0 1.5px var(--brand-line); }
.wday.is-off { background: var(--surface-2); border-style: dashed; }
.wday-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.wday-date { font-size: 15px; font-weight: 800; letter-spacing: -.02em; }
.wday-date small { margin-left: 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-4); }
.wday .tag-today { background: var(--brand); color: #fff; }
.wday-score { display: flex; align-items: baseline; gap: 5px; margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--ink-4); }
.wday-score .pts { font-size: 20px; }
.wday-items { display: grid; gap: 4px; margin-top: 10px; font-size: 14.5px; font-weight: 600; color: var(--ink-2); }
.wday-items li { display: flex; align-items: center; gap: 6px; min-width: 0; }
.wday-items li::before { content: ""; width: 4px; height: 4px; flex: none; border-radius: 50%; background: var(--ink-4); }
.wday-items li.hl { font-weight: 800; color: var(--ink); }
.wday-items li.hl::before { background: var(--brand); }
.wday-kcal { margin-top: auto; padding-top: 10px; font-size: 12px; font-weight: 700; color: var(--ink-4); }
.wday-off { display: grid; place-items: center; gap: 4px; flex: 1; padding: 20px 0; text-align: center; font-size: 13.5px; font-weight: 700; color: var(--ink-3); }
.wday-off .ico { width: 24px; height: 24px; color: var(--ink-4); }

@media (max-width: 1023px) {
  .wday:not(.is-sel) { display: none; }
}
@media (min-width: 1024px) {
  .week-tabs { display: none; }
  .week-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .wday { padding: 16px 14px; }
  .wday-items { font-size: 13.5px; }
}

/* ---------- 6. 순위 흐름 ---------- */
.trend-cmp { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.trend-cmp > div { padding: 12px 14px; border-radius: 16px; background: var(--surface-2); text-align: center; }
.trend-cmp > div.now { background: var(--navy); color: #fff; }
.trend-cmp small { display: block; font-size: 12px; font-weight: 700; color: var(--ink-3); }
.trend-cmp .now small { color: rgba(255, 255, 255, .7); }
.trend-cmp b { display: block; font-size: 26px; font-weight: 900; letter-spacing: -.05em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.trend-cmp .arrow { color: var(--ink-4); }
.trend-msg { margin-top: 12px; text-align: center; font-size: 14.5px; font-weight: 700; color: var(--ink-2); }
.trend-chart { margin-top: 16px; }
.trend-chart svg { width: 100%; height: auto; overflow: visible; }
.trend-chart .grid line { stroke: var(--line-2); stroke-width: 1; }
.trend-chart .line { fill: none; stroke: var(--navy-2); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.trend-chart .area { fill: url(#trendFill); }
.trend-chart .pt { fill: #fff; stroke: var(--navy-2); stroke-width: 2.5; }
.trend-chart .pt.now { fill: var(--brand); stroke: #fff; stroke-width: 3; }
.trend-chart text { font-family: var(--font); font-size: 12px; font-weight: 700; fill: var(--ink-3); }
.trend-chart text.v { font-size: 12.5px; font-weight: 800; fill: var(--navy); }
.trend-chart text.v.now { fill: var(--brand-deep); }
.trend-region { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
.trend-region b { color: var(--navy); }

/* ---------- 7. 운영 정보 ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { padding: 13px 14px; border-radius: 16px; background: var(--surface-2); min-width: 0; }
.stat-l { display: flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; color: var(--ink-3); }
.stat-l .ico { width: 15px; height: 15px; color: var(--ink-4); }
.stat-v { margin-top: 4px; font-size: 20px; font-weight: 800; letter-spacing: -.04em; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-v small { margin-left: 1px; font-size: 13px; font-weight: 700; color: var(--ink-3); }
.stat-s { margin-top: 2px; font-size: 12px; color: var(--ink-3); }
.stat.is-wide { grid-column: 1 / -1; }
.stat.is-blue { background: var(--blue-soft); }
.stat.is-blue .stat-v { color: var(--blue-deep); }
.stat.is-pending .stat-v { font-size: 14.5px; color: var(--ink-3); }
.info-links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(3, 1fr); } .stat.is-wide { grid-column: span 3; } }

/* ---------- 8. 지역 비교 ---------- */
.vs-lead { font-size: 17px; font-weight: 800; letter-spacing: -.03em; line-height: 1.45; }
.vs-lead em { font-style: normal; color: var(--brand-deep); }
.vs-bars { display: grid; gap: 10px; margin-top: 16px; }
.vs-bar { display: grid; grid-template-columns: 84px minmax(0, 1fr) 48px; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
.vs-bar .bar { height: 14px; }
.vs-bar b { text-align: right; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; }
.vs-bar.is-me { color: var(--ink); font-weight: 800; }

.vs-table { width: 100%; margin-top: 20px; font-size: 14px; }
.vs-table th, .vs-table td { padding: 11px 6px; border-top: 1px solid var(--line-2); text-align: right; font-variant-numeric: tabular-nums; }
.vs-table thead th { border-top: 0; padding-top: 0; font-size: 12px; font-weight: 700; color: var(--ink-4); }
.vs-table th:first-child, .vs-table td:first-child { text-align: left; }
.vs-table tbody th { font-weight: 700; color: var(--ink-2); }
.vs-table td b { font-weight: 800; color: var(--navy); }
.vs-table .delta { justify-content: flex-end; }
@media (max-width: 420px) { .vs-table .col-nat { display: none; } }
@media (min-width: 1024px) {
  .vs-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 40px; align-items: start; }
  .vs-table { margin-top: 0; }
}

/* ---------- 9. 함께 보기 ---------- */
.rel-tabs { width: 100%; margin-bottom: 8px; }
.rel-list .rrow { min-height: 62px; }
@media (min-width: 768px) {
  .rel-tabs { width: auto; }
  .rel-list .rrow { grid-template-columns: 48px minmax(0, 1fr) 104px; }
}
