/* Phase 5: History tab, weekly summary, Printables tab and the printed pages. */

/* ---------- weekly summary ---------- */
.sumgrid { display: grid; gap: 1rem; }
.sumcard { padding: 1rem 1.25rem; }
.sumcard__head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.sumcard__head .avatar { --size: 3rem; }
.sumcard__head h3 { margin: 0; flex: 1; }
.sumtiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.sumtile { background: var(--surface2); border: 1px solid var(--line); border-radius: 1rem; padding: .75rem; display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.sumtile__label { font-size: 1rem; color: var(--muted); font-weight: 700; }
.sumtile__value { font-size: 2.25rem; line-height: 1.15; }
.sumtile__sub { font-size: 1rem; color: var(--muted); overflow-wrap: anywhere; }
.sumcard__tip { margin: .9rem 0 0; padding: .75rem 1rem; border-radius: 1rem; background: var(--accent-soft); font-weight: 600; }

/* ---------- 14-day bars ---------- */
.hbars { padding: 1rem 1.25rem; }
.hbars__head { display: flex; align-items: center; gap: .75rem 1.25rem; flex-wrap: wrap; }
.hbars__head h3 { margin: 0; }
.hbars__head .btn { margin-left: auto; }
.hbars__legend { display: flex; gap: 1rem; color: var(--muted); font-weight: 700; font-size: 1rem; }
.hbars__legend span { display: inline-flex; align-items: center; gap: .4rem; }
.hbars__key { width: 1rem; height: 1rem; border-radius: .25rem; display: inline-block; }
.hbars__key--plan { opacity: .2; }
.hbars__wrap { position: relative; margin-top: .5rem; }
.hbars__svg { width: 100%; height: auto; display: block; overflow: visible; }
.hbars__grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.hbars__base { stroke: var(--muted); stroke-width: 1.5; opacity: .5; }
.hbars__axis { font-size: 13px; fill: var(--muted); }
.hbars__plan { opacity: .18; }
.hbars__val { font-size: 15px; font-weight: 800; fill: var(--ink); }
.hbars__day { font-size: 15px; font-weight: 700; fill: var(--muted); }
.hbars__day--today { fill: var(--ink); font-weight: 900; }
.hbars__date { font-size: 13px; fill: var(--muted); }
.hbars__g { cursor: default; outline: none; }
.hbars__g.is-hover .hbars__done, .hbars__g:focus .hbars__done { filter: brightness(.9); }
.hbars__g:focus rect { stroke: var(--primary); stroke-width: 2; }
.hbars__tip {
  position: absolute; top: -.25rem; transform: translate(-50%, -100%); pointer-events: none; white-space: nowrap;
  background: var(--ink); color: var(--surface); padding: .4rem .75rem; border-radius: .6rem; font-size: 1rem; font-weight: 700;
  box-shadow: 0 .25rem .75rem rgba(0,0,0,.15);
}
.htable { width: 100%; border-collapse: collapse; margin-top: .75rem; }
.htable th, .htable td { padding: .5rem .75rem; border-bottom: 1px solid var(--line); text-align: left; }
.htable td { font-variant-numeric: tabular-nums; }

/* ---------- lifetime ---------- */
.ltsince { font-size: 1rem; font-weight: 600; }
.ltgrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .75rem; }
.ltgrid li { background: var(--surface2); border: 1px solid var(--line); border-radius: 1rem; padding: .75rem; display: flex; flex-direction: column; gap: .1rem; }
.ltgrid__icon { font-size: 1.5rem; }
.ltgrid strong { font-size: 1.75rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.ltgrid li > span:last-child { color: var(--muted); font-size: 1rem; font-weight: 600; }

/* ---------- activity log ---------- */
.hlog { list-style: none; margin: 0; padding: 0; }
.hlog__day { font-weight: 800; color: var(--muted); padding: 1rem 0 .35rem; border-bottom: 2px solid var(--line); }
.hlog__item { display: flex; align-items: center; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.hlog__icon { width: 2.25rem; text-align: center; font-size: 1.4rem; flex: none; }
.hlog__text { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.hlog__stars { font-weight: 800; color: #9A6A10; background: var(--accent-soft); padding: .1rem .6rem; border-radius: 999px; font-size: 1rem; }
.hlog__stars--spent { color: var(--muted); background: var(--surface2); }
.hlog__time { color: var(--muted); font-size: 1rem; min-width: 4.5rem; text-align: right; }
.hlog__item--pending .hlog__text { color: var(--muted); }

/* ---------- Printables tab ---------- */
.achlist { list-style: none; margin: 0; padding: 0; }
.achrow { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.achrow__icon { font-size: 2rem; width: 2.75rem; text-align: center; }
.achrow__text { flex: 1 1 12rem; display: flex; flex-direction: column; min-width: 0; }
.ppreview { margin-top: .5rem; }
.ppreview__paper {
  display: inline-block; background: #fff; border-radius: .5rem; box-shadow: 0 .25rem 1.25rem rgba(0,0,0,.12);
  padding: 4mm; zoom: .55; max-width: none;
}
.ppreview__paper--land { zoom: .5; }

/* ---------- printed pages (used in preview and print) ---------- */
#printroot { display: none; }
.pp {
  box-sizing: border-box; background: #fff; color: #222; font-size: 11pt; line-height: 1.25;
  display: flex; flex-direction: column; overflow: hidden; position: relative;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.pp .avatar { --size: 22mm; box-shadow: none; }
.pp-head { display: flex; align-items: center; gap: 5mm; padding-bottom: 3mm; border-bottom: 1.5mm solid var(--kid); }
.pp-headtext { flex: 1; }
.pp-head h1 { margin: 0; font-size: 26pt; line-height: 1.1; }
.pp-head p { margin: 1mm 0 0; font-size: 13pt; color: #555; }
.pp-logo { width: 16mm; height: 16mm; }
.pp-logo svg { width: 100%; height: 100%; }
.pp-table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; margin-top: 4mm; }
.pp-table th, .pp-table td { border-bottom: .3mm solid #d4d4d4; padding: 0 1.5mm; height: 10mm; }
.pp-table thead th { height: 11mm; background: var(--kid); font-size: 11pt; text-align: center; border-bottom: 0; }
.pp-table thead th:first-child { width: 36%; background: transparent; }
.pp-table thead th:nth-child(2) { border-radius: 3mm 0 0 3mm; }
.pp-table thead th:last-child { border-radius: 0 3mm 3mm 0; }
.pp-table thead th span { display: block; font-weight: 800; }
.pp-table thead th small { display: block; font-size: 9pt; color: #555; }
.pp-sec th { text-align: left; font-size: 12.5pt; padding-top: 3mm; height: 9mm; border-bottom: .6mm solid var(--kid-deep); }
.pp-task { text-align: left; font-weight: 600; font-size: 11pt; }
.pp-task .pp-emoji { font-size: 15pt; margin-right: 2mm; vertical-align: middle; }
.pp-task small { color: #C89220; font-size: 8.5pt; white-space: nowrap; }
.pp-on { text-align: center; color: var(--kid-deep); }
.pp-tick { width: 7mm; height: 7mm; vertical-align: middle; }
.pp-off { background: repeating-linear-gradient(135deg, #f1f1f1 0 1.2mm, #fff 1.2mm 2.6mm); }
.pp-none { text-align: center; color: #777; height: 20mm; }
.pp--compact .pp-table th, .pp--compact .pp-table td { height: 8mm; }
.pp--compact .pp-tick { width: 6mm; height: 6mm; }
.pp--tiny .pp-table th, .pp--tiny .pp-table td { height: 6.6mm; font-size: 9.5pt; }
.pp--tiny .pp-sec th { height: 7mm; padding-top: 1.5mm; font-size: 11pt; }
.pp--tiny .pp-tick { width: 5mm; height: 5mm; }
.pp--tiny .pp-task .pp-emoji { font-size: 12pt; }
.pp-foot { margin-top: auto; padding-top: 4mm; display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 4mm; }
.pp-box { border: .4mm solid #bbb; border-radius: 3mm; padding: 2.5mm 3mm; display: flex; flex-direction: column; gap: 1mm; }
.pp-box span { font-size: 9.5pt; color: #666; font-weight: 700; }
.pp-box i { display: block; height: 8mm; }
.pp-box b { font-size: 11pt; }
.pp-howto { text-align: center; color: #777; font-size: 10pt; margin: 2.5mm 0 0; }
.pp--ink .pp-table thead th, .pp--ink .pp-off { background: none; }
.pp--ink .pp-table thead th { border-bottom: .5mm solid #999; }
.pp--ink .pp-head, .pp--ink .pp-sec th { border-bottom-color: #999; }
.pp--ink .pp-on { color: #777; }

/* certificate */
.pp--cert { padding: 0; }
.pc-frame {
  flex: 1; margin: 2mm; border: 3mm solid var(--kid-deep); border-radius: 8mm; position: relative;
  outline: .8mm dashed var(--kid-deep); outline-offset: -7mm;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 10mm 16mm;
  background: radial-gradient(ellipse at 50% 0, var(--kid) 0, #fff 60%);
}
.pc-stars span { position: absolute; color: #F6C453; font-size: 15pt; }
.pc-kicker { margin: 0; font-size: 15pt; font-weight: 800; letter-spacing: .25em; text-transform: uppercase; color: var(--kid-deep); }
.pc-title { margin: 1mm 0 3mm; font-size: 38pt; line-height: 1.05; }
.pc-to { margin: 0; font-size: 13pt; color: #555; }
.pc-name { margin: 1mm 0 2mm; font-size: 44pt; font-weight: 900; line-height: 1.1; padding: 0 10mm 1mm; border-bottom: .6mm solid #bbb; }
.pc-badge svg { width: 38mm; height: 42mm; }
.pc-emoji { font-size: 46pt; line-height: 1.2; }
.pc-reason { margin: 1mm 0 0; font-size: 17pt; font-weight: 700; max-width: 80%; }
.pc-sign { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12mm; align-items: end; width: 100%; margin-top: 6mm; }
.pc-sign i { display: block; border-bottom: .4mm solid #555; height: 8mm; }
.pc-sign span { display: block; font-size: 10pt; color: #555; margin-top: 1.5mm; }
.pc-buddy .avatar { --size: 20mm; }
.pp--ink .pc-frame { background: #fff; border-color: #999; outline-color: #bbb; }
.pp--ink .pc-kicker { color: #666; }

@media print {
  html.is-printing body > *:not(#printroot) { display: none !important; }
  html.is-printing, html.is-printing body { background: #fff !important; }
  html.is-printing #printroot { display: block; }
  #printroot .pp { break-after: page; page-break-after: always; }
  #printroot .pp:last-child { break-after: auto; page-break-after: auto; }
}

@media (max-width: 760px) {
  .sumtiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ppreview__paper { zoom: .4; }
  .ppreview__paper--land { zoom: .28; }
}
@media (max-width: 440px) {
  .ltgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ppreview__paper { zoom: .33; }
  .ppreview__paper--land { zoom: .23; }
  .hlog__time { min-width: 0; }
}
