/* Program (the weekly planner). Classes are prefixed with pg-; tokens and rules come from app.css. */

.pg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Week navigator: 1..38 in a strip that scrolls sideways */
/* The week's dates and name keep their lines while the weeks are read. */
#week-range:empty::before, #week-label:empty::before { content: "\00a0"; }
.pg-weeks { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pg-step { flex: none; width: 40px; justify-content: center; padding: 0; font-size: 18px; }
.pg-step:disabled { opacity: .4; cursor: default; }
.pg-strip { flex: 1; min-width: 0; min-height: 48px; display: flex; gap: 4px; padding: 4px; border-radius: var(--r-pill); background: var(--surface-sunken); overflow-x: auto; scrollbar-width: none; }
.pg-strip::-webkit-scrollbar { display: none; }
.pg-week { position: relative; flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: none; font: 500 14px/20px var(--font); color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.pg-week:hover { color: var(--ink); background: var(--surface); }
.pg-week.is-active { background: var(--ink); color: var(--on-coach); }
.pg-week.is-now::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; }
.pg-now { flex: none; white-space: nowrap; }

.pg-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 20px; border-radius: var(--r-lg); background: var(--gold-100); font: 500 14px/21px var(--font); }
.pg-note-text { flex: 1 1 240px; }

.pg-meter { height: 6px; border-radius: var(--r-pill); background: var(--surface); overflow: hidden; }
.pg-meter i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--level-accent); transition: width .2s; }

.pg-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.pg-status { color: var(--ink-muted); }
.pg-status:empty { display: none; }
.pg-status.bad { color: var(--danger); }
.pg .seg button[aria-pressed="true"], .pg-dialog .seg button[aria-pressed="true"] { background: var(--surface-raised); }
.pg-dialog .seg { align-self: flex-start; background: var(--surface-sunken); }

/* Lessons view */
.pg-lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 24px; align-items: start; }
.pg-lesson { gap: 12px; }
.pg-lesson-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pg-lesson-name { font: 500 18px/24px var(--font); }
.pg-list { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pg-add { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; min-height: 32px; text-decoration: none; }
.pg-add:hover { text-decoration: underline; }
.pg-empty { align-items: flex-start; }

/* One plan item */
.pg-item { display: flex; align-items: center; gap: 8px; padding: 6px 4px 6px 6px; border-radius: var(--r-md); background: var(--surface); min-width: 0; }
.pg-item[draggable="true"] { cursor: grab; }
.pg-item.is-dragging { opacity: .45; }
.pg-item .plan-title { overflow-wrap: anywhere; }
.pg-item.is-done .plan-title { text-decoration: line-through; color: var(--ink-muted); }
.pg-check { flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--r-md); background: none; display: grid; place-items: center; color: var(--on-coach); }
.pg-check::before { content: ""; grid-area: 1 / 1; width: 22px; height: 22px; border-radius: 6px; box-shadow: inset 0 0 0 2px var(--ink); }
.pg-check svg { grid-area: 1 / 1; position: relative; visibility: hidden; }
.pg-check[aria-checked="true"]::before { background: var(--ink); }
.pg-check[aria-checked="true"] svg { visibility: visible; }
.pg-check:hover::before { box-shadow: inset 0 0 0 2px var(--ink), 0 0 0 4px var(--surface-sunken); }
.pg-more { flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: none; display: grid; place-items: center; color: var(--ink-muted); font: 500 14px/1 var(--font); }
.pg-more:hover, .pg-more[aria-expanded="true"] { background: var(--surface-sunken); color: var(--ink); }

/* Item menu */
.pg { position: relative; }
.pg-menu { position: absolute; z-index: 7; width: 264px; display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: var(--r-lg); background: var(--surface-raised); box-shadow: inset 0 0 0 1px var(--border), 0 10px 30px rgb(40 40 40 / .12); }
.pg-menu .label { padding: 0 8px 4px; }
.pg-menu-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; padding-bottom: 4px; }
.pg-day-pick { height: 36px; padding: 0; border: 0; border-radius: var(--r-md); background: var(--surface); font: 500 12px/18px var(--font); }
.pg-day-pick:hover { background: var(--surface-sunken); }
.pg-day-pick.is-on { background: var(--ink); color: var(--on-coach); }
.pg-menu-item { min-height: 40px; padding: 8px; border: 0; border-radius: var(--r-md); background: none; text-align: left; font: 500 14px/20px var(--font); }
.pg-menu-item:hover { background: var(--surface); }
.pg-menu-item.is-danger { color: var(--danger); font-weight: 800; }
.pg-sep { width: 100%; height: 1px; margin: 4px 0; border: 0; background: var(--border); }

