/*
  Ratings: styles for the "Performance over time" section (insights.js).
  Same design language as the summary cards: white cards on #fafafa, hairline
  borders, Inter, tabular figures. Charts are inline SVG, so the marks are
  styled here too.
*/

.insights { display: none; margin-top: 52px; border-top: 1px solid var(--ink, var(--ink)); padding-top: 18px; }
.insights.show { display: block; }

.ins-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 18px;
}
.ins-head h2 { font-size: 19px; font-weight: 640; letter-spacing: -0.02em; }

/* breakdowns fold behind one toggle per panel */
.ins-more { margin-top: 6px; }
.ins-more-btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 550; color: var(--ink, var(--ink));
  padding: 9px 16px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px;
  transition: border-color .15s ease, background .15s ease;
}
.ins-more-btn:hover { border-color: var(--ink, var(--ink)); }
.ins-more-btn .chev { display: inline-block; transition: transform .2s ease; color: var(--muted); }
.ins-more.open .ins-more-btn .chev { transform: rotate(180deg); }
.ins-more-body { display: none; }
.ins-more.open .ins-more-body { display: block; }
.ins-more-body .ins-section:first-child .sec-head { margin-top: 26px; }
/* who this section is about: the reader is a long scroll from the search box */
.ins-who { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; font-size: 14px; color: var(--muted); }
.ins-who-av { width: 26px; height: 26px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); background: var(--wash, #f6f6f7); flex: none; }
.ins-who-av.mono { display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; color: var(--muted); }
.ins-who-title { font-family: var(--mono, ui-monospace, monospace); font-size: 10.5px; font-weight: 600; letter-spacing: .06em; color: var(--badge-fg); background: var(--badge-bg); border: 1px solid var(--badge-line); padding: 1px 6px; border-radius: 5px; }
.ins-who-name { font-weight: 600; color: var(--ink, var(--ink)); font-size: 15px; letter-spacing: -0.01em; }
/* the platform strip scrolls rather than wrapping or clipping on a phone */
.seg.tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg.tabs::-webkit-scrollbar { display: none; }
.ins-sub { margin-top: 4px; font-size: 13px; color: var(--muted); max-width: 62ch; }

/* segmented controls: platform tabs, ranges, rating systems */
.seg {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--wash); border: 1px solid var(--line); border-radius: 999px; padding: 3px;
}
.seg .opt {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 550; color: var(--muted);
  padding: 6px 13px; border-radius: 999px; line-height: 1;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.seg .opt:hover { color: var(--ink); }
.seg .opt.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px var(--shadow-soft); }
.seg.small .opt { padding: 5px 11px; font-size: 12.5px; }
.seg .tab .spin {
  width: 11px; height: 11px; border-radius: 50%; flex: none; display: none;
  border: 2px solid var(--line); border-top-color: var(--muted); animation: ispin .7s linear infinite;
}
.seg .tab.loading .spin { display: inline-block; }
@keyframes ispin { to { transform: rotate(360deg); } }

.ins-panel { display: none; }
.ins-panel.on { display: block; }

.ins-loading, .ins-error {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 40px 24px; text-align: center; color: var(--muted); font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.ins-loading .spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--muted); animation: ispin .7s linear infinite;
}

.ins-section { margin-bottom: 30px; }
.ins-section .sec-head { margin: 34px 0 14px; }
.ins-section .sec-head h3 { font-size: 17px; font-weight: 650; letter-spacing: -0.015em; }
.ins-section .sec-head .vnote { margin-top: 4px; }

/* cards */
.vcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px 22px;
}
.vhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.vtitle { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.vnote { font-size: 12.5px; color: var(--muted); line-height: 1.45; max-width: 70ch; }
.vhead .vnote { flex: 1 1 240px; text-align: right; }
.vgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.vgrid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .vgrid, .vgrid.three { grid-template-columns: 1fr; } .vhead .vnote { text-align: left; } }

