/* Early Internet / Lofi Aesthetic */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background-color: #000;
    color: #00ff00;
    line-height: 1.4;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Terminal-style header */
header {
    padding: 20px;
    border-bottom: 1px solid #00ff00;
    text-align: left;
    background: #000;
    /* Make header sticky so it remains visible above the canvas */
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 99999; /* keep header above the canvas and any transformed stacking contexts */
}

.header-content {
    display: flex;
    align-items: center;
    position: relative;
    width: 100%;
}

.logo {
    height: 60px;
    width: auto;
    flex-shrink: 0;
    position: absolute;
    left: 0;
    z-index: 1;
}

.header-text {
    flex: 1;
    text-align: center;
    padding: 0 75px; /* padding instead of margin to keep content within bounds */
    box-sizing: border-box;
}

header h1 {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 5px;
    text-transform: lowercase;
    letter-spacing: 2px;
}

.title-short {
    display: none;
}

header p {
    font-size: 0.9rem;
    opacity: 0.8;
    text-transform: lowercase;
}

.subtitle-desktop {
    display: inline;
}

.subtitle-mobile {
    display: none;
}

/* Main content area */
main {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 0;
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1rem;
    z-index: 10;
}

#graph-container {
    width: 100%;
    height: 100%;
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

#network-canvas {
    width: 100%;
    height: 100%;
    cursor: grab;
    display: block;
    flex: 1;
}

#list-container {
    width: 100%;
    height: 100%;
    flex: 1;
    overflow-y: auto;
    padding: 70px 20px 80px 20px;
    background: rgba(0, 0, 0, 0.92);
    color: #00ff00;
}

#node-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.node-section {
    border: 1px solid rgba(0, 255, 0, 0.4);
    padding: 12px;
    background: rgba(0, 0, 0, 0.65);
}

.node-section-title {
    font-size: 0.9rem;
    margin-bottom: 10px;
    text-transform: lowercase;
    letter-spacing: 1px;
    color: #00ff00;
}

.node-section-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.node-list-item-btn {
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid rgba(0, 255, 0, 0.5);
    color: inherit;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.node-list-item-btn:hover {
    background: #00ff00;
    color: #000;
}

.node-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.node-list-name {
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.node-list-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
}

.node-list-badge {
    font-size: 0.65rem;
    border: 1px solid currentColor;
    padding: 2px 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.node-list-meta {
    font-size: 0.7rem;
    opacity: 0.75;
}

.list-empty {
    margin-bottom: 16px;
    font-size: 0.8rem;
    opacity: 0.7;
    text-transform: lowercase;
}

body.list-view-active {
    overflow: hidden;
}

body.list-view-active main {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 24px;
    padding: 0 20px 20px 20px;
    box-sizing: border-box;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

body.list-view-active #loading {
    display: none;
}

body.list-view-active #graph-container {
    display: none !important;
}

body.list-view-active #list-container {
    display: block;
    flex: 0 1 640px;
    width: min(640px, 100%);
    max-width: 640px;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    padding: 28px 20px 60px 20px;
    margin: 0 auto;
    border: 1px solid rgba(0, 255, 0, 0.4);
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

body.list-view-active #list-empty {
    margin-bottom: 20px;
}

@media (max-width: 900px) {
    body.list-view-active main {
        flex-direction: column;
        padding: 0 15px 15px 15px;
        align-items: stretch;
        overflow: hidden;
    }

    body.list-view-active #controls {
        position: relative;
        width: 100%;
        border: none;
        padding: 10px 0;
        background: transparent;
        flex: 0 0 auto;
    }

    body.list-view-active #list-container {
        max-width: 100%;
        width: 100%;
        flex: 1 1 auto;
        height: 100%;
        max-height: 100%;
        min-height: 0;
        padding: 20px 15px 60px 15px;
        border: 1px solid rgba(0, 255, 0, 0.4);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Ensure touch gestures are handled by JS and allow panning/zooming on mobile */
#network-canvas {
    touch-action: none; /* allow handling pinch/pan in JS */
    -ms-touch-action: none;
}

