/* /profile, the member's own page (2026-10-27): the site's navy and orange, as on /analysis and
   the lobby, in place of the page's old brown and gold. Colours are tokens here and no hex
   appears below :root. Geist and Geist Mono are self-hosted (static/fonts/geist/geist.css), as on
   /analysis. The page script builds the chart, the game rows and the course rows with these class
   names (pages/student_profile.html). */
:root {
  --canon: #0b162a;  --panel: #13203a;  --edge: #1c2c48;  --raised: #182844;
  --ink: #eef3f9;    --muted: #9db1c7;  --faint: #6a7f96;
  --gold: #e64100;   --gold-soft: rgba(230, 65, 0, .16);  --gold-edge: rgba(230, 65, 0, .6);
  --brand-hover: #f3d8ad;
  --rule: rgba(157, 177, 199, .13);  --rule-strong: rgba(157, 177, 199, .28);
  --good: #7fbf6a;  --good-soft: rgba(127, 191, 106, .14);  --good-edge: rgba(127, 191, 106, .45);
  --bad: #e74c3c;
  --learn: #5ea9f0;  --learn-soft: rgba(94, 169, 240, .12);  --learn-edge: rgba(94, 169, 240, .4);
  --white-share: #e9edf3;  --black-share: #05090f;
  --sq-light: #f0d9b5;  --sq-dark: #b58863;            /* the board squares, as on /analysis */
  --display: 'Geist', system-ui, sans-serif;
  --read: 'Geist', system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, monospace;
  --radius: 10px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--canon); }
body { background: var(--canon); color: var(--ink); font-family: var(--read); -webkit-font-smoothing: antialiased;
  min-height: 100vh; padding: 22px 20px 80px; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }

/* ── Top bar: the wordmark, as on /analysis, and the way back ── */
.pf-top { max-width: 1020px; margin: 0 auto 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pf-logo { display: flex; align-items: baseline; gap: 9px; white-space: nowrap; }
.pf-logo .mark { color: var(--gold); font-size: 21px; line-height: 1; }
.pf-logo .word { font-family: var(--display); font-weight: 700; font-size: 27px; line-height: 1; letter-spacing: -.02em;
  color: var(--ink); transition: color .3s ease; }
.pf-logo .word b { color: var(--gold); }
.pf-logo:hover .word { color: var(--brand-hover); }
.pill { display: inline-block; font-family: var(--mono); font-size: 13px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--rule-strong); background: transparent; color: var(--muted); cursor: pointer;
  text-align: center; white-space: nowrap; transition: background .15s ease, border-color .15s ease, color .15s ease; }
.pill:hover { background: var(--gold); border-color: var(--gold); color: var(--canon); }

.profile-wrap { max-width: 1020px; margin: 0 auto; }
.eyebrow { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.section-label { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--faint); margin: 0 0 12px; }
.loading-msg { color: var(--faint); font-size: 14px; padding: 20px 0; }

/* ── Hero: who you are, and the Skill Rating as the page's one big number ── */
.pf-hero { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 16px 24px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.pf-name { font-family: var(--display); font-size: clamp(26px, 2vw + 14px, 38px); font-weight: 700; letter-spacing: -.02em;
  line-height: 1.1; margin-top: 4px; overflow-wrap: anywhere; }
.pf-ratings { display: flex; align-items: flex-end; gap: 28px; flex-wrap: wrap; }

/* ── Puzzles by tactic (2026-11-25): bars for the share solved, dots for the rating per tactic.
   One series each, so no legend: the card titles name them. Each row is a link to /tactics. ── */
.pz-section { margin-bottom: 26px; }
.pz-section[hidden] { display: none; }
.pz-count { color: var(--muted); letter-spacing: 0; text-transform: none; }
.pz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.pz-card { background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); padding: 16px 18px; }
.pz-h { font-family: var(--display); font-size: 17px; font-weight: 700; }
.pz-sub { font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
.pz-rows { display: flex; flex-direction: column; gap: 2px; }
.pz-row { display: grid; grid-template-columns: minmax(96px, 9.5em) 1fr 5.6em; align-items: center; gap: 10px;
  padding: 4px 6px; border-radius: 6px; font-size: 13px; }
a.pz-row:hover { background: var(--raised); }
.pz-row.few { opacity: .5; }
.pz-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pz-track { position: relative; height: 10px; border-radius: 4px; background: var(--rule); }
.pz-track.pz-plain { background: transparent; height: 16px; }
.pz-track.pz-plain::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--rule); }
.pz-bar { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--learn); }
.pz-dot { position: absolute; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: var(--learn); box-shadow: 0 0 0 2px var(--panel); }
.pz-ref { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--gold); }
.pz-you-lbl { position: absolute; bottom: 0; transform: translateX(-50%); font-family: var(--mono); font-size: 11px;
  color: var(--gold); white-space: nowrap; }
