/*
 * Goskunk web bundles — shared stylesheet.
 *
 * Used by all three Dioxus bundles (public, admin, contributors). Every class is
 * namespaced with `goskunk-` and the component rules are prefixed with one of the
 * three bundle roots, so this can be served alongside older pages without
 * touching their markup.
 *
 * Served by each host server at /goskunk.css from
 * `goskunk_web_shared::style::STYLESHEET` (embedded with include_str!). No
 * external fonts or imports: a self-hosted search engine should not phone home.
 */

:root {
    color-scheme: light dark;

    /* Warm paper, deep ink. A results page is read, not viewed, so the palette
       stays quiet and the results carry the colour. */
    --goskunk-bg: #fbfaf7;
    --goskunk-surface: #f3f1ea;
    --goskunk-border: #e2dfd4;
    --goskunk-text: #1a1b17;
    --goskunk-muted: #61645a;
    --goskunk-accent: #1d4ed8;
    --goskunk-accent-contrast: #ffffff;
    --goskunk-ring: rgb(29 78 216 / 20%);
    --goskunk-danger: #b42318;
    --goskunk-success: #146c43;

    --goskunk-radius: 10px;
    --goskunk-radius-sm: 7px;
    --goskunk-gap: 0.75rem;
    --goskunk-pad: 1rem;
    --goskunk-max-width: 62rem;

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

    --goskunk-shadow: 0 1px 2px rgb(24 22 16 / 6%), 0 1px 3px rgb(24 22 16 / 9%);
}

@media (prefers-color-scheme: dark) {
    :root {
        --goskunk-bg: #131417;
        --goskunk-surface: #1b1d21;
        --goskunk-border: #2b2e33;
        --goskunk-text: #e9e7e1;
        --goskunk-muted: #9b9e95;
        --goskunk-accent: #8ab4ff;
        --goskunk-accent-contrast: #0d1017;
        --goskunk-ring: rgb(138 180 255 / 22%);
        --goskunk-danger: #f2857a;
        --goskunk-success: #6fd39b;
        --goskunk-shadow: none;
    }
}

/* ── Shared base ─────────────────────────────────────────────────────────────
   Applied to all three bundle roots. `min-height` + flex column keeps the footer
   area stable on short pages like "not found". */

.goskunk-app,
.goskunk-admin,
.goskunk-contributors {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    background: var(--goskunk-bg);
    color: var(--goskunk-text);
    font-family: var(--goskunk-font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

.goskunk-app *,
.goskunk-admin *,
.goskunk-contributors * {
    box-sizing: border-box;
}

.goskunk-app a,
.goskunk-admin a,
.goskunk-contributors a {
    color: var(--goskunk-accent);
    text-decoration: none;
}

.goskunk-app a:hover,
.goskunk-admin a:hover,
.goskunk-contributors a:hover {
    text-decoration: underline;
}

.goskunk-app :focus-visible,
.goskunk-admin :focus-visible,
.goskunk-contributors :focus-visible {
    outline: 2px solid var(--goskunk-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ── Header / nav ────────────────────────────────────────────────────────── */

.goskunk-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--goskunk-gap);
    width: 100%;
    max-width: var(--goskunk-max-width);
    margin: 0 auto;
    padding: var(--goskunk-pad) var(--goskunk-pad) 0;
}

.goskunk-brand {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--goskunk-text);
}

a.goskunk-brand:hover {
    text-decoration: none;
    color: var(--goskunk-accent);
}

.goskunk-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--goskunk-gap);
    margin-left: auto;
    font-size: 0.9375rem;
}

/* ── Main ────────────────────────────────────────────────────────────────── */

.goskunk-main {
    flex: 1;
    width: 100%;
    max-width: var(--goskunk-max-width);
    margin: 0 auto;
    padding: var(--goskunk-pad);
}

.goskunk-section {
    margin-bottom: 2rem;
}

.goskunk-section h1 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
}

.goskunk-section h2 {
    margin: 0 0 0.75rem;
    font-size: 1.125rem;
    letter-spacing: -0.01em;
}

/* ── Home / search box ───────────────────────────────────────────────────── */

.goskunk-home {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding-top: 16vh;
    text-align: center;
}

/* The wordmark is the page's only display type. Tight tracking at a large size
   is what makes it read as a mark rather than as a heading. */
.goskunk-wordmark {
    margin: 0;
    font-size: clamp(2.75rem, 8vw, 4.25rem);
    font-weight: 650;
    line-height: 1;
    letter-spacing: -0.05em;
}

