/* ═══════════════════════════════════════════════════════════════
   Notes Hub — Kanban Board
   ═══════════════════════════════════════════════════════════════ */

.nh-kanban {
    --nh-k-bg: #f1f5f9;
    --nh-k-col-bg: #ffffff;
    --nh-k-card-bg: #ffffff;
    --nh-k-border: #e2e8f0;
    --nh-k-text: #0f172a;
    --nh-k-muted: #64748b;
    --nh-k-faint: #94a3b8;
    --nh-k-shadow-hover: 0 8px 20px -6px rgba(15, 23, 42, .15);

    background: var(--nh-k-bg);
    border: 1px solid var(--nh-k-border);
    border-radius: 16px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
    color: var(--nh-k-text);
    margin: 16px 0;
}

/*
 * BUGFIX: `body.nh-dark` never matched — the theme toggles `nh-dark` on
 * <html>, not <body>. Every dark-mode rule in this file was inert, so the
 * board and the move sheet rendered white in dark mode. Now uses
 * `html.nh-dark`.
 */
html.nh-dark .nh-kanban,
body.noteshub-dark-default .nh-kanban {
    --nh-k-bg: #0b1220;
    --nh-k-col-bg: #111a2e;
    --nh-k-card-bg: #1e293b;
    --nh-k-border: #1e293b;
    --nh-k-text: #f8fafc;
    --nh-k-muted: #94a3b8;
    --nh-k-faint: #64748b;
}

/* ─── Head ─────────────────────────────────────────────────── */

.nh-kanban-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--nh-k-col-bg);
    border-bottom: 1px solid var(--nh-k-border);
    flex-wrap: wrap;
}

.nh-kanban-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 800;
    color: var(--nh-k-text);
    letter-spacing: -.01em;
}

/* BUGFIX: hardcoded gradient → theme tokens (accent customization). */
.nh-kanban-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--nh-primary, #6366f1), var(--nh-primary-2, #8b5cf6));
    font-size: 15px;
}

.nh-kanban-stats {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: var(--nh-k-muted);
    display: flex;
    gap: 12px;
}

.nh-kanban-stats strong {
    color: var(--nh-k-text);
    font-size: 14px;
    font-weight: 800;
}

.nh-kanban-refresh {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--nh-k-border);
    background: transparent;
    color: var(--nh-k-muted);
    font-size: 15px;
    cursor: pointer;
    font-family: inherit;
    transition: all 150ms ease;
}

.nh-kanban-refresh:hover {
    border-color: var(--nh-primary, #6366f1);
    color: var(--nh-primary, #6366f1);
    background: var(--nh-primary-soft, rgba(99, 102, 241, .08));
}

/* ─── Board ────────────────────────────────────────────────── */

.nh-kanban-board {
    display: flex;
    gap: 14px;
    padding: 18px;
    overflow-x: auto;
    min-height: 320px;
    align-items: flex-start;
    scroll-snap-type: x mandatory;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    /* BUGFIX: prevent horizontal-overscroll from dragging the parent page. */
    overscroll-behavior-x: contain;
}

.nh-kanban-board::-webkit-scrollbar { height: 8px; }
.nh-kanban-board::-webkit-scrollbar-track { background: transparent; }
.nh-kanban-board::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--nh-k-muted) 30%, transparent);
    border-radius: 999px;
}

/* ─── Column ───────────────────────────────────────────────── */

.nh-kanban-col {
    flex: 0 0 300px;
    background: var(--nh-k-col-bg);
    border: 1px solid var(--nh-k-border);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    max-height: 620px;
    scroll-snap-align: start;
    transition: box-shadow 180ms ease, border-color 180ms ease;
}

.nh-kanban-col.is-drop-target {
    border-color: var(--nh-primary, #6366f1);
    box-shadow: 0 0 0 3px var(--nh-primary-soft, rgba(99, 102, 241, .18));
}

.nh-kanban-col-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--nh-k-border);
    position: relative;
}

.nh-kanban-col-head::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--col-color, var(--nh-primary, #6366f1));
    border-radius: 14px 14px 0 0;
}

.nh-kanban-col-icon { font-size: 16px; line-height: 1; }

.nh-kanban-col-label {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--nh-k-text);
}

.nh-kanban-col-count {
    margin-left: auto;
    min-width: 22px;
    height: 22px;
    padding: 0 8px;
    background: var(--nh-k-bg);
    color: var(--nh-k-muted);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nh-kanban-col-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 80px;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    /*
     * BUGFIX: without this, reaching the bottom of a column's card list
     * chained the scroll to the parent board, which then jumped the user
     * sideways into the next column. Contains vertical scroll within
     * the column body.
     */
    overscroll-behavior-y: contain;
}

.nh-kanban-col-body::-webkit-scrollbar { width: 6px; }
.nh-kanban-col-body::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--nh-k-muted) 25%, transparent);
    border-radius: 999px;
}

