/* Self-hosted so the type never depends on a third party.
   Licences and copyright notices: fonts/OFL.txt */
@font-face {
    font-family: 'Plex Mono';
    src: url('fonts/plex-mono-400-latin.woff2') format('woff2');
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Plex Mono';
    src: url('fonts/plex-mono-600-latin.woff2') format('woff2');
    font-weight: 600; font-style: normal; font-display: swap;
}

/* ══════════════════════════════════════════════════════════════════════════
   allkitty — a media fetcher that looks like the tool it is.

   One typeface, one accent, hairline rules, tabular numbers. Hierarchy comes
   from weight and opacity, never from decoration.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
    --bg:      #0b0d10;
    --panel:   #0f1216;
    --raised:  #141920;
    --rule:    #1c222b;
    --rule-hi: #2a323d;

    --ink:     #ccd4de;   /* body */
    --ink-hi:  #eef3f8;   /* headings, values */
    --ink-dim: #6d7986;   /* labels, meta */

    --accent:  #f2a65a;   /* one signal colour */
    --ok:      #7ee787;
    --bad:     #ff7b72;
    --info:    #79c0ff;

    --mono: 'Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* one spacing scale, used everywhere */
    --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
    --s5: 24px; --s6: 32px; --s7: 48px;

    --fs-micro: 11px;
    --fs-small: 12px;
    --fs-body:  13.5px;
    --fs-lead:  15px;

    --radius: 6px;
    --wrap: 940px;
}

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

/* author display rules beat the UA sheet, so [hidden] needs saying out loud */
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
    min-height: 100dvh;
    background: var(--bg);
    color: var(--ink);
    font: 400 var(--fs-body)/1.65 var(--mono);
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    padding: var(--s6) var(--s4) var(--s7);
}

::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); color: var(--ink-hi); }

.grain {
    position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .035;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip {
    position: fixed; top: var(--s3); left: 50%; z-index: 60;
    transform: translate(-50%, -220%);
    background: var(--accent); color: #12161b; text-decoration: none;
    padding: var(--s2) var(--s4); border-radius: var(--radius);
    font-size: var(--fs-small); transition: transform .16s;
}
.skip:focus { transform: translate(-50%, 0); }

.app {
    position: relative; z-index: 1;
    max-width: var(--wrap); margin: 0 auto;
    display: flex; flex-direction: column; gap: var(--s5);
}

.dim { color: var(--ink-dim); }
.accent { color: var(--accent); }

/* ══ title bar ══════════════════════════════════════════════════════════ */
.bar {
    display: flex; align-items: baseline; gap: var(--s3);
    padding-bottom: var(--s3);
    border-bottom: 1px solid var(--rule);
}
.bar-brand {
    font-size: var(--fs-lead); font-weight: 600; color: var(--ink-hi);
    letter-spacing: -.01em;
}
.bar-brand::before { content: '❯ '; color: var(--accent); font-weight: 400; }
.bar-sub { font-size: var(--fs-small); color: var(--ink-dim); }
.bar-spacer { flex: 1; }
.bar-status {
    display: inline-flex; align-items: center; gap: var(--s2);
    font-size: var(--fs-small); color: var(--ink-dim);
}

.dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--ink-dim);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink-dim) 14%, transparent);
}
.dot[data-state="ok"]   { background: var(--ok);  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 16%, transparent); }
.dot[data-state="bad"]  { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 16%, transparent); }
.dot[data-state="busy"] { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

/* ══ banner ═════════════════════════════════════════════════════════════ */
.banner {
    display: grid; grid-template-columns: auto 1fr; gap: var(--s7);
    align-items: center;
    padding: var(--s5) var(--s5);
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
}

.cat {
    font-family: var(--mono);
    font-size: 19px; line-height: 1.3;
    color: var(--accent);
    white-space: pre;
    cursor: pointer;
    user-select: none;
    /* the art is authored on a fixed grid; keep it from being nudged */
    letter-spacing: .04em;
    transition: color .2s;
}
.cat:hover { color: color-mix(in srgb, var(--accent) 70%, var(--ink-hi)); }

.spec { display: grid; gap: 2px; align-content: center; min-width: 0; }
.spec-row {
    display: grid; grid-template-columns: 84px 1fr; gap: var(--s3);
    align-items: baseline;
}
.spec dt {
    font-size: var(--fs-small); color: var(--ink-dim);
    text-transform: lowercase; letter-spacing: .02em;
}
.spec dd {
    color: var(--ink-hi); min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ══ prompt ═════════════════════════════════════════════════════════════ */
.prompt {
    display: flex; align-items: center; gap: var(--s3);
    padding: var(--s3) var(--s4);
    background: var(--raised);
    border: 1px solid var(--rule-hi);
    border-radius: var(--radius);
    transition: border-color .16s, box-shadow .16s;
}
.prompt:focus-within {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--rule-hi));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.prompt-sigil { color: var(--accent); font-weight: 600; }

#url {
    flex: 1; min-width: 0;
    background: none; border: 0; outline: none;
    color: var(--ink-hi); font: inherit; font-size: var(--fs-lead);
    caret-color: var(--accent);
}
#url::placeholder { color: var(--ink-dim); }

