/* ===== RhythmStudio – Jalon 2 : grille interactive (thème sombre) ===== */

/* --- Page height fixes --- */
/* 'hidden' must win over .grid-wrapper { display:flex } (legacy grid) */
[hidden] { display: none !important; }

/* No extra padding around the editor: it already fills the viewport */
article.content:has(> .rhythm-editor) { padding: 0 !important; }

.rhythm-editor {
    height: 100vh;
    height: 100dvh;
    box-sizing: border-box;
    min-height: 0;
}

/* Grid fills remaining height and scrolls internally */
.rhythm-editor > .rg-root {
    flex: 1;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
}
.rhythm-editor > .rg-root > .rg-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.rg-root {
    --rg-bg: #12141c;
    --rg-bg-2: #1b1e2a;
    --rg-line: #2a2f40;
    --rg-line-strong: #4a5170;
    --rg-text: #e6e8f0;
    --rg-muted: #7d849c;
    --rg-cursor: #ffffff;
    background: var(--rg-bg);
    color: var(--rg-text);
    border-radius: 10px;
    padding: 10px;
    position: relative;
    user-select: none;
}

.rg-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.rg-hint { color: var(--rg-muted); font-size: .8rem; }
.rg-beats { display: inline-flex; gap: 4px; align-items: center; color: var(--rg-muted); font-size: .85rem; margin-left: 8px; }

.rg-select, .rg-input {
    background: var(--rg-bg-2); color: var(--rg-text);
    border: 1px solid var(--rg-line-strong); border-radius: 6px; padding: 4px 8px;
}

