/* =========================================================
   PIGOMENTRY — Design System
   D1 Swiss Utility · D2 geometric sans + mono results
   D3 10-12px uniform corners · D4 monochrome + violet accent
   D5 live data-strip, count-up results · D6 soft shadow
   ========================================================= */

:root {
  --bg: #FAFAF8;
  --bg-alt: #F1F0EC;
  --surface: #FFFFFF;
  --ink: #14151A;
  --ink-soft: #55565E;
  --ink-faint: #6E6E6E; /* darkened from #86878E — original failed WCAG AA (3.42:1) against --bg; this passes 4.87:1 */
  --border: #E1DED5;
  --border-strong: #C9C5B9;

  --accent: #6C5CE7;
  --accent-dark: #5642D6;
  --accent-ink: #FFFFFF;
  --accent-soft: #EFEBFF;
  --accent-soft-border: #D9D2FA;

  --success: #157A3E; /* darkened from #1F9D55 — original only reached 3.15:1 on --success-soft and 3.49:1 for white-on-success text; this reaches 4.87:1 / 5.40:1 */
  --success-soft: #E7F7ED;
  --danger: #B83232; /* darkened from #D64545 — original only reached 3.76:1 on --danger-soft and 4.38:1 on white; this reaches 5.10:1 / 5.93:1 */
  --danger-soft: #FBEAEA;

  --radius: 11px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(20, 21, 26, 0.05);
  --shadow-md: 0 2px 10px rgba(20, 21, 26, 0.07), 0 1px 3px rgba(20, 21, 26, 0.05);
  --shadow-lg: 0 8px 28px rgba(20, 21, 26, 0.10), 0 2px 6px rgba(20, 21, 26, 0.06);

  --font-sans: -apple-system, "Segoe UI", "Inter", ui-sans-serif, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --measure: 68ch;
  --header-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img, svg, canvas { max-width: 100%; display: block; }

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 1.5rem + 1.6vw, 2.6rem); }
h2 { font-size: clamp(1.4rem, 1.2rem + 0.9vw, 1.9rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; max-width: var(--measure); }
p:last-child { margin-bottom: 0; }

code, .mono, .result-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--ink); color: #fff; padding: 10px 16px;
  border-radius: 0 0 8px 0; z-index: 200;
}
.skip-link:focus { left: 0; }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}
.container--narrow { max-width: 820px; }

/* ---------- Header / Nav (minimal top + footer links, S6) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(250, 250, 248, 0.92);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: conic-gradient(from 210deg, #6C5CE7, #FF6B9A, #FFC85E, #4CD0A6, #6C5CE7);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.main-nav { display: flex; align-items: center; gap: 22px; }
.main-nav a { color: var(--ink-soft); font-weight: 600; font-size: 0.94rem; }
.main-nav a:hover { color: var(--ink); text-decoration: none; }
.main-nav details { position: relative; }
.main-nav summary { list-style: none; cursor: pointer; color: var(--ink-soft); font-weight: 600; font-size: 0.94rem; display: flex; align-items: center; gap: 4px; }
.main-nav summary::-webkit-details-marker { display: none; }
.main-nav details[open] summary { color: var(--ink); }
.nav-dropdown {
  position: absolute; top: calc(100% + 10px); left: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 8px; min-width: 220px;
}
.nav-dropdown a { display: block; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--ink); font-weight: 500; font-size: 0.92rem; }
.nav-dropdown a:hover { background: var(--accent-soft); text-decoration: none; }

.nav-toggle {
  display: none; background: var(--surface); border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm); width: 44px; height: 44px; cursor: pointer;
  align-items: center; justify-content: center; font-size: 1.1rem;
}

@media (max-width: 760px) {
  .main-nav {
    display: none; position: fixed; inset: var(--header-h) 0 0 0; background: var(--bg);
    flex-direction: column; align-items: flex-start; gap: 4px; padding: 18px 20px; overflow-y: auto; z-index: 90;
  }
  .main-nav.open { display: flex; }
  .main-nav a, .main-nav summary { width: 100%; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 1rem; }
  .main-nav details { width: 100%; }
  .nav-dropdown { position: static; box-shadow: none; border: none; padding: 0 0 0 12px; }
  .nav-toggle { display: inline-flex; }
}

/* Breadcrumbs */
.breadcrumbs { font-size: 0.85rem; color: var(--ink-faint); padding: 14px 0 0; }
.breadcrumbs a { color: var(--ink-faint); }
.breadcrumbs a:hover { color: var(--accent-dark); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-sans); font-weight: 700; font-size: 0.92rem;
  padding: 10px 18px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
  min-height: 44px;
  transition: transform 0.06s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; box-shadow: var(--shadow-md); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--bg-alt); text-decoration: none; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 22px;
}

