/*
 * panel.css — the side panel: reminders (nb-rem-) and Analyze (nb-an-).
 * Built by js/reminders.js and js/analyze.js. Colors come from tokens.css
 * only; shared pieces (buttons, chips, quotes, fields) from components.css.
 */

/* ---------------------------- panel frame -------------------------- */
/* Each tab is a column: a head that stays and a body that scrolls. */
.nb-rem, .nb-an {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0; max-height: 100%;
  color: var(--text);
}
.nb-rem__head, .nb-an__head {
  flex: none;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  padding: 8px 12px 4px 24px; min-height: 60px;
}
.nb-rem__title, .nb-an__title {
  font: 600 22px/1.1 var(--font-display); letter-spacing: -0.01em;
}
.nb-rem__count, .nb-an__count {
  margin-right: auto;
  font: 400 12px/1 var(--font-util); color: var(--text-3);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.nb-rem__body, .nb-an__body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

/* ------------------------------ groups ----------------------------- */
.nb-rem-group__h {
  display: flex; align-items: center; gap: 6px;
  padding: 22px 24px 6px;
  font: italic 500 17px/1.2 var(--font-display);
  color: var(--text-2);
}
.nb-rem-group--overdue .nb-rem-group__h { color: var(--overdue); }
.nb-rem-group--today .nb-rem-group__h { color: var(--today); }
.nb-rem-group--upcoming .nb-rem-group__h { color: var(--upcoming); }
.nb-rem-group__n {
  margin-left: 2px;
  font: normal 400 12px/1 var(--font-util); color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
/* Done is folded away until asked for; its heading is the switch */
.nb-rem-group--done .nb-rem-group__h { padding: 12px 24px 0 16px; }
.nb-rem-group__toggle {
  min-height: var(--tap);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px 0 8px;
  border: 0; border-radius: var(--r-m);
  background: transparent; color: inherit; font: inherit;
  touch-action: manipulation;
}
.nb-rem-group__toggle:hover { background: var(--hover); color: var(--text); }
.nb-rem-group__toggle .nb-icon { color: var(--text-3); }

.nb-rem__clear {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 24px 0;
  font-size: 14px; color: var(--text-2);
}
.nb-rem__clear .nb-icon { color: var(--ok); }
.nb-rem-empty { padding: 28px 24px; max-width: 46ch; }

/* ------------------------------- rows ------------------------------ */
.nb-rem-list { list-style: none; margin: 0; padding: 0; }
.nb-rem-row {
  position: relative;
  display: grid; grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap);
  gap: 0 4px; align-items: start;
  padding: 6px 8px 6px 12px;
}
.nb-rem-row + .nb-rem-row::before {
  content: ""; position: absolute; top: 0; left: 60px; right: 0;
  height: 1px; background: var(--hairline);
}
.nb-rem-row__check {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--on-ink);
  touch-action: manipulation;
}
.nb-rem-row__box {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border: 1.5px solid var(--text-3); border-radius: 50%;
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease);
}
.nb-rem-row__box .nb-icon { opacity: 0; }
.nb-rem-row__check:hover .nb-rem-row__box { border-color: var(--text); background: var(--hover); }
.nb-rem-row__check[aria-checked="true"] .nb-rem-row__box { border-color: var(--ok); background: var(--ok); }
.nb-rem-row__check[aria-checked="true"] .nb-icon { opacity: 1; }

.nb-rem-row__body {
  min-width: 0; padding-block: 11px 8px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
}
.nb-rem-row__text { font: 500 15px/1.35 var(--font-body); overflow-wrap: anywhere; }
.nb-rem-row--done .nb-rem-row__text { color: var(--text-3); text-decoration: line-through; }
.nb-rem-row__meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px;
  /* the whole width: fitted to its content, the negative margin of the note
     button leaves it 8 px short and the title wraps for no reason */
  align-self: stretch; max-width: 100%;
  font: 400 12px/1.3 var(--font-util); color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.nb-rem-row__when { white-space: nowrap; }
.nb-rem-row__note {
  position: relative;
  min-height: 28px; max-width: 100%;
  padding: 0 4px; margin-inline: -4px;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--accent);
  font: inherit; text-align: left; overflow-wrap: anywhere;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px;
  touch-action: manipulation;
}
/* the title is small; its touch target is not */
.nb-rem-row__note::after { content: ""; position: absolute; inset: -8px -4px; }
.nb-rem-row__note:hover { text-decoration-color: currentColor; }
.nb-rem-row__quote { max-width: 100%; }
/* the clamp sits inside the padding, or a third line would show in it */
.nb-rem-row__clamp {
  display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden;
}
/* The picture of handwriting has no background and ink in the colors for white
   paper: it lies on white paper in either theme, or dark ink would vanish on dark. */
