/* MolComp ChemCanvas Bridge
   - Dashboard Tool Studio grid + embedded tool view
   - ModelHub ChemCanvas window sizing helpers
*/

:root{
  --mc-chemcanvas-thumb: url("/wp-content/plugins/chemcanvas/assets/img/chemcanvas-thumb.png");
}

/* -----------------------------
   Dashboard: Tool Studio view
------------------------------ */
.mcc-tools-wrap{ max-width:1100px; margin:0 auto; }

.mcc-tools-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
  flex-wrap:wrap;
}

.mcc-tools-title{ font-weight:950; font-size:18px; letter-spacing:-.01em; }
.mcc-tools-sub{ font-size:13px; opacity:.78; margin-top:4px; }

.mcc-tools-controls{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.mcc-select{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid rgba(15,23,42,.10);
  background:#fff;
  box-shadow:0 8px 18px rgba(2,6,23,.06);
}
.mcc-select span{ font-size:12px; font-weight:800; opacity:.72; letter-spacing:.02em; }
.mcc-select select{ border:0; background:transparent; outline:none; font-size:12px; font-weight:900; }

/* 3 per row desktop, 2 tablet, 1 mobile */
.mcc-tools-grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0,1fr));
  gap:12px;
  align-items:start;
}
@media (max-width:980px){ .mcc-tools-grid{ grid-template-columns:repeat(2, minmax(0,1fr)); } }
@media (max-width:620px){ .mcc-tools-grid{ grid-template-columns:1fr; } }

/* --- Card flip base --- */
.mcc-tool-card{
  position:relative;
  border-radius:18px;
  border:1px solid rgba(15,23,42,.10);
  background:transparent;
  overflow:hidden;
  cursor:pointer;
  user-select:none;
  -webkit-tap-highlight-color:transparent;

  aspect-ratio:1/1;

  box-shadow: 0 10px 24px rgba(2,6,23,.06), inset 0 0 0 1px rgba(255,255,255,.45);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, filter .18s ease;

  perspective: 1100px;
}
.mcc-tool-card:hover{
  transform: translateY(-2px);
  border-color: rgba(6,182,212,.35);
  box-shadow: 0 16px 36px rgba(2,6,23,.10), inset 0 0 0 1px rgba(255,255,255,.55);
}
.mcc-tool-card:focus-visible{
  outline:2px solid rgba(6,182,212,.9);
  outline-offset:3px;
}

/* Featured highlight (not oversized) */
.mcc-tool-card.featured{ border-color: rgba(167,139,250,.30); }

/* Placeholders */
.mcc-tool-card.is-placeholder{ cursor:default; filter:saturate(.85); }
.mcc-tool-card.is-placeholder:hover{
  transform:none;
  border-color: rgba(15,23,42,.10);
  box-shadow: 0 10px 24px rgba(2,6,23,.06), inset 0 0 0 1px rgba(255,255,255,.45);
}

/* Inner flip */
.mcc-card-inner{
  position:absolute;
  inset:0;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.2,.9,.2,1);
}
.mcc-tool-card:hover .mcc-card-inner,
.mcc-tool-card:focus-visible .mcc-card-inner{
  transform: rotateY(180deg);
}
@media (prefers-reduced-motion: reduce){
  .mcc-card-inner{ transition:none; }
  .mcc-tool-card:hover .mcc-card-inner{ transform:none; }
}

.mcc-card-face{
  position:absolute;
  inset:0;
  backface-visibility:hidden;
  border-radius:inherit;
  overflow:hidden;
}

/* FRONT */
.mcc-card-front{
  background:#fff;
}
.mcc-card-front::before{
  content:"";
  position:absolute;
  inset:0;
  background:
    radial-gradient(380px 240px at 30% 20%, rgba(34,211,238,.22), transparent 60%),
    radial-gradient(420px 260px at 80% 45%, rgba(167,139,250,.18), transparent 62%),
    linear-gradient(180deg, rgba(2,6,23,.10) 0%, rgba(2,6,23,.08) 36%, rgba(2,6,23,.55) 100%);
  pointer-events:none;
  z-index:2;
}
.mcc-card-front::after{
  content:"";
  position:absolute;
  left:-30%;
  top:-40%;
  width:70%;
  height:180%;
  transform: rotate(18deg);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent);
  opacity:.35;
  pointer-events:none;
  transition: opacity .28s ease;
  z-index:3;
}
.mcc-tool-card:hover .mcc-card-front::after{ opacity:.55; }

