/*
 * Copyright (c) 2026 Aryamind SARL
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* --------------------------------------------------------------------------
 * CarveTrace Verifier — design system
 *
 * Vercel-grade B2B aesthetic: sober, technical, cryptographic-confidence.
 * Vanilla CSS only; no framework, no bundler, no CDN. Webfonts are
 * self-hosted under ./fonts/ and referenced via @font-face below.
 *
 * Inter         — SIL Open Font License 1.1, (c) 2016 The Inter Project Authors.
 *                 Bundled regular (400) + semibold (600) Latin-subset .woff2.
 * JetBrains Mono — SIL Open Font License 1.1, (c) 2020 The JetBrains Mono Project Authors.
 *                 Bundled regular (400) Latin-subset .woff2.
 *
 * Font files live under web/fonts/ as <family>-<weight>.woff2 and are NEVER
 * fetched from a CDN at runtime (CSP `connect-src 'self'` enforces this).
 * If a font file is missing the system fallback stack kicks in.
 * ------------------------------------------------------------------------ */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/Inter-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('./fonts/Inter-SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/JetBrainsMono-Regular.woff2') format('woff2');
}

/* --------------------------------------------------------------------------
 * Variables
 * ------------------------------------------------------------------------ */
:root {
  /* Palette */
  --color-bg: #ffffff;
  --color-fg: #0a0a0a;
  --color-fg-secondary: #666666;
  --color-fg-tertiary: #737373;
  --color-border: #eaeaea;
  --color-border-strong: #e5e5e5;
  --color-border-soft: #f0f0f0;
  --color-surface-hover: #fafafa;
  --color-success: #0a7c3a;
  --color-success-bg: #f0fdf4;
  --color-error: #cf222e;
  --color-error-bg: #fef2f2;
  --color-warning: #9a6700;
  --color-warning-bg: #fffbeb;
  --color-link-underline: #999999;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', "SF Mono", Menlo, monospace;

  /* Spacing — 8px grid */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;

  /* Layout */
  --content-max: 720px;
}

/* --------------------------------------------------------------------------
 * Reset (minimal)
 * ------------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
button { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
ul { padding-left: var(--space-5); }

html {
  background: #fafafa;
  color: var(--color-fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body { background: #fafafa; color: var(--color-fg); }

/* --------------------------------------------------------------------------
 * Card surface — used across every section in the content column so each
 * piece of evidence stands as its own elevated block on the soft-gray page
 * background. Subtle double-layer shadow keeps the depth honest (no
 * dashboard-chrome gradients) and 10px radius matches the wordmark
 * rhythm.
 * ------------------------------------------------------------------------ */
.card {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.03);
}

/* --------------------------------------------------------------------------
 * Typography
 * ------------------------------------------------------------------------ */
h1 {
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 var(--space-2);
}
h2 {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 0 0 var(--space-4);
}
.card > h2:first-child { margin-top: 0; }
.card > h1:first-child { margin-top: 0; }
h3 {
  font-size: 16px;
  font-weight: 600;
  margin: var(--space-6) 0 var(--space-2);
}
p { margin: 0 0 var(--space-3); }
code, .mono, .hash {
  font-family: var(--font-mono);
  font-size: 13px;
}
.hash { word-break: break-all; }

