/* Hand-built figures for lesson 19, Loss functions. */

/* shared: chart text, tables, colours */
.ls-grid { stroke: var(--line); }
.ls-axis { stroke: var(--ink-3); stroke-width: 1.2; }
.ls-curve { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.ls-tick { font: 12px var(--f-mono); fill: var(--ink-3); }
.ls-tick.on { fill: var(--ink); font-weight: 600; }
.ls-tick.good { fill: var(--good); } .ls-tick.bad { fill: var(--bad); }
.ls-tick.mse { fill: var(--bad); } .ls-tick.mae { fill: var(--accent-ink); }
.ls-table { border-collapse: collapse; width: 100%; font: 0.85rem var(--f-ui); margin: 0 0 10px; }
.ls-table th { text-align: left; font: 500 0.66rem var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); padding: 5px 6px; border-bottom: 1px solid var(--line-2); }
.ls-table td { padding: 6px; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.ls-table td.num { font-family: var(--f-mono); font-size: 0.82rem; color: var(--ink); white-space: nowrap; }
.ls-table tr.on td { background: color-mix(in oklab, var(--gold) 14%, transparent); }
.ls-table td i { font-style: normal; font-size: 0.72rem; }
.ls-c { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg.ls-wrap { flex-wrap: wrap; border-radius: 18px; max-width: 100%; }
.seg.ls-wrap button { height: auto; min-height: 28px; padding: 4px 12px; white-space: normal; line-height: 1.3; }
.bad { color: var(--bad); } .good { color: var(--good); }
.mse { color: var(--bad); } .mae { color: var(--accent-ink); }
.plain { color: var(--accent-ink); } .smooth { color: var(--gold); }

/* hero */
.hls { width: 100%; height: auto; display: block; margin: 0 auto; max-width: 900px; }
.hls-ax { font: italic 17px var(--f-body); fill: var(--ink-3); }
.hls-state { opacity: 0; transition: opacity 0.5s; }
.hls-state.in { opacity: 1; }
.hls-dot { fill: var(--gold); }
.hls-faint { fill: var(--ink-3); opacity: 0.5; }
.hls-drop { stroke: var(--gold); stroke-dasharray: 4 4; }
.hls-say { font: 22px var(--f-body); fill: var(--ink); }
.hls .ls-tick { font-size: 14px; }
@media (max-width: 600px) { .hls-say { font-size: 30px; } .hls-ax, .hls .ls-tick { font-size: 22px; } }

/* Level 2: one number */
.on-kind { margin-bottom: 14px; }
.on-two { display: grid; gap: 22px; grid-template-columns: 1fr; align-items: center; }
@media (min-width: 760px) { .on-two { grid-template-columns: 1.1fr 1fr; } }
.on-say { margin: 0 0 10px; font-size: 0.95rem; color: var(--ink-2); }
.on-ctl .slider { font-size: 0.85rem; }
.on-out { padding: 16px 18px; border-radius: var(--r-2); background: var(--surface-2); border: 1px solid var(--line); }
.on-name { margin: 0 0 4px; }
.on-big { font: 400 2.6rem/1.1 var(--f-display); margin: 0 0 10px; color: var(--ink); font-variant-numeric: tabular-nums; }
.on-bar { height: 14px; border-radius: 7px; background: var(--bg-2); overflow: hidden; border: 1px solid var(--line); }
.on-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--good), var(--gold), var(--bad)); transition: width 0.2s; }
.on-how { margin: 10px 0 0; font: 0.9rem var(--f-mono); color: var(--ink-2); }

