/*
 * Eurorack Modules Plugin — Single Module Page (§8.2)
 * CSS extracted from module-single-mockup.html.
 * Scoped to .erm-page; tokens defined in erm-tokens.css.
 */

/* ============================================================
   SCOPED RESET
   ============================================================ */
.erm-page *,
.erm-page *::before,
.erm-page *::after {
  box-sizing: border-box;
}

/* ============================================================
   PROSE DEFAULTS — restore sensible margins for text content
   ============================================================ */
.erm-page p,
.erm-page ul,
.erm-page ol {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.erm-page p:last-child,
.erm-page ul:last-child,
.erm-page ol:last-child {
  margin-bottom: 0;
}

.erm-page ul,
.erm-page ol {
  padding-left: 1.5rem;
}

.erm-page li {
  margin-bottom: 0.25rem;
}

.erm-page li:last-child {
  margin-bottom: 0;
}

/* ============================================================
   PAGE LAYOUT
   ============================================================ */
.erm-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* ============================================================
   BREADCRUMB
   ============================================================ */
.erm-breadcrumb {
  font-size: 12px;
  color: var(--erm-color-text-muted);
  margin-bottom: 1.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.erm-breadcrumb a {
  color: var(--erm-color-text-secondary);
  text-decoration: none;
}

.erm-breadcrumb a:hover { color: var(--erm-color-accent-bg); }

.erm-breadcrumb span {
  margin: 0 6px;
  opacity: 0.5;
}

/* ============================================================
   MODULE HEADER
   ============================================================ */
.erm-module-title {
  margin-bottom: 0.75rem;
}

.erm-badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 2rem;
}

.erm-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.6;
}

.erm-badge-built   { background: var(--erm-badge-built-bg);   color: var(--erm-badge-built-text); }
.erm-badge-dev     { background: var(--erm-badge-dev-bg);     color: var(--erm-badge-dev-text); }
.erm-badge-concept { background: var(--erm-badge-concept-bg); color: var(--erm-badge-concept-text); }

.erm-badge-type {
  background: var(--erm-color-surface);
  color: var(--erm-color-text-secondary);
}

/* ============================================================
   TWO-COLUMN ABOVE THE FOLD
   --erm-module-hp is set inline from PHP (the module's HP value).
   1HP = 15.81px on screen → height is always 15.81 × 25.295 ≈ 400px.
   Modules >= 26HP would exceed half the page width, so they get
   .erm-above-fold--wide which stacks specs above the panel photo.
   ============================================================ */
.erm-above-fold {
  display: grid;
  grid-template-columns: calc(var(--erm-module-hp, 12) * 15.81px) 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
  align-items: start;
}

/* Wide module: specs above, photo full-width below */
.erm-above-fold--wide {
  grid-template-columns: 1fr;
}

.erm-above-fold--wide > div:first-child {
  order: 2;
}

/* Small screens: always stack, specs first */
@media (max-width: 640px) {
  .erm-above-fold { grid-template-columns: 1fr; }
  .erm-above-fold > div:first-child { order: 2; }
}

/* ============================================================
   PANEL PHOTO
   ============================================================ */
.erm-panel-photo {
  width: 100%;
  /* Eurorack 3U: height = HP × 25.295 → aspect-ratio = HP : 25.295.
     Fallback 12 matches the 12px/HP grid column default. */
  aspect-ratio: var(--erm-module-hp, 12) / 25.295;
  border-radius: 8px;
  border: 1px solid var(--erm-color-border);
  overflow: hidden;
  background: var(--erm-color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.erm-panel-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.erm-panel-photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--erm-color-text-muted);
  padding: 1rem;
  text-align: center;
}

.erm-panel-photo-placeholder svg { opacity: 0.3; }
.erm-panel-photo-placeholder span { font-size: 11px; }

/* ============================================================
   SPECS COLUMN
   ============================================================ */
.erm-specs-col { display: flex; flex-direction: column; gap: 1.5rem; }

.erm-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--erm-color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.6rem;
}

.erm-description {
  font-size: 15px;
  line-height: 1.75;
  color: var(--erm-color-text-secondary);
}

