/* PatternCube Motif Canvas — calm, white, and the theme's own fonts and accent colour. */
.pcmc {
  --pcmc-accent: var(--ast-global-color-0, #1F6B4F);
  --pcmc-text: var(--ast-global-color-3, #3a3a3a);
  --pcmc-line: #e3e6ea;
  --pcmc-soft: #f6f7f9;
  --pcmc-checker: repeating-conic-gradient(#eef0f3 0 25%, #fff 0 50%) 0 0 / 18px 18px;
  display: grid; grid-template-columns: 250px minmax(0, 1fr) 270px; gap: 20px; align-items: start;
  color: var(--pcmc-text); font: inherit; margin: 0 0 2.5em;
}
.pcmc * { box-sizing: border-box; }
.pcmc button, .pcmc input, .pcmc select { font: inherit; }
.pcmc-h { font-size: 1rem; margin: 0 0 10px; font-weight: 600; }
.pcmc-picker, .pcmc-panel > div { border: 1px solid var(--pcmc-line); border-radius: 10px; background: #fff; padding: 14px; }
.pcmc-panel { display: flex; flex-direction: column; gap: 14px; }
.pcmc-picker { position: sticky; top: 90px; max-height: calc(100vh - 110px); display: flex; flex-direction: column; }

/* Picker */
.pcmc input.pcmc-search {
  width: 100%; min-height: 42px; padding: 8px 14px; margin: 0 0 10px; border: 1px solid var(--pcmc-line);
  border-radius: 999px; background: #fff; font-size: .95rem;
}
.pcmc-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.pcmc-chips::-webkit-scrollbar { display: none; }
.pcmc .pcmc-chips button, .pcmc .pcmc-chips button:hover, .pcmc .pcmc-chips button:focus {
  flex: 0 0 auto; min-height: 34px; padding: 5px 12px; margin: 0; border: 1px solid var(--pcmc-line); border-radius: 999px;
  background: #fff; color: var(--pcmc-text); font-size: .85rem; line-height: 1.2; box-shadow: none;
}
.pcmc .pcmc-chips button[aria-pressed="true"] { background: var(--pcmc-accent); border-color: var(--pcmc-accent); color: #fff; }
.pcmc-motifs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; overflow-y: auto; min-height: 0; flex: 1 1 auto; padding: 2px; }
.pcmc .pcmc-motif, .pcmc .pcmc-motif:hover, .pcmc .pcmc-motif:focus {
  aspect-ratio: 1; padding: 6px; margin: 0; border: 1px solid var(--pcmc-line); border-radius: 8px; background: #fff;
  color: #2f3a45; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: none; min-height: 0;
}
.pcmc .pcmc-motif:hover { border-color: var(--pcmc-accent); color: var(--pcmc-accent); }
.pcmc .pcmc-motif[hidden] { display: none; }
.pcmc-motif svg { width: 100%; height: 100%; display: block; }
.pcmc-hint { font-size: .8rem; color: #6b7280; margin: 10px 0 0; }

/* Canvas */
.pcmc-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.pcmc select { min-height: 40px; padding: 6px 10px; border: 1px solid var(--pcmc-line); border-radius: 8px; background: #fff; color: var(--pcmc-text); max-width: 100%; }
.pcmc-bar .pcmc-shape { margin-right: auto; }
.pcmc-stage {
  position: relative; width: 100%; max-height: 78vh; margin: 0 auto; border: 1px solid var(--pcmc-line); border-radius: 10px;
  overflow: hidden; background: #fff; touch-action: none;
}
.pcmc-stage.pcmc-clear-bg { background: var(--pcmc-checker); }
.pcmc-svg { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-select: none; }
.pcmc-item { cursor: grab; }
.pcmc-item:active { cursor: grabbing; }
.pcmc-frame { stroke: var(--pcmc-accent); stroke-width: 1.5; stroke-dasharray: 6 4; pointer-events: none; }
.pcmc-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; padding: 20px; text-align: center; color: #6b7280; pointer-events: none; }
.pcmc-empty[hidden] { display: none; }
.pcmc-saved { font-size: .8rem; color: #6b7280; margin: 8px 0 0; }

/* Buttons: firm styles, so the theme's dark button fill never shows. */
.pcmc .pcmc-btn, .pcmc .pcmc-btn:hover, .pcmc .pcmc-btn:focus {
  min-height: 42px; padding: 8px 16px; margin: 0; border: 1px solid var(--pcmc-line); border-radius: 999px;
  background: #fff; color: var(--pcmc-text); font-size: .92rem; font-weight: 500; line-height: 1.2; white-space: nowrap;
  box-shadow: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.pcmc .pcmc-btn:hover { border-color: var(--pcmc-accent); color: var(--pcmc-accent); }
.pcmc .pcmc-btn:disabled { opacity: .5; cursor: default; border-color: var(--pcmc-line); color: var(--pcmc-text); }
.pcmc .pcmc-primary, .pcmc .pcmc-primary:hover, .pcmc .pcmc-primary:focus { background: var(--pcmc-accent); border-color: var(--pcmc-accent); color: #fff; }
.pcmc .pcmc-primary:hover { filter: brightness(1.08); color: #fff; }
.pcmc .pcmc-ghost { min-height: 38px; padding: 6px 12px; }
.pcmc .pcmc-btn:focus-visible, .pcmc .pcmc-icon:focus-visible, .pcmc .pcmc-sw:focus-visible { outline: 2px solid var(--pcmc-accent); outline-offset: 2px; }

/* Selected motif */
.pcmc-edit[hidden] { display: none; }
.pcmc-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.pcmc .pcmc-sw, .pcmc .pcmc-sw:hover, .pcmc .pcmc-sw:focus {
  position: relative; width: 32px; height: 32px; min-width: 32px; padding: 0; margin: 0; border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .14); cursor: pointer; box-shadow: none; display: inline-flex; align-items: center; justify-content: center;
}
.pcmc .pcmc-sw[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--pcmc-accent); }
.pcmc .pcmc-sw-none { background: var(--pcmc-checker); }
.pcmc .pcmc-sw-any { background: #fff; color: #6b7280; font-size: 1.1rem; overflow: hidden; }
.pcmc-sw-any input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.pcmc-range { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 10px; margin: 0 0 10px; font-size: .88rem; }
.pcmc-range input { width: 100%; accent-color: var(--pcmc-accent); margin: 0; padding: 0; border: 0; background: none; }
.pcmc-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.pcmc .pcmc-icon, .pcmc .pcmc-icon:hover, .pcmc .pcmc-icon:focus {
  width: 42px; height: 42px; min-width: 42px; padding: 0; margin: 0; border: 1px solid var(--pcmc-line); border-radius: 8px;
  background: #fff; color: #4b5563; box-shadow: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.pcmc .pcmc-icon:hover { border-color: #cfd4da; color: #111827; background: var(--pcmc-soft); }
.pcmc .pcmc-icon[aria-pressed="true"] { border-color: var(--pcmc-accent); color: var(--pcmc-accent); }
.pcmc-icon svg { width: 20px; height: 20px; display: block; flex: 0 0 auto; }

/* Palette and downloads */
.pcmc-pal select, .pcmc-dl select { width: 100%; margin-bottom: 10px; }
.pcmc-strip { display: flex; height: 26px; border-radius: 6px; overflow: hidden; margin-bottom: 10px; border: 1px solid var(--pcmc-line); }
.pcmc-strip span { flex: 1; }
.pcmc-pal .pcmc-btn { width: 100%; margin-bottom: 12px; }
.pcmc-label { display: block; font-size: .8rem; color: #6b7280; margin-bottom: 8px; }
.pcmc-row { display: flex; gap: 8px; }
.pcmc-row .pcmc-btn { flex: 1 1 0; }

/* Page sections under the tool */
.pcmc-page h2 { margin-top: 1.8em; }
.pcmc-page .pcmc-steps { padding-left: 1.3em; }
.pcmc-page .pcmc-steps li { margin-bottom: .5em; }
.pcmc-page .pcmc-faq details { border-bottom: 1px solid var(--pcmc-line, #e3e6ea); padding: 12px 0; }
.pcmc-page .pcmc-faq summary { cursor: pointer; font-weight: 600; }
.pcmc-page .pcmc-faq details p { margin: .6em 0 0; }

/* Tablets: motifs on the left, canvas and controls stacked on the right. */
@media (max-width: 1080px) {
  .pcmc { grid-template-columns: 240px minmax(0, 1fr); }
  .pcmc-panel { grid-column: 2; display: grid; grid-template-columns: 1fr 1fr; }
  .pcmc-panel > .pcmc-edit { grid-column: 1 / -1; }
}

/* Phones: canvas first, then the selected motif, then motifs to add, then colours and downloads. */
@media (max-width: 720px) {
  .pcmc { display: flex; flex-direction: column; gap: 14px; }
  .pcmc-stage-wrap { order: 1; width: 100%; }
  .pcmc-panel { order: 3; display: flex; width: 100%; }
  .pcmc-picker { order: 2; position: static; max-height: none; width: 100%; }
  .pcmc-panel > .pcmc-edit { order: -1; }
  .pcmc-stage { max-height: 62vh; }
  .pcmc-motifs { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 64px; grid-template-rows: 64px 64px; overflow-x: auto; overflow-y: hidden; }
  .pcmc-bar .pcmc-shape { flex: 1 1 100%; margin-right: 0; }
  .pcmc-bar .pcmc-ghost { flex: 1 1 0; }
}

/* Fixed sizes inside the motif list, so the tiles never squash. */
.pcmc .pcmc-h { margin: 0 0 10px; padding: 0; line-height: 1.3; }
.pcmc-picker > * { flex: 0 0 auto; }
.pcmc-picker > .pcmc-motifs { flex: 1 1 auto; }
.pcmc-motifs { grid-auto-rows: 52px; align-content: start; }
.pcmc .pcmc-motif, .pcmc .pcmc-motif:hover, .pcmc .pcmc-motif:focus { aspect-ratio: auto; height: 52px; }
.pcmc-row { flex-wrap: wrap; }
.pcmc .pcmc-row .pcmc-btn { padding: 8px 12px; min-width: 0; }
@media (max-width: 720px) {
  .pcmc-motifs { grid-auto-rows: 64px; }
  .pcmc .pcmc-motif, .pcmc .pcmc-motif:hover, .pcmc .pcmc-motif:focus { height: 64px; }
}