/* 1: the forecaster */
.fb-two { display: grid; gap: 22px; grid-template-columns: 1fr; align-items: center; }
@media (min-width: 820px) { .fb-two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.fb-chart { width: 100%; max-width: 420px; height: auto; display: block; margin: 0 auto; }
.fb-side .slider { font-size: 0.85rem; margin-bottom: 10px; }
.fb-c { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 0.85rem; margin-bottom: 12px; }
.fb-read p { margin: 0 0 6px; font-size: 0.92rem; }
.fb-big { font: 400 1.6rem/1.2 var(--f-display); }
.fb-big b { color: var(--gold); font-weight: 400; }
.fb-dot { fill: var(--gold); stroke: var(--bg-2); stroke-width: 2; }
.fb-faint { fill: var(--ink-3); opacity: 0.55; }
.fb-drop { stroke: var(--gold); stroke-dasharray: 4 4; }

/* 2: from logits */
.sl2-ctl { display: flex; flex-wrap: wrap; gap: 10px 26px; margin-bottom: 16px; font-size: 0.85rem; align-items: center; }
.sl2-two { display: grid; gap: 24px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .sl2-two { grid-template-columns: 1.1fr 1fr; } }
.sl2-lines, .sl2-naive { font: 0.86rem/1.7 var(--f-mono); color: var(--ink-2); margin: 0 0 16px; overflow-wrap: anywhere; }
.sl2-lines b, .sl2-naive b { color: var(--ink); }
.sl2-naive b.bad { color: var(--bad); }
.sl2-bars { width: 100%; max-width: 420px; height: auto; display: block; }
.sl2-bar { fill: var(--ink-3); fill-opacity: 0.45; }
.sl2-bar.right { fill: var(--gold); fill-opacity: 0.85; }
.sl2-arrow { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.sl2-arrow.up { stroke: var(--good); } .sl2-arrow.down { stroke: var(--bad); }
.sl2-read { font: 0.82rem/1.6 var(--f-mono); color: var(--ink-2); overflow-wrap: anywhere; }

/* 3: doors */
.dr-two { display: grid; gap: 22px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .dr-two { grid-template-columns: 1fr 1.2fr; } }
.dr-ctl .slider { font-size: 0.85rem; margin: 6px 0; }
.dr-ctl .slider b { min-width: 5ch; }
.dr-lines { font-size: 0.95rem; margin: 6px 0 12px; }
.dr-lines b { font-family: var(--f-mono); }
.dr-doors { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; min-height: 44px; }
.dr-door { display: block; width: 22px; height: 40px; border-radius: 11px 11px 3px 3px; background: var(--accent); position: relative; }
.dr-door::after { content: ""; position: absolute; right: 5px; top: 20px; width: 4px; height: 4px; border-radius: 50%; background: var(--bg); }
.dr-door.part { background: linear-gradient(0deg, var(--accent) calc(var(--f) * 100%), var(--surface-2) calc(var(--f) * 100%)); border: 1px solid var(--line-2); }
.dr-more { font: 0.85rem var(--f-ui); color: var(--ink-2); align-self: center; }
.dr-read { font-size: 0.85rem; margin: 8px 0 0; }

/* 4: two valleys */
.tv-ctl { display: flex; flex-wrap: wrap; gap: 10px 26px; align-items: center; margin-bottom: 12px; font-size: 0.85rem; }
.tv-chart { width: 100%; height: auto; display: block; }
.tv-line { fill: none; stroke-width: 2.5; }
.tv-line.mse { stroke: var(--bad); } .tv-line.mae { stroke: var(--accent); }
.tv-min.mse { fill: var(--bad); } .tv-min.mae { fill: var(--accent); }
.tv-c { stroke: var(--gold); stroke-width: 2; stroke-dasharray: 5 4; }
.tv-legend { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.84rem; margin: 0 0 8px; }
.tv-key { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }
.tv-key.mse { background: var(--bad); } .tv-key.mae { background: var(--accent); }
.tv-read p { margin: 6px 0 0; font-size: 0.92rem; }
.tv-read b { font-family: var(--f-mono); }

/* 5: the partner grid */
.pg-two { display: grid; gap: 22px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 820px) { .pg-two { grid-template-columns: minmax(0, 340px) 1fr; } }
.pg-circle { width: 100%; max-width: 340px; height: auto; display: block; margin: 0 auto; touch-action: none; }
.pg-ring { fill: none; stroke: var(--line-2); stroke-width: 1.5; }
.pg-q { stroke: var(--gold); stroke-width: 3.5; stroke-linecap: round; }
.pg-d { stroke-width: 2.5; stroke-linecap: round; }
.pg-d.d { stroke: var(--accent); } .pg-d.h { stroke: var(--bad); }
.pg-handle { fill-opacity: 0.25; stroke-width: 2; cursor: grab; }
.pg-handle.d { fill: var(--accent); stroke: var(--accent); } .pg-handle.h { fill: var(--bad); stroke: var(--bad); }
.pg-handle:focus-visible { outline: none; stroke: var(--ink); stroke-width: 3; }
.pg-lbl { font: 600 14px var(--f-mono); }
.pg-lbl.q { fill: var(--gold); } .pg-lbl.d { fill: var(--accent-ink); } .pg-lbl.h { fill: var(--bad); }
.pg-hn { display: inline-flex; gap: 8px; align-items: center; color: var(--ink-2); }
.pg-side .slider { font-size: 0.85rem; margin-bottom: 12px; }
.pg-grid th[scope="row"] { font: 600 0.85rem var(--f-mono); color: var(--gold); text-transform: none; letter-spacing: 0; }
.pg-cell { background: color-mix(in oklab, var(--accent) calc(var(--p) * 70%), transparent); }
.pg-cell.own { box-shadow: inset 0 0 0 2px var(--gold); }
.pg-read { font-size: 0.9rem; }

/* 6: label smoothing */
.st-ctl { display: flex; flex-wrap: wrap; gap: 10px 26px; align-items: center; margin-bottom: 16px; font-size: 0.85rem; }
.st-two { display: grid; gap: 24px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .st-two { grid-template-columns: 1fr 1.2fr; } }
.st-bars { display: flex; gap: 6px; align-items: flex-end; height: 170px; padding-top: 18px; }
.st-bar { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.st-bar i { display: block; width: 100%; max-width: 44px; background: var(--ink-3); opacity: 0.6; border-radius: 4px 4px 0 0; transition: height 0.2s; min-height: 2px; }
.st-bar.right i { background: var(--gold); opacity: 1; }
.st-bar span { font: 11px var(--f-mono); color: var(--ink-2); margin-top: 4px; }
.st-bar small { font: 10px var(--f-mono); color: var(--ink-3); }
.st-bars + .st-t { font-size: 0.86rem; margin-top: 10px; }
.st-chart { width: 100%; max-width: 420px; height: auto; display: block; }
.st-line { fill: none; stroke-width: 2.5; }
.st-line.plain { stroke: var(--accent); } .st-line.smooth { stroke: var(--gold); }
.st-dot.plain { fill: var(--accent); } .st-dot.smooth { fill: var(--gold); }
.st-floor { stroke: var(--ink-2); stroke-dasharray: 6 4; }
.st-read { font-size: 0.88rem; }
.st-read b { font-family: var(--f-mono); }
@media (max-width: 480px) { .st-bar span { font-size: 9px; } .st-bar small { display: none; } }
