/* ip.hbenali.ovh: dark editorial, shared with hbenali.ovh. Cold ink, bone text, sodium accent,
   verdigris for pass, sodium for warning, red for fail. Fonts are self-hosted (see fonts/README.md). */

@font-face {
    font-family: 'Big Shoulders';
    font-style: normal;
    font-weight: 600 900;
    font-display: swap;
    src: url('fonts/big-shoulders-latin-wght.woff2') format('woff2');
}
@font-face {
    font-family: 'Newsreader';
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url('fonts/newsreader-latin-wght.woff2') format('woff2');
}
@font-face {
    font-family: 'Newsreader';
    font-style: italic;
    font-weight: 200 800;
    font-display: swap;
    src: url('fonts/newsreader-italic-latin-wght.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url('fonts/jetbrains-mono-latin-wght.woff2') format('woff2');
}

:root {
    --ink: #0c1218;
    --slate: #17212b;
    --line: #263341;
    --bone: #e7e1d3;
    --mist: #8e9aa6;
    --sodium: #e9a23b;
    --verdigris: #5db7a0;
    --fail: #e5776f;
    --glow: rgba(233, 162, 59, 0.2);
    --glow-soft: rgba(233, 162, 59, 0.06);
    --loader-ring: rgba(12, 18, 24, 0.3);
    --snow-fill: rgba(231, 225, 211, 0.85);
    --snow-edge: rgba(142, 154, 166, 0.4);

    --display: 'Big Shoulders', 'Arial Narrow', Impact, sans-serif;
    --serif: 'Newsreader', Georgia, serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;

    --gutter: clamp(1.25rem, 4vw, 2.5rem);
    color-scheme: dark;
}

/* Light: follows the system setting until the lamp (theme.js) is used. Dark above is the default and the identity.
   Contrast on --ink (page) / --slate (surface): text 16/14.7, muted 6.0/5.4, accent 5.5/4.9,
   ok 5.2/4.7, fail 5.7/5.1, ink on accent button 5.5. */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --ink: #f4efe4;
        --slate: #e9e3d4;
        --line: #cbc3b0;
        --bone: #0c1218;
        --mist: #4f5b67;
        --sodium: #8a5300;
        --verdigris: #1b7058;
        --fail: #b3261e;
        --glow: rgba(233, 162, 59, 0.22);
        --glow-soft: rgba(233, 162, 59, 0.07);
        --loader-ring: rgba(244, 239, 228, 0.3);
        --snow-fill: rgba(79, 91, 103, 0.7);
        --snow-edge: rgba(12, 18, 24, 0.3);
        color-scheme: light;
    }
}
:root[data-theme="light"] {
    --ink: #f4efe4;
    --slate: #e9e3d4;
    --line: #cbc3b0;
    --bone: #0c1218;
    --mist: #4f5b67;
    --sodium: #8a5300;
    --verdigris: #1b7058;
    --fail: #b3261e;
    --glow: rgba(233, 162, 59, 0.22);
    --glow-soft: rgba(233, 162, 59, 0.07);
    --loader-ring: rgba(244, 239, 228, 0.3);
    --snow-fill: rgba(79, 91, 103, 0.7);
    --snow-edge: rgba(12, 18, 24, 0.3);
    color-scheme: light;
}

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

html { background: var(--ink); overflow-x: clip; }
body { overflow-x: clip; position: relative; }
main, .hero, footer { position: relative; z-index: 1; }

