/* The history page, on top of hub/style.css. */
.top-right .back { gap: 6px; text-decoration: none; background: var(--card); box-shadow: var(--shadow); }
.hero h1 { font-size: clamp(2rem, 5vw, 2.8rem); }
.hist-sub { margin: 12px 0 0; color: var(--muted); font-size: 1.02rem; }
.hist-sub b { color: var(--ink); font-weight: 600; }
.hist-back { margin: 8px 0 0; color: var(--muted); font-size: 0.95rem; }
.hist-back a { color: var(--brand); font-weight: 700; text-underline-offset: 3px; }
.day-games li.is-focus { box-shadow: inset 4px 0 0 var(--ink); padding-left: 12px; }
.total.is-focus { outline: 2px solid var(--ink); outline-offset: 2px; }

.hist-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }

.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.cal-head h2 { margin: 0; font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; }
.cal-nav {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--ink);
  font: 600 1.3rem/1 var(--font); cursor: pointer;
}
.cal-nav:hover:not(:disabled) { background: var(--line); }
.cal-nav:disabled { opacity: 0.3; cursor: default; }
.cal-nav:focus-visible, .cal-day:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-week { margin-bottom: 6px; }
.cal-week span { text-align: center; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.cal-day {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 4px;
  position: relative; aspect-ratio: 1 / 1.05; min-width: 0; padding: 7px 2px 4px; border: 1px solid transparent; border-radius: 12px;
  background: var(--bg); color: var(--ink); font: 600 0.95rem var(--font); cursor: pointer;
}
button.cal-day:hover { border-color: var(--line); }
.cal-day.is-off { background: transparent; color: var(--muted); opacity: 0.45; cursor: default; }
.cal-day.is-played { background: var(--done-bg); }
.cal-day.is-today { border-color: var(--brand); }
.cal-day.is-today .n { color: var(--brand); text-decoration: underline 2px; text-underline-offset: 3px; }
.cal-day.is-picked { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.cal-day .n { font-variant-numeric: tabular-nums; }
/* Played days get a tick as well as the tint, so they show without colour. */
.cal-day.is-played::after { content: '✓'; position: absolute; top: 4px; right: 5px; font-size: 0.68rem; line-height: 1; color: var(--done); }
/* A day a streak freeze covered. */
.cal-day.is-frozen::after { content: '❄️'; position: absolute; top: 3px; right: 3px; font-size: 0.62rem; line-height: 1; }
.freeze-note { font-size: 0.86em; }
.pips { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 34px; }
.pips i, .legend i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.day h2 { margin: 0; font-size: 1.3rem; font-weight: 800; letter-spacing: -0.01em; }
.day-sub { margin: 4px 0 12px; color: var(--muted); font-size: 0.92rem; }
.day-games { list-style: none; margin: 0; padding: 0; }
.day-games li {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: 'dot name act' 'dot chip act';
  align-items: center; gap: 2px 10px; padding: 10px 0; border-top: 1px solid var(--line);
}
.gdot { flex: none; grid-area: dot; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.gname { grid-area: name; font-weight: 700; }
.gname small { font: 500 0.78rem var(--mono); color: var(--muted); }
.day-games .chip { grid-area: chip; justify-self: start; }
.day-games .chip-none { color: var(--muted); padding-left: 0; }
.day-games .btn, .no-arch { grid-area: act; }
.btn-sm { padding: 6px 12px; font-size: 0.84rem; text-decoration: none; }
.no-arch { font-size: 0.78rem; color: var(--muted); }
.chip { font-size: 0.78rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }

.totals-wrap { padding: 28px 0 10px; }
.sec-title { margin: 0 0 12px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--brand); }
.totals { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.total { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.total-head { display: flex; align-items: center; gap: 8px; min-width: 0; margin-bottom: 10px; font-weight: 800; font-size: 1.05rem; }
.total-head a { text-decoration: none; }
.total-head a:hover { text-decoration: underline; }
.total dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; }
.total dt { font-size: 0.72rem; color: var(--muted); }
.total dd { margin: 2px 0 0; font: 500 1.25rem var(--mono); font-variant-numeric: tabular-nums; }

/* Your week: one row per game, a square per day. */
.week { margin-top: 20px; }
.wk-sum { margin: 0 0 12px; color: var(--muted); font-size: 0.95rem; }
.wk-sum b { color: var(--ink); }
.wk-grid { display: grid; gap: 4px; }
.wk-row { display: grid; grid-template-columns: minmax(4.5em, 8em) repeat(7, minmax(0, 1fr)) 2.6em; align-items: center; gap: 4px; }
.wk-g { font-weight: 700; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-d { text-align: center; font-size: 0.72rem; font-weight: 600; color: var(--muted); }
.wk-d.is-today { color: var(--brand); text-decoration: underline 2px; text-underline-offset: 3px; }
.wk-n { text-align: right; font: 500 0.85rem var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.wk-c { position: relative; height: 22px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); }
.wk-c.done { background: var(--accent); border-color: transparent; }
.wk-c.done::before { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 0.7rem; font-weight: 800; color: #fff; text-shadow: 0 0 2px rgba(0, 0, 0, 0.6); }
.wk-c.lost { background: color-mix(in srgb, var(--accent) 35%, transparent); border-color: transparent; }
.wk-c.prog { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 45%, transparent) 50%, transparent 50%); }
.wk-c.off { background: transparent; border-style: dashed; opacity: 0.4; }
.wk-actions { margin-top: 12px; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }

/* Achievements: unlocked ones in full colour, locked ones greyed with their rule. */
.ach-wrap { padding: 28px 0 0; }
.sec-title small { margin-left: 8px; letter-spacing: 0; text-transform: none; color: var(--muted); font-weight: 500; font-size: 0.9rem; }
.ach { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.ach-i { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; }
.ach-e { font-size: 1.6rem; line-height: 1; }
.ach-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ach-t small { color: var(--muted); font-size: 0.8rem; }
.ach-i:not(.got) { background: transparent; border-style: dashed; }
.ach-i:not(.got) .ach-e { filter: grayscale(1); opacity: 0.45; }
.ach-i:not(.got) b { color: var(--muted); }
.ach-new { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 0.7rem; font-weight: 700; vertical-align: 1px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 760px) {
  .hist-layout { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .panel { padding: 14px 12px; }
  .cal-week, .cal-grid { gap: 4px; }
  .cal-day { font-size: 0.86rem; border-radius: 10px; padding-top: 5px; }
  .cal-day.is-played::after { top: 3px; right: 3px; font-size: 0.58rem; }
  .pips { gap: 2px; }
  .pips i { width: 6px; height: 6px; }
  .wk-row { grid-template-columns: minmax(3.6em, 5.5em) repeat(7, minmax(0, 1fr)) 2.2em; gap: 3px; }
  .wk-g { font-size: 0.8rem; }
  /* Totals become compact rows: name, then the three numbers. */
  .totals { gap: 0; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 2px 14px; }
  .total { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 10px 0; border: 0; border-radius: 0; background: none; }
  .total + .total { border-top: 1px solid var(--line); }
  .total-head { margin: 0; font-size: 0.98rem; min-width: 0; }
  .total-head a { overflow-wrap: anywhere; } /* wraps rather than cut a long name */
  .total dl { grid-template-columns: repeat(3, 2.6em); gap: 4px; text-align: right; }
  .total dt .long { display: none; }
  .total dt::first-letter { text-transform: uppercase; }
  .total dt { font-size: 0.66rem; }
  .total dd { font-size: 1.05rem; }
}

/* Touch screens: small controls keep their look but take taps in a 44px box around their centre
   (the same rule as hub/links.css). */
@media (pointer: coarse) {
  :where(.brand, .btn, .cal-nav) { position: relative; }
  :where(.brand, .btn, .cal-nav)::after { content: ''; position: absolute; inset: min(0px, calc((100% - 44px) / 2)); }
  .total-head a { padding: 12px 0; }
}
