/* set CSS variables */
:root {
    --primary-color: #163c7a;
    --secondary-color: #b4becf;
    --text-color: #ffffff;
    --font-family: 'Arial', sans-serif;
}

html { 
    scroll-behavior: smooth;
    scroll-padding-top: 1.5em; /* to offset sticky nav bar */
}

#version-footer{ 
    max-width: 1200px;
    margin: 15px auto;
    padding: 8px 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    color: #555;
    font-size: 0.8em;
    line-height: 1.3;
}

#version-footer p {
    margin: 0.2em 0;
    text-align: left;
}

#version-footer a {
    display:inline;
    color: var(--primary-color);
    text-decoration: none;
}
#version-footer a:hover {
    color: var(--secondary-color);
}

header img { 
    width: 100px;
    height: auto;
    margin: 0 auto;
    display: inline;
    vertical-align:middle;
    border-radius:8px;
}


/* General body styling */
body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--secondary-color);
    color: #333;
    line-height: 2.5;
    position:relative;
}

/* Header styling */
header {
    background-color: var(--primary-color);
    color: var(--text-color);
    padding: 20px 0;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position:relative;
}

header h1 {
    margin: 0;
    font-size: 2.5rem;
}

/* Navigation bar styling */
nav {
    position: sticky;
    top: 0;
    z-index: 1000; /* Keep the nav on top */
    background-color: var(--primary-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    color: var(--text-color);
}
nav ul {
    padding: 10px 0;
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    gap: 20px;
}

nav ul li {
    display: inline;
}

nav ul li a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 1rem;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

nav ul li a:hover {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

/* Main content styling */
main {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    color: var(--primary-color);
}

/* Section styling */
section {
    margin-bottom: 30px;
}

section h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
    margin-bottom: 15px;
}

section p, section div, section pre {
    text-align: left;
    font-size: 1rem;
    margin: 10px 0;
}

/* Styling for the graph */
#graph {
    border: 1px solid #ddd;
    padding: 20px;
    border-radius: 8px;
    background-color: #f4f4f4;
    overflow: hidden;
    line-height: .5;
    position: relative;
}

/* Graph container to fit entire graph */
#graph svg {
    width: 100% !important;
    height: auto !important;
    max-width: 100%;
}

/* Expand icon for graph */
.graph-expand-icon {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 24px;
    height: 24px;
    background-color: var(--primary-color);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease;
}

.graph-expand-icon:hover {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

/* Modal styles */
.graph-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
}

.graph-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.graph-modal-content {
    background-color: white;
    border-radius: 8px;
    width: 95%;
    height: 90%;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.graph-modal-header {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 20;
    display: flex;
    gap: 5px;
}

.graph-modal-button {
    width: 32px;
    height: 32px;
    background-color: var(--primary-color);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease;
}

.graph-modal-button:hover {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

.graph-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
}

.graph-modal-graph {
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 50px 20px 20px 20px;
    box-sizing: border-box;
}

.graph-modal-graph svg {
    display: block;
    margin: 0 auto;
    transform-origin: 0 0;
    transition: none;
    user-select: none;
}

.graph-modal-graph {
    user-select: none;
    overflow: hidden;
}

#graph .current rect {
    stroke: red !important;
}

#graph .mermaidTooltip {
    position: absolute;
    text-align: center;
    max-width: 200px;
    background-color: #fff;
    border: 1px solid #ddd;
    padding: 5px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Styling for JSON display */
#json-display {
    line-height:2;
}

/* Styling for music scores */
#music-scores {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

#music-scores .mei {
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 8px;
    background-color: #f9f9f9;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

#music-scores .highlight {
    fill: red;
}


.audio-container {
    position: relative;
}

.audio-label {
    position: absolute;
    top: -20px;
    left: 5px;
    color: black;
    font-family: Arial, sans-serif;
    font-size: 16px;
    z-index: 10;
}

/* Styling for textual content */
#text-content {
    font-size: 1.2rem;
    color: #555;
    line-height: 1.6;
}

/* Styling for JSON display */
#json-display {
    background-color: #f4f4f4;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    color: #333;
}