/* ─── Card ─────────────────────────────────────────────────── */

.nh-kanban-card {
    background: var(--nh-k-card-bg);
    border: 1px solid var(--nh-k-border);
    border-radius: 12px;
    padding: 12px 14px;
    cursor: grab;
    transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease, border-color 150ms ease;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* BUGFIX: iOS Safari ignores user-select:none for the long-press
     * callout (Copy / Look Up popover), which interrupts drag. Add
     * -webkit-touch-callout: none so long-press stays a drag gesture. */
    -webkit-touch-callout: none;
    touch-action: none;
}

.nh-kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--nh-k-shadow-hover);
    border-color: color-mix(in srgb, var(--nh-k-text) 20%, transparent);
}

.nh-kanban-card:active {
    cursor: grabbing;
}

.nh-kanban-card.is-dragging {
    opacity: .4;
    transform: scale(.96);
}

.nh-kanban-card-top {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}

.nh-kanban-card-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--card-color, var(--nh-primary, #6366f1)) 15%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.nh-kanban-card-title {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--nh-k-text);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nh-kanban-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.nh-kanban-card-tag {
    background: var(--nh-k-bg);
    color: var(--nh-k-muted);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
}

.nh-kanban-card-time {
    margin-top: 6px;
    font-size: 10.5px;
    color: var(--nh-k-faint);
    font-weight: 600;
}

.nh-kanban-card-hint {
    margin-top: 8px;
    font-size: 10px;
    color: var(--nh-k-faint);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    opacity: 0;
    transition: opacity 150ms ease;
}

/* Show hint only on touch devices */
@media (hover: none) {
    .nh-kanban-card-hint {
        opacity: .7;
    }
}

/* ─── Empty state ─────────────────────────────────────────── */

.nh-kanban-empty {
    padding: 24px 12px;
    text-align: center;
    font-size: 12px;
    color: var(--nh-k-faint);
    font-weight: 600;
    font-style: italic;
    border: 2px dashed transparent;
    border-radius: 10px;
    transition: all 150ms ease;
}

