/**
 * Reference System Styles
 * Wikipedia-style citation and reference formatting
 */

/* Inline citation numbers */
.reference-citation {
    font-size: 0.85em;
    line-height: 1;
    vertical-align: super;
}

.reference-citation a {
    color: #0645ad;
    text-decoration: none;
    padding: 0 2px;
}

.reference-citation a:hover {
    text-decoration: none;
    background: #f0f8ff;
    border-radius: 2px;
}

.reference-citation a:visited {
    color: #0b0080;
}

/* References section */
.references-section {
    margin-top: 2em;
    padding-top: 1.5em;
    border-top: 2px solid #a7d7f9;
    font-size: 0.9em;
    clear: both;
}

.references-section h2 {
    font-family: 'Linux Libertine', 'Times New Roman', Times, serif;
    font-size: 1.5em;
    font-weight: 400;
    margin: 0 0 0.5em 0;
    padding-bottom: 0.25em;
    border-bottom: 1px solid #a7d7f9;
}

/* References list */
.references-list {
    list-style: none;
    counter-reset: ref-counter;
    margin: 0;
    padding: 0;
}

.reference-item {
    counter-increment: ref-counter;
    margin: 0.5em 0;
    padding-left: 2.5em;
    position: relative;
    line-height: 1.6;
}

.reference-item::before {
    content: counter(ref-counter) ".";
    position: absolute;
    left: 0;
    font-weight: 700;
    color: #202122;
}

/* Backlink arrow */
.reference-backlink {
    position: absolute;
    left: 1.5em;
    font-size: 0.9em;
}

.reference-backlink a {
    color: #0645ad;
    text-decoration: none;
    font-weight: 700;
    padding: 0 2px;
}

.reference-backlink a:hover {
    background: #f0f8ff;
    border-radius: 2px;
}

/* Internal vs external links in references */
.internal-link {
    color: #0b0080;
    text-decoration: none;
    font-weight: 500;
}

.internal-link:hover {
    text-decoration: underline;
    color: #0645ad;
}

.external-link {
    color: #0645ad;
    text-decoration: none;
}

.external-link:hover {
    text-decoration: underline;
}

.external-link::after {
    content: "↗";
    font-size: 0.8em;
    margin-left: 2px;
    color: #666;
}

/* Broken link warning */
.broken-link {
    color: #c33;
    border-bottom: 1px dotted #c33;
    cursor: help;
}

/* Backlinks section */
.backlinks-section {
    margin-top: 2em;
    padding: 1em;
    background: #f8f9fa;
    border: 1px solid #a7d7f9;
    border-radius: 4px;
}

.backlinks-section h3 {
    font-family: 'Linux Biolinum', 'Helvetica Neue', Arial, sans-serif;
    font-size: 1.1em;
    font-weight: 700;
    margin: 0 0 0.5em 0;
}

.backlinks-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.backlinks-list li {
    margin: 0.3em 0;
}

.backlink {
    color: #0b0080;
    text-decoration: none;
    padding: 2px 4px;
    border-radius: 2px;
    transition: background 0.2s;
}

.backlink:hover {
    background: #e8f4ff;
    text-decoration: none;
}

/* Hover preview tooltip */
.reference-tooltip {
    position: absolute;
    z-index: 10000;
    background: #fff;
    border: 1px solid #a2a9b1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 0.75em 1em;
    max-width: 400px;
    font-size: 0.9em;
    line-height: 1.5;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.reference-tooltip.show {
    opacity: 1;
}

.reference-tooltip-number {
    font-weight: 700;
    color: #202122;
    margin-bottom: 0.3em;
}

.reference-tooltip-content {
    color: #202122;
}

.reference-tooltip-content em {
    font-style: italic;
}

.reference-tooltip-content a {
    color: #0645ad;
    text-decoration: none;
}

.reference-tooltip-content a:hover {
    text-decoration: underline;
}

/* Reference error messages */
.reference-item .error {
    color: #c33;
    font-style: italic;
}

/* Wikipedia-style wiki-links for references */
a.wiki-ref-link {
    color: #0645ad;
    text-decoration: none;
    border-bottom: 1px dotted #0645ad;
    padding: 0 1px;
}

a.wiki-ref-link:hover {
    text-decoration: none;
    border-bottom: 1px solid #0645ad;
    background: #f0f8ff;
    border-radius: 2px;
}

a.wiki-ref-link:visited {
    color: #0b0080;
    border-bottom-color: #0b0080;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .references-section {
        font-size: 0.85em;
    }
    
    .reference-item {
        padding-left: 2em;
    }
    
    .reference-tooltip {
        max-width: 90vw;
        font-size: 0.85em;
    }
    
    .backlinks-section {
        padding: 0.75em;
    }
}

