/* ============================================================
   شمس حلب - Shams Halab
   Shared chrome for the tools hub and the 16 tool pages
   Logical properties only — this stylesheet must stay RTL-safe.
   ============================================================ */

/* The tool-page header moved to .page-head in site.css — a header the whole
   site shares, rather than a banner only these pages knew how to draw. */

/* ── Hub ──────────────────────────────────── */
.hub-group {
  margin-bottom: var(--space-12);
}

.hub-group-title {
  font-size: var(--text-xl);
  font-weight: 800;
  margin-bottom: var(--space-2);
}

.hub-group-sub {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
}

.tool-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .tool-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1000px) {
  .tool-grid { grid-template-columns: repeat(3, 1fr); }
}

.tool-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text);
  text-decoration: none;
  position: relative;
  box-shadow: var(--shadow-xs);
  /* Only transform and box-shadow — cheap on a low-end Android. */
  transition: transform var(--transition-fast), box-shadow var(--transition-base),
              border-color var(--transition-fast);
}

.tool-card:hover {
  border-color: var(--brand-ink);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.tool-card:active {
  transform: translateY(0) scale(0.99);
  box-shadow: var(--shadow-xs);
}

.tool-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand-ink);
  transition: background-color var(--transition-fast);
}

.tool-card:hover .tool-card-icon {
  background: var(--brand-ink);
  color: var(--brand-contrast);
}

.tool-card-body {
  min-width: 0;
}

.tool-card-title {
  display: block;
  font-size: var(--text-base);
  font-weight: 700;
  line-height: var(--leading-snug);
  margin-bottom: 4px;
}

.tool-card-desc {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-snug);
}

/* The chevron only announces itself on hover — a permanent arrow on
   every card is visual noise at this density. */
.tool-card-go {
  color: var(--line-strong);
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.tool-card:hover .tool-card-go {
  color: var(--brand-ink);
  transform: translateX(-3px);
}

.tool-card-badge {
  position: absolute;
  inset-block-start: calc(var(--space-3) * -1);
  inset-inline-end: var(--space-4);
  padding: 3px var(--space-3);
  border-radius: var(--radius-full);
  background: var(--ok-bg);
  color: var(--ok);
  font-size: var(--text-xs);
  font-weight: 800;
  border: 1px solid var(--ok);
}

.hub-group-head {
  margin-bottom: var(--space-5);
}

/* ── Onboarding ───────────────────────────────────────────── */
.onboard {
  position: relative;
  padding: var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-10);
}

.onboard-close {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-end: var(--space-2);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.onboard-close:hover { background: var(--surface-sunken); color: var(--text); }

.onboard-title {
  font-size: var(--text-lg);
  font-weight: 800;
  margin-bottom: var(--space-5);
  padding-inline-end: var(--space-12);
}

.onboard-steps {
  list-style: none;
  display: grid;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
}

@media (min-width: 800px) {
  .onboard-steps { grid-template-columns: repeat(3, 1fr); }
}

.onboard-steps li {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.onboard-num {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--brand-ink);
  color: var(--brand-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: var(--text-sm);
}

.onboard-steps strong {
  display: block;
  font-size: var(--text-base);
  margin-bottom: 2px;
}

.onboard-steps a {
  color: var(--brand-ink);
  font-weight: 700;
}

.onboard-steps span span {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-snug);
}

/* A button that reads as a link, used inside running text. Deliberately
   below the 48px target: WCAG 2.5.8 exempts targets inline in a sentence,
   and forcing one to 48px would break the paragraph around it. */
.link-btn {
  border: none;
  background: none;
  /* Vertical padding only: it grows the tap target to 44px without moving
     the sentence this button sits inside. tools.css loads after site.css,
     so the padding has to be restated here rather than inherited. */
  padding: 12px 0;
  font: inherit;
  color: var(--brand-ink);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* ── Profile strip ────────────────────────── */
.profile-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius);
  background: var(--muted);
  border: 1px solid var(--border);
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
}

.profile-bar-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  flex: 1;
  min-width: 0;
}

.profile-bar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand-ink);
  flex: 0 0 auto;
}

.profile-bar-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.profile-fact strong {
  font-variant-numeric: tabular-nums;
}

/* ── Verdict card ─────────────────────────── */
.verdict {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  padding: var(--space-5) var(--space-6);
  border-radius: var(--radius);
  margin-bottom: var(--space-6);
  background: var(--ok-bg);
  color: var(--ok);
}

.verdict--warning { background: var(--warn-bg); color: var(--warn); }
.verdict--danger  { background: var(--bad-bg);  color: var(--bad); }
.verdict--info    { background: var(--tile);    color: var(--ink); }

