/* Asset Foundry dashboard. Every selector is scoped to the private Studio window. */
#win-asset-foundry {
  --foundry-green: #5df2a5;
  --foundry-amber: #ffc66d;
  --foundry-red: #ff6b7a;
  min-width: min(760px, calc(100vw - var(--dock-w) - 28px));
}

#win-asset-foundry .win-body {
  overflow: auto;
  background:
    radial-gradient(circle at 88% 2%, rgba(20,215,242,.09), transparent 29rem),
    linear-gradient(145deg, rgba(4,11,20,.96), rgba(4,7,15,.98));
}

.foundry-dashboard {
  display: grid;
  gap: 18px;
  min-height: 100%;
  padding: 20px;
  color: var(--text);
}

.foundry-dashboard[data-state="loading"] { opacity: .72; }

.foundry-hero,
.foundry-feature-layout,
.foundry-section-head,
.foundry-card-head,
.foundry-line-head,
.foundry-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.foundry-hero {
  align-items: flex-end;
  padding: 18px;
  border: 1px solid rgba(20,215,242,.18);
  border-radius: 12px;
  background: linear-gradient(115deg, rgba(20,215,242,.08), rgba(99,102,241,.04) 55%, transparent);
}

.foundry-kicker,
.foundry-section-kicker,
.foundry-card-kicker {
  font: 500 .52rem/1.35 var(--font-mono);
  letter-spacing: .15em;
  color: var(--primary);
}

.foundry-hero h2 {
  margin-top: 4px;
  font: 600 clamp(1.45rem, 3vw, 2.25rem)/.98 var(--font-display);
  letter-spacing: .055em;
  text-transform: uppercase;
}

.foundry-hero p {
  max-width: 720px;
  margin-top: 8px;
  color: var(--muted);
  font-size: .68rem;
  line-height: 1.55;
}

.foundry-status-cluster { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.foundry-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid rgba(148,163,184,.22);
  border-radius: 999px;
  background: rgba(3,8,15,.68);
  color: var(--muted);
  font: 500 .5rem/1 var(--font-mono);
  letter-spacing: .08em;
  white-space: nowrap;
}
.foundry-badge[data-state="passed"] { border-color: rgba(93,242,165,.34); color: var(--foundry-green); }
.foundry-badge[data-state="failed"] { border-color: rgba(255,107,122,.42); color: var(--foundry-red); }
.foundry-badge[data-state="blocked"] { border-color: rgba(255,198,109,.42); color: var(--foundry-amber); }

.foundry-metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 9px; }
.foundry-metric {
  padding: 12px;
  border: 1px solid rgba(20,215,242,.12);
  border-radius: 9px;
  background: rgba(7,16,29,.66);
}
.foundry-metric span { display: block; color: var(--muted); font: .49rem var(--font-mono); letter-spacing: .1em; }
.foundry-metric strong { display: block; margin-top: 5px; color: var(--primary-bright); font: 600 1.15rem var(--font-display); }

.foundry-section {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}
.foundry-section-head { justify-content: flex-start; align-items: baseline; }
.foundry-section h3 { font: 600 .93rem var(--font-head); letter-spacing: .025em; }

.foundry-gate-rail {
  display: grid;
  grid-template-columns: repeat(6, minmax(0,1fr));
  gap: 7px;
  list-style: none;
}
.foundry-gate {
  position: relative;
  min-height: 126px;
  padding: 11px;
  overflow: hidden;
  border: 1px solid rgba(148,163,184,.15);
  border-radius: 9px;
  background: rgba(6,13,24,.78);
}
.foundry-gate::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: var(--muted);
  opacity: .38;
}
.foundry-gate[data-state="passed"]::before { background: var(--foundry-green); opacity: 1; }
.foundry-gate[data-state="failed"]::before { background: var(--foundry-red); opacity: 1; }
.foundry-gate[data-state="blocked"]::before { background: var(--foundry-amber); opacity: 1; }
.foundry-gate-index { display: block; color: var(--muted); font: .52rem var(--font-mono); }
.foundry-gate strong { display: block; margin-top: 12px; font: 600 .68rem var(--font-head); }
.foundry-gate-state { display: block; margin-top: 4px; color: var(--muted); font: .46rem var(--font-mono); letter-spacing: .08em; }
.foundry-gate[data-state="passed"] .foundry-gate-state { color: var(--foundry-green); }
.foundry-gate[data-state="failed"] .foundry-gate-state { color: var(--foundry-red); }
.foundry-gate[data-state="blocked"] .foundry-gate-state { color: var(--foundry-amber); }
.foundry-gate p { margin-top: 8px; color: var(--muted); font-size: .54rem; line-height: 1.42; }

