/* MidiEditor AI — Manual Stylesheet */

:root {
    --bg: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2129;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --border: #30363d;
    --link: #58a6ff;
    --link-hover: #79c0ff;
    --code-bg: #1c2129;
    --table-alt: #161b22;
    --header-bg: #010409;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 16px;
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 2rem 4rem;
}

/* Header / Title */
h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.4em;
}

h1 { font-size: 2em; }
h2 { font-size: 1.5em; }
h3 { font-size: 1.25em; border-bottom: none; }
h4 { font-size: 1.1em; border-bottom: none; }

/* Paragraphs & text */
p {
    margin-bottom: 1rem;
    color: var(--text);
}

/* Links */
a {
    color: var(--link);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--link-hover);
    text-decoration: none;
}

/* Scroll-to-top button */
.scroll-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background 0.2s;
    z-index: 999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}
.scroll-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.scroll-top:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

/* Lists */
ul, ol {
    margin: 0.5rem 0 1rem 1.5rem;
}

li {
    margin-bottom: 0.4rem;
}

li ul, li ol {
    margin-top: 0.3rem;
    margin-bottom: 0.3rem;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin: 1rem 0;
}

/* Inline tool icons (small images in tables/paragraphs) */
img[src*="tools/"] {
    display: inline-block;
    vertical-align: middle;
    max-width: 24px;
    max-height: 24px;
    border: none;
    border-radius: 3px;
    margin: 0 4px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 1.5rem;
    font-size: 0.95em;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

th {
    background: var(--bg-card);
    color: var(--text);
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

tr:nth-child(even) {
    background: var(--table-alt);
}

tr:hover {
    background: var(--bg-card);
}

/* Code */
code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    background: var(--code-bg);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
    border: 1px solid var(--border);
}

pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
    font-size: 0.9em;
}

pre code {
    border: none;
    padding: 0;
    background: transparent;
}

/* Horizontal rule */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* Navigation bar at top */
.nav-bar {
    background: var(--header-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    margin-bottom: 2rem;
    animation: navSlideDown 0.4s ease-out;
}

@keyframes navSlideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.nav-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.nav-icon {
    font-size: 1.15em;
    display: inline-block;
    animation: robotBounce 2s ease-in-out infinite;
}

@keyframes robotBounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-2px); }
}

.nav-title {
    color: var(--text);
    font-weight: 700;
    font-size: 1em;
}

.nav-version {
    color: var(--text-muted);
    font-size: 0.8em;
    font-weight: 400;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1em 0.45em;
}

.nav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem clamp(0.25rem, 0.8vw, 0.55rem);
    flex-wrap: wrap;
}

.nav-bar a {
    color: var(--text-muted);
    font-size: clamp(0.62em, 1.3vw, 0.78em);
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.2s, transform 0.15s;
    display: inline-block;
    padding: 0.15em 0.35em;
    border-radius: 4px;
}

.nav-bar a:hover {
    color: var(--accent);
    text-decoration: none;
    transform: translateY(-1px);
    background: rgba(88, 166, 255, 0.08);
}

.nav-bar a.active {
    color: var(--accent);
    background: rgba(88, 166, 255, 0.12);
}

.nav-links .nav-sep {
    color: var(--border);
    font-size: 0.7em;
    user-select: none;
}

.nav-links a {
    animation: linkFadeIn 0.5s ease-out both;
}

.nav-links a:nth-child(1)  { animation-delay: 0.03s; }
.nav-links a:nth-child(2)  { animation-delay: 0.05s; }
.nav-links a:nth-child(3)  { animation-delay: 0.07s; }
.nav-links a:nth-child(4)  { animation-delay: 0.09s; }
.nav-links a:nth-child(5)  { animation-delay: 0.11s; }
.nav-links a:nth-child(6)  { animation-delay: 0.13s; }
.nav-links a:nth-child(7)  { animation-delay: 0.15s; }
.nav-links a:nth-child(8)  { animation-delay: 0.17s; }
.nav-links a:nth-child(9)  { animation-delay: 0.19s; }
.nav-links a:nth-child(10) { animation-delay: 0.21s; }
.nav-links a:nth-child(11) { animation-delay: 0.23s; }
.nav-links a:nth-child(12) { animation-delay: 0.25s; }
.nav-links a:nth-child(13) { animation-delay: 0.27s; }
.nav-links a:nth-child(14) { animation-delay: 0.29s; }
.nav-links a:nth-child(15) { animation-delay: 0.31s; }
.nav-links a:nth-child(16) { animation-delay: 0.33s; }

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

/* Footer */
.footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85em;
}

.footer a {
    color: var(--accent);
}

/* Blockquote */
blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.5rem 1rem;
    margin: 1rem 0;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-radius: 0 6px 6px 0;
}

/* Selection */
::selection {
    background: var(--accent);
    color: var(--bg);
}

/* Lightbox overlay */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    backdrop-filter: blur(4px);
}

.lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-overlay img {
    max-width: 92vw;
    max-height: 90vh;
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    transform: scale(0.92);
    transition: transform 0.25s ease;
    cursor: default;
    margin: 0;
}

.lightbox-overlay.active img {
    transform: scale(1);
}

.lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1.5rem;
    color: var(--text-muted);
    font-size: 2rem;
    font-weight: 300;
    cursor: pointer;
    z-index: 10000;
    line-height: 1;
    transition: color 0.2s;
    background: none;
    border: none;
    font-family: inherit;
}

.lightbox-close:hover {
    color: var(--text);
}

/* Clickable thumbnails (not tool icons) */
img.lightbox-thumb {
    cursor: zoom-in;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

img.lightbox-thumb:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 20px rgba(88, 166, 255, 0.15);
}

/* Responsive */
@media (max-width: 700px) {
    body {
        padding: 1rem;
        font-size: 15px;
    }

    table {
        font-size: 0.85em;
    }

    td, th {
        padding: 0.5rem;
    }
}
