/*
  Credimi EUDI Trusted Lists — application styles.

  Shared Credimi design tokens and components (topbar, footer, cards, buttons,
  badges, page shell, responsive breakpoints) live in style.css, adapted from
  the EUDI Conformance Atlas. Only publisher-specific surfaces are defined here:
  the product lockup, catalogue/manifest tables, onboarding cards, forms,
  notices and the embedded API reference.
*/

/*
  --- Product lockup ---

  The logo boxes match the Credimi Capture Wallet shell (HITL reference
  `credimi-capture-wallet-master/src/ui.ts`): a square, padded, contained box
  of 42px in the topbar and 56px in the footer.
*/
.tlp-product-name {
  color: var(--fg);
  font-size: var(--fs-sm);
  font-weight: 800;
  white-space: nowrap;
}

.topbar-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: auto;
  color: var(--fg);
  font-weight: 800;
  text-decoration: none;
}

.topbar-logo img {
  box-sizing: border-box;
  width: 42px;
  height: 42px;
  padding: 4px;
  object-fit: contain;
  flex: 0 0 auto;
}

.tlp-footer-logo {
  box-sizing: border-box;
  width: 56px;
  height: 56px;
  padding: 6px;
  object-fit: contain;
  flex: 0 0 auto;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.footer-brand p {
  color: rgba(255, 255, 255, 0.7);
}

/*
  --- Top navigation groups ---

  The nav reads as three groups — the site itself, the API surface, and the
  source — separated by a hairline rule rather than by extra whitespace alone.
*/
.topbar-nav .nav-sep {
  width: 1px;
  height: 18px;
  padding: 0;
  background: var(--border);
  flex: 0 0 auto;
}

/*
  --- Colour coding for Trusted List Families and Trusted Lists ---

  Every place that names a family or a list renders one of these chips, so the
  same family (and the same list key) is always the same colour across the
  catalogue, onboarding, administration and settings pages.
*/
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.chip code {
  font-size: inherit;
  color: inherit;
  background: none;
  padding: 0;
}

a .chip {
  text-decoration: none;
}

.chip-family--wallet {
  background: oklch(0.95 0.04 300);
  border-color: oklch(0.82 0.09 300);
  color: oklch(0.42 0.18 300);
}

.chip-family--pid {
  background: oklch(0.95 0.04 235);
  border-color: oklch(0.82 0.09 235);
  color: oklch(0.42 0.16 235);
}

.chip-family--pubeaa {
  background: oklch(0.95 0.05 85);
  border-color: oklch(0.82 0.1 85);
  color: oklch(0.42 0.13 85);
}

.chip-family--wrpac {
  background: oklch(0.95 0.04 25);
  border-color: oklch(0.82 0.09 25);
  color: oklch(0.45 0.18 25);
}

.chip-family--wrprc {
  background: oklch(0.95 0.04 345);
  border-color: oklch(0.82 0.09 345);
  color: oklch(0.44 0.17 345);
}

.chip-family--registrar {
  background: oklch(0.95 0.04 200);
  border-color: oklch(0.82 0.08 200);
  color: oklch(0.4 0.12 200);
}

.chip-family--unknown {
  background: var(--bg-muted);
  border-color: var(--border);
  color: var(--fg-muted);
}

/*
  List swatches are picked by `listColorClass()` from the list key, so the
  count here must stay in step with `LIST_SWATCH_COUNT` in colors.ts.
*/
.chip-list {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-weight: 500;
}

.chip-list--0 {
  background: oklch(0.96 0.035 264);
  border-color: oklch(0.84 0.08 264);
  color: oklch(0.42 0.15 264);
}

.chip-list--1 {
  background: oklch(0.96 0.035 150);
  border-color: oklch(0.84 0.08 150);
  color: oklch(0.4 0.13 150);
}

.chip-list--2 {
  background: oklch(0.96 0.04 40);
  border-color: oklch(0.84 0.09 40);
  color: oklch(0.44 0.15 40);
}

.chip-list--3 {
  background: oklch(0.96 0.035 315);
  border-color: oklch(0.84 0.08 315);
  color: oklch(0.43 0.16 315);
}

.chip-list--4 {
  background: oklch(0.96 0.04 190);
  border-color: oklch(0.84 0.08 190);
  color: oklch(0.4 0.11 190);
}

.chip-list--5 {
  background: oklch(0.96 0.045 100);
  border-color: oklch(0.84 0.1 100);
  color: oklch(0.42 0.12 100);
}

.chip-list--6 {
  background: oklch(0.96 0.035 10);
  border-color: oklch(0.84 0.09 10);
  color: oklch(0.45 0.17 10);
}

.chip-list--7 {
  background: oklch(0.96 0.035 285);
  border-color: oklch(0.84 0.08 285);
  color: oklch(0.42 0.16 285);
}

/* --- Page rhythm --- */
.content h1,
.content h2 {
  margin-bottom: var(--space-3);
}

/*
  The Atlas heading scale is sized for page and section titles; headings that
  label a card are one step down so they do not compete with the page title.
*/
.card h2 {
  font-size: var(--fs-xl);
  line-height: 1.364;
  letter-spacing: normal;
}

.card h3 {
  font-size: var(--fs-lg);
  line-height: 1.5;
  letter-spacing: normal;
}

.content p,
.content ul,
.content table,
.content form {
  margin-bottom: var(--space-4);
}

.content ul {
  padding-left: var(--space-6);
}

.lead {
  font-size: var(--fs-md);
  color: var(--fg-muted);
  max-width: 68ch;
  line-height: 1.6;
}

/*
  Stacked cards need breathing room, but cards laid out by a grid get their
  spacing from the grid gap — the sibling margin would offset every cell but
  the first and break the row alignment.
*/
.card + .card,
.card + p,
.card + .form-actions {
  margin-top: var(--space-5);
}

.onboarding-grid .card + .card {
  margin-top: 0;
}

/* --- Notices / alerts --- */
.notice,
.trust-notice,
.error-msg,
.success-msg,
.warn-msg {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-4) 0;
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.notice-warning,
.trust-notice,
.warn-msg {
  background: var(--warning-bg);
  border-color: var(--warning);
  color: var(--fg);
}

.notice-info {
  background: var(--info-bg);
  border-color: var(--info);
  color: var(--fg);
}

.success-msg {
  background: var(--success-bg);
  border-color: var(--success);
}

.notice-error,
.error-msg {
  background: var(--destructive-bg);
  border-color: var(--destructive);
}

/* --- Buttons: default size for bare .btn (style.css only sizes modifiers) --- */
.btn {
  height: 36px;
  padding: 0 var(--space-4);
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-muted);
}