/* Allow canvas drawing to overflow horizontally on mobile when zoomed in */
#graph-container {
    overflow-x: visible;
}

/* Controls */
#controls {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 3200; /* keep controls above modal overlay */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.control-buttons.bottom-row {
    justify-content: flex-start;
    gap: 8px;
}

.legend-toggle-row {
    display: none;
}

.legend-toggle-row .control-btn {
    width: 100%;
}

.control-btn {
    background: #000000a1;
    border: 1px solid #00ff00;
    color: #00ff00;
    padding: 8px 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    cursor: pointer;
    text-transform: lowercase;
    transition: all 0.2s;
}

.control-btn:hover {
    background: #00ff00;
    color: #000;
}

.search-wrapper {
    display: flex;
    width: 100%;
}

@media (max-width: 1024px) {
    .search-wrapper {
        display: none !important;
    }
}

#node-search {
    flex: 1;
    min-width: 170px;
    background: rgba(0, 0, 0, 0.75);
    border: 1px solid #00ff00;
    color: #00ff00;
    padding: 8px 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    text-transform: lowercase;
}

#node-search::placeholder {
    color: rgba(0, 255, 0, 0.55);
    text-transform: lowercase;
}

#legend {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #00ff00;
    padding: 10px;
    font-size: 0.7rem;
    min-width: 120px;
}

#legend div {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    gap: 8px;
}

    /* On mobile keep legend items inline and remove extra spacing */
    @media (max-width: 480px) {
        #legend div { margin-bottom: 0; }
        #legend { gap: 10px; }
    }

.artist-dot, .dj-dot, .location-dot, .genre-dot, .collective-dot, .other-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.artist-dot {
    background-color: #00ff00;
}

.dj-dot {
    background-color: #ff6f00;
}

.location-dot {
    background-color: #ff0080;
}

.genre-dot {
    background-color: #0080ff;
}

.other-dot {
    background-color: #bfbfbf;
}

.collective-dot {
    background-color: #ffff00;
}

/* Modal styling */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

#modal-overlay.hidden {
    display: none;
}

#modal {
    background: #000;
    border: 2px solid #00ff00;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: slideIn 0.3s ease;
}

#modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #00ff00;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#modal-title {
    font-size: 1.2rem;
    font-weight: normal;
    text-transform: lowercase;
}

#close-modal {
    background: transparent;
    border: none;
    color: #00ff00;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#close-modal:hover {
    background: #00ff00;
    color: #000;
}

#modal-content {
    padding: 20px;
}

.info-row {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.label {
    font-weight: bold;
    opacity: 0.8;
    font-size: 0.9rem;
}

#artist-info {
    color: #b0d0aa;
}

#artist-info .label {
    color: #00ff00;
}

#artist-name, #artist-genre, #artist-location, #artist-location2 {
    font-size: 1rem;
}

#artist-url {
    color: #0080ff;
    text-decoration: underline;
    word-break: break-all;
}

#artist-url {
    color: #0080ff;
    text-decoration: underline;
    word-break: break-all;
    transition: all 0.12s ease;
    display: inline-block; /* allow background to show consistently */
    padding: 2px 4px;
    border-radius: 3px;
}

#artist-url:hover {
    background: #00ff00;
    color: #000;
    text-decoration: none;
}

/* Use same link styling for collective links inside artist modal */
.artist-collective-link {
    color: #0080ff;
    text-decoration: underline;
    word-break: break-all;
    transition: all 0.12s ease;
    display: inline-block;
    padding: 2px 4px;
    border-radius: 3px;
}

.artist-collective-link:hover {
    background: #00ff00;
    color: #000;
    text-decoration: none;
}

#artist-info-text {
    margin-top: 5px;
    line-height: 1.5;
    font-size: 0.95rem;
    opacity: 0.9;
}

.about-content {
    line-height: 1.6;
    font-size: 0.95rem;
}

.about-content p {
    margin-bottom: 15px;
}

.about-content ul {
    line-height: 1.8;
}