.pz-val { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pz-val small { color: var(--faint); font-size: 11px; }
.pz-ticks { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.pz-ticks::before, .pz-axis-head .pz-track::before { display: none; }
.pz-note { font-size: 13px; color: var(--muted); margin-top: 10px; }
.pf-skill { display: none; flex-direction: column; align-items: flex-end; }
.pf-skill strong { font-family: var(--display); font-size: clamp(40px, 3vw + 22px, 56px); font-weight: 700; letter-spacing: -.02em;
  line-height: 1; font-variant-numeric: tabular-nums; }
.pf-skill-lbl { font-family: var(--mono); font-size: 12px; color: var(--gold); margin-top: 6px; }
.pf-skill-lbl span { color: var(--muted); }
.pf-skill-change { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 4px; }
.pf-skill-change.up   { color: var(--good); }
.pf-skill-change.down { color: var(--bad); }
.pf-record { font-family: var(--mono); font-size: 13px; color: var(--muted); margin-top: 8px; font-variant-numeric: tabular-nums; }
.pf-record .w { color: var(--good); }
.pf-record .l { color: var(--bad); }

/* ── A member with no rated games yet ── */
.pf-start { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px 24px;
  background: var(--panel); border: 1px solid var(--gold-edge); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 30px; }
.pf-start[hidden] { display: none; }
.pf-start h2 { font-family: var(--display); font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.pf-start p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.pill.primary { background: var(--gold); border-color: var(--gold); color: var(--canon); font-weight: 600; padding: 10px 22px; }
.pill.primary:hover { filter: brightness(1.08); }

/* ── Stat chips: the record, and the three phases ── */
.stats-chips { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 30px; }
.stat-chip { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius);
  padding: 14px 16px; }
.chip-val { font-family: var(--mono); font-size: 26px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--ink); }
.chip-val.green { color: var(--good); }
.chip-val.red   { color: var(--bad); }
.chip-val.gold  { color: var(--gold); }
.chip-lbl { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-top: 4px; }
/* Beside each phase: what is typical for FIDE players in the member's band, and the gap. */
.chip-cmp { font-family: var(--mono); font-size: 11.5px; color: var(--faint); margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--rule); }
.chip-cmp:empty { display: none; }
.chip-cmp .up   { color: var(--good); }
.chip-cmp .down { color: var(--bad); }

/* ── Skill Rating trend: each game's Game Rating a dot, the Skill Rating (average of the last 20
      at that point) a line through them. Drawn by buildTrend(). ── */
