/* Public certificate page.

   The portal's visual language (src/styles/tokens.css): ink on porcelain, one
   petrol accent, quiet chrome. The tokens are restated here rather than imported
   because this site deploys on its own hosting target with no build step — if the
   portal's tokens move, move these with them. Names and headings use the serif of
   the issued certificate itself (Cormorant Garamond), labels the portal's sans.

   Everything is cs-prefixed. The phone layout is the base: one column, the
   certificate between the heading and the facts. From 1024px a verified certificate
   with its image is two columns inside a 1200px frame — the certificate large on the
   left, the facts beside it. Text colours hold 4.5:1 on every surface they sit on;
   --muted-faint is for lines and marks, never for text. */

:root {
    --ink: #1c2025;
    --ink-soft: #3c434c;
    --muted: #667080;
    --muted-faint: #8b93a1;
    --paper: #f4f5f7;
    --surface: #ffffff;
    --surface-sunken: #f7f8fa;
    --line: #e5e7eb;
    --line-strong: #d2d6dc;

    --accent: #14586e;
    --accent-tint: #e9f1f4;
    --ok: #1d7a55;
    --ok-tint: #e7f3ed;
    --danger: #b23b32;
    --danger-tint: #faedec;

    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    --font-serif: "Cormorant Garamond", "Iowan Old Style", Georgia, "Times New Roman", serif;
    --font-mono: "SF Mono", "Menlo", "Consolas", "Liberation Mono", monospace;

    --tracking-caps: 0.08em;
    --tracking-eyebrow: 0.16em;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-1: 0 1px 2px rgba(28, 32, 37, 0.05), 0 1px 3px rgba(28, 32, 37, 0.04);
    --shadow-2: 0 4px 12px rgba(28, 32, 37, 0.08), 0 2px 4px rgba(28, 32, 37, 0.05);
    --shadow-sheet: 0 1px 2px rgba(28, 32, 37, 0.06), 0 12px 32px -12px rgba(28, 32, 37, 0.18);

    --frame: 1200px;
    --gutter: 20px;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

[hidden] {
    display: none !important;
}

p {
    margin: 0;
    text-wrap: pretty;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 2px;
}

.cs-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ── Frame and chrome ─────────────────────────────────────────────────── */

.cs-frame {
    width: 100%;
    max-width: calc(var(--frame) + 2 * var(--gutter));
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.cs-top {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.cs-top-inner {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding-block: 16px;
}

.cs-wordmark {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.cs-top-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--accent);
}

.cs-main {
    flex: 1;
    padding-block: 28px 48px;
}

.cs-foot-inner {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-block: 20px 32px;
    border-top: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--muted);
}

.cs-foot a {
    align-self: flex-start;
    color: var(--ink-soft);
    text-decoration: none;
    border-bottom: 1px solid var(--line-strong);
}

.cs-foot a:hover {
    color: var(--ink);
    border-bottom-color: var(--ink-soft);
}

/* ── The certificate ──────────────────────────────────────────────────── */

.cs-cert {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
        "head"
        "figure"
        "facts";
    max-width: 640px;
    margin-inline: auto;
}

.cs-cert-head {
    grid-area: head;
    min-width: 0;
}

.cs-figure {
    grid-area: figure;
    min-width: 0;
    margin: 32px 0 0;
}

.cs-cert-facts {
    grid-area: facts;
    min-width: 0;
    margin-top: 32px;
}

/* The verdict: a plain line for a verified certificate, a tinted band for a
   revoked one, which is the case a reader must not miss. */

.cs-verdict {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 22px;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--line);
}

.cs-verdict--revoked {
    padding: 14px 16px;
    border: 1px solid #efd3d0;
    border-radius: var(--radius-md);
    background: var(--danger-tint);
}

.cs-verdict-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    margin-top: 1px;
    border-radius: 50%;
    background: var(--ok);
    color: #fff;
}

.cs-verdict--revoked .cs-verdict-icon {
    background: var(--danger);
}

.cs-verdict-icon svg {
    width: 14px;
    height: 14px;
}

.cs-verdict .cs-icon-revoked,
.cs-verdict--revoked .cs-icon-ok {
    display: none;
}

.cs-verdict--revoked .cs-icon-revoked {
    display: block;
}

.cs-verdict-title {
    font-size: 14px;
    font-weight: 650;
    line-height: 1.4;
    color: var(--ok);
}

.cs-verdict--revoked .cs-verdict-title {
    color: var(--danger);
}

.cs-verdict-note {
    margin-top: 2px;
    max-width: 46ch;
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
}

.cs-verdict--revoked .cs-verdict-note {
    max-width: none;
    color: var(--ink-soft);
}

.cs-eyebrow,
.cs-label {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: var(--tracking-eyebrow);
    color: var(--muted);
}

.cs-title {
    margin: 6px 0 0;
    font-family: var(--font-serif);
    font-size: 36px;
    font-weight: 600;
    line-height: 1.08;
    letter-spacing: -0.005em;
    color: var(--ink);
    overflow-wrap: break-word;
    text-wrap: balance;
}

.cs-holder {
    margin-top: 28px;
}

.cs-name {
    margin-top: 4px;
    font-family: var(--font-serif);
    font-size: 28px;
    font-weight: 500;
    line-height: 1.15;
    color: var(--ink);
    overflow-wrap: break-word;
}

