:root,
[data-theme="dark"] {
    --sky: #070a1c;
    --panel: rgba(13, 18, 44, 0.66);
    --panel-edge: rgba(163, 171, 198, 0.16);
    --ink: #eaedf8;
    --ink-2: #aab2cc;
    --ink-3: #8189a8;
    --rule: rgba(163, 171, 198, 0.16);
    --accent: #ffc46b;
    --accent-ink: #1b1405;
    --glow: 0 18px 50px rgba(2, 4, 16, 0.55);

    --step: 8px;
    --radius: 14px;
    --sans: "Schibsted Grotesk", system-ui, sans-serif;
}

[data-theme="light"] {
    --sky: #eef1f6;
    --panel: rgba(255, 255, 255, 0.72);
    --panel-edge: rgba(13, 21, 48, 0.1);
    --ink: #0d1530;
    --ink-2: #404a6a;
    --ink-3: #5c6584;
    --rule: rgba(13, 21, 48, 0.12);
    --accent: #2742d6;
    --accent-ink: #ffffff;
    --glow: 0 18px 50px rgba(30, 40, 90, 0.14);
}

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

html {
    color-scheme: dark;
}

:root[data-theme="light"] {
    color-scheme: light;
}

body {
    background: var(--sky);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.45;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: var(--accent);
    color: var(--accent-ink);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 6px;
}

/* Surfaces flip theme one by one as a wave front reaches them. */
.surface,
.surface * {
    transition: color 180ms ease, background-color 180ms ease,
                border-color 180ms ease, fill 180ms ease, stroke 180ms ease,
                box-shadow 180ms ease;
}

#orb {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

#labels {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.label {
    position: absolute;
    top: 0;
    left: 0;
    translate: -50% 0;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: opacity 200ms ease;
}

#mark,
#corner,
#readout,
#detail,
#controls {
    position: fixed;
    z-index: 2;
}

#readout,
#detail,
#controls,
#corner {
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: var(--radius);
    box-shadow: var(--glow);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

/* Header: name, promise, search. */

#mark {
    top: calc(var(--step) * 3);
    left: calc(var(--step) * 3);
    width: min(320px, calc(100vw - var(--step) * 6 - 120px));
}

#mark h1 {
    font-size: clamp(30px, 4vw, 40px);
    font-weight: 700;
    letter-spacing: -0.045em;
    line-height: 0.95;
}

#mark > p {
    margin-top: var(--step);
    max-width: 30ch;
    color: var(--ink-2);
    font-size: 14px;
    text-wrap: pretty;
}

#finder {
    display: block;
    margin-top: calc(var(--step) * 2);
}

#search {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--panel-edge);
    border-radius: 999px;
    background: var(--panel);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: var(--ink);
    font: inherit;
}

#search::placeholder {
    color: var(--ink-3);
}

#search:focus {
    border-color: var(--accent);
    outline: none;
}

#search-count {
    margin: 6px 14px 0;
    color: var(--ink-3);
    font-size: 12px;
    min-height: 1.2em;
}

#search-results,
.d-near {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

#search-results {
    margin: 4px 0 0;
}

#search-results button,
.d-near button {
    padding: 5px 11px;
    border: 1px solid var(--panel-edge);
    border-radius: 999px;
    background: var(--panel);
    color: var(--ink);
    font-size: 13px;
}

#search-results button:hover,
.d-near button:hover {
    border-color: var(--accent);
}

/* Theme switch and repository link. */

#corner {
    top: calc(var(--step) * 3);
    right: calc(var(--step) * 3);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 4px 4px 14px;
    border-radius: 999px;
}

.github-link {
    color: var(--ink-2);
    font-size: 13px;
    text-decoration: none;
}

.github-link:hover {
    color: var(--ink);
}

#theme {
    width: 36px;
    height: 36px;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    background: var(--ink);
    color: var(--sky);
}

#theme svg {
    width: 20px;
    height: 20px;
    overflow: visible;
}

#theme .sun {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

#theme .moon {
    fill: currentColor;
}

#theme .sun,
#theme .moon {
    transform-origin: 12px 12px;
    transition: transform 520ms cubic-bezier(0.22, 1, 0.36, 1), opacity 260ms ease;
}

/* The icon shows the theme a click leads to. */
#theme[aria-pressed="false"] .moon,
#theme[aria-pressed="true"] .sun {
    opacity: 0;
    transform: rotate(-90deg) scale(0.4);
}

/* Coverage. */

#readout {
    right: calc(var(--step) * 3);
    bottom: calc(var(--step) * 3 + 64px);
    width: 232px;
    padding: 6px 16px 12px;
}

