/* home page «الرئيسية» (#/home/<place>): owned by the "home" page builder (docs/UI_V4.md).
   Not in the design files: built from the design's dashboard pieces (main column + a narrow card column like the
   insight column, KPI tiles, cards, chips, rings). Everything comes from tokens.css; no shadows. */

/* ---------- Layout: main column (feed) + narrow side column; one column when the page is narrow ---------- */
.home { container-type: inline-size; min-width: 0; }
.home-cols { display: flex; gap: 20px; align-items: flex-start; min-width: 0; }
.home-main { flex: 2.2 1 0; min-width: 0; display: flex; flex-direction: column; gap: 26px; }
.home-aside {
  flex: 1 1 0; min-width: 300px; max-width: 420px; align-self: flex-start; position: sticky; top: 20px;
  background: var(--card); border-radius: var(--r-shell); padding: 24px; display: flex; flex-direction: column; gap: 22px;
}
@container (max-width: 900px) {
  .home-cols { flex-direction: column; align-items: stretch; }
  .home-aside { position: static; max-width: none; min-width: 0; width: 100%; }
}

/* ---------- Top: last update + since your last visit, update button, full analysis link ---------- */
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.home-meta { display: flex; flex-wrap: wrap; gap: 6px 20px; color: var(--muted); font-size: var(--fs-meta); min-width: 0; }
.home-meta-item { display: inline-flex; align-items: center; gap: 6px; }
.home-meta-item .ph, .home-meta-item .ph-fill { font-size: 15px; color: var(--ac); flex: none; }
.home-top-end { display: flex; align-items: center; gap: 16px; }
.home-full {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--hit); white-space: nowrap;
  color: var(--text); font-size: var(--fs-ui); text-decoration: underline; text-underline-offset: 6px;
}
.home-full:hover { color: var(--ac); }
.home-full .ph { font-size: 14px; }

/* ---------- Section heads ---------- */
.home-week, .home-feed { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.home-head-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.home-h2 { margin: 0; font-size: var(--fs-h2); font-weight: 400; line-height: 1.3; display: inline-flex; align-items: center; gap: 10px; }
.home-head-end { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.home-revs { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-meta); color: var(--muted); }
.home-revs .ph { font-size: 15px; color: var(--ac); }
.home-count {
  min-width: 30px; height: 30px; padding: 0 9px; border-radius: var(--r-pill); background: var(--card-2);
  display: inline-grid; place-items: center; font-size: 15px;
}

/* ---------- This week / this month: the dashboard's KPI tiles (desktop rings all accent, like the design) ---------- */
/* the title + its «أسبوع / شهر» switch (components.css .seg); a failed switch shows its message across the 3 columns */
.home-title-row { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; min-width: 0; }
.home-range { flex: none; }
.home-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.home-kpis > .alert { grid-column: 1 / -1; }
.home-kpis .kpi-label { white-space: nowrap; }
/* iPad: three tiles in a row leave a label like "Complaint share" little room, so it wraps inside its tile */
@media (min-width: 701px) and (max-width: 1366px) { .home-kpis .kpi-label { white-space: normal; min-width: 0; } }
@media (min-width: 701px) { .home-kpis .ring-fill.bad { stroke: var(--ac); } }
.home-kpis .kpi-sub > span:first-child { white-space: normal; }
@container (max-width: 620px) {
  .home-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .home-kpis > :last-child { grid-column: 1 / -1; }
}

/* ---------- The events feed ---------- */
.home-events { display: flex; flex-direction: column; gap: 10px; }
.home-ev {
  display: flex; align-items: flex-start; gap: 16px; min-width: 0;
  background: var(--card); border-radius: var(--r-card); padding: 18px 20px;
}
.home-ev-ic {
  width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--raised); color: var(--text);
}
.home-ev-ic .ph, .home-ev-ic .ph-fill { font-size: 22px; }
.home-ev.is-good .home-ev-ic { background: var(--ac); color: var(--ink); }
.home-ev.is-bad .home-ev-ic { background: var(--bad); color: var(--ink); }
.home-ev-body { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.home-ev-top { display: flex; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; }
.home-ev-title { margin: 0; font-size: 17px; font-weight: 400; line-height: 1.5; overflow-wrap: anywhere; }
.home-ev-time { font-size: var(--fs-small); color: var(--muted-2); white-space: nowrap; }
.home-ev-text { margin: 0; color: var(--muted); font-size: var(--fs-ui); line-height: 1.75; overflow-wrap: anywhere; }
.home-ev-text .badge { vertical-align: middle; }
.home-ev-act { margin-top: 6px; }
.home-ev-act .ph { font-size: 14px; }
.home-ev-num { flex: none; min-width: 56px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; padding-top: 2px; }
.home-ev-num .num { line-height: 1; }
.home-ev.is-good .home-ev-num .num { color: var(--ac); }
.home-ev.is-bad .home-ev-num .num { color: var(--bad-text); }
.home-ev-cap { font-size: var(--fs-small); color: var(--muted-2); white-space: nowrap; }
.home-empty { padding: 36px 24px; }

/* ---------- Side column: «تحتاج رد», the newest bad review, the monthly report ---------- */
.home-need { display: flex; flex-direction: column; gap: 14px; }
.home-need-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.home-need-row { display: flex; align-items: center; gap: 16px; min-width: 0; }
.home-need-n { line-height: 1; }
.home-need-what { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-body); min-width: 0; }
.home-need-btn { width: 100%; }
.home-need-ok { margin: 0; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: var(--fs-ui); line-height: 1.7; }
.home-need-ok .ph-fill { color: var(--ac); font-size: 22px; flex: none; }
.home-newest { display: flex; flex-direction: column; gap: 10px; }
.home-newest:empty { display: none; }
.home-label { font-size: var(--fs-meta); color: var(--muted); }
.home-link-row {
  display: flex; align-items: center; gap: 12px; min-height: var(--hit-lg); padding: 12px 14px;
  border-radius: var(--r-inner); background: var(--card-2); color: var(--text); text-decoration: none;
  transition: background var(--t-fast) var(--ease);
}
.home-link-row:hover { background: var(--raised); color: var(--text); }
.home-link-ic { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; background: #000; color: var(--ac); }
.home-link-ic .ph { font-size: 18px; }
.home-link-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-ui); }
.home-link-row > .ph { font-size: 16px; color: var(--muted); flex: none; }