.mcc-tool-thumb{
  position:absolute;
  inset:0;
  background-image: var(--mc-chemcanvas-thumb);
  background-size: cover;
  background-position: center;
  transform: scale(1.02);
  filter: saturate(1.05) contrast(1.02);
  transition: transform .28s ease, filter .28s ease;
  z-index:1;
}
.mcc-tool-card:hover .mcc-tool-thumb{
  transform: scale(1.06);
  filter: saturate(1.10) contrast(1.04);
}

.mcc-tool-meta{
  position:absolute;
  inset:auto 0 0 0;
  padding:14px 14px 12px;
  color:#fff;
  z-index:4;
}
.mcc-tool-name{
  font-weight:950;
  letter-spacing:-.01em;
  font-size:16px;
  margin-bottom:6px;
}
.mcc-tool-cta{
  font-size:12px;
  opacity:.88;
}

/* BACK */
.mcc-card-back{
  transform: rotateY(180deg);
  background:
    radial-gradient(420px 260px at 25% 20%, rgba(34,211,238,.20), transparent 60%),
    radial-gradient(460px 280px at 80% 30%, rgba(167,139,250,.18), transparent 62%),
    linear-gradient(180deg, rgba(2,6,23,.92), rgba(2,6,23,.98));
  color:#fff;
}
.mcc-back-inner{
  position:absolute;
  inset:0;
  padding:16px 14px 14px;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  gap:10px;
}
.mcc-card-back .mcc-tool-name{ margin:0; }
.mcc-tool-desc{
  font-size:12.5px;
  line-height:1.45;
  opacity:.90;
}
.mcc-tool-uses{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
}
.mcc-chip{
  font-size:11px;
  padding:3px 9px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(8px);
}

/* Pager */
.mcc-pager{
  margin-top:14px;
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:center;
  align-items:center;
}
.mcc-page{
  border:1px solid rgba(15,23,42,.12);
  background:#fff;
  color: rgba(15,23,42,.92);
  padding:9px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:900;
  font-size:12px;
}
.mcc-page:hover{ background: rgba(15,23,42,.04); }
.mcc-page.is-active{ border-color: rgba(6,182,212,.45); background: rgba(6,182,212,.12); }
.mcc-page:disabled{ opacity:.45; cursor:not-allowed; }

/* -----------------------------
   Dashboard: Embedded tool view
------------------------------ */
.mcc-embed{
  border-radius:16px;
  border:1px solid rgba(15,23,42,.10);
  background:#fff;
  overflow:hidden;
  box-shadow:0 10px 26px rgba(2,6,23,.08);
}
.mcc-embed-h{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-bottom:1px solid rgba(15,23,42,.10);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
.mcc-embed-title{ font-weight:950; letter-spacing:-.01em; }

.mcc-embed-b{
  height:min(74dvh, 860px);
  min-height:520px;
  max-height:calc(100dvh - 180px);
  display:flex;
  flex-direction:column;
  min-height:0;
}
.mcc-embed-canvas{ flex:1 1 auto; min-height:0; }
.mcc-embed .cc-structure-studio{ height:100%; }

/* -----------------------------
   OPTIONAL: fallback tool window
------------------------------ */
.mcc-toolwin{
  position:fixed;
  left:16px;
  top:96px;
  width:min(1100px, calc(100vw - 32px));
  height:min(78dvh, calc(100dvh - 120px));
  min-width:720px;
  min-height:520px;
  max-width:min(1240px, calc(100vw - 32px));
  max-height:calc(100dvh - 120px);
  background:#ffffff;
  border:1px solid rgba(0,0,0,.12);
  border-radius:12px;
  box-shadow:0 12px 30px rgba(2,6,23,.18);
  overflow:hidden;
  resize:both;
  z-index:10090;
}
@media (max-width:820px){
  .mcc-toolwin{ left:12px; right:12px; width:auto; min-width:unset; resize:none; }
}
.mcc-toolwin[hidden]{ display:none !important; }
.mcc-toolwin__h{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:6px 8px;
  background:#fafafa;
  border-bottom:1px solid rgba(0,0,0,.10);
  cursor:move;
  user-select:none;
  -webkit-user-select:none;
  touch-action:none;
}
.mcc-toolwin__title{ font-weight:900; font-size:13px; color:#0f172a; }
.mcc-toolwin__close{
  width:24px;height:24px;
  border-radius:8px;
  border:1px solid rgba(0,0,0,.12);
  background:#ffffff;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-weight:900;
  line-height:1;
}
.mcc-toolwin__close:hover{ background:#fee2e2; border-color:#fecaca; color:#dc2626; }
.mcc-toolwin__b{ height:calc(100% - 38px); display:flex; flex-direction:column; min-height:0; }
.mcc-toolwin__canvas{ flex:1 1 auto; min-height:0; }
.mcc-toolwin .cc-structure-studio{ height:100%; }
