/* ==========================================================================
   ippub.ir — Glass UI
   Density: comfortable · Accent: sky (network/trust) · Type: Dastkhat (one family)
   Note: backdrop-filter is NOT nested — only the outer .glass surfaces blur;
   inner panes use plain translucent fills (nested backdrop-filter breaks).
   ========================================================================== */

@font-face {
  font-family: 'DastkhatFaNum';
  src: url('/fonts/DastkhatFaNum-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark light;

  --font: 'DastkhatFaNum', Tahoma, system-ui, sans-serif;
  /* IP / command values stay LTR + monospace so digits remain Latin and copy-safe.
     To render them in Dastkhat too, set this to var(--font). */
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Courier New', monospace;

  --bg-0: #070d1a;
  --bg-1: #0b1630;
  --blob-1: rgba(56, 189, 248, 0.26);
  --blob-2: rgba(20, 184, 166, 0.18);
  --vignette: rgba(4, 8, 18, 0.55);

  --text: #eaf0fb;
  --muted: #a9b6cc;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.16);
  --btn-bg: #38bdf8;
  --btn-ink: #04202e;
  --ok: #34d399;
  --danger: #fca5a5;

  --glass-bg:
    linear-gradient(145deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04)),
    rgba(10, 19, 40, 0.5);
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-hi: rgba(255, 255, 255, 0.24);
  --pane-bg: rgba(255, 255, 255, 0.05);
  --row-line: rgba(255, 255, 255, 0.09);
  --shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.6);
  --code-bg: rgba(3, 8, 20, 0.6);
  --code-ink: #7dd3fc;

  --map-opacity: 0.6;
  --map-filter: invert(1) hue-rotate(200deg) saturate(0.55) brightness(0.85) contrast(0.95);

  --radius: 26px;
  --radius-sm: 14px;
  --blur: 22px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-0: #dbe7fb;
    --bg-1: #eef3fd;
    --blob-1: rgba(14, 165, 233, 0.28);
    --blob-2: rgba(45, 212, 191, 0.25);
    --vignette: rgba(255, 255, 255, 0);

    --text: #0b1730;
    --muted: #43526b;
    --accent: #0369a1;
    --accent-soft: rgba(3, 105, 161, 0.12);
    --btn-bg: #0369a1;
    --btn-ink: #ffffff;
    --ok: #047857;
    --danger: #b91c1c;

    --glass-bg:
      linear-gradient(145deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.34)),
      rgba(255, 255, 255, 0.18);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-hi: rgba(255, 255, 255, 0.95);
    --pane-bg: rgba(15, 23, 42, 0.05);
    --row-line: rgba(15, 23, 42, 0.1);
    --code-bg: rgba(11, 23, 48, 0.9);
    --shadow: 0 24px 60px -18px rgba(30, 58, 110, 0.35);

    --map-opacity: 0.75;
    --map-filter: saturate(0.7) brightness(1.05);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; background: var(--bg-0); }

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg-0);
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60rem 38rem at 88% -8%, var(--blob-1), transparent 60%),
    radial-gradient(50rem 38rem at -5% 108%, var(--blob-2), transparent 60%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1));
}

/* ---- Map (decorative background) ---- */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: var(--map-opacity);
  pointer-events: none;
  background: transparent;
}
#map .leaflet-container { background: transparent; }
#map .leaflet-tile-pane { filter: var(--map-filter); }

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 30%, var(--vignette) 100%);
}

.pin {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.6);
  animation: pulse 2.2s ease-out infinite;
}
@keyframes pulse {
  70%  { box-shadow: 0 0 0 22px rgba(56, 189, 248, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

/* ---- Page frame ---- */
.page {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 1040px;
  margin-inline: auto;
  padding: clamp(16px, 3vw, 32px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---- Glass surface ---- */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: rgba(14, 24, 48, 0.92); }
  @media (prefers-color-scheme: light) { .glass { background: rgba(255, 255, 255, 0.92); } }
}

/* ---- Icons ---- */
.icon {
  width: 1.25rem; height: 1.25rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Header / hero ---- */
.topbar { display: flex; align-items: center; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 18px 8px 14px;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.brand-name { direction: ltr; letter-spacing: 0.2px; }

.hero { text-align: center; padding: 8px 0 0; }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; line-height: 1.4; }
.hero p { color: var(--muted); max-width: 52ch; margin: 8px auto 0; }

/* ---- Main landscape card: IP (right) | connection (left) ---- */
.card {
  display: grid;
  grid-template-columns: 1fr 1.15fr;   /* RTL: first column sits on the right */
  padding: 10px;
  position: relative;
}
.pane { padding: clamp(18px, 3vw, 30px); min-width: 0; }
.pane + .pane { border-inline-start: 1px solid var(--row-line); }

.pane-ip { display: flex; flex-direction: column; gap: 16px; justify-content: center; }

.eyebrow {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}
.pane-title { font-size: 1rem; font-weight: 700; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; color: var(--muted); }

.ip-value {
  display: block;
  font-family: var(--font-mono);
  font-size: clamp(1.7rem, 3.6vw, 2.5rem);
  font-weight: 700;
  line-height: 1.25;
  direction: ltr;
  text-align: right;               /* hugs the right edge like the label above */
  overflow-wrap: anywhere;
  word-break: break-all;
  min-height: 1.25em;
}
.ip-value.is-long { font-size: clamp(1.05rem, 2vw, 1.4rem); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem; font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
}
.chip-ok { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.chip .icon { width: 1rem; height: 1rem; }
.chip-ver { direction: ltr; font-family: var(--font-mono); }

.where {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted);
}
.where .icon { color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit; font-weight: 600; font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, border-color 0.2s;
}
.btn:hover { background: rgba(255, 255, 255, 0.16); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--btn-bg); color: var(--btn-ink); border-color: transparent; }
.btn-primary:hover { background: var(--btn-bg); filter: brightness(1.08); }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.btn.is-done { background: rgba(52, 211, 153, 0.2); color: var(--ok); border-color: transparent; }
@media (prefers-color-scheme: light) {
  .btn { background: rgba(255, 255, 255, 0.6); border-color: rgba(15, 23, 42, 0.16); }
  .btn:hover { background: rgba(255, 255, 255, 0.95); }
  .btn-primary { border-color: transparent; background: var(--btn-bg); }
  .btn-primary:hover { background: var(--btn-bg); }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }

.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Info rows ---- */
.info { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--row-line);
}
.row:last-child { border-bottom: 0; }
.row dt {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted);
  font-size: 0.95rem;
  white-space: nowrap;
}
.row dt .icon { color: var(--accent); }
.row dd {
  min-width: 0;
  text-align: left;
  unicode-bidi: plaintext;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.row dd.mono { font-family: var(--font-mono); font-size: 0.9rem; direction: ltr; }
.row dd.is-unknown { font-family: var(--font); direction: rtl; font-weight: 500; color: var(--muted); }
.row-numeric { margin-top: 4px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--pane-bg); border: 0; }

/* Latin-digit token inside Persian text (e.g. AS12880) */
.tok { font-family: var(--font-mono); font-size: 0.92em; direction: ltr; unicode-bidi: isolate; color: var(--accent); }

/* ---- Loading + error ---- */
.is-loading {
  display: inline-block;
  min-width: 8ch;
  color: transparent !important;
  user-select: none;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--row-line), rgba(255, 255, 255, 0.2), var(--row-line));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.ip-value.is-loading { min-width: 12ch; }