.trend-section { margin-bottom: 30px; }
.trend-wrap { background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); padding: 14px 16px 8px; }
.trend-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.trend-key { display: inline-flex; align-items: center; gap: 7px; }
.trend-key-dot  { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.trend-key-line { width: 18px; height: 2px; border-radius: 1px; background: var(--gold); }
#trend-chart { width: 100%; height: 200px; display: block; overflow: visible; }
.trend-grid { stroke: var(--rule); stroke-width: 1; }
.trend-tick { fill: var(--faint); font-family: var(--mono); font-size: 11px; font-variant-numeric: tabular-nums; }
.trend-dot  { fill: var(--muted); stroke: var(--panel); stroke-width: 2; }
.trend-dot.win,  .trend-key-dot.win  { fill: var(--good); background: var(--good); }
.trend-dot.loss, .trend-key-dot.loss { fill: var(--bad);  background: var(--bad); }
.trend-dot.draw, .trend-key-dot.draw { fill: var(--muted); background: var(--muted); }
.trend-hit  { fill: transparent; }
.trend-pt:hover .trend-dot { fill: var(--ink); }
.trend-line { fill: none; stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-end  { fill: var(--gold); font-family: var(--mono); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.trend-pt   { cursor: pointer; }
.trend-pt.sel .trend-dot { r: 6; stroke: var(--ink); }
.trend-info { font-size: 13px; color: var(--muted); border-top: 1px solid var(--rule); margin-top: 6px; padding: 9px 2px 4px; }
.trend-info b { color: var(--ink); font-family: var(--mono); font-weight: 600; }

/* ── Folding sections (Quick Courses, Account Settings): the label is the toggle ── */
.pf-fold > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; width: fit-content; }
.pf-fold > summary::-webkit-details-marker { display: none; }
.pf-fold > summary::before { content: '▸'; font-size: 11px; color: var(--faint); transition: transform .15s ease; }
.pf-fold[open] > summary::before { transform: rotate(90deg); }
.pf-fold > summary:hover { color: var(--muted); }
.pf-fold:not([open]) > summary { margin-bottom: 30px; }
.pf-fold-n { color: var(--muted); }

/* ── Opening Lab: two tabs of small boards. Your games: where each game left the explorer's
      book. Your repertoire: the explorer's saved lines, As White / As Black. ── */
.lab-section { margin-bottom: 30px; }
.lab-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 10px; }
.lab-head .section-label { margin: 0; }
.lab-tabs, .lab-sides { display: flex; gap: 6px; flex-wrap: wrap; }
.lab-tab, .lab-side { font-family: var(--mono); font-size: 12.5px; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid var(--rule-strong); color: var(--muted);
  transition: border-color .15s ease, color .15s ease, background .15s ease; }
.lab-tab:hover, .lab-side:hover { color: var(--ink); border-color: var(--muted); }
.lab-tab.on, .lab-side.on { color: var(--ink); border-color: var(--gold); background: var(--gold-soft); }
.lab-side { font-size: 12px; padding: 5px 12px; }
.lab-side span { color: var(--faint); }
.lab-sides { margin-bottom: 12px; }
.lab-note { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.lab-empty { font-size: 14px; color: var(--faint); padding: 16px 0; }
.lab-empty a { color: var(--gold); }
.lab-panel[hidden] { display: none; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
.book-card { position: relative; display: flex; flex-direction: column; gap: 4px; background: var(--panel);
  border: 1px solid var(--edge); border-radius: var(--radius); padding: 10px 10px 12px; transition: border-color .18s ease; }
.book-card:hover { border-color: var(--gold-edge); }
/* Rows as well as columns are fixed eighths: left to size themselves, a rank with no pieces
   came out a different height from the others and showed as a strip across the board. */
.book-board { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1 / 1; border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
.book-sq { display: block; min-width: 0; min-height: 0; overflow: hidden; }
.book-sq img { display: block; width: 100%; height: 100%; object-fit: contain; }
.book-sq-light { background: var(--sq-light); }
.book-sq-dark  { background: var(--sq-dark); }
.book-count { font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--gold); margin-top: 2px; }
.book-name { font-size: 13.5px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.book-meta { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.book-meta.book-mine { color: var(--muted); }
.book-meta:empty { display: none; }

/* ── Train from your games ── */
.train-section { margin-bottom: 30px; }
.train-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.train-link { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--edge);
  border-radius: var(--radius); padding: 14px 18px; transition: border-color .18s ease; }
.train-link:hover { border-color: var(--gold-edge); }
.train-n { font-family: var(--mono); font-size: 26px; font-weight: 600; color: var(--gold); min-width: 2ch; text-align: right;
  font-variant-numeric: tabular-nums; }
.train-what { display: flex; flex-direction: column; font-weight: 600; color: var(--ink); font-size: 15px; }
.train-what em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 2px; }
.train-what em.train-progress { font-family: var(--mono); font-size: 12px; color: var(--good); margin-top: 4px; }
.train-what em.train-progress:empty { display: none; }
.train-go { margin-left: auto; color: var(--faint); transition: color .18s ease; }
.train-link:hover .train-go { color: var(--gold); }

/* ── Recent games ── */
.games-section { margin-bottom: 36px; }
#games-container { background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); padding: 4px 14px 12px; }
.games-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.games-table th { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); padding: 12px 8px 10px; text-align: left; border-bottom: 1px solid var(--rule-strong); }
.games-table td { padding: 10px 8px; border-bottom: 1px solid var(--rule); color: var(--muted); vertical-align: middle; }
.games-table tr:last-child td { border-bottom: none; }
.games-table tbody tr:hover td { background: var(--raised); }
.result-win  { color: var(--good); font-weight: 600; }
.result-loss { color: var(--bad);  font-weight: 600; }
.result-draw { color: var(--muted); font-weight: 600; }
.gr-val  { font-family: var(--mono); color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.opp-sub { display: block; font-size: 12px; color: var(--faint); margin-top: 1px; }   /* the computer's level */
.gr-lbl  { display: none; }                                   /* phones only, where the table header is hidden */
.game-link { color: var(--ink); }
.game-link:hover { color: var(--gold); }
.game-open { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.game-open:hover { color: var(--gold); }
.num-dim { color: var(--faint); }
/* The same filled pawn for both colours, coloured by the chip (house rule: no hollow glyphs). */
.color-chip { display: inline-block; width: 18px; height: 18px; border-radius: 3px; font-size: 12px; line-height: 18px; text-align: center; }
.color-chip.white { background: var(--white-share); color: var(--black-share); }
.color-chip.black { background: var(--black-share); color: var(--muted); border: 1px solid var(--edge); }
.show-more-btn { display: block; width: 100%; margin-top: 12px; padding: 9px; background: none; border: 1px solid var(--rule-strong);
  border-radius: 999px; color: var(--muted); font-family: var(--mono); font-size: 13px; cursor: pointer;
  transition: border-color .18s ease, color .18s ease; }
.show-more-btn:hover { border-color: var(--gold); color: var(--gold); }
.games-note  { font-family: var(--mono); font-size: 12px; color: var(--faint); text-align: center; margin-top: 10px; }
.games-empty { color: var(--faint); font-size: 14px; padding: 18px 0; text-align: center; }

/* ── Courses: one compact row each ── */
.courses-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 10px; margin-bottom: 36px; }
.course-row { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--edge);
  border-radius: var(--radius); padding: 12px 16px; transition: border-color .2s ease; }
.course-row:hover { border-color: var(--learn-edge); }
.course-num { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--learn); background: var(--learn-soft); border: 1px solid var(--learn-edge); }
.course-row.done .course-num { color: var(--good); background: var(--good-soft); border-color: var(--good-edge); }
.course-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.course-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.course-meta  { font-size: 12.5px; color: var(--faint); }
.course-state { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--learn); white-space: nowrap; }
.course-row.done .course-state { color: var(--good); }

