/* ifconfig.razbansec.com — styles
   Original protocol-stack design preserved; PRV (privacy) layer added. */

:root {
  --bg:     #F2F6FA;   /* pale blue-tint — light side of razbansec brand */
  --panel:  #FFFFFF;
  --inset:  #F6FAFD;
  --line:   #E3EAF1;
  --line2:  #C9D6E2;
  --ink:    #16283A;
  --muted:  #5D7386;
  --faint:  #8FA5B8;
  --mint:   #0C8C5E;   /* brand green, darkened for light bg */
  --mint-dim: rgba(16,150,100,.11);
  --sky:    #2563EB;   /* brand blue */
  --sky-dim: rgba(37,99,235,.09);
  --navy:   #0A2B60;   /* brand navy — primary actions */
  --amber:  #B45309;
  --amber-dim: rgba(217,119,6,.12);
  --red:    #B91C1C;
  --red-dim: rgba(220,38,38,.10);
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Consolas, Menlo, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r: 12px;
  --shadow: 0 1px 2px rgba(22,40,58,.04), 0 4px 14px rgba(22,40,58,.06);
  /* Tokenised so the dark theme can override them (were hardcoded). */
  --navy-hover: #123C7E;
  --on-navy:    #fff;
  --glow-a:     rgba(37,99,235,.05);
  --glow-b:     rgba(16,150,100,.04);
  --pulse:      rgba(10,43,96,.35);
  --pulse-0:    rgba(10,43,96,0);
  --toast-bg:   var(--ink);
  --toast-ink:  #fff;
  --toast-shadow: 0 8px 24px rgba(22,40,58,.22);
  --logo-light: block;   /* which logo variant is visible */
  --logo-dark:  none;
}

/* ── Dark theme ──────────────────────────────────────────────
   The inline boot script in index.php always resolves a concrete
   data-theme (stored choice, else prefers-color-scheme) before first
   paint, so only this one explicit selector is needed — no duplicated
   palette under a media query, and no flash of the wrong theme. */
:root[data-theme="dark"] {
  --bg:     #0B1520;
  --panel:  #111E2B;
  --inset:  #0E1926;
  --line:   #1D2E3F;
  --line2:  #2C4056;
  --ink:    #E6EFF7;
  --muted:  #9DB2C6;
  --faint:  #7089A0;
  --mint:   #34D399;
  --mint-dim: rgba(52,211,153,.15);
  --sky:    #60A5FA;
  --sky-dim: rgba(96,165,250,.15);
  --navy:   #2F6BE0;
  --amber:  #FBBF24;
  --amber-dim: rgba(251,191,36,.16);
  --red:    #F87171;
  --red-dim: rgba(248,113,113,.15);
  --shadow: 0 1px 2px rgba(0,0,0,.40), 0 4px 14px rgba(0,0,0,.34);
  --navy-hover: #4381F0;
  --on-navy:    #fff;
  --glow-a:     rgba(96,165,250,.07);
  --glow-b:     rgba(52,211,153,.06);
  --pulse:      rgba(96,165,250,.40);
  --pulse-0:    rgba(96,165,250,0);
  --toast-bg:   #E6EFF7;
  --toast-ink:  #0B1520;
  --toast-shadow: 0 8px 24px rgba(0,0,0,.55);
  --logo-light: none;
  --logo-dark:  block;
}

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

html { background: var(--bg); }