/*
  The bare .btn defaults above are declared after style.css, so the Atlas
  variants must restate their fill to win the cascade.
*/
.btn.btn-primary {
  background: var(--brand-primary);
  border-color: transparent;
  color: white;
}

.btn.btn-primary:hover {
  background: var(--brand-primary-700);
  border-color: transparent;
  color: white;
}

.btn.btn-outline {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
}

.btn.btn-outline:hover {
  border-color: var(--border-strong);
  background: var(--bg-muted);
}

.btn-danger {
  background: var(--destructive);
  border-color: transparent;
  color: white;
}

.btn-danger:hover {
  background: oklch(0.42 0.2 25);
  border-color: transparent;
  color: white;
}

.btn-sm {
  height: 28px;
}

/* --- Badges used by the publisher state machine --- */
.badge.ok {
  background: var(--success-bg);
  color: var(--success);
}

.badge.info {
  background: var(--info-bg);
  color: var(--info);
}

.badge.error {
  background: var(--destructive-bg);
  color: var(--destructive);
}

.badge.muted {
  background: var(--bg-muted);
  color: var(--fg-muted);
}

/* --- Tables --- */
.catalogue-table,
.kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  background: var(--bg);
  display: table;
}

.catalogue-table {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.catalogue-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 2px solid var(--border);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  background: var(--bg-muted);
}

.catalogue-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.catalogue-table tr:last-child td {
  border-bottom: none;
}

/*
  The Open cell holds one small button per available artifact, on a single line
  at the right edge, so the last column reads as actions rather than as data. It
  stays a table cell — the responsive rule below scrolls the whole table, and a
  flex cell would fall out of that.
*/
.catalogue-table td.catalogue-open {
  text-align: right;
  white-space: nowrap;
}

.catalogue-open .btn + .btn {
  margin-left: var(--space-2);
}

.catalogue-table tr:hover td {
  background: var(--bg-muted);
}