/* ============================================================
   SPEC METRIC CARDS
   ============================================================ */
.erm-spec-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.erm-spec-card {
  background: var(--erm-color-surface);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.erm-spec-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--erm-color-text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.erm-spec-unit {
  font-size: 12px;
  color: var(--erm-color-text-muted);
  margin-left: 2px;
}

.erm-spec-label {
  font-size: 12px;
  color: var(--erm-color-text-secondary);
  margin-top: 3px;
}

/* ============================================================
   POWER DRAW
   ============================================================ */
.erm-power-chips { display: flex; gap: 8px; }

.erm-power-chip {
  flex: 1;
  background: var(--erm-color-surface);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  text-align: center;
}

.erm-power-val {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.erm-power-val-pos { color: var(--erm-dot-built); }
.erm-power-val-neg { color: #e07040; }
.erm-power-val-5v  { color: var(--erm-color-accent-bg); }
.erm-power-unit    { font-size: 11px; color: var(--erm-color-text-muted); }
.erm-power-lbl     { font-size: 11px; color: var(--erm-color-text-muted); margin-top: 2px; }

/* ============================================================
   FULL-WIDTH SECTIONS
   ============================================================ */
.erm-divider {
  border: none;
  border-top: 1px solid var(--erm-color-border);
  margin: 2rem 0;
}

.erm-section { margin-bottom: 2rem; }

/* ============================================================
   I/O TABLE
   ============================================================ */
.erm-io-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.erm-io-table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--erm-color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 0;
  border-bottom: 1px solid var(--erm-color-border);
  text-align: left;
}

.erm-io-table td {
  padding: 8px 0;
  border-bottom: 1px solid var(--erm-color-border);
  color: var(--erm-color-text-secondary);
  vertical-align: middle;
}

.erm-io-table tr:last-child td { border-bottom: none; }

.erm-io-dir-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.erm-io-in {
  background: var(--erm-color-accent-subtle);
  color: var(--erm-color-accent-bg);
}

.erm-io-out {
  background: var(--erm-badge-built-bg);
  color: var(--erm-badge-built-text);
}

.erm-io-name   { font-weight: 500; color: var(--erm-color-text-primary); min-width: 80px; }
.erm-io-signal { min-width: 120px; }
.erm-io-notes  { color: var(--erm-color-text-muted); font-size: 13px; }

/* ============================================================
   BUILD NOTES
   ============================================================ */
.erm-build-notes {
  font-size: 15px;
  line-height: 1.8;
  color: var(--erm-color-text-secondary);
}

.erm-build-notes p { margin-bottom: 0.75rem; }
.erm-build-notes p:last-child { margin-bottom: 0; }

.erm-build-notes code {
  background: var(--erm-color-surface);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 13px;
  color: var(--erm-color-text-primary);
}

/* ============================================================
   BUILD FILES / DOWNLOADS
   ============================================================ */
.erm-downloads {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.erm-dl-card {
  border: 1px solid var(--erm-color-border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  background: var(--erm-color-surface-raised);
  transition: background 0.15s, border-color 0.15s;
}

.erm-dl-card:hover {
  background: var(--erm-color-surface);
  border-color: var(--erm-color-border-strong);
}

.erm-dl-icon {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  background: var(--erm-color-accent-subtle);
  color: var(--erm-color-accent-bg);
}

.erm-dl-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--erm-color-text-primary);
  line-height: 1.3;
}

.erm-dl-meta {
  font-size: 11px;
  color: var(--erm-color-text-muted);
  margin-top: 2px;
}

/* ============================================================
   BUILD GALLERY
   ============================================================ */
.erm-gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (max-width: 600px) {
  .erm-gallery { grid-template-columns: repeat(2, 1fr); }
}

.erm-gallery-item {
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  background: var(--erm-color-surface);
  border: 1px solid var(--erm-color-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.erm-gallery-item:hover .erm-gallery-overlay {
  opacity: 1;
}

.erm-gallery-placeholder {
  font-size: 11px;
  color: var(--erm-color-text-muted);
  text-align: center;
  padding: 6px;
}

.erm-gallery-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.erm-gallery-overlay-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
}
