/* IPVitals layout and components. Colors come from brand.css (--iv-*), with fallbacks.
 * No inline styles anywhere: state is expressed through data attributes on <html> and <body>. */

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

:root {
  --bg: var(--iv-bg, #f4f8f6);
  --surface: var(--iv-surface, #fff);
  --fg: var(--iv-fg, #10231c);
  --muted: var(--iv-muted, #4a5f57);
  --border: var(--iv-border, #d3e0da);
  --accent: var(--iv-accent, #15654a);
  --accent-fg: var(--iv-accent-fg, #fff);
  --ok: var(--iv-ok, #157347);
  --warn: var(--iv-warn, #a15c00);
  --leak: var(--iv-leak, #b42318);
  --info: var(--iv-info, #1f6fb2);
  --ring: var(--iv-focus, #15654a);
  --radius: var(--iv-radius, 14px);
  --font: var(--iv-font, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
  --mono: var(--iv-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace);
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 var(--font);
}
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.25; }
code, .mono { font-family: var(--mono); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
/* 1px clip, not an off-screen offset: on right-to-left pages left:-9999px is scrollable overflow. */
.skip-link:not(:focus) {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link:focus { position: absolute; inset-inline-start: 8px; top: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; }

/* Header */
.site-header {
  position: relative; max-width: 1100px; margin: 0 auto; padding: 12px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
}
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); font-weight: 700; text-decoration: none; }
.brand .brand-name { font-size: 22px; letter-spacing: .2px; }
.brand .logo-dark { display: none; }
:root[data-theme="dark"] .brand .logo-light { display: none; }
:root[data-theme="dark"] .brand .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .logo-light { display: none; }
  :root:not([data-theme="light"]) .brand .logo-dark { display: block; }
}
.site-nav { display: flex; gap: 14px; flex-wrap: wrap; }
.site-nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.site-nav a[aria-current="page"], .site-nav a:hover { color: var(--fg); }
.header-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
/* The nav takes the second row so theme and language stay at the end of the first row.
 * At full width (1068px of content) brand + nav + tools fit one row in these languages
 * (measured 816-1040px); es/pt/id/fr/de/ar need 1064-1307px. In one row the nav shrinks
 * and scrolls rather than wrapping. */
.site-nav { order: 3; flex-basis: 100%; }
@media (min-width: 1100px) {
  :root:is([lang="en"], [lang="tr"], [lang="vi"], [lang="ru"], [lang="ja"], [lang="zh"],
    [lang="zh-hant"], [lang="th"]) .site-nav {
    order: 0; flex: 0 1 auto; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  }
  :root:is([lang="en"], [lang="tr"], [lang="vi"], [lang="ru"], [lang="ja"], [lang="zh"],
    [lang="zh-hant"], [lang="th"]) .site-nav a { white-space: nowrap; }
}

/* Header language menu (<details>: opens and switches without JS) */
.lang-menu { position: relative; flex: none; }
.lang-menu__btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px;
  font-size: 15px; font-weight: 600; color: var(--fg); white-space: nowrap; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  list-style: none; user-select: none;
}
.lang-menu__btn::-webkit-details-marker { display: none; }
.lang-menu__btn:hover, .lang-menu[open] .lang-menu__btn { border-color: var(--muted); }
.lang-menu__short { display: none; }
.lang-menu__caret { transition: transform .2s; }
.lang-menu[open] .lang-menu__caret { transform: rotate(180deg); }
.lang-menu__list {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: max-content; gap: 2px;
  margin: 0; padding: 8px; list-style: none; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}
.lang-menu__list a {
  display: block; padding: 8px 14px; border-radius: 8px;
  color: var(--fg); white-space: nowrap; text-decoration: none;
}
.lang-menu__list a:hover { background: var(--bg); }
.lang-menu__list a[aria-current="true"] { font-weight: 700; color: var(--accent); background: var(--bg); }
/* Right-to-left pages: addresses and numbers stay left-to-right but keep the page's alignment. */
:root[dir="rtl"] dd[dir="ltr"], :root[dir="rtl"] .ip-big[dir="ltr"] { text-align: right; }

/* Buttons and fields */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--fg);
  padding: 8px 14px; min-height: 40px;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--fg); padding: 6px 10px; }
.btn-ghost:hover { border-color: var(--border); }

input[type="text"] {
  font: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; min-height: 40px; width: 100%;
}

/* Layout */
main { max-width: 1100px; margin: 0 auto; padding: 8px 16px 40px; }
.tool { margin: 8px 0 32px; }
.tool-title { margin: 8px 0 4px; font-size: clamp(26px, 4vw, 38px); }
.lead { color: var(--muted); font-size: 18px; max-width: 65ch; }
.page-head h1 { font-size: clamp(26px, 4vw, 38px); margin: 16px 0 4px; }
.content { max-width: 760px; }
.content section { margin: 28px 0; }
.content h2 { margin-bottom: 8px; }
.content ul, .content ol { padding-left: 22px; }
.content li { margin: 4px 0; }
.links { list-style: none; padding-left: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.hint { color: var(--muted); font-size: 14px; }
.error { color: var(--leak); font-weight: 600; }

/* FAQ */
.faq details { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin: 8px 0; }
.faq summary { cursor: pointer; font-weight: 600; padding: 10px 14px; }
.faq p { margin: 0; padding: 0 14px 12px; }

/* Home */
.ip-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin: 18px 0; text-align: center;
}
.ip-label { margin: 0; color: var(--muted); font-weight: 600; }
.ip-big {
  font-family: var(--mono); font-size: clamp(24px, 5vw, 42px); font-weight: 700;
  margin: 6px 0 12px; overflow-wrap: normal;
}
.ip-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.ipv6-status { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.ipv6-status[data-state="available"] { color: var(--ok); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 24px; margin: 18px 0; }
.detail-grid .row { border-bottom: 1px solid var(--border); padding: 6px 0; min-width: 0; }
.detail-grid dt { color: var(--muted); font-size: 14px; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; }
.ip-row dd { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
/* Addresses break only after their <wbr> points (IPv6 colons), never mid-group. */
.addr { overflow-wrap: normal; }
@media (min-width: 900px) { .detail-grid .ipv6 { grid-column: span 2; } }
.btn-icon { min-width: 40px; padding: 8px 10px; }
.theme-icon { font-size: 18px; line-height: 1; }
dd.mono, .detail-grid dd { font-variant-numeric: tabular-nums; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin: 16px 0; }
.card > h2 { margin-top: 0; font-size: 20px; }
.verdict { font-weight: 700; }
.verdict[data-verdict="ok"] { color: var(--ok); }
.verdict[data-verdict="warning"] { color: var(--warn); }
.verdict[data-verdict="leak"] { color: var(--leak); }
.verdict[data-verdict="unknown"], .verdict[data-verdict="pending"] { color: var(--muted); }

.findings { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.finding { border-left: 4px solid var(--border); padding: 4px 0 4px 10px; }
.finding-title { display: block; }
.finding-detail { display: block; color: var(--muted); font-size: 15px; }
.finding-ok { border-left-color: var(--ok); }
.finding-info { border-left-color: var(--info); }
.finding-warning { border-left-color: var(--warn); }
.finding-leak { border-left-color: var(--leak); }

/* IPv6 test and ISP pages */
.verdict-big { font-family: var(--font); overflow-wrap: anywhere; }
.verdict-big[data-state="available"] { color: var(--ok); }
.verdict-big[data-state="not-detected"] { color: var(--warn); }
.verdict-big[data-state="unknown"], .verdict-big[data-state="pending"] { color: var(--muted); }
.isp-big { font-family: var(--font); overflow-wrap: anywhere; }

/* Breadcrumb */
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 0; padding: 0; font-size: 14px; color: var(--muted); }
.breadcrumb li + li::before { content: "›"; margin-right: 4px; }
.breadcrumb a { color: var(--muted); }

/* Lookup */
.lookup-form label { display: block; font-weight: 600; margin-bottom: 6px; }
.lookup-row { display: flex; gap: 10px; flex-wrap: wrap; }
.lookup-row input { flex: 1 1 260px; max-width: 420px; }
.result[data-state="loading"] { opacity: .7; }
.result h3 { margin-bottom: 0; }
.status { color: var(--muted); }

/* Leak */
.candidates { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.candidates li { font-family: var(--mono); border-bottom: 1px solid var(--border); padding: 6px 0; overflow-wrap: anywhere; }
.candidates .cand-type { font-family: var(--font); color: var(--muted); font-size: 14px; margin-right: 8px; }
.candidates .cand-addr { overflow-wrap: normal; }
.candidates li.empty { font-family: var(--font); color: var(--muted); }

/* Toast and clipboard helper */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--fg); color: var(--bg); border-radius: 10px; padding: 10px 16px;
  max-width: 90vw; box-shadow: 0 6px 24px rgb(0 0 0 / .25); z-index: 20;
}
.copy-helper { position: fixed; left: -9999px; top: 0; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 40px; }
.lang-switch { margin: 0 0 14px; }
.lang-switch summary {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 6px 14px; min-height: 38px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg); color: var(--fg); font-weight: 600; list-style: none;
}
.lang-switch summary::-webkit-details-marker { display: none; }
.lang-switch summary:hover { border-color: var(--muted); }
.lang-globe { flex: none; }
.lang-switch ul { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 12px 0 2px; padding: 0; list-style: none; }
.lang-switch li { margin: 0; }
.lang-switch a { display: inline-block; padding: 4px 2px; color: var(--muted); text-decoration: none; }
.lang-switch a:hover { color: var(--fg); }
.lang-switch a[aria-current="true"] { color: var(--fg); font-weight: 700; }
.footer-inner { max-width: 1100px; margin: 0 auto; padding: 20px 16px 32px; color: var(--muted); font-size: 15px; }
.footer-inner nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; }
.footer-inner p { margin: 6px 0; }
.footer-note { font-weight: 600; }

@media (max-width: 600px) {
  .site-header {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand tools" "nav nav";
    align-items: center; gap: 6px 12px; padding: 8px 12px;
  }
  .brand { grid-area: brand; }
  .header-tools { grid-area: tools; margin-inline-start: 0; }
  .site-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav { grid-area: nav; gap: 12px; font-size: 15px; padding-inline-end: 28px; }
  .site-nav a { white-space: nowrap; }
  /* Fade the right edge instead of cutting the last item in half. */
  .site-nav {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  :root[dir="rtl"] .site-nav {
    -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent);
  }
  .lang-menu { position: static; }
  .lang-menu__btn { gap: 5px; padding: 0 10px; }
  .lang-menu__name {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .lang-menu__short { display: inline; }
  .lang-menu__list {
    top: 100%; inset-inline: 0; width: auto; padding: 8px 12px 12px;
    border-inline: 0; border-radius: 0; box-shadow: 0 8px 16px rgba(0, 0, 0, .08);
  }
  .lang-menu__list a { padding: 12px 14px; }
  .theme-label { display: none; }
  main { padding: 0 12px 32px; }
  .tool-title { font-size: 24px; margin: 6px 0 2px; }
  .lead { font-size: 16px; }
  .ip-card { margin: 10px 0; padding: 14px; }
  .ip-big { font-size: 24px; margin: 4px 0 8px; }
}

.content, .content p, .content li, main a {
  overflow-wrap: anywhere;
  word-break: break-word;
}