.kv-table th {
  text-align: left;
  width: 220px;
  padding: var(--space-2) var(--space-3);
  color: var(--fg-muted);
  font-weight: 600;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.kv-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.kv-table tr:last-child th,
.kv-table tr:last-child td {
  border-bottom: none;
}

/*
  Wide content scrolls inside its card instead of stretching the page. The
  page width itself is owned by the Atlas .container inside .page-content.
*/
.card {
  max-width: 100%;
}

/* --- Onboarding catalogue --- */
.onboarding-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.onboarding-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.onboarding-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.onboarding-card-head h3 {
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.3;
}

.onboarding-card-key {
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  margin: 0;
}

.onboarding-card-action {
  margin-top: auto;
}

.onboarding-card-note {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}

.card-disabled {
  background: var(--bg-muted);
  border-style: dashed;
  opacity: 0.7;
}

.card-disabled:hover {
  border-color: var(--border);
}

.card-disabled h3 {
  color: var(--fg-muted);
}

/* --- Forms --- */
.onboarding-form {
  max-width: 760px;
}

.form-group {
  margin-bottom: var(--space-4);
}

.form-group label,
fieldset legend {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: var(--space-1);
  color: var(--fg);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin: var(--space-4) 0;
}

fieldset legend {
  padding: 0 var(--space-2);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

input[type="text"],
input[type="search"],
input[type="url"],
input[type="email"],
input[type="password"],
select,
textarea {
  font-family:
    "Manrope",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  font-size: var(--fs-base);
  padding: 0 var(--space-4);
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  color: var(--fg);
  width: 100%;
  transition:
    border-color 200ms ease-out,
    box-shadow 200ms ease-out;
}

textarea {
  height: auto;
  padding: var(--space-3) var(--space-4);
  line-height: 1.5;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: var(--fs-sm);
  resize: vertical;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--fg-muted) 50%),
    linear-gradient(135deg, var(--fg-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 16px,
    calc(100% - 13px) 16px;
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--space-8);
}

input[type="url"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px oklch(0.2955 0.1659 277.31 / 0.18);
}

.field-help {
  display: block;
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  margin-top: var(--space-1);
  line-height: 1.5;
}

.field-error {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--destructive);
  margin-top: var(--space-1);
}

.required {
  color: var(--destructive);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-6) 0 var(--space-10);
}

.service-block {
  background: var(--bg-muted);
  margin-bottom: var(--space-4);
}

.service-block h3 {
  font-size: var(--fs-md);
  font-weight: 700;
  margin-bottom: 0;
}

.service-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

/*
  Only the second and later service blocks are removable, so the button is
  rendered on every block and hidden on whichever block is currently first.
*/
.service-remove {
  width: 28px;
  height: 28px;
  padding: 0;
  flex: 0 0 auto;
  font-weight: 700;
  line-height: 1;
}

.service-remove[hidden] {
  display: none;
}

/* --- Settings --- */
.settings-family {
  margin-bottom: var(--space-5);
}

.settings-family-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.settings-lists {
  border-left: 2px solid var(--border);
  margin-left: var(--space-2);
  padding-left: var(--space-4);
}

.settings-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.settings-row + .settings-row {
  border-top: 1px solid var(--border);
}

.settings-row input[type="checkbox"] {
  margin-top: 3px;
  flex: 0 0 auto;
}

.settings-row label {
  font-size: var(--fs-sm);
  font-weight: 500;
  margin: 0;
}

.settings-row .field-help {
  margin-top: 0;
}

.cert-preview {
  font-family: "JetBrains Mono", monospace;
  font-size: var(--fs-xs);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --- Administrator sign-in --- */
.admin-login-card {
  max-width: 28rem;
}

.admin-login-form .form-actions {
  margin-bottom: 0;
}

/* --- API documentation --- */
.api-docs {
  padding: 0;
  overflow: hidden;
}

.api-docs-frame {
  display: block;
  width: 100%;
  height: 78vh;
  min-height: 520px;
  border: 0;
  background: var(--bg);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .onboarding-grid {
    grid-template-columns: 1fr;
  }
  .kv-table th {
    width: 40%;
  }
  .api-docs-frame {
    height: 70vh;
    min-height: 420px;
  }
  .catalogue-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* --- Trust Inspector panel and version downloads --- */
/*
  The Inspector verdict is the first thing a reader looks for on a version page,
  so Pass/Fail/Unavailable is a badge rather than a table value. `badge-danger`
  reuses the destructive tokens from style.css; the other two states reuse the
  existing assurance and neutral badges.
*/
.badge-danger {
  background: var(--destructive-bg);
  color: var(--destructive);
}

.inspector-status {
  font-size: var(--fs-sm);
}

.inspector-actions,
.version-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.inspector-failures {
  margin: var(--space-3) 0 0;
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.inspector-failures li + li {
  margin-top: var(--space-2);
}

/* The onboarding introduction reads across the content column, not a narrow measure. */
.lead-wide {
  max-width: none;
}

/* --- Trusted List creation --- */
.tl-create-form fieldset {
  margin-top: var(--space-5);
}

.tl-broken-options {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.tl-broken-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--fs-sm);
}

@media (max-width: 640px) {
  .tlp-product-name {
    display: none;
  }

  /*
    Six nav entries do not fit a phone width. Rather than wrapping out of the
    fixed-height topbar, the nav scrolls sideways and each label stays intact.
  */
  .topbar-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .topbar-nav::-webkit-scrollbar {
    display: none;
  }

  .topbar-nav a {
    white-space: nowrap;
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }
}