.verdict-mark {
  flex: 0 0 auto;
  font-size: var(--text-2xl);
  line-height: 1;
}

.verdict-title {
  font-size: var(--text-lg);
  font-weight: 800;
  margin-bottom: var(--space-2);
}

.verdict-body {
  font-size: var(--text-sm);
  line-height: 1.9;
}

/* ── Flags ────────────────────────────────── */
.flag-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.flag {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  border-inline-start: 4px solid var(--border);
  background: var(--background);
  font-size: var(--text-sm);
  line-height: 1.8;
}

.flag--danger  { border-inline-start-color: var(--bad);  background: var(--bad-bg); }
.flag--warning { border-inline-start-color: var(--warn); background: var(--warn-bg); }
.flag--info    { border-inline-start-color: var(--ink-soft); background: var(--tile); }

.flag-mark {
  flex: 0 0 auto;
  font-weight: 800;
}

/* ── Appliance picker ─────────────────────── */
.appliance-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.appliance-row {
  display: grid;
  grid-template-columns: 1fr 92px 92px auto;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
}

.appliance-row.is-on {
  border-color: var(--primary);
  background: var(--app-card);
}

.appliance-name {
  font-weight: 600;
  font-size: var(--text-sm);
}

.appliance-meta {
  display: block;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  font-weight: 400;
  margin-top: 2px;
}

.appliance-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.appliance-field label {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.appliance-field input {
  width: 100%;
  min-height: var(--hit);
  padding: var(--space-2);
  text-align: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-arabic);
  font-size: max(16px, var(--text-sm));
  background: var(--card);
  color: var(--foreground);
}

.appliance-toggle {
  min-width: 48px;
  min-height: var(--hit);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--muted-foreground);
}

.appliance-row.is-on .appliance-toggle {
  background: var(--success);
  border-color: var(--success);
  /* Not #FFFFFF: --success is a light green at night, and a white tick on it
     measured 1.54:1. The paired token flips with the ground. */
  color: var(--success-foreground);
}

@media (max-width: 768px) {
  .appliance-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name toggle"
      "fields fields";
  }
  .appliance-name  { grid-area: name; }
  .appliance-toggle { grid-area: toggle; }
  .appliance-fields {
    grid-area: fields;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
  }
}

.appliance-fields {
  display: contents;
}

@media (max-width: 768px) {
  .appliance-fields { display: grid; }
}

/* ── Comparison columns (quotes) ──────────── */
.compare-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}

@media (min-width: 800px) {
  .compare-grid { grid-template-columns: repeat(3, 1fr); }
}

.quote-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  background: var(--card);
}

.quote-card.is-best {
  border-color: var(--success);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12);
}

.quote-card-title {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

/* ── Printable checklist ──────────────────── */
.checklist {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.checklist-section {
  font-size: var(--text-lg);
  font-weight: 700;
  margin: var(--space-6) 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--border);
}

.checklist-item {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: var(--text-sm);
  line-height: 1.8;
}

.checklist-box {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 2px solid var(--muted-foreground);
  border-radius: 4px;
  margin-top: 2px;
}

.checklist-why {
  display: block;
  color: var(--muted-foreground);
  font-size: var(--text-xs);
  margin-top: 4px;
}

/* ── Small stat row ───────────────────────── */
.mini-stats {
  display: grid;
  gap: var(--s-3);
  margin-bottom: var(--s-6);
}

/* Sizes to its content instead of demanding four columns wherever it
   lands — the sticky results column is 380px wide, not a full page. */
.mini-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* On the system now: a hairline instead of a 2px rule, semibold instead
   of 800, and figures set left rather than centred — centred numbers in a
   row of cards give the eye no common edge to compare along. */
.mini-stat {
  padding: var(--s-4);
  border: var(--hairline);
  border-radius: var(--r-card);
  background: var(--app-card);
  box-shadow: var(--lift-1);
  text-align: start;
}

.mini-stat-label {
  font-size: var(--t-caption);
  font-weight: var(--w-body);
  color: var(--ink-soft);
  margin-bottom: var(--s-1);
}

.mini-stat-value {
  font-size: var(--t-title);
  font-weight: var(--w-strong);
  letter-spacing: -0.6px;
  font-variant-numeric: tabular-nums;
  line-height: var(--lh-tight);
  color: var(--ink);
}

.mini-stat-sub {
  font-size: var(--t-caption);
  color: var(--ink-soft);
  margin-top: var(--s-1);
}

/* ── Assumption note ──────────────────────── */
.assumption {
  padding: var(--space-4) var(--space-5);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: var(--text-xs);
  line-height: 1.9;
}

/* ── Chart box ────────────────────────────── */
.chart-box {
  position: relative;
  height: 320px;
  margin-bottom: var(--space-4);
}

@media (max-width: 768px) {
  .chart-box { height: 260px; }
}

/* ── Mobile ───────────────────────────────── */
@media (max-width: 768px) {
  .tool-card,
  .appliance-toggle {
    transition: none;
  }

  .tool-card:hover {
    transform: none;
  }

  .verdict {
    flex-direction: column;
    gap: var(--space-2);
  }
}


/* ============================================================
   Shared component blocks, moved here from qisma.css.
   They started life in the القسمة tool but every one of the 16
   tools now uses them, and only qisma.php loads qisma.css —
   a3tal.php's choice cards were rendering completely unstyled.
   ============================================================ */

/* ── Building step: the flat rows ─────────── */
.flat-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.flat-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
}

