/* ============================================================
   City workspace frame: the city masthead (stage register) + the workspace tabs.
   (.area-chip base / .tab-spark live in map.css; the masthead restyles
   .area-chip for the stage.)  The masthead is theme-invariant: --stage-* only.
   ============================================================ */

/* ---------------- masthead ----------------
   <header class="city-head city-mast [is-compact] [no-still]">: a still of the city (or the
   drawn stage), a scrim, the top row (eyebrow · actions) and the body (name, period,
   readiness line · three numbers). .is-compact = every tab but the dashboard. */
.city-mast {
  position: relative; isolation: isolate; overflow: hidden;
  min-height: 300px; margin-bottom: var(--s-4);
  display: flex; flex-direction: column; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-5) var(--s-6) var(--s-5);
  border-radius: var(--radius-stage);
  background: var(--stage-bg); color: var(--stage-ink);
  box-shadow: 0 18px 48px rgba(4, 6, 14, 0.22), 0 1px 3px rgba(4, 6, 14, 0.18);
}
.city-mast.is-compact { min-height: 196px; gap: var(--s-3); }

.cm-still {
  position: absolute; inset: 0; z-index: -2;
  width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%;
  animation: cm-settle 1100ms var(--ease-out) both;
}
.city-mast.is-compact .cm-still { object-position: 50% 62%; }
@keyframes cm-settle { from { opacity: 0; transform: scale(1.045); } to { opacity: 1; transform: none; } }
/* an in-place re-render (period / sub-view switch) holds the frame still */
.ws-screen.is-inplace, .ws-screen.is-inplace .cm-still { animation: none; }

/* words over the city: dark at the foot (scrim-up), a veil at the top for the eyebrow row,
   and both sides held down where the name and the numbers sit */
.cm-scrim {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    var(--scrim-up),
    linear-gradient(to bottom, rgba(4, 6, 14, 0.58), rgba(4, 6, 14, 0) 42%),
    linear-gradient(90deg, rgba(4, 6, 14, 0.5), rgba(4, 6, 14, 0.06) 42%, rgba(4, 6, 14, 0.06) 58%, rgba(4, 6, 14, 0.45));
}
.city-mast.no-still .cm-scrim {
  background: var(--scrim-up), linear-gradient(90deg, rgba(4, 6, 14, 0.4), transparent 45%, transparent 55%, rgba(4, 6, 14, 0.4));
}

/* the drawn stage (a city without a still) */
.cm-blueprint {
  position: absolute; inset: 0; z-index: -2; color: var(--stage-accent);
  background:
    radial-gradient(ellipse 60% 90% at 70% 70%, rgba(154, 168, 255, 0.16), transparent 70%),
    linear-gradient(170deg, var(--stage-bg-2), var(--stage-bg));
}
html[dir="rtl"] .cm-blueprint {
  background:
    radial-gradient(ellipse 60% 90% at 30% 70%, rgba(154, 168, 255, 0.16), transparent 70%),
    linear-gradient(190deg, var(--stage-bg-2), var(--stage-bg));
}
.cm-blueprint svg { width: 100%; height: 100%; display: block; }
.cm-blueprint .bp-grid { stroke: rgba(196, 204, 255, 0.055); stroke-width: 1; }
.cm-blueprint .bp-rings { fill: none; stroke: currentColor; stroke-width: 1; opacity: 0.16; }
.cm-blueprint .bp-axis { fill: none; stroke: currentColor; stroke-width: 1; opacity: 0.08; }
.cm-blueprint .bp-blocks rect { fill: rgba(196, 204, 255, 0.06); stroke: currentColor; stroke-width: 0.8; opacity: 0.32; }

/* top row: eyebrow · actions */
.cm-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); min-width: 0; }
.cm-eyebrow {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0;
  font-size: var(--fs-eyebrow); font-weight: 700; color: var(--stage-ink-dim);
  text-shadow: var(--stage-text-shadow);
}
.cm-eyebrow .sep { color: var(--stage-ink-faint); font-weight: 500; }
.cm-eyebrow .unit { font-size: 1em; color: inherit; font-weight: inherit; }
.cm-pop { display: inline-flex; align-items: center; gap: 8px; }
.cm-back {
  display: inline-flex; align-items: center; gap: 6px; color: var(--stage-accent);
  transition: color var(--t-fast) var(--ease-std);
}
.cm-back:hover { color: #fff; }
.cm-back .ico { width: 16px; height: 16px; }
.cm-actions { display: flex; align-items: center; gap: var(--s-2); flex: none; }
.cm-actions .btn { min-height: 38px; }
.cm-more { width: 38px; padding: 0; }
.cm-more .ico { margin: 0; }

/* body: identity (name, period, readiness) · the numbers */
.cm-body { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4) var(--s-6); flex-wrap: wrap; }
.cm-id { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-3); }
.cm-name {
  font-size: var(--fs-display); line-height: 1.12; font-weight: 800; color: var(--stage-ink);
  text-shadow: var(--stage-text-shadow); text-wrap: balance;
}
html[lang="ar"] .cm-name { line-height: 1.3; }
html[lang="en"] .cm-name { letter-spacing: -0.02em; }
.cm-name.is-long { font-size: clamp(32px, 3.3vw, 46px); }
.city-mast.is-compact .cm-name { font-size: var(--fs-h1); }
.cm-controls { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

/* glass on the city: the period switcher, chips, the readiness line */
.city-mast :is(.cm-period, .cm-chip, .cm-status, .area-chip) {
  background: var(--stage-glass);
  -webkit-backdrop-filter: var(--stage-glass-filter); backdrop-filter: var(--stage-glass-filter);
  border: 1px solid var(--stage-line); box-shadow: var(--stage-rim);
}
.city-mast .seg.cm-period { padding: 3px; border-radius: 12px; gap: 2px; }
.city-mast .seg.cm-period button {
  min-height: 30px; padding: 0 12px; border-radius: 9px;
  font-family: var(--f-num); font-size: 13px; font-weight: 600; color: var(--stage-ink-dim);
}
.city-mast .seg.cm-period button:hover { color: var(--stage-ink); background: rgba(255, 255, 255, 0.06); }
.city-mast .seg.cm-period button.on, .city-mast .seg.cm-period button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.16); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 2px 8px rgba(4, 6, 14, 0.3);
}
.cm-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 14px;
  border-radius: 12px; font-size: 13px; font-weight: 600; color: var(--stage-ink-dim);
}
.cm-chip .ico { width: 16px; height: 16px; opacity: 0.8; }
.cm-chip .num { color: var(--stage-ink); font-weight: 700; }
.city-mast .area-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 6px 0 14px;
  border-radius: 12px; color: var(--stage-ink); font-size: 13px;
}
html[dir="rtl"] .city-mast .area-chip { padding: 0 14px 0 6px; }
.city-mast .area-chip .ac-label { color: var(--stage-ink-dim); }
.city-mast .area-chip .ac-x { width: 26px; height: 26px; border-radius: 8px; color: var(--stage-ink-dim); }
.city-mast .area-chip .ac-x:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.city-mast .area-chip .ac-x .ico { width: 14px; height: 14px; }

