/* ============================================================================
   DESIGN_GUIDE.md v3 — official brand palette + typography.
   Corrects Step 1's placeholder palette. Loaded AFTER style.css so values win.

   Brand: Vibrant Blue #1D70B8, Deep Teal #008080, Dark Navy #1A237E.
   Accent shades verified with a WCAG AA contrast audit (see outputs/59):
     - dark --accent #3D8FD6 (lightened Vibrant Blue): link text 5.15-5.60:1
     - --accent-strong #1D70B8 (true brand): white button text 5.17:1
     - --accent-secondary #1FA3A3 (dark): text/outline/highlight ONLY — white
       text on a #1FA3A3 fill is 3.08:1 (fails), so never fill+white with it.
   ============================================================================ */

/* ---- v3 canonical tokens ---- */
:root {
    --bg-primary: #0A0E17;
    --bg-surface: #121826;
    --bg-surface-raised: #1A2236;
    --text-primary: #EDEFF3;
    --text-muted: #8B93A7;
    --accent: #3D8FD6;            /* links/focus/borders/active — lightened for AA on dark */
    --accent-strong: #1D70B8;     /* button fills (white text 5.17:1) — true Vibrant Blue */
    --accent-strong-hover: #1558A0; /* button-fill HOVER (white 7.15:1). NOT --accent-hover:
                                       dark --accent-hover #5AA8E8 fails white-text AA (2.56:1) */
    --accent-hover: #5AA8E8;      /* link hover (lighter) — links only, never a white-text fill */
    --accent-secondary: #1FA3A3;  /* secondary emphasis; text/outline only, not white-fill */
    --border-color: #232B3D;
    --status-success: #3DD68C;
    --status-warning: #F5B84C;
    --status-danger: #F0555A;

    /* legacy template tokens remapped to v3 (dark) */
    --primary-bg-color: #0A0E17;
    --secondary-bg-color: #121826;
    --tertiary-bg-color: #1A2236;
    --primary-color: #EDEFF3;
    --secondary-color: #8B93A7;
    --tertiary-color: #3D8FD6;
    --quaternary-color: rgba(29, 112, 184, 0.18);
    --title-font-color: #EDEFF3;
}

:root[data-theme="light"] {
    --bg-primary: #F7F9FC;
    --bg-surface: #FFFFFF;
    --bg-surface-raised: #FFFFFF;
    --text-primary: #1A237E;      /* Dark Navy, per brand */
    --text-muted: #5C6478;
    --accent: #1D70B8;            /* Vibrant Blue — 5.17:1 as text on white */
    --accent-strong: #1D70B8;     /* white button text 5.17:1 */
    --accent-strong-hover: #1558A0;
    --accent-hover: #1558A0;
    --accent-secondary: #008080;  /* Deep Teal — white-fill 4.77:1 ok in light */
    --border-color: #E4E7EE;
    --status-success: #157A4A;   /* darkened for AA as small text on white (5.36:1) */
    --status-warning: #8A5A00;   /* darkened for AA (5.93:1) */
    --status-danger: #C1272D;    /* darkened for AA headroom on badge tint (5.84:1) */

    /* legacy remap (light) */
    --primary-bg-color: #F7F9FC;
    --secondary-bg-color: #FFFFFF;
    --tertiary-bg-color: #EFF2F7;
    --primary-color: #1A237E;
    --secondary-color: #5C6478;
    --tertiary-color: #1D70B8;
    --quaternary-color: rgba(29, 112, 184, 0.12);
    --title-font-color: #1A237E;
}

/* ---- Typography: Poppins (headings/UI) + Nunito (body) + monospace ---- */
/* #68: set the PAGE background + default text color from theme tokens. Nothing else
   targets `body` background — Bootstrap's Reboot `body{background-color:#fff;color:#212529}`
   was the only rule, so the page was white in every theme and dark-theme page-level
   text (which sits directly on `body` in the rebuilt homepage) washed out. theme.css
   now loads after bootstrap (see header.ejs), so this wins. */
