/* public/css/ezlan-wg-download.css — پاپ‌آپ دانلود WireGuard
   توکن‌ها از ezlan-tokens.css می‌آن (روشن/تیره خودکار). همهٔ کلاس‌ها با پیشوند wgd- */

html.wgd-lock {
  overflow: hidden;
}
.wgd-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0s linear 0.22s;
}
.wgd-overlay.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.22s ease;
}
.wgd-modal {
  display: flex;
  flex-direction: column;
  width: min(700px, 100%);
  max-height: min(92vh, 780px);
  max-height: min(92dvh, 780px);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  transform: translateY(14px) scale(0.975);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.wgd-overlay.is-open .wgd-modal {
  transform: none;
}
.wgd-modal *,
.wgd-modal *::before,
.wgd-modal *::after {
  box-sizing: border-box;
}
.wgd-modal button {
  font: inherit;
  color: inherit;
}

/* ---------- سربرگ ---------- */
.wgd-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 24px 16px;
}
.wgd-shield {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--r-md);
  color: var(--accent-ink);
  background: var(--accent-soft-2);
  border: 1px solid var(--accent-line);
}
.wgd-shield svg {
  width: 24px;
  height: 24px;
}
.wgd-head-text {
  flex: 1;
  min-width: 0;
}
.wgd-head h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.5;
}
.wgd-head p {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.8;
}
.wgd-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: background-color 0.15s ease;
}
.wgd-close:hover {
  background: var(--surface-3);
}
.wgd-close svg {
  width: 18px;
  height: 18px;
}

/* ---------- بدنه (اسکرول‌شونده) ---------- */
.wgd-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 24px 18px;
}
.wgd-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.wgd-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 14px 6px 12px;
  min-height: 78px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease,
    box-shadow 0.18s ease;
}
.wgd-tab svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.wgd-tab:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.wgd-tab[aria-selected="true"] {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}
.wgd-tab-check {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: var(--on-accent);
  background: var(--accent);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.18s ease, transform 0.25s cubic-bezier(0.34, 1.6, 0.5, 1);
}
.wgd-tab-check svg {
  width: 10px;
  height: 10px;
  stroke-width: 3;
}
.wgd-tab[aria-selected="true"] .wgd-tab-check {
  opacity: 1;
  transform: none;
}

.wgd-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  animation: wgd-in 0.28s ease both;
}
.wgd-panel[hidden] {
  display: none;
}
.wgd-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 15.5px;
  font-weight: 800;
}
.wgd-panel-title svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--accent-ink);
}
.wgd-opts {
  display: grid;
  gap: 8px;
}
.wgd-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  text-align: start;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}
.wgd-opt:hover {
  border-color: var(--accent-line);
}
.wgd-opt[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}
.wgd-radio {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  display: grid;
  place-items: center;
  transition: border-color 0.18s ease;
}
.wgd-radio::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform 0.22s cubic-bezier(0.34, 1.6, 0.5, 1);
}
.wgd-opt[aria-checked="true"] .wgd-radio {
  border-color: var(--accent);
}
.wgd-opt[aria-checked="true"] .wgd-radio::after {
  transform: scale(1);
}
.wgd-opt-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.wgd-opt-title {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.6;
}
.wgd-opt-hint {
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.6;
}
.wgd-opt-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 4px;
}
.wgd-lg {
  display: inline;
}
.wgd-badge {
  flex: none;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-soft-2);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.wgd-size {
  flex: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
}
.wgd-help {
  margin: 12px 2px 0;
  font-size: 13px;
  line-height: 1.9;
  color: var(--ink-2);
}
.wgd-help a,
.wgd-links a,
.wgd-fine a {
  color: var(--accent-ink);
  text-underline-offset: 3px;
}

/* دستور لینوکس / brew با دکمهٔ کپی */
.wgd-cmd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.wgd-cmd-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wgd-cmd-label {
  font-size: 13px;
  font-weight: 700;
}
.wgd-cmd code {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-2);
  overflow-x: auto;
  white-space: nowrap;
}
.wgd-copy {
  flex: none;
  min-height: 36px;
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--surface);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.wgd-copy:hover {
  background: var(--accent-soft);
}

