/* whatismyipaddressip.com: shared styles for the IP checker and the blog.
   Apple-style grouped surfaces, with glass only on the sticky nav and the IP card.
   Light/dark follows the system. Token names (--bg, --surface, --border, --text,
   --muted, --accent, --accent-dim) are used inline in blog posts, so keep them. */

/* Tokens */
:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --border: rgba(60, 60, 67, 0.16);
  --separator: rgba(60, 60, 67, 0.18);
  --text: #1c1c1e;
  --muted: #5d5d63;
  --accent: #0064d2;
  --accent-hover: #0057b8;
  --accent-dim: rgba(0, 100, 210, 0.1);
  --on-accent: #ffffff;
  --danger: #c4001a;
  --glass: rgba(242, 242, 247, 0.74);
  --glass-card: rgba(255, 255, 255, 0.64);
  --glass-edge: rgba(255, 255, 255, 0.85);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 32px -14px rgba(0, 0, 0, 0.14);
  --glow-a: rgba(0, 122, 255, 0.16);
  --glow-b: rgba(88, 86, 214, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --column: 42rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(118, 118, 128, 0.36);
    --border: rgba(84, 84, 88, 0.6);
    --separator: rgba(84, 84, 88, 0.55);
    --text: #f5f5f7;
    --muted: #a1a1a8;
    --accent: #4aa3ff;
    --accent-hover: #6cb4ff;
    --accent-dim: rgba(74, 163, 255, 0.16);
    --on-accent: #001a33;
    --danger: #ff6b6b;
    --glass: rgba(18, 18, 20, 0.72);
    --glass-card: rgba(44, 44, 48, 0.55);
    --glass-edge: rgba(255, 255, 255, 0.1);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -16px rgba(0, 0, 0, 0.7);
    --glow-a: rgba(10, 132, 255, 0.22);
    --glow-b: rgba(94, 92, 230, 0.16);
  }
}

@media (prefers-contrast: more) {
  :root {
    --muted: #3a3a3f;
    --border: rgba(60, 60, 67, 0.5);
    --separator: rgba(60, 60, 67, 0.45);
    --accent: #0050a8;
    --glass: #f2f2f7;
    --glass-card: #ffffff;
  }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root {
    --muted: #c7c7cc;
    --border: rgba(235, 235, 245, 0.45);
    --separator: rgba(235, 235, 245, 0.4);
    --accent: #7cc0ff;
    --glass: #000000;
    --glass-card: #1c1c1e;
  }
}

/* Base */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  caret-color: var(--accent);
  accent-color: var(--accent);
  font-feature-settings: "kern";
}

::selection { background: var(--accent-dim); color: inherit; }

a {
  color: var(--accent);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 0.2em;
  transition: color 160ms var(--ease), text-decoration-color 160ms var(--ease);
}
a:hover { color: var(--accent-hover); text-decoration-color: currentColor; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
  border-radius: 6px;
}

strong { font-weight: 600; color: var(--text); }
em { font-style: italic; }

/* Glass navigation bar */
.site-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 3.25rem;
  padding: 0.25rem max(0.5rem, calc((100% - var(--column)) / 2 - 0.5rem));
  padding-top: max(0.25rem, env(safe-area-inset-top));
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0.5px 0 var(--separator);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-topbar { background: var(--bg); }
}

.site-topbar .nav-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.625rem;
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 1.0625rem;
  font-weight: 400;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
.site-topbar .nav-btn:first-child {
  margin-right: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.site-topbar .nav-btn:first-child::before {
  content: "";
  flex: none;
  width: 22px;
  height: 22px;
  margin-right: 0.5rem;
  border-radius: 6px;
  background: var(--accent) center / 14px 14px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21s-7-6.1-7-11.5A7 7 0 0 1 19 9.5C19 14.9 12 21 12 21z'/%3E%3Ccircle cx='12' cy='9.5' r='2.5'/%3E%3C/svg%3E");
}
.site-topbar .nav-btn:hover { background: var(--fill); }
.site-topbar .nav-btn:active { background: var(--fill-strong); }
.site-topbar .nav-btn[aria-current="page"]:not(:first-child) { font-weight: 600; }

/* Reading column (blog) */
.wrap {
  max-width: calc(var(--column) + 2rem);
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--text);
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.875rem, 1.4rem + 2vw, 2.5rem);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0.5rem 0 1rem;
}

h2 {
  font-size: clamp(1.3125rem, 1.15rem + 0.6vw, 1.5rem);
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 2.5rem 0 0.75rem;
}

