
/* Trust Infrastructure Engine — Frontend Widgets (Stage 7A) */
.tie-widget, .tie-badge{
  --tie-bg:#111827;
  --tie-fg:#ffffff;
  --tie-muted: rgba(255,255,255,.72);
  --tie-border: rgba(255,255,255,.12);
  --tie-shadow: 0 10px 30px rgba(0,0,0,.18);
  --tie-grade:#22c55e; /* default, overridden per grade */
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

/* Themes */
.tie-theme-dark{ --tie-bg:#111827; --tie-fg:#ffffff; --tie-muted: rgba(255,255,255,.72); --tie-border: rgba(255,255,255,.12); }
.tie-theme-light{ --tie-bg:#ffffff; --tie-fg:#0f172a; --tie-muted: rgba(15,23,42,.72); --tie-border: rgba(15,23,42,.12); --tie-shadow: 0 10px 30px rgba(15,23,42,.10); }
.tie-theme-glass{ --tie-bg: rgba(17,24,39,.55); --tie-fg:#ffffff; --tie-muted: rgba(255,255,255,.72); --tie-border: rgba(255,255,255,.18); --tie-shadow: 0 14px 40px rgba(0,0,0,.22); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }

/* Sizes */
.tie-size-sm{ --tie-ring: 92px; --tie-score: 26px; --tie-grade-size: 12px; --tie-pad: 12px; }
.tie-size-md{ --tie-ring: 116px; --tie-score: 34px; --tie-grade-size: 13px; --tie-pad: 14px; }
.tie-size-lg{ --tie-ring: 140px; --tie-score: 42px; --tie-grade-size: 14px; --tie-pad: 16px; }

/* Grade colors */
[data-grade="A"]{ --tie-grade:#16a34a; }
[data-grade="B"]{ --tie-grade:#22c55e; }
[data-grade="C"]{ --tie-grade:#f59e0b; }
[data-grade="D"]{ --tie-grade:#f97316; }
[data-grade="E"]{ --tie-grade:#ef4444; }
[data-grade="N/A"]{ --tie-grade:#94a3b8; }

/* Widget container */
.tie-widget{
  display:inline-flex;
  align-items:center;
  gap: 14px;
  padding: var(--tie-pad);
  background: var(--tie-bg);
  color: var(--tie-fg);
  border: 1px solid var(--tie-border);
  border-radius: 14px;
  box-shadow: var(--tie-shadow);
}

/* Ring */
.tie-ring{
  position:relative;
  width: var(--tie-ring);
  height: var(--tie-ring);
  display:grid;
  place-items:center;
}
.tie-ring-svg{ width:100%; height:100%; transform: rotate(-90deg); }
.tie-ring-track{
  fill: none;
  stroke: rgba(255,255,255,.10);
  stroke-width: 10;
}
.tie-theme-light .tie-ring-track{ stroke: rgba(15,23,42,.10); }
.tie-ring-fill{
  fill:none;
  stroke: var(--tie-grade);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 900ms ease;
}
.tie-ring-center{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  text-align:center;
  transform: rotate(0deg);
}
.tie-score-value{
  font-size: var(--tie-score);
  font-weight: 800;
  line-height: 1;
}
.tie-grade{
  margin-top: 4px;
  font-size: var(--tie-grade-size);
  font-weight: 700;
  opacity: .92;
  color: var(--tie-grade);
}

/* Label */
.tie-label{ display:flex; flex-direction:column; gap: 2px; }
.tie-label-title{ font-weight: 700; font-size: 14px; }
.tie-label-sub{ font-size: 12px; color: var(--tie-muted); }

/* Badge */
.tie-badge{
  display:inline-flex;
  align-items:center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--tie-bg);
  color: var(--tie-fg);
  border: 1px solid var(--tie-border);
  box-shadow: var(--tie-shadow);
}
.tie-badge-dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--tie-grade);
  box-shadow: 0 0 0 3px rgba(34,197,94,.18);
}
.tie-badge-grade{ color: var(--tie-grade); font-weight:700; margin-left:4px; }
.tie-badge-text{ font-size: 13px; }

/* Make badge size react */
.tie-badge.tie-size-sm{ padding: 7px 12px; }
.tie-badge.tie-size-lg{ padding: 10px 16px; }


/* Certificate (Stage 7B) */
.tie-certificate{
  margin: 20px 0;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--tie-border);
  background: var(--tie-bg);
  color: var(--tie-fg);
  box-shadow: var(--tie-shadow);
}
.tie-cert-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.tie-cert-title{ margin:0; font-size: 22px; }
.tie-cert-badges{ margin-top: 10px; display:flex; flex-wrap:wrap; gap:8px; }
.tie-status-badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--tie-border);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .02em;
  background: rgba(255,255,255,.02);
}
.tie-theme-light .tie-status-badge{ background: rgba(15,23,42,.02); }
.tie-status-valid{ color: #16a34a; }
.tie-status-stale{ color: #f59e0b; }
.tie-status-invalid{ color: #94a3b8; }
.tie-status-sub{ font-weight: 800; font-size: 11px; opacity: .9; }
.tie-cert-sub{ margin-top:6px; font-size: 12px; color: var(--tie-muted); }
.tie-cert-score .tie-widget{ box-shadow:none; }
.tie-cert-score-label{ margin-top: 8px; text-align:center; font-size: 12px; font-weight: 900; color: var(--tie-muted); }

/* Make the score ring feel premium on desktop */
@media (min-width: 1024px){
  .tie-certificate .tie-size-lg{ --tie-ring: 170px; --tie-score: 48px; }
}

.tie-cert-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
@media (max-width: 900px){
  .tie-cert-grid{ grid-template-columns: 1fr; }
}

.tie-cert-card{
  border: 1px solid var(--tie-border);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255,255,255,.02);
}
.tie-theme-light .tie-cert-card{ background: rgba(15,23,42,.02); }
.tie-cert-wide{ margin-top: 14px; }
.tie-cert-card h3{ margin:0 0 10px 0; font-size: 15px; }
.tie-cert-list{ list-style:none; padding:0; margin:0; display:grid; gap: 8px; }
.tie-cert-list li{ display:flex; justify-content:space-between; gap: 10px; }
.tie-cert-muted{ color: var(--tie-muted); font-size: 12px; }
.tie-cert-footnote{ margin-top: 10px; font-size: 12px; color: var(--tie-muted); }

.tie-cert-weights{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 700px){
  .tie-cert-weights{ grid-template-columns: 1fr; }
}
.tie-cert-weights > div{
  border: 1px solid var(--tie-border);
  border-radius: 12px;
  padding: 10px;
  display:flex;
  justify-content:space-between;
}

.tie-cert-note{
  margin-top: 14px;
  font-size: 12px;
  color: var(--tie-muted);
  border-top: 1px dashed var(--tie-border);
  padding-top: 12px;
}

/* Stage 18: Public Trust Report */
.tie-report-summary{display:flex;gap:18px;flex-wrap:wrap;}
.tie-report-summary > div{flex:1;min-width:240px;display:grid;gap:10px;}
.tie-report-kpi{display:flex;justify-content:space-between;gap:12px;align-items:baseline;padding:10px 12px;border:1px solid rgba(0,0,0,.06);border-radius:10px;background:rgba(0,0,0,.015);}
.tie-report-kpi span{color:rgba(0,0,0,.6);font-size:12px;}
.tie-report-kpi strong{font-weight:700;}

.tie-trend-wrap{display:grid;gap:10px;}
.tie-trend-svg{width:100%;height:140px;background:rgba(0,0,0,.015);border:1px solid rgba(0,0,0,.06);border-radius:12px;}
.tie-trend-line{stroke:currentColor;stroke-width:3;opacity:.9;}
.tie-theme-dark .tie-trend-svg{background:rgba(255,255,255,.04);border-color:rgba(255,255,255,.08);}
.tie-theme-dark .tie-report-kpi{background:rgba(255,255,255,.04);border-color:rgba(255,255,255,.08);}
.tie-theme-dark .tie-report-kpi span{color:rgba(255,255,255,.7);}

.tie-trend-meta{display:flex;gap:12px;flex-wrap:wrap;color:rgba(0,0,0,.6);font-size:12px;}
.tie-theme-dark .tie-trend-meta{color:rgba(255,255,255,.7);}
.tie-trend-delta{font-weight:700;}


/* Stage 8A.1 — Public trends on certificate */
.tie-cert-trends{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-top: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.tie-cert-momentum{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--tie-border);
  background: rgba(255,255,255,.02);
  font-size: 13px;
}
.tie-theme-light .tie-cert-momentum{ background: rgba(15,23,42,.02); }
.tie-cert-momentum.tie-mom-up{ color: #16a34a; }
.tie-cert-momentum.tie-mom-down{ color: #dc2626; }
.tie-cert-momentum.tie-mom-flat{ color: var(--tie-fg); }
.tie-cert-momentum.tie-mom-na{ color: var(--tie-muted); }

.tie-cert-sparkline{
  width: 360px;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--tie-border);
  border-radius: 12px;
  padding: 6px 8px;
  background: rgba(255,255,255,.02);
  color: var(--tie-fg);
}
.tie-theme-light .tie-cert-sparkline{ background: rgba(15,23,42,.02); }

/* Stage 8B — Verification block */
.tie-verify-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
  padding: 10px 12px;
  border: 1px dashed var(--tie-border);
  border-radius: 14px;
}
.tie-verify-id{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 800;
  letter-spacing: .02em;
}
.tie-verify-link{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--tie-border);
  text-decoration:none;
}

.tie-verify-wrap{ margin-top:8px; }
.tie-verify-actions{
  margin-top:10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}
.tie-verify-btn{
  appearance:none;
  border:1px solid var(--tie-border);
  background:rgba(255,255,255,.02);
  color:var(--tie-fg);
  padding:8px 10px;
  border-radius:999px;
  font-weight:700;
  cursor:pointer;
}
.tie-theme-light .tie-verify-btn{ background:rgba(15,23,42,.02); }
.tie-verify-btn:hover{ filter:brightness(1.05); }
.tie-verify-status{ color:var(--tie-muted); font-size:12px; }
.tie-verify-qr{ width:132px; height:132px; display:flex; align-items:center; justify-content:center; border:1px solid var(--tie-border); border-radius:14px; padding:6px 8px; background:rgba(255,255,255,.02); }
.tie-theme-light .tie-verify-qr{ background:rgba(15,23,42,.02); }

/* Stage 8B.2 — Verification badge */
.tie-vbadge{
  display:inline-flex;
  flex-direction:column;
  gap:6px;
  border:1px solid var(--tie-border);
  border-radius: 999px;
  padding:10px 12px;
  background: rgba(255,255,255,.02);
}
.tie-theme-light .tie-vbadge{ background: rgba(15,23,42,.02); }
.tie-vbadge-main{ display:flex; align-items:center; justify-content:space-between; gap:10px; min-width: 240px; }
.tie-vbadge-score{ display:flex; align-items:baseline; gap:10px; }
.tie-vbadge-score strong{ font-size:18px; font-weight:900; }
.tie-vbadge-score span{ font-size:12px; color:var(--tie-muted); }
.tie-vbadge-link{ text-decoration:none; border:1px solid var(--tie-border); padding:6px 10px; border-radius:999px; font-weight:800; }
.tie-vbadge-meta{ display:flex; gap:10px; flex-wrap:wrap; font-size:12px; color:var(--tie-muted); padding-left: 4px; }
.tie-vbadge-id{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.tie-vbadge-full{ border-radius: 16px; }
