/* ScholaNova – public statistics page + chart styling.
   Loaded only by Default.aspx (signed-out view). Additive: does not override sn.css. */

/* Chart colours – validated categorical palette (light: #ffffff surface, dark: #0e1c28 surface).
   Amber is low-contrast on white, so every chart also carries visible labels and a Table view. */
:root { --viz-1: #0a8f84; --viz-2: #e89f00; --viz-3: #1d4ed8; }
html[data-theme="dark"] { --viz-1: #17a091; --viz-2: #c98500; --viz-3: #5b87e8; }

/* ── Type: Fraunces for a few headings and big figures, Plus Jakarta Sans for the rest ── */
.pub { max-width: 1180px; margin: 0 auto; padding: clamp(20px, 4vw, 44px) 0 clamp(40px, 6vw, 72px); font-family: var(--font-body); color: var(--ink); font-size: .95rem; line-height: 1.65; }
.pub h1, .pub h2 { font-family: var(--font-display); font-weight: 500; letter-spacing: -.018em; color: var(--ink); margin: 0; text-wrap: balance; font-variation-settings: "opsz" 72; }
.pub h1 { font-size: clamp(1.9rem, 1.1rem + 3vw, 3rem); line-height: 1.1; }
.pub h2 { font-size: clamp(1.35rem, 1rem + 1.2vw, 1.8rem); line-height: 1.2; }
.pub h3 { font-family: var(--font-body); font-size: 1rem; font-weight: 650; letter-spacing: -.005em; margin: 0; color: var(--ink); }
.pub p { margin: 0; color: var(--ink-soft); max-width: 62ch; }
.pub .pub-muted { color: var(--muted); font-size: .85rem; }
.pub-sec { margin-top: clamp(40px, 6vw, 72px); scroll-margin-top: 84px; }
.pub-sec__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 18px; }
.pub-sec__head p { margin-top: 6px; }

/* ── Hero ── */
.pub-hero { display: grid; gap: clamp(24px, 4vw, 56px); grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; }
.pub-hero__copy { display: grid; gap: 18px; justify-items: start; }
.pub-hero__copy p { font-size: 1.05rem; color: var(--ink-soft); }
.pub-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.pub-fig { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: clamp(16px, 2.4vw, 24px); display: grid; gap: 14px; }
.pub-fig__top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pub-fig__n { font-family: var(--font-display); font-weight: 500; font-size: clamp(2rem, 1.4rem + 2vw, 2.8rem); line-height: 1; letter-spacing: -.02em; font-variant-numeric: lining-nums tabular-nums; }
.pub-fig__l { color: var(--muted); font-size: .85rem; }
.pub-live { display: inline-flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--ink-soft); font-weight: 600; }
.pub-live i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(21, 128, 61, .5); animation: pubPulse 2.2s ease-out infinite; }
@keyframes pubPulse { 70% { box-shadow: 0 0 0 8px rgba(21, 128, 61, 0); } 100% { box-shadow: 0 0 0 0 rgba(21, 128, 61, 0); } }

/* ── Headline totals: one ruled strip, not a grid of identical cards ── */
.pub-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: clamp(28px, 4vw, 44px) 0 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.pub-totals li { padding: 18px 20px; border-left: 1px solid var(--line); display: grid; gap: 2px; align-content: start; }
.pub-totals li:first-child { border-left: 0; }
.pub-totals b { font-family: var(--font-display); font-weight: 500; font-size: clamp(1.5rem, 1.1rem + 1.2vw, 2rem); line-height: 1.15; letter-spacing: -.015em; font-variant-numeric: lining-nums tabular-nums; }
.pub-totals span { color: var(--muted); font-size: .84rem; }

/* ── Chart cards ── */
.pub-grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.pub-card { grid-column: span 6; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: 18px 20px 20px; display: grid; gap: 14px; align-content: start; min-width: 0; }
.pub-card--wide { grid-column: span 12; }
.pub-card--third { grid-column: span 4; }
.pub-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pub-card__head p { font-size: .84rem; color: var(--muted); margin-top: 2px; }
.pub-card__tools { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pub-seg { display: inline-flex; background: var(--surface-3); border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.pub-seg button, .pub-tbl { font: inherit; font-size: .78rem; font-weight: 600; border: 0; background: transparent; color: var(--muted); padding: 5px 11px; border-radius: var(--r-pill); cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.pub-seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); }
.pub-tbl { background: var(--surface-3); }
.pub-tbl[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-ink); }
.pub-seg button:hover, .pub-tbl:hover { color: var(--ink); }
.pub-seg button:focus-visible, .pub-tbl:focus-visible { outline: none; box-shadow: var(--ring); }
.pub-empty { color: var(--muted); font-size: .88rem; padding: 18px 0; }
.pub-table { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.pub-table table { width: 100%; border-collapse: collapse; font-size: .84rem; font-variant-numeric: tabular-nums; }
.pub-table th, .pub-table td { padding: 7px 12px; text-align: right; border-bottom: 1px solid var(--line); }
.pub-table th:first-child, .pub-table td:first-child { text-align: left; }
.pub-table thead th { position: sticky; top: 0; background: var(--surface-2); font-weight: 650; color: var(--ink-soft); }
.pub-table tbody th { font-weight: 500; color: var(--ink-soft); }
.pub-note { margin-top: 16px; color: var(--muted); font-size: .82rem; display: flex; gap: 8px; align-items: center; }

/* ── Capabilities ── */
.pub-caps { display: grid; gap: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.pub-caps li { padding: 20px 24px 22px 0; border-bottom: 1px solid var(--line); display: grid; gap: 6px; align-content: start; }
.pub-caps i { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--brand-soft); color: var(--brand-ink); font-size: .95rem; margin-bottom: 6px; }
.pub-caps p { font-size: .9rem; color: var(--muted); }

/* ── CTA ── */
.pub-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px; padding: clamp(22px, 3vw, 34px); border-radius: var(--r-lg); background: var(--brand-soft); border: 1px solid var(--line); }
.pub-cta h2 { max-width: 28ch; }