body {
    min-height: 100vh;
    background: var(--ink);
    color: var(--bone);
    font-family: var(--serif);
    font-size: 1.125rem;
    line-height: 1.7;
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { background: var(--sodium); color: var(--ink); }
:focus-visible { outline: 2px solid var(--sodium); outline-offset: 3px; border-radius: 2px; }

a { color: inherit; }
ul { list-style: none; }
strong { font-weight: 600; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }

.display { font-family: var(--display); font-weight: 800; line-height: 0.86; letter-spacing: -0.01em; }

.link, footer a, .map-link a {
    text-decoration: none;
    background-image: linear-gradient(currentColor, currentColor);
    background-repeat: no-repeat;
    background-size: 100% 1px;
    background-position: 0 100%;
    padding-bottom: 2px;
    transition: background-size 0.35s cubic-bezier(0.22, 1, 0.36, 1), color 0.2s;
}
.link:hover, .link:focus-visible, footer a:hover, footer a:focus-visible,
.map-link a:hover, .map-link a:focus-visible { color: var(--sodium); background-size: 100% 2px; }

.wrap { max-width: 64rem; margin: 0 auto; padding-inline: var(--gutter); }

/* ───────────── Header ───────────── */
.hero { position: relative; padding-block: 4.5rem 2.5rem; }
.glow {
    position: absolute; z-index: 0; top: -14rem; right: -12rem;
    width: min(42rem, 140vw); aspect-ratio: 1; border-radius: 50%;
    background: radial-gradient(closest-side, var(--glow), var(--glow-soft) 55%, transparent);
    pointer-events: none;
}
.hero h1 { font-size: clamp(3.4rem, 14vw, 8.5rem); margin-left: -0.03em; overflow: hidden; padding-bottom: 0.2em; margin-bottom: -0.15em; }
.hero h1 span { display: block; animation: rise 1.1s cubic-bezier(0.16, 1, 0.3, 1) both; }
.subhead { margin-top: 1.5rem; max-width: 40ch; font-size: clamp(1.2rem, 2.2vw, 1.5rem); line-height: 1.5; animation: fade 0.9s 0.4s both; }
.subhead strong { color: var(--mist); font-weight: 400; }

@keyframes rise { from { transform: translateY(108%); } }
@keyframes fade { from { opacity: 0; transform: translateY(12px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes settle { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-in { animation: settle 0.35s ease-out; }

/* ───────────── Sections ───────────── */
.section { border-top: 1px solid var(--line); padding-block: 2.25rem; }
.section h2, .field-label { font-family: var(--display); font-weight: 800; font-size: 1.9rem; line-height: 1.05; color: var(--sodium); }
.hint { color: var(--mist); font-size: 1rem; font-style: italic; margin-left: 0.6rem; font-family: var(--serif); font-weight: 400; }

/* Your IP */
.my-ip-card { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 2rem; }
.my-ip-label { font-family: var(--display); font-weight: 800; font-size: 1.9rem; line-height: 1.05; color: var(--sodium); }
.my-ip-value { margin-top: 0.4rem; font: 500 clamp(1.4rem, 5.4vw, 2.6rem)/1.2 var(--mono); overflow-wrap: anywhere; }
#myIpFlag { margin-right: 0.6rem; font-family: var(--serif); }
.my-ip-actions { display: flex; gap: 1.25rem; }

/* Buttons: one solid sodium action per area, the rest are quiet text buttons */
button { cursor: pointer; background: none; border: 0; }
button:disabled { opacity: 0.5; cursor: default; }
#checkBtn, #calcBtn, #rangeCalcBtn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    background: var(--sodium); color: var(--ink); padding: 0.75rem 1.6rem; font-weight: 600;
    border-radius: 2px; transition: background-color 0.2s, transform 0.2s;
}
#checkBtn:hover, #calcBtn:hover, #rangeCalcBtn:hover { background: var(--bone); transform: translateY(-2px); }
#checkBtn:active, #calcBtn:active, #rangeCalcBtn:active { transform: none; }
.my-ip-copy, .my-ip-refresh, .action-btn, .history-clear, .try-btn {
    color: var(--bone); border: 1px solid var(--line); padding: 0.35rem 0.9rem; border-radius: 2px;
    font-size: 1rem; transition: border-color 0.2s, color 0.2s;
}
.my-ip-copy:hover, .my-ip-refresh:hover, .action-btn:hover, .history-clear:hover, .try-btn:hover { border-color: var(--sodium); color: var(--sodium); }
.my-ip-refresh.spinning { animation: pulse 0.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

/* Lookup field */
.input-group { display: flex; flex-direction: column; gap: 0.6rem; }
.input-group label, .calc-wrapper label { font-family: var(--display); font-weight: 800; font-size: 1.9rem; line-height: 1.05; color: var(--sodium); display: block; }
.input-group label i, .calc-wrapper label i { display: block; font: 400 italic 1rem/1.4 var(--serif); color: var(--mist); }
.ip-input-wrapper, .calc-input-row { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: flex-end; }
#ipInput, .calc-text-input {
    flex: 1 1 16rem; min-width: 0; background: none; border: 0; border-bottom: 1px solid var(--mist);
    color: var(--bone); font: 500 1.1rem/1.2 var(--mono); padding: 0.75rem 0; border-radius: 0;
    transition: border-color 0.2s;
}
#ipInput:focus, .calc-text-input:focus { outline: 0; border-color: var(--sodium); box-shadow: 0 1px 0 var(--sodium); }
#ipInput::placeholder, .calc-text-input::placeholder { color: var(--mist); font-family: var(--serif); font-weight: 400; }
.kbd-hint { color: var(--mist); font-size: 1rem; }
kbd { font: 0.8125rem var(--mono); color: var(--mist); border: 1px solid var(--line); padding: 0.05rem 0.4rem; border-radius: 3px; }
#btnLoader.loader, .loader { width: 1rem; height: 1rem; border: 2px solid var(--loader-ring); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.8s linear infinite; }

/* History */
.history-section { padding-block: 0 0.5rem; }
.history-header { display: flex; align-items: center; justify-content: space-between; color: var(--mist); margin-bottom: 0.6rem; }
.history-clear { font-size: 0.9rem; padding: 0.15rem 0.7rem; }
.history-chips { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.history-chip { display: inline-flex; align-items: center; gap: 0.5rem; max-width: 100%; border-bottom: 1px solid var(--line); font: 0.95rem var(--mono); cursor: pointer; transition: border-color 0.2s, color 0.2s; }
.history-chip:hover { border-color: var(--sodium); color: var(--sodium); }
.history-chip span { max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-chip-remove { color: var(--mist); width: 1.75rem; height: 1.75rem; font-size: 1.1rem; line-height: 1; }
.history-chip-remove:hover { color: var(--fail); }

/* ───────────── Results ───────────── */
.result-area { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: 2rem; min-height: 8rem; }
.empty-state { color: var(--mist); max-width: 46ch; }
.result-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1.5rem; }

.stats-grid { display: grid; grid-template-columns: 1fr; margin-bottom: 1.5rem; }
.stat-card { display: grid; gap: 0.15rem 2rem; border-top: 1px solid var(--line); padding: 1rem 0; }
.stats-grid .stat-card:last-child { border-bottom: 1px solid var(--line); }
.stat-label { font-family: var(--display); font-weight: 800; font-size: 1.5rem; line-height: 1.1; color: var(--sodium); }
.stat-value { font-size: 1.3rem; line-height: 1.4; overflow-wrap: anywhere; }
.stat-value-small { font: 0.95rem/1.6 var(--mono); color: var(--mist); overflow-wrap: anywhere; }
.stat-value.stat-value-small { color: var(--bone); }
.stat-card > div:nth-child(n+2) { grid-column: 2; }
@media (min-width: 40rem) {
    .stat-card { grid-template-columns: 13rem 1fr; }
    .stat-card > .stat-label { grid-row: 1 / span 3; }
}
@media (max-width: 39.99rem) { .stat-card > div:nth-child(n+2) { grid-column: 1; } }

.risk-badge { display: inline-block; padding: 0 0 0 0.9rem; font-weight: 600; font-size: 1.3rem; text-transform: capitalize; border-left: 3px solid currentColor; line-height: 1.2; }
.risk-low { color: var(--verdigris); }
.risk-medium { color: var(--sodium); }
.risk-high { color: var(--fail); }
.st-ok { color: var(--verdigris); }
.st-warn { color: var(--sodium); }

.map-frame { width: 100%; height: 280px; border: 1px solid var(--line); border-radius: 2px; margin-top: 1rem; display: block; background: var(--slate); }
.map-link { margin-top: 0.6rem; font-size: 1rem; }
.map-placeholder { border-top: 1px solid var(--line); color: var(--mist); padding: 1rem 0; }

.error-message { border-left: 3px solid var(--fail); padding: 0.4rem 0 0.4rem 1rem; color: var(--bone); }
.error-message::before { content: 'Error. '; color: var(--fail); font-weight: 600; }

/* ───────────── Guide ───────────── */
.guide-tabs { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.tab-btn { color: var(--mist); padding: 0.5rem 0; margin-bottom: -1px; border-bottom: 2px solid transparent; transition: color 0.2s, border-color 0.2s; }
.tab-btn:hover { color: var(--bone); }
.tab-btn.active { color: var(--sodium); border-bottom-color: var(--sodium); }
.tab-content { display: none; }
.tab-content.active { display: block; }
.info-table { width: 100%; border-collapse: collapse; }
.info-table td { padding: 0.8rem 1rem 0.8rem 0; border-top: 1px solid var(--line); vertical-align: top; }
.info-table tr:last-child td { border-bottom: 1px solid var(--line); }
.info-table td:first-child { font-weight: 600; width: 34%; }
.info-table td:nth-child(2) { font-family: var(--mono); font-size: 0.9rem; overflow-wrap: anywhere; }
#aboutTab .info-table td:nth-child(2), #securityTab .info-table td:nth-child(2) { font-family: var(--serif); font-size: 1.05rem; }
.try-btn { font: 0.85rem var(--mono); white-space: nowrap; }
.calc-section { margin-top: 2.25rem; padding-top: 1.75rem; border-top: 1px solid var(--line); }
.calc-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.calc-wrapper label { margin-bottom: 0.4rem; }
.calc-input-row { margin-bottom: 1.25rem; }
.cidr-list { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
.cidr-chip { font: 500 1rem var(--mono); border-bottom: 1px solid var(--sodium); padding: 0.2rem 0; }

footer { border-top: 1px solid var(--line); margin-top: 1rem; padding-block: 2rem 3rem; color: var(--mist); font-size: 1rem; }

/* ───────────── Toasts and snow ───────────── */
.toast-container { position: fixed; bottom: 1.25rem; right: 1.25rem; display: flex; flex-direction: column; gap: 0.6rem; z-index: 1000; max-width: calc(100vw - 2rem); }
.toast { background: var(--slate); color: var(--bone); padding: 0.7rem 1.1rem; border: 1px solid var(--line); border-left: 3px solid var(--sodium); border-radius: 2px; font-size: 1rem; max-width: 20rem; animation: settle 0.25s ease-out; transition: opacity 0.3s, transform 0.3s; }
#snowCanvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; display: none; }
.snow-toggle { position: fixed; bottom: 1.25rem; left: 1.25rem; z-index: 1000; display: none; align-items: center; background: var(--slate); color: var(--bone); border: 1px solid var(--line); padding: 0.4rem 0.9rem; border-radius: 2px; font-size: 1rem; }
.snow-toggle:hover { border-color: var(--sodium); color: var(--sodium); }

/* ───────────── 404 ───────────── */
.nf { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding-block: 5rem 4rem; position: relative; z-index: 1; }
.nf-code { font-size: clamp(9rem, 34vw, 24rem); color: var(--sodium); }
.nf h1 { font-size: clamp(2.8rem, 7vw, 5rem); margin-top: 0.5rem; }
.nf-lead { margin-top: 1rem; max-width: 36ch; color: var(--mist); font-size: 1.3rem; }
.lookup-form { margin-top: 2.5rem; max-width: 36rem; }
.lookup-form label { font-family: var(--display); font-weight: 800; font-size: 1.9rem; line-height: 1.05; color: var(--sodium); display: block; }
.lookup-form .ip-input-wrapper { margin-top: 0.4rem; }
.lookup-form #jumpInput { flex: 1 1 14rem; min-width: 0; background: none; border: 0; border-bottom: 1px solid var(--mist); color: var(--bone); font: 500 1.1rem/1.2 var(--mono); padding: 0.75rem 0; border-radius: 0; }
.lookup-form #jumpInput:focus { outline: 0; border-color: var(--sodium); box-shadow: 0 1px 0 var(--sodium); }
.lookup-form #jumpInput::placeholder { color: var(--mist); font-family: var(--serif); }
.lookup-form button { background: var(--sodium); color: var(--ink); padding: 0.75rem 1.6rem; font-weight: 600; border-radius: 2px; transition: background-color 0.2s, transform 0.2s; }
.lookup-form button:hover { background: var(--bone); transform: translateY(-2px); }
.nf-links { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; font-size: 1.25rem; }
.nf-links .try { color: var(--mist); }
.nf .nf-foot { margin-top: 3rem; color: var(--mist); font-size: 1rem; }

@media (max-width: 40rem) {
    #checkBtn, #calcBtn, #rangeCalcBtn { width: 100%; }
    .my-ip-actions { width: 100%; }
    .info-table td { display: block; width: auto !important; padding: 0.2rem 0; border: 0; }
    .info-table tr { display: block; padding: 0.8rem 0; border-top: 1px solid var(--line); }
    .info-table tr:last-child { border-bottom: 1px solid var(--line); }
    .info-table td:first-child { padding-top: 0; }
    .map-frame { height: 220px; }
    .toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
    .toast { max-width: none; }
    .snow-toggle { bottom: 1rem; left: 1rem; }
}
@media (hover: none) and (pointer: coarse) {
    button, .tab-btn { min-height: 2.75rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; }
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- Theme lamp: pull-cord switch (see theme.js). Lamp on = light theme. ---- */
.theme-lamp {
    position: absolute; /* scrolls away with the page; fixed on pages with a fixed bar, see below */
    top: 0;
    inset-inline-end: clamp(0.75rem, 3vw, 2rem);
    z-index: 1000;
    display: block;
    width: 2.75rem;
    height: 5.25rem;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
/* Pages with a fixed top bar or fixed top-right controls: the lamp stays visible and the bar
   reserves room for it (lamp offset + lamp width + gap), so it never covers a link. */
html:has(.bar-inner) .theme-lamp,
html:has(.controls) .theme-lamp { position: fixed; }
.bar-inner { padding-inline-end: calc(clamp(0.75rem, 3vw, 2rem) + 2.75rem + 0.75rem); }
.controls { right: calc(clamp(0.75rem, 3vw, 2rem) + 2.75rem + 0.75rem); }
.theme-lamp svg { display: block; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.lamp-wire { stroke: var(--mist); stroke-width: 1.2; }
.lamp-shade { fill: var(--slate); stroke: var(--bone); stroke-width: 1.4; stroke-linejoin: round; }
.lamp-bulb { fill: var(--line); transition: fill 0.4s; }
.lamp-halo { fill: var(--sodium); opacity: 0; transition: opacity 0.5s; }
.lamp-cone { fill: url(#lamp-cone); opacity: 0; transition: opacity 0.5s; }
.lamp-stop-a { stop-color: var(--sodium); stop-opacity: 0.38; }
.lamp-stop-b { stop-color: var(--sodium); stop-opacity: 0; }
.lamp-cord { stroke: var(--mist); stroke-width: 1; }
.lamp-bead { fill: var(--sodium); }
.theme-lamp[data-on="true"] .lamp-bulb { fill: #ffd27a; }
.theme-lamp[data-on="true"] .lamp-halo { opacity: 0.35; }
.theme-lamp[data-on="true"] .lamp-cone { opacity: 1; }
.lamp-swing { transform-box: view-box; transform-origin: 22px 0; animation: lamp-swing 0.9s ease-out; }
.lamp-pull { animation: lamp-pull 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes lamp-swing { 20% { transform: rotate(-5deg); } 45% { transform: rotate(3.5deg); } 70% { transform: rotate(-1.5deg); } }
@keyframes lamp-pull { 35% { transform: translateY(10px); } }

/* The theme switch is a plain cross-fade of the whole page. */
html.theme-vt::view-transition-old(root) { animation: 0.45s ease both lamp-fade-out; }
html.theme-vt::view-transition-new(root) { animation: 0.45s ease both lamp-fade-in; }
@keyframes lamp-fade-out { to { opacity: 0; } }
@keyframes lamp-fade-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .lamp-swing, .lamp-pull { animation: none; }
    .lamp-bulb, .lamp-halo, .lamp-cone { transition: none; }
}