.rg-btn {
    background: #2d6cdf; color: #fff; border: 0; border-radius: 6px;
    padding: 5px 12px; cursor: pointer; font-weight: 600;
}
.rg-btn:hover { filter: brightness(1.15); }
.rg-btn-danger { background: #c2334d; width: 100%; margin-top: 8px; }

.rg-scroll { overflow-x: auto; overflow-y: auto; max-width: 100%; }

.rg-grid { border-collapse: separate; border-spacing: 0; width: max-content; table-layout: fixed; }
.rg-grid th, .rg-grid td { padding: 0; border-bottom: 1px solid var(--rg-line); }

.rg-sticky { position: sticky; left: 0; z-index: 2; background: var(--rg-bg); }
.rg-label {
    min-width: 210px; width: 210px; padding: 4px 8px !important; white-space: nowrap;
    border-right: 1px solid var(--rg-line-strong);
}
.rg-inst-row .rg-label { background: var(--rg-bg-2); font-weight: 700; }
.rg-inst-fill { background: var(--rg-bg-2); }
.rg-sound-label { padding-left: 26px !important; font-size: .9rem; }
.rg-inst-name { margin-right: 6px; }

.rg-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

.rg-icon {
    background: transparent; color: var(--rg-muted); border: 1px solid var(--rg-line-strong);
    border-radius: 4px; font-size: .7rem; padding: 0 5px; margin-left: 3px; cursor: pointer;
}
.rg-icon:hover { color: var(--rg-text); }
.rg-on-mute { background: #c2334d; color: #fff; border-color: #c2334d; }
.rg-on-solo { background: #ffb703; color: #111; border-color: #ffb703; }
.rg-del:hover { color: #ff4d6d; border-color: #ff4d6d; }

.rg-dim { opacity: .35; }

/* Header */
.rg-beat-head { width: 52px; min-width: 52px; max-width: 52px; height: 30px; text-align: center; font-size: .75rem; color: var(--rg-muted); position: relative; }
.rg-measure-num { position: absolute; top: 1px; left: 4px; font-size: .65rem; color: var(--rg-text); }
.rg-bell { font-size: .9rem; display: inline-block; }
.rg-bell-ring { animation: rg-ring .3s ease-in-out infinite alternate; }
@keyframes rg-ring { from { transform: rotate(-18deg) scale(1.1); } to { transform: rotate(18deg) scale(1.3); } }

/* Measure header (copy / paste) */
.rg-measure-head {
    text-align: left; padding: 2px 4px !important; height: 26px;
    background: var(--rg-bg-2); white-space: nowrap; font-size: .75rem;
}
.rg-measure-bar { display: flex; align-items: center; gap: 3px; height: 22px; overflow: hidden; }
.rg-measure-bar .rg-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; padding: 0; margin: 0; flex-shrink: 0; line-height: 0;
}
.rg-measure-head[draggable="true"] { cursor: grab; }
.rg-measure-head.rg-dragging { opacity: .4; }
.rg-measure-head.rg-drop-target { box-shadow: inset 3px 0 0 #00E5FF; }
.rg-measure-bar .icon-svg { vertical-align: middle; }
.rg-measure-title { font-weight: 700; margin-right: 4px; }
.rg-measure-label { background: var(--rg-bg-2) !important; }
.rg-clip-info { color: var(--rg-muted); font-size: .7rem; font-weight: 400; }
.rg-icon:disabled { opacity: .3; cursor: default; }

/* Measure separators / downbeat */
.rg-downbeat { border-left: 2px solid var(--rg-line-strong) !important; }

/* Cells */
.rg-cell { width: 52px; min-width: 52px; max-width: 52px; height: 34px; padding: 3px !important; }
.rg-slots { display: flex; gap: 2px; height: 100%; }

.rg-slot {
    flex: 1; border-radius: 4px; background: #232737; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-size: .6rem; line-height: 1; color: #10121a; font-weight: 800;
    transition: background .08s, box-shadow .08s, transform .08s;
}
.rg-slot:hover { background: #2f3550; }
.rg-slot.on {
    background: var(--c);
    box-shadow: 0 0 6px color-mix(in srgb, var(--c) 70%, transparent);
}
.rg-slot.rg-hit { transform: scale(1.12); box-shadow: 0 0 14px var(--c), 0 0 4px #fff; filter: brightness(1.3); }

.rg-hand { font-size: .65rem; }
.rg-syl { font-size: .55rem; font-weight: 600; opacity: .85; }

/* Playback cursor (current beat column) */
.rg-current { background: rgba(0, 255, 240, .18); box-shadow: inset 2px 0 0 var(--color-accent), inset -2px 0 0 var(--color-accent); }
.rg-beat-head.rg-current { color: var(--color-accent); background: rgba(0, 255, 240, .28); }
.rg-seekable { cursor: pointer; user-select: none; }
.rg-seekable:hover { background: rgba(255, 255, 255, .12); }

/* Context menu */
.rg-menu {
    position: fixed; z-index: 1000; min-width: 210px;
    background: var(--rg-bg-2); border: 1px solid var(--rg-line-strong);
    border-radius: 8px; padding: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.rg-menu-title { font-weight: 700; margin-bottom: 4px; padding-right: 22px; }
.rg-menu-close {
    position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
    background: transparent; border: none; border-radius: 4px; color: var(--rg-muted);
    cursor: pointer; font-size: .9rem; line-height: 1; padding: 0;
}
.rg-menu-close:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.rg-menu-section { color: var(--rg-muted); font-size: .7rem; text-transform: uppercase; margin: 6px 0 3px; }
.rg-menu-row { display: flex; gap: 4px; flex-wrap: wrap; }
.rg-chip {
    background: #232737; color: var(--rg-text); border: 1px solid var(--rg-line-strong);
    border-radius: 5px; padding: 2px 8px; cursor: pointer; font-size: .8rem;
}
.rg-chip.active { background: #2d6cdf; border-color: #2d6cdf; }
.rg-menu .rg-input { width: 100%; margin-top: 6px; }

/* Themed scrollbars */
html, body, .rg-root, .rg-root * {
    scrollbar-width: thin;
    scrollbar-color: #4a5170 #12141c;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #12141c; }
::-webkit-scrollbar-thumb {
    background: #4a5170; border-radius: 6px; border: 2px solid #12141c;
}
::-webkit-scrollbar-thumb:hover { background: #2d6cdf; }
::-webkit-scrollbar-corner { background: #12141c; }