/* ── Chart primitives (sn-charts.js) ── */
.sc { position: relative; min-width: 0; }
.sc-svg { display: block; width: 100%; height: auto; overflow: visible; }
.sc-grid { stroke: var(--line); stroke-width: 1; }
.sc-ax { fill: var(--muted); font: 500 11px var(--font-body); font-variant-numeric: tabular-nums; }
.sc-cross { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.sc-bar { transition: opacity var(--dur) var(--ease); }
.sc-svg:hover .sc-bar { opacity: .9; }
.sc-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; padding: 0; margin: 0 0 8px; font-size: .82rem; color: var(--ink-soft); }
.sc-legend li { display: inline-flex; align-items: center; gap: 7px; }
.sc-legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sc-legend b { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.sc-legend--big { margin: 14px 0 0; font-size: .88rem; gap: 8px 22px; }
.sc-split { display: flex; gap: 2px; height: 22px; border-radius: 8px; overflow: hidden; }
.sc-split span { display: block; min-width: 3px; transition: opacity var(--dur) var(--ease); }
.sc-split:hover span { opacity: .8; }
.sc-split span:hover { opacity: 1; }
.sc-hb { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.sc-hb li { display: grid; grid-template-columns: minmax(84px, 34%) 1fr auto; gap: 12px; align-items: center; font-size: .86rem; }
.sc-hb__k { color: var(--ink-soft); overflow-wrap: anywhere; }
.sc-hb__t { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; display: block; }
.sc-hb__t i { display: block; height: 100%; border-radius: 4px; }
.sc-hb b { font-weight: 650; font-variant-numeric: tabular-nums; min-width: 2.5ch; text-align: right; }
.sc-tip { position: fixed; z-index: 3000; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow-md); padding: 8px 11px; font-size: .8rem; display: grid; gap: 3px; min-width: 130px; }
.sc-tip[hidden] { display: none; }
.sc-tip b { font-weight: 650; }
.sc-tip span { display: flex; align-items: center; gap: 7px; color: var(--ink-soft); }
.sc-tip span i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.sc-tip strong { margin-left: auto; padding-left: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ── Responsive ── */
@media (max-width: 960px) {
    .pub-hero { grid-template-columns: 1fr; }
    .pub-card, .pub-card--third { grid-column: span 12; }
    .pub-caps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .pub { font-size: .92rem; }
    .pub-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pub-totals li:nth-child(odd) { border-left: 0; }
    .pub-totals li:nth-child(n+3) { border-top: 1px solid var(--line); }
    .pub-caps { grid-template-columns: 1fr; }
    .pub-card { padding: 16px 14px 16px; }
    .pub-card__head { flex-direction: column; }
    .pub-card__tools { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) { .pub-live i { animation: none; } .sc-bar, .sc-split span { transition: none; } }

/* ── Pie charts, value labels, loading state ── */
.sc-pie { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 22px; }
.sc-pie__svg { width: 160px; height: 160px; flex: none; overflow: visible; }
.sc-slice { transition: opacity var(--dur) var(--ease); }
.sc-pie:hover .sc-slice { opacity: .82; }
.sc-pie .sc-slice:hover { opacity: 1; }
.sc-legend--col { flex-direction: column; flex-wrap: nowrap; gap: 8px; margin: 0; font-size: .86rem; min-width: 0; flex: 1 1 130px; }
.sc-legend--col li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 4px 9px; align-items: baseline; }
.sc-legend--col li i { align-self: center; }
.sc-legend--col b { font-variant-numeric: tabular-nums; }
.sc-legend--col small { grid-column: 2 / 4; color: var(--muted); font-size: .78rem; margin-top: -4px; }
.sc-val { fill: var(--ink-soft); font: 600 11px var(--font-body); font-variant-numeric: tabular-nums; }

.pub .is-loading { min-height: 150px; border-radius: var(--r); background: linear-gradient(100deg, var(--surface-3) 30%, var(--surface-2) 50%, var(--surface-3) 70%); background-size: 200% 100%; animation: pubShimmer 1.4s linear infinite; }
@keyframes pubShimmer { to { background-position: -200% 0; } }
.pub-retry { font: inherit; font-weight: 650; color: var(--brand); background: none; border: 0; padding: 0 2px; cursor: pointer; text-decoration: underline; }
@media (prefers-reduced-motion: reduce) { .pub .is-loading { animation: none; } }