.vtop { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.vchart { width: 100%; }
.viz-empty { padding: 34px 0; text-align: center; color: var(--faint); font-size: 13px; }
.viz-note { margin-top: 10px; font-size: 12px; color: var(--faint); }

.more {
  appearance: none; margin-top: 14px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 550;
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 16px;
}
.more:hover { border-color: var(--rule-strong); background: var(--wash); }
.more:disabled { color: var(--faint); cursor: default; }

/* svg chart chrome */
.viz-line, .viz-col { display: block; width: 100%; overflow: visible; }
.viz-line .tick, .viz-col .tick { font-size: 11px; fill: var(--faint); font-variant-numeric: tabular-nums; }
.viz-line .endlab, .viz-line .peak {
  font-weight: 600; fill: var(--muted); font-variant-numeric: tabular-nums;
  /* a surface-coloured halo so a label stays legible where it crosses a line */
  paint-order: stroke; stroke: var(--card); stroke-width: 3px; stroke-linejoin: round;
}
.viz-line .endlab { font-size: 11.5px; }
.viz-line .peak { font-size: 11px; }
.viz-col .col { transition: opacity .12s ease; }
.viz-col .col.hover { opacity: .72; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 4px; }
.legend .item {
  appearance: none; border: 0; background: transparent; cursor: pointer; font: inherit;
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--ink); padding: 5px 9px; border-radius: 999px;
}
.legend .item:hover { background: var(--wash); }
.legend .item.off { color: var(--faint); }
.legend .item.off .key { opacity: .3; }
.legend .item .cnt { color: var(--faint); font-variant-numeric: tabular-nums; }
.key { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.key.rect { width: 10px; height: 10px; border-radius: 3px; }

/* stat tiles */
.tiles {
  /* separators are drawn by each tile, not by a coloured background behind the
     grid: a half-filled last row then stays white instead of showing a gap */
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; margin-top: 18px;
}
@media (max-width: 760px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .tiles { grid-template-columns: 1fr; } }
.tile {
  background: var(--card); padding: 15px 16px 16px; min-width: 0;
  box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line);
}
.tile .lbl { font-size: 11.5px; color: var(--muted); letter-spacing: .01em; }
.tile .val {
  margin-top: 5px; font-size: 25px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15;
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.tile .val.up { color: var(--up); }
.tile .val.down { color: var(--down); }
.tile .sub { margin-top: 5px; font-size: 12px; color: var(--faint); line-height: 1.4; }
.tile .delta { font-size: 12.5px; font-weight: 600; }
.tile .delta.up { color: var(--up); }
.tile .delta.down { color: var(--down); }

/* milestone badges */
.milestones { margin-top: 26px; }
.milestones .vtitle { margin-bottom: 12px; }
.badges { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 860px) { .badges { grid-template-columns: 1fr; } }
.badge {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 13px 15px;
}
.badge .glyph {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink); color: var(--paper); font-size: 15px; line-height: 1;
}
.badge.big { border-color: var(--gold-line); background: linear-gradient(180deg, var(--gold-soft), var(--card)); }
.badge .bbody { min-width: 0; }
.badge .btitle { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.badge .bsub { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge .bdate { font-size: 11.5px; color: var(--faint); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* win / draw / loss strip */
.wdl { margin-top: 10px; }
.wdl .bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; background: var(--wash); }
.wdl .bar .seg { height: 100%; }
.wdl .leg { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 9px; font-size: 12px; color: var(--muted); }
.wdl .leg .item { display: inline-flex; align-items: center; gap: 6px; }
.wdl .leg b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.color-block { padding: 12px 0; border-bottom: 1px solid var(--line); }
.color-block:last-child { border-bottom: 0; padding-bottom: 0; }
.color-block:first-child { padding-top: 0; }
.color-lab { display: flex; align-items: center; gap: 8px; font-size: 13.5px; flex-wrap: wrap; }
.color-lab b { font-weight: 600; }
.color-lab .muted { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.color-lab .sq { width: 11px; height: 11px; border-radius: 3px; border: 1px solid var(--axis, #d6d3d1); flex: none; }
.color-lab .sq.w { background: var(--sq-white); }
.color-lab .sq.b { background: var(--sq-black); }

/* horizontal ranked bars */
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hb {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(70px, 1fr) auto;
  align-items: center; gap: 12px;
  margin: 0 -8px; padding: 3px 8px; border-radius: 8px;
}
.hb:hover { background: var(--wash); }
.hb .lab { min-width: 0; display: flex; flex-direction: column; }
.hb .lab .name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb .lab .sub { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.hb .track { display: flex; gap: 2px; height: 9px; border-radius: 5px; overflow: hidden; background: var(--wash); }
.hb .track .fill, .hb .track .seg { height: 100%; }
.hb .val { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }

/* key / value rows inside format cards */
.kv { margin-top: 14px; border-top: 1px solid var(--line); }
.kvr { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kvr:last-child { border-bottom: 0; }
.kvr .k { font-size: 12.5px; color: var(--muted); }
.kvr .v { font-size: 13px; font-weight: 550; text-align: right; font-variant-numeric: tabular-nums; }

/* activity heatmap */
.heat { display: flex; flex-direction: column; gap: 3px; }
.heat-row { display: grid; grid-template-columns: 28px repeat(24, minmax(0, 1fr)); gap: 3px; align-items: center; }
.heat-row .dl { font-size: 10.5px; color: var(--faint); }
.heat-row .hl { font-size: 9.5px; color: var(--faint); text-align: center; }
.heat .cell { height: 14px; border-radius: 3px; }
.heat-row.head .cell { height: auto; }

/* shared tooltip */
.viz-tip {
  position: fixed; z-index: 60; display: none; pointer-events: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 24px var(--shadow); padding: 9px 11px; min-width: 110px;
  font-size: 12.5px; color: var(--ink);
}
.viz-tip .title { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.viz-tip .row { display: flex; align-items: center; gap: 7px; padding: 1.5px 0; }
.viz-tip .row b { font-weight: 650; font-variant-numeric: tabular-nums; }
.viz-tip .row .lbl { color: var(--muted); }

/* Motion: charts draw themselves in, bars grow from zero. Everything here is
   opt-out under reduced motion, matching the summary cards in index.html. */
.ins-panel.on .vcard { animation: iRise .16s ease-out both; }
@keyframes iRise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.tile { transition: border-color .18s ease, transform .18s ease; }
.tile:hover { border-color: var(--rule-strong); transform: translateY(-1px); }
.badge { transition: transform .18s ease, border-color .18s ease; }
.badge:hover { transform: translateY(-1px); }
.heat .cell { transition: transform .12s ease; }
.heat .cell:hover { transform: scale(1.35); border-radius: 2px; }

@media (prefers-reduced-motion: reduce) {
  .ins-panel.on .vcard { animation: none; }
  .tile:hover, .badge:hover, .heat .cell:hover { transform: none; }
  .seg .tab .spin, .ins-loading .spinner { animation-duration: 1.4s; }
}

/* Chess.com full-history loader */
.com-progress { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.com-progress b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.com-progress .spinner { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--muted); animation: ispin .7s linear infinite; }
.com-progress .linkish { border: 0; background: none; font: inherit; font-size: 12.5px; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.com-progress .linkish:hover { color: var(--ink); }

/* one-line timelines: format picker beside the range control; scrolls on phones */
.seg.fmts { max-width: 100%; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.seg.fmts::-webkit-scrollbar { display: none; }