body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}
h1, h2, h3, h4, h5, h6,
.navbar, .nav-link, .dropdown-toggle, .dropdown-item,
button, .btn, .theme-toggle, label {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
code, kbd, samp, pre, .mono {
    font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
}

/* ---- Nav logo sizing (new brand mark aspect ratio) ---- */
.navbar-brand img { height: 44px; width: auto; }
/* #68: inlined horizontal logo. color drives the wordmark's currentColor so it
   flips with the theme (Dark Navy in light mode, near-white in dark). */
.navbar-brand.nav-logo { color: var(--text-primary); display: inline-flex; align-items: center; }
.navbar-brand.nav-logo svg { height: 34px; width: auto; display: block; }

/* ---- Theme toggle button (nav) ---- */
.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    padding: 2px 10px;
    line-height: 1.6;
}
.theme-toggle:hover { color: var(--accent); }

/* ============================================================================
   v2 STEP 2 — Partial: Header / nav (feat/57), palette-corrected to v3
   ============================================================================ */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: transparent;
    border-bottom: 1px solid transparent;
    transition: background 200ms ease-out, box-shadow 200ms ease-out, border-color 200ms ease-out;
    padding-top: 12px;
    padding-bottom: 12px;
}
.navbar.nav-scrolled {
    background: rgba(10, 14, 23, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom-color: var(--border-color);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}
:root[data-theme="light"] .navbar.nav-scrolled {
    background: rgba(247, 249, 252, 0.82);
    box-shadow: 0 2px 12px rgba(20, 24, 35, 0.06);
}
.navbar .nav-link,
.navbar .dropdown-toggle {
    color: var(--text-muted) !important;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: color 150ms ease-out;
}
.navbar .nav-link:hover,
.navbar .nav-link.active,
.navbar .dropdown-toggle:hover {
    color: var(--text-primary) !important;
}
.dropdown-menu {
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
    padding: 8px;
    margin-top: 8px;
}
:root[data-theme="light"] .dropdown-menu { box-shadow: 0 8px 28px rgba(20, 24, 35, 0.12); }
.dropdown-menu .dropdown-item {
    color: var(--text-muted);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.9375rem;
}
.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus {
    background: rgba(29, 112, 184, 0.14);
    color: var(--text-primary);
}
.dropdown-menu .dropdown-divider { border-top-color: var(--border-color); }

/* ---- v2 STEP 2 — Partial: Footer (feat/58) ---- */
.footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 48px 0 32px;
    margin-top: 64px;
}
.footer h4, .footer .quick { color: var(--text-primary); font-size: 1rem; font-weight: 600; }
.footer h6 { color: var(--text-muted); font-size: 0.8125rem; font-weight: 400; }
.footer a { color: var(--text-muted); text-decoration: none; transition: color 150ms ease-out; }
.footer a:hover { color: var(--accent); }
.footer .footer-links li { list-style: none; }

