/* SecAITech certificate verification */

:root {
  --ink: #16233B;
  --paper: #FAFAF7;
  --surface: #FFFFFF;
  --rule: #D9DCE1;
  --field: #B6BCC6;
  --muted: #5B6472;
  --seal: #1E6B47;
  --seal-soft: #E6F1EA;
  --void: #A4262C;
  --void-soft: #F8E8E8;
  --info-soft: #E9EEF8;
  --focus: #2D5BD7;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.6 var(--sans);
}
a { color: var(--ink); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Page frame ---------- */

.page, .site-foot {
  max-width: 40rem;
  margin: 0 auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}
.page { padding-top: 2rem; }
.page--narrow { max-width: 28rem; }
.page--wide, .admin .site-foot { max-width: 72rem; }
.page--narrow ~ .site-foot { max-width: 28rem; }

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  padding-bottom: 1rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--rule);
}
.wordmark {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -.01em;
  text-decoration: none;
}
.masthead-note { margin: 0; color: var(--muted); font-size: .9375rem; }
.masthead-side { display: flex; align-items: center; gap: 1rem; }
.masthead-side form { margin: 0; }

h1 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -.015em; margin: 0 0 .75rem; }
h2 { font-size: 1.25rem; line-height: 1.3; margin: 0 0 1rem; }
.intro p { color: var(--muted); margin: 0 0 2rem; }

.site-foot {
  margin-top: 4rem;
  padding-bottom: 2.5rem;
  color: var(--muted);
  font-size: .875rem;
}
.site-foot p { margin: 0; padding-top: 1rem; border-top: 1px solid var(--rule); }
.site-foot a { color: inherit; }

/* ---------- The verification record ---------- */

.record {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 4px solid var(--seal);
  padding: 2rem 1.75rem 1.75rem;
  margin-bottom: 2.5rem;
}
.record.is-revoked { border-top-color: var(--void); }
.record.is-missing { border-top-color: var(--muted); }
.record p { margin: 0 0 .75rem; }
.record p:last-child { margin-bottom: 0; }

.record-status { font-size: 1.375rem; margin-bottom: 1.25rem; }
.is-valid .record-status { color: var(--seal); }
.is-revoked .record-status { color: var(--void); }

.record .record-lede { color: var(--muted); margin: 0; }
.record-lede strong { color: var(--ink); font-weight: 600; }

.holder {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: clamp(1.875rem, 6vw, 2.625rem);
  line-height: 1.12;
  letter-spacing: -.01em;
  margin: .35rem 0 .5rem !important;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 1rem 1.5rem;
  margin: 1.75rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}
.facts dt { font-size: .8125rem; color: var(--muted); }
.facts dd { margin: .125rem 0 0; font-weight: 600; }

