/* pra.toolforge.ai — page layer over toolforge-ds.css.
 *
 * Every value here comes from the design system: the 4px scale (4 8 12 16 24 32 48 64),
 * the four border widths (1 hairline, 2 control, 3 rule, 6 accent), and the token colours.
 * No radius, no shadow, one red action (the Search button), one yellow band at the end.
 *
 * Chart ink: bars and heat cells are Ink over a Line or Canvas track. Red stays reserved
 * for the single primary action, so no chart element is red.
 */

/* ---------- page frame ---------- */

.pra-page { gap: 64px; }

.pra-head {
  display: flex; flex-direction: column; gap: 16px;
  border-bottom: 3px solid var(--tf-ink); padding-bottom: 32px;
}
.pra-head__brand { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.pra-mark { width: 48px; height: 38px; display: block; flex: none; }
.pra-mark--foot { width: 48px; height: 38px; }
.pra-wordmark { font-size: 42px; font-weight: 600; letter-spacing: -0.025em; line-height: 1; }
.pra-wordmark--foot { font-size: 30px; color: #fff; }
.pra-crumbs {
  font-family: var(--tf-label); font-weight: 700; font-size: 12px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--tf-muted); margin-left: auto; align-self: flex-end;
}
.pra-eyebrow { color: var(--tf-muted); margin: 0; }
.pra-head h1 { margin: 0; text-wrap: pretty; }
.pra-head p.tf-body { margin: 0; color: var(--tf-ink-60); }

.pra-jump { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pra-jump a {
  font-family: var(--tf-label); font-weight: 700; font-size: 12px; letter-spacing: 0.11em;
  text-transform: uppercase; color: var(--tf-ink-60); text-decoration: none;
  border: 2px solid var(--tf-line); padding: 6px 14px;
}
.pra-jump a:hover { border-color: var(--tf-ink); color: var(--tf-ink); }

/* ---------- section head (spec section 3) ---------- */

.pra-sec-head { display: flex; align-items: baseline; gap: 16px; }
.pra-sec-num {
  font-family: var(--tf-label); font-weight: 700; font-size: 13px; letter-spacing: 0.18em;
  color: var(--tf-muted);
}
.pra-sec-head h2 { margin: 0; }

.pra-two { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }

.pra-panel {
  background: var(--tf-paper); border: 1px solid var(--tf-line); padding: 24px;
  display: flex; flex-direction: column; gap: 16px; min-width: 0;
}
.pra-panel h3 { margin: 0; }
.pra-note { margin: 0; font-size: 13px; line-height: 1.6; color: var(--tf-muted); }

/* ---------- metric tiles ---------- */

.pra-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.pra-tiles .tf-tile__value { display: flex; align-items: baseline; gap: 8px; }
.pra-unit { font-size: 16px; font-weight: 600; letter-spacing: 0; color: var(--tf-muted); }
.tf-tile--ink .pra-unit { color: var(--tf-on-ink-body); }
.tf-tile--yellow .pra-unit { color: var(--tf-on-yellow-body); }

/* ---------- horizontal bars ---------- */

.pra-bars { display: flex; flex-direction: column; gap: 12px; }
.pra-bar { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: baseline; }
.pra-bar__label {
  font-family: var(--tf-label); font-weight: 700; font-size: 12px; letter-spacing: 0.11em;
  text-transform: uppercase; color: var(--tf-ink);
}
.pra-bar__num { font-family: var(--tf-mono); font-size: 14px; color: var(--tf-ink-60); white-space: nowrap; }
.pra-bar__track { grid-column: 1 / -1; height: 8px; background: var(--tf-line); }
.pra-bar__fill { height: 8px; background: var(--tf-ink); }
.pra-bar__fill--ok { background: var(--tf-success); }
.pra-bar__fill--warn { background: var(--tf-yellow); }
.pra-bar__fill--muted { background: var(--tf-muted); }
.pra-bars--topic .pra-bar__label { text-transform: none; font-family: var(--tf-sans);
  font-size: 15px; font-weight: 500; letter-spacing: 0; }

.pra-kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 24px;
          border-top: 1px solid var(--tf-hairline-soft); padding-top: 16px; }
.pra-kv__k { font-family: var(--tf-label); font-weight: 700; font-size: 11px;
             letter-spacing: 0.13em; text-transform: uppercase; color: var(--tf-muted); }
.pra-kv__v { font-family: var(--tf-mono); font-size: 14px; }

/* ---------- monthly columns ---------- */

/* 🔴 The bar height is a percentage of .pra-month__plot, and the plot is the ONLY thing
 * the percentage may resolve against. An earlier version made the bar a direct flex
 * child of the column: its percentage then resolved against the full 220px, the column
 * overflowed by the height of its own labels, and flex-shrink silently squashed the
 * tallest bars — Jan 2022 (49) and Feb 2022 (59) painted the same height. The bar is
 * absolutely positioned inside the plot so nothing can shrink it. done_check asserts
 * the painted heights stay proportional to the counts. */
.pra-months { display: flex; align-items: stretch; gap: 8px; height: 220px; }
.pra-month { flex: 1 1 0; display: grid; grid-template-rows: auto 1fr auto auto; gap: 4px;
             justify-items: center; height: 100%; min-width: 0; }
.pra-month__n { font-family: var(--tf-mono); font-size: 12px; color: var(--tf-ink-60); }
.pra-month__plot { position: relative; width: 100%; min-height: 0; }
/* border-box: the partial-month variant carries a 1px border, and a content-box bar
 * would paint 2px taller than its count. */
.pra-month__bar { position: absolute; left: 0; right: 0; bottom: 0; box-sizing: border-box;
                  background: var(--tf-ink); min-height: 2px; }
.pra-month__bar--partial {
  background: repeating-linear-gradient(135deg, var(--tf-ink) 0 4px, var(--tf-canvas) 4px 8px);
  border: 1px solid var(--tf-ink);
}
.pra-month__lab { font-family: var(--tf-label); font-weight: 700; font-size: 11px;
                  letter-spacing: 0.08em; text-transform: uppercase; color: var(--tf-muted);
                  white-space: nowrap; }
.pra-month__yr { font-family: var(--tf-mono); font-size: 10px; color: var(--tf-day-outside); }

/* ---------- day calendar ---------- */

.pra-cal-wrap { overflow-x: auto; padding-bottom: 8px; }
/* The right padding holds the last month label, which is wider than the 12px column
 * it labels and would otherwise be cut off by the scroll edge. */
.pra-cal { display: flex; flex-direction: column; gap: 4px; width: max-content;
           padding-right: 32px; }
/* One grid column per week, the same 12px+4px rhythm as the day grid below it, so a
 * month label sits over the week its month opens in. Labels overflow their column on
 * purpose — grid items do not clip. */
.pra-cal__months { display: grid; grid-auto-flow: column; grid-auto-columns: 12px;
                   gap: 4px; height: 16px; }
.pra-cal__mlab { font-family: var(--tf-label); font-weight: 700; font-size: 11px;
                 letter-spacing: 0.08em; text-transform: uppercase; color: var(--tf-muted);
                 white-space: nowrap; }
.pra-cal__grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px);
                 gap: 4px; }