.foundry-feature {
  padding: 14px;
  border: 1px solid rgba(168,85,247,.26);
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(41,15,69,.36), rgba(248,184,8,.035));
}
.foundry-feature-layout { align-items: stretch; }
.foundry-feature-summary { flex: 0 0 min(36%, 340px); }
.foundry-feature-summary > p { margin: 10px 0 14px; color: #d3c8df; font-size: .63rem; line-height: 1.52; }
.foundry-identity { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 5px 10px; }
.foundry-identity dt { color: #c77dff; font: .48rem var(--font-mono); letter-spacing: .08em; }
.foundry-identity dd { overflow: hidden; color: #fff2c2; font: .52rem var(--font-mono); text-overflow: ellipsis; white-space: nowrap; }
.foundry-feature-evidence { display: grid; flex: 1; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }

.foundry-media { position: relative; min-height: 110px; overflow: hidden; border: 1px solid rgba(248,184,8,.2); border-radius: 7px; background: #030309; }
.foundry-media img { width: 100%; height: 100%; min-height: 110px; object-fit: cover; }
.foundry-media.is-missing img { opacity: 0; }
.foundry-media figcaption { position: absolute; inset: auto 0 0; padding: 6px 7px; background: linear-gradient(transparent, rgba(0,0,0,.9)); color: #fff2c2; font: .47rem var(--font-mono); letter-spacing: .05em; }

.foundry-card-grid,
.foundry-library-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.foundry-card,
.foundry-library-card {
  overflow: hidden;
  border: 1px solid rgba(20,215,242,.14);
  border-radius: 9px;
  background: rgba(6,13,24,.76);
}
.foundry-card { padding: 12px; }
.foundry-card-head { align-items: flex-start; }
.foundry-card-head strong { display: block; max-width: 240px; margin-top: 3px; overflow: hidden; color: var(--text); font: .57rem var(--font-mono); text-overflow: ellipsis; white-space: nowrap; }
.foundry-attempts { display: grid; gap: 4px; margin-top: 10px; }
.foundry-attempt { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 7px; padding: 6px 7px; border-radius: 5px; background: rgba(255,255,255,.025); font: .48rem var(--font-mono); }
.foundry-attempt[data-state="technical_pass"] { color: var(--foundry-green); background: rgba(93,242,165,.055); }
.foundry-attempt[data-state$="error"], .foundry-attempt[data-state$="failed"] { color: var(--foundry-red); }
.foundry-attempt-result { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foundry-attempt-id { color: var(--muted); }
.foundry-claim-note { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(255,198,109,.13); color: var(--foundry-amber); font-size: .51rem; line-height: 1.4; }

.foundry-library-lines { display: grid; gap: 14px; }
.foundry-library-line { display: grid; gap: 8px; }
.foundry-line-head strong { font: 600 .58rem var(--font-mono); letter-spacing: .1em; }
.foundry-library-card { display: grid; grid-template-columns: 148px minmax(0,1fr); }
.foundry-library-preview { width: 100%; height: 100%; min-height: 142px; object-fit: cover; background: #020408; }
.foundry-library-preview.is-missing { visibility: hidden; }
.foundry-library-body { display: flex; flex-direction: column; align-items: flex-start; padding: 11px; }
.foundry-library-body h4 { margin-top: 10px; font: 600 .68rem var(--font-head); }
.foundry-library-body p { margin-top: 4px; color: var(--muted); font: .49rem/1.4 var(--font-mono); }
.foundry-actions { width: 100%; margin-top: auto; padding-top: 10px; justify-content: flex-start; }
.foundry-link { padding: 6px 8px; border: 1px solid rgba(20,215,242,.25); border-radius: 5px; color: var(--primary); font: .48rem var(--font-mono); text-decoration: none; }
.foundry-link:hover { background: rgba(20,215,242,.08); }
.foundry-link.is-primary { background: var(--primary); color: var(--bg-void); }

.foundry-empty {
  display: grid;
  grid-column: 1 / -1;
  gap: 4px;
  min-height: 86px;
  place-content: center;
  padding: 16px;
  border: 1px dashed rgba(148,163,184,.18);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}
.foundry-empty strong { color: var(--text); font: 600 .67rem var(--font-head); }
.foundry-empty span { max-width: 560px; font-size: .56rem; line-height: 1.45; }

@media (max-width: 1080px) {
  #win-asset-foundry:not([data-maximized="1"]) {
    left: calc(var(--dock-w) + 14px) !important;
    width: calc(100vw - var(--dock-w) - 28px) !important;
    max-width: calc(100vw - var(--dock-w) - 28px);
  }
  .foundry-gate-rail { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .foundry-gate { min-height: 112px; }
}

@media (max-width: 760px) {
  #win-asset-foundry { min-width: 0; }
  .foundry-dashboard { padding: 12px; }
  .foundry-hero, .foundry-feature-layout { align-items: stretch; flex-direction: column; }
  .foundry-status-cluster { justify-content: flex-start; }
  .foundry-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .foundry-gate-rail { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .foundry-card-grid, .foundry-library-grid { grid-template-columns: 1fr; }
  .foundry-feature-summary { flex-basis: auto; }
}

@media (max-width: 470px) {
  .foundry-gate-rail, .foundry-feature-evidence { grid-template-columns: 1fr; }
  .foundry-library-card { grid-template-columns: 1fr; }
  .foundry-library-preview { max-height: 190px; }
}