h3 {
  font-size: 1.125rem;
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 1.75rem 0 0.5rem;
}

p { margin: 0 0 1rem; text-wrap: pretty; }
ul, ol { margin: 0 0 1.25rem; padding-left: 1.4rem; }
li { margin: 0 0 0.45rem; }
li::marker { color: var(--muted); }

.crumb {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--accent); }

.lede {
  font-size: 1.1875rem;
  line-height: 1.5;
  color: var(--muted);
  margin: 0 0 1.75rem;
}

/* Callout cards */
.direct,
.tldr,
.pick {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  margin: 0 0 1.5rem;
}
.direct { font-size: 1.0625rem; }
.direct strong:first-child,
.tldr strong:first-child {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  color: var(--accent);
}
.tldr { background: var(--accent-dim); }
.tldr > :last-child,
.direct > :last-child,
.pick > :last-child { margin-bottom: 0; }
.pick strong { display: block; margin-bottom: 0.3rem; color: var(--text); font-size: 1.0625rem; }
.pick p { margin: 0; color: var(--muted); font-size: 0.9875rem; }

.highlight {
  font-family: var(--mono);
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* Steps */
ol.steps {
  counter-reset: s;
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
}
ol.steps li {
  counter-increment: s;
  position: relative;
  margin: 0;
  padding: 0.875rem 1.125rem 0.875rem 3.5rem;
}
ol.steps li + li::after {
  content: "";
  position: absolute;
  top: 0;
  left: 3.5rem;
  right: 0;
  height: 1px;
  background: var(--separator);
}
ol.steps li::before {
  content: counter(s);
  position: absolute;
  left: 1.125rem;
  top: 0.9rem;
  display: grid;
  place-items: center;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.875rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0 0 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.9375rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
th,
td {
  padding: 0.7rem 0.875rem;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  border-bottom: 1px solid var(--separator);
}
th {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--fill);
}
td { color: var(--text); }
tr:last-child td { border-bottom: 0; }

/* Code */
pre {
  margin: 0 0 1.5rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
}
code { font-family: var(--mono); font-size: 0.9em; }

/* Blog index: inset grouped list */
ul.posts {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}
ul.posts li { position: relative; margin: 0; }
ul.posts li + li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 1rem;
  right: 0;
  height: 1px;
  background: var(--separator);
}
ul.posts a {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-height: 44px;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  text-decoration: none;
  color: var(--text);
  transition: background-color 160ms var(--ease);
}
ul.posts a::after {
  content: "";
  position: absolute;
  right: 1rem;
  top: 50%;
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--muted);
  border-right: 2px solid var(--muted);
  transform: translateY(-50%) rotate(45deg);
  opacity: 0.7;
}
ul.posts a:hover { background: var(--fill); }
ul.posts a:active { background: var(--fill-strong); }
ul.posts a:focus-visible { outline-offset: -3px; border-radius: 0; }
ul.posts a strong { font-size: 1.0625rem; font-weight: 600; line-height: 1.35; }
ul.posts a span { font-size: 0.9375rem; line-height: 1.45; color: var(--muted); }

/* Footer */
footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--separator);
  font-size: 0.875rem;
  color: var(--muted);
}
footer a { color: var(--accent); }

/* Home: IP checker */
.home {
  max-width: calc(var(--column) + 2rem);
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}
.home-bg {
  background:
    radial-gradient(60rem 28rem at 15% -6rem, var(--glow-a), transparent 70%),
    radial-gradient(44rem 24rem at 95% 2rem, var(--glow-b), transparent 70%),
    var(--bg);
  background-repeat: no-repeat;
}

.page-header h1 { margin: 0.25rem 0 0.5rem; }
.subtitle {
  margin: 0 0 1.5rem;
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--muted);
  max-width: 36rem;
}

.ip-card {
  position: relative;
  padding: 1.25rem 1.25rem 1.125rem;
  border-radius: 22px;
  background: var(--glass-card);
  -webkit-backdrop-filter: saturate(170%) blur(24px);
  backdrop-filter: saturate(170%) blur(24px);
  box-shadow: inset 0 0 0 1px var(--glass-edge), var(--shadow-card);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .ip-card { background: var(--surface); }
}

.ip-card .label {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--muted);
}