body {
  background:
    radial-gradient(1100px 500px at 85% -10%, var(--glow-a), transparent 60%),
    radial-gradient(900px 480px at -10% 30%, var(--glow-b), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

[dir="rtl"] body { font-family: Vazirmatn, Tahoma, var(--sans); }
[dir="rtl"] .eyebrow, [dir="rtl"] .card-title, [dir="rtl"] .section-title { letter-spacing: 0; }

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 20px 72px;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 18px;
  margin-bottom: 34px;
  border-bottom: 1px solid var(--line);
}
.logo {
  display: flex; flex-direction: column; align-items: flex-start; gap: 7px;
  text-decoration: none;
  color: var(--ink);
}
/* Wordmark row keeps its old baseline alignment; the shield sits under it. */
.logo-line { display: flex; align-items: baseline; gap: 10px; }
/* The shield sits on the physical LEFT of the name in BOTH directions
   (owner's call). DOM order is text-then-image, which already puts the mark
   on the left under RTL, so only LTR needs reversing. Reversing visually
   rather than reordering the DOM keeps the reading order intact — and the
   image is alt="" decorative, so nothing is lost for screen readers. */
.logo-org-row { display: flex; align-items: center; gap: 8px; flex-direction: row-reverse; }
[dir="rtl"] .logo-org-row { flex-direction: row; }
.logo-org {
  font-size: 11px;
  line-height: 1.2;
  color: var(--faint);
  letter-spacing: .2px;
  white-space: nowrap;
}
/* flex-start follows `dir`, so the mark hugs the correct edge in RTL.
   Two variants ship: black monogram for light, white monogram for dark.
   Only one is displayed; the other stays in the DOM so the swap is instant. */
.logo-mark {
  height: 22px;
  width: auto;
  opacity: .55;
  transition: opacity .18s ease;
}
.logo-mark.for-light { display: var(--logo-light); }
.logo-mark.for-dark  { display: var(--logo-dark); }
.logo:hover .logo-mark,
.logo:focus-visible .logo-mark { opacity: 1; }
.logo-text {
  font-weight: 750;
  font-size: 14px;
  letter-spacing: .6px;
}
.logo-text span { color: var(--mint); }
.logo-tool {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--faint);
}
.logo-tool::before { content: '/'; margin-inline-end: 8px; color: var(--line2); }
.head-right { display: flex; align-items: center; gap: 14px; }
.ts {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.lang-btn {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 650;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--line2);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.lang-btn:hover { border-color: var(--mint); color: var(--mint); }
/* Theme toggle — same pill language as .lang-btn, but icon-only and square. */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line2);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--mint); color: var(--mint); }
.icon-btn:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
.icon-btn svg { width: 15px; height: 15px; display: block; }
/* Show the icon for the theme you'd switch TO. */
.icon-btn .i-sun  { display: var(--logo-dark); }
.icon-btn .i-moon { display: var(--logo-light); }

/* ── Protocol stack: spine + layers ─────────────────────────
   The page is laid out as a packet dissection: each section is
   a protocol layer hanging off a vertical trace line. */
.stack { position: relative; }
.stack::before {
  content: '';
  position: absolute;
  inset-inline-start: 17px;
  top: 6px; bottom: 6px;
  width: 2px;
  background: linear-gradient(to bottom, var(--navy) 0%, var(--mint) 25%, var(--sky) 65%, transparent 100%);
  opacity: .45;
  transform-origin: top;
  animation: trace .9s ease both;
}
@keyframes trace { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.layer {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  margin-bottom: 26px;
}
.gutter { position: relative; padding-top: 4px; }
.node {
  position: absolute;
  inset-inline-start: 12px;
  top: 6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--mint);
}
.layer.l4 .node, .layer.l7 .node { border-color: var(--sky); }
.layer.api .node { border-color: var(--faint); border-radius: 3px; }
.layer.prv .node { border-color: var(--navy); }
.layer.prv[data-state="scanning"] .node { animation: pulse 1.2s ease-in-out infinite; }
.layer.prv[data-state="strong"]   .node { border-color: var(--mint); background: var(--mint); }
.layer.prv[data-state="moderate"] .node { border-color: var(--amber); background: var(--amber); }
.layer.prv[data-state="weak"]     .node { border-color: var(--red); background: var(--red); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 var(--pulse); } 50% { box-shadow: 0 0 0 6px var(--pulse-0); } }

.l-tag {
  position: absolute;
  inset-inline-start: 4px;
  top: 28px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--faint);
  letter-spacing: .5px;
  width: 28px;
  text-align: center;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--mint);
  margin-bottom: 12px;
}
.layer.l4 .eyebrow, .layer.l7 .eyebrow { color: var(--sky); }
.layer.api .eyebrow { color: var(--muted); }
.layer.prv .eyebrow { color: var(--navy); }