/* جزئیات هش */
.wgd-details {
  margin-top: 12px;
  font-size: 13px;
}
.wgd-details summary {
  cursor: pointer;
  color: var(--accent-ink);
  font-weight: 700;
  padding: 4px 2px;
}
.wgd-hash {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.wgd-hash code {
  flex: 1;
  min-width: 0;
  direction: ltr;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.wgd-note {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  padding: 11px 13px;
  font-size: 13px;
  line-height: 1.85;
  color: var(--ink-2);
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.wgd-foot .wgd-note {
  margin: 0 0 12px;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.8;
}
.wgd-note svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  fill: none;
  stroke: var(--accent-ink);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.wgd-state {
  padding: 22px 8px;
  text-align: center;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.9;
}
.wgd-state a {
  color: var(--accent-ink);
}

/* ---------- پایین مودال: CTA همیشه در دسترس ---------- */
.wgd-foot {
  flex: none;
  padding: 12px 24px 12px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.wgd-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  color: var(--on-accent);
  background: var(--accent);
  border: 0;
  border-radius: var(--r-md);
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.wgd-cta:hover {
  background: var(--accent-hover);
}
.wgd-cta:active {
  transform: translateY(1px);
}
.wgd-cta svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.wgd-cta[aria-disabled="true"] {
  opacity: 0.55;
  pointer-events: none;
}
.wgd-cta-sub {
  font-weight: 600;
  font-size: 13px;
  opacity: 0.85;
  padding-inline-start: 10px;
  border-inline-start: 1px solid rgba(255, 255, 255, 0.35);
}
.wgd-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 16px;
  justify-content: center;
  margin-top: 6px;
  font-size: 13px;
}
.wgd-links a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 2px;
}
.wgd-links svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.wgd-fine {
  margin: 14px 2px 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.85;
  color: var(--ink-3);
}

/* ---------- کارت پیشرفت دانلود ---------- */
.wgd-prog {
  position: relative;
  overflow: hidden;
  padding: 14px 16px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-md);
  animation: wgd-in 0.3s ease both;
}
.wgd-prog-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.wgd-ring {
  position: relative;
  flex: none;
  width: 50px;
  height: 50px;
}
.wgd-ring svg {
  display: block;
  width: 50px;
  height: 50px;
  transform: rotate(-90deg);
}
.wgd-ring-track {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 4;
}
.wgd-ring-fill {
  fill: none;
  stroke: var(--accent-ink);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 125.66;
  stroke-dashoffset: 125.66;
  transition: stroke-dashoffset 0.25s linear;
}
.wgd-ring.is-indeterminate svg {
  animation: wgd-spin 1.1s linear infinite;
}
.wgd-ring.is-indeterminate .wgd-ring-fill {
  stroke-dashoffset: 94;
}
.wgd-ring-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--accent-ink);
}
.wgd-ring-icon svg {
  width: 20px;
  height: 20px;
  transform: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.wgd-prog.is-active .wgd-ring-icon svg {
  animation: wgd-bob 1.1s ease-in-out infinite;
}
.wgd-prog-text {
  flex: 1;
  min-width: 0;
}
.wgd-prog-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.6;
}
.wgd-prog-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.wgd-prog-meta b {
  font-weight: 700;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}