/* ---------- Update sheet (also the dashboard's and the live page's) ---------- */
.home-up-text { margin: 0; color: var(--muted); font-size: var(--fs-ui); line-height: 1.8; }
.home-up-rows { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.home-up-row { display: flex; justify-content: space-between; gap: 12px; font-size: var(--fs-ui); }
.home-up-row > :first-child { color: var(--muted); }
/* the choice and the rows fill in when the place's facts arrive (home: right after a fresh load) */
.home-up-pick:empty, .home-up-rows:empty { display: none; }
/* the quota, and why «كل المراجعات حتى أقدمها» is not offered (.home-up-note) */
.home-quota, .home-up-note { margin: 0; display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: var(--fs-meta); line-height: 1.7; }
.home-quota .ph, .home-up-note .ph { color: var(--ac); font-size: 16px; flex: none; margin-top: 3px; }
/* «ماذا نقرأ؟»: two radio cards (the chosen one has an accent border); what is missing in amber under «كل المراجعات
   حتى أقدمها» */
.home-up-choice { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.home-up-legend { padding: 0; margin-bottom: 8px; font-size: var(--fs-meta); color: var(--muted); }
.home-up-opt {
  display: flex; align-items: flex-start; gap: 12px; min-height: var(--hit-lg); padding: 12px 14px; cursor: pointer;
  border-radius: var(--r-inner); background: var(--card-2); border: 2px solid transparent;
  transition: border-color var(--t-fast) var(--ease);
}
.home-up-opt:has(.home-up-radio:checked) { border-color: var(--ac); }
.home-up-opt:has(.home-up-radio:focus-visible) { outline: 2px solid var(--ac); outline-offset: 2px; }
.home-up-radio { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--ac); cursor: pointer; }
.home-up-radio:focus-visible { outline: none; }
.home-up-opt-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.home-up-opt-t { font-size: var(--fs-body); }
.home-up-opt-s { font-size: var(--fs-meta); color: var(--muted); line-height: 1.6; }
.home-up-opt-s.is-warn { color: var(--alert-amber-text); }
.home-up-msg:empty { display: none; }

/* ---------- «اقرأ المراجعات الناقصة»: only part of the history saved (also on the dashboard and the live page) ---------- */
.fh-notice { gap: 14px; }
.fh-body { min-width: 0; }
.fh-notice .alert-title { line-height: 1.6; overflow-wrap: anywhere; }
.fh-act { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; padding-inline-start: 46px; }
.fh-btn { flex: none; }
.fh-btn .ph { font-size: 17px; }
.fh-hint { flex: 1 1 14em; min-width: 0; font-size: var(--fs-meta); line-height: 1.6; color: var(--alert-amber-text); }

/* ---------- «جارٍ تحليل: <place> — الخطوة 2 من 4 · 45%» (home.js runningCard; also on «أماكني») ---------- */
/* One quiet row that opens the live page: a breathing accent dot (still with reduced motion), the words, an arrow */
.home-run:empty { display: none; }
.run-card {
  display: flex; align-items: center; gap: 12px; min-height: var(--hit-lg); padding: 12px 16px; min-width: 0;
  border-radius: var(--r-inner); background: var(--card); color: var(--text); text-decoration: none;
  font-size: var(--fs-ui); line-height: 1.6; transition: background var(--t-fast) var(--ease);
}
.run-card:hover { background: var(--card-hover); color: var(--text); }
.run-card:focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }
.run-card > .ph { font-size: 16px; color: var(--muted); flex: none; }
.run-dot { position: relative; width: 10px; height: 10px; border-radius: 50%; background: var(--ac); flex: none; }
.run-dot::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%; background: var(--ac);
  animation: m-pulse 1.6s var(--ease) infinite;
}
html[data-motion="reduce"] .run-dot::after { display: none; }
.run-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Phone ---------- */
@media (max-width: 700px) {
  .home-main { gap: 22px; }
  .home-top { flex-direction: column; align-items: stretch; }
  .home-meta { flex-direction: column; gap: 6px; }
  .home-top-end { justify-content: space-between; }
  .home-upbtn { height: var(--hit); }
  .home-h2 { font-size: var(--fs-section); }
  .home-range button { height: 40px; padding: 0 18px; }
  .home-ev { gap: 12px; padding: 14px 16px; border-radius: var(--r-tile); }
  .home-ev-ic { width: 40px; height: 40px; }
  .home-ev-ic .ph, .home-ev-ic .ph-fill { font-size: 19px; }
  .home-ev-title { font-size: var(--fs-body); }
  .home-ev-num { min-width: 40px; }
  .home-ev-num .num-stat { font-size: 26px; }
  .home-ev-act { height: var(--hit); }
  .home-aside { border-radius: var(--r-card); padding: 18px 16px; gap: 18px; }
  .home-need-n.num-hero { font-size: 48px; }
  .home-empty { padding: 28px 18px; }
  .fh-act { padding-inline-start: 0; } /* the button keeps its own width (full width only on the live page) */
}