/* ---- Internet Speed Test page (#55, palette-corrected to v3) ---- */
.speedtest-page { font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; padding: 64px 0; }
.speedtest-page .st-wrap { max-width: 720px; margin: 0 auto; }
.speedtest-page .st-header { text-align: center; margin-bottom: 32px; }
.speedtest-page .st-header h1 { font-family: 'Poppins', sans-serif; font-size: 2.25rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); line-height: 1.2; margin: 0; }
.speedtest-page .st-sub { color: var(--text-muted); font-size: 1rem; line-height: 1.6; margin-top: 8px; }
.speedtest-page .st-card { background: var(--bg-surface); border-radius: 20px; padding: 40px 32px; box-shadow: 0 4px 24px rgba(0,0,0,0.35); text-align: center; }
:root[data-theme="light"] .speedtest-page .st-card { box-shadow: 0 2px 12px rgba(20,24,35,0.06); border: 1px solid var(--border-color); }
.speedtest-page .st-btn { background: var(--accent-strong); color: #fff; border: none; border-radius: 8px; padding: 12px 28px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: background 150ms ease-out, opacity 150ms ease-out; }
.speedtest-page .st-btn:hover { background: #1558A0; }
.speedtest-page .st-btn:disabled { opacity: 0.6; cursor: default; }
.speedtest-page .st-status { color: var(--text-muted); font-size: 0.8125rem; margin: 16px 0 24px; }
.speedtest-page .st-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (min-width: 576px) { .speedtest-page .st-grid { grid-template-columns: repeat(4, 1fr); } }
.speedtest-page .st-stat { background: var(--bg-surface-raised); border-radius: 12px; padding: 20px 12px; }
:root[data-theme="light"] .speedtest-page .st-stat { background: var(--bg-primary); }
.speedtest-page .st-label { color: var(--text-muted); font-size: 0.8125rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.speedtest-page .st-value { color: var(--text-primary); font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace; font-size: 1.25rem; font-weight: 600; margin-top: 8px; }
.speedtest-page .st-note { color: var(--text-muted); font-size: 0.8125rem; text-align: center; margin-top: 24px; line-height: 1.6; }

/* ---- v2/v3 STEP 2 — Tool-card component (feat/60), reused on /tools + homepage ---- */
.tool-card {
    display: block;
    background: var(--bg-surface);
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 24px;
    height: 100%;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.20);
    transition: transform 150ms ease-out, box-shadow 150ms ease-out, border-color 150ms ease-out;
}
.tool-card:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35); border-color: var(--border-color); }
:root[data-theme="light"] .tool-card { box-shadow: 0 1px 3px rgba(20, 24, 35, 0.06); }
:root[data-theme="light"] .tool-card:hover { box-shadow: 0 8px 28px rgba(20, 24, 35, 0.12); }
.tool-card h3, .tool-card h5 { font-family: 'Poppins', sans-serif; font-size: 1.125rem; font-weight: 600; color: var(--text-primary); margin: 0 0 6px; }
.tool-card p { color: var(--text-muted); font-size: 0.9375rem; line-height: 1.5; margin: 0; }
.tool-card:hover h3 a, .tool-card:hover h5 a { color: var(--accent); }
.tool-card a { text-decoration: none; color: inherit; }

/* ---- v2/v3 STEP 2 — Results-table component (feat/61) ---- */
.table {
    --bs-table-color: var(--text-primary);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--border-color);
    color: var(--text-primary);
}
.table thead th {
    color: var(--text-muted);
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 16px;
}
.table tbody td, .table tbody th {
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
    vertical-align: middle;
}
.table th { color: var(--text-muted); font-weight: 600; }
.table td { color: var(--text-primary); }
.table code { color: var(--text-primary); }