.cm-status {
  display: inline-flex; align-items: center; gap: 10px; max-width: 100%; min-width: 0;
  min-height: 36px; padding: 0 16px; border-radius: 999px;
  font-size: 13px; color: var(--stage-ink-dim);
  transition: border-color var(--t-fast) var(--ease-std);
}
.cm-status:hover { border-color: var(--stage-line-strong); }
.cm-status .sdot { width: 8px; height: 8px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--sc) 25%, transparent); }
.cm-status b { color: var(--stage-ink); font-weight: 700; white-space: nowrap; }
.cm-status-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-status-go {
  display: inline-flex; align-items: center; gap: 4px; flex: none; white-space: nowrap;
  padding-inline-start: 10px; border-inline-start: 1px solid var(--stage-line);
  color: var(--stage-accent); font-weight: 700;
}
.cm-status-go .ico { width: 15px; height: 15px; }
.city-mast.is-compact .cm-status { display: none; }

/* the three numbers, written on the city */
.cm-facts { display: flex; margin: 0; flex: none; }
.cm-fact { padding: 0 var(--s-5); border-inline-start: 1px solid var(--stage-line-strong); min-width: 0; }
.cm-fact:first-child { border-inline-start: 0; padding-inline-start: 0; }
.cm-fact:last-child { padding-inline-end: 0; }
.cm-val {
  margin: 0; font-family: var(--f-num); font-variant-numeric: tabular-nums;
  font-size: clamp(44px, 4.3vw, 64px); font-weight: 700; line-height: 1; letter-spacing: -0.025em;
  color: var(--stage-ink); text-shadow: var(--stage-num-glow); white-space: nowrap;
}
.city-mast.is-compact .cm-val { font-size: clamp(30px, 2.8vw, 40px); }
.cm-of, .cm-unit { font-size: 0.44em; font-weight: 600; color: var(--stage-ink-dim); letter-spacing: 0; margin-inline-start: 0.06em; }
.cm-label {
  margin: 8px 0 0; max-width: 15ch; font-size: var(--fs-micro); font-weight: 600; line-height: 1.5;
  color: var(--stage-ink-dim); text-shadow: var(--stage-text-shadow);
}

/* ---------------- workspace tabs ---------------- */
.ws-tabs-wrap { margin-bottom: var(--s-5); }

/* ---------------- phone ---------------- */
@media (max-width: 980px) {
  /* the tab row pins under the top bar (its height is measured into --ws-pin) */
  .ws-tabs-wrap {
    position: sticky; top: var(--ws-pin, 0px); z-index: 20;
    margin-inline: calc(-1 * clamp(18px, 4vw, 44px)); padding-inline: clamp(18px, 4vw, 44px);
    background: var(--bg);
  }
}
@media (max-width: 760px) {
  .city-mast, .city-mast.is-compact {
    min-height: 220px; padding: var(--s-4); gap: var(--s-3);
    border-radius: var(--radius-xl);
  }
  .cm-pop { display: none; }
  .cm-blueprint svg { opacity: 0.5; }
  .cm-export { display: none; }
  .cm-present { width: 38px; padding: 0; }
  .cm-present .cm-act-label { display: none; }
  .cm-present .ico { margin: 0; }
  .cm-body { gap: var(--s-4); }
  .cm-id { gap: var(--s-2); width: 100%; }
  .cm-name, .city-mast.is-compact .cm-name { font-size: 34px; }
  .cm-name.is-long { font-size: 26px; }
  .cm-status { display: none; }
  .cm-facts { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cm-fact { padding: 0 var(--s-3); }
  .cm-val, .city-mast.is-compact .cm-val { font-size: 30px; }
  .cm-label { margin-top: 4px; font-size: 12px; }
  html[lang="ar"] .cm-label { font-size: 12.5px; }
}
