/* Kodeks' small public tools: domene.kodeks.no (D O M E N E) and ip.kodeks.no (I P).

   Kodeks Studio's look, as status.kodeks.no has it (mainframe: ops/status/public/assets/status.css, which copies
   studio/public/assets/studio.css; "External systems use Studio's look"): the same tokens, the same sticky header with
   the wordmark, a thin line and the tool's name letter-spaced, the same cards, buttons, fields and pills, Studio's
   page width (980px), and the same light/dark behaviour -- the system's choice unless Appearance in the footer says
   otherwise (data-theme on <html>, assets/theme.js). The same file serves both tools. Copied, not linked: local
   files only, no fonts from elsewhere. */

:root {
    --brand: #00989a; --brand-ink: #007f81; --brand-soft: #e5f4f4;
    --ink: #14212b; --muted: #5d6b76; --line: #e2e8ec; --line-strong: #cfd8de;
    --bg: #f4f7f8; --card: #ffffff; --col: #eaeff2; --hover: #f7fafb;
    --bad: #c8382f; --good: #00989a;
    --warn: #f0900c; --warn-ink: #9a5800;
    --shadow: 0 1px 2px rgba(20,33,43,.06), 0 6px 20px rgba(20,33,43,.06);
    --radius: 12px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --brand-ink: #22c9cb; --brand-soft: color-mix(in srgb, #22c9cb 9%, #151f25);
        --ink: #e8eef1; --muted: #9fb0ba; --line: #253139; --line-strong: #34434d;
        --bg: #0d1418; --card: #151f25; --col: #111a1f; --hover: #1a262d;
        --bad: #ff7b70; --good: #22c9cb;
        --warn: #f0a030; --warn-ink: #ffbc5c;
        --shadow: 0 1px 2px rgba(0,0,0,.35), 0 6px 20px rgba(0,0,0,.25);
    }
}
:root[data-theme="dark"] {
    --brand-ink: #22c9cb; --brand-soft: color-mix(in srgb, #22c9cb 9%, #151f25);
    --ink: #e8eef1; --muted: #9fb0ba; --line: #253139; --line-strong: #34434d;
    --bg: #0d1418; --card: #151f25; --col: #111a1f; --hover: #1a262d;
    --bad: #ff7b70; --good: #22c9cb;
    --warn: #f0a030; --warn-ink: #ffbc5c;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 6px 20px rgba(0,0,0,.25);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
    background: var(--bg); color: var(--ink);
    font: 15px/1.55 var(--font);
    overflow-x: hidden; overflow-wrap: anywhere;
}
h1, h2, h3, p, ol, ul { margin: 0; }
h1, h2, h3 { line-height: 1.2; }
a { color: var(--brand-ink); text-underline-offset: 2px; }
button, input, textarea, select { font: inherit; color: inherit; }
.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; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

/* ---------------------------------------------------------------- header (Studio's .top) */

.top {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; flex-shrink: 0;
    height: 56px; padding: 0 12px 0 16px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right));
    background: color-mix(in srgb, var(--card) 90%, transparent);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex: 0 0 auto; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand:focus-visible { border-radius: 6px; }