.pra-cal__cell { width: 12px; height: 12px; background: var(--tf-line); }
.pra-cal__cell--out { background: transparent; border: 1px solid var(--tf-hairline-soft); }
.pra-cal__cell--l0 { background: var(--tf-line); }
.pra-cal__cell--l1 { background: #BDB8AF; }
.pra-cal__cell--l2 { background: #8A857C; }
.pra-cal__cell--l3 { background: #45423D; }
.pra-cal__cell--l4 { background: var(--tf-ink); }
.pra-cal-key { display: flex; align-items: center; gap: 8px; }
.pra-cal-key span { font-family: var(--tf-label); font-weight: 700; font-size: 11px;
                    letter-spacing: 0.13em; text-transform: uppercase; color: var(--tf-muted); }
.pra-cal-key i { width: 12px; height: 12px; display: block; }

/* ---------- hour columns ---------- */

/* Same plot rule as the month columns above, for the same reason. */
.pra-hours { display: flex; align-items: stretch; gap: 4px; height: 160px; }
.pra-hour { flex: 1 1 0; display: grid; grid-template-rows: 1fr auto; gap: 4px;
            justify-items: center; height: 100%; min-width: 0; }
.pra-hour__plot { position: relative; width: 100%; min-height: 0; }
.pra-hour__bar { position: absolute; left: 0; right: 0; bottom: 0;
                 background: var(--tf-ink); min-height: 2px; }
.pra-hour__bar--off { background: var(--tf-muted); }
/* 🔴 Fixed height, not auto. Only every sixth column carries a label, so an auto row
 * gave the labelled columns a shorter plot than their neighbours and the bar above a
 * label painted short — hour 13 read 120px where its count wanted 131px. */
.pra-hour__lab { font-family: var(--tf-mono); font-size: 10px; color: var(--tf-muted);
                 height: 14px; line-height: 14px; }

/* ---------- tables ---------- */

.pra-table { overflow: hidden; }
.pra-row { display: grid; align-items: center; }
.pra-table--req .pra-row { grid-template-columns: 1.6fr 1.4fr 0.7fr 0.7fr; }
.pra-table--org .pra-row { grid-template-columns: 2.2fr 0.8fr 0.8fr; }
.pra-table--log .pra-row { grid-template-columns: 1.05fr 1.25fr 2.9fr 0.75fr 0.95fr; }
.pra-table .tf-table__row > *,
.pra-table .tf-table__head > * { min-width: 0; }
.pra-cell-id { font-family: var(--tf-mono); font-size: 14px; }
.pra-cell-sub { font-size: 13px; color: var(--tf-muted); word-break: break-word; }
.pra-cell-dim { color: var(--tf-ink-60); }
.pra-num { font-family: var(--tf-mono); font-size: 14px; }

/* ---------- the log ---------- */

.pra-controls { display: flex; flex-direction: column; gap: 16px; }
.pra-search { background: var(--tf-paper); }
.pra-search input { min-width: 0; }
.pra-search__btn {
  font-family: var(--tf-sans); font-size: 14px; font-weight: 600; color: #fff;
  background: var(--tf-ink); border: none; padding: 0 24px; cursor: pointer;
}
.pra-search__btn:hover { background: var(--tf-red); }

.pra-filters { display: flex; flex-wrap: wrap; gap: 16px; }
.pra-fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; position: relative; }
.pra-fld .tf-label { color: var(--tf-ink); }
/* The spec's select glyph: Geist Mono, 14px in from the right edge, click-through. */
.pra-fld::after { content: '▾'; font-family: var(--tf-mono); font-size: 15px;
                  position: absolute; right: 14px; bottom: 12px; pointer-events: none; }
.pra-select {
  font-family: var(--tf-sans); font-size: 15px; padding: 12px 44px 12px 14px;
  border: 2px solid var(--tf-ink); background: var(--tf-paper); color: var(--tf-ink);
  border-radius: 0; outline: none; appearance: none; max-width: 100%;
  background-image: linear-gradient(var(--tf-paper), var(--tf-paper));
}
.pra-select:focus { border-color: var(--tf-red); }

.pra-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pra-chips:empty { display: none; }
.pra-chip { display: inline-flex; align-items: center; gap: 9px; font-size: 14px;
            background: var(--tf-ink); color: #fff; padding: 8px 14px; border: none;
            cursor: pointer; font-family: var(--tf-sans); }
.pra-chip span { font-family: var(--tf-mono); color: var(--tf-yellow); }

/* app.js sets .pra-zebra, because an expanded detail panel is a sibling of the rows and
 * would otherwise flip a :nth-child banding for every row below it. */
.pra-table--log .tf-table__row:nth-child(even) { background: var(--tf-paper); }
.pra-table--log .tf-table__row.pra-zebra { background: var(--tf-row-zebra); }
.pra-logrow { cursor: pointer; }
.pra-logrow:hover { background: var(--tf-canvas); }
.pra-table--log .tf-table__row.pra-logrow--open { background: var(--tf-canvas); }
.pra-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
             overflow: hidden; color: var(--tf-ink-60); font-size: 15px; line-height: 1.5; }
.pra-hit { background: var(--tf-yellow); color: var(--tf-ink); }

.pra-detail { background: var(--tf-canvas); border-bottom: 1px solid var(--tf-hairline-soft);
              padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.pra-detail__text { font-size: 15px; line-height: 1.7; max-width: 620px; margin: 0; }
.pra-detail__grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.pra-detail__k { font-family: var(--tf-label); font-weight: 700; font-size: 11px;
                 letter-spacing: 0.13em; text-transform: uppercase; color: var(--tf-muted); }
.pra-detail__v { font-family: var(--tf-mono); font-size: 14px; word-break: break-word; }
.pra-tags { display: flex; flex-wrap: wrap; gap: 8px; }

.pra-count { font-size: 14px; color: var(--tf-muted); }
.pra-pager { display: flex; flex-wrap: wrap; gap: 8px; }
.pra-empty { padding: 48px 24px; text-align: center; display: flex; flex-direction: column;
             align-items: center; gap: 8px; }
.pra-empty h3 { margin: 0; font-size: 18px; font-weight: 600; }
.pra-empty p { margin: 0; font-size: 14px; line-height: 1.65; color: var(--tf-ink-60);
               max-width: 280px; }

/* ---------- band + footer ---------- */

.tf-band h2 { margin: 0 0 8px; }
.tf-band__sub { margin: 0; }
.pra-dl { background: var(--tf-ink); border-color: var(--tf-ink); color: #fff; }
.pra-dl:hover { background: var(--tf-red); border-color: var(--tf-red); }

/* The pillar strip is a 392px non-wrapping row. Left alone it sets a hard floor wider
 * than a phone and pushes the whole page into horizontal scroll — measured at 390px,
 * where the footer column came out 410px and document scrollWidth read 450. It wraps. */
.pra-foot__brand { display: flex; flex-direction: column; gap: 16px; min-width: 0; max-width: 100%; }
.pra-foot__brand .tf-pillars { flex-wrap: wrap; }
.pra-foot__note { max-width: 420px; display: flex; flex-direction: column; gap: 8px; }
.pra-foot__head { color: var(--tf-muted); margin: 0; }
.pra-foot__note p { margin: 0; font-size: 15px; line-height: 1.65; color: var(--tf-on-ink-body); }

/* ---------- responsive ----------
 * Measured breakpoints, not guesses: the log grid loses its fifth column first, the
 * two-column sections stack next, and the page padding steps down on the 4px scale.
 */

@media (max-width: 1180px) {
  .pra-tiles { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1000px) {
  .pra-page { padding: 48px 24px 64px; gap: 48px; }
  .pra-two { grid-template-columns: 1fr; }
  .pra-detail__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .pra-wordmark { font-size: 30px; }
  .pra-crumbs { margin-left: 0; align-self: auto; width: 100%; }
  .pra-head h1 { font-size: 30px; }
  .tf-h2 { font-size: 24px; }
  .pra-months { height: 180px; gap: 4px; }
  .pra-month__lab, .pra-month__yr, .pra-month__n { font-size: 9px; }

  /* The log stops being a grid and becomes one stacked card per request. */
  #logHead { display: none; }
  .pra-table--log .pra-row { grid-template-columns: 1fr; }
  .pra-table--log .tf-table__row > * { padding: 4px 20px; }
  .pra-table--log .tf-table__row > *:first-child { padding-top: 16px; }
  .pra-table--log .tf-table__row > *:last-child { padding-bottom: 16px; }
  .pra-clamp { -webkit-line-clamp: 3; }
  /* Pager buttons paint 40x38 at the desktop padding — under the 44px tap target the
   * responsive audit warns about. Grow the box, keep the type and border untouched. */
  .tf-page-btn { min-width: 44px; min-height: 44px; padding: 12px 16px; }
  .pra-table--req .pra-row { grid-template-columns: 1.6fr 0.6fr 0.6fr; }
  .pra-table--req .pra-row > :nth-child(2) { display: none; }
}

@media (max-width: 620px) {
  .pra-page { padding: 32px 16px 48px; }
  .pra-tiles { grid-template-columns: 1fr; }
  .pra-panel { padding: 16px; }
  .pra-detail__grid { grid-template-columns: 1fr; }
  .pra-filters { flex-direction: column; }
  .pra-fld, .pra-select { width: 100%; }
  .tf-band { padding: 24px; }
  .tf-band h2 { font-size: 20px; }
  .tf-footer { padding: 32px 16px; }
  .pra-wordmark--foot { font-size: 24px; }
  .pra-foot__brand .tf-pillars { gap: 8px; font-size: 11px; letter-spacing: 0.08em; }
  .pra-hours { gap: 2px; }
  .pra-hour__lab { font-size: 8px; }
}