.tool-card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
  height: 100%;
}
.tool-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: var(--accent-soft-border); text-decoration: none; }
.tool-card-icon {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; background: var(--accent-soft); border: 1px solid var(--accent-soft-border);
}
.tool-card h3 { margin-bottom: 2px; color: var(--ink); }
.tool-card p { color: var(--ink-soft); font-size: 0.92rem; margin: 0; }
.tool-card .tag { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent-dark); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }

/* ---------- Form controls ---------- */
label { display: block; font-weight: 700; font-size: 0.85rem; margin-bottom: 6px; color: var(--ink); }
input[type="text"], input[type="number"], input[type="email"], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong); background: var(--surface);
  font-family: var(--font-mono); font-size: 0.95rem; color: var(--ink);
  min-height: 44px;
}
textarea { font-family: var(--font-sans); min-height: 88px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="color"] { width: 56px; height: 44px; padding: 3px; border-radius: var(--radius-sm); border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > * { flex: 1; min-width: 140px; }
.hint { font-size: 0.8rem; color: var(--ink-faint); margin-top: 5px; }
.error-msg { font-size: 0.82rem; color: var(--danger); margin-top: 5px; display: none; }
.error-msg.show { display: block; }
input.invalid, select.invalid { border-color: var(--danger); }

/* ---------- Tool workspace layout ---------- */
.tool-hero { padding: 34px 0 22px; border-bottom: 1px solid var(--border); background: var(--bg-alt); }
.tool-hero .eyebrow { font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-dark); margin-bottom: 8px; }
.tool-hero p { color: var(--ink-soft); }

.workspace { padding: 32px 0; }
.workspace-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 820px) { .workspace-grid { grid-template-columns: 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-sm); }
.panel h2 { font-size: 1.02rem; margin-bottom: 14px; }

/* D5 — live data-strip ticker */
.data-strip {
  display: flex; gap: 0; overflow-x: auto; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--ink); margin: 18px 0;
}
.data-strip .cell {
  flex: 1; min-width: 110px; padding: 12px 14px; border-right: 1px solid rgba(255,255,255,0.08);
  color: #fff;
}
.data-strip .cell:last-child { border-right: none; }
.data-strip .cell .k { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: rgba(255,255,255,0.55); margin-bottom: 3px; }
.data-strip .cell .v { font-family: var(--font-mono); font-size: 0.95rem; font-variant-numeric: tabular-nums; }

/* Result blocks */
.result-block { background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.result-block .result-value { font-size: 1.02rem; font-weight: 600; }
.copy-btn { flex-shrink: 0; }
.copy-btn.copied { background: var(--success); border-color: var(--success); color: #fff; }

.swatch { border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }

/* D5 — count-up numeric transitions */
.count-up { transition: color 0.2s ease; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 800; padding: 5px 11px; border-radius: 999px; }
.badge-pass { background: var(--success-soft); color: var(--success); }
.badge-fail { background: var(--danger-soft); color: var(--danger); }

/* ---------- Content / reference article pages ---------- */
.article { padding: 40px 0 60px; }
.article .lede { font-size: 1.08rem; color: var(--ink-soft); }
.article table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 0.92rem; }
.article th, .article td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.article th { background: var(--bg-alt); font-weight: 700; }
.source-note { font-size: 0.82rem; color: var(--ink-faint); border-top: 1px dashed var(--border); padding-top: 12px; margin-top: 28px; }

/* Internal links / related grid (S5 bottom grid) */
.related { padding: 30px 0 50px; border-top: 1px solid var(--border); background: var(--bg-alt); }
.related h2 { font-size: 1.05rem; margin-bottom: 14px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 30px 0; background: var(--surface); }
.footer-grid { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px; }
.footer-brand p { color: var(--ink-faint); font-size: 0.85rem; max-width: 40ch; }
.footer-links { display: flex; flex-wrap: wrap; gap: 28px; }
.footer-links h4 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin-bottom: 10px; }
.footer-links a { display: block; color: var(--ink-soft); font-size: 0.88rem; padding: 3px 0; }
.footer-links a:hover { color: var(--accent-dark); }
.footer-bottom { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--ink-faint); }

/* Section utility */
.section { padding: 48px 0; }
.section-alt { background: var(--bg-alt); }
.section-title { text-align: center; max-width: 640px; margin: 0 auto 30px; }
.section-title p { margin: 8px auto 0; color: var(--ink-soft); }

/* Privacy-check note box */
.notice {
  border: 1px solid var(--accent-soft-border); background: var(--accent-soft);
  border-radius: var(--radius); padding: 14px 16px; font-size: 0.9rem; color: var(--ink);
  margin: 16px 0;
}
.notice strong { color: var(--accent-dark); }

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .panel, .card { padding: 16px; }
}
