/*
 * Third-Party Licenses page styles
 * Every selector is scoped to #tpl-root so this page and the existing site
 * theme cannot contaminate each other.
 */
#tpl-root {
  --tpl-ink: #17191d;
  --tpl-muted: #626a75;
  --tpl-line: #dde1e6;
  --tpl-soft-line: #e9ebee;
  --tpl-paper: #ffffff;
  --tpl-accent: #1f5eff;
  --tpl-accent-soft: #eef3ff;
  --tpl-error: #a72828;
  --tpl-error-bg: #fff2f2;
  --tpl-radius: 14px;

  color: var(--tpl-ink);
  font-size: 16px;
  line-height: 1.65;
  text-align: left;
}

#tpl-root * { box-sizing: border-box; }
#tpl-root button,
#tpl-root select { font: inherit; }

#tpl-root .tpl-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Page head ---------- */

#tpl-root .tpl-pagehead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

#tpl-root .tpl-intro {
  max-width: 640px;
  margin: 0;
  color: var(--tpl-muted);
}

/* ---------- Status panels: loading / error / empty ---------- */

#tpl-root .tpl-status,
#tpl-root .tpl-empty {
  padding: 48px 24px;
  text-align: center;
  background: var(--tpl-paper);
  border: 1px solid var(--tpl-line);
  border-radius: var(--tpl-radius);
}

#tpl-root .tpl-status--error {
  color: var(--tpl-error);
  background: var(--tpl-error-bg);
  border-color: #f0caca;
}

#tpl-root .tpl-status h3,
#tpl-root .tpl-empty h3 {
  margin: 0 0 8px;
  font-size: 19px;
  text-transform: none;
  letter-spacing: normal;
}

#tpl-root .tpl-status p,
#tpl-root .tpl-empty p { margin: 0; color: var(--tpl-muted); }

#tpl-root .tpl-status--error p { color: inherit; }

#tpl-root .tpl-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid #ccd2da;
  border-top-color: var(--tpl-accent);
  border-radius: 50%;
  animation: tpl-spin .8s linear infinite;
}

@keyframes tpl-spin { to { transform: rotate(360deg); } }

#tpl-root .tpl-button {
  min-height: 42px;
  margin-top: 18px;
  padding: 8px 18px;
  color: #fff;
  background: var(--tpl-accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

/* ---------- Filtering: category tabs ---------- */

#tpl-root .tpl-filter { margin-bottom: 30px; }

#tpl-root .tpl-summary { margin: 0 0 14px; color: var(--tpl-muted); font-size: 14px; }

#tpl-root .tpl-tabs {
  display: flex;
  gap: 8px;
  padding-bottom: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

#tpl-root .tpl-tab {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 7px 13px;
  color: var(--tpl-muted);
  background: #fff;
  border: 1px solid var(--tpl-line);
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
}

#tpl-root .tpl-tab[aria-selected="true"] {
  color: #1245c5;
  background: var(--tpl-accent-soft);
  border-color: #b9cbff;
  font-weight: 650;
}

#tpl-root .tpl-tab-count {
  display: inline-block;
  min-width: 20px;
  margin-left: 6px;
  padding: 0 6px;
  color: inherit;
  background: rgba(31, 94, 255, .08);
  border-radius: 999px;
  font-size: 12px;
  text-align: center;
}

/* ---------- License entry cards ---------- */

#tpl-root .tpl-list { display: grid; gap: 18px; outline: none; }

#tpl-root .tpl-card {
  overflow: hidden;
  background: var(--tpl-paper);
  border: 1px solid var(--tpl-line);
  border-radius: var(--tpl-radius);
  box-shadow: 0 6px 20px rgba(20, 29, 43, .035);
}

#tpl-root .tpl-card-main { padding: 26px 28px 22px; }

#tpl-root .tpl-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 19px;
}

#tpl-root .tpl-card h3 {
  margin: 0;
  font-size: 23px;
  line-height: 1.3;
  letter-spacing: -.015em;
  text-transform: none;
}

#tpl-root .tpl-card-sub { margin: 4px 0 0; color: var(--tpl-muted); font-size: 14px; }

#tpl-root .tpl-badge {
  flex: 0 0 auto;
  padding: 4px 9px;
  color: #435066;
  background: #f0f2f5;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

#tpl-root .tpl-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 28px;
  margin: 0 0 18px;
}

#tpl-root .tpl-meta > div { min-width: 0; }
#tpl-root .tpl-meta dt { margin: 0 0 2px; color: var(--tpl-muted); font-size: 12px; font-weight: 400; }
#tpl-root .tpl-meta dd { margin: 0; overflow-wrap: anywhere; }

/* License text: fixed-height scroll area, monospace, newlines preserved,
   shown verbatim. */
#tpl-root .tpl-license {
  max-height: 420px;
  margin: 0;
  padding: 18px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  color: #343943;
  background: #f7f8fa;
  border: 1px solid var(--tpl-line);
  border-left: 3px solid #aeb7c4;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  -moz-tab-size: 4;
  tab-size: 4;
}

/* Title link: inherits the heading color, permanently underlined to show it
   is clickable. */
#tpl-root .tpl-card h3 a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
#tpl-root .tpl-card h3 a:hover { color: #174fcf; text-decoration-thickness: 2px; }

#tpl-root .tpl-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 19px;
}

#tpl-root .tpl-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #174fcf;
  font-weight: 650;
  text-decoration: none;
  overflow-wrap: anywhere;
}

#tpl-root .tpl-link:hover { text-decoration: underline; }
#tpl-root .tpl-link-icon { font-size: 12px; }

/* An invalid or non-HTTPS URL degrades to non-clickable text; other entries
   are unaffected. */
#tpl-root .tpl-link--disabled { color: #8a919c; font-weight: 400; cursor: default; }

#tpl-root .tpl-empty-icon { margin-bottom: 8px; color: #a4acb7; font-size: 38px; line-height: 1; }

#tpl-root button:focus-visible,
#tpl-root a:focus-visible,
#tpl-root .tpl-license:focus-visible {
  outline: 3px solid rgba(31, 94, 255, .35);
  outline-offset: 2px;
}

/* ---------- Mobile: supported down to 320px ---------- */

@media screen and (max-width: 640px) {
  #tpl-root .tpl-pagehead { flex-direction: column; align-items: stretch; gap: 16px; }
  #tpl-root .tpl-card-main { padding: 21px 19px 19px; }
  #tpl-root .tpl-card-top { gap: 12px; }
  #tpl-root .tpl-card h3 { font-size: 20px; }
  #tpl-root .tpl-meta { grid-template-columns: 1fr; gap: 12px; }
  #tpl-root .tpl-license { max-height: 300px; padding: 15px 16px; font-size: 12px; }
  #tpl-root .tpl-status,
  #tpl-root .tpl-empty { padding: 36px 18px; }
}

@media screen and (max-width: 360px) {
  #tpl-root .tpl-card-top { flex-direction: column; }
  #tpl-root .tpl-badge { align-self: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  #tpl-root .tpl-spinner { animation: none; }
}