.btn {
    flex: none; cursor: pointer;
    font: inherit; font-size: var(--fs-small);
    padding: 6px var(--s3);
    border-radius: 4px; border: 1px solid transparent;
    background: none; color: var(--ink-dim);
    transition: color .14s, background .14s, border-color .14s;
}
.btn:hover { color: var(--ink-hi); }
.btn.ghost { border-color: var(--rule-hi); }
.btn.ghost:hover { border-color: var(--ink-dim); }
.btn.primary {
    background: var(--accent); color: #12161b; font-weight: 600;
    border-color: var(--accent);
}
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.danger { border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }

/* ══ flags ══════════════════════════════════════════════════════════════ */
.flags { display: grid; gap: var(--s2); }
.flag { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.flag-key {
    width: 84px; flex: none;
    font-size: var(--fs-small); color: var(--ink-dim);
}
.opts { display: flex; gap: var(--s1); flex-wrap: wrap; }
.opts button {
    cursor: pointer; font: inherit; font-size: var(--fs-small);
    padding: 3px 10px; border-radius: 4px;
    border: 1px solid var(--rule); background: none; color: var(--ink-dim);
    transition: color .14s, border-color .14s, background .14s;
}
.opts button:hover { color: var(--ink); border-color: var(--rule-hi); }
.opts button[aria-pressed="true"] {
    color: var(--ink-hi);
    border-color: color-mix(in srgb, var(--accent) 55%, transparent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.opts button[aria-pressed="true"]::before { content: '● '; color: var(--accent); }
.opts button[aria-pressed="false"]::before { content: '○ '; opacity: .5; }

/* ══ panels ═════════════════════════════════════════════════════════════ */
.panel {
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--s2) var(--s4);
    border-bottom: 1px solid var(--rule);
    background: color-mix(in srgb, var(--raised) 55%, transparent);
}
.panel-title {
    font-size: var(--fs-micro); color: var(--ink-dim);
    text-transform: uppercase; letter-spacing: .14em;
}
.panel-meta { font-size: var(--fs-small); color: var(--ink-dim); }

.linkish {
    background: none; border: 0; cursor: pointer;
    font: inherit; font-size: var(--fs-small); color: var(--ink-dim);
    text-decoration: underline; text-underline-offset: 3px;
    text-decoration-color: var(--rule-hi);
}
.linkish:hover { color: var(--accent); text-decoration-color: currentColor; }

/* ── transcript ─────────────────────────────────────────────────────── */
.log {
    list-style: none;
    max-height: 210px; overflow-y: auto;
    padding: var(--s3) var(--s4);
    font-size: var(--fs-small);
    display: flex; flex-direction: column; gap: 2px;
    scrollbar-width: thin; scrollbar-color: var(--rule-hi) transparent;
}
.log:empty::after {
    content: 'waiting for a link…';
    color: var(--ink-dim);
}
.log li { display: grid; grid-template-columns: 62px 74px 1fr; gap: var(--s3); }
.log .t { color: var(--ink-dim); }
.log .k { text-transform: lowercase; }
.log .m { color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.log li[data-kind="ok"]   .k { color: var(--ok); }
.log li[data-kind="bad"]  .k { color: var(--bad); }
.log li[data-kind="work"] .k { color: var(--accent); }
.log li[data-kind="info"] .k { color: var(--info); }

.meter {
    display: flex; align-items: center; gap: var(--s3);
    padding: var(--s3) var(--s4);
    border-top: 1px solid var(--rule);
    font-size: var(--fs-small); color: var(--ink-dim);
}
.meter-track {
    flex: 1; height: 3px; border-radius: 2px;
    background: var(--rule);
    position: relative; overflow: hidden;
}
/* Indeterminate on purpose: the queue reports state, not a percentage, so a
   number here would be invented. A travelling band says "working" honestly. */
.meter-track::after {
    content: ''; position: absolute; inset: 0 auto 0 0;
    width: 34%; border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: sweep 1.35s cubic-bezier(.5, 0, .5, 1) infinite;
}
@keyframes sweep {
    from { transform: translateX(-110%); }
    to   { transform: translateX(320%); }
}
.meter-label { flex: none; color: var(--accent); }

/* ── history ────────────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--rule-hi) transparent; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
.tbl th, .tbl td {
    text-align: left; padding: var(--s2) var(--s4);
    white-space: nowrap;
}
.tbl th {
    font-weight: 400; font-size: var(--fs-micro);
    color: var(--ink-dim); text-transform: uppercase; letter-spacing: .12em;
    border-bottom: 1px solid var(--rule);
}
.tbl tbody tr { border-bottom: 1px solid color-mix(in srgb, var(--rule) 55%, transparent); }
.tbl tbody tr:last-child { border-bottom: 0; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--raised) 60%, transparent); }
.tbl .c-nm { width: 100%; }
.tbl td.c-nm {
    color: var(--ink-hi);
    max-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.tbl td.c-sz, .tbl td.c-wh { color: var(--ink-dim); }
.tbl .empty { color: var(--ink-dim); padding: var(--s5) var(--s4); }
.st { display: inline-flex; align-items: center; gap: var(--s2); }
.st[data-s="completed"] { color: var(--ok); }
.st[data-s="failed"]    { color: var(--bad); }
.st[data-s="pending"], .st[data-s="processing"] { color: var(--accent); }

.get {
    background: none; border: 0; padding: 0; cursor: pointer;
    font: inherit; color: inherit; text-align: left;
    text-decoration: underline; text-underline-offset: 3px;
    text-decoration-color: var(--rule-hi);
}
.get:hover { color: var(--accent); text-decoration-color: currentColor; }

/* ══ footer ═════════════════════════════════════════════════════════════ */
.foot {
    display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap;
    padding-top: var(--s3);
    border-top: 1px solid var(--rule);
    font-size: var(--fs-small); color: var(--ink-dim);
}
.foot-spacer { flex: 1; }
kbd {
    font: inherit; font-size: var(--fs-micro);
    padding: 2px 6px; border-radius: 3px;
    background: var(--raised); border: 1px solid var(--rule-hi);
    color: var(--ink);
}

/* ══ focus ══════════════════════════════════════════════════════════════ */
:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
    outline-offset: 2px; border-radius: 3px;
}

/* ══ narrow ═════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
    body { padding: var(--s4) var(--s3) var(--s6); }

    .bar { flex-wrap: wrap; row-gap: var(--s1); }
    .bar-spacer { display: none; }
    .bar-status { margin-left: auto; }

    .banner { grid-template-columns: 1fr; gap: var(--s4); justify-items: start; }
    .cat { font-size: 15px; }
    .spec { width: 100%; }
    .spec-row { grid-template-columns: 72px 1fr; }

    .flag-key { width: 100%; }

    /* stack: field on its own line, actions beneath. The sigil is decoration
       and only gets in the way once the row wraps. */
    .prompt { flex-wrap: wrap; row-gap: var(--s3); }
    .prompt-sigil { display: none; }
    #url { flex-basis: 100%; font-size: var(--fs-body); }
    .prompt .btn { flex: 1; }

    .log li { grid-template-columns: 56px 62px 1fr; gap: var(--s2); }

    /* drop the least load-bearing columns rather than squeeze every one */
    .tbl .c-fm, .tbl .c-sz { display: none; }
    .tbl th, .tbl td { padding-left: var(--s3); padding-right: var(--s3); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important; animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
    .meter-track::after { animation: none; width: 100%; opacity: .5; }
}
