/* =========================================
   polyrhythmgeneratorstyle.css
   Builds on shared/global.css
   ========================================= */

/* ── Full-height layout (no scroll) ── */
html, body { height: 100%; overflow: hidden; }

.poly-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  touch-action: none;
}

/* ── Game title ── */
.gameMainTitle {
  text-align: center;
  font-size: 26px;
  font-weight: 900;
  color: var(--text-main);
  margin: 0;
  padding-top: 4px;
  padding-bottom: 0;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Controls panel ── */
.controlsPanel {
  background: var(--bg-surface);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 12px;
  padding-top: 8px;
  box-shadow: var(--shadow-soft);
  flex-shrink: 0;
}
body.light-theme .controlsPanel { border-color: rgba(0,0,0,0.06); }

.actionsGrid {
  display: flex;
  gap: 8px;
  width: 100%;
}
.actionsGrid .icon-btn      { flex: 0 0 52px; height: 52px; padding: 0; font-size: 22px; }
.actionsGrid .flex-text-btn { flex: 1 1 0; padding: 0 4px; font-size: 14px; white-space: nowrap; }

/* Play button turns red when active */
#btn-play.playing {
  background: var(--danger) !important;
  border-color: var(--danger-shadow) !important;
  box-shadow: 0 4px 0 var(--danger-shadow) !important;
  color: #fff !important;
}

/* ── Stacked layout ── */
.poly-stack {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 0 4px;
}

/* ── Shared tile base ── */
.poly-tile {
  background: var(--bg-surface);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
body.light-theme .poly-tile { border-color: rgba(0,0,0,0.06); }

/* ── Canvas tile ── */
.poly-canvas-tile {
  flex: 1 1 220px;   /* grows/shrinks freely; canvas absorbs height pressure first */
  min-height: 110px;
  display: flex;
  flex-direction: row;
}

/* Left portion — canvas */
.poly-canvas-area {
  flex: 1 1 0;
  min-width: 0;
  position: relative;
}

#visuals {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

/* Right portion — BPM + ratio */
#bpm-container {
  flex: 0 0 33%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  border-left: 2px solid rgba(255,255,255,0.07);
  gap: 2px;
}
body.light-theme #bpm-container { border-left-color: rgba(0,0,0,0.07); }

#bpm-number {
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 900;
  color: var(--text-main);
  line-height: 1;
}

/* Inline BPM edit input */
.poly-bpm-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--accent);
  color: var(--text-main);
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 900;
  text-align: center;
  outline: none;
  padding: 0;
  line-height: 1;
  -moz-appearance: textfield;
}
.poly-bpm-input::-webkit-outer-spin-button,
.poly-bpm-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

#bpm-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-top: 3px;
}

/* Polyrhythm ratio display (e.g. "3/4") */
#poly-ratio {
  font-size: clamp(0.85rem, 3vw, 1.05rem);
  font-weight: 900;
  color: var(--text-main);
  text-align: center;
  letter-spacing: 1px;
  margin-top: 6px;
  word-break: break-all;
  line-height: 1.3;
  max-width: 100%;
}

.poly-bpm-hint {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
  line-height: 1.4;
  opacity: 0.7;
}

/* ── Beat tiles tile ── */
.poly-ctrl-tile {
  flex: 0 0 auto;   /* size to content; doesn't shrink */
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.poly-beat-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
  flex-shrink: 0;
}

/* 6-column grid → 2 rows of 6 */
.poly-beat-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

/* Individual beat tile */
.beat-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 2px solid var(--bg-elevated);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s;
  min-height: 40px;
}

.beat-tile:active {
  transform: scale(0.93);
}

/* Active state — border/text/bg set dynamically via JS */
.beat-tile--active {
  /* Base overrides — colours applied inline by JS */
}

/* ── Inline settings (inside beat tile) ── */
.poly-inline-settings {
  display: flex;
  flex-direction: row;
  gap: 6px;
  border-top: 1px solid var(--bg-elevated);
  padding-top: 8px;
  margin-top: 2px;
}
.poly-inline-settings .poly-setting-row { flex: 1 1 0; }

/* ── Settings modal body ── */
.poly-settings-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 4px;
}

.poly-setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.poly-setting-info {
  flex: 1;
  min-width: 0;
}

.poly-setting-name {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
}

.poly-setting-desc {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.4;
}

/* ── Toggle button ── */
.poly-toggle {
  flex-shrink: 0;
  min-width: 52px;
  height: 34px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.5px;
  cursor: pointer;
  border: 2px solid;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  padding: 0 8px;
}

.poly-toggle--on {
  background: var(--info-teal);
  border-color: var(--info-shadow);
  color: #fff;
}

.poly-toggle--off {
  background: var(--bg-base);
  border-color: var(--bg-elevated);
  color: var(--text-muted);
}

.poly-toggle--locked {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
