:root {
  --ink: #0f1b3d;
  --navy: #1e3261;
  --royal: #0c279f;
  --cyan: #00cdff;
  --azure: #119dd8;
  --verified: #1f9d6b;
  --paper: #eaeff7;
  --surface: #ffffff;
  --surface-2: #f5f8fc;
  --line: #e4e9f2;
  --line-strong: #d4dcea;
  --muted: #697088;

  --shadow-card: 0 30px 70px -28px rgba(15, 27, 61, 0.42);
  --shadow-soft: 0 2px 10px rgba(15, 27, 61, 0.06);

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;

  --display: "Viga", "Roboto", system-ui, -apple-system, sans-serif;
  --ui: "Roboto", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
  --brandface: "Viga", sans-serif;
}

* { box-sizing: border-box; }

/* El atributo hidden debe ganar sobre display explícitos (.btn, .profile-link, etc.) */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--ui);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { position: relative; overflow-x: hidden; }

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(130% 70% at 50% -15%, rgba(0, 205, 255, 0.18), transparent 58%),
    radial-gradient(90% 50% at 92% -5%, rgba(12, 39, 159, 0.12), transparent 55%),
    linear-gradient(180deg, #f4f7fc 0%, #e7edf6 100%);
}

/* ---------- Shell + card ---------- */
.shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 30px 16px 36px;
}

.card {
  width: min(540px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 26px 24px 28px;
  position: relative;
  overflow: hidden;
}

/* ---------- Brand ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.brand:hover,
.brand:focus {
  opacity: 0.85;
  outline: none;
}

.brand-mark { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; }

.brand-lockup { display: flex; flex-direction: column; gap: 2px; }

.brand-word {
  font-family: var(--brandface);
  font-size: 1.4rem;
  color: var(--navy);
  line-height: 1;
}

.brand-preview-word { display: none; }

.brand-tagline {
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Brand preview: /?brandPreview=1 ---------- */
body.brand-preview .brand {
  gap: 16px;
  margin-bottom: 22px;
  padding: 0 0 18px;
  border-bottom-color: var(--line);
}

body.brand-preview .brand:hover,
body.brand-preview .brand:focus {
  opacity: 0.9;
  border-bottom-color: var(--line);
}

body.brand-preview .brand-mark {
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 14px;
  background: none;
  box-shadow: none;
}

body.brand-preview .brand-lockup { gap: 8px; }

body.brand-preview .brand-default-word { display: none; }
body.brand-preview .brand-preview-word { display: inline; }

body.brand-preview .brand-word {
  font-family: var(--ui);
  font-size: 1.72rem;
  font-weight: 800;
  line-height: 0.88;
  letter-spacing: 0;
  text-transform: none;
  color: #17295a;
}

body.brand-preview .brand-tagline {
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #6f7488;
}

/* ---------- Search state ---------- */
.card.result-mode .search { display: none; }
.card.loading-mode .search,
.card.loading-mode .result { display: none; }

.search-title {
  margin: 0 0 10px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.65rem, 5.2vw, 2.16rem);
  line-height: 1.12;
  letter-spacing: 0;
  color: var(--ink);
}

.search-lead {
  margin: 0 0 24px;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--muted);
}

.field-label {
  display: block;
  margin-bottom: 9px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--royal);
}

.field input {
  width: 100%;
  padding: 15px 16px;
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--mono);
  font-size: 1.05rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--surface-2);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.field input::placeholder { color: #aab2c4; }

.field input:focus {
  outline: none;
  border-color: var(--azure);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(17, 157, 216, 0.16);
}

.search-trust {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 18px 0 2px;
  font-size: 0.82rem;
  color: var(--muted);
}

.search-trust strong { color: var(--navy); font-weight: 600; }
.search-trust svg { width: 16px; height: 16px; color: var(--verified); flex-shrink: 0; }

/* ---------- Validation splash ---------- */
.validation-splash {
  min-height: 312px;
  padding: 16px 0 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.validation-emblem {
  position: relative;
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  margin: 0 0 22px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--navy);
}

.validation-emblem::before {
  content: "";
  position: absolute;
  inset: -5px;
  border: 2px solid rgba(17, 157, 216, 0.16);
  border-top-color: var(--azure);
  border-radius: 50%;
  animation: validation-spin 1.15s linear infinite;
}

.validation-emblem svg {
  position: relative;
  width: 36px;
  height: 36px;
}

.validation-splash h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.48rem, 5vw, 1.9rem);
  line-height: 1.16;
  letter-spacing: 0;
  color: var(--ink);
}

.validation-steps {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 24px;
}

