/* ==========================================================================
   IP Tools — design system
   One owned stylesheet. Tokens first, then components, then the legacy
   compat layer for markup that still carries Bootstrap-era classes.
   ========================================================================== */

:root {
    /* Colour */
    --ink-900: #0f1c2e;   /* dark field: masthead, hero, footer */
    --ink-800: #16283f;
    --ink-700: #1f3652;
    --paper:   #f4f6f9;   /* page ground */
    --surface: #ffffff;   /* cards, panels */
    --line:    #e3e8ef;   /* borders, dividers */
    --accent:       #2563eb;
    --accent-ink:   #1d4ed8;
    --accent-soft:  #eaf1fe;
    --text:         #1a2333;
    --text-muted:   #5b6472;
    --danger:  #c22f3a;
    --danger-soft: #fdeaea;
    --warning: #b58100;
    --success: #1d7a46;

    /* Type scale */
    --step--1: 0.875rem;
    --step-0:  1rem;
    --step-1:  1.125rem;
    --step-2:  1.25rem;
    --step-3:  1.5rem;
    --step-4:  1.875rem;
    --step-5:  2.25rem;
    --step-6:  3rem;

    /* Spacing (4 px base) */
    --s-1: 0.25rem;
    --s-2: 0.5rem;
    --s-3: 0.75rem;
    --s-4: 1rem;
    --s-5: 1.5rem;
    --s-6: 2rem;
    --s-8: 3rem;

    /* Geometry */
    --radius: 8px;
    --radius-sm: 5px;
    --shadow-1: 0 1px 2px rgba(15, 28, 46, 0.06), 0 1px 3px rgba(15, 28, 46, 0.08);
    --shadow-2: 0 4px 12px rgba(15, 28, 46, 0.10);
    --container: 1100px;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ------------------------------------------------------------------ Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--step-0);
    line-height: 1.6;
    color: var(--text);
    background: var(--paper);
}
img { max-width: 100%; height: auto; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { line-height: 1.25; color: var(--ink-900); margin: 0 0 var(--s-4); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }
p { margin: 0 0 var(--s-4); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-5) 0; }
code, pre { font-family: var(--font-mono); }
code { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.1em 0.4em; font-size: 0.9em; }
pre {
    background: var(--ink-900);
    color: #e8eef7;
    padding: var(--s-4);
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: var(--step--1);
    line-height: 1.5;
    margin: 0 0 var(--s-5);
}
pre code { background: none; border: 0; color: inherit; padding: 0; }

/* ------------------------------------------------------------- Layout */
.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--s-5); }
.site-main { padding: var(--s-6) 0 var(--s-8); }
.skip-link {
    position: absolute; left: -9999px; top: 0;
    background: var(--accent); color: #fff; padding: var(--s-2) var(--s-4); border-radius: 0 0 var(--radius) 0; z-index: 100;
}
.skip-link:focus { left: 0; }

