@charset "UTF-8";

@layer dialogs {
  /* Single source of truth for certificate query, report, search & WeChat dialogs */
  .service-overlay {
    position: fixed;
    inset: 0;
    z-index: 220;
    background: #090f17a8;
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 25px;
    overflow: auto;
  }
  .service-overlay[data-kind="cert"] {
    --senior-body: max(24px, 1.5rem);
    top: var(--cert-visible-top, 0px);
    bottom: auto;
    height: var(--cert-visible-height, 100dvh);
    box-sizing: border-box;
    align-items: flex-start;
    overscroll-behavior: contain;
    overflow-anchor: none;
  }
  .service-overlay:has(> .service-dialog.dialog-character-surface) {
    top: var(--dialog-character-window-top, 0px);
    bottom: auto;
    height: var(--dialog-character-window-height, 100dvh);
    padding-block: 25px;
    align-items: center;
    overflow: hidden;
  }
  @media (min-width: 601px) {
    .service-overlay[data-kind="cert"] {
      scrollbar-gutter: stable both-edges;
      padding-block-start: clamp(25px, calc((100dvh - 640px) / 2), 14dvh);
    }
    .service-overlay[data-kind="cert"]:has(> .service-dialog.dialog-character-surface) {
      padding-block: 25px;
    }
  }

  .service-dialog {
    --surface: #101a27;
    --surface-raised: #172332;
    --text: #f0ede8;
    --muted: #b9bec7;
    --accent: #e9bd98;
    --line: #ffffff26;
    width: 560px;
    max-width: 100%;
    max-height: calc(100dvh - 50px);
    overflow-y: auto;
    padding: 38px;
    background: var(--surface);
    color: #f2ede4;
    color-scheme: dark;
    border: 1px solid #544d43;
    border-radius: 3px;
    box-shadow: 0 35px 150px #0006;
  }
  .service-overlay[data-kind="search"] .service-dialog { width: 740px; }
  .service-overlay[data-kind="cert"] > .service-dialog:not(.dialog-character-surface) {
    margin-block: 0;
    max-height: none;
    overflow: clip;
  }
  .service-overlay[data-report-step] .service-dialog:not(.dialog-character-surface) {
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* Carbon character matrix backing surface */
  .service-dialog.dialog-character-surface {
    position: relative;
    isolation: isolate;
    background: #0a0c10;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(var(--dialog-character-window-height, 100dvh) - 50px);
  }
  .service-dialog.dialog-character-surface > .service-panel {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    max-height: inherit;
    padding: 38px;
    background: transparent;
  }
  .interaction-nav-panel.dialog-character-surface,
  .menu-open #main-nav.dialog-character-surface {
    isolation: isolate;
    background: #0a0c10;
  }
  .menu-open #main-nav.dialog-character-surface .interaction-nav-panel { background: transparent; }
  .dialog-character-surface > .dialog-character-paper {
    position: absolute;
    inset: 0 0 auto;
    height: var(--dialog-character-height, 100%);
    transform: translateY(var(--dialog-character-scroll, 0px));
    overflow: hidden;
    border-radius: inherit;
    z-index: -1;
    pointer-events: none;
    user-select: none;
  }
  .dialog-character-paper > canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
  }

  /* Header, close button & descriptions */
  .service-dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 25px;
    margin-bottom: 24px;
  }
  .service-dialog-header h2 {
    font-size: 28px;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
  .service-dialog-header .service-eyebrow {
    font-size: 14px;
    line-height: 1.6;
    letter-spacing: .14em;
    color: var(--accent);
    margin: 0 0 10px;
  }
  .service-dialog .service-close {
    position: relative;
    display: grid;
    place-items: center;
    flex: none;
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #d9cdbb;
    cursor: pointer;
  }
  .service-dialog .service-close::before,
  .service-dialog .service-close::after {
    content: "";
    grid-area: 1 / 1;
    width: 18px;
    height: 1px;
    background: currentColor;
    transform: rotate(45deg);
    transition: transform .36s ease, width .36s ease;
  }
  .service-dialog .service-close::after { transform: rotate(-45deg); }
  .service-dialog .service-close:is(:hover, :focus-visible) { background: transparent; color: #ffe1b5; }
  @media (prefers-reduced-motion: no-preference) {
    .service-dialog .service-close:is(:hover, :focus-visible)::before { width: 16px; transform: rotate(135deg); }
    .service-dialog .service-close:is(:hover, :focus-visible)::after { width: 16px; transform: rotate(45deg); }
  }

  .service-description {
    font-size: var(--reading-body);
    line-height: 1.85;
    color: var(--muted);
    margin: 10px 0 25px;
  }
  .service-dialog .certificate-query-hint {
    font-size: 14px;
    line-height: 1.7;
    color: #acb5c0;
    margin: 0 0 16px;
  }
  .service-dialog .certificate-privacy-note,
  .service-dialog .report-purpose {
    margin: 14px 0 0;
    color: #acb5c0;
    font-size: .82rem;
    line-height: 1.65;
  }
  .service-dialog .certificate-privacy-note a,
  .service-dialog .report-purpose a {
    color: inherit;
    text-underline-offset: .15em;
    white-space: nowrap;
  }
  .service-dialog .certificate-privacy-note a { text-decoration-line: underline; }

  /* Form controls, results & QR */
  .service-form { display: grid; gap: 20px; }
  .service-field label {
    display: block;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 10px;
    color: var(--muted);
  }
  .service-dialog .service-field input {
    width: 100%;
    padding: 15px;
    background: #0b1420;
    border: 1px solid #ffffff38;
    border-radius: 0;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
  }
  .service-dialog .service-search-input {
    width: 100%;
    padding: 15px 0;
    background: #0b1420;
    border: 0;
    border-bottom: 1px solid #ffffff38;
    border-radius: 0;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
  }
  .service-dialog input::placeholder { color: #929eae; opacity: 1; }
  .service-dialog input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

  .service-dialog .service-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 13px;
    min-height: 60px;
    padding: 16px;
    margin-top: 5px;
    font-size: var(--reading-action);
    line-height: 1.6;
    background: var(--amber-gold);
    color: var(--cta-fg);
    border: 1px solid transparent;
  }
  .service-dialog .service-submit:disabled { opacity: .5; }
  .service-dialog .service-link {
    display: block;
    padding: 16px;
    min-height: 48px;
    text-align: center;
    font-size: var(--reading-action);
    line-height: 1.6;
    margin-top: 25px;
    background: #304359;
    border: 1px solid #796c5c;
    color: #f2ede4;
  }
  .service-dialog .service-link:is(:hover, :focus-visible) {
    background: #3b5069;
    border-color: #d5b599aa;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 6px;
  }
  .service-dialog :is(.service-submit, .service-link):focus-visible {
    outline: 2px solid #e9bd98;
    outline-offset: 4px;
  }

  .service-dialog .service-status {
    font-size: var(--reading-body);
    line-height: 1.85;
    margin-top: 25px;
    padding: 15px;
    background: #20382f;
    color: #ceeadb;
  }
  .service-dialog .service-status[data-state="error"],
  .service-dialog .service-status[data-state="expired"] {
    background: #432b29;
    color: #ffccba;
  }
  .service-status-title { display: flex; align-items: center; gap: 12px; }
  .result-icon {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    animation: result-pop .48s cubic-bezier(.2, 1.6, .4, 1) both;
  }
  .result-icon.success { stroke: #8cdeb2; filter: drop-shadow(0 0 6px #8cdeb244); }
  .result-icon.failure { stroke: #ed9199; filter: drop-shadow(0 0 6px #ed919933); }
  .result-icon circle { stroke-dasharray: 82; stroke-dashoffset: 82; animation: result-draw .45s ease-out forwards; }
  .result-icon path { stroke-dasharray: 32; stroke-dashoffset: 32; animation: result-draw .4s ease-out .25s forwards; }
  .result-icon.failure path:last-child { animation-delay: .4s; }
  @keyframes result-draw { to { stroke-dashoffset: 0; } }
  @keyframes result-pop {
    0% { transform: scale(.65); opacity: 0; }
    70% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
  }

  .service-cert-fields {
    font-size: 16px;
    line-height: 1.8;
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 15px 10px;
    margin-top: 25px;
  }
  .service-cert-fields dt { color: var(--muted); }
  .service-cert-fields dd { margin: 0; overflow-wrap: anywhere; }
  .service-cert-note { color: var(--muted); }
  .service-cert-image {
    display: block;
    margin-top: 25px;
    text-align: center;
    font-size: var(--reading-meta);
    line-height: 1.7;
    color: var(--accent);
  }
  .service-cert-image img { max-height: 350px; margin: auto; object-fit: contain; }
  .service-cert-image span { display: block; padding: 13px; }
  .cert-image-guard {
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  .cert-image-guard::after { content: ""; position: absolute; inset: 0; }
  .cert-image-guard img { pointer-events: none; display: block; width: auto; max-width: 100%; height: auto; }

  /* Search results */
  .service-dialog .service-search-results { display: block; margin-top: 20px; }
  .service-dialog button.service-search-result {
    display: grid;
    width: 100%;
    text-align: left;
    gap: 5px;
    padding: 14px 4px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid #564b3d;
    border-radius: 0;
    box-shadow: none;
    color: #f2ede4;
  }
  .service-dialog button.service-search-result:is(:hover, :focus-visible) { background: #171b21; }
  .service-dialog button.service-search-result strong { display: block; font-size: 17px; line-height: 1.65; font-weight: 500; color: var(--ink-primary); }
  .service-dialog button.service-search-result small { display: block; font-size: var(--reading-meta); line-height: 1.7; margin: 6px 0; color: var(--amber-gold); }
  .service-dialog button.service-search-result p { font-size: var(--reading-body); line-height: 1.85; color: #c7c4be; }
  .service-overlay[data-kind="search"] .service-search-result p {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  .service-empty { font-size: var(--reading-body); color: var(--muted); padding: 25px 0; line-height: 1.85; }

  /* WeChat QR reticle */
  .qr-reticle {
    --corner: linear-gradient(var(--amber-gold), var(--amber-gold));
    box-sizing: border-box;
    width: min(224px, 100%);
    margin: 20px auto 26px;
    padding: 11px;
    background:
      var(--corner) left top / 14px 1px, var(--corner) left top / 1px 14px,
      var(--corner) right top / 14px 1px, var(--corner) right top / 1px 14px,
      var(--corner) left bottom / 14px 1px, var(--corner) left bottom / 1px 14px,
      var(--corner) right bottom / 14px 1px, var(--corner) right bottom / 1px 14px;
    background-repeat: no-repeat;
  }
  .qr-reticle[data-qr="enterprise"] { --poster-width: 206.25%; --poster-x: -53.125%; --poster-y: -30.2632%; }
  .qr-reticle[data-qr="official"] { --poster-width: 173.5593%; --poster-x: -37.7966%; --poster-y: -50.1695%; }
  .qr-face { box-sizing: border-box; width: 100%; aspect-ratio: 1; padding: 9.5%; background: #fff; }
  .qr-symbol { position: relative; display: block; width: 100%; aspect-ratio: 1; overflow: hidden; }
  .service-dialog .qr-reticle .service-qr {
    position: absolute;
    display: block;
    left: var(--poster-x);
    top: var(--poster-y);
    width: var(--poster-width);
    max-width: none;
    height: auto;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }

  /* Report flow */
  .service-overlay[data-kind="cert"][data-report-step] .service-dialog .service-panel > :not(.report-sheet),
  .service-overlay[data-report-step] .service-panel > :not(.report-sheet) { display: none; }
  .service-dialog .report-sheet { min-width: 0; background: transparent; }
  .service-dialog #report-heading[tabindex="-1"]:focus { outline: none; box-shadow: none; }
  .report-choices,
  .report-form { display: grid; gap: 12px; }
  .report-sheet .service-field { display: grid; gap: 6px; min-width: 0; }
  .report-sheet textarea {
    font: inherit;
    color: inherit;
    background: #101116;
    border: 1px solid #504957;
    padding: 12px;
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
  }
  .report-sheet textarea.report-wrap-field {
    field-sizing: content;
    line-height: 1.5;
    min-height: calc(1.5em + 26px);
    min-width: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    resize: none;
  }
  .report-sheet input[type="file"] { width: 100%; white-space: normal; }
  .report-form input[type="file"]:disabled { opacity: .48; pointer-events: none; filter: grayscale(1); }
  .report-sheet .report-help,
  .report-message { font-size: 14px; line-height: 1.6; }
  .report-sheet .report-message:empty { display: none; }
  .report-sheet .report-back {
    display: block;
    width: fit-content;
    min-height: 44px;
    margin: 0 auto 0 0;
    padding-left: 0;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
  }
  .report-entry:focus-visible,
  .report-sheet button:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
  .service-dialog .report-entry[data-liquid],
  .service-dialog .report-sheet [data-liquid] {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 9px;
    width: 100%;
    min-height: 44px;
    padding: 8px 0;
    margin: 7px 0 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    color: #dfd5c7;
    font: 14px/1.6 var(--editorial-sans);
    text-align: left;
    cursor: pointer;
  }
  .service-dialog .report-entry[data-liquid]:is(:hover, :focus-visible) { color: #ffc4b2; }
  .service-dialog .report-dot {
    display: block;
    flex: none;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #c63c35;
  }
  .service-dialog .report-upload {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
    min-height: 50px;
    padding: 10px 14px;
    border: 1px dashed #aa855b;
    border-radius: 0;
    background: #101318;
    color: #f2ede4;
    font: 500 14px/1.6 var(--editorial-sans);
    text-align: left;
    cursor: pointer;
  }
  .report-upload .report-upload-count { color: #e9bd8e; font-size: .9em; }
  .service-dialog .report-upload[aria-disabled="true"] { border-color: #72675a; color: #c5c1ba; cursor: default; }
  .service-dialog .report-upload:focus-visible { outline: 2px solid var(--amber-gold); outline-offset: 2px; }
  .report-form .report-image-choice {
    display: flex;
    align-items: flex-start;
    gap: .6em;
    font-size: .9rem;
    line-height: 1.5;
    cursor: pointer;
  }
  .report-form .report-image-choice input[type="checkbox"] {
    font: inherit;
    box-sizing: border-box;
    width: 1.1em;
    height: 1.1em;
    min-height: 0;
    margin: 0;
    margin-block-start: .2em;
    padding: 0;
    flex: none;
    accent-color: #e89861;
  }
  .report-form .report-image-choice input:focus { outline: 2px solid #e89861; outline-offset: 3px; }
  .report-form .report-image-choice input:focus:not(:checked) { outline-color: #ff7078; }

  /* Solid legibility pillows behind report form text over carbon matrix */
  .service-dialog .report-sheet:has(> .report-form) :is(
    .service-dialog-header h2,
    .service-description,
    .service-field > span:not([aria-hidden]),
    .report-image-choice,
    .report-help,
    .report-message,
    .report-purpose
  ) {
    width: fit-content;
    max-width: 100%;
    background-color: #10141b;
    border-radius: 3px;
    box-shadow: 0 0 0 3px #10141b, 0 0 9px 4px #10141b99;
  }
  .service-dialog .report-form .service-field:has(input[type="file"]) { background-color: #10141b; }

  /* Senior mode (desktop, tablet & mobile) */
  .service-overlay[data-kind="cert"] .service-dialog .cert-senior-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: fit-content;
    min-height: 44px;
    margin: 0 0 16px;
    padding: 4px 2px;
    border: 0;
    border-bottom: 1px solid #877969;
    border-radius: 0;
    background: transparent;
    color: #d5ccc0;
    font: 600 15px/1.5 system-ui, sans-serif;
  }
  .cert-senior-toggle:focus-visible { outline: 2px solid #edc8a6; outline-offset: 2px; }
  .service-dialog .cert-senior-toggle::before {
    content: "";
    flex: none;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #837e76;
  }
  .service-overlay[data-kind="cert"] .service-dialog .cert-senior-toggle[aria-pressed="true"] {
    font-size: var(--senior-body);
    border-bottom-color: var(--amber-gold);
    color: #f6d3a5;
  }
  .service-dialog .cert-senior-toggle[aria-pressed="true"]::before { background: #edbd81; }

  .service-overlay[data-kind="cert"][data-senior="true"] .service-dialog {
    font-size: var(--senior-body);
    line-height: 1.65;
    overflow-wrap: anywhere;
  }
  .service-overlay[data-senior="true"][data-kind="cert"] :is(
    .service-dialog-header h2,
    .service-field,
    .service-field label,
    .service-field span,
    .service-field input,
    .service-field textarea,
    .service-description,
    .service-cert-note,
    .report-message,
    .report-image-choice,
    .service-submit,
    .service-link
  ) {
    font-size: var(--senior-body);
    line-height: 1.55;
  }
  .service-overlay[data-senior="true"][data-kind="cert"] :is(
    .service-eyebrow,
    .certificate-query-hint,
    .certificate-privacy-note,
    .report-purpose,
    .report-help
  ) {
    font-size: var(--senior-body);
    line-height: 1.65;
  }
  .service-overlay[data-senior="true"][data-kind="cert"] .service-cert-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    font-size: var(--senior-body);
    line-height: 1.55;
  }
  .service-overlay[data-senior="true"][data-kind="cert"] .service-cert-fields dt { font-size: inherit; }
  .service-overlay[data-senior="true"][data-kind="cert"] .service-cert-fields dd { font-size: inherit; margin: 0 0 .6em; font-weight: 600; }
  .service-overlay[data-senior="true"][data-kind="cert"] .service-status-title { font-size: var(--senior-body); line-height: 1.5; }
  .service-overlay[data-senior="true"][data-kind="cert"] :is(button, .service-link, .service-field input:not([type="checkbox"])) { min-height: 48px; }
  .service-overlay[data-senior="true"][data-kind="cert"] .service-close { min-width: 48px; }

  /* Responsive dialogs */
  @media (max-width: 600px) {
    .service-overlay { padding: 14px; }
    .service-overlay:has(> .service-dialog.dialog-character-surface) { padding-block: 14px; }
    .service-dialog { padding: 27px 23px; max-height: calc(100dvh - 28px); }
    .service-dialog.dialog-character-surface {
      padding: 0;
      max-height: calc(var(--dialog-character-window-height, 100dvh) - 28px);
    }
    .service-dialog.dialog-character-surface > .service-panel { padding: 27px 23px; }
    .service-overlay[data-kind="cert"] .service-dialog.dialog-character-surface > .service-panel { padding: 16px 18px; }
    .service-dialog-header { gap: 14px; }
    .service-dialog-header h2 { font-size: 23px; }
    .service-close { flex-shrink: 0; }
    .service-description,
    .service-empty,
    .service-search-result p,
    .service-status { font-size: 16px; }
    .service-cert-fields { grid-template-columns: 82px minmax(0, 1fr); font-size: 16px; gap: 12px 8px; }
    .report-sheet textarea.report-wrap-field { font-size: 16px; min-height: calc(3em + 26px); }
    .service-overlay[data-kind="cert"] .service-dialog-header { margin-bottom: 10px; }
    .service-overlay[data-kind="cert"] .service-description { margin: 4px 0 10px; }
    .service-overlay[data-kind="cert"] .service-dialog .cert-senior-toggle { margin-bottom: 8px; }
    .service-overlay[data-kind="cert"] .service-panel > .service-form { gap: 10px; }
    .service-overlay[data-kind="cert"] .service-field label { margin-bottom: 5px; }
    .service-overlay[data-kind="cert"] .certificate-query-hint { margin-bottom: 0; }
    .service-overlay[data-kind="cert"] .certificate-privacy-note { margin-top: 8px; }
  }
  @media (max-width: 359px) {
    .service-dialog { padding: 26px 20px; }
    .service-cert-fields { grid-template-columns: 1fr; gap: 4px; }
    .service-cert-fields dd { margin-bottom: 12px; }
  }
  @media (prefers-reduced-motion: reduce) {
    .result-icon,
    .result-icon circle,
    .result-icon path { stroke-dashoffset: 0; }
  }
}
