/* ============================================================
   Cities list: stage cards (the city still or its district drawing on --stage-bg,
   name + period on a scrim) over a desk body (progress, numerals, actions); the compact
   create tile; the quieter sandbox section; the import drop zone.
   ============================================================ */

.city-grid {
  --cy-stage-h: 184px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
  gap: var(--s-5); align-items: stretch;
}

/* ---------------- card ---------------- */
.city-card { display: flex; flex-direction: column; min-width: 0; }

/* stage band: theme-invariant, like every stage */
.cy-stage {
  position: relative; isolation: isolate; overflow: hidden;
  height: var(--cy-stage-h); flex: none;
  background: radial-gradient(120% 90% at 78% 8%, rgba(154, 168, 255, 0.16), transparent 62%), var(--stage-bg);
  color: var(--stage-ink);
}
/* survey grid, faded towards the edges (hidden under a still) */
.cy-stage::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image:
    linear-gradient(var(--stage-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--stage-line) 1px, transparent 1px);
  background-size: 32px 32px; background-position: center;
  opacity: 0.45;
  -webkit-mask-image: radial-gradient(75% 85% at 60% 40%, #000, transparent);
  mask-image: radial-gradient(75% 85% at 60% 40%, #000, transparent);
}
.cy-stage.has-still::before { display: none; }
/* scrim under the caption */
.cy-stage::after { content: ""; position: absolute; inset: 0; z-index: 1; background: var(--scrim-up); pointer-events: none; }

.cy-still {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity var(--t-slow) var(--ease-out), transform 900ms var(--ease-out);
}
.cy-stage.has-still .cy-still { opacity: 1; }
.cy-stage.is-cached .cy-still { transition: transform 900ms var(--ease-out); }
.cy-stage:hover .cy-still { transform: scale(1.03); }

/* the districts as a line drawing (no still yet) */
.cy-blueprint {
  position: absolute; inset: 14px 20px 64px; display: grid; place-items: center;
  color: var(--stage-accent); opacity: 0.6;
}
.cy-blueprint svg { width: 100%; height: 100%; display: block; overflow: visible; }
.cy-blueprint path {
  fill: rgba(196, 204, 255, 0.05);
  stroke: currentColor; stroke-width: 1.1; stroke-linejoin: round; vector-effect: non-scaling-stroke;
  stroke-dasharray: 2400; stroke-dashoffset: 2400;
  animation: cy-draw 1800ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes cy-draw { to { stroke-dashoffset: 0; } }
.cy-blueprint.generic { opacity: 0.32; }
.cy-blueprint.generic .ico { width: 76px; height: 76px; stroke-width: 1.1; }

.cy-hit { position: absolute; inset: 0; z-index: 2; }
.cy-caption {
  position: absolute; inset-inline: 20px; bottom: 16px; z-index: 3;
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4);
  pointer-events: none; text-shadow: var(--stage-text-shadow);
}
.cy-title { min-width: 0; }
.cy-country { font-size: 13px; font-weight: 600; color: var(--stage-ink-dim); line-height: 1.5; }
.cy-name {
  font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: 800; color: var(--stage-ink);
  text-wrap: balance;
}
html[lang="en"] .cy-name { letter-spacing: -0.01em; }
.cy-period { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: end; }
.cy-period > span { font-size: 12.5px; font-weight: 600; color: var(--stage-ink-dim); }
.cy-period .range { font-size: 15px; font-weight: 650; color: var(--stage-ink); }

/* desk body */
.cy-body { flex: 1; display: flex; flex-direction: column; gap: var(--s-4); padding: 18px 20px 20px; }

.cy-todo { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; min-height: 42px; font-size: 13.5px; color: var(--ink-dim); }
.cy-todo a { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--accent); }
.cy-todo a:hover { text-decoration: underline; text-underline-offset: 3px; }
.cy-todo .ico { width: 16px; height: 16px; }
.cy-progress-label { font-size: 13.5px; font-weight: 600; color: var(--ink); margin-bottom: var(--s-2); }
.cy-bar { height: 6px; border-radius: 99px; background: var(--viz-track); overflow: hidden; }
:root:not([data-theme="dark"]) .cy-bar { background: var(--line); }
.cy-bar > i {
  display: block; height: 100%; border-radius: inherit; background: var(--accent);
  transform-origin: left center; animation: cy-grow 700ms var(--ease-out) 200ms both;
}
html[dir="rtl"] .cy-bar > i { transform-origin: right center; }
.cy-bar.done > i { background: var(--sage); }
@keyframes cy-grow { from { transform: scaleX(0); } }

.cy-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0; padding-top: var(--s-4); border-top: 1px solid var(--line);
}
.cy-stat { min-width: 0; padding-inline: var(--s-4); border-inline-start: 1px solid var(--line); }
.cy-stat:first-child { padding-inline-start: 0; border-inline-start: none; }
.cy-stat dt { font-size: 22px; font-weight: 650; line-height: 1.15; color: var(--ink-hi); letter-spacing: -0.01em; }
.cy-stat dd { margin: 4px 0 0; font-size: var(--fs-micro); font-weight: 600; color: var(--ink-dim); }

.cy-actions { display: flex; align-items: center; gap: var(--s-2); margin-top: auto; padding-top: var(--s-1); }
.cy-actions .icon-btn { width: var(--h-md); height: var(--h-md); border-radius: var(--radius-sm); margin-inline-start: auto; }

/* ---------------- create tile: compact, the height of a stage band ---------------- */
.city-create {
  align-self: start; min-height: max(140px, var(--cy-stage-h));
  display: flex; align-items: center; gap: var(--s-4);
  padding: 20px 22px; text-align: start;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  background: transparent; color: var(--ink-dim);
  transition: border-color var(--t-fast) var(--ease-std), background var(--t-fast) var(--ease-std), color var(--t-fast) var(--ease-std);
}
.city-create:hover { border-color: var(--accent); color: var(--ink-hi); background: color-mix(in srgb, var(--accent) 5%, transparent); }
.city-create-plus {
  width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.city-create-plus .ico { width: 22px; height: 22px; }
.city-create-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.city-create-title { font-size: 15px; font-weight: 700; color: var(--ink-hi); }
.city-create-sub { font-size: 13px; color: var(--ink-dim); line-height: 1.6; text-wrap: pretty; }

/* ---------------- sandbox: quieter, below a hairline ---------------- */
.city-sandbox { margin-top: var(--section-gap); padding-top: var(--s-5); border-top: 1px solid var(--line); }
.city-sandbox-head { display: flex; align-items: baseline; gap: 6px var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-4); }
.city-sandbox-title { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: 800; color: var(--ink-hi); }
.city-sandbox-sub { margin: 0; font-size: 13.5px; color: var(--ink-dim); }

/* ---------------- create form: tighter title → fields ---------------- */
.city-form .field-group { gap: var(--s-3); }
/* the pairs are short (a name in two scripts): they stay side by side on phones too */
.city-form .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }

/* ---------------- import drop zone ---------------- */
.city-drop { padding: 36px 24px; transition: border-color var(--t-fast) var(--ease-std), background var(--t-fast) var(--ease-std); }
.city-drop.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }

/* reset-demo confirmation (also opened from the shell) */
.city-reset-text { margin: 0; color: var(--ink); font-size: 14.5px; line-height: 1.8; max-width: 60ch; text-wrap: pretty; }

@media (max-width: 760px) {
  .city-grid { --cy-stage-h: 168px; gap: var(--s-4); }
  .cy-caption { inset-inline: 16px; bottom: 14px; }
  .cy-body { padding: 16px; }
  .cy-actions .btn { padding-inline: 14px; }
}