.brand-logo { display: block; line-height: 0; }
.logo-text { font-weight: 800; letter-spacing: .08em; color: #00afb1; font-size: 18px; }
.flair-mark { position: relative; display: block; line-height: 0; transform: translate(-2px, 0); }
.flair-logo { display: block; width: 140px; height: auto; color: #00afb1; overflow: visible; }
.top-spacer { flex: 1 1 auto; min-width: 0; }
.top-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: 0 0 auto;
    height: 34px; padding: 4px 12px; border-radius: 8px; border: 1px solid var(--line-strong);
    background: var(--card); color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.2; text-decoration: none;
}
.top-btn:hover { background: var(--hover); }
.top-btn .ico { width: 17px; height: 17px; color: var(--muted); flex: 0 0 auto; }
@media (max-width: 560px) {
    .brand { gap: 10px; }
}
@media (max-width: 768px) {
    .top { height: 48px; padding: 0 8px; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
    .flair-mark { transform: translate(-6px, -1px); }
    .flair-logo { width: 121px; }
    .top-btn { height: 32px; }
}
@media (max-width: 420px) {
    .top-btn { width: 32px; padding: 0; }
    .top-btn-label { display: none; }
}

/* ---------------------------------------------------------------- the page (Studio's .page) */

.page { width: 100%; max-width: 980px; margin: 0 auto; padding: 32px 16px 24px; flex: 1 0 auto; }
.lead { font-size: 18px; margin: 0 0 12px; }
.page-head { margin: 0 0 20px; }
.page-head h1 { margin: 4px 0 10px; font-size: clamp(28px, 5vw, 40px); letter-spacing: -.02em; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.page-head .lead { color: var(--muted); margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.more { margin-top: 12px; font-size: 14px; }
.more a { font-weight: 600; text-decoration: none; }
.more a:hover { text-decoration: underline; }

/* Section titles: Studio's group titles */
.section-title { margin: 0 0 12px; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ---------------------------------------------------------------- pills (Studio's .pill) */

.pill {
    --c: var(--muted); --ink-s: var(--muted);
    flex: none; display: inline-block; padding: 1px 8px; border-radius: 999px; white-space: nowrap;
    font-size: 11.5px; font-weight: 700; letter-spacing: .03em; line-height: 18px;
    color: var(--ink-s); background: color-mix(in srgb, var(--c) 12%, var(--card));
    border: 1px solid color-mix(in srgb, var(--c) 35%, var(--line));
}
.pill.p-warn { --c: var(--warn); --ink-s: var(--warn-ink); }

/* ---------------------------------------------------------------- buttons, fields (Studio's) */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
    min-height: 34px; padding: 6px 14px; border-radius: 8px; border: 1px solid transparent;
    font-weight: 600; font-size: 14px; line-height: 1.2; text-decoration: none; cursor: pointer; white-space: nowrap;
    background: transparent; color: var(--ink); transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); border-color: color-mix(in srgb, var(--brand) 88%, #000); }
.btn.secondary { background: var(--card); border-color: var(--line-strong); color: var(--ink); }
.btn.secondary:hover { background: var(--hover); }
.btn .ico { width: 17px; height: 17px; color: var(--muted); flex: 0 0 auto; }

input[type=text], select {
    border: 1px solid var(--line-strong); border-radius: 8px; background: var(--card);
    padding: 6px 12px; min-height: 34px;
}
input[type=text]:focus, select:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
label { font-weight: 600; font-size: 14px; }

/* ---------------------------------------------------------------- domene: the lookup */

.lookup { padding: 24px; }
.lookup label { display: block; margin-bottom: 6px; }
.lookup-row { display: flex; gap: 8px; max-width: 680px; }
.lookup-row input { flex: 1 1 auto; min-width: 0; }
.lookup-row select { flex: none; }

/* The answer: a card of lines, each with its mark (✓ / ✕) in the margin */
.container { margin-top: 12px; padding: 20px 24px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.container > p { position: relative; padding-left: 30px; }
.container > p + p, .container > p + .tablewrap, .container > .tablewrap + p { margin-top: 12px; }
.container > p.meta { padding-left: 0; color: var(--muted); font-size: 13.5px; }
.container > p.meta strong { color: var(--ink); font-weight: 600; margin-left: 4px; }
.container > p.hint { margin-top: 4px; color: var(--muted); font-size: 13.5px; }
.container > p > span.green:first-child, .container > p > span.red:first-child { position: absolute; left: 0; top: 1px; }
span.green, span.red {
    display: inline-grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; vertical-align: -3px;
    font-size: 11.5px; font-weight: 700; line-height: 1;
}
span.green { color: var(--brand-ink); background: color-mix(in srgb, var(--good) 14%, var(--card)); border: 1px solid color-mix(in srgb, var(--good) 40%, var(--line)); }
span.red   { color: var(--bad);       background: color-mix(in srgb, var(--bad) 12%, var(--card));  border: 1px solid color-mix(in srgb, var(--bad) 40%, var(--line)); }
span.warn  { color: var(--warn-ink); font-weight: 600; }
.container strong { font-weight: 600; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.container > .tablewrap { margin-top: 16px; }
table.nstable, table.changes { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.45; }
table.nstable td, table.nstable th, table.changes td { padding: 9px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
table.nstable td:first-child, table.changes td { white-space: nowrap; }
table.nstable tr:last-child td, table.changes tr:last-child td { border-bottom: 0; }
table.nstable th { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--col); white-space: nowrap; }
table.nstable td:first-child { font-weight: 600; }
table.nstable tr.external td { border-top: 2px solid var(--line-strong); background: var(--hover); }
table.nstable span.green, table.nstable span.red { margin-right: 4px; }
/* a mark in the margin of its cell, so a value that wraps lines up under itself */
table.nstable td[data-label] { position: relative; padding-left: 41px; }
table.nstable td[data-label] > span.green:first-child, table.nstable td[data-label] > span.red:first-child { position: absolute; left: 14px; top: 10px; }
table.nstable span.ttl { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
table.changes td { font-family: var(--mono); font-size: 13.5px; }
table.changes td:nth-child(2) { color: var(--brand-ink); font-weight: 600; }

/* debug: the raw answer */
.container pre { margin: 0; font: 13px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.blink_me { animation: blinker 1s linear infinite; }
@keyframes blinker { 50% { opacity: 0; } }

/* ---------------------------------------------------------------- ip: the address */

.ip-card { padding: 24px; }
.ip-card .section-title { margin-bottom: 8px; }
.ip-value {
    display: inline-flex; align-items: center; gap: 12px; max-width: 100%;
    margin: 0; padding: 4px 8px; margin-left: -8px; border: 0; border-radius: 8px; background: none; cursor: pointer; text-align: left;
    font-size: clamp(28px, 5vw, 40px); font-weight: 700; letter-spacing: -.01em; line-height: 1.2; font-variant-numeric: tabular-nums;
}
.ip-value:hover { background: var(--hover); }
#ip-text { min-width: 0; overflow-wrap: anywhere; }
.ip-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 12px; }
.copied { font-size: 14px; font-weight: 600; color: var(--brand-ink); }

/* ---------------------------------------------------------------- footer (status.kodeks.no's) */

.foot { width: 100%; max-width: 980px; margin: 24px auto 0; padding: 0 16px 32px; padding-bottom: max(32px, env(safe-area-inset-bottom)); color: var(--muted); font-size: 13px; }
.foot-row { padding-top: 20px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 24px; }
.foot .links a { color: var(--muted); }
.foot .links a:hover { color: var(--brand-ink); }

/* Appearance: Studio's switch (.theme-seg), in the footer; shown once tool.js runs */
.theme { display: inline-flex; align-items: center; gap: 10px; }
.theme-seg { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--col); }
.theme-seg button {
    min-height: 0; border: 0; background: none; padding: 3px 10px; border-radius: 999px; cursor: pointer;
    font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.theme-seg button:hover { color: var(--ink); }
.theme-seg button.is-on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.theme-seg button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ---------------------------------------------------------------- phones */

@media (max-width: 650px) {
    .page { padding-top: 20px; }
    .lookup, .ip-card { padding: 16px; }
    .container { padding: 16px; }
    .lookup-row { flex-wrap: wrap; }
    .lookup-row input { flex-basis: 100%; }
    .lookup-row .btn { flex: 1 1 auto; }

    /* Each server as a small card instead of a row */
    table.nstable tr:first-child { display: none; }
    table.nstable, table.nstable tbody, table.nstable tr, table.nstable td { display: block; width: auto; }
    table.nstable tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
    table.nstable tr:last-child { border-bottom: 0; }
    table.nstable tr.external td { border-top: 0; background: transparent; }
    table.nstable tr.external { background: var(--hover); border-top: 2px solid var(--line-strong); }
    table.nstable td { border-bottom: 0; padding: 3px 14px; white-space: normal; }
    table.nstable td:first-child { padding-bottom: 6px; }
    /* label, mark, then the value, which wraps under itself */
    table.nstable td[data-label] { padding-left: 123px; }
    table.nstable td[data-label] > span.green:first-child, table.nstable td[data-label] > span.red:first-child { left: 96px; top: 4px; }
    table.nstable td[data-label]::before { content: attr(data-label); position: absolute; left: 14px; top: 4px; width: 78px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
    /* a change as two lines: the name, then type and value */
    table.changes, table.changes tbody { display: block; }
    table.changes tr { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
    table.changes tr:last-child { border-bottom: 0; }
    table.changes td { padding: 0; border: 0; font-size: 13px; white-space: normal; }
    table.changes td:first-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
    .btn { transition: none; }
    .blink_me { animation: none; }
}

/* Framed in Mainframe: its own header is above the frame, so this one goes (theme.js sets .is-framed) */
.is-framed .top { display: none; }
.is-framed .theme { display: none !important; }   /* the theme is Mainframe's there */