@keyframes shimmer { to { background-position: -200% 0; } }

.alert {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 6px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, 0.14);
  color: var(--danger);
  font-weight: 600;
}
.alert[hidden] { display: none; }
.alert > span { display: inline-flex; align-items: center; gap: 8px; }

/* ---- Secondary panels ---- */
.panel { padding: clamp(18px, 3vw, 28px); }
.panel h2 { font-size: 1.15rem; font-weight: 700; display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.panel h2 .icon { color: var(--accent); }

.tabs {
  display: flex; gap: 6px;
  overflow-x: auto;
  padding: 5px;
  border-radius: var(--radius-sm);
  background: var(--pane-bg);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  flex: none;
  min-height: 40px;
  padding: 6px 14px;
  border: 0; border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit; font-size: 0.92rem; font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.tab:hover { color: var(--text); }
.tab[aria-selected='true'] { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-soft); }

.tabpanel { margin-top: 14px; }
.tabpanel .hint { color: var(--muted); font-size: 0.9rem; margin-top: 10px; }

.cmd {
  direction: ltr;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px 6px 16px;
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  border: 1px solid var(--row-line);
}
.cmd code {
  flex: 1; min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  padding: 10px 0;
  color: var(--code-ink);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  text-align: left;
  scrollbar-width: thin;
}
.cmd .btn, .cmd .btn:hover { min-height: 40px; padding: 6px 14px; flex: none; color: #eaf0fb; border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.1); }
.cmd .btn.is-done { color: #34d399; background: rgba(52,211,153,.16); }

/* ---- FAQ ---- */
.faq-list { display: flex; flex-direction: column; gap: 8px; }
.faq-item { border-radius: var(--radius-sm); background: var(--pane-bg); }
.faq-item summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  min-height: 48px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item .chev { color: var(--accent); transition: transform 0.2s; }
.faq-item[open] .chev { transform: rotate(180deg); }
.faq-item p { padding: 0 18px 16px; color: var(--muted); }
.faq-item code, .api-note code {
  direction: ltr; unicode-bidi: isolate;
  font-family: var(--font-mono); font-size: 0.88em;
  padding: 1px 6px; border-radius: 6px;
  background: var(--code-bg); color: var(--code-ink);
}

/* ---- Footer ---- */
.footer { margin-top: auto; text-align: center; padding: 8px 0 4px; }
.footer .glass {
  display: inline-block;
  padding: 14px 28px;
  border-radius: 20px;
}
.footer .made { font-weight: 700; }
.footer .rights { color: var(--muted); font-size: 0.92rem; }
.footer .credits { color: var(--muted); font-size: 0.78rem; margin-top: 6px; }
.footer .credits a { color: inherit; }
.heart { display: inline-block; animation: beat 1.8s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.22); } 24% { transform: scale(1); } }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translate(-50%, 12px);
  z-index: 50;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px;
  border-radius: 14px;
  background: rgba(6, 14, 30, 0.88);
  color: #eaf0fb;
  border: 1px solid rgba(255, 255, 255, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.toast .icon { color: #34d399; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- Responsive ---- */
@media (max-width: 800px) {
  .card { grid-template-columns: 1fr; }
  .pane + .pane { border-inline-start: 0; border-top: 1px solid var(--row-line); }
  .ip-value { text-align: right; }
}
@media (max-width: 340px) {
  .row { flex-direction: column; align-items: flex-start; gap: 2px; }
  .row dd { text-align: right; }
  .row-numeric { align-items: flex-start; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.main { display: flex; flex-direction: column; gap: 24px; }