.about-content a {
    color: #0080ff;
    text-decoration: underline;
}

.about-content a:hover {
    color: #00ff00;
}

/* About modal styling - wider than default */
#modal.about-modal {
    max-width: 700px;
    width: 90%;
}

#modal.about-modal .about-content {
    max-width: none;
}

/* Bottom info bar */
#bottom-info {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(0, 0, 0, 0.95);
    border-top: 1px solid #00ff00;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    font-size: 0.8rem;
    z-index: 3300; /* float above modal overlay */
}

.explainer-text {
    color: #00ff00;
    opacity: 0.8;
    font-family: 'Courier New', monospace;
}

#about-us-btn {
    background: transparent;
    border: 1px solid #00ff00;
    color: #00ff00;
    padding: 6px 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    cursor: pointer;
    text-transform: lowercase;
    transition: all 0.2s;
    white-space: nowrap;
}

#about-us-btn:hover {
    background: #00ff00;
    color: #000;
}

/* Reuse the about-us hover color for overview/listing pages showing multiple producers.
   This covers common selectors for artist lists/cards/rows/links. Adjust selectors
   if your overview markup uses different class names. */
.overview a:hover,
.overview .artist-item:hover,
.artist-list a:hover,
.artist-card:hover,
.artist-entry:hover,
.artist-row:hover,
.artist-link:hover,
.overview button:hover {
    background: #00ff00;
    color: #000;
    transition: all 0.15s;
}

/* Apply same invert hover to group artist buttons used in lists/overviews.
   We use !important to override inline 'background' styles if present. */
.group-artist-btn {
    transition: all 0.12s ease;
}
.group-artist-btn:hover {
    background: #00ff00 !important;
    color: #000 !important;
    text-decoration: none;
}

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

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to { 
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    header {
        text-align: center;
    }
    
    .header-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        position: static;
    }
    
    .logo {
        height: 45px;
        position: static;
        order: -1;
    }
    
    .header-text {
        padding: 0;
        text-align: center;
        line-height: 1.2;
    }
    
    header h1 {
        font-size: 1.4rem;
        margin-bottom: 3px;
    }
    
    .title-full {
        display: none;
    }
    
    .title-short {
        display: inline;
    }
    
    header p {
        font-size: 0.8rem;
        line-height: 1.1;
    }
    
    /* Hide usage description on mobile */
    .explainer-text {
        display: none;
    }
    
    /* Make main take full available height on mobile */
    main {
        flex: 1;
        height: auto;
        padding-bottom: 0;
        min-height: 0; /* allow flex shrinking */
    }
    
    #graph-container {
        height: 100%;
        min-height: 0; /* allow flex shrinking */
        flex: 1;
    }
    
    #network-canvas {
        height: 100%;
        width: 100%;
        display: block;
    }
    
    #modal {
        width: 98%;
        max-height: 92vh;
        border-radius: 4px;
    }
    
    #modal-content {
        padding: 15px;
    }
    
    .info-row {
        margin-bottom: 12px;
    }
    
    #network-canvas {
        cursor: default;
    }
}

/* When modal is open, prevent scroll without hiding chrome */
body.modal-open {
    overflow: hidden; /* prevent background scrolling */
}

body.modal-open #controls {
    z-index: 1900; /* position controls just beneath the modal overlay */
}

body.modal-open header {
    display: none;
}

/* Make overlay highest z-index to cover everything */
#modal-overlay {
    z-index: 2000;
}