.ip-stack { display: grid; gap: 0.875rem; }
.ip-row { display: grid; gap: 0.25rem; min-width: 0; }
.ip-kind {
  justify-self: start;
  padding: 0.0625rem 0.5rem;
  border-radius: 6px;
  background: var(--fill);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ip-display {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums slashed-zero;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
  line-height: 1.2;
  min-height: 1.2em;
}
#ipv4.ip-display { font-size: clamp(1.75rem, 1.2rem + 3vw, 2.5rem); letter-spacing: -0.02em; }
#ipv6.ip-display { font-size: clamp(1rem, 0.9rem + 0.5vw, 1.1875rem); }

.ip-display.loading {
  color: transparent;
  width: min(15ch, 100%);
  border-radius: 8px;
  background: var(--fill);
  animation: skeleton 1.4s ease-in-out infinite;
  user-select: none;
}
#ipv6.ip-display.loading { width: min(28ch, 100%); }
.ip-display.na {
  font-family: var(--font);
  font-size: 1rem !important;
  font-weight: 400;
  letter-spacing: 0 !important;
  color: var(--muted);
}
.ip-display.error {
  font-family: var(--font);
  font-size: 1rem !important;
  font-weight: 500;
  letter-spacing: 0 !important;
  color: var(--danger);
}

@keyframes skeleton {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin-top: 1.25rem;
}

.btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 1.25rem;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 160ms var(--ease), color 160ms var(--ease), transform 160ms var(--ease), opacity 160ms var(--ease);
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:active:not([disabled]) { transform: scale(0.97); }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn:focus-visible { border-radius: 999px; }

.btn-primary { background: var(--accent); color: var(--on-accent); flex: 1 1 10rem; }
.btn-primary:hover:not([disabled]) { background: var(--accent-hover); }
.btn-primary.is-done { background: #1f8a3d; color: #fff; }

.btn-tinted { background: var(--accent-dim); color: var(--accent); }
.btn-tinted:hover:not([disabled]) { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.btn-tinted[aria-busy="true"] svg { animation: spin 0.9s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Location: inset grouped list */
.geo-grid { margin-top: 1.75rem; display: grid; gap: 1rem; }
.geo-card h2 {
  margin: 0 0 0.375rem 1rem;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--muted);
}
.geo-card .rows {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}
.geo-card .row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 44px;
  padding: 0.625rem 1rem;
}
.geo-card .row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 1rem;
  right: 0;
  height: 1px;
  background: var(--separator);
}
.geo-card .k { color: var(--text); flex: none; }
.geo-card .v {
  min-width: 0;
  text-align: right;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.geo-card.loading .v {
  color: transparent;
  min-width: 8rem;
  border-radius: 6px;
  background: var(--fill);
  animation: skeleton 1.4s ease-in-out infinite;
  user-select: none;
}
.geo-empty {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9375rem;
}

.hint {
  margin: 0.75rem 1rem 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--muted);
}

/* Home: guides and FAQ */
.home-section { margin-top: 2.75rem; }
.home-section > h2 { margin: 0 0 0.75rem; }
.home-section > p { color: var(--muted); }

.faq details {
  background: var(--surface);
  position: relative;
}
.faq details:first-of-type { border-radius: var(--radius) var(--radius) 0 0; }
.faq details:last-of-type { border-radius: 0 0 var(--radius) var(--radius); }
.faq details + details::before {
  content: "";
  position: absolute;
  top: 0;
  left: 1rem;
  right: 0;
  height: 1px;
  background: var(--separator);
}
.faq summary {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0.75rem 2.75rem 0.75rem 1rem;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  list-style: none;
  border-radius: inherit;
  transition: background-color 160ms var(--ease);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "";
  position: absolute;
  right: 1.125rem;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  transition: transform 200ms var(--ease);
}
.faq details[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
.faq summary:hover { background: var(--fill); }
.faq summary:focus-visible { outline-offset: -3px; }
.faq details p {
  margin: 0;
  padding: 0 1rem 1rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}
.faq details p strong { color: var(--text); }

.home footer { text-align: center; }

/* Preferences */
@media (prefers-reduced-transparency: reduce) {
  .site-topbar { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .ip-card { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 30rem) {
  body { font-size: 1.0625rem; }
  .ip-card { padding: 1.125rem 1rem 1rem; border-radius: 20px; }
  .site-topbar .nav-btn { padding: 0 0.5rem; }
  table { font-size: 0.875rem; }
  th, td { padding: 0.6rem 0.65rem; }
}

@media print {
  .site-topbar, .ipbar, .actions { display: none; }
  body { background: #fff; color: #000; }
}