.row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: calc(var(--step) * 2);
    padding: 8px 0;
    border-bottom: 1px solid var(--rule);
}

dt {
    color: var(--ink-2);
    font-size: 13px;
}

dd {
    font-variant-numeric: tabular-nums;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: -0.01em;
}

#stat-source {
    margin-top: 10px;
    color: var(--ink-3);
    font-size: 12px;
}

/* Selected domain. */

#detail {
    left: calc(var(--step) * 3);
    bottom: calc(var(--step) * 3);
    width: 320px;
    max-height: calc(100vh - 260px);
    overflow-y: auto;
    padding: 18px 18px 8px;
}

#detail .d-title {
    padding-right: 56px;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

#detail .d-link {
    display: inline-block;
    margin-top: 6px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
    text-underline-offset: 3px;
}

#detail dl {
    margin-top: 12px;
}

#detail dd {
    font-size: 14px;
}

.d-near-block {
    margin-top: 14px;
}

.d-near-block h3 {
    margin-bottom: 8px;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
}

.d-close {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    border: 1px solid var(--panel-edge);
    border-radius: 999px;
    font-size: 12px;
}

/* Navigation. */

button {
    display: inline-flex;
    align-items: center;
    gap: var(--step);
    border: 0;
    background: none;
    color: var(--ink-2);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: color 160ms ease, border-color 160ms ease;
}

button:hover {
    color: var(--ink);
}

button[aria-pressed="true"] {
    color: var(--ink);
}

#controls {
    right: calc(var(--step) * 3);
    bottom: calc(var(--step) * 3);
    display: flex;
    gap: 2px;
    padding: 4px;
    border-radius: 999px;
}

#controls button {
    padding: 9px 12px;
    border-radius: 999px;
}

#controls button:hover {
    background: var(--rule);
}

kbd {
    min-width: 20px;
    padding: 1px 5px;
    border: 1px solid var(--rule);
    border-radius: 5px;
    color: var(--ink-3);
    font-family: inherit;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
}

#hint {
    position: fixed;
    z-index: 2;
    bottom: calc(var(--step) * 4);
    left: 50%;
    transform: translateX(-50%);
    color: var(--ink-3);
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
}

#tip {
    position: fixed;
    z-index: 4;
    max-width: 40ch;
    padding: 8px 12px;
    border: 1px solid var(--panel-edge);
    border-radius: 10px;
    background: var(--panel);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    pointer-events: none;
}

#tip .t-title {
    display: block;
    font-weight: 700;
}

#tip .t-url {
    display: block;
    color: var(--ink-2);
    font-size: 12px;
}

#overlay {
    position: fixed;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--step);
    padding: calc(var(--step) * 4);
    background: var(--sky);
    text-align: center;
}

#overlay[hidden] {
    display: none;
}

#overlay h2 {
    font-size: clamp(26px, 4vw, 36px);
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.1;
    text-wrap: balance;
}

#overlay p {
    max-width: 46ch;
    color: var(--ink-2);
}

#overlay-action {
    margin-top: calc(var(--step) * 2);
    padding: 9px 18px;
    border-radius: 999px;
    background: var(--ink);
    color: var(--sky);
}

#debug {
    position: fixed;
    top: calc(var(--step) * 1.5);
    left: 50%;
    z-index: 5;
    transform: translateX(-50%);
    color: var(--ink-3);
    font-size: 12px;
    pointer-events: none;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

@keyframes fade {
    to { opacity: 0; }
}

#readout:not([hidden]),
#controls:not([hidden]) {
    animation: rise 900ms cubic-bezier(0.16, 1, 0.3, 1) 120ms backwards;
}

#hint:not([hidden]) {
    animation: fade 1200ms ease 9s forwards;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
    }

    #hint {
        animation: none;
    }
}

@media (max-width: 760px) {
    #mark {
        top: calc(var(--step) * 2);
        left: calc(var(--step) * 2);
        width: calc(100vw - var(--step) * 4);
    }

    #mark > p {
        font-size: 13px;
    }

    #corner {
        top: calc(var(--step) * 2);
        right: calc(var(--step) * 2);
    }

    #readout {
        display: none;
    }

    #controls {
        left: calc(var(--step) * 2);
        right: calc(var(--step) * 2);
        bottom: calc(var(--step) * 2);
        justify-content: space-between;
    }

    #controls kbd {
        display: none;
    }

    #detail {
        left: calc(var(--step) * 2);
        right: calc(var(--step) * 2);
        bottom: calc(var(--step) * 2 + 60px);
        width: auto;
        max-height: 46vh;
    }

    #hint {
        display: none;
    }
}