.cs-programme {
    margin-top: 18px;
}

.cs-structure {
    margin-top: 4px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--ink-soft);
    overflow-wrap: break-word;
}

.cs-honours {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 22px;
    font-family: var(--font-serif);
    font-size: 21px;
    font-style: italic;
    font-weight: 500;
    line-height: 1.2;
    color: var(--ink);
}

.cs-honours::before {
    content: "";
    flex: none;
    width: 28px;
    border-top: 1px solid var(--line-strong);
}

/* The certificate image keeps its own aspect ratio; the shadow lifts it off the
   paper like a sheet, and clicking it opens the full-size file. */

.cs-figure-link {
    display: block;
    cursor: zoom-in;
}

.cs-figure img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--line);
    border-radius: 2px;
    background: #fff;
    box-shadow: var(--shadow-sheet);
}

.cs-figure-caption {
    margin-top: 12px;
    font-size: 12.5px;
    text-align: right;
}

.cs-figure-caption a {
    color: var(--muted);
    text-decoration: none;
    border-bottom: 1px solid var(--line-strong);
}

.cs-figure-caption a:hover {
    color: var(--ink);
    border-bottom-color: var(--ink-soft);
}

/* The facts: one label and one value per row, ruled like a ledger. */

.cs-facts {
    margin: 0;
    border-top: 1px solid var(--line);
}

.cs-fact {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    align-items: baseline;
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
}

.cs-fact dt {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--muted);
}

.cs-fact dd {
    margin: 0;
    min-width: 0;
    font-size: 14.5px;
    font-weight: 550;
    color: var(--ink);
}

.cs-id {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
}

.cs-mono {
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-soft);
    overflow-wrap: anywhere;
}

.cs-copy {
    flex: none;
    min-width: 64px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink-soft);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 550;
    cursor: pointer;
    transition: border-color 140ms ease, color 140ms ease;
}

.cs-copy:hover {
    border-color: var(--muted-faint);
    color: var(--ink);
}

.cs-actions {
    margin-top: 28px;
}

.cs-actions-note {
    margin-top: 10px;
    font-size: 12.5px;
    color: var(--muted);
}

.cs-note {
    margin-top: 24px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    font-size: 13px;
    color: var(--ink-soft);
}

/* ── Buttons ──────────────────────────────────────────────────────────── */

.cs-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink-soft);
    font-family: inherit;
    font-size: 14px;
    font-weight: 550;
    text-decoration: none;
    cursor: pointer;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.cs-btn:hover {
    background: var(--surface-sunken);
    border-color: var(--muted-faint);
    color: var(--ink);
}

.cs-btn--primary {
    width: 100%;
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

.cs-btn--primary:hover {
    background: #000;
    border-color: #000;
    color: #fff;
}

.cs-btn svg {
    width: 15px;
    height: 15px;
}

/* ── Loading, missing, error ──────────────────────────────────────────── */

.cs-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 560px;
    margin: 4vh auto 0;
    padding: 44px 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    text-align: center;
}

.cs-state p {
    max-width: 44ch;
    font-size: 14.5px;
    color: var(--muted);
}

.cs-state-title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 30px;
    font-weight: 600;
    line-height: 1.15;
    color: var(--ink);
    text-wrap: balance;
}

.cs-state-title--quiet {
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 500;
    color: var(--muted);
}

.cs-state-aside {
    margin-top: 4px !important;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 13px !important;
}

.cs-state .cs-btn {
    margin-top: 8px;
}

.cs-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--line);
    border-top-color: var(--ink);
    border-radius: 50%;
    animation: cs-spin 0.9s linear infinite;
}

@keyframes cs-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Wider than a phone ───────────────────────────────────────────────── */

@media (min-width: 600px) {
    :root {
        --gutter: 32px;
    }

    .cs-top-inner {
        padding-block: 18px;
    }

    .cs-main {
        padding-block: 48px 64px;
    }

    .cs-foot-inner {
        flex-direction: row;
        justify-content: space-between;
        align-items: baseline;
        gap: 24px;
    }

    .cs-foot a {
        align-self: auto;
    }

    .cs-title {
        font-size: 44px;
    }

    .cs-name {
        font-size: 32px;
    }

    .cs-btn--primary {
        width: auto;
    }

    .cs-state {
        margin-top: 8vh;
        padding: 56px 48px;
    }
}

/* ── Desktop: the certificate is the hero ─────────────────────────────── */

@media (min-width: 1024px) {
    :root {
        --gutter: 40px;
    }

    .cs-main {
        padding-block: 56px 80px;
    }

    .cs-cert--with-figure {
        grid-template-columns: minmax(0, 1.65fr) minmax(340px, 1fr);
        grid-template-rows: auto 1fr;
        grid-template-areas:
            "figure head"
            "figure facts";
        column-gap: 72px;
        max-width: none;
        align-items: start;
    }

    .cs-cert--with-figure .cs-figure {
        margin-top: 0;
    }

    .cs-cert--with-figure .cs-cert-facts {
        margin-top: 36px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cs-spinner {
        animation-duration: 3s;
    }

    .cs-btn,
    .cs-copy {
        transition: none;
    }
}