/* ---- v2/v3 STEP 2 — Buttons (feat/62) ---- */
.btn { border-radius: 8px; font-family: 'Poppins', sans-serif; font-weight: 600; transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out, opacity 150ms ease-out; }
.btn:active { transform: translateY(1px); }
/* Primary: solid --accent-strong fill, white text, hover darkens (AA-safe) */
.btn-primary { background-color: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active { background-color: var(--accent-strong-hover); border-color: var(--accent-strong-hover); color: #fff; }
/* Secondary / outline: transparent bg, border, primary text */
.btn-outline-secondary { background-color: transparent; border-color: var(--border-color); color: var(--text-primary); }
.btn-outline-secondary:hover, .btn-outline-secondary:focus { background-color: rgba(29,112,184,0.10); border-color: var(--accent); color: var(--text-primary); }
.btn-outline-primary { background-color: transparent; border-color: var(--accent); color: var(--accent); }
.btn-outline-primary:hover, .btn-outline-primary:focus { background-color: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-outline-danger { background-color: transparent; border-color: var(--status-danger); color: var(--status-danger); }
.btn-outline-danger:hover, .btn-outline-danger:focus { background-color: var(--status-danger); color: #fff; }

/* ---- v2/v3 STEP 2 — Form inputs (feat/63) ---- */
.form-control, .form-select {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 10px 14px;
}
.form-control:focus, .form-select:focus {
    background-color: var(--bg-surface);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(29, 112, 184, 0.18);
    outline: none;
}
.form-control::placeholder { color: var(--text-muted); opacity: 1; }
.form-label { color: var(--text-muted); font-size: 0.8125rem; font-weight: 500; }
/* template search box (home/whois/port): colors + focus only, keep its shape */
.search_input {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.search_input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 112, 184, 0.18); outline: none; }
.search_input::placeholder { color: var(--text-muted); opacity: 1; }

/* ---- v2/v3 STEP 2 — Status badges (feat/64). Pill: soft status tint + colored
   label (color + text, never color alone). --accent-secondary is NOT used as a
   fill here (dark #1FA3A3 fails white-fill AA). ---- */
.status-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 999px;
    font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 0.8125rem; line-height: 1.4;
}
.status-badge.is-success { background: rgba(61, 214, 140, 0.15); color: var(--status-success); }
.status-badge.is-danger  { background: rgba(240, 85, 90, 0.15);  color: var(--status-danger); }
.status-badge.is-warning { background: rgba(245, 184, 76, 0.15); color: var(--status-warning); }
.status-badge.is-muted   { background: rgba(139, 147, 167, 0.15); color: var(--text-muted); }

/* ============================================================================
   v3 STEP 3 — Homepage rebuild (feat/65), per DESIGN_GUIDE.md §6b.
   Uses only already-audited tokens (no new color pairings). Reuses the Step-2
   .tool-card, .table and .btn components.
   ============================================================================ */
.home section { position: relative; }
.home-hero { padding: 56px 0 40px; }
.home-hero-head { text-align: center; max-width: 720px; margin: 0 auto 28px; }
.home-hero-head h1 { font-size: 2.5rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); line-height: 1.15; margin: 0 0 12px; }
.home-hero-head .lead { color: var(--text-muted); font-size: 1.0625rem; line-height: 1.6; margin: 0; }

/* Search bar (keeps .search_input / .search_icon hooks) */
.home-search { position: relative; max-width: 620px; margin: 0 auto 40px; }
.home-search .search_input { width: 100%; border-radius: 999px; padding: 15px 56px 15px 22px; font-size: 1.0625rem; }
.home-search .search_icon { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border: none; border-radius: 999px; background: var(--accent-strong); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 150ms ease-out; }
.home-search .search_icon:hover { background: var(--accent-strong-hover); }
.home-search .error-msg { position: absolute; left: 22px; bottom: -26px; margin: 0; color: var(--status-danger); font-size: 0.875rem; opacity: 0; }

/* Loader / error overlays over the hero block */
.home .address-content { min-height: 260px; }
.home .address-content-loader,
.home .address-content-error { position: absolute; inset: 0; z-index: 3; align-items: center; justify-content: center; background: var(--bg-primary); border-radius: 20px; }
.home .address-content-loader { display: flex; }
.home .address-content-error { display: none; }
.home .address-content-error p { color: var(--status-danger); font-size: 1rem; margin: 0; text-align: center; padding: 0 24px; }

/* Hero layout: card + info panel/map */
.hero-ip-layout { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 24px; align-items: start; }
.hero-ip-card { background: var(--bg-surface-raised); border: 1px solid var(--border-color); border-radius: 20px; padding: 32px; box-shadow: 0 8px 32px rgba(0,0,0,0.35); }
:root[data-theme="light"] .hero-ip-card { box-shadow: 0 4px 20px rgba(20,24,35,0.08); }
.hero-eyebrow { font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 4px; }
.hero-query-sub { color: var(--text-primary); font-size: 1.125rem; font-weight: 600; margin: 0 0 8px; }
.hero-query-sub:empty { display: none; }
.hero-ip-values { display: flex; flex-wrap: wrap; gap: 24px; margin: 16px 0 20px; }
.hero-ip { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 auto; }
.hero-ip-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.hero-ip-num { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 1.5rem; font-weight: 600; color: var(--text-primary); line-height: 1.25; word-break: break-all; }
.hero-note { color: var(--text-muted); font-size: 0.875rem; line-height: 1.55; margin: 0 0 18px; }
.hero-details-link { color: var(--accent); font-weight: 600; text-decoration: none; font-size: 0.9375rem; }
.hero-details-link:hover { color: var(--accent-hover); text-decoration: underline; }

.hero-ip-side { display: flex; flex-direction: column; gap: 16px; }
.ip-panel { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 16px; padding: 6px 20px; }
.ip-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--border-color); }
.ip-row:last-child { border-bottom: none; }
.ip-k { color: var(--text-muted); font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.ip-v { color: var(--text-primary); font-size: 0.9375rem; text-align: right; word-break: break-word; }
.ip-v img { height: 16px; width: auto; vertical-align: -2px; margin-left: 4px; }

.map-frame { border: 1px solid var(--border-color); border-radius: 16px; overflow: hidden; }
.home #map { height: 300px; width: 100%; }

/* Section heads shared by tools + FAQ */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-head h2 { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin: 0; }
.view-all-link { color: var(--accent); font-weight: 600; text-decoration: none; font-size: 0.9375rem; white-space: nowrap; }
.view-all-link:hover { color: var(--accent-hover); text-decoration: underline; }

.home-tools { padding: 32px 0; }
.home .table-container { padding: 32px 0; }
.home .export-toolbar { display: flex; gap: 8px; }
.home-ad-center { display: flex; justify-content: center; }

/* FAQ accordion */
.home-faq { padding: 32px 0 8px; }
.faq { border-top: 1px solid var(--border-color); }
.faq-item { border-bottom: 1px solid var(--border-color); }
.faq-q { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; text-align: left; background: none; border: none; cursor: pointer; padding: 18px 4px; font-family: 'Poppins', sans-serif; font-size: 1.0625rem; font-weight: 600; color: var(--text-primary); }
.faq-q:hover { color: var(--accent); }
.faq-ico { flex: 0 0 auto; color: var(--accent); font-size: 1.5rem; line-height: 1; width: 20px; text-align: center; }
.faq-ico::before { content: '+'; }
.faq-q[aria-expanded="true"] .faq-ico::before { content: '\2212'; }
.faq-a { padding: 0 4px 20px; }
.faq-a p { color: var(--text-muted); font-size: 0.9688rem; line-height: 1.65; margin: 0; max-width: 68ch; }

@media (max-width: 991px) {
    .hero-ip-layout { grid-template-columns: 1fr; }
    .home-hero-head h1 { font-size: 2rem; }
}
@media (max-width: 480px) {
    .hero-ip-values { flex-direction: column; gap: 14px; }
    .hero-ip-num { font-size: 1.25rem; }
}

/* ============================================================================
   v3 STEP 4 — Sweep: align legacy content-page cards with the new component
   system (feat/66). About / Privacy / Terms / blog / contact / 404 are styled in
   style.css via the remapped legacy tokens, so they already pick up the palette
   and fonts. Two things fought the new look: they used --secondary-color (the
   muted body-text grey) for card BORDERS instead of --border-color, and justified
   body text. Re-point borders to --border-color and left-align. Additive overrides
   (theme.css loads after style.css). Admin panel is a separate flag — see output.
   ============================================================================ */
.card-header,
.pp-tos-container, .pp-tos-text-container,
.contact-us-container, .contact-us-input-container,
.error404-container { border-color: var(--border-color) !important; }
.pp-tos-container, .contact-us-container, .error404-container { box-shadow: 0 4px 24px rgba(0,0,0,0.35); }
:root[data-theme="light"] .pp-tos-container,
:root[data-theme="light"] .contact-us-container,
:root[data-theme="light"] .error404-container { box-shadow: 0 2px 12px rgba(20,24,35,0.06); }
.pp-tos-text-container p { text-align: left; }
.pp-tos-text-container h2 { border-bottom-color: var(--border-color); }