.wgd-prog-btn {
  flex: none;
  min-height: 38px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  transition: background-color 0.15s ease;
}
.wgd-prog-btn:hover {
  background: var(--surface-3);
}
.wgd-bar {
  position: relative;
  height: 6px;
  margin-top: 14px;
  overflow: hidden;
  background: var(--surface-3);
  border-radius: var(--r-pill);
}
.wgd-bar-fill {
  position: absolute;
  inset: 0;
  background: var(--accent);
  border-radius: inherit;
  transform-origin: right center; /* RTL: از راست پر می‌شه */
  transform: scaleX(0);
  transition: transform 0.25s linear;
}
.wgd-prog.is-active .wgd-bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.45) 50%, transparent 80%);
  transform: translateX(120%);
  animation: wgd-sheen 1.4s ease-in-out infinite;
}
.wgd-prog.is-indeterminate .wgd-bar-fill {
  transform: scaleX(0.35);
  animation: wgd-slide 1.3s ease-in-out infinite;
}
.wgd-prog.is-done .wgd-bar-fill {
  transform: scaleX(1);
}
/* حالت تمام: حلقه کامل، تیک کشیده می‌شه و یک موج نرم پخش می‌شه */
.wgd-prog.is-done .wgd-ring-fill {
  stroke-dashoffset: 0;
}
.wgd-prog.is-done .wgd-ring::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent-ink);
  animation: wgd-ping 0.9s ease-out 1 both;
}
.wgd-check path {
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  animation: wgd-draw 0.45s ease 0.15s forwards;
}
.wgd-prog.is-error {
  background: var(--danger-soft);
  border-color: var(--danger-line);
}
.wgd-prog.is-error .wgd-ring-fill {
  stroke: var(--danger);
  stroke-dashoffset: 0;
}
.wgd-prog.is-error .wgd-ring-icon {
  color: var(--danger);
}
.wgd-prog.is-error .wgd-bar {
  display: none;
}
.wgd-prog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.wgd-prog-actions .wgd-prog-btn,
.wgd-prog-actions a.wgd-prog-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
}
.wgd-prog-actions .is-primary {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}
.wgd-prog-actions .is-primary:hover {
  background: var(--accent-hover);
}

.wgd-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@keyframes wgd-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes wgd-spin {
  to {
    transform: rotate(270deg);
  }
}
@keyframes wgd-bob {
  0%,
  100% {
    transform: translateY(-1.5px);
  }
  50% {
    transform: translateY(2px);
  }
}
@keyframes wgd-sheen {
  to {
    transform: translateX(-120%);
  }
}
@keyframes wgd-slide {
  0% {
    transform: translateX(120%) scaleX(0.35);
  }
  100% {
    transform: translateX(-120%) scaleX(0.35);
  }
}
@keyframes wgd-draw {
  to {
    stroke-dashoffset: 0;
  }
}
@keyframes wgd-ping {
  from {
    opacity: 0.7;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(1.7);
  }
}

/* ---------- موبایل: باتم‌شیت ---------- */
@media (max-width: 639px) {
  .wgd-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .wgd-modal {
    width: 100%;
    max-height: 94vh;
    max-height: 94dvh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-bottom: 0;
    transform: translateY(40px);
  }
  .wgd-head {
    padding: 16px 16px 12px;
    gap: 12px;
  }
  .wgd-head h2 {
    font-size: 18px;
  }
  .wgd-head p {
    font-size: 13px;
  }
  .wgd-body {
    padding: 0 16px 14px;
  }
  .wgd-tabs {
    gap: 6px;
  }
  .wgd-tab {
    min-height: 68px;
    padding: 10px 2px 9px;
    font-size: 11.5px;
    gap: 5px;
  }
  .wgd-tab svg {
    width: 22px;
    height: 22px;
  }
  .wgd-lg {
    display: none;
  }
  .wgd-tab-check {
    top: 4px;
    inset-inline-end: 4px;
    width: 14px;
    height: 14px;
  }
  .wgd-panel {
    padding: 14px;
  }
  .wgd-foot {
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  }
  .wgd-prog-row {
    gap: 10px;
  }
  .wgd-ring,
  .wgd-ring svg {
    width: 44px;
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wgd-overlay,
  .wgd-modal,
  .wgd-panel,
  .wgd-prog,
  .wgd-ring-fill,
  .wgd-bar-fill,
  .wgd-tab,
  .wgd-opt,
  .wgd-radio::after,
  .wgd-tab-check {
    transition: none !important;
    animation: none !important;
  }
  .wgd-ring.is-indeterminate svg,
  .wgd-prog.is-active .wgd-ring-icon svg,
  .wgd-prog.is-active .wgd-bar-fill::after,
  .wgd-prog.is-indeterminate .wgd-bar-fill,
  .wgd-prog.is-done .wgd-ring::after {
    animation: none !important;
  }
  .wgd-check path {
    animation: none !important;
    stroke-dashoffset: 0;
  }
}