.flat-row-name {
  border: none;
  background: transparent;
  font-family: var(--font-arabic);
  font-size: max(16px, var(--text-base));
  font-weight: 600;
  color: var(--foreground);
  min-height: var(--hit);
  width: 100%;
  padding: 0 var(--space-2);
}

.flat-row-name:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.flat-row-value {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.flat-row-unit {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  white-space: nowrap;
}

.flat-row[hidden] {
  display: none;
}

/* ── Method cards ─────────────────────────── */
.method-grid {
  display: grid;
  gap: var(--space-3);
}

.method-card {
  text-align: start;
  display: block;
  width: 100%;
  padding: var(--space-5);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  font-family: var(--font-arabic);
  color: var(--foreground);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.method-card:hover {
  border-color: var(--primary);
}

.method-card.is-active {
  border-color: var(--primary);
  box-shadow: var(--shadow-orange);
}

.method-card-title {
  display: block;
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.method-card-desc {
  display: block;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  line-height: 1.7;
}

@media (min-width: 769px) {
  .method-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Allocation table ─────────────────────── */
.alloc-table td.is-numeric,
.alloc-table th.is-numeric {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Flat names are long ("الطابق الثاني — يسار"); without a floor width the
   column collapses and every row becomes three lines tall. The table's own
   container scrolls horizontally instead. */
.alloc-table td:first-child,
.alloc-table th:first-child {
  min-width: 165px;
}

.alloc-flat {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
}

.alloc-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex: 0 0 auto;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.alloc-bonus {
  display: inline-block;
  margin-inline-start: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--ok-bg);
  color: var(--ok);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
}

.alloc-shade {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: var(--text-xs);
  font-weight: 700;
}

/* ── Neighbour agreement ──────────────────── */
.agreement {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);
  background: var(--card);
}

.agreement-head {
  text-align: center;
  border-bottom: 2px solid var(--border);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-5);
}

.agreement-title {
  font-size: var(--text-xl);
  font-weight: 800;
  margin-bottom: var(--space-2);
}

.agreement-meta {
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}

.agreement-terms {
  padding-inline-start: var(--space-5);
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
  line-height: 2;
}

.agreement-signs {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1fr;
}

@media (min-width: 600px) {
  .agreement-signs {
    grid-template-columns: 1fr 1fr;
  }
}

.agreement-sign {
  padding-top: var(--space-6);
  border-top: 1px dashed var(--muted-foreground);
  font-size: var(--text-sm);
}

.agreement-sign-name {
  font-weight: 700;
  margin-bottom: 2px;
}

.agreement-sign-line {
  color: var(--muted-foreground);
}

/* ── Print ────────────────────────────────── */
@media print {
  .page-back,
  .hub-search,
  .profile-bar,
  .no-print {
    display: none !important;
  }

  body { background: #FFFFFF; }

  .card,
  .checklist-item,
  .quote-card {
    border: 1px solid var(--line-strong);
    box-shadow: none;
  }

  .checklist-item,
  .quote-card,
  .mini-stats {
    break-inside: avoid;
  }

  .table-container { overflow: visible !important; }

  .section { padding: 0 !important; }
}

/* The diagnostic's stop state.
   It takes focus so a screen reader lands on it, but it is a container, not a
   control — a 3px focus ring around the whole card reads as an error about the
   error. role="alert" already announces it. And it needs scroll-margin, or
   scrollIntoView tucks its heading under the sticky nav. */
#a3tal-stop {
  scroll-margin-block-start: calc(var(--hit) + var(--s-6));
}
#a3tal-stop:focus { outline: none; }