.goskunk-home p {
    margin: 0.75rem 0 2.25rem;
    color: var(--goskunk-muted);
}

/* Positioning context for the suggestion list, which is a sibling of the form
   rather than a child so that `.goskunk-searchbar button` (the accent-filled
   submit button) does not style the suggestion rows. */
.goskunk-searchbox {
    position: relative;
    width: 100%;
    max-width: 40rem;
}

.goskunk-searchbar {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

/* Shared field look: the search box and standalone fields (such as the
   contributors' access token) read as the same control. */
.goskunk-searchbar input,
.goskunk-input {
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--goskunk-border);
    border-radius: var(--goskunk-radius);
    background: var(--goskunk-bg);
    color: inherit;
    font: inherit;
}

/* Only the search box's field stretches to fill its flex row. */
.goskunk-searchbar input {
    flex: 1;
    min-width: 0;
    padding: 0.8125rem 1rem;
    font-size: 1.0625rem;
    border-radius: var(--goskunk-radius);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

/* Focus belongs to the control, not to the field inside it: the ring hugs the
   box the user is actually looking at. */
.goskunk-searchbox:focus-within .goskunk-searchbar input {
    border-color: var(--goskunk-accent);
    box-shadow: 0 0 0 3px var(--goskunk-ring);
    outline: none;
}

.goskunk-searchbar input::placeholder,
.goskunk-input::placeholder {
    color: var(--goskunk-muted);
}

/* WebKit draws its own clear button that clashes with the field padding. */
.goskunk-searchbar input[type="search"]::-webkit-search-cancel-button {
    margin-right: 0.25rem;
}

/* ── Autocomplete ────────────────────────────────────────────────────────── */

.goskunk-suggestions {
    position: absolute;
    z-index: 20;
    top: calc(100% + 0.25rem);
    right: 0;
    left: 0;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    border: 1px solid var(--goskunk-border);
    border-radius: var(--goskunk-radius);
    background: var(--goskunk-bg);
    box-shadow: 0 8px 24px rgb(16 24 40 / 12%);
    /* The home page centres its children; the rows stay left-aligned. */
    text-align: left;
}

.goskunk-suggestion {
    display: block;
    width: 100%;
    padding: 0.4375rem 0.625rem;
    border: 0;
    border-radius: var(--goskunk-radius-sm);
    background: none;
    color: var(--goskunk-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.goskunk-suggestion-active,
.goskunk-suggestion:hover {
    background: var(--goskunk-surface);
}

/* The matched span of a suggestion row or a result snippet. */
.goskunk-hit {
    font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.goskunk-searchbar button,
.goskunk-actions button {
    padding: 0.625rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--goskunk-radius);
    background: var(--goskunk-accent);
    color: var(--goskunk-accent-contrast);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

.goskunk-searchbar button:hover,
.goskunk-actions button:hover:not(:disabled) {
    filter: brightness(1.08);
}

.goskunk-actions button:disabled {
    background: var(--goskunk-surface);
    border-color: var(--goskunk-border);
    color: var(--goskunk-muted);
    cursor: not-allowed;
}

.goskunk-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: var(--goskunk-gap);
}

/* The "Refresh" button is secondary to start/stop. */
.goskunk-actions button:last-child {
    background: var(--goskunk-surface);
    border-color: var(--goskunk-border);
    color: var(--goskunk-text);
}

/* ── SERP ────────────────────────────────────────────────────────────────── */

/* The bar stays put. Searching again must never mean scrolling to the top or
   going back to the home page. */
.goskunk-serp-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    padding: 0.75rem 0;
    background: var(--goskunk-bg);
    border-bottom: 1px solid var(--goskunk-border);
}

.goskunk-search .goskunk-searchbox {
    max-width: none;
    margin-bottom: 0;
}

.goskunk-stats {
    margin: 0 0 var(--goskunk-pad);
    color: var(--goskunk-muted);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.goskunk-results {
    margin: 0;
    padding: 0;
    list-style: none;
}

.goskunk-result {
    margin-bottom: 2rem;
}

.goskunk-result-title {
    display: inline-block;
    font-size: 1.125rem;
    font-weight: 550;
    line-height: 1.3;
    letter-spacing: -0.011em;
    color: var(--goskunk-text);
}

/* The title carries the link, so it takes the accent on approach rather than at
   rest; a page of blue headings is harder to scan than a page of ink ones. */
a.goskunk-result-title:hover {
    color: var(--goskunk-accent);
    text-decoration: none;
}

.goskunk-result-url {
    margin-top: 0.1875rem;
    color: var(--goskunk-muted);
    font-size: 0.8125rem;
    letter-spacing: 0.005em;
    word-break: break-all;
}

.goskunk-result-snippet {
    max-width: 68ch;
    margin: 0.375rem 0 0;
    color: var(--goskunk-text);
    font-size: 0.9375rem;
    line-height: 1.55;
}

/* ── SERP layout + sidebar ───────────────────────────────────────────────── */

.goskunk-serp {
    display: grid;
    gap: var(--goskunk-pad);
}

/* Grid items default to `min-width: auto`, which lets a long unbreakable URL
   push the results column wider than its share. */
.goskunk-results-column {
    min-width: 0;
}

/* The aside column is only reserved when there is a panel to put in it, so an
   ordinary query keeps the full width. */
@media (min-width: 72rem) {
    .goskunk-serp-aside {
        grid-template-columns: minmax(0, 1fr) 20rem;
    }
}

.goskunk-sidebar {
    align-self: start;
}

.goskunk-sidebar-card {
    padding: var(--goskunk-pad);
    border: 1px solid var(--goskunk-border);
    border-radius: var(--goskunk-radius);
    background: var(--goskunk-surface);
}

.goskunk-sidebar-kicker {
    margin: 0 0 0.375rem;
    color: var(--goskunk-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.goskunk-sidebar-title {
    margin: 0 0 0.5rem;
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.goskunk-sidebar-abstract {
    margin: 0 0 0.75rem;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.goskunk-sidebar-info {
    margin: 0;
    font-size: 0.875rem;
}

.goskunk-sidebar-info-entry + .goskunk-sidebar-info-entry {
    margin-top: 0.375rem;
}

.goskunk-sidebar-info-entry dt {
    color: var(--goskunk-muted);
    font-weight: 600;
}

.goskunk-sidebar-info-entry dd {
    margin: 0;
}

.goskunk-sidebar-url {
    display: block;
    font-size: 0.8125rem;
    word-break: break-all;
}

.goskunk-sidebar-meta {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0 0;
    color: var(--goskunk-muted);
    font-size: 0.8125rem;
}

.goskunk-sidebar-accepted {
    color: var(--goskunk-success);
    font-weight: 600;
}

/* An inline link inside an entity abstract or info value. */
.goskunk-entity-link {
    text-decoration: underline;
}

/* ── Stat cards ──────────────────────────────────────────────────────────── */

.goskunk-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: var(--goskunk-gap);
}

.goskunk-card {
    padding: 0.875rem var(--goskunk-pad);
    border: 1px solid var(--goskunk-border);
    border-radius: var(--goskunk-radius);
    background: var(--goskunk-surface);
    box-shadow: var(--goskunk-shadow);
}

.goskunk-card-value {
    font-size: 1.375rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.goskunk-card-label {
    margin-top: 0.125rem;
    color: var(--goskunk-muted);
    font-size: 0.8125rem;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */

.goskunk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.goskunk-table th,
.goskunk-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--goskunk-border);
    text-align: left;
    vertical-align: top;
}

.goskunk-table th {
    color: var(--goskunk-muted);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.goskunk-table tbody tr:hover {
    background: var(--goskunk-surface);
}

.goskunk-table td:nth-child(n + 3) {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ── Status / badge ──────────────────────────────────────────────────────── */

.goskunk-status {
    margin: 0;
    font-size: 1.0625rem;
}

.goskunk-status strong {
    font-weight: 600;
}

.goskunk-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.0625rem 0.4375rem;
    border: 1px solid var(--goskunk-border);
    border-radius: 999px;
    background: var(--goskunk-surface);
    color: var(--goskunk-muted);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: 1px;
}

/* ── States: error / empty / hint / not found ────────────────────────────── */

.goskunk-error {
    margin: 0.5rem 0 0;
    color: var(--goskunk-danger);
    font-size: 0.9375rem;
}

/* Loading: the shape of the answer rather than the word "Searching", so the
   page does not jump when the results arrive. */
.goskunk-skeletons {
    display: grid;
    gap: 1.75rem;
}

.goskunk-skeleton {
    height: 4.25rem;
    border-radius: var(--goskunk-radius-sm);
    background: var(--goskunk-surface);
    animation: goskunk-skeleton-pulse 1.6s ease-in-out infinite;
}

@keyframes goskunk-skeleton-pulse {
    0%,
    100% {
        opacity: 0.55;
    }

    50% {
        opacity: 1;
    }
}

/* Empty: naming the query leaves no doubt about what found nothing. */
.goskunk-empty-state {
    padding: 2.5rem 0 1rem;
    border-top: 1px solid var(--goskunk-border);
}

.goskunk-empty-title {
    margin: 0 0 0.375rem;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.goskunk-empty-hint {
    max-width: 52ch;
    margin: 0;
    color: var(--goskunk-muted);
    font-size: 0.9375rem;
}

.goskunk-empty,
.goskunk-hint {
    margin: 0;
    color: var(--goskunk-muted);
    font-size: 0.9375rem;
}

.goskunk-not-found {
    padding-top: 12vh;
    text-align: center;
}

.goskunk-not-found h1 {
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
}

.goskunk-not-found p {
    margin: 0 0 1rem;
    color: var(--goskunk-muted);
    font-family: var(--goskunk-mono);
    font-size: 0.875rem;
}

@media (prefers-reduced-motion: reduce) {
    .goskunk-app *,
    .goskunk-admin *,
    .goskunk-contributors * {
        transition: none !important;
        animation: none !important;
    }
}

/* ── settings gear and panel ──────────────────────────────────────────────── */

.goskunk-gear {
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 40;
    width: 2.25rem;
    height: 2.25rem;
    display: grid;
    place-items: center;
    border: 1px solid var(--goskunk-border);
    border-radius: var(--goskunk-radius-sm);
    background: var(--goskunk-surface);
    color: var(--goskunk-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.goskunk-gear:hover {
    color: var(--goskunk-text);
    border-color: var(--goskunk-text);
}

.goskunk-settings-panel {
    position: fixed;
    top: 3.5rem;
    right: 0.75rem;
    z-index: 50;
    width: min(22rem, calc(100vw - 1.5rem));
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: var(--goskunk-gap);
    background: var(--goskunk-bg);
    border: 1px solid var(--goskunk-border);
    border-radius: var(--goskunk-radius);
    box-shadow: 0 12px 32px rgb(0 0 0 / 14%);
}

.goskunk-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.goskunk-panel-title {
    font-weight: 650;
}

.goskunk-panel-close {
    border: none;
    background: transparent;
    color: var(--goskunk-muted);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.25rem 0.4rem;
    cursor: pointer;
}

.goskunk-panel-close:hover {
    color: var(--goskunk-text);
}

.goskunk-panel-section {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.goskunk-panel-label {
    margin: 0;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--goskunk-muted);
}

.goskunk-panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.goskunk-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--goskunk-muted);
}

.goskunk-button {
    padding: 0.5rem 0.85rem;
    border: 1px solid transparent;
    border-radius: var(--goskunk-radius-sm);
    background: var(--goskunk-accent);
    color: var(--goskunk-accent-contrast);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

.goskunk-button:hover {
    filter: brightness(1.08);
}

.goskunk-button-quiet {
    background: transparent;
    border-color: var(--goskunk-border);
    color: var(--goskunk-text);
}

.goskunk-engine {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--goskunk-border);
    border-radius: var(--goskunk-radius-sm);
    background: transparent;
    color: var(--goskunk-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.goskunk-engine:hover {
    border-color: var(--goskunk-muted);
}

/* Selected state is a ring, not a fill: a fill would read as a button being
   pressed rather than as a setting being on. */
.goskunk-engine-on {
    border-color: var(--goskunk-accent);
    box-shadow: inset 0 0 0 1px var(--goskunk-accent);
}

.goskunk-engine-state {
    color: var(--goskunk-muted);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.goskunk-engine-on .goskunk-engine-state {
    color: var(--goskunk-accent);
}

.goskunk-note {
    margin: 0;
    color: var(--goskunk-muted);
    font-size: 0.85rem;
    line-height: 1.45;
}

.goskunk-note-detail {
    opacity: 0.8;
}

/* The TOTP enrolment secret.
   `user-select: all` so one click selects the whole value: it is a credential
   that has to survive being retyped into a phone, and selecting it by hand
   across a line break is how people mistype one character and conclude the
   server is broken. */
.goskunk-secret {
    display: block;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--goskunk-border);
    border-radius: var(--goskunk-radius-sm);
    background: var(--goskunk-surface);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    word-break: break-all;
    user-select: all;
}

/* The `otpauth://` URI is long and mostly boilerplate; it is there for clients
   that take a URI, so it stays quieter than the secret above it. */
.goskunk-secret-uri {
    font-size: 0.7rem;
    opacity: 0.75;
}

.goskunk-code-input {
    max-width: 9rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.15em;
}

.goskunk-totp-on {
    color: var(--goskunk-success);
}

.goskunk-error {
    margin: 0;
    color: var(--goskunk-danger);
    font-size: 0.85rem;
}