/* ── Hero (L3) ── */
.hero {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 30px 32px 28px;
  box-shadow: var(--shadow);
}
.ip-display {
  font-family: var(--mono);
  font-size: clamp(34px, 8vw, 64px);
  font-weight: 650;
  letter-spacing: -1px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
  margin-bottom: 14px;
}
.ip-display .dot { color: var(--mint); }
.ip-display.v6 { font-size: clamp(18px, 4.5vw, 32px); letter-spacing: 0; }

/* ── Country flag (L3 hero) ──
   Sized in em so it tracks both the v4 and v6 IP sizes. line-height:1 on an
   inline-block keeps the emoji out of the IP's line box, so it cannot change
   the hero's line height. .ip-display is dir="ltr", so the flag stays to the
   left of the IP in RTL too. */
.flag-wrap {
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
  margin-inline-end: .22em;
}
.flag {
  font-size: .62em;
  line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
/* Fallback for platforms that do not render regional-indicator pairs as flags
   (Windows). Styled like .badge.ver. Swapped in by app.js. */
.flag-code {
  display: none;
  font-family: var(--mono);
  font-size: .26em;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--mint);
  background: var(--mint-dim);
  padding: .3em .7em;
  border-radius: 999px;
  vertical-align: middle;
}
.flag-wrap.no-emoji .flag { display: none; }
.flag-wrap.no-emoji .flag-code { display: inline-block; }

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

.readouts {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px 18px;
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 12.5px;
}
.readout { color: var(--muted); }
.readout b { font-weight: 500; color: var(--faint); margin-inline-end: 7px; }
.badge {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 999px;
}
.badge.ver  { color: var(--mint); background: var(--mint-dim); }
.badge.tls  { color: var(--sky);  background: var(--sky-dim); }
.badge.host { color: var(--amber); background: var(--amber-dim); }

.geo-line {
  display: flex; flex-wrap: wrap; gap: 6px 22px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink);
  margin-bottom: 24px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.geo-item b { font-weight: 500; color: var(--faint); margin-inline-end: 7px; text-transform: lowercase; }
.geo-line.geo-off { color: var(--faint); }

.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 650;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid var(--line2);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: var(--mint); color: var(--mint); }
.btn.primary {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--on-navy);
}
.btn.primary:hover { background: var(--navy-hover); color: var(--on-navy); }
.btn svg { width: 14px; height: 14px; }
.btn:focus-visible, .lang-btn:focus-visible, .section-head:focus-visible, .cli-cmd:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 2px;
}

/* ── Cards (L4 / L7) ── */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: none; }
.kv-key { font-size: 13px; color: var(--muted); flex-shrink: 0; }
.kv-val {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  text-align: end;
  word-break: break-all;
  font-variant-numeric: tabular-nums;
}

/* ── PRV: privacy card ── */
.prv-card { padding: 24px 28px 22px; }
.prv-grid {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 18px 30px;
  align-items: start;
}
.gauge-wrap { position: relative; width: 168px; text-align: center; }
.gauge { width: 150px; height: 150px; display: block; margin: 0 auto; transform: rotate(-90deg); }
.gauge-track { fill: none; stroke: var(--line); stroke-width: 9; }
.gauge-arc {
  fill: none;
  stroke: var(--navy);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 326.7;         /* 2π·52 */
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset .9s cubic-bezier(.2,.7,.2,1), stroke .4s;
}
[data-state="strong"]   .gauge-arc { stroke: var(--mint); }
[data-state="moderate"] .gauge-arc { stroke: var(--amber); }
[data-state="weak"]     .gauge-arc { stroke: var(--red); }
[data-state="scanning"] .gauge-arc { stroke-dashoffset: 245; opacity: .35; animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); transform-origin: 60px 60px; } }
.gauge-num {
  position: absolute; top: 52px; left: 0; right: 0;
  font-family: var(--mono);
  font-size: 38px;
  font-weight: 650;
  letter-spacing: -1px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.gauge-num small { font-size: 14px; font-weight: 500; color: var(--faint); margin-inline-start: 2px; }
.gauge-status {
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
}
[data-state="strong"]   .gauge-status { color: var(--mint); }
[data-state="moderate"] .gauge-status { color: var(--amber); }
[data-state="weak"]     .gauge-status { color: var(--red); }

.checks { list-style: none; }
.check {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.check:last-child { border-bottom: none; }
.ck-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line2); justify-self: center; }
.check.pass .ck-dot { background: var(--mint); }
.check.info .ck-dot { background: var(--sky); }
.check.warn .ck-dot { background: var(--amber); }
.check.fail .ck-dot { background: var(--red); box-shadow: 0 0 0 3px var(--red-dim); }
.check.na   .ck-dot { background: var(--line2); }
.ck-name { color: var(--ink); }
.ck-val {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  text-align: end;
  word-break: break-all;
  max-width: 46ch;
}
.check.fail .ck-val { color: var(--red); }
.check.warn .ck-val { color: var(--amber); }
.check.na   .ck-val { color: var(--faint); }
.ck-sub { display: block; font-size: 11px; color: var(--faint); }
.prv-note { margin-top: 12px; font-size: 12.5px; color: var(--faint); }
.prv-note code { font-family: var(--mono); font-size: 12px; }