.nb-rem-row__thumb, .nb-rem-form__pic {
  display: block; width: auto; height: auto;
  max-width: min(100%, 280px); max-height: 88px;
  border-radius: var(--r-s);
  background: var(--sheet-print);
  box-shadow: 0 0 0 1px var(--hairline-strong);
  object-fit: contain;
}
.nb-rem-row__more { margin-top: 0; }

/* ------------------------------ dialog ----------------------------- */
/* The form is tall for a phone: the dialog keeps to the screen and its body
   scrolls, so Save reminder stays in reach. */
.nb-rem-dialog {
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(var(--nb-vv-h, 100dvh) - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
}
.nb-rem-form { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.nb-rem-form .nb-textarea { min-height: 68px; }
.nb-rem-form .nb-rem-form__details { min-height: var(--tap); }
.nb-rem-form__under {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  min-height: 17px;
}
.nb-rem-form__count {
  margin-left: auto;
  font: 400 12px/1.4 var(--font-util); color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.nb-rem-form__reading {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font: 400 12px/1.4 var(--font-util); color: var(--text-2);
}
.nb-rem-form__pic { max-height: 132px; max-width: 100%; }
.nb-rem-form__src { font: 400 12px/1.3 var(--font-util); color: var(--text-3); overflow-wrap: anywhere; }
.nb-rem-form__picks { display: flex; flex-wrap: wrap; gap: 8px; }
.nb-rem-pick {
  min-height: var(--tap); padding: 0 14px;
  border: 1px solid var(--hairline-strong); border-radius: var(--r-m);
  background: transparent; color: var(--text-2);
  font: 500 13px/1 var(--font-util); white-space: nowrap;
  touch-action: manipulation;
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease);
}
.nb-rem-pick:hover { background: var(--hover); color: var(--text); }
.nb-rem-pick[aria-pressed="true"] {
  border-color: var(--ink); background: var(--accent-wash); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.nb-rem-form__pair .nb-input {
  font: 400 16px/1.35 var(--font-util); font-variant-numeric: tabular-nums;   /* 16px: iOS zooms in for less */
  min-width: 0;
}

/* --------------------------- alert cards --------------------------- */
/* Due reminders, top right of the window, under the top bar and the tool tray
   (--nb-app-stage-top, set on the root by js/app.js, includes the safe area).
   While a software keyboard pans the view, the app moves down by --nb-vv-top
   (css/app.css): the cards follow it, so they stay in the visible part. */
.nb-rem-alerts {
  position: fixed;
  top: calc(var(--nb-app-stage-top, env(safe-area-inset-top, 0px)) + var(--nb-vv-top, 0px) + 12px);
  right: calc(12px + env(safe-area-inset-right, 0px));
  width: min(360px, calc(100vw - 24px));
  /* it starts below the tool tray: its end stays in the window, and above a software keyboard */
  max-height: calc(100% - 24px);
  max-height: calc(100% - var(--nb-app-stage-top, env(safe-area-inset-top, 0px)) - var(--nb-vv-top, 0px) - 24px - env(safe-area-inset-bottom, 0px) - var(--nb-kb, 0px));
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto;
  padding: 2px;                 /* room for the shadow ring inside the scroll box */
  pointer-events: none;
}
/* The open side panel starts where the cards do, on the same side: the cards
   keep to the left of it (392 px wide from 700 px up, css/app.css). A phone
   shows the panel as a full sheet: there the cards go to the bottom. */
@media (min-width: 700px) {
  #nb-app[data-panel="open"] ~ .nb-layer .nb-rem-alerts {
    right: 404px;
    width: min(360px, calc(100vw - 416px));
  }
}
@media (max-width: 699px) {
  #nb-app[data-panel="open"] ~ .nb-layer .nb-rem-alerts {
    top: auto;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px) + var(--nb-kb, 0px));
  }
}
.nb-rem-alerts > * { pointer-events: auto; flex: none; }
.nb-rem-alert {
  display: flex; flex-direction: column; gap: 4px;
  padding: 6px 8px 10px 16px;
  background: var(--raised); color: var(--text);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-float);
}
.nb-rem-alert.is-new { animation: nb-rem-in 220ms var(--ease); }
.nb-rem-alert__top { display: flex; align-items: center; gap: 8px; min-height: var(--tap); }
.nb-rem-alert__top > .nb-icon { color: var(--overdue); }
.nb-rem-alert__close { margin-left: auto; }
.nb-rem-alert__text { font: 600 16px/1.3 var(--font-body); overflow-wrap: anywhere; padding-right: 8px; }
.nb-rem-alert__src { font: 400 12px/1.3 var(--font-util); color: var(--text-3); overflow-wrap: anywhere; padding-right: 8px; }
.nb-rem-alert__acts { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; margin-left: -4px; }
.nb-rem-alert__acts .nb-btn { padding-inline: 12px; font-size: 14px; }
.nb-rem-alerts__more {
  align-self: flex-end;
  min-height: var(--tap); padding: 0 16px;
  border: 0; border-radius: 999px;
  background: var(--raised); color: var(--accent);
  box-shadow: var(--shadow-float);
  font: 500 13px/1 var(--font-util);
  touch-action: manipulation;
}
.nb-rem-alerts__more:hover { background: var(--hover); }
@keyframes nb-rem-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------ analyze ---------------------------- */
.nb-an-state { padding: 28px 24px; gap: 10px; max-width: 46ch; }
.nb-an-state .nb-btn { margin-top: 8px; }
.nb-an-state--error > .nb-icon { color: var(--overdue); }
.nb-an-state__acts { display: flex; flex-wrap: wrap; gap: 8px; }

