/*
 * Stage 5 P8: styles for the Desk tools — the hub, the free-days / D&D and CBM
 * calculators, the compact tools strip, and the `:::tool` card inside articles.
 *
 * Uses the shared design tokens (tokens.css) only. No browser-default widgets:
 * dates and selects are branded by datepicker.js / selectpicker.js; number
 * fields here get the same border, radius and focus ring as the rest of the
 * site. Timeline segments always carry a text legend, so state is never
 * conveyed by colour alone.
 */

/* ---------------------------------------------------------------- tools hub */
.p8-tools-grid {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}
.p8-tool-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.4rem 1.35rem 1.3rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  box-shadow: var(--shadow-1);
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}
.p8-tool-card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); border-color: var(--color-border-strong); }
.p8-tool-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  color: var(--color-secondary);
  background: var(--status-active-bg);
}
.p8-tool-card h3 { margin: 0.2rem 0 0; font-size: 1.15rem; }
.p8-tool-card h3 a { color: var(--color-text); text-decoration: none; }
.p8-tool-card h3 a:hover { color: var(--color-link); }
.p8-tool-card p { margin: 0; color: var(--color-text-tertiary); line-height: 1.55; }
.p8-tool-open {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--color-link);
  text-decoration: none;
}
.p8-tool-open:hover { color: var(--color-link-hover); }
.p8-tool-open svg { transition: transform 0.18s ease; }
.p8-tool-open:hover svg { transform: translateX(3px); }

.p8-notes { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.p8-note {
  padding: 1.3rem 1.4rem;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-surface-alt);
}
.p8-note h3 { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.5rem; font-size: 1.02rem; }
.p8-note h3 svg { color: var(--color-secondary); }
.p8-note p { margin: 0; line-height: 1.6; color: var(--color-text-tertiary); }
.p8-note .btn { margin-top: 0.9rem; }
.p8-note--accent { background: var(--status-approved-bg); border-color: transparent; }

/* -------------------------------------------------------------- calculators */
.p8-calc-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: start;
}
@media (max-width: 900px) { .p8-calc-grid { grid-template-columns: minmax(0, 1fr); } }

.p8-form {
  padding: 1.5rem 1.5rem 1.6rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: var(--shadow-1);
}
.p8-form-title { display: flex; align-items: center; gap: 0.55rem; margin: 0 0 1.1rem; font-size: 1.2rem; }
.p8-form-title svg { color: var(--color-secondary); }
.p8-fieldset { border: 0; margin: 0 0 1.2rem; padding: 0; min-width: 0; }
.p8-fieldset > legend { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.5rem; padding: 0; }
.p8-row { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1rem; }
.p8-row--unit { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 480px) { .p8-row { grid-template-columns: minmax(0, 1fr); } }

.p8-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.p8-field > span { font-weight: 600; font-size: 0.9rem; }
.p8-hint { color: var(--color-text-tertiary); font-size: 0.82rem; line-height: 1.45; margin: 0 0 0.35rem; }

.p8-form input[type="number"],
.p8-form input[type="text"] {
  width: 100%;
  min-width: 0;
  padding: 0.62rem 0.7rem;
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-input);
  border-radius: 9px;
}
.p8-form input[type="number"]:focus-visible { outline: 3px solid var(--color-focus-ring); outline-offset: 1px; border-color: var(--color-focus); }
.p8-form input::placeholder { color: var(--color-text-tertiary); opacity: 1; }

.p8-radio-cards { display: grid; gap: 0.6rem; }
.p8-radio { display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.85rem 0.95rem; border: 1px solid var(--color-border-input); border-radius: 11px; cursor: pointer; background: var(--color-surface); }
.p8-radio:hover { border-color: var(--color-focus); }
.p8-radio:has(input:checked) { border-color: var(--color-secondary); background: var(--status-active-bg); }
.p8-radio:has(input:focus-visible) { outline: 3px solid var(--color-focus-ring); outline-offset: 1px; }
.p8-radio input { margin-top: 0.2rem; accent-color: var(--color-secondary); }
.p8-radio span { display: flex; flex-direction: column; gap: 0.15rem; }
.p8-radio strong { font-size: 0.95rem; }
.p8-radio small { color: var(--color-text-tertiary); font-size: 0.82rem; }

