/* PatternCube Motif Library — inherits the theme's fonts and accent colour. */
.pcml, .pcml-dialog {
  --pcml-accent: var(--ast-global-color-0, #1F5C8B);
  --pcml-text: var(--ast-global-color-3, #3a3a3a);
  --pcml-line: #e3e6ea;
  --pcml-soft: #f6f7f9;
  --pcml-radius: 8px;
  --pcml-checker: repeating-conic-gradient(#eef0f3 0 25%, #fff 0 50%) 0 0 / 16px 16px;
  color: var(--pcml-text);
  font: inherit;
}
.pcml *, .pcml-dialog * { box-sizing: border-box; }
.pcml { margin: 0 0 2.5em; }
.pcml button, .pcml-dialog button, .pcml input, .pcml-dialog input, .pcml-dialog select { font: inherit; color: inherit; }

/* toolbar */
.pcml-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; }
.pcml input.pcml-search {
  flex: 1 1 260px; min-height: 44px; padding: 10px 14px; border: 1px solid var(--pcml-line);
  border-radius: 999px; background: #fff; font-size: 1rem; outline: none;
}
.pcml input.pcml-search:focus { border-color: var(--pcml-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pcml-accent) 18%, transparent); }
.pcml-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.pcml-cats button, .pcml-seg button {
  min-height: 36px; padding: 6px 14px; border: 1px solid var(--pcml-line); border-radius: 999px;
  background: #fff; cursor: pointer; font-size: .92rem; line-height: 1.2;
}
.pcml-cats button:hover, .pcml-seg button:hover { border-color: #c9ced5; }
.pcml-cats button[aria-pressed="true"], .pcml-seg button[aria-pressed="true"] {
  background: var(--pcml-accent); border-color: var(--pcml-accent); color: #fff;
}

/* controls */
.pcml-controls {
  display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: flex-start;
  padding: 14px 16px; border: 1px solid var(--pcml-line); border-radius: var(--pcml-radius); background: #fff; margin-bottom: 18px;
}
.pcml-field { display: flex; flex-direction: column; gap: 6px; }
.pcml-label { font-size: .8rem; letter-spacing: .02em; color: #6b7280; }
.pcml-swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pcml-swatch {
  position: relative; width: 28px; height: 28px; padding: 0; border-radius: 50%;
  border: 1px solid rgba(0,0,0,.12); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.pcml-swatch[aria-pressed="true"], .pcml-swatch.is-on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--pcml-accent); }
.pcml-sw-none { background: var(--pcml-checker); }
.pcml-sw-white { background: #fff; }
.pcml-sw-tint { background: color-mix(in srgb, var(--pcml-colour, #1F5C8B) 14%, #fff); }
.pcml-custom { background: #fff; color: #6b7280; overflow: hidden; }
.pcml-custom.is-on { color: #fff; }
.pcml-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }
.pcml input.pcml-hex, .pcml-dialog input.pcml-hex {
  width: 100px; min-height: 32px; height: auto; padding: 4px 8px; margin: 0 0 0 4px; line-height: 1.4; border: 1px solid var(--pcml-line); border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; text-transform: uppercase;
}
.pcml-seg { display: flex; gap: 6px; }

/* grid */
.pcml-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 12px; }
.pcml-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 10px 10px;
  border: 1px solid var(--pcml-line); border-radius: var(--pcml-radius); background: var(--pcml-bg, #fff);
  cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.pcml-bg-none .pcml-tile { background: #fff; }
.pcml-tile:hover, .pcml-tile:focus-visible { border-color: var(--pcml-accent); box-shadow: 0 4px 14px rgba(0,0,0,.06); outline: none; transform: translateY(-1px); }
.pcml-tile svg { width: 64px; height: 64px; color: var(--pcml-colour); overflow: visible; }
.pcml-g { fill: currentColor; }
.pcml-is-outline .pcml-g { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.pcml-name { font-size: .78rem; line-height: 1.25; text-align: center; color: #6b7280; }
.pcml-tile[hidden] { display: none; }
.pcml-empty { margin: 18px 0; color: #6b7280; }
.pcml-empty[hidden] { display: none; }

.pcml-foot { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-top: 18px; }
.pcml-count { font-size: .88rem; color: #6b7280; }
.pcml-btn {
  min-height: 42px; padding: 9px 18px; border-radius: 999px; border: 1px solid var(--pcml-line); background: #fff;
  cursor: pointer; font-size: .95rem; font-weight: 500;
}
.pcml-btn span { color: #6b7280; font-weight: 400; }
.pcml-btn:hover { border-color: var(--pcml-accent); }
.pcml-btn:disabled { opacity: .55; cursor: default; }
.pcml-primary { background: var(--pcml-accent); border-color: var(--pcml-accent); color: #fff !important; }
.pcml-primary:hover { filter: brightness(1.08); }

/* dialog */
.pcml-dialog {
  width: min(880px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 0;
  border-radius: 12px; background: #fff; box-shadow: 0 20px 60px rgba(0,0,0,.18); overflow: auto;
}
.pcml-dialog::backdrop { background: rgba(20, 24, 31, .45); }
.pcml-d-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--pcml-line); }
.pcml-d-title { margin: 0; font-size: 1.15rem; }
.pcml-close { width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.pcml-close:hover { background: var(--pcml-soft); }
.pcml-d-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; padding: 18px; }
.pcml-stage {
  aspect-ratio: 1; border: 1px solid var(--pcml-line); border-radius: var(--pcml-radius);
  display: flex; align-items: center; justify-content: center; overflow: hidden; background: #fff;
}
.pcml-dialog.pcml-bg-none .pcml-stage { background: var(--pcml-checker); }
.pcml-stage svg { width: 100%; height: 100%; }
.pcml-side { display: flex; flex-direction: column; gap: 16px; }
.pcml-rot { display: flex; align-items: center; gap: 8px; }
.pcml-rot input[type=range] { flex: 1; accent-color: var(--pcml-accent); }
.pcml-rot-out { min-width: 38px; font-size: .85rem; color: #6b7280; text-align: right; }
.pcml-icon-btn { width: 36px; height: 36px; border: 1px solid var(--pcml-line); border-radius: 8px; background: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.pcml-icon-btn[aria-pressed="true"] { border-color: var(--pcml-accent); color: var(--pcml-accent); }
.pcml-link { border: 0; background: none; padding: 6px 4px; cursor: pointer; color: var(--pcml-accent) !important; font-size: .9rem; }
.pcml-link:hover { text-decoration: underline; }
.pcml-dialog select { min-height: 38px; padding: 6px 10px; border: 1px solid var(--pcml-line); border-radius: 6px; background: #fff; max-width: 200px; }
.pcml-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pcml-nav { display: flex; justify-content: space-between; padding: 4px 14px 14px; }

@media (max-width: 720px) {
  .pcml-d-body { grid-template-columns: 1fr; }
  .pcml-stage { max-width: 360px; width: 100%; margin: 0 auto; }
  .pcml-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .pcml-tile svg { width: 52px; height: 52px; }
  .pcml-controls { gap: 14px 20px; }
  .pcml-actions { position: sticky; bottom: 0; background: #fff; padding: 10px 0; margin-bottom: -10px; border-top: 1px solid var(--pcml-line); }
  .pcml-actions .pcml-btn { flex: 1 1 auto; }
}

/* page sections below the tool */
.pcml-page h2 { margin-top: 1.8em; }
.pcml-steps { padding-left: 1.3em; }
.pcml-steps li { margin-bottom: .5em; }
.pcml-faq details { border-bottom: 1px solid var(--pcml-line); padding: 12px 0; }
.pcml-faq summary { cursor: pointer; font-weight: 600; }
.pcml-faq details p { margin: .6em 0 0; }
.pcml-share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 2em 0 1em; }
.pcml-share-label { font-size: .85rem; color: #6b7280; margin-right: 4px; }
.pcml-share a, .pcml-share button {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--pcml-line); background: #fff; color: #4b5563;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; text-decoration: none;
}
.pcml-share a:hover, .pcml-share button:hover { border-color: var(--pcml-accent); color: var(--pcml-accent); }
.pcml-share svg { width: 17px; height: 17px; }

/* -------------------------------------------------------------------------
 * 1.2.0 — firm button styles. The theme gives every button wide padding and a
 * dark fill on hover and focus; these rules keep the library's own look.
 * ---------------------------------------------------------------------- */
.pcml-dialog .pcml-close,
.pcml-dialog .pcml-close:hover,
.pcml-dialog .pcml-close:focus,
.pcml-dialog .pcml-close:active {
  width: 40px; height: 40px; min-width: 40px; padding: 0; margin: 0;
  border: 1px solid var(--pcml-line); border-radius: 50%;
  background: #fff; color: #4b5563; box-shadow: none;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.pcml-dialog .pcml-close:hover { background: var(--pcml-soft); border-color: #cfd4da; color: #111827; }
.pcml-dialog .pcml-close:focus-visible { outline: 2px solid var(--pcml-accent); outline-offset: 2px; }
.pcml-dialog .pcml-close svg { width: 18px; height: 18px; flex: 0 0 auto; display: block; }

.pcml-dialog .pcml-icon-btn,
.pcml-dialog .pcml-icon-btn:hover,
.pcml-dialog .pcml-icon-btn:focus {
  width: 40px; height: 40px; min-width: 40px; padding: 0; margin: 0;
  border: 1px solid var(--pcml-line); border-radius: 8px; background: #fff; color: #4b5563; box-shadow: none;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.pcml-dialog .pcml-icon-btn:hover { border-color: #cfd4da; color: #111827; background: var(--pcml-soft); }
.pcml-dialog .pcml-icon-btn[aria-pressed="true"] { border-color: var(--pcml-accent); color: var(--pcml-accent); background: #fff; }
.pcml-dialog .pcml-icon-btn svg { width: 18px; height: 18px; flex: 0 0 auto; display: block; }
.pcml-dialog .pcml-rot input[type=range] { flex: 1 1 auto; min-width: 90px; width: auto; padding: 0; margin: 0; background: none; border: 0; }
.pcml-dialog .pcml-rot { flex-wrap: wrap; }

/* Plain text buttons (Previous, Next, Reset, Copy SVG code) never take a fill. */
.pcml-dialog .pcml-link,
.pcml-dialog .pcml-link:hover,
.pcml-dialog .pcml-link:focus {
  background: none; border: 0; box-shadow: none; padding: 6px 4px; margin: 0; min-height: 0;
  color: var(--pcml-accent); font-size: .92rem; font-weight: 500; text-decoration: none;
}
.pcml-dialog .pcml-link:hover { text-decoration: underline; }

/* Download buttons keep their colours on hover and focus. */
.pcml .pcml-btn, .pcml .pcml-btn:hover, .pcml .pcml-btn:focus,
.pcml-dialog .pcml-btn, .pcml-dialog .pcml-btn:hover, .pcml-dialog .pcml-btn:focus {
  min-height: 44px; padding: 10px 20px; margin: 0; border-radius: 999px; border: 1px solid var(--pcml-line);
  background: #fff; color: var(--pcml-text); box-shadow: none; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1.2;
}
.pcml .pcml-btn:hover, .pcml-dialog .pcml-btn:hover { border-color: var(--pcml-accent); color: var(--pcml-accent); }
.pcml-dialog .pcml-primary, .pcml-dialog .pcml-primary:hover, .pcml-dialog .pcml-primary:focus {
  background: var(--pcml-accent); border-color: var(--pcml-accent); color: #fff;
}
.pcml-dialog .pcml-primary:hover { filter: brightness(1.08); color: #fff; }
.pcml .pcml-btn:focus-visible, .pcml-dialog .pcml-btn:focus-visible { outline: 2px solid var(--pcml-accent); outline-offset: 2px; }

/* Group and style buttons: same idea. */
.pcml .pcml-cats button:hover, .pcml .pcml-cats button:focus,
.pcml .pcml-seg button:hover, .pcml .pcml-seg button:focus,
.pcml-dialog .pcml-seg button:hover, .pcml-dialog .pcml-seg button:focus { background: #fff; color: var(--pcml-text); }
.pcml .pcml-cats button[aria-pressed="true"], .pcml .pcml-seg button[aria-pressed="true"],
.pcml-dialog .pcml-seg button[aria-pressed="true"] { background: var(--pcml-accent); border-color: var(--pcml-accent); color: #fff; }
.pcml .pcml-cats button, .pcml .pcml-seg button, .pcml-dialog .pcml-seg button { padding: 6px 14px; }
.pcml .pcml-swatch, .pcml-dialog .pcml-swatch { padding: 0; }
.pcml .pcml-tile, .pcml .pcml-tile:hover, .pcml .pcml-tile:focus { padding: 14px 10px 10px; background: var(--pcml-bg, #fff); color: inherit; }
.pcml.pcml-bg-none .pcml-tile { background: #fff; }

.pcml-more { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin-top: -6px; }
.pcml-dialog .pcml-actions .pcml-btn { flex: 1 1 0; }
.pcml-dialog .pcml-d-head { gap: 12px; }

/* Share buttons come from the Pattern Studio, so they match the tool pages. */
.pcml-page .pcstudio-sharebar { margin: 2em 0 1em; }

/* -------------------------------------------------------------------------
 * Phones
 * ---------------------------------------------------------------------- */
@media (max-width: 720px) {
  /* Groups in one row that scrolls sideways, so the motifs show sooner. */
  .pcml .pcml-cats { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; width: 100%; padding-bottom: 2px; }
  .pcml .pcml-cats::-webkit-scrollbar { display: none; }
  .pcml .pcml-cats button { flex: 0 0 auto; }
  .pcml .pcml-controls { padding: 12px; gap: 12px 18px; }
  .pcml .pcml-swatch, .pcml-dialog .pcml-swatch { width: 32px; height: 32px; }
  .pcml-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pcml-foot { flex-direction: column; align-items: stretch; }
  .pcml-foot .pcml-btn { width: 100%; }

  /* The motif window fills the screen, with the close button always in view. */
  .pcml-dialog { width: 100vw; max-width: 100vw; height: 100%; max-height: 100%; margin: 0; border-radius: 0; }
  .pcml-dialog .pcml-d-head { position: sticky; top: 0; z-index: 2; background: #fff; padding: 10px 14px; }
  .pcml-dialog .pcml-d-body { padding: 14px; gap: 16px; }
  .pcml-dialog .pcml-stage { max-width: 240px; }
  .pcml-dialog .pcml-side { gap: 14px; }
  .pcml-dialog .pcml-actions {
    position: sticky; bottom: 0; z-index: 2; background: #fff; margin: 0 -14px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--pcml-line); flex-wrap: nowrap;
  }
  .pcml-dialog .pcml-actions .pcml-btn { min-height: 46px; padding: 10px 12px; }
  .pcml-dialog .pcml-nav { padding: 6px 14px 14px; }
}
.pcml .pcml-btn, .pcml-dialog .pcml-btn { white-space: nowrap; }
@media (min-width: 721px) { .pcml-dialog .pcml-d-body { grid-template-columns: minmax(0, 1fr) 340px; } }

.pcml-foot-links { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 720px) { .pcml-foot-links { flex-direction: column; } .pcml-foot-links .pcml-btn { width: 100%; } }