.nb-an-work {
  display: flex; flex-direction: column; align-items: flex-start; gap: 16px;
  padding: 24px 24px 8px;
}
.nb-an-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.nb-an-step { display: flex; align-items: center; gap: 10px; min-height: 22px; font-size: 15px; color: var(--text-3); }
.nb-an-step > :first-child { flex: none; width: 18px; }
.nb-an-step--done { color: var(--text-2); }
.nb-an-step--done .nb-icon { color: var(--ok); }
.nb-an-step--now { color: var(--text); font-weight: 600; }
.nb-an-step .nb-spin { width: 18px; height: 18px; }
.nb-an-step__dot { height: 18px; display: grid; place-items: center; }
.nb-an-step__dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--hairline-strong); }
.nb-an-work__hint { font-size: 13px; color: var(--text-2); }

.nb-an__note { padding: 0 24px 10px; font-size: 13px; color: var(--text-2); }
.nb-an__summary { padding: 2px 24px 8px; font-size: 15px; line-height: 1.5; max-width: 62ch; }
.nb-an__none { padding: 14px 24px 0; font-size: 15px; color: var(--text-2); }
.nb-an-notice {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 0 24px 10px; padding: 8px 12px;
  border-radius: var(--r-s);
  background: var(--today-wash); color: var(--text);
  font-size: 13px; line-height: 1.4;
}
.nb-an-notice .nb-icon { color: var(--today); margin-top: 1px; }

.nb-an-list { list-style: none; margin: 0; padding: 0; }
.nb-an-sug {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 18px 24px 12px;
}
.nb-an-sug + .nb-an-sug::before {
  content: ""; position: absolute; top: 0; left: 24px; right: 0;
  height: 1px; background: var(--hairline);
}
.nb-an-sug__top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.nb-an-sug__kind {
  font: 500 var(--fs-micro)/1 var(--font-util); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3);
}
.nb-an-sug__title { font: 600 16px/1.3 var(--font-body); overflow-wrap: anywhere; }
.nb-an-sug__detail { font-size: 13px; color: var(--text-2); max-width: 60ch; }
.nb-an-sug .nb-quote { max-width: 100%; }
.nb-an-sug__when {
  font: 400 12px/1.3 var(--font-util); color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.nb-an-sug__acts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding-top: 2px; }
.nb-an-sug__added {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--tap);
  font: 500 13px/1 var(--font-util); color: var(--ok);
}
.nb-an__foot {
  display: flex; justify-content: flex-end;
  margin-top: 6px; padding: 14px 24px 0;
  border-top: 1px solid var(--hairline);
}

/* ------------------------------ narrow ----------------------------- */
/* a phone shows the panel as a full sheet: less air at the sides */
@media (max-width: 480px) {
  .nb-rem__head, .nb-an__head { padding-left: 16px; padding-right: 8px; }
  .nb-rem-group__h { padding-inline: 16px; }
  .nb-rem-group--done .nb-rem-group__h { padding-left: 8px; }
  .nb-rem-row { padding-left: 4px; padding-right: 4px; }
  .nb-rem-row + .nb-rem-row::before { left: 52px; }
  .nb-rem__clear, .nb-rem-empty, .nb-an-state, .nb-an-work { padding-inline: 16px; }
  .nb-an__note, .nb-an__summary, .nb-an__none, .nb-an-sug, .nb-an__foot { padding-inline: 16px; }
  .nb-an-notice { margin-inline: 16px; }
  .nb-an-sug + .nb-an-sug::before { left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .nb-rem-alert.is-new { animation: none; }
}