.p8-check-label { display: flex; align-items: flex-start; gap: 0.65rem; padding: 0.8rem 0.9rem; border: 1px solid var(--color-border); border-radius: 11px; background: var(--color-surface-alt); cursor: pointer; }
.p8-check-label input { margin-top: 0.2rem; accent-color: var(--color-secondary); }
.p8-check-label span { display: flex; flex-direction: column; gap: 0.15rem; }
.p8-check-label small { color: var(--color-text-tertiary); font-size: 0.82rem; line-height: 1.45; }
.p8-check { margin-bottom: 1.2rem; }

.p8-example { display: inline-block; margin-top: 0.15rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--status-attention-bg); color: var(--status-attention-text); font-size: 0.78rem; font-weight: 600; }
.p8-tier-head, .p8-tier { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
.p8-tier-head { margin: 0.4rem 0 0.3rem; font-size: 0.76rem; color: var(--color-text-tertiary); }
.p8-tier { margin-bottom: 0.5rem; }

.p8-line-head, .p8-line { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.45rem; }
.p8-line-head { margin-bottom: 0.35rem; font-size: 0.75rem; color: var(--color-text-tertiary); }
.p8-line { margin-bottom: 0.45rem; }
@media (max-width: 560px) {
  .p8-line-head { display: none; }
  .p8-line { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; padding-bottom: 0.5rem; border-bottom: 1px dashed var(--color-border); }
}

.p8-submit { width: 100%; justify-content: center; }
.p8-submit svg { margin-right: 0.4rem; }

/* ----------------------------------------------------------------- results */
.p8-results { min-width: 0; }
.p8-state {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 2.2rem 1.6rem;
  text-align: center;
  align-items: center;
  border: 1px dashed var(--color-border-strong);
  border-radius: 16px;
  background: var(--color-surface-alt);
}
.p8-state-ico { display: inline-flex; width: 54px; height: 54px; align-items: center; justify-content: center; border-radius: 50%; background: var(--color-surface); color: var(--color-secondary); }
.p8-state h2 { margin: 0.3rem 0 0; font-size: 1.1rem; }
.p8-state p { margin: 0; color: var(--color-text-tertiary); max-width: 34ch; }
.p8-state--error { border-style: solid; border-color: var(--status-error-text); background: var(--status-error-bg); }
.p8-state--error .p8-state-ico { color: var(--status-error-text); }

.p8-result {
  padding: 1.5rem 1.5rem 1.6rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: var(--shadow-1);
}
.p8-result-title { margin: 0 0 1rem; font-size: 1.15rem; }
.p8-figures { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin-bottom: 1rem; }
.p8-figure { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.85rem 0.95rem; border-radius: 12px; background: var(--color-surface-alt); border: 1px solid var(--color-border); }
.p8-figure-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-text-tertiary); }
.p8-figure strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; color: var(--color-text); }
.p8-figure small { color: var(--color-text-tertiary); font-size: 0.8rem; }
.p8-figure--total { background: var(--pm-navy); border-color: var(--pm-navy); }
.p8-figure--total .p8-figure-label { color: var(--pm-on-navy-muted); }
.p8-figure--total strong { color: var(--pm-white); }
.p8-figure--total small { color: var(--pm-on-navy-muted); }

.p8-badge { display: inline-flex; align-items: center; gap: 0.45rem; margin: 0 0 1rem; padding: 0.5rem 0.8rem; border-radius: 10px; background: var(--status-active-bg); color: var(--status-active-text); font-size: 0.88rem; line-height: 1.45; }
.p8-badge svg { flex: none; }