/* --------------------------------------------------------------- Header */
.site-header { background: var(--ink-900); color: #fff; }
.header-inner { max-width: var(--container); margin: 0 auto; padding: 0 var(--s-5); display: flex; align-items: center; justify-content: space-between; min-height: 62px; gap: var(--s-4); flex-wrap: wrap; }
.brand { color: #fff; font-weight: 800; font-size: var(--step-1); letter-spacing: 0.02em; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
.nav-toggle { display: none; background: none; border: 0; cursor: pointer; padding: var(--s-2); }
.nav-toggle span { display: block; width: 22px; height: 2px; background: #fff; margin: 5px 0; border-radius: 2px; }
.site-nav { }
.nav-list { display: flex; list-style: none; margin: 0; padding: 0; gap: var(--s-1); }
.nav-list > li { position: relative; }
.nav-list > li > a,
.sub-toggle {
    display: block; color: #dbe4f0; padding: var(--s-3) var(--s-4); font-size: var(--step--1); font-weight: 600; border-radius: var(--radius-sm); background: none; border: 0; cursor: pointer; font-family: inherit;
}
.nav-list > li > a:hover,
.sub-toggle:hover,
.nav-list > li.is-open > .sub-toggle { color: #fff; background: var(--ink-700); text-decoration: none; }
.nav-list > li > a.is-active { color: #fff; background: var(--accent); }
.sub-menu {
    position: absolute; top: 100%; left: 0; min-width: 260px; background: var(--surface); color: var(--text);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: var(--s-2);
    display: none; z-index: 50;
}
.nav-list > li.is-open > .sub-menu { display: block; }
.sub-group-label { display: block; padding: var(--s-2) var(--s-3); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 700; }
.sub-menu ul { list-style: none; margin: 0; padding: 0; }
.sub-menu a { display: block; padding: var(--s-2) var(--s-3); color: var(--text); font-size: var(--step--1); border-radius: var(--radius-sm); }
.sub-menu a:hover { background: var(--accent-soft); color: var(--accent-ink); text-decoration: none; }
.sub-group + .sub-group { border-top: 1px solid var(--line); margin-top: var(--s-2); padding-top: var(--s-2); }

/* ---------------------------------------------------------------- Panels */
.container1 {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    padding: var(--s-6);
    margin: 0 auto var(--s-6);
    max-width: 860px;
}
.container1 > h1, .container1 > h2 { text-align: center; }
.container1 > p { text-align: center; color: var(--text-muted); }

.tool-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    padding: var(--s-5) var(--s-6);
    margin: 0 auto var(--s-6);
    max-width: 860px;
}
.tool-panel > h1, .tool-panel > h2 { text-align: center; }
.tool-panel > p { color: var(--text-muted); }
.password-output { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; margin: var(--s-4) 0; }
.password-output .password {
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: var(--s-2) var(--s-3); font-family: var(--font-mono); font-size: var(--step--1);
    color: var(--ink-800); word-break: break-all; cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.password-output .password:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.pwd-controls { display: flex; flex-wrap: wrap; gap: var(--s-4); justify-content: center; align-items: flex-end; margin: var(--s-4) 0; }
.pwd-controls label { margin: 0; }
.pwd-controls input[type="number"] { width: 80px; display: inline-block; margin: 0 var(--s-1); }
.pwd-sets { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; }
.pwd-sets label { display: inline-flex; align-items: center; gap: var(--s-1); font-weight: 500; }
.pwd-sets input[type="checkbox"] { width: auto; margin: 0; }
.copy-btn { margin-left: var(--s-2); }
.tool-intro { color: var(--text-muted); text-align: center; }
.result-note {
    background: var(--accent-soft); border: 1px solid #cfe0fb; border-radius: var(--radius-sm);
    padding: var(--s-3) var(--s-4); margin: var(--s-4) 0 0; font-size: var(--step--1);
    color: var(--ink-800);
}

/* tooltip explainer */
.tip {
    display: inline-block; position: relative; cursor: help;
    color: var(--accent); font-weight: 700; margin-left: var(--s-1);
    border: 1px solid var(--accent); border-radius: 50%; width: 16px; height: 16px;
    line-height: 14px; text-align: center; font-size: 11px;
}
.tip::after {
    content: attr(data-tip);
    position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%);
    width: 240px; padding: var(--s-3); background: var(--ink-900); color: #fff;
    font-size: 12px; line-height: 1.4; font-weight: 400; text-align: left;
    border-radius: var(--radius-sm); box-shadow: var(--shadow-2);
    opacity: 0; pointer-events: none; transition: opacity 0.15s; z-index: 60;
}
.tip:hover::after { opacity: 1; }

/* --------------------------------------------------------------- Buttons */
.btn {
    display: inline-block; font-family: inherit; font-size: var(--step-0); font-weight: 600;
    padding: var(--s-2) var(--s-4); border: 1px solid transparent; border-radius: var(--radius-sm);
    cursor: pointer; line-height: 1.5; text-align: center; transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none; color: var(--text); background: var(--surface); border-color: var(--line);
}
.btn:hover { text-decoration: none; background: var(--paper); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-info { background: var(--ink-700); border-color: var(--ink-700); color: #fff; }
.btn-info:hover { background: var(--ink-800); border-color: var(--ink-800); }
.btn-block { display: block; width: 100%; }
.btn-lg { font-size: var(--step-1); padding: var(--s-3) var(--s-5); }
.btn-sm { font-size: var(--step--1); padding: var(--s-1) var(--s-3); }
.btn-outline-secondary { background: transparent; border-color: var(--line); color: var(--text-muted); }
.btn-outline-secondary:hover { background: var(--paper); }
.btn + .btn, .btn + input.btn, input.btn + .btn { margin-left: var(--s-2); }

/* ---------------------------------------------------------------- Forms */
.form-control {
    display: block; width: 100%; font-family: inherit; font-size: var(--step-0);
    padding: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); margin: 0 0 var(--s-4);
}
.form-control:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.form-control-lg { font-size: var(--step-1); padding: var(--s-3); }
textarea.form-control, textarea { min-height: 9rem; resize: vertical; font-family: var(--font-mono); }

/* Global input styling so every tool's fields look consistent */
input[type="text"], input[type="url"], input[type="email"], input[type="number"],
input[type="search"], input[type="password"], input[type="tel"], select, textarea {
    display: block; width: 100%; box-sizing: border-box;
    font-family: var(--font-sans); font-size: var(--step-0);
    padding: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); margin: 0 0 var(--s-4);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
label, .field-label { display: inline-block; font-weight: 600; color: var(--ink-800); margin: var(--s-3) 0 var(--s-1); font-size: var(--step--1); }

/* --------------------------------------------------------------- Alerts */
.alert { padding: var(--s-3) var(--s-4); border-radius: var(--radius-sm); margin: 0 0 var(--s-4); border: 1px solid transparent; }
.alert-danger { background: var(--danger-soft); border-color: #f2c6ca; color: var(--danger); }

/* ---------------------------------------------------------- Text utils */
.text-danger { color: var(--danger); font-weight: 600; }
.text-warning { color: var(--warning); font-weight: 600; }
.text-success { color: var(--success); }
.text-muted { color: var(--text-muted); }

/* --------------------------------------------------------------- Tables */
.table { width: 100%; border-collapse: collapse; margin: 0 0 var(--s-5); }
.table th, .table td { padding: var(--s-2) var(--s-3); text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: var(--paper); color: var(--ink-800); font-weight: 700; }
.table-bordered { border: 1px solid var(--line); }
.table-bordered th, .table-bordered td { border: 1px solid var(--line); }

/* ------------------------------------------------- Homepage tool grid */
.hero { background: var(--ink-900); color: #fff; padding: var(--s-8) 0 var(--s-6); text-align: center; }
.hero h1 { color: #fff; font-size: var(--step-5); margin-bottom: var(--s-3); }
.hero-sub { color: #9fb0c6; font-size: var(--step-1); margin: 0; }

/* ------------------------------------------------- Tool page content */
.tool-about, .tool-howto, .tool-faq {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-1); padding: var(--s-5) var(--s-6); margin: 0 auto var(--s-5); max-width: 860px;
}
.tool-about h2, .tool-howto h2, .tool-faq h2 { font-size: var(--step-2); margin-bottom: var(--s-3); }
.tool-howto ol { margin: 0 0 0 var(--s-5); padding: 0; }
.tool-howto li { margin-bottom: var(--s-2); }
.tool-faq h3 { font-size: var(--step-1); margin: var(--s-4) 0 var(--s-2); }
.tool-faq p { color: var(--text-muted); margin: 0 0 var(--s-2); }
.ad-slot { margin-bottom: var(--s-6); }

.tool-group { margin-bottom: var(--s-8); }
.tool-group h2, .tool-group h3 { text-align: center; color: var(--ink-900); margin-bottom: var(--s-5); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s-4); }
.tool-card {
    display: flex; flex-direction: column; justify-content: center; text-align: center;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: var(--s-5) var(--s-4); min-height: 96px; color: var(--text); font-weight: 600;
    box-shadow: var(--shadow-1); transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.tool-card:hover { border-color: var(--accent); box-shadow: var(--shadow-2); transform: translateY(-2px); text-decoration: none; color: var(--accent-ink); }

/* --------------------------------------------------------------- Footer */
.site-footer { background: var(--ink-900); color: #dbe4f0; margin-top: var(--s-8); }
.footer-inner { padding: var(--s-6) var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); align-items: center; text-align: center; }
.footer-brand { color: #fff; font-weight: 800; font-size: var(--step-1); }
.footer-brand span { color: var(--accent); }
.footer-tagline { color: #9fb0c6; margin: 0; }
.footer-nav { list-style: none; display: flex; gap: var(--s-4); margin: 0; padding: 0; flex-wrap: wrap; justify-content: center; }
.footer-nav a { color: #dbe4f0; }
.footer-nav a:hover { color: #fff; }
.footer-copy { color: #7c8ba1; font-size: var(--step--1); margin: 0; }

/* ---------------------------------------------------- Responsive (nav) */
@media (max-width: 900px) {
    .nav-toggle { display: block; }
    .site-nav { display: none; width: 100%; flex-basis: 100%; }
    .site-nav.is-open { display: block; padding-bottom: var(--s-4); }
    .nav-list { flex-direction: column; }
    .sub-menu { position: static; min-width: 0; box-shadow: none; border: 0; border-left: 2px solid var(--line); border-radius: 0; margin-left: var(--s-4); padding: 0 0 0 var(--s-2); }
    .nav-list > li.is-open > .sub-menu { display: block; }
    .sub-menu a { color: var(--text-muted); }
}

@media (max-width: 600px) {
    .site-main { padding: var(--s-5) 0 var(--s-6); }
    .container1 { padding: var(--s-4); }
    h1 { font-size: var(--step-3); }
}
