/*
 * Minimal custom CSS - only for things Tailwind can't handle inline:
 * - Scrollbar styling (pseudo-elements)
 * - HTMX dynamic states
 */

/* Inter variable features: cv01, ss03, and slashed zero.
   Dark is the default. Light overrides the same tokens. */
html {
    font-feature-settings: "cv01" on, "ss03" on, "zero" on;
    --bg: 8 9 10; /* #08090a */
    --sidebar: 8 9 10; /* #08090a */
    --panel: 15 16 17; /* #0f1011 */
    --card: 22 23 24; /* #161718 */
    --elevated: 22 23 24; /* #161718 */
    --border: 35 37 42; /* #23252a */
    --border-subtle: 35 37 42; /* #23252a */
    --border-strong: 56 59 63; /* #383b3f */
    --hover: rgba(255, 255, 255, 0.05);
    --hover-strong: rgba(255, 255, 255, 0.08);
    --zinc-50: 255 255 255; /* #ffffff */
    --zinc-100: 255 255 255; /* #ffffff */
    --zinc-200: 229 229 230; /* #e5e5e6 */
    --zinc-300: 208 214 224; /* #d0d6e0 */
    --zinc-400: 138 143 152; /* #8a8f98 */
    --zinc-500: 138 143 152; /* #8a8f98 */
    --zinc-600: 98 102 109; /* #62666d */
    --zinc-700: 98 102 109; /* #62666d */
    --zinc-800: 56 59 63; /* #383b3f */
    --zinc-900: 35 37 42; /* #23252a */
    --zinc-950: 8 9 10; /* #08090a */
}

html.light {
    --bg: 246 247 248; /* #f6f7f8 */
    --sidebar: 255 255 255;
    --panel: 255 255 255;
    --card: 255 255 255;
    --elevated: 243 244 246; /* #f3f4f6 */
    --border: 230 231 234; /* #e6e7ea */
    --border-subtle: 230 231 234; /* #e6e7ea */
    --border-strong: 209 210 213; /* #d1d2d5 */
    --hover: rgba(22, 23, 24, 0.05);
    --hover-strong: rgba(22, 23, 24, 0.08);
    /* text-zinc-100 is the primary text, so the light end of the scale is dark. */
    --zinc-50: 22 23 24; /* #161718 */
    --zinc-100: 22 23 24; /* #161718 */
    --zinc-200: 44 47 52; /* #2c2f34 */
    --zinc-300: 70 74 80; /* #464a50 */
    --zinc-400: 98 102 109; /* #62666d */
    --zinc-500: 98 102 109; /* #62666d */
    --zinc-600: 138 143 152; /* #8a8f98 */
    --zinc-700: 212 213 216; /* #d4d5d8 */
    --zinc-800: 209 210 213; /* #d1d2d5 */
    --zinc-900: 230 231 234; /* #e6e7ea */
    --zinc-950: 246 247 248; /* #f6f7f8 */
    /* Thumb follows the border so it stays visible on the light canvas. */
    --scrollbar-thumb: var(--border);
    --scrollbar-thumb-hover: var(--border-strong);
}

/* Scrollbar follows the theme tokens. */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgb(var(--bg));
}

::-webkit-scrollbar-thumb {
    background: rgb(var(--scrollbar-thumb, var(--elevated)));
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgb(var(--scrollbar-thumb-hover, var(--border)));
}

/* The row or card the keyboard is on (static/js/task-view.js). It reads the theme
   tokens, so it works on both themes. The extra `html` beats the hover backgrounds
   Tailwind puts on rows and cards. */
html [data-task-row].task-selected {
    background: var(--hover-strong);
    outline: 1px solid rgb(var(--border-strong));
    outline-offset: -1px;
}

/* Fixed table header over a scrolling body: reserve the same scrollbar gutter on
   both so their columns line up and the scrollbar only spans the body rows. */
.scrollbar-gutter-stable {
    scrollbar-gutter: stable;
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgb(var(--scrollbar-thumb, var(--elevated))) rgb(var(--bg));
}

/* HTMX loading states.
   htmx already shows/hides the indicator by toggling opacity, so it stays in the
   layout the whole time. At opacity 0 it was still hit-testable and, being fixed
   to the top-right corner, silently swallowed clicks on the header action
   buttons ("Add Client", "Add Task", "Edit"). It is decoration — never let it
   take pointer events.
   Do not add `display` rules here: `.htmx-request .htmx-indicator` outranks the
   element's Tailwind `flex` class and would break its internal layout. */
