/* Multifractal Sonifier styles */

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

body {
    background: var(--bg-warm, #f5f5f5);
    color: var(--text-primary, #2d2d2d);
    font-family: 'EB Garamond', Georgia, serif;
    min-height: 100vh;
}

.content {
    max-width: 960px;
    margin: 0 auto;
    padding: calc(var(--header-height, 64px) + 2rem) 1.5rem 3rem;
}

.intro h1 {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 2rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
}

.intro p {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-muted, #6b6b6b);
    margin-bottom: 1.5rem;
}

.intro a {
    color: var(--text-primary, #2d2d2d);
    text-decoration: underline;
    text-decoration-color: #ccc;
}

.intro a:hover {
    text-decoration-color: var(--text-primary, #2d2d2d);
}

/* Status bar */
#status-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #eee;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-size: 0.85rem;
    color: var(--text-muted, #6b6b6b);
}

#status-bar.ready {
    background: #e8f5e9;
    color: #2e7d32;
}

#status-bar.error {
    background: #fce4ec;
    color: #c62828;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-top-color: #666;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner.hidden {
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Layout */
.app-layout {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.canvas-area {
    flex: 1;
    min-width: 0;
}

.canvas-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 512px;
}

#field-canvas {
    width: 100%;
    height: auto;
    background: #222;
    border-radius: 4px;
    image-rendering: pixelated;
    display: block;
}

.row-pointer {
    position: absolute;
    left: -1.2em;
    top: 0;
    font-size: 0.75rem;
    line-height: 1;
    color: var(--text-primary, #2d2d2d);
    transition: top 0.05s linear;
    pointer-events: none;
    transform: translateY(-50%);
}

.row-pointer.hidden {
    display: none;
}

.col-pointer {
    position: absolute;
    top: -1.2em;
    left: 0;
    font-size: 0.75rem;
    line-height: 1;
    color: var(--text-primary, #2d2d2d);
    transition: left 0.05s linear;
    pointer-events: none;
    transform: translateX(-50%);
}

.col-pointer.hidden {
    display: none;
}

#field-canvas.waveform-canvas {
    background: #f5f5f5;
    image-rendering: auto;
    aspect-ratio: auto;
}

/* Controls panel */
#controls {
    width: 100%;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-size: 0.82rem;
}

#controlsBody {
    padding: 0.75rem 0.9rem;
}

.control-group {
    margin-bottom: 0.7rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--text-primary, #2d2d2d);
    font-size: 0.82rem;
}

.control-group label span {
    font-weight: 600;
}

input[type="range"] {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, #ccc, #888);
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    border: 2px solid #888;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: border-color 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    border-color: var(--text-primary, #2d2d2d);
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    border: 2px solid #888;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.control-divider {
    border: none;
    border-top: 1px solid #eee;
    margin: 0.7rem 0;
}

/* Grid info */
.grid-info {
    font-size: 0.8rem;
    color: var(--text-muted, #6b6b6b);
    line-height: 1.5;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(0,0,0,0.03);
    border-radius: 4px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.grid-warning {
    color: #c0392b;
    font-weight: 600;
}

/* Size toggle */
.toggle-group {
    display: flex;
    gap: 0;
    margin-top: 0.25rem;
}

.toggle-btn {
    flex: 1;
    padding: 0.35rem 0.5rem;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    font-size: 0.78rem;
    font-family: inherit;
    color: var(--text-muted, #6b6b6b);
    transition: all 0.15s ease;
}

.toggle-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.toggle-btn:last-child {
    border-radius: 0 4px 4px 0;
    border-left: none;
}

.toggle-btn.active {
    background: var(--text-primary, #2d2d2d);
    color: #fff;
    border-color: var(--text-primary, #2d2d2d);
}

/* Action buttons */
.button-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.action-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    background: #fff;
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-primary, #2d2d2d);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.action-btn.primary {
    background: var(--text-primary, #2d2d2d);
    color: #fff;
    border-color: var(--text-primary, #2d2d2d);
}

.action-btn.primary:hover:not(:disabled) {
    background: #444;
}

.action-btn:hover:not(:disabled):not(.primary) {
    background: #f0f0f0;
}

#play-btn, #stop-btn {
    flex: 0 0 auto;
    width: 2.2rem;
    padding: 0.5rem 0;
    text-align: center;
    font-size: 0.7rem;
    letter-spacing: -0.1em;
}

.download-btn {
    width: 100%;
    margin-top: 0.5rem;
    flex: none;
    transition: all 0.15s ease;
    min-height: 2.2rem;
}

/* Toggle row (log-scale etc.) */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toggle-row label {
    margin-bottom: 0;
}

/* Preset buttons */
.preset-row {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

.preset-btn {
    flex: 1;
    padding: 0.3rem 0.4rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    font-family: inherit;
    font-size: 0.72rem;
    cursor: pointer;
    color: var(--text-muted, #6b6b6b);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.preset-btn:hover {
    background: #f0f0f0;
    border-color: #999;
    color: var(--text-primary, #2d2d2d);
}

/* Controls column wrapper */
.controls-column {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* About / What is this? dropdown */
.about-section {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.about-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-size: 0.8rem;
    color: var(--text-muted, #6b6b6b);
    text-align: left;
    cursor: pointer;
    transition: color 0.15s ease;
}

.about-toggle:hover {
    color: var(--text-primary, #2d2d2d);
}

.about-toggle.open {
    border-bottom: 1px solid #e0e0e0;
}

.about-label {
    font-weight: 500;
}

.about-arrow {
    font-size: 0.7rem;
    transition: transform 0.15s ease;
}

.about-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 1rem;
}

.about-content.open {
    max-height: 1000px;
    padding: 0.75rem 1rem 1rem;
}

.about-content p {
    font-size: 0.85rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
    color: var(--text-primary, #2d2d2d);
}

.about-content p:last-child {
    margin-bottom: 0;
}

.about-content a {
    color: inherit;
    text-decoration: underline;
}

.about-content a:hover {
    text-decoration: none;
}

/* Download section error message */
.download-error {
    margin-top: 0.5rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.78rem;
    line-height: 1.4;
    color: #c62828;
    background: #fce4ec;
    border-radius: 4px;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
}

/* Download section loops row */
.loops-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.loops-row label {
    margin-bottom: 0;
    color: var(--text-primary, #2d2d2d);
}

.loops-input {
    width: 56px;
    padding: 0.28rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.82rem;
    text-align: center;
    color: var(--text-primary, #2d2d2d);
    background: #fff;
    outline: none;
    transition: border-color 0.15s ease;
}

.loops-input:focus {
    border-color: #888;
}

/* Mobile layout */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    .controls-column {
        width: 100%;
        order: 1;
    }

    .canvas-area {
        order: 0;
    }

    #field-canvas {
        max-width: 100%;
    }
}
