/* Project canvas — layered on top of the lookup stylesheet. */

/* An explicit display wins over the hidden attribute, which silently breaks
   every element we toggle with it. Restore the attribute's meaning. */
[hidden] { display: none !important; }

body.projects main { padding-bottom: 60px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 7px 13px;
    background: var(--accent);
    color: #fff;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all .16s ease;
    white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-muted);
}
.btn.ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn:disabled { opacity: .55; cursor: default; }
.btn:disabled:hover { filter: none; color: var(--text-muted); border-color: var(--border); }
.btn.danger:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* ------------------------------------------------------------ list page */

.projects-hero { padding: 44px 0 8px; text-align: center; }
.projects-hero h1 {
    margin: 0 0 12px;
    font-size: clamp(26px, 5vw, 38px);
    font-weight: 700;
    letter-spacing: -.03em;
}
.projects-hero p {
    margin: 0 auto;
    max-width: 44rem;
    color: var(--text-muted);
}

#create-form { max-width: 560px; margin: 26px auto 0; }

.projects-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 14px 0 30px;
}

.project-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.project-card {
    display: block;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    transition: all .16s ease;
}
.project-card:hover {
    text-decoration: none;
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.project-name { font-weight: 650; margin-bottom: 4px; }
.project-meta { font-size: 12.5px; color: var(--text-faint); }

.project-list .empty-note {
    grid-column: 1 / -1;
    text-align: center;
    padding: 26px 0;
}

.projects-note { max-width: 760px; margin: 34px auto 0; }

/* ---------------------------------------------------------- canvas page */

body.is-canvas .topbar { flex-shrink: 0; }

/* The bar's height depends on how many buttons fit on a line, so the canvas
   takes what is left rather than guessing at a viewport offset. */
body.is-canvas {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.canvas-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 10px;
    padding-bottom: 10px;
    flex-wrap: wrap;
}
/* The counts are metadata about the canvas, not a control, so they sit under
   the name instead of competing with the buttons for the same line. */
.canvas-title { min-width: 0; }
.canvas-bar h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.canvas-title .canvas-counts { display: block; margin-top: 2px; }
.canvas-bar .spacer { flex: 1; }
.canvas-counts, .canvas-busy {
    font-size: 12px;
    color: var(--text-faint);
    font-family: var(--mono);
}
.canvas-busy { display: inline-flex; align-items: center; gap: 6px; }

.canvas-shell {
    position: relative;
    flex: 1;
    min-height: 0;
    margin: 0 20px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}
/* Stop the graph short of the legend, so fitting it never tucks a label
   underneath something opaque. */
#canvas { position: absolute; top: 0; left: 0; right: 0; bottom: 42px; }

.inspector {
    position: absolute;
    top: 14px; right: 14px;
    width: 260px;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 5;
}
.inspector-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.inspector-head strong { word-break: break-all; font-size: 14px; }
.type-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.inspector-type { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.inspector-meta { font-size: 12px; color: var(--text-faint); margin-bottom: 12px; }
.inspector-shared {
    margin: 8px 0 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-muted);
}

#shared-toggle[aria-pressed="true"] { color: var(--text); border-color: var(--border-strong); }
.inspector-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.legend {
    position: absolute;
    left: 14px; bottom: 9px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    max-width: 60%;
    padding: 9px 12px;
    background: color-mix(in srgb, var(--surface-2) 90%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--text-muted);
    z-index: 4;
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Stub nodes are drawn hollow; say so once rather than in every tooltip. */
.legend .legend-stub { color: var(--text-faint); }

.toast {
    position: fixed;
    left: 50%; bottom: 24px;
    transform: translate(-50%, 20px);
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 13px;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
    z-index: 60;
    max-width: min(560px, 90vw);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.danger { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

@media (max-width: 720px) {
    .canvas-shell { margin: 0 12px 12px; }
    #canvas { bottom: 0; }                 /* no legend to leave room for */
    /* Not static: the canvas is positioned and would paint straight over it.
       A sheet along the bottom keeps it clear of whatever was tapped. */
    .inspector { top: auto; bottom: 12px; left: 12px; right: 12px; width: auto; }
    .legend { display: none; }
    .canvas-bar { gap: 6px; }
    .canvas-bar h1 { width: 100%; }
    .canvas-bar .spacer { display: none; }
}