/* ── Headers table ── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 14px 24px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-family: var(--sans);
  text-align: start;
  color: var(--ink);
}
.section-head[aria-expanded="false"] { border-bottom-color: transparent; }
.section-title {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}
.section-title small { color: var(--faint); font-weight: 500; letter-spacing: .5px; text-transform: none; margin-inline-start: 6px; }
.chev { color: var(--faint); transition: transform .25s; font-size: 13px; }
.section-head[aria-expanded="false"] .chev { transform: rotate(-90deg); }

.headers-body { max-height: 1400px; overflow: hidden; transition: max-height .35s ease; }
.headers-body.hidden { max-height: 0; }
.h-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.h-row:last-child { border-bottom: none; }
.h-key {
  font-family: var(--mono);
  padding: 9px 24px;
  color: var(--sky);
  font-size: 12px;
  word-break: break-all;
  border-inline-end: 1px solid var(--line);
}
.h-val {
  font-family: var(--mono);
  padding: 9px 18px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

/* ── API / CLI reference ── */
.cli-note { font-size: 12px; color: var(--faint); font-weight: 500; }
.cli-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1px;
  background: var(--line);
}
.cli-card { background: var(--inset); padding: 15px 24px; }
.cli-label { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.cli-cmd {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  text-align: start;
  word-break: break-all;
  transition: color .15s;
}
.cli-cmd:hover { color: var(--mint); }
.cli-cmd .prompt { color: var(--mint); margin-inline-end: 6px; user-select: none; }

/* ── Footer ── */
footer {
  text-align: center;
  font-size: 12.5px;
  color: var(--faint);
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--mint); }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translate(-50%, 16px);
  background: var(--toast-bg);
  color: var(--toast-ink);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  box-shadow: var(--toast-shadow);
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ── Entrance ── */
.fade { animation: rise .45s ease both; }
.d1 { animation-delay: .08s; } .d2 { animation-delay: .18s; }
.d3 { animation-delay: .28s; } .d4 { animation-delay: .38s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .fade, .stack::before, .layer.prv .node, [data-state="scanning"] .gauge-arc { animation: none; }
  .headers-body, .gauge-arc { transition: none; }
}

@media (max-width: 640px) {
  .wrap { padding: 20px 14px 56px; }
  .layer { grid-template-columns: 34px minmax(0, 1fr); margin-bottom: 20px; }
  .stack::before { inset-inline-start: 8px; }
  .node { inset-inline-start: 3px; }
  .l-tag { display: none; }
  .hero { padding: 24px 20px 22px; }
  .card { padding: 16px 18px; }
  .prv-grid { grid-template-columns: 1fr; }
  .gauge-wrap { margin: 0 auto; }
  .check { grid-template-columns: 14px 1fr; }
  .ck-val { grid-column: 2; text-align: start; max-width: none; }
  .h-row { grid-template-columns: 1fr; }
  .h-key { border-inline-end: none; padding-bottom: 2px; }
  .h-val { padding-top: 2px; padding-inline-start: 24px; }
  .kv { flex-direction: column; gap: 0; }
  .kv-val { text-align: start; }
  .ts { display: none; }
  /* Let the header reflow instead of forcing the row wider than the viewport. */
  header { flex-wrap: wrap; }
  .logo { min-width: 0; }
  .logo-org { font-size: 10px; white-space: normal; }
}