/* Footer styling */
footer {
    text-align: center;
    padding: 10px 0;
    background-color: var(--primary-color);
    color: var(--text-color);
    position: fixed;
    bottom: 0;
    width: 100%;
}

/* Link to open score in mei-friend, 
   styled as centered button */
.meifriendLink{
    display: block;
    text-align: center;
    margin: 10px 0;
    padding: 10px;
    border: 2px solid  var(--secondary-color);
    color: var(--primary-color);
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

/* Hide content if splash page is active, i.e. no ?obj parameter */
.splash nav, .splash main a, .splash main section{
    display: none;
}

#splash {
    display:none;
    text-align: justify;
    line-height: 1.6;
    padding: 10px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    color: #555;
    font-size: 1.2rem;
}

#splash span {
    text-decoration: underline
}

#splash a { 
    display: inline;
    color: var(--primary-color);
    text-decoration: none;
}

#splash a:hover {
    color: var(--secondary-color);
}

.splash #splash {
    display: block;
}

#splash pre {
    font-size:.9rem; 
}


/* Loading spinner styles */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #999;
    font-style: italic;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Subtle zoom wobble animation to indicate zoomability */
@keyframes zoomWobble {
    0% { transform: scale(1); }
    25% { transform: scale(1.02); }
    50% { transform: scale(0.98); }
    75% { transform: scale(1.01); }
    100% { transform: scale(1); }
}

/* Animation class for modal graph */
.graph-modal-content svg.zoom-wobble {
    animation: zoomWobble 1.2s ease-in-out;
}

/* Smooth zoom transitions for button clicks */
.graph-modal-content svg.zoom-transition {
    transition: transform 0.3s ease-out;
}

/* Hide loading spinner when content is loaded */
.content-loaded .loading-spinner {
    display: none;
}

/* No content message styles */
.no-content-message {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #999;
    font-style: italic;
    text-align: center;
    background-color: #f9f9f9;
    border: 1px dashed #ddd;
    border-radius: 4px;
    margin: 10px 0;
}

/* Error banner styles */
.error-banner {
    background-color: #fee;
    border: 1px solid #fcc;
    border-radius: 8px;
    margin: 0 0 20px 0;
    padding: 15px;
    position: relative;
    color: #c33;
}

.error-banner-content {
    margin-right: 30px;
}

.error-message {
    margin-bottom: 10px;
    font-size: 1rem;
}

.error-uri {
    margin-bottom: 10px;
    font-size: 0.9rem;
    word-break: break-all;
}

.error-uri code {
    background-color: #fdd;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
}

.error-status {
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.error-status code {
    background-color: #fdd;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-weight: bold;
}

.error-suggestions {
    font-size: 0.9rem;
}

.error-suggestions ul {
    margin: 5px 0 0 0;
    padding-left: 20px;
}

.error-suggestions li {
    margin: 5px 0;
    line-height: 1.4;
}

.error-banner-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 20px;
    color: #c33;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.error-banner-close:hover {
    background-color: rgba(204, 51, 51, 0.1);
}

/* Responsive design */
@media (max-width: 768px) {
    main {
        padding: 10px;
    }

    section h2 {
        font-size: 1.5rem;
    }

    #music-scores {
        flex-direction: column;
        align-items: center;
    }
}

/* Audio selections metadata styling */
#meta-audio-selections {
    margin: 1em 0;
    padding: 1em;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

#meta-audio-selections h3 {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 1.1rem;
}

#meta-audio-selections ul {
    list-style-type: none;
    padding: 0;
    margin: 0.5em 0;
}

#meta-audio-selections li {
    margin: 1em 0;
    padding: 0.8em;
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#meta-audio-selections li strong {
    color: var(--primary-color);
    font-size: 1.05em;
}

#meta-audio-selections a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9em;
    display: inline-block;
    margin-right: 10px;
}

#meta-audio-selections a:hover {
    text-decoration: underline;
}

#meta-audio-selections a:before {
    content: "🔗 ";
    opacity: 0.7;
}

#meta-audio-selections a[href*="musicbrainz.org"]:before {
    content: "🎵 ";
}