.nh-kanban-col.is-drop-target .nh-kanban-empty {
    border-color: var(--nh-primary, #6366f1);
    color: var(--nh-primary, #6366f1);
    background: var(--nh-primary-softer, rgba(99, 102, 241, .05));
}

/* ─── Loading ─────────────────────────────────────────────── */

.nh-kanban-loading {
    padding: 40px 20px;
    text-align: center;
    color: var(--nh-k-muted);
    font-size: 13px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
}

.nh-kanban-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid color-mix(in srgb, var(--nh-primary, #6366f1) 20%, transparent);
    border-top-color: var(--nh-primary, #6366f1);
    border-radius: 50%;
    animation: nh-kanban-spin .8s linear infinite;
}

@keyframes nh-kanban-spin { to { transform: rotate(360deg); } }

/* ─── Hint ────────────────────────────────────────────────── */

.nh-kanban-hint {
    padding: 12px 18px;
    border-top: 1px solid var(--nh-k-border);
    font-size: 12px;
    color: var(--nh-k-muted);
    font-weight: 600;
    background: var(--nh-k-col-bg);
}

/* ═══════════════════════════════════════════════════════════════
   Move sheet (tap-to-move menu)
   ═══════════════════════════════════════════════════════════════ */

/*
 * BUGFIX: The overlay previously had no `display:none`, `visibility:hidden`,
 * or `pointer-events:none` — it was ALWAYS in the layout tree, always
 * covering the viewport at z-index 99998 with a transparent opacity. If the
 * JS ever failed to remove it from the DOM (navigation, error path, race
 * condition), the entire page became unclickable behind an invisible wall.
 *
 * Now uses visibility + pointer-events toggled via .is-open — same pattern
 * as .nh-notif-overlay — so the overlay is fully inert when closed without
 * relying on the JS to clean up.
 *
 * BUGFIX: z-index was 99998, below the theme's mobile drawer (100000), the
 * auth modal (100050), the notification panel (9999999), and the account
 * panel (9999990). If any of those was open, it would cover the sheet.
 * Bumped to 100060 — above the drawer and auth modal, below the goppo
 * pickers (100150) and the editor modal (2147483647).
 */
.nh-kanban-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100060;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 200ms ease, visibility 0s 200ms;
    padding: 0;
}

.nh-kanban-sheet-overlay.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 200ms ease, visibility 0s 0s;
}

.nh-kanban-sheet {
    width: 100%;
    max-width: 480px;
    background: #ffffff;
    border-top-left-radius: 22px;
    border-top-right-radius: 22px;
    box-shadow: 0 -20px 40px -12px rgba(15, 23, 42, .3);
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 260ms cubic-bezier(.2, .9, .3, 1);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nh-kanban-sheet-overlay.is-open .nh-kanban-sheet {
    transform: translateY(0);
}

/* BUGFIX: `body.nh-dark` → `html.nh-dark`. */
html.nh-dark .nh-kanban-sheet,
body.noteshub-dark-default .nh-kanban-sheet {
    background: #111a2e;
    color: #f8fafc;
}

/* Grab bar at top */
.nh-kanban-sheet::before {
    content: '';
    display: block;
    width: 44px;
    height: 4px;
    background: rgba(148, 163, 184, .4);
    border-radius: 999px;
    margin: 10px auto 4px;
}

.nh-kanban-sheet-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px 12px;
    border-bottom: 1px solid #e2e8f0;
}

html.nh-dark .nh-kanban-sheet-head,
body.noteshub-dark-default .nh-kanban-sheet-head {
    border-bottom-color: #1e293b;
}

.nh-kanban-sheet-title {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/* BUGFIX: hardcoded gradient → theme tokens. */
.nh-kanban-sheet-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--nh-primary, #6366f1), var(--nh-primary-2, #8b5cf6));
    font-size: 18px;
    flex-shrink: 0;
}

.nh-kanban-sheet-name {
    font-size: 15px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

html.nh-dark .nh-kanban-sheet-name,
body.noteshub-dark-default .nh-kanban-sheet-name {
    color: #f8fafc;
}

.nh-kanban-sheet-sub {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    margin-top: 2px;
}

.nh-kanban-sheet-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
}

.nh-kanban-sheet-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

html.nh-dark .nh-kanban-sheet-close:hover,
body.noteshub-dark-default .nh-kanban-sheet-close:hover {
    background: #1e293b;
    color: #f8fafc;
}

.nh-kanban-sheet-body {
    padding: 10px 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nh-kanban-sheet-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: #0f172a;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
    transition: background 120ms ease;
}

html.nh-dark .nh-kanban-sheet-btn,
body.noteshub-dark-default .nh-kanban-sheet-btn {
    color: #f8fafc;
}

.nh-kanban-sheet-btn:hover {
    background: #f1f5f9;
}

html.nh-dark .nh-kanban-sheet-btn:hover,
body.noteshub-dark-default .nh-kanban-sheet-btn:hover {
    background: #1e293b;
}

/*
 * BUGFIX: .is-current had no dark-mode override — in dark mode the current
 * column lit up with an off-white #f1f5f9 chip inside the dark sheet.
 */
.nh-kanban-sheet-btn.is-current {
    background: #f1f5f9;
    cursor: default;
}

html.nh-dark .nh-kanban-sheet-btn.is-current,
body.noteshub-dark-default .nh-kanban-sheet-btn.is-current {
    background: #1e293b;
}

.nh-kanban-sheet-btn-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    /*
     * NOTE: box-shadow uses `currentColor`, which resolves to the button's
     * text color, not the dot's fill. The ring around the dot therefore
     * renders neutral grey instead of a tinted halo of the column color.
     * Fixable only from JS — the JS should set `--dot-color` on the button
     * element alongside the dot's background, and this rule should read
     *   box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot-color) 20%, transparent);
     */
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 20%, transparent);
}

.nh-kanban-sheet-btn-icon {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

.nh-kanban-sheet-btn-label {
    flex: 1;
    min-width: 0;
}

.nh-kanban-sheet-btn-check {
    color: #10b981;
    font-weight: 900;
    font-size: 16px;
    flex-shrink: 0;
}

/* ─── Toast ───────────────────────────────────────────────── */

.nh-kanban-toast {
    position: fixed;
    left: 50%;
    bottom: 100px;
    transform: translate(-50%, 20px);
    background: #0f172a;
    color: #f8fafc;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 8px 24px -8px rgba(15, 23, 42, .5);
    opacity: 0;
    transition: opacity 220ms ease, transform 220ms ease;
    z-index: 100061; /* above the sheet */
    pointer-events: none;
}

.nh-kanban-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ─── Mobile ──────────────────────────────────────────────── */

@media (max-width: 640px) {
    .nh-kanban-board {
        padding: 14px;
        gap: 12px;
        scroll-snap-type: x mandatory;
        /* Restore Y-axis scroll propagation up to the app canvas when the
         * user wants to scroll the page rather than the board. */
        touch-action: pan-x pan-y;
    }

    .nh-kanban-col {
        flex: 0 0 82%;
    }

    .nh-kanban-head { padding: 12px 14px; }
    .nh-kanban-stats { display: none; }
    .nh-kanban-hint { font-size: 11px; padding: 10px 14px; }

    .nh-kanban-card {
        touch-action: none;
        -webkit-user-drag: none;
    }

    .nh-kanban-col-body {
        touch-action: pan-y;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Print — hide the sheet, overlay and toast
   BUGFIX: previously missing. If a user printed with the move sheet
   open, both the sheet and its dark backdrop landed on the page.
   ═══════════════════════════════════════════════════════════════ */

@media print {
    .nh-kanban-sheet-overlay,
    .nh-kanban-sheet,
    .nh-kanban-toast {
        display: none !important;
    }
}