/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Markdown editor (Write/Preview tabs + toolbar) — module description field. */
.md-tab { background: transparent; color: #737373; }
.md-tab[data-active="true"] { background: #0D0D0D; color: #FAFAFA; }
/* Scoped to the editor only — a global `.hidden { !important }` would override the
   inline `display` that other panels (properties, specs, modals) rely on. */
.md-hidden { display: none; }

/* Rendered Markdown (preview pane and module show), dark theme. */
.markdown-body { word-wrap: break-word; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { color: #FAFAFA; font-weight: 700; margin: 12px 0 6px; }
.markdown-body h1 { font-size: 18px; }
.markdown-body h2 { font-size: 16px; }
.markdown-body h3 { font-size: 14px; }
.markdown-body p { margin: 0 0 10px; }
.markdown-body ul, .markdown-body ol { margin: 0 0 10px; padding-left: 20px; }
.markdown-body li { margin: 2px 0; }
.markdown-body a { color: #0EA5E9; text-decoration: underline; }
.markdown-body code { background: #1A1A1A; border: 1px solid #2A2A2A; border-radius: 3px; padding: 1px 4px; font-family: 'IBM Plex Mono', monospace; font-size: 0.9em; }
.markdown-body blockquote { border-left: 3px solid #2A2A2A; margin: 0 0 10px; padding-left: 12px; color: #A3A3A3; }

/* ── Realistic rack chrome (rails, screw holes, HP ruler) — read-only shows ── */
.rack-body { position: relative; padding: 7px 0; border-radius: 4px; background-color: #161616; }

/* Brushed-metal rails top & bottom, with screw holes punched every 1 HP. The
   holes are a single repeating radial-gradient, not one element per screw. */
.rack-rail {
  position: relative;
  height: 7px;
  background:
    radial-gradient(circle at calc(var(--hp-px) / 2) 50%, #0b0b0b 0 1.1px, transparent 1.4px) repeat-x,
    linear-gradient(180deg, #3d3d3d 0%, #262626 45%, #1a1a1a 100%);
  background-size: var(--hp-px) 100%, auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), inset 0 -1px 0 rgba(0,0,0,.6);
}
.rack-rail--top { border-radius: 3px 3px 0 0; margin-bottom: 2px; }
.rack-rail--bottom { border-radius: 0 0 3px 3px; margin-top: 2px; }

/* Aluminium HP ruler. */
.rack-ruler { background: linear-gradient(180deg, #2a2a2a, #202020); border-radius: 3px 3px 0 0; overflow: hidden; margin-bottom: 2px; }
.rack-ruler-tick { position: absolute; top: 0; width: 1px; height: 6px; background: #4a4a4a; }
.rack-ruler-tick--major { height: 11px; background: #6b7f88; }
.rack-ruler-num { position: absolute; bottom: 1px; transform: translateX(2px); font-family: 'IBM Plex Mono', monospace; font-size: 9px; color: #8a9aa0; }

/* Module link + hover "View ↗" overlay (show rack only). */
.rack-module-link { cursor: pointer; }
.rack-module-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  background: rgba(13,13,13,.55); border: 1.5px solid #0EA5E9; border-radius: 4px;
  box-shadow: 0 0 12px rgba(14,165,233,.35);
  opacity: 0; transition: opacity 120ms ease; pointer-events: none;
}
.rack-module-link:hover .rack-module-overlay,
.rack-module-link:focus-visible .rack-module-overlay { opacity: 1; }
.rack-module-overlay-label { font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 700; color: #0EA5E9; }
.rack-module-overlay-name { font-family: 'IBM Plex Mono', monospace; font-size: 9px; color: #E5E5E5; text-align: center; padding: 0 4px; }

/* Read-only rack/patch shows: components are not draggable, so no move cursor.
   Overrides the editor's `.placed-component { cursor: move }` by specificity. */
.rack-body .placed-component,
.rack-body .placed-component * { cursor: default; }

/* Read-only module designer (module show): components are inert → default cursor. */
[data-module-designer-readonly-value="true"] .placed-component,
[data-module-designer-readonly-value="true"] .placed-component * { cursor: default; }

/* Knob/slider ViewComponents set `cursor:grab` inline for editor dragging; in a
   read-only show that drag is disabled, so force the default cursor. Scoped
   !important is required to beat the inline style, and only applies in shows. */
.rack-body .placed-component svg,
[data-module-designer-readonly-value="true"] .placed-component svg { cursor: default !important; }

/* ── Module show: two-column layout (panel + body) ─────────────────────────── */
.module-show-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}
.module-show-grid--single { grid-template-columns: minmax(0, 1fr); }
.module-show-panel { position: sticky; top: 24px; }
.module-show-grid--single .module-show-panel { position: static; max-width: 520px; }
@media (max-width: 768px) {
  .module-show-grid { grid-template-columns: 1fr; gap: 24px; }
  .module-show-panel { position: static; max-width: 240px; }
}

/* ── Demo thumbnails grid ──────────────────────────────────────────────────── */
.demo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.demo-tile {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9;
  padding: 0; border: 1px solid #2A2A2A; border-radius: 6px; overflow: hidden;
  background: #161616; cursor: pointer; transition: border-color 120ms ease;
}
.demo-tile:hover, .demo-tile:focus-visible { border-color: #0EA5E9; }
.demo-tile-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.demo-tile-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; letter-spacing: 0.1em; color: #8a8a8a;
}
.demo-tile-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.demo-tile-figure { margin: 0; }
.demo-tile-caption {
  margin-top: 6px; color: #A3A3A3; font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Demo lightbox ─────────────────────────────────────────────────────────── */
.demo-lightbox-overlay {
  position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center;
  padding: 24px; background: rgba(0,0,0,.8);
}
.demo-lightbox-overlay.is-open { display: flex; }
.demo-lightbox-dialog { width: 100%; max-width: 900px; background: #0D0D0D; border: 1px solid #2A2A2A; border-radius: 8px; overflow: hidden; }
.demo-lightbox-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid #2A2A2A; }
.demo-lightbox-title { font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: #E5E5E5; }
.demo-lightbox-close { background: transparent; border: none; color: #A3A3A3; font-size: 16px; cursor: pointer; line-height: 1; }
.demo-lightbox-close:hover { color: #FAFAFA; }
.demo-lightbox-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; }
.demo-lightbox-frame--audio { aspect-ratio: auto; height: 166px; }
.demo-lightbox-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.demo-lightbox-frame--audio iframe { position: static; height: 166px; }

/* Module show — header & body text (classes instead of inline styles). */
.module-show { background-color: #0D0D0D; color: #E5E5E5; }
.module-show-inner { max-width: 1080px; margin: 0 auto; padding: 24px 16px; }
.module-show-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; gap: 16px; }
.module-show-name { font-family: 'IBM Plex Mono', monospace; color: #FAFAFA; font-size: 22px; }
.module-show-subtitle { color: #A3A3A3; font-size: 14px; margin-top: 2px; }
.module-show-meta { color: #737373; font-size: 13px; }
.module-show-edit {
  background: #0EA5E9; color: #0D0D0D; border-radius: 4px; padding: 8px 16px;
  text-decoration: none; font-family: 'IBM Plex Mono', monospace; white-space: nowrap;
}
.module-show-h2 { font-family: 'IBM Plex Mono', monospace; color: #E5E5E5; font-size: 14px; text-transform: uppercase; letter-spacing: 0.12em; margin: 0; }
.module-show-desc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.module-show-fallback-badge { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: #FACC15; background: #2A2314; border: 1px solid #b45309; border-radius: 4px; padding: 2px 8px; }
.module-show-desc { color: #C8C8C8; font-size: 14px; line-height: 1.65; max-width: 68ch; }
.module-show-manufacturer { margin-top: 16px; }
.module-show-link { color: #0EA5E9; font-family: 'IBM Plex Mono', monospace; font-size: 13px; text-decoration: none; }
.module-show-demos { margin-top: 32px; }
.demo-link { color: #0EA5E9; font-family: 'IBM Plex Mono', monospace; font-size: 13px; text-decoration: none; word-break: break-all; }

/* ── Shared app modal (module show opened from a rack via turbo-frame) ──────── */
/* The overlay never scrolls the page: it centres a height-capped dialog whose
   OWN content scrolls when it overflows. */
.app-modal-overlay {
  position: fixed; inset: 0; z-index: 90; display: none;
  align-items: center; justify-content: center; padding: 24px 16px;
  background: rgba(0,0,0,.78);
}
.app-modal-overlay.is-open { display: flex; }
.app-modal-dialog {
  position: relative; width: 100%; max-width: 1120px;
  max-height: calc(100vh - 48px); overflow: hidden;
  display: flex; flex-direction: column;
  background: #0D0D0D; border: 1px solid #2A2A2A; border-radius: 10px;
}
.app-modal-content { overflow-y: auto; }
.app-modal-close {
  position: absolute; top: 12px; right: 14px; z-index: 2;
  background: transparent; border: none; color: #A3A3A3; font-size: 18px; cursor: pointer; line-height: 1;
}
.app-modal-close:hover { color: #FAFAFA; }
