/* FOLIO API CSS Variables */
@import url('https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,100..900;1,100..900&display=swap');

html, body {
    height: 100%;
}

:root {
    --font-sans: 'Public Sans Variable';
    --font-serif: 'Public Sans Variable';
    --font-heading: 'Public Sans Variable';
    --color-primary: rgb(24 70 120);
    --color-secondary: rgb(134, 147, 171);
    --color-accent: rgb(234, 82, 111);
    --color-text-heading: rgb(0 0 0);
    --color-text-default: rgb(16 16 16);
    --color-text-muted: rgb(16 16 16 / 66%);
    --color-bg-page: rgb(255 255 255);
    --color-bg-page-dark: rgb(12 35 60);
}

.dark {
    --color-primary: rgb(24 70 120);
    --color-secondary: rgb(134 147 171);
    --color-accent: rgb(234 82 111);
    --color-text-heading: rgb(247 248 248);
    --color-text-default: rgb(229 236 246);
    --color-text-muted: rgba(229, 236, 246, 0.66);
    --color-bg-page: rgb(12 35 60);
}

.dark ::selection {
    background-color: black;
    color: snow;
}

/* Typeahead Styles */
.twitter-typeahead {
    width: 100%;
}

.tt-menu {
    width: 100%;
    margin-top: 0.5rem;
    background-color: white;
    border: 1px solid var(--color-secondary);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.tt-suggestion {
    padding: 0.75rem 1rem;
    cursor: pointer;
}

.tt-suggestion:hover, .tt-suggestion.tt-cursor {
    background-color: rgba(24, 70, 120, 0.1);
}

/* Cytoscape Graph Styles */
.cy-tooltip {
    display: none;
    position: absolute;
    z-index: 999;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    max-width: 250px;
    font-size: 12px;
    line-height: 1.4;
    pointer-events: none;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .header-buttons {
        display: none;
    }

    .mobile-menu {
        display: block;
    }
}

@media (min-width: 769px) {
    .header-buttons {
        display: flex;
    }

    .mobile-menu {
        display: none;
    }
}

/* Accessibility Improvements */
:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--color-accent);
}

.btn-secondary {
    background-color: white;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}

.btn-secondary:hover {
    background-color: rgba(24, 70, 120, 0.1);
}

/* Responsive button sizes */
@media (max-width: 640px) {
    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* Card Styles */
.card {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    padding: 1.5rem;
    transition: box-shadow 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

.card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Animation Utilities */
.animate-fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Tree View Styles */
.tree-explorer-container {
    display: flex;
    min-height: 600px;
}

#tree-container {
    overflow: auto;
    border-right: 1px solid #e2e8f0;
}

#detail-container {
    display: flex;
    flex-direction: column;
}

.card .overflow-y-auto {
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.5) rgba(243, 244, 246, 0.7);
}

.card .overflow-y-auto::-webkit-scrollbar {
    width: 6px;
}

.card .overflow-y-auto::-webkit-scrollbar-track {
    background: rgba(243, 244, 246, 0.7);
    border-radius: 6px;
}

.card .overflow-y-auto::-webkit-scrollbar-thumb {
    background-color: rgba(156, 163, 175, 0.5);
    border-radius: 6px;
    border: 1px solid rgba(243, 244, 246, 0.7);
}

.jstree-default .jstree-anchor {
    color: var(--color-text-default);
    padding: 5px;
}

.jstree-default .jstree-hovered {
    background-color: rgba(24, 70, 120, 0.1);
    border-radius: 4px;
}

.jstree-default .jstree-clicked {
    background-color: rgb(24, 70, 120);
    color: white;
    border-radius: 4px;
}

/* Spinner for loading states */
.spinner-border {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    vertical-align: text-bottom;
    border: 0.25em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border .75s linear infinite;
}

@keyframes spinner-border {
    to { transform: rotate(360deg); }
}

/* Responsive layout for the tree explorer */
@media (max-width: 768px) {
    .tree-explorer-container {
        flex-direction: column;
    }

    #tree-container {
        width: 100% !important;
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }

    #detail-container {
        width: 100% !important;
    }
}

/* ============================================================ */
/* Phase 1 (milestone v1.1): Entity Graph state styles.         */
/* Tailwind utilities cover most of the surface; this block only */
/* contains rules that Tailwind cannot express via utilities.   */
/* ============================================================ */

/* Skeleton container — currently only a marker class for the
   reduced-motion override below; the visible pulse comes from
   Tailwind's animate-pulse utility on each rectangle. */
.entity-graph-skeleton {
    /* No properties needed; class is a hook for the @media rule. */
}

/* Reduced-motion override per UI-SPEC §Motion. */
@media (prefers-reduced-motion: reduce) {
    .entity-graph-skeleton .animate-pulse {
        animation: none !important;
        opacity: 0.7;
    }
}