/* Days view */
.pg-days { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 24px; align-items: start; }
.pg-pool { position: sticky; top: 84px; gap: 12px; max-height: calc(100dvh - 240px); overflow-y: auto; }
.pg-day { display: grid; grid-template-columns: 148px minmax(0, 1fr) 36px; gap: 16px; align-items: start; padding: 16px 16px 16px 20px; border-radius: var(--r-lg); background: var(--surface-raised); }
.pg-day.is-today { box-shadow: inset 0 0 0 2px var(--ink); }
.pg-day-name { display: grid; gap: 2px; justify-items: start; }
.pg-day .empty { padding: 7px 0; }
.pg-done { gap: 12px; border-radius: var(--r-lg); padding: 16px 20px; }
[data-drop].is-over { outline: 2px dashed var(--gray-400); outline-offset: -2px; }

/* Dialogs */
.pg-dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 0; border-radius: var(--r-xl); background: var(--surface-raised); color: var(--ink); overflow: hidden; }
.pg-dialog[open] { display: flex; flex-direction: column; }
.pg-dialog.is-wide { width: min(880px, calc(100vw - 32px)); background: var(--surface); }
.pg-dialog::backdrop { background: rgb(40 40 40 / .45); }
.pg-dialog-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 16px 8px 24px; }
.pg-dialog-body { display: flex; flex-direction: column; gap: 16px; padding: 8px 24px 24px; overflow-y: auto; }
.pg-dialog .link { align-self: flex-start; }
.pg-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pg-field .select, .pg-dialog input.select { width: 100%; min-height: 44px; font-weight: 500; }
.pg-dialog:not(.is-wide) .select { background: var(--surface); }
.pg-dialog input.pg-num { width: 88px; }
.pg-current { padding: 12px 16px; border-radius: var(--r-md); background: var(--surface); font: 500 14px/20px var(--font); }
.pg-dialog .lib-row + .lib-row { padding-top: 12px; border-top: 1px solid var(--surface); }
.pg-dialog .pweeks { max-height: none; }
.pg-dialog .row.start { flex: 1 1 240px; min-width: 0; justify-content: flex-end; }
.pg-dialog .row.start .select { flex: 0 1 auto; min-width: 0; }

@media (max-width: 900px) {
  .pg-actions { width: 100%; }
  .pg-actions .btn { margin-left: auto; }
  .pg-now { display: none; }
  .pg-lessons { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .pg-days { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .pg-pool { position: static; max-height: none; }
  .pg-day { grid-template-columns: minmax(0, 1fr) 36px; gap: 8px; padding: 16px; }
  .pg-day-name { grid-column: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-height: 36px; align-content: center; }
  .pg-day-name .link { white-space: nowrap; }
  .pg-day .pg-day-add { grid-column: 2; grid-row: 1; }
  .pg-day .pg-list { grid-column: 1 / -1; grid-row: 2; }
  .pg-bar .grow { display: none; }
  .pg-status { order: 5; width: 100%; }
  .pg .trio { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pg .trio .card { padding: 16px; gap: 8px; border-radius: var(--r-lg); }
  .pg .trio .card:first-child { grid-column: 1 / -1; }
  .pg .trio .mid { font-size: 28px; line-height: 34px; }
  .pg-bar .btn { margin-left: auto; }
  .pg-dialog, .pg-dialog.is-wide { width: 100vw; max-width: 100vw; max-height: calc(100dvh - 24px); margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .pg-dialog-head { padding: 16px 8px 8px 16px; }
  .pg-dialog-body { padding: 8px 16px 24px; }
}

/* Days: seven rows of one card instead of seven cards. */
.pg-days > .stack { gap: 0; }
.pg-day { border-radius: 0; }
.pg-day + .pg-day { border-top: 1px solid var(--border); }
.pg-day:first-child { border-radius: var(--r-xl) var(--r-xl) 0 0; }
.pg-day:nth-last-child(2) { border-radius: 0 0 var(--r-xl) var(--r-xl); }
.pg-day.is-today { box-shadow: none; }
.pg-day-name strong { font-weight: 500; }
.pg-day.is-today .pg-day-name strong { font-weight: 800; }
.pg-days > .stack > .pg-done { margin-top: 24px; border-radius: var(--r-xl); }
.pg-pool { border-radius: var(--r-xl); }