/* Print styles */
@media print {
    .reference-citation a {
        color: #000;
    }
    
    .reference-tooltip {
        display: none;
    }
    
    .references-section {
        page-break-before: auto;
    }
    
    .reference-item {
        page-break-inside: avoid;
    }
}

/* ============================================
   MARKDOWN EXTENSIONS
   ============================================ */

/* Musical Notation: <#>C0</#> */
.musical-notation {
    font-family: 'Times New Roman', 'Linux Libertine', serif;
    font-weight: 500;
    color: #1a472a;
    white-space: nowrap;
}

.musical-notation .note-name {
    font-size: 1.1em;
    letter-spacing: 0.02em;
}

.musical-notation .note-exponent {
    font-size: 0.75em;
    font-weight: 400;
    color: #2d5a3d;
}

/* Piano Key Notation: &C5& */
.piano-key {
    font-family: 'Courier New', 'Consolas', monospace;
    font-weight: 600;
    color: #2c2c2c;
    background: linear-gradient(180deg, #ffffff 0%, #f0f0f0 100%);
    border: 1px solid #999;
    border-radius: 3px;
    padding: 2px 6px;
    white-space: nowrap;
    box-shadow: 0 2px 3px rgba(0,0,0,0.1);
    display: inline-block;
    line-height: 1.4;
}

.piano-key .key-name {
    font-size: 1em;
}

.piano-key .key-octave {
    font-size: 0.7em;
    color: #666;
}

/* Temperament and Scale Thumbnails: {{temperament:Name}} */
.temperament-thumbnail,
.scale-thumbnail {
    display: inline-block;
    margin: 0.5em;
    vertical-align: middle;
    border: 1px solid #a7d7f9;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.temperament-thumbnail[data-float="right"],
.scale-thumbnail[data-float="right"] {
    float: right;
    margin-left: 1em;
}

.temperament-thumbnail[data-float="left"],
.scale-thumbnail[data-float="left"] {
    float: left;
    margin-right: 1em;
}

.temperament-thumbnail[data-size="small"],
.scale-thumbnail[data-size="small"] {
    width: 200px;
}

.temperament-thumbnail[data-size="medium"],
.scale-thumbnail[data-size="medium"] {
    width: 300px;
}

.temperament-thumbnail[data-size="large"],
.scale-thumbnail[data-size="large"] {
    width: 400px;
}

.thumbnail-loading {
    background: #f8f9fa;
    padding: 1em;
    text-align: center;
    color: #666;
    font-size: 0.9em;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Thumbnail hover effects */
.temperament-thumbnail:hover,
.scale-thumbnail:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

/* Include System */
.included-content {
    /* Seamlessly integrated - no special styling by default */
}

.include-error {
    background: #fee;
    border: 1px solid #fcc;
    padding: 0.75em 1em;
    margin: 1em 0;
    border-radius: 4px;
    color: #c33;
    font-size: 0.9em;
}

/* Lattice Diagram Tables - Clean, borderless layout for musical notation diagrams */
.lattice-diagram {
    display: inline-table !important;
    border-collapse: collapse !important;
    border: none !important;
    background: none !important;
    width: auto !important;
    margin: 2em auto !important;
}

.lattice-diagram tr {
    background: none !important;
    border: none !important;
}

.lattice-diagram td,
.lattice-diagram th {
    padding: 0.75em 1.5em !important;
    border: none !important;
    background: none !important;
    text-align: center !important;
}

/* Responsive */
@media (max-width: 768px) {
    .temperament-thumbnail[data-float="right"],
    .scale-thumbnail[data-float="right"],
    .temperament-thumbnail[data-float="left"],
    .scale-thumbnail[data-float="left"] {
        float: none;
        display: block;
        margin: 1em auto;
        max-width: 100%;
    }
    
    .piano-key {
        font-size: 0.9em;
        padding: 1px 4px;
    }
    
    .lattice-diagram td,
    .lattice-diagram th {
        padding: 0.5em 1em !important;
    }
}