/* ============================================================ */
/* Phase 1 (milestone v1.1): Entity Graph node + edge styling.  */
/* Visual polish pass — matches folio-enrich / folio-mapper     */
/* reference implementations (ported to vanilla JS/CSS).        */
/* ============================================================ */

/* Plain background for the graph canvas (dotted grid removed
   per user feedback 2026-05-08 — was too visually noisy). */
#entity-graph-pane {
    background-color: #f9fafb;
}

/* subClassOf edges — blue with arrowhead (blue-500 #3b82f6).
   marker-end is set inline in entity_graph.js via url(#arrow-sub). */
.graph-edge {
    stroke: #3b82f6;
    fill: none;
    stroke-width: 2;
    opacity: 0.7;
}

/* rdfs:seeAlso edges — dashed purple, no arrowhead (lateral link). */
.graph-edge--seealso {
    stroke: #8b5cf6;
    stroke-dasharray: 6 3;
    stroke-width: 1.5;
    opacity: 0.7;
}

/* Base node — hover shadow. Positioning is inline from ELK.
   white-space: nowrap prevents label wrapping; label width is sized by ELK
   via labelText.length * 7.5 + 32 (matching folio-enrich's formula).
   cursor: grab signals nodes are draggable; overridden to grabbing during drag
   via document.body.style.cursor and nodeEl.style.cursor in the drag handler. */
.graph-node {
    transition: filter 0.12s ease-out;
    user-select: none;
    white-space: nowrap;
    cursor: grab;
}

/* The +N children button and hover-badge keep their pointer cursor. */
.graph-node-children-btn,
.graph-node-hover-badge {
    cursor: pointer !important;
}

.graph-node:hover {
    filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.4));
}

/* Focus / selected node: blue border + blue tinted bg */
.graph-node-selected > div {
    border-color: #3b82f6 !important;
    border-width: 2px !important;
    background-color: #eff6ff !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

/* Branch root — ultimate ancestor: red 3px border (matches folio-enrich) */
.graph-node-root > div {
    border-color: #ef4444 !important;
    border-width: 3px !important;
    background-color: #fef2f2 !important;
}

/* Branch root that is ALSO the selected node: blue wins for focus clarity */
.graph-node-selected.graph-node-root > div {
    border-color: #3b82f6 !important;
    border-width: 3px !important;
    background-color: #eff6ff !important;
}
/* Ancillary ancestor branch root: gray 3px border (matches folio-enrich
   .graph-node.branch-root-ancillary pattern). */
.graph-node-ancillary > div {
    border-color: #6b7280 !important;
    border-width: 3px !important;
    background-color: #f9fafb !important;
}

/* Reduced-motion: drop transitions */
@media (prefers-reduced-motion: reduce) {
    .graph-node {
        transition: none;
        filter: none;
    }
}

/* ============================================================ */
/* Phase 1 (milestone v1.1): hover-only +N expansion badge.     */
/* ============================================================ */

.graph-node:hover .graph-node-hover-badge {
    opacity: 1;
    pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
    .graph-node-hover-badge {
        transition: none;
    }
}

/* ============================================================ */
/* Entity Graph canvas: graph-viewport cursor states            */
/* ============================================================ */

#graph-viewport {
    cursor: grab;
}

#graph-viewport.graph-grabbing {
    cursor: grabbing;
}

/* ============================================================ */
/* Entity Graph: minimap (canvas-based, bottom-right corner).   */
/* Ported from folio-enrich graph-minimap pattern.              */
/* ============================================================ */

#graph-minimap {
    position: absolute;
    bottom: 40px;   /* sits above the legend bar */
    right: 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    pointer-events: none;
    z-index: 10;
}

/* ============================================================ */
/* Entity Graph: legend strip (bottom of graph canvas).         */
/* Ported from folio-enrich graph-modal-legend + folio-mapper   */
/* legend footer pattern.                                       */
/* ============================================================ */

#graph-legend {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid #e5e7eb;
    font-size: 11px;
    color: #6b7280;
    flex-shrink: 0;
    z-index: 10;
    flex-wrap: wrap;
}

.graph-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.graph-legend-hint {
    margin-left: auto;
    color: #9ca3af;
    font-size: 10.5px;
}

/* ============================================================ */
/* Phase 1 (milestone v1.1): Entity Graph full-screen modal.    */
/* ============================================================ */

#graph-modal-root.hidden { display: none; }

#graph-modal-root #graph-modal-scrim {
    opacity: 1;
    transition: opacity 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

#graph-modal-root #graph-modal-panel {
    opacity: 1;
    transform: scale(1);
    transition: opacity 200ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
    #graph-modal-root #graph-modal-scrim,
    #graph-modal-root #graph-modal-panel {
        transition: none !important;
    }
}