/* ── Account settings ── */
.settings-card { background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); padding: 20px 22px;
  display: flex; flex-direction: column; gap: 24px; margin-bottom: 24px; }
.settings-group-title { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin-bottom: 12px; }
.settings-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.settings-input { flex: 1; min-width: 0; background: var(--canon); border: 1px solid var(--edge); border-radius: 8px; color: var(--ink);
  font-size: 14px; padding: 10px 14px; outline: none; transition: border-color .18s ease; }
.settings-input:focus { border-color: var(--gold-edge); }
.settings-input::placeholder { color: var(--faint); }
.settings-btn { background: var(--gold); border: 1px solid var(--gold); border-radius: 999px; color: var(--canon); font-family: var(--mono);
  font-size: 13px; font-weight: 600; padding: 9px 18px; cursor: pointer; white-space: nowrap; transition: filter .18s ease; }
.settings-btn:hover { filter: brightness(1.08); }
.settings-btn:disabled { opacity: .5; cursor: default; }
.settings-msg { font-size: 13px; margin-top: 8px; min-height: 1.2em; }
.settings-msg.ok  { color: var(--good); }
.settings-msg.err { color: var(--bad); }
.settings-pw-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }

@media (max-width: 640px) {
  body { padding: 16px 16px 60px; }
  .pf-logo .word { font-size: 23px; }
  .pf-hero { padding: 16px; }
  .pf-skill { align-items: flex-start; }
  .courses-grid, .train-links { grid-template-columns: 1fr; }
  .stats-chips { gap: 8px; }
  .stat-chip { padding: 12px; flex: 1 1 calc(33.333% - 6px); }   /* three to a row */
  .chip-val { font-size: 20px; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }   /* two small boards to a row */
  .book-name { font-size: 12.5px; }
  /* The phases carry a comparison line, too long for a third of a phone: one to a row. */
  .phase-section .stat-chip { flex-basis: 100%; }
  /* Each game a two-line card: who and the Game Rating, then result, accuracy and date. */
  .games-table thead { display: none; }
  .games-table, .games-table tbody { display: block; }
  .games-table tr { display: grid; grid-template-columns: auto auto 1fr; gap: 3px 14px; align-items: baseline;
    padding: 11px 2px; border-bottom: 1px solid var(--rule); }
  .games-table tr:last-child { border-bottom: none; }
  .games-table td { padding: 0; border: 0; }
  .games-table tbody tr:hover td { background: none; }
  .games-table .hide-mobile { display: none; }
  .td-opp  { grid-column: 1 / 3; grid-row: 1; color: var(--ink); }
  .td-gr   { grid-column: 3; grid-row: 1; justify-self: end; white-space: nowrap; }
  .td-res  { grid-column: 1; grid-row: 2; font-size: 13px; }
  .td-acc  { grid-column: 2; grid-row: 2; font-size: 13px; }
  .td-date { grid-column: 3; grid-row: 2; justify-self: end; font-size: 13px; white-space: nowrap; }
  .opp-sub { display: inline; margin-left: 6px; }
  .gr-lbl  { display: inline; font-family: var(--mono); font-size: 11px; color: var(--faint); }
  .settings-pw-grid { grid-template-columns: 1fr; }
}