@media (max-width: 480px) {
    header {
        padding: 15px;
        text-align: center;
    }
    
    .header-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        position: static;
    }
    
    .logo {
        height: 35px;
        position: static;
        order: -1;
    }

    
    
    .header-text {
        padding: 0;
        text-align: center;
        line-height: 1.1;
    }
    
    header h1 {
        font-size: 1.2rem;
        letter-spacing: 1px;
        margin-bottom: 2px;
        line-height: 1.2;
    }
    
    .title-full {
        display: none;
    }
    
    .title-short {
        display: inline;
    }
    
    header p {
        line-height: 1.0;
    }

    .subtitle-desktop {
        display: none;
    }

    .subtitle-mobile {
        display: inline;
        white-space: nowrap;
    }
    
    /* Hide usage text on mobile */
    .explainer-text {
        display: none;
    }
    
    /* Ensure full height usage on small mobile */
    main {
        flex: 1;
        height: auto;
        padding-bottom: 0;
        min-height: 0; /* allow flex shrinking */
    }
    
    #graph-container {
        height: 100%;
        min-height: 0; /* allow flex shrinking */
        flex: 1;
    }
    
    #network-canvas {
        height: 100%;
        width: 100%;
        display: block;
    }

    /* Modern mobile modal layout */
    #modal {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
    }

    #modal-header {
        padding: 18px 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    #modal-content {
        padding: 18px;
        overflow-y: auto;
    }

    .group-list button.group-artist-btn {
        padding: 12px 14px !important;
        font-size: 1rem !important;
        border-radius: 4px;
    }

    #list-container {
        padding: 8px 12px 90px 12px;
    }
}

@media (max-width: 768px) {
    body {
        padding-bottom: 0;
    }

    main {
        padding-bottom: 0;
    }

    #bottom-info {
        display: none;
    }

    #modal-overlay {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    #modal {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    #modal-content {
        flex: 1;
        overflow-y: auto;
    }

    #controls {
        position: fixed !important;
        bottom: 0 !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 16px 18px !important;
        background: rgba(0, 0, 0, 0.95) !important;
    border-top: 1px solid #00ff00;
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        box-shadow: 0 -6px 22px rgba(0, 0, 0, 0.35);
        z-index: 1100;
    }

    #controls.mobile-bottom-controls .control-buttons,
    #controls.mobile-bottom-controls #legend {
        width: 100%;
    }

    #controls.mobile-bottom-controls #legend {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px 14px;
        font-size: 0.78rem;
        padding: 12px 14px;
    border: 1px solid #00ff00;
    border-radius: 0;
        box-sizing: border-box;
        background: rgba(0, 0, 0, 0.78);
    }

    #controls.mobile-bottom-controls #legend div {
        display: flex;
        align-items: center;
        gap: 10px;
        min-height: 20px;
    }

    /* Hide search by default when filters (legend) are collapsed on mobile */
    #controls.mobile-bottom-controls .search-wrapper {
        display: none;
        width: 100%;
        box-sizing: border-box;
    }

    /* When the mobile controls are expanded (not legend-collapsed), show search */
    #controls.mobile-bottom-controls:not(.legend-collapsed) .search-wrapper {
        display: block;
        padding: 0 4px;
    }

    #controls.mobile-bottom-controls .legend-toggle-row {
        display: block;
    }

    #controls.mobile-bottom-controls .legend-toggle-row .control-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
        min-height: 34px;
    }

    #controls.mobile-bottom-controls.legend-collapsed #legend {
        display: none;
    }

    #controls.mobile-bottom-controls .control-buttons.bottom-row {
        display: flex;
        gap: 10px;
        width: 100%;
    }

    #controls.mobile-bottom-controls .control-buttons.bottom-row .control-btn,
    #controls.mobile-bottom-controls .control-buttons.bottom-row #about-us-btn {
        flex: 1 1 0;
        text-align: center;
        padding: 8px 10px;
        font-size: 0.8rem;
        min-height: 34px;
    }

    #controls.mobile-bottom-controls .control-buttons.bottom-row #about-us-btn {
        border: 1px solid #00ff00;
        background: transparent;
        color: #00ff00;
        transition: all 0.2s;
    }

    #controls.mobile-bottom-controls .control-buttons.bottom-row #about-us-btn:hover {
        background: #00ff00;
        color: #000;
    }

    #controls.mobile-bottom-controls .control-buttons {
        gap: 8px;
        justify-content: stretch;
    }

    #controls.mobile-bottom-controls .control-buttons:not(.bottom-row):not(.legend-toggle-row) {
        display: none;
    }

}
