/* ==========================================================================
   Downloads around the world — the home page section and its admin preview.
   One hue for every mark (the brand orange), a lighter step of it for tracks,
   gray for "Other". Text never wears the mark colour.
   ========================================================================== */

.ds { position: relative; isolation: isolate; }
/* a dotted halo behind the heading, like a map seen from far away */
.ds::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 30rem; z-index: -1; pointer-events: none;
  background-image: radial-gradient(hsl(var(--primary) / .5) 1px, transparent 1.3px);
  background-size: 14px 14px;
  -webkit-mask: radial-gradient(36rem 13rem at 50% 7rem, #000, transparent 72%);
          mask: radial-gradient(36rem 13rem at 50% 7rem, #000, transparent 72%);
  opacity: .45;
}

.ds-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 1.25rem; }
.ds-grid.solo { grid-template-columns: minmax(0, 1fr); }
.ds-langs { grid-column: 1 / -1; container-type: inline-size; }

.ds-card {
  position: relative; display: flex; flex-direction: column; padding: 1.75rem; border-radius: 1.375rem;
  background: linear-gradient(180deg, hsl(var(--card)), hsl(var(--card) / .78));
  border: 1px solid hsl(var(--border)); box-shadow: inset 0 1px 0 hsl(0 0% 100% / .03);
}
.ds-card h3 { margin: 0; font-size: 1.1875rem; letter-spacing: -0.02em; }
.ds-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.ds-chip {
  flex: none; padding: 0.25rem 0.625rem; border-radius: 999px; font-size: 0.75rem; font-weight: 500; white-space: nowrap;
  color: hsl(var(--muted-foreground)); background: hsl(var(--secondary) / .7); border: 1px solid hsl(var(--border));
}
.ds-note { margin: 1.25rem 0 0; font-size: 0.8125rem; color: hsl(var(--muted-foreground)); line-height: 1.6; }

/* ------------------------------------------------------------- the total */
.ds-label {
  font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}
html[dir="rtl"] .ds-label { font-family: var(--font-arabic); letter-spacing: 0; text-transform: none; font-size: 0.8125rem; }
.ds-hero {
  display: block; margin-top: 0.625rem; font-size: clamp(3rem, 6vw, 4.25rem); font-weight: 700; line-height: 1;
  letter-spacing: -0.05em; color: hsl(var(--foreground));
}
.ds-delta { display: flex; align-items: center; gap: 0.5rem; margin: 0.875rem 0 0; font-size: 0.875rem; color: hsl(var(--muted-foreground)); }
.ds-delta b { color: hsl(var(--foreground)); font-weight: 600; }
.ds-delta .icon { width: 1rem; height: 1rem; color: hsl(var(--teal)); flex: none; }
html[dir="rtl"] .ds-delta .icon { transform: scaleX(-1); }

.ds-trend { flex: 1; display: flex; flex-direction: column; min-height: 8.5rem; margin: 1.75rem 0 0; }
.ds-cols { flex: 1; display: flex; align-items: flex-end; gap: 2px; min-height: 6.5rem; border-bottom: 1px solid hsl(var(--border)); }
.ds-col { position: relative; flex: 1 1 0; align-self: stretch; display: flex; align-items: flex-end; justify-content: center; }
.ds-col i {
  display: block; width: 100%; max-width: 24px; border-radius: 4px 4px 0 0;
  background: hsl(var(--primary) / .5); transition: background .15s, transform .7s var(--ease, ease);
  transform-origin: bottom;
}
.ds-col.today i, .ds-col:hover i { background: hsl(var(--primary)); }
.ds-axis { display: flex; justify-content: space-between; margin-top: 0.5rem; font-size: 0.6875rem; color: hsl(var(--muted-foreground)); font-family: var(--font-mono); }
html[dir="rtl"] .ds-axis { font-family: var(--font-arabic); font-size: 0.75rem; }