a {
  color: #0a0a0a;
  text-decoration: underline;
  text-decoration-color: #d4d4d4;
  text-underline-offset: 3px;
}
a:hover { text-decoration-color: #0d4f4f; }

/* --------------------------------------------------------------------------
 * Layout — branded header band + centred content column
 *
 * The header band is the full-width brand surface: dark teal fill, white
 * wordmark + tagline, ~96px tall on desktop / 72px on mobile (achieved via
 * 24px vertical padding around a 22px wordmark, 36px / 24px lines stacked).
 * The content area is a max-width: 760px column centred under the band.
 * ------------------------------------------------------------------------ */
.brand-header {
  background: #0d4f4f;
  color: #ffffff;
  padding: 24px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.brand-header__inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
}
.brand-wordmark {
  font-size: 22px;
  letter-spacing: -0.01em;
  line-height: 1;
  color: #ffffff;
}
.brand-wordmark__carve { font-weight: 400; }
.brand-wordmark__trace { font-weight: 700; }
.brand-tagline {
  font-size: 13px;
  opacity: 0.85;
  font-weight: 400;
  color: #ffffff;
}
@media (max-width: 560px) {
  .brand-header__inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .brand-tagline { font-size: 12px; }
}

main.content {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px;
}
.intro {
  color: var(--color-fg-secondary);
  font-size: 15px;
  margin: 0 0 var(--space-6);
}

/* --------------------------------------------------------------------------
 * Drop zone
 *
 * Cohabits with `.card`: the dashed-affordance border layered over the
 * card surface keeps the "drop a file here" affordance legible without
 * fighting the editorial elevation. Hover swaps the surface to a hairline-
 * darker shade rather than collapsing the dashed border.
 * ------------------------------------------------------------------------ */
.drop {
  display: block;
  border: 1.5px dashed #d4d4d4;
  border-radius: 10px;
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  background: #ffffff;
  transition: background 120ms ease, border-color 120ms ease;
}
.drop:hover { background: var(--color-surface-hover); border-color: #0d4f4f; }
.drop.dragover {
  border-style: dashed;
  border-color: #0d4f4f;
  background: var(--color-surface-hover);
}
.drop strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-fg);
  margin-bottom: var(--space-1);
}
.drop p {
  margin: 0;
  color: var(--color-fg-secondary);
  font-size: 14px;
}
.drop input { display: none; }
.privacy {
  margin-top: var(--space-3);
  font-size: 13px;
  color: var(--color-fg-secondary);
  text-align: center;
}

/* --------------------------------------------------------------------------
 * CTA block (spec + brand + commercial)
 * ------------------------------------------------------------------------ */
.cta {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  font-size: 13px;
  color: var(--color-fg-secondary);
  text-align: center;
}
.cta p { margin: var(--space-1) 0; }

/* --------------------------------------------------------------------------
 * Action bar (Print / Copy URL)
 * ------------------------------------------------------------------------ */
.actions {
  display: none;
  margin: var(--space-8) 0 var(--space-2);
  text-align: right;
}
.actions.shown { display: block; }
.actions button {
  font-size: 14px;
  font-weight: 500;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border);
  background: #ffffff;
  color: var(--color-fg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-left: var(--space-2);
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.actions button:hover {
  background: #ffffff;
  border-color: #0d4f4f;
  color: #0d4f4f;
}
.actions button:disabled {
  color: var(--color-fg-tertiary);
  border-color: var(--color-border-soft);
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
 * Evidence panel
 * ------------------------------------------------------------------------ */
#evidence {
  display: none;
  background: var(--color-bg);
  padding: 0;
  animation: fadeIn 200ms ease-out;
}
#evidence.shown { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.evidence-summary { padding: 0; }
.summary-header h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-4);
}

/* Verdict box — the dominant surface of the page. Sized so it visually
 * weighs more than the surrounding cards: 120px min-height, 32x40 padding,
 * 2px coloured border, tinted fill, 24px label. The SVG icon renders at
 * 32x32 (overrides whatever intrinsic size the inline SVG declares). */