.p8-sub { margin: 1.2rem 0 0.6rem; font-size: 1rem; }
.p8-bar { display: flex; width: 100%; height: 22px; border-radius: 999px; overflow: hidden; background: var(--color-surface-alt); border: 1px solid var(--color-border); }
.p8-seg { display: block; height: 100%; min-width: 2px; }
.p8-seg--free { background: var(--pm-beryl); }
.p8-seg--tier1 { background: var(--pm-picton); }
.p8-seg--tier2 { background: var(--pm-cornflower); }
.p8-seg--tier3 { background: var(--pm-violet); }
.p8-seg--uncovered { background: var(--pm-navy-20); }
.p8-legend { list-style: none; margin: 0.7rem 0 0; padding: 0; display: grid; gap: 0.35rem; font-size: 0.85rem; color: var(--color-text-tertiary); }
.p8-legend li { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.p8-dot { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.p8-dot--free { background: var(--pm-beryl); }
.p8-dot--tier1 { background: var(--pm-picton); }
.p8-dot--tier2 { background: var(--pm-cornflower); }
.p8-dot--tier3 { background: var(--pm-violet); }
.p8-dot--uncovered { background: var(--pm-navy-20); }

.p8-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.p8-table th, .p8-table td { padding: 0.55rem 0.6rem; text-align: left; border-bottom: 1px solid var(--color-border); }
.p8-table thead th { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-text-tertiary); }
.p8-table tbody th { font-weight: 600; }
.p8-table-total th, .p8-table-total td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--color-border-strong); }
.p8-pill { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.p8-pill--ok { background: var(--status-success-bg); color: var(--status-success-text); }
.p8-pill--no { background: var(--status-neutral-bg); color: var(--status-neutral-text); }

.p8-warn, .p8-indicative { display: flex; align-items: flex-start; gap: 0.45rem; margin: 1rem 0 0; padding: 0.7rem 0.85rem; border-radius: 10px; font-size: 0.86rem; line-height: 1.5; }
.p8-warn { background: var(--status-attention-bg); color: var(--status-attention-text); }
.p8-indicative { background: var(--color-surface-alt); color: var(--color-text-tertiary); }
.p8-warn svg, .p8-indicative svg { flex: none; margin-top: 0.1rem; }
.p8-quote { margin: 1.1rem 0 0; }
.p8-print-head { display: none; }

/* ------------------------------------------------------- compact tools strip */
.p8-tools-row ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.p8-tools-row a { display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.85rem 0.95rem; border: 1px solid var(--color-border); border-radius: 12px; background: var(--color-surface); text-decoration: none; color: var(--color-text); transition: border-color 0.18s ease, box-shadow 0.18s ease; }
.p8-tools-row a:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-1); }
.p8-row-ico { display: inline-flex; width: 34px; height: 34px; flex: none; align-items: center; justify-content: center; border-radius: 9px; background: var(--status-active-bg); color: var(--color-secondary); }
.p8-tools-row strong { display: block; font-size: 0.95rem; }
.p8-tools-row small { display: block; color: var(--color-text-tertiary); font-size: 0.82rem; line-height: 1.45; margin-top: 0.1rem; }

/* ------------------------------------------------ `:::tool` card in articles */
.pmb-tool {
  margin: 1.5rem 0;
  padding: 1.2rem 1.3rem;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-secondary);
  border-radius: 12px;
  background: var(--color-surface-alt);
}
.pmb-tool-title { margin: 0 0 0.3rem; font-weight: 700; font-size: 1.05rem; }
.pmb-tool-line { margin: 0 0 0.5rem; color: var(--color-text-tertiary); line-height: 1.55; }
.pmb-tool-note { margin: 0 0 0.9rem; font-size: 0.82rem; color: var(--color-text-tertiary); }
.pmb-tool-link { display: inline-block; font-weight: 600; color: var(--color-link); }
.pmb-tool-bn { display: none; }
html[lang="bn"] .pmb-tool-bn { display: block; }
html[lang="bn"] a.pmb-tool-link.pmb-tool-bn { display: inline-block; }
html[lang="bn"] .pmb-tool-en { display: none; }

/* -------------------------------------------------------------- print (A4) */
@media print {
  .p8-form, .pm-page-hero, .pm-crumbs, nav, footer, .skip-link { display: none !important; }
  .p8-calc-grid { display: block; }
  .p8-result { box-shadow: none; border: 1px solid #999; page-break-inside: avoid; }
  .p8-print-head { display: block; font-size: 1.05rem; font-weight: 700; color: #123b5d; border-bottom: 2px solid #123b5d; padding-bottom: 0.4rem; margin-bottom: 0.8rem; }
  .p8-quote { display: none; }
  .p8-figure--total { background: #eee; border-color: #999; }
  .p8-figure--total .p8-figure-label { color: #333; }
  .p8-figure--total strong { color: #000; }
}