.validation-step {
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--navy);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1.1;
  text-transform: uppercase;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  animation: validation-step-complete 0.32s ease forwards;
}

.validation-step svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  padding: 2px;
  border-radius: 50%;
  background: #cbd5e1;
  color: #fff;
  transform: scale(0.82);
  animation: validation-check-complete 0.32s ease forwards;
}

.validation-step:nth-child(1),
.validation-step:nth-child(1) svg { animation-delay: 0.55s; }
.validation-step:nth-child(2),
.validation-step:nth-child(2) svg { animation-delay: 1.45s; }
.validation-step:nth-child(3),
.validation-step:nth-child(3) svg { animation-delay: 2.35s; }

.validation-step > span {
  min-width: 0;
  white-space: nowrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 50px;
  padding: 0 18px;
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  font-family: var(--ui);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.1;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.64; cursor: wait; transform: none; }
.btn:disabled:hover { transform: none; }
.btn-block { width: 100%; }

.btn-primary {
  margin-top: 22px;
  background: linear-gradient(180deg, #15409a 0%, #0c279f 100%);
  color: #fff;
  box-shadow: 0 12px 26px -10px rgba(12, 39, 159, 0.7);
}
.cred-actions .btn-primary { margin-top: 0; }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 16px 30px -10px rgba(12, 39, 159, 0.75); }
.btn-primary:disabled { background: #c8d0de; color: #eef1f6; box-shadow: none; cursor: not-allowed; }

.btn-linkedin { background: #0a66c2; color: #fff; }
.btn-linkedin:hover { background: #08589f; transform: translateY(-1px); }

.btn-soft { background: var(--surface-2); border-color: var(--line); color: var(--navy); }
.btn-soft:hover { background: #eef2f9; border-color: var(--line-strong); transform: translateY(-1px); }

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

.btn[data-loading="true"] { opacity: 0.92; cursor: wait; }

/* ---------- Result shell ---------- */
.result { margin-top: 2px; }

/* ---------- Filas de verificación (ID · verificado · firma) — caja unificada ---------- */
.cred-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 9px;
  padding: 10px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.row-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.row-label svg { width: 15px; height: 15px; color: var(--navy); flex-shrink: 0; }
.row-value {
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}
.row-value time { font-variant-numeric: tabular-nums; }

.live-check {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--verified);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(31, 157, 107, 0.5);
  animation: pulse 2.2s infinite;
}
.live-check svg { width: 8px; height: 8px; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(31, 157, 107, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(31, 157, 107, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 157, 107, 0); }
}

.cred-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong) 18%, var(--line-strong) 82%, transparent);
  margin: 0 0 18px;
}

.cred-eyebrow {
  margin: 0 0 4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.cred-name {
  margin: 0 0 6px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.62rem, 5.7vw, 2.12rem);
  line-height: 1.14;
  letter-spacing: 0;
  color: var(--ink);
}
.cred-name a { color: inherit; text-decoration: none; border-bottom: 2px solid rgba(17, 157, 216, 0.35); }
.cred-name a:hover { border-bottom-color: var(--azure); }
.cred-flag { font-size: 0.8em; }

