/* Moth, the bug tracker. Shade's and Shadow's dusk with a lamp lit in it: the site's own surfaces and text, and one violet
   light (--mth-lamp), the family's purple, that marks what to look at — the open queue, the key of an issue, the tab you are
   on. The lamp is darker on a light page and paler on a dark one, so a key drawn in it reads on either; --mth-lamp-ink is the
   text that reads on the lamp itself. Pills take the colour each choice was given in the admin (--mth-c) and the ink that
   reads on it (--mth-ink), worked out on the server. */

.mth {
    --mth-lamp: #7c3aed;
    --mth-lamp-ink: #ffffff;
    --mth-lamp-soft: color-mix(in srgb, var(--mth-lamp) 12%, var(--rl-surface));
    --mth-glow: 0 0 0 1px color-mix(in srgb, var(--mth-lamp) 35%, transparent), 0 8px 28px -12px color-mix(in srgb, var(--mth-lamp) 55%, transparent);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .mth { --mth-lamp: #c084fc; --mth-lamp-ink: #1a0b2e; }
}
:root[data-theme="dark"] .mth { --mth-lamp: #c084fc; --mth-lamp-ink: #1a0b2e; }

.mth-hero .hero__orb { background: radial-gradient(circle at 40% 40%, hsl(var(--hero-hue) 91% 66% / .5), transparent 62%); }

.mth-tabs { margin: 0 0 1rem; max-width: 100%; overflow-x: auto; }
.mth-subtabs { margin: 0 0 .9rem; max-width: 100%; overflow-x: auto; }
.mth-muted { color: var(--rl-text-muted); font-size: .85em; }
.mth-label { display: block; font-weight: 600; font-size: .82rem; color: var(--rl-text-muted); text-transform: uppercase; letter-spacing: .05em; margin: .2rem 0 .1rem; }
.mth-key { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-weight: 700; color: var(--mth-lamp); letter-spacing: .02em; }
.mth-upper { text-transform: uppercase; }
.mth-mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85rem; }
.mth-check { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; cursor: pointer; }
.mth-inline { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.mth-inline input:not([type=checkbox], [type=color]), .mth-inline select, .mth-side input, .mth-side select, .mth-side textarea,
.mth-movebox textarea, .mth-movebox select, .mth-composer__box {
    padding: .32rem .55rem; border: 1px solid var(--rl-border); border-radius: 8px; background: var(--rl-surface-raised);
    color: inherit; font: inherit; font-size: .9rem; min-width: 0; max-width: 100%;
}
.mth-addrow { margin-top: .7rem; padding-top: .7rem; border-top: 1px dashed var(--rl-border); }
/* A row being edited in place lays its swatch and fields out in a line, not in the column .ui-row__main stacks its title in. */
.ui-row__main.mth-inline { flex-direction: row; align-items: center; justify-content: flex-start; }
.mth-addrow input:not([type=checkbox], [type=color]), .ui-row__main.mth-inline input:not([type=checkbox], [type=color]) { flex: 1 1 12rem; }
.mth-swatch { width: 2.1rem; height: 2rem; padding: .1rem; border: 1px solid var(--rl-border); border-radius: 8px; background: none; cursor: pointer; }
.mth-tagline { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; padding: .05rem .4rem; border-radius: 99px; background: var(--rl-surface-sunken); color: var(--rl-text-muted); margin-left: .35rem; }
.mth-retired { opacity: .6; }
.mth-done { text-decoration: line-through; text-decoration-color: var(--rl-text-muted); }
.mth-lock { width: .85rem; height: .85rem; vertical-align: -.1rem; margin-right: .25rem; color: var(--mth-lamp); }
.mth-h { margin: 1rem 0 .35rem; font-size: .95rem; }
.mth-steps { margin: 0; padding-left: 1.2rem; display: grid; gap: .35rem; }

/* ---- pills -------------------------------------------------------------------------------------------------------- */

.mth-pill {
    display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 99px; border: 0;
    background: var(--mth-c, #94a3b8); color: var(--mth-ink, #111827); font-size: .76rem; font-weight: 650; line-height: 1.35;
    white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.mth-pill--lg { font-size: .85rem; padding: .2rem .7rem; }
.mth-pill--dot { background: none; color: inherit; font-weight: 500; padding-left: 0; }
.mth-pill--dot::before { content: ""; width: .55rem; height: .55rem; border-radius: 50%; background: var(--mth-c); box-shadow: 0 0 6px var(--mth-c); flex: none; }
.mth-pill--tag { background: color-mix(in srgb, var(--mth-c) 22%, transparent); color: var(--rl-text); border: 1px solid color-mix(in srgb, var(--mth-c) 55%, transparent); font-weight: 600; }
.mth-pill--pick { cursor: pointer; background: var(--rl-surface-sunken); color: var(--rl-text); border: 1px solid var(--rl-border); transition: background var(--rl-dur), transform var(--rl-dur); }
.mth-pill--pick[style] { background: color-mix(in srgb, var(--mth-c) 16%, transparent); border-color: color-mix(in srgb, var(--mth-c) 50%, transparent); }
.mth-pill--pick:hover { transform: translateY(-1px); }
.mth-pill--pick.is-on { background: var(--mth-c, var(--mth-lamp)); color: var(--mth-ink, #111827); border-color: transparent; }
.mth-pill--pick:not([style]).is-on { background: var(--mth-lamp); color: var(--mth-lamp-ink); }
.mth-pill__x { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 .15rem; font-size: .95rem; line-height: 1; opacity: .7; }
.mth-pill__x:hover { opacity: 1; }
.mth-tagpick { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }

/* ---- the status flow on the front page --------------------------------------------------------------------------- */

.mth-flow { display: flex; gap: .5rem; overflow-x: auto; padding: .1rem .1rem .6rem; margin: 0 0 1rem; scroll-snap-type: x proximity; }
.mth-flow__step {
    flex: 1 0 7.5rem; scroll-snap-align: start; display: flex; flex-direction: column; gap: .1rem; padding: .7rem .85rem;
    border-radius: 12px; text-decoration: none; color: var(--rl-text); background: var(--rl-surface);
    border: 1px solid var(--rl-border); border-top: 3px solid var(--mth-c); transition: box-shadow var(--rl-dur), transform var(--rl-dur);
}
.mth-flow__step:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -14px var(--mth-c); }
.mth-flow__count { font-size: 1.6rem; font-weight: 750; line-height: 1; }
.mth-flow__name { font-size: .8rem; color: var(--rl-text-muted); }

.mth-board { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); margin-bottom: 1rem; }
.mth-board > .ui-card { margin: 0; }
.mth-project--archived { opacity: .65; }

/* ---- issue list: a grid on a wide screen, a card per issue on a phone ------------------------------------------- */

.mth-list { display: flex; flex-direction: column; border: 1px solid var(--rl-border); border-radius: 12px; overflow: hidden; background: var(--rl-surface); }
.mth-list__head, .mth-row {
    display: grid; grid-template-columns: minmax(0, 1fr) 8.5rem 7rem 7rem 8.5rem 6.5rem; gap: .75rem; align-items: center; padding: .6rem .9rem;
}
.mth-list--compact .mth-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main status" "main who"; row-gap: .2rem; }
.mth-list--compact .mth-row__main { grid-area: main; }
.mth-list--compact .mth-row__status { grid-area: status; justify-self: end; }
.mth-list--compact .mth-row__who { display: none; }
.mth-list--compact .mth-row__when { grid-area: who; justify-self: end; }
.mth-list__head { background: var(--rl-surface-raised); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--rl-text-muted); font-weight: 650; }
.mth-row {
    position: relative; text-decoration: none; color: inherit; border-top: 1px solid var(--rl-border);
    transition: background var(--rl-dur) var(--rl-ease);
}
.mth-row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--mth-edge, transparent); opacity: .85; }
.mth-list__head + .mth-row, .mth-list > .mth-row:first-child { border-top: 0; }
.mth-row:hover { background: var(--mth-lamp-soft); }
.mth-row:focus-visible { outline: 2px solid var(--mth-lamp); outline-offset: -2px; }
.mth-row--closed .mth-row__title { color: var(--rl-text-muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--rl-text-muted) 60%, transparent); }
.mth-row__main { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.mth-row__key { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .75rem; font-weight: 700; color: var(--mth-lamp); }
.mth-row__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mth-row__tags { display: flex; flex-wrap: wrap; gap: .25rem; }
.mth-row__tags .mth-pill { font-size: .68rem; padding: .02rem .45rem; }
.mth-row__sub { font-size: .78rem; color: var(--rl-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mth-row__cell { min-width: 0; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mth-row__when { color: var(--rl-text-muted); font-size: .8rem; }

.mth-pager { display: flex; justify-content: center; align-items: center; gap: .8rem; margin: 1rem 0; font-size: .9rem; }
.mth-filters select { max-width: 12rem; }

@media (max-width: 900px) {
    .mth-list__head { display: none; }
    .mth-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main status" "main when" "meta meta"; row-gap: .3rem; }
    .mth-row__main { grid-area: main; }
    .mth-row__status { grid-area: status; justify-self: end; }
    .mth-row__sev, .mth-row__pri { display: none; }
    .mth-row__who { grid-area: meta; font-size: .78rem; color: var(--rl-text-muted); }
    .mth-row__who::before { content: "Assigned: "; }
    .mth-row__when { grid-area: when; justify-self: end; }
    .mth-list--compact .mth-row { grid-template-areas: "main status" "main when"; }
}

/* ---- one issue ---------------------------------------------------------------------------------------------------- */

.mth-prose { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.mth-prose--steps { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88rem; padding: .6rem .8rem; border-radius: 10px; background: var(--rl-surface-sunken); }
.mth-facts { display: grid; grid-template-columns: minmax(6.5rem, auto) 1fr; gap: .45rem .8rem; margin: 0; font-size: .9rem; }
.mth-facts > div { display: contents; }
.mth-facts dt { color: var(--rl-text-muted); font-weight: 500; }
.mth-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.mth-facts--fields { margin-top: 1rem; padding-top: .8rem; border-top: 1px dashed var(--rl-border); }
.mth-side { display: flex; flex-direction: column; gap: .45rem; }
.mth-moves { display: flex; flex-wrap: wrap; gap: .35rem; }
.mth-pill--move { font-size: .78rem; }
.mth-movebox { display: flex; flex-direction: column; gap: .45rem; padding: .65rem .7rem; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--mth-lamp) 40%, var(--rl-border)); background: var(--mth-lamp-soft); margin: .2rem 0 .4rem; }

.mth-timeline { list-style: none; margin: 0 0 1rem; padding: 0 0 0 1rem; border-left: 2px solid var(--rl-border); display: flex; flex-direction: column; gap: .7rem; }
.mth-note { position: relative; padding: .65rem .8rem; border-radius: 12px; background: var(--rl-surface-raised); border: 1px solid var(--rl-border); }
.mth-note::before { content: ""; position: absolute; left: calc(-1rem - 6px); top: 1rem; width: 10px; height: 10px; border-radius: 50%; background: var(--mth-lamp); box-shadow: 0 0 8px var(--mth-lamp); }
.mth-note--private { border-style: dashed; background: color-mix(in srgb, var(--mth-lamp) 7%, var(--rl-surface-raised)); }
.mth-note__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; margin-bottom: .3rem; font-size: .9rem; }
.mth-note__tools { margin-left: auto; display: flex; gap: .2rem; }
.mth-change { position: relative; display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; font-size: .84rem; color: var(--rl-text-muted); }
.mth-change strong { color: var(--rl-text); font-weight: 600; }
.mth-change__dot { position: absolute; left: calc(-1rem - 4px); top: .45rem; width: 6px; height: 6px; border-radius: 50%; background: var(--rl-border-strong, var(--rl-border)); }
.mth-composer { display: flex; flex-direction: column; gap: .5rem; }
.mth-composer__box { width: 100%; resize: vertical; }

/* ---- agent fix ---------------------------------------------------------------------------------------------------- */

.mth-fix { display: flex; flex-direction: column; gap: .6rem; padding: .7rem .8rem; border-radius: 12px; border: 1px solid var(--rl-border); background: var(--rl-surface-raised); margin-bottom: .8rem; }
.mth-fix__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; }
.mth-fix__state { font-weight: 700; }
.mth-fix code { font-size: .8rem; overflow-wrap: anywhere; }
.mth-fix--running, .mth-fix--preparing { box-shadow: var(--mth-glow); }
.mth-fix--running .mth-fix__state::before, .mth-fix--preparing .mth-fix__state::before {
    content: ""; display: inline-block; width: .55rem; height: .55rem; margin-right: .4rem; border-radius: 50%;
    background: var(--mth-lamp); animation: mth-flutter 1.4s ease-in-out infinite;
}
.mth-fix--awaitingcompile { border-color: color-mix(in srgb, var(--mth-lamp) 60%, var(--rl-border)); }
.mth-fix--awaitingcompile .mth-fix__state { color: var(--mth-lamp); }
.mth-fix--passed .mth-fix__state { color: var(--rl-ok); }
.mth-fix--failed .mth-fix__state { color: var(--rl-danger); }
@keyframes mth-flutter { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .mth-fix__state::before { animation: none !important; } }

/* ---- admin suite: a rail of tabs beside the body, a row of chips above it on a phone ---------------------------- */

.mth-admin { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.mth-rail {
    position: sticky; top: 1rem; display: flex; flex-direction: column; gap: .15rem; padding: .6rem; border-radius: 14px;
    background: var(--rl-surface); border: 1px solid var(--rl-border);
}
.mth-rail__group { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--rl-text-muted); font-weight: 700; padding: .6rem .55rem .25rem; }
.mth-rail__group:first-child { padding-top: .2rem; }
.mth-rail__tab {
    display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem; border-radius: 9px; color: var(--rl-text); text-decoration: none;
    font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: background var(--rl-dur);
}
.mth-rail__tab svg { width: 1rem; height: 1rem; flex: none; color: var(--rl-text-muted); }
.mth-rail__tab:hover { background: var(--rl-surface-sunken); }
.mth-rail__tab[aria-current="page"] { background: var(--mth-lamp-soft); box-shadow: inset 3px 0 0 var(--mth-lamp); font-weight: 650; }
.mth-rail__tab[aria-current="page"] svg { color: var(--mth-lamp); }
.mth-rail__tab--project { font-size: .85rem; }
.mth-rail__key { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .72rem; font-weight: 700; color: var(--mth-lamp); min-width: 2.4rem; }
.mth-admin__body { min-width: 0; display: flex; flex-direction: column; gap: 1rem; }
.mth-admin__body > .ui-card { margin: 0; }

.mth-options .ui-row__end { flex-wrap: wrap; justify-content: flex-end; }

.mth-matrix { overflow: auto; border: 1px solid var(--rl-border); border-radius: 12px; max-height: 70vh; }
.mth-matrix table { border-collapse: separate; border-spacing: 0; font-size: .82rem; }
.mth-matrix th, .mth-matrix td { padding: .4rem .5rem; border-bottom: 1px solid var(--rl-border); text-align: center; white-space: nowrap; background: var(--rl-surface); }
.mth-matrix thead th { position: sticky; top: 0; z-index: 2; background: var(--rl-surface-raised); }
.mth-matrix tbody th { position: sticky; left: 0; z-index: 1; text-align: left; background: var(--rl-surface-raised); display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; }
.mth-matrix thead th:first-child { left: 0; z-index: 3; }
.mth-matrix select { padding: .2rem .3rem; border: 1px solid var(--rl-border); border-radius: 7px; background: var(--rl-surface-raised); color: var(--rl-text-muted); font-size: .8rem; }
.mth-matrix select.is-set { color: var(--rl-text); border-color: var(--mth-lamp); background: var(--mth-lamp-soft); font-weight: 600; }
.mth-matrix__open td { background: color-mix(in srgb, var(--rl-surface-sunken) 40%, var(--rl-surface)); }

@media (max-width: 900px) {
    .mth-admin { grid-template-columns: minmax(0, 1fr); }
    .mth-rail { position: static; flex-direction: row; overflow-x: auto; padding: .4rem; gap: .3rem; }
    .mth-rail__group { display: none; }
    .mth-rail__tab { flex: none; }
    .mth-rail__tab[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--mth-lamp); }
}

@media (max-width: 640px) {
    .mth-filters select, .mth-filters .ui-search { max-width: none; flex: 1 1 100%; }
    .mth-facts { grid-template-columns: minmax(5.5rem, auto) 1fr; }
}