#htmx-indicator {
    pointer-events: none;
}

/* Rendered markdown in task descriptions, comments and the Preview tab
   (apps/tasks/templatetags/task_markdown.py). Only the tags the sanitizer keeps
   are styled, on the theme tokens, so both themes work. */
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p,
.markdown ul,
.markdown ol,
.markdown pre,
.markdown blockquote,
.markdown table { margin: 0.5em 0; }
.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
    margin: 0.9em 0 0.4em;
    font-weight: 600;
    line-height: 1.3;
    color: rgb(var(--zinc-100));
}
.markdown h1 { font-size: 1.25em; }
.markdown h2 { font-size: 1.125em; }
.markdown h3 { font-size: 1em; }
.markdown h4,
.markdown h5,
.markdown h6 { font-size: 0.9375em; }
.markdown strong { font-weight: 600; color: rgb(var(--zinc-100)); }
.markdown ul { list-style: disc; padding-left: 1.25em; }
.markdown ol { list-style: decimal; padding-left: 1.5em; }
.markdown li + li { margin-top: 0.2em; }
.markdown li > ul,
.markdown li > ol { margin: 0.2em 0; }
.markdown a {
    color: #8b5cf6;
    text-decoration: underline;
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
}
.markdown a:hover { color: #a78bfa; }
.markdown code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.875em;
    padding: 0.1em 0.35em;
    border-radius: 4px;
    background: rgb(var(--elevated));
    border: 1px solid rgb(var(--border-subtle));
}
.markdown pre {
    padding: 0.6em 0.8em;
    border-radius: 6px;
    background: rgb(var(--elevated));
    border: 1px solid rgb(var(--border-subtle));
    overflow-x: auto;
}
.markdown pre code { padding: 0; border: 0; background: none; font-size: 0.8125em; }
.markdown blockquote {
    padding-left: 0.8em;
    border-left: 2px solid rgb(var(--border-strong));
    color: rgb(var(--zinc-400));
}
.markdown hr { margin: 1em 0; border: 0; border-top: 1px solid rgb(var(--border-subtle)); }
.markdown table { border-collapse: collapse; font-size: 0.9375em; display: block; overflow-x: auto; }
.markdown th,
.markdown td { padding: 0.3em 0.6em; border: 1px solid rgb(var(--border-subtle)); text-align: left; }
.markdown th { font-weight: 600; background: rgb(var(--elevated)); }

/* Activity tabs (All / Comments / Work log). They only hide rows: the list is always
   whole, so a refresh or a new comment never has to know which tab is open. */
.activity-feed [data-empty] { display: none; }
.activity-feed[data-filter="all"] [data-kind="summary"],
.activity-feed[data-filter="comments"] [data-kind]:not([data-kind="comment"]),
.activity-feed[data-filter="work"] [data-kind]:not([data-kind="work"]):not([data-kind="summary"]) {
    display: none;
}
.activity-feed[data-filter="comments"]:not(:has([data-kind="comment"])) [data-empty="comments"],
.activity-feed[data-filter="work"]:not(:has([data-kind="work"])):not(:has([data-kind="summary"])) [data-empty="work"] {
    display: block;
}

/* The Properties sidebar of the full task page is narrow and ends at the edge of the
   window. The menus of its rows (state, assignee, priority, due date, labels) are
   written to open from the left of the value, which fits the drawer but runs past the
   sidebar here and gets cut off. Open them from the right edge of the row instead.
   The ones that already span the row (left-0 right-0) are left as they are. */
.task-props-sidebar .absolute.left-0:not(.right-0) {
    left: auto;
    right: 0;
}

/* The comment that raised an Inbox notification, lit up for a moment when the
   notification opens (static/js/inbox.js). */
.inbox-flash {
    border-radius: 6px;
    background: rgba(139, 92, 246, 0.16);
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.5);
    transition: background 0.6s ease, box-shadow 0.6s ease;
}

/* Live updates (static/js/live.js): a row or card someone else just changed. */
@keyframes live-flash {
    from { background-color: rgba(139, 92, 246, 0.16); } /* accent-muted */
    to { background-color: transparent; }
}
.live-flash {
    animation: live-flash 1.2s ease-out;
}
@media (prefers-reduced-motion: reduce) {
    .live-flash { animation: none; }
}