.verdict {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: 32px 40px;
  border: 2px solid var(--color-border-strong);
  border-radius: 12px;
  background: #ffffff;
  margin: var(--space-4) 0 var(--space-6);
  min-height: 120px;
  justify-content: center;
}
.verdict-header {
  display: flex;
  align-items: center;
  gap: 16px;
}
.verdict-icon {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  line-height: 0;
}
.verdict-icon svg {
  width: 32px;
  height: 32px;
  display: block;
}
.verdict-label {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.verdict-detail {
  color: #333333;
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
}
.verdict.verified {
  border-color: var(--color-success);
  background: var(--color-success-bg);
}
.verdict.verified .verdict-label { color: var(--color-success); }
.verdict.failed {
  border-color: var(--color-error);
  background: var(--color-error-bg);
}
.verdict.failed .verdict-label { color: var(--color-error); }
.verdict.error {
  border-color: var(--color-warning);
  background: var(--color-warning-bg);
}
.verdict.error .verdict-label { color: var(--color-warning); }

/* Evidence table — 2-col borderless, row separator only */
.evidence-table { width: 100%; }
.evidence-table th,
.evidence-table td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-3) 0;
  border: 0;
  border-bottom: 1px solid var(--color-border-soft);
}
.evidence-table tr:last-child th,
.evidence-table tr:last-child td { border-bottom: 0; }
.evidence-table th {
  width: 38%;
  color: var(--color-fg-secondary);
  font-size: 13px;
  font-weight: 400;
  padding-right: var(--space-4);
}
.evidence-table td {
  font-size: 14px;
  color: var(--color-fg);
}
.evidence-table td .mono,
.evidence-table td .hash,
.evidence-table td code {
  font-size: 13px;
}
.evidence-table .subtitle {
  display: block;
  margin-top: var(--space-1);
  font-size: 13px;
  color: var(--color-fg-secondary);
}
.evidence-table .muted { color: var(--color-fg-secondary); }

/* Checks list — semantic list, no table */
.checks-list {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
}
.checks-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-soft);
  font-size: 14px;
}
.checks-list li:last-child { border-bottom: 0; }
.check-name { color: var(--color-fg); }
.check-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  font-weight: 600;
}
.check-badge.pass { color: var(--color-success); }
.check-badge.fail { color: var(--color-error); }
.check-badge.skip { color: var(--color-fg-secondary); }
.check-badge svg { flex: 0 0 16px; }

/* Attribution / Warnings */
.attribution {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid #fecaca;
  background: var(--color-error-bg);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.attribution strong { color: var(--color-error); }
.warnings {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid #fde68a;
  background: var(--color-warning-bg);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.warnings strong { color: var(--color-warning); }
.warnings ul { margin: var(--space-2) 0 0; }

/* Trust model — restricted measure for readability */
.trust-model p {
  max-width: 65ch;
  color: var(--color-fg);
  font-size: 15px;
  line-height: 1.6;
}
.trust-model .source-link {
  font-size: 13px;
  color: var(--color-fg-secondary);
}

/* Chain visualisation — lives in its own card (.chain-viz-card). The
 * inner .chain-viz host holds the SVG + caption. Height matches the
 * Phase 6 viewBox (600x160) so we don't crop the spotlight or labels. */
.chain-viz {
  margin: 0;
  padding: 0;
}
.chain-viz svg { display: block; width: 100%; height: 160px; }
.chain-caption {
  font-size: 13px;
  color: var(--color-fg-secondary);
  margin: var(--space-3) 0 0;
  text-align: center;
}

/* Verifier metadata card (within evidence panel). The .card class now
 * carries the elevation and spacing; the legacy top-border separator was
 * removed in the editorial pass because each section is its own surface. */
.verifier-footer .evidence-table th { width: 38%; }

/* --------------------------------------------------------------------------
 * Site footer — aerated spacing, low-key colour, kept below the centred
 * content column. Lives directly on the #fafafa page background (no
 * card chrome).
 * ------------------------------------------------------------------------ */
footer.site-footer {
  max-width: 760px;
  margin: 64px auto var(--space-8);
  padding: 0 24px;
  text-align: center;
  font-size: 13px;
  color: #737373;
  line-height: 1.6;
}
footer.site-footer p { margin: var(--space-2) 0; }
footer.site-footer a {
  color: #737373;
  text-decoration-color: #d4d4d4;
}
footer.site-footer a:hover { text-decoration-color: #0d4f4f; color: #0d4f4f; }

/* --------------------------------------------------------------------------
 * Print — strip drop zone / actions / CTA / site footer, leave evidence only.
 * ------------------------------------------------------------------------ */
@media print {
  .brand-header,
  .intro,
  .drop,
  .privacy,
  .cta,
  .actions,
  footer.site-footer { display: none !important; }
  #evidence { display: block !important; padding: 0; animation: none; }
  main, main.content { max-width: none; padding: 0; margin: 0; }
  body { background: #ffffff; }
  .verdict { background: #fff !important; }
}