.ds-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: auto 0 0; padding-top: 1.5rem; }
.ds-facts > div { padding: 1rem 0 0; border-top: 1px solid hsl(var(--border)); }
.ds-facts > div + div { padding-inline-start: 1rem; border-inline-start: 1px solid hsl(var(--border)); }
.ds-facts dt { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
.ds-facts dd { margin: 0.25rem 0 0; font-size: 1.25rem; font-weight: 650; letter-spacing: -0.02em; }

/* --------------------------------------------------------- the countries */
.ds-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.125rem; }
.ds-row { position: relative; display: grid; gap: 0.5rem; outline: none; border-radius: 0.5rem; }
.ds-row:focus-visible { box-shadow: 0 0 0 2px hsl(var(--ring)); }
.ds-row-top { display: flex; align-items: center; gap: 0.625rem; min-width: 0; }
.ds-cc {
  flex: none; min-width: 2rem; padding: 0.125rem 0.375rem; border-radius: 0.375rem; text-align: center;
  font-family: var(--font-mono); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.04em;
  color: hsl(var(--foreground) / .82); background: hsl(var(--secondary)); border: 1px solid hsl(var(--border));
}
.ds-cc.more { color: hsl(var(--muted-foreground)); }
.ds-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9375rem; font-weight: 500; }
.ds-row.other .ds-name { color: hsl(var(--muted-foreground)); font-weight: 450; }
.ds-pct { flex: none; font-size: 0.875rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.ds-track { display: block; height: 0.5rem; border-radius: 999px; background: hsl(var(--primary) / .1); overflow: hidden; }
.ds-track i {
  display: block; height: 100%; min-width: 2px; background: hsl(var(--primary));
  border-start-end-radius: 4px; border-end-end-radius: 4px;
  transform-origin: left; transition: transform .8s var(--ease, ease);
}
html[dir="rtl"] .ds-track i { transform-origin: right; }
.ds-row.other .ds-track { background: hsl(var(--muted-foreground) / .1); }
.ds-row.other .ds-track i { background: hsl(var(--muted-foreground) / .55); }

/* --------------------------------------------------------- the languages */
.ds-meters { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }
/* four across when there is room, else two; never three and one */
@container (max-width: 60rem) { .ds-meters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ds-meter {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.125rem; border-radius: 1rem;
  background: hsl(var(--background) / .55); border: 1px solid hsl(var(--border));
}
.ds-dial { position: relative; flex: none; width: 4.25rem; height: 4.25rem; display: grid; place-items: center; }
.ds-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ds-ring circle { fill: none; stroke-width: 4.5; }
.ds-ring .track { stroke: hsl(var(--primary) / .14); }
.ds-ring .fill { stroke: hsl(var(--primary)); stroke-linecap: round; stroke-dasharray: var(--pct) 100; transition: stroke-dasharray 1s var(--ease, ease); }
.ds-meter-pct { position: relative; font-size: 0.875rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.ds-meter-name { display: grid; gap: 0.125rem; min-width: 0; }
.ds-meter-name b { text-align: left; font-size: 0.9375rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-meter-name span { font-size: 0.8125rem; color: hsl(var(--muted-foreground)); }

/* --------------------------------------------------------------- tooltips */
:is(.ds, .ds-scope) [data-tip]:hover::after, :is(.ds, .ds-scope) [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 0.5rem); left: 50%; transform: translateX(-50%);
  z-index: 5; padding: 0.375rem 0.625rem; border-radius: 0.5rem; white-space: nowrap; pointer-events: none;
  font-size: 0.75rem; font-weight: 500; letter-spacing: 0; text-transform: none; line-height: 1.4;
  color: hsl(var(--popover-foreground)); background: hsl(var(--popover));
  border: 1px solid hsl(var(--border)); box-shadow: 0 10px 30px -12px hsl(0 0% 0% / .6);
}
:is(.ds, .ds-scope) .ds-col.edge-s:hover::after { left: 0; transform: none; }
:is(.ds, .ds-scope) .ds-col.edge-e:hover::after { left: auto; right: 0; transform: none; }
:is(.ds, .ds-scope) .ds-row[data-tip]:hover::after, :is(.ds, .ds-scope) .ds-row[data-tip]:focus-visible::after { bottom: calc(100% + 0.25rem); }

/* ------------------------------------------------------- growing on reveal */
.will-reveal:not(.in) .ds-col i { transform: scaleY(0); }
.will-reveal:not(.in) .ds-track i { transform: scaleX(0); }
.will-reveal:not(.in) .ds-ring .fill { stroke-dasharray: 0 100; }

@media (max-width: 48rem) {
  .ds-grid { grid-template-columns: minmax(0, 1fr); }
  .ds-card { padding: 1.375rem; }
  .ds-trend { min-height: 7rem; }
}
@container (max-width: 30rem) {
  .ds-meter { flex-direction: column; gap: 0.75rem; padding: 1rem 0.75rem; text-align: center; }
  .ds-meter-name b, html[dir="rtl"] .ds-meter-name b { text-align: center; }
}
@media (max-width: 30rem) {
  .ds-card-head { flex-direction: column; gap: 0.75rem; }
  .ds-facts dd { font-size: 1.125rem; }
}
@media (prefers-reduced-motion: reduce) {
  .ds-col i, .ds-track i, .ds-ring .fill { transition: none; }
}

/* ------------------------------------------------------------- the admin */
.ds-admin-sub { margin: 1.5rem 0 0.25rem; font-size: 0.8125rem; font-weight: 600; color: hsl(var(--muted-foreground)); }
.ds-admin-table { max-height: 30rem; overflow: auto; }
.ds-admin-table table { min-width: 30rem; }
.ds-admin-table thead th { position: sticky; top: 0; z-index: 1; background: hsl(var(--card)); }
.ds-admin-table .ds-cc { margin-inline-end: 0.5rem; }
.ds-admin-share { display: inline-flex; align-items: center; gap: 0.75rem; width: 100%; }
.ds-admin-share .ds-track { flex: 1; min-width: 4rem; }
.ds-admin-share b { min-width: 3rem; text-align: end; font-weight: 600; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.ds-admin-unknown { display: grid; gap: 0.25rem; padding: 1rem 1.75rem 1.25rem; border-top: 1px solid hsl(var(--border)); font-size: 0.875rem; }

.ds-preview { margin-top: 0.5rem; padding: 0.25rem; border-radius: 1.25rem; background: hsl(var(--background) / .6); border: 1px dashed hsl(var(--border)); overflow: hidden; }
.ds-preview .ds { padding: 2rem 1.25rem 1.25rem; }
.ds-preview .h-head { max-width: 40rem; margin: 0 auto 2rem; text-align: center; }
.ds-preview .h-head h2 { margin: 0.625rem 0 0; font-size: 1.75rem; letter-spacing: -0.03em; }
.ds-preview .h-head .lead { margin: 0.75rem 0 0; color: hsl(var(--muted-foreground)); font-size: 0.9375rem; line-height: 1.65; }
.ds-preview .eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--font-mono); font-size: 0.6875rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: hsl(var(--primary));
}
.ds-preview .eyebrow::before { content: ""; width: 1.25rem; height: 1px; background: hsl(var(--primary)); }
html[dir="rtl"] .ds-preview .eyebrow { font-family: var(--font-arabic); letter-spacing: 0; text-transform: none; font-size: 0.8125rem; }

/* right-to-left pages turn every [dir=ltr] into monospace; here only the country codes stay mono */
html[dir="rtl"] :is(.ds, .ds-scope) [dir="ltr"]:not(.mono, .num), html[dir="rtl"] :is(.ds, .ds-scope) [data-tip]::after { font-family: var(--font-arabic); }
html[dir="rtl"] :is(.ds, .ds-scope) .ds-cc { font-family: var(--font-mono); }
html[dir="rtl"] .ds-meter-name b { text-align: right; }

.ds-admin-langs .kv-row > span:first-child { white-space: nowrap; min-width: 10rem; }
.ds-admin-langs .kv-row { flex-wrap: wrap; gap: 0.5rem 1rem; }
.ds-admin-langs .ds-admin-share { flex: 1 1 14rem; max-width: 22rem; }

/* ---------------------------------------- notification reach (admin only) */
.reach-ov-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 2.5rem; align-items: start; }
.reach-ov-main { display: grid; gap: 1rem; }
.reach-ov-top { display: flex; align-items: center; gap: 1.25rem; }
.reach-dial { width: 5.5rem; height: 5.5rem; }
.reach-dial .ds-meter-pct { font-size: 1rem; }
.reach-ov-num b { display: block; font-size: 2.5rem; font-weight: 700; letter-spacing: -0.04em; line-height: 1.1; }
.reach-ov-num span { font-size: 0.875rem; color: hsl(var(--muted-foreground)); }
.reach-ov .ds-facts { padding-top: 0.25rem; }
.reach-cell { display: inline-flex; align-items: center; gap: 0.625rem; }
.reach-cell .ds-track { width: 4.5rem; }
.reach-cell b { font-weight: 600; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
html[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
@media (max-width: 64rem) { .reach-ov-grid { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; } }
