/* =====================================================================
   My study (views/studylog.js): today against the daily goal, the last
   14 days, study packs and the daily log. It is a reading screen
   (body.news-mode, news.css palette); one colour per kind of study.
   ===================================================================== */

body.news-mode {
  --st-read: var(--brand);
  --st-study: #a78bfa;
  --st-words: #2dd4bf;
  --st-listen: #60a5fa;
}
[data-theme="light"] body.news-mode {
  --st-study: #7c3aed;
  --st-words: #0d9488;
  --st-listen: #2563eb;
}
.st-k-read { --c: var(--st-read); }
.st-k-study { --c: var(--st-study); }
.st-k-words { --c: var(--st-words); }
.st-k-listen { --c: var(--st-listen); }

/* ---------- layout: one column on phones (today, 14 days, packs, log); two from 1000px ---------- */
.st-page { padding-top: 16px; }
.st-cols { display: grid; gap: 22px; }
.st-main, .st-side { display: contents; }
.st-s-today { order: 1; }
.st-s-chart { order: 2; }
.st-s-packs { order: 3; }
.st-s-log { order: 4; }
.st-sec { min-width: 0; }
/* the note on the right goes under the heading when both don't fit (e.g. the week totals on a phone) */
.st-sh { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin: 0 2px 10px; }
.st-sh h2 { font: 800 13px/1 var(--font); letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); white-space: nowrap; }
.st-sh .x { min-width: 0; font-size: 12.5px; font-weight: 700; color: var(--text-2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-more { margin: 2px auto 0; display: flex; }
.st-foot { margin: 26px 4px 0; font-size: 12.5px; line-height: 1.55; color: var(--text-3); text-align: center; text-wrap: pretty; }

/* ---------- today ---------- */
.st-today { display: grid; gap: 16px; }
.st-today-top { display: flex; align-items: center; gap: 18px; }
.st-ring { position: relative; flex: none; width: 112px; height: 112px; }
.st-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.st-ring circle { fill: none; stroke-width: 11; }
.st-ring .trk { stroke: var(--surface-3); }
.st-ring .fg { stroke: var(--brand); stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.2, .8, .2, 1), stroke .3s; }
.st-ring.met .fg { stroke: var(--ok); }
.st-ring .c { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.st-ring .v { font: 900 34px/1 var(--serif); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.st-ring .l { margin-top: 4px; font-size: 11px; font-weight: 750; color: var(--text-3); }
.st-ring.met .v { color: var(--ok); }
.st-big { font: 800 21px/1.2 var(--serif); letter-spacing: -.01em; }
.st-status { margin-top: 4px; font-size: 13.5px; line-height: 1.4; color: var(--text-2); }
.st-streak { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 28px; margin-top: 10px; padding: 4px 11px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 12.5px; font-weight: 800; line-height: 1.25; }
.st-streak svg { flex: none; width: 15px; height: 15px; }
.st-streak.off { background: var(--surface-2); color: var(--text-2); }
.st-kinds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.st-kind { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); }
.st-kind .dot { flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.st-kind .n { font: 800 16px/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.st-kind .k { margin-top: 2px; font-size: 11.5px; font-weight: 700; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-kind.zero .n { color: var(--text-3); }
.st-kind.zero .dot { opacity: .45; }
.st-goalrow .label { margin-bottom: 6px; }
.st-goalrow .seg button { padding: 0 2px; font-variant-numeric: tabular-nums; }

/* ---------- last 14 days: stacked bars, the goal as a dashed line ---------- */
.st-chartcard { display: grid; gap: 14px; }
/* no grid gap: the space between the columns is the buttons' own padding, so every tap picks a day */
.st-chart { --colh: 128px; --labh: 18px; --g: 0; position: relative; display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 0; padding-top: 6px; }
.st-bar { display: flex; flex-direction: column; gap: 5px; min-width: 0; padding: 0 2px; border-radius: 8px; }
.st-col { display: flex; flex-direction: column-reverse; gap: 1px; flex: none; height: var(--colh); overflow: hidden; border-radius: 6px; background: var(--surface-2); transition: background .2s, box-shadow .2s; }
.st-col i { display: block; flex: none; min-height: 3px; background: var(--c); }
.st-bar .dl { flex: none; height: var(--labh); font-size: 10.5px; font-weight: 800; line-height: var(--labh); text-align: center; color: var(--text-3); }
.st-bar.today .dl { color: var(--brand); }
.st-bar.today .st-col { box-shadow: inset 0 0 0 1.5px var(--brand); }
.st-bar.on .st-col { background: var(--surface-3); }
.st-bar.on .dl { color: var(--text); text-decoration: underline 2px var(--brand); text-underline-offset: 3px; }
.st-bar:focus-visible { outline-offset: 1px; }
@media (hover: hover) { .st-bar:hover .st-col { background: var(--surface-3); } }
/* --g: the goal as a share of the column height (set by the view, at most ~0.87) */
.st-goal { position: absolute; left: 0; right: 0; bottom: calc(var(--labh) + 5px + var(--colh) * var(--g)); z-index: 1; border-top: 1.5px dashed var(--line-2); pointer-events: none; }
.st-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; font-weight: 700; color: var(--text-2); }
.st-legend span { display: inline-flex; align-items: center; gap: 6px; }
.st-legend span::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--c); }
/* the goal line's label sits in the legend, not on the bars */
.st-legend .st-lg-goal::before { width: 14px; height: 0; border-radius: 0; border-top: 1.5px dashed var(--line-2); background: none; }
.st-pick { padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- one day (under the chart and in the daily log) ---------- */
.st-day { display: grid; gap: 10px; }
.st-day-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.st-day-h .d { font: 800 17px/1.2 var(--serif); }
.st-day-h .t { flex: none; font: 800 17px/1.2 var(--serif); font-variant-numeric: tabular-nums; color: var(--brand); }
.st-mix { display: flex; gap: 2px; height: 6px; overflow: hidden; border-radius: 99px; }
.st-mix i { flex-basis: 0; min-width: 3px; background: var(--c); }
.st-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.st-tag { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 8px; background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.st-tag::before { content: ""; width: 8px; height: 8px; border-radius: 3px; background: var(--c); }
.st-arts { display: grid; }
.st-art { display: flex; align-items: baseline; gap: 12px; padding: 8px 2px; border-top: 1px solid var(--line); color: inherit; }
.st-art:active { background: var(--surface-2); }
.st-art .ttl { flex: 1; min-width: 0; font: 600 15px/1.35 var(--serif); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.st-art .m { flex: none; font-size: 12.5px; font-weight: 800; color: var(--text-2); font-variant-numeric: tabular-nums; }
.st-counts { font-size: 13px; line-height: 1.5; color: var(--text-2); }
.st-log { display: grid; gap: 10px; }

/* ---------- study packs ---------- */
.st-packs { display: grid; gap: 10px; }
.st-pack { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); color: inherit; transition: transform .12s, border-color .2s; }
.st-pack:active { transform: scale(.985); }
@media (hover: hover) { .st-pack:hover { border-color: var(--line-2); } }
.st-pack .th { flex: none; display: grid; place-items: center; width: 64px; height: 64px; overflow: hidden; border-radius: 13px; background: var(--surface-2); color: var(--text-3); }
.st-pack .th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.st-pack .grow { min-width: 0; }
.st-pack .h { font: 700 15.5px/1.3 var(--serif); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.st-pack .meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.st-pack .meta:empty { display: none; }
.st-pack .when { margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--text-3); }
.st-pack .when.new { color: var(--brand); }
.st-pack > svg { flex: none; width: 18px; height: 18px; color: var(--text-3); }
.st-none { display: flex; align-items: flex-start; gap: 12px; }
.st-none > svg { flex: none; width: 22px; height: 22px; margin-top: 1px; color: var(--st-study); }
.st-none .t-sm { margin-top: 3px; line-height: 1.45; }

/* ---------- wide screens (iPad landscape, desktop): today, chart, log | study packs ---------- */
@media (min-width: 1000px) {
  .st-page { max-width: 1100px; margin: 0 auto; padding-top: 28px; }
  .st-cols { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 0 28px; align-items: start; }
  .st-main, .st-side { display: grid; gap: 22px; align-content: start; min-width: 0; }
  .st-chart { --colh: 168px; }
  .st-bar { padding: 0 3px; }
  .st-kinds { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .st-ring { width: 128px; height: 128px; }
  .st-ring .v { font-size: 38px; }
  .st-big { font-size: 24px; }
  .st-foot { max-width: 720px; margin-left: auto; margin-right: auto; }
}