/* ---------- Profile links (LinkedIn / Trailhead), aparte del nombre ---------- */
.cred-profiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
}
.profile-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--navy);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.profile-link svg { width: 15px; height: 15px; flex-shrink: 0; }
.profile-link:hover { background: var(--surface-2); transform: translateY(-1px); }
.profile-linkedin { color: #0a66c2; }
.profile-linkedin:hover { border-color: #0a66c2; }
.profile-trailhead { color: #0d4d8c; }
.profile-trailhead:hover { border-color: #0d4d8c; }

/* ---------- Credential meta ---------- */
.cred-meta {
  margin: 0 0 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}

.meta-cell { background: var(--surface-2); padding: 12px 14px; }
.meta-wide { grid-column: 1 / -1; }

.meta-cell dt {
  margin: 0 0 3px;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.meta-cell dd {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
  word-break: break-word;
}

/* ---------- Actions ---------- */
.cred-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 12px;
}
.cred-actions .btn {
  width: 100%;
  min-width: 0;
}
.btn-label {
  min-width: 0;
  overflow-wrap: anywhere;
}
.cred-actions .span2 { grid-column: 1 / -1; }

.linkedin-hint {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 0 16px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 1.45;
}
.linkedin-hint strong { font-weight: 700; color: var(--ink); }
.hint-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #f59e0b;
}

/* ---------- Skills ---------- */
.cred-skills {
  margin: 0 0 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.cred-skills-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.cred-skills-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--royal);
}
.copy-skills-btn {
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--royal);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
}
.copy-skills-btn:hover { background: var(--surface-2); }
.cred-skills-list { display: flex; flex-wrap: wrap; gap: 7px; }
.skill-chip {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--navy);
  font-family: var(--ui);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.skill-chip:hover { background: #eaf0f9; border-color: var(--line-strong); }

/* ---------- Verify / QR footer ---------- */
.cred-verify {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  margin: 28px 0 0;
  padding: 24px 0 0;
  border-top: 1px dashed var(--line);
}
.qr {
  width: 100%;
  aspect-ratio: 1 / 1;
}
.qr img { width: 100%; height: 100%; display: block; }
.cred-verify-title { margin: 0 0 3px; font-size: 0.95rem; font-weight: 700; color: var(--ink); }

/* ---------- Vista del diploma ---------- */
.cred-diploma { margin: 16px 0 24px; }
.cred-diploma-title {
  margin: 0 0 8px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--royal);
}
.diploma-preview {
  width: 100%;
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-soft);
}
.diploma-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 36px 24px;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  color: var(--muted);
}
.diploma-fallback > svg {
  width: 44px;
  height: 44px;
  color: rgba(12, 39, 159, 0.22);
}
.diploma-fallback > span {
  font-size: 0.82rem;
  line-height: 1.5;
  font-weight: 500;
  max-width: 320px;
}
.diploma-retry {
  min-height: 42px;
  margin-top: 2px;
  padding: 0 14px;
  font-size: 0.82rem;
}

/* ---------- Error state ---------- */
.cred-error { text-align: center; padding: 10px 6px 6px; }
.error-badge {
  width: 60px; height: 60px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
}
.error-badge svg { width: 30px; height: 30px; }
.error-title {
  margin: 0 0 8px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.42rem;
  line-height: 1.16;
  letter-spacing: 0;
  color: var(--ink);
}
.error-msg { margin: 0; font-size: 0.95rem; line-height: 1.55; color: var(--muted); }

#result-reset { margin-top: 14px; }

/* ---------- Footer ---------- */
.foot {
  margin: 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
}

.foot a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.foot a:hover,
.foot a:focus {
  color: var(--navy);
}

/* ---------- Focus visibility ---------- */
:focus-visible {
  outline: 3px solid rgba(17, 157, 216, 0.45);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Motion ---------- */
.result.visible .cred > * { animation: rise 0.45s ease both; }
.result.visible .cred-row { animation-delay: 0.08s; }
.result.visible #cred-hash { animation-delay: 0.14s; }
.result.visible .cred-divider { animation-delay: 0.18s; }
.result.visible .cred-eyebrow { animation-delay: 0.22s; }
.result.visible .cred-name { animation-delay: 0.26s; }
.result.visible .cred-profiles { animation-delay: 0.3s; }
.result.visible .cred-meta { animation-delay: 0.34s; }
.result.visible .cred-actions { animation-delay: 0.38s; }

@keyframes pop-in { from { opacity: 0; transform: scale(0.5); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes validation-spin { to { transform: rotate(360deg); } }
@keyframes validation-check-complete {
  to { background: var(--verified); transform: scale(1); }
}
@keyframes validation-step-complete {
  to { border-color: rgba(31, 157, 107, 0.28); background: rgba(31, 157, 107, 0.08); color: #176449; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .validation-step { border-color: rgba(31, 157, 107, 0.28); background: rgba(31, 157, 107, 0.08); color: #176449; }
  .validation-step svg { background: var(--verified); transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .shell { padding: 16px 12px 28px; justify-content: flex-start; }
  .card { padding: 22px 18px 24px; border-radius: 18px; }
  .validation-splash { min-height: 286px; }
  .validation-steps { gap: 6px; }
  .validation-step {
    padding-inline: 7px;
    font-size: 0.62rem;
    letter-spacing: 0.05em;
  }
  .validation-step svg {
    width: 15px;
    height: 15px;
  }
  .cred-actions { grid-template-columns: 1fr 1fr; }
  .cred-verify { flex-direction: column; text-align: center; gap: 12px; }
  .cred-verify-copy { display: flex; flex-direction: column; align-items: center; }
}

@media (max-width: 380px) {
  .validation-steps { grid-template-columns: 1fr; }
  .cred-actions { grid-template-columns: 1fr; }
  .cred-actions .btn { grid-column: 1 / -1; }
}

@media (min-width: 600px) {
  .shell { padding: 48px 20px 40px; }
  .card { padding: 34px 36px 36px; }
}