.cert-id {
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.note {
  background: var(--void-soft);
  border-left: 3px solid var(--void);
  padding: .75rem 1rem;
}

/* The seal: the one memorable element on the page */
.rosette { display: block; width: 112px; height: 112px; margin-bottom: 1.25rem; }
.rosette--valid { color: var(--seal); }
.rosette--revoked { color: var(--void); }
.rosette .petals ellipse { fill: none; stroke: currentColor; stroke-width: .55; opacity: .6; }
.rosette .core { fill: var(--surface); stroke: currentColor; stroke-width: 1.5; }
.rosette .mark { fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }

@media (prefers-reduced-motion: no-preference) {
  .rosette .petals {
    transform-box: fill-box;
    transform-origin: center;
    animation: seal-turn 1.1s cubic-bezier(.2, .7, .2, 1) both;
  }
  .rosette .mark {
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
    animation: seal-mark .45s .75s ease-out forwards;
  }
}
@keyframes seal-turn { from { transform: rotate(-45deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes seal-mark { to { stroke-dashoffset: 0; } }

/* ---------- Forms ---------- */

.lookup label, .field label { display: block; font-weight: 600; margin-bottom: .4rem; }
.lookup-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.lookup-row input { flex: 1 1 14rem; }
.lookup input { text-transform: uppercase; letter-spacing: .04em; }
.lookup input::placeholder { text-transform: none; letter-spacing: normal; }

input[type="text"], input[type="password"], input[type="date"], input[type="file"], select {
  font: inherit;
  color: inherit;
  width: 100%;
  min-width: 0;
  padding: .65rem .8rem;
  background: var(--surface);
  border: 1px solid var(--field);
  border-radius: 6px;
}
.lookup-row input { width: auto; }
input:focus-visible, select:focus-visible { border-color: var(--focus); }

button, .btn {
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  display: inline-block;
  padding: .7rem 1.1rem;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .btn:hover { background: #22345A; }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--field); }
.btn-quiet:hover { background: var(--surface); border-color: var(--ink); }
.btn-danger { background: var(--void); border-color: var(--void); }
.btn-danger:hover { background: #861E23; }
.btn-small { padding: .4rem .7rem; font-size: .875rem; }

.link-btn {
  background: none; border: 0; padding: 0;
  color: var(--ink); font-weight: 500; font-size: .875rem;
  text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { background: none; color: var(--focus); }

.stack { display: flex; flex-direction: column; gap: 1rem; align-items: flex-start; }
.stack > .field, .stack > .field-row { width: 100%; }
.field-row { display: flex; flex-wrap: wrap; gap: 1rem; }
.field.grow { flex: 1 1 12rem; }
.field.short { flex: 0 0 7rem; }
.hint { color: var(--muted); font-size: .875rem; margin: .35rem 0 0; }
.optional { color: var(--muted); font-weight: 400; }

/* ---------- Messages ---------- */

.flash {
  padding: .85rem 1rem;
  border-radius: 6px;
  margin: 0 0 1.25rem;
  background: var(--seal-soft);
  border-left: 4px solid var(--seal);
}
.flash p { margin: 0; }
.flash--error { background: var(--void-soft); border-left-color: var(--void); }
.flash--info { background: var(--info-soft); border-left-color: var(--focus); }
.flash-actions { display: flex; gap: 1.25rem; margin-top: .5rem !important; font-size: .875rem; }

/* ---------- Admin ---------- */

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.5rem;
}
.panel > p { margin: 0 0 1rem; color: var(--muted); }

.listing-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .75rem; }
.count { color: var(--muted); font-weight: 400; margin-left: .35rem; }
.listing-search { margin: .25rem 0 1rem; max-width: 36rem; }
.empty { color: var(--muted); padding: 2rem 0; }

.table-scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th, td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: .8125rem; font-weight: 600; color: var(--muted); background: var(--paper); }
tbody tr:last-child td { border-bottom: 0; }
td.cert-id a { text-decoration: none; }
td.cert-id a:hover { text-decoration: underline; }
.sub { display: block; color: var(--muted); font-size: .8125rem; }
.nowrap { white-space: nowrap; }

.badge {
  display: inline-block;
  font-size: .8125rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 999px;
}
.badge--valid { background: var(--seal-soft); color: var(--seal); }
.badge--revoked { background: var(--void-soft); color: var(--void); }

.actions { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: flex-start; min-width: 14rem; }
.actions form.inline { margin: 0; }
.revoke summary { cursor: pointer; font-size: .875rem; color: var(--void); text-decoration: underline; text-underline-offset: 2px; }
.revoke[open] { flex-basis: 100%; }
.revoke form { margin-top: .6rem; padding: .85rem; background: var(--void-soft); border-radius: 6px; gap: .5rem; }
.revoke label { font-size: .8125rem; font-weight: 600; }

dialog {
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1.5rem;
  max-width: min(24rem, calc(100vw - 2rem));
  color: var(--ink);
}
dialog::backdrop { background: rgba(22, 35, 59, .45); }
dialog h2 { margin-bottom: .25rem; }
.qr-box { background: #fff; padding: .75rem; border: 1px solid var(--rule); border-radius: 6px; margin: .75rem 0; }
.qr-box img, .qr-box canvas { display: block; width: 100%; height: auto; }
.dialog-actions { display: flex; gap: .5rem; margin-top: 1rem; }

/* ---------- Print: a clean record someone can file ---------- */

@media print {
  body { background: #fff; }
  .lookup, .site-foot a { display: none; }
  .record { border-width: 1px; border-top-width: 4px; }
}
