/* ============================================================
   ISO 27001 Control Mapper — Design System
   grc.theadminstack.com/iso27001
   Follows theadminstack.com style guide (IBM Plex Sans/Mono,
   neutral palette, no hue accent, no blur, no gradients)
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── Design Tokens — Light Mode ───────────────────────────── */
:root {
  /* Backgrounds */
  --bg:      #f9fafb;
  --bg-2:    #f3f4f6;
  --bg-3:    #e5e7eb;
  --surface: #ffffff;

  /* Borders */
  --border:   rgba(0,0,0,0.07);
  --border-2: rgba(0,0,0,0.12);
  --border-3: rgba(0,0,0,0.22);

  /* Accent (monochrome only) */
  --accent: #111827;

  /* Text */
  --text:   #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --text-4: #d1d5db;

  /* Status — functional use only */
  --green:  #16a34a;
  --red:    #dc2626;
  --orange: #d97706;
  --blue:   #2563eb;

  /* Radii */
  --r-xs:   2px;
  --r-sm:   4px;
  --r-md:   6px;
  --r-lg:   8px;
  --r-xl:   12px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);

  /* Spacing */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;

  /* Typography */
  --font-display: 'IBM Plex Sans', system-ui, sans-serif;
  --font-body:    'IBM Plex Sans', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', 'Fira Code', monospace;

  /* Nav height */
  --nav-h: 56px;
}

/* ── Dark Mode Tokens ──────────────────────────────────────── */
html.dark {
  --bg:      #0c0c0c;
  --bg-2:    #141414;
  --bg-3:    #1c1c1c;
  --surface: #111111;

  --border:   rgba(255,255,255,0.08);
  --border-2: rgba(255,255,255,0.13);
  --border-3: rgba(255,255,255,0.22);

  --accent: #ebebeb;

  --text:   #f0f0f0;
  --text-2: #a0a0a0;
  --text-3: #555555;
  --text-4: #333333;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3),  0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35), 0 2px 4px rgba(0,0,0,0.2);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.4), 0 4px 8px rgba(0,0,0,0.2);
}

/* ── Base Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
ul { list-style: none; }
svg { display: block; flex-shrink: 0; }

/* ── Typography ────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

/* ── Navigation ────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-xl);
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  flex-shrink: 0;
}

.nav-brand-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: var(--surface);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

html.dark .nav-brand-mark {
  background: var(--accent);
  color: #111111;
}

.nav-brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-brand-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.nav-brand-sub {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-3);
  line-height: 1.2;
}

.nav-sep {
  flex: 1;
}

.nav-back {
  font-size: 0.8125rem;
  color: var(--text-2);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: color 0.15s;
}

.nav-back:hover { color: var(--text); }

.theme-toggle {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--border-3);
  color: var(--text);
}

/* ── Hero ──────────────────────────────────────────────────── */
.hero {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: var(--space-2xl) 0 var(--space-xl);
}

.hero-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-pill);
  padding: 0.25rem 0.75rem;
  margin-bottom: var(--space-md);
}

.hero h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.25rem);
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.hero-sub {
  font-size: 1rem;
  color: var(--text-2);
  max-width: 560px;
  line-height: 1.65;
}

/* ── Main Layout ───────────────────────────────────────────── */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl);
}

/* ── Toolbar (search + version toggle + export) ────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.version-toggle {
  display: flex;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.ver-btn {
  padding: 0.4375rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.02em;
}

.ver-btn + .ver-btn {
  border-left: 1px solid var(--border-2);
}

.ver-btn.active {
  background: var(--accent);
  color: var(--surface);
}

html.dark .ver-btn.active {
  background: var(--accent);
  color: #111111;
}

.search-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 38px;
  padding: 0 0.75rem 0 2.375rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color 0.15s;
}

.search-input::placeholder { color: var(--text-3); }
.search-input:focus { border-color: var(--border-3); }

.btn-export {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.4375rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.btn-export:hover { border-color: var(--border-3); color: var(--text); }

/* ── Filter Pills ──────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar { display: none; }

.filter-pill {
  flex-shrink: 0;
  padding: 0.3125rem 0.875rem;
  font-size: 0.775rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-pill);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.filter-pill:hover {
  border-color: var(--border-3);
  color: var(--text);
}

.filter-pill.active {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
}

html.dark .filter-pill.active {
  background: var(--accent);
  color: #111111;
  border-color: var(--accent);
}

/* ── Results Stats ─────────────────────────────────────────── */
.results-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.results-count {
  font-size: 0.8125rem;
  color: var(--text-3);
  font-family: var(--font-mono);
}

.results-count strong { color: var(--text-2); }

/* ── Control Cards Grid ────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-lg);
}

/* ── Control Card ──────────────────────────────────────────── */
.control-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.control-card:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
}

.card-id-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.card-id {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xs);
  padding: 0.125rem 0.5rem;
  letter-spacing: 0.02em;
}

.badge-new {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #166534;
  background: rgba(22,163,74,0.08);
  border: 1px solid rgba(22,163,74,0.2);
  border-radius: var(--r-xs);
  padding: 0.1rem 0.45rem;
}

html.dark .badge-new {
  color: #4ade80;
  background: rgba(74,222,128,0.1);
  border-color: rgba(74,222,128,0.2);
}

.btn-copy {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.725rem;
  font-weight: 500;
  color: var(--text-3);
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.btn-copy:hover { color: var(--text-2); border-color: var(--border-3); }
.btn-copy.copied { color: var(--green); border-color: rgba(22,163,74,0.3); }

.card-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.card-domain {
  font-size: 0.725rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.card-desc {
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.6;
  padding-top: var(--space-xs);
  border-top: 1px solid var(--border);
}

/* ── Evidence Section ──────────────────────────────────────── */
.evidence-section {
  border-top: 1px solid var(--border);
  padding-top: var(--space-sm);
}

.evidence-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: var(--space-xs);
}

.evidence-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.evidence-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-2);
  line-height: 1.5;
}

.evidence-item::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-4);
  flex-shrink: 0;
  margin-top: 0.5em;
}

/* ── Mapping Badge ─────────────────────────────────────────── */
.mapping-row {
  padding-top: var(--space-xs);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.mapping-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
  flex-shrink: 0;
}

.mapping-ids {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mapping-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-2);
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xs);
  padding: 0.1rem 0.4rem;
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-2xl) var(--space-xl);
  color: var(--text-3);
}

.empty-state svg {
  margin: 0 auto var(--space-md);
  opacity: 0.35;
}

.empty-state p {
  font-size: 0.9375rem;
}

/* ── Footer ────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  margin-top: var(--space-2xl);
  padding: var(--space-xl);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-3);
}

footer a { color: var(--text-2); }
footer a:hover { color: var(--text); }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nav-inner { padding: 0 var(--space-md); }
  .hero-wrap  { padding: 0 var(--space-md); }
  main        { padding: var(--space-md); }

  .nav-brand-sub { display: none; }

  .toolbar {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .version-toggle { order: -1; }
  .search-wrap    { min-width: 100%; order: 0; }
  .btn-export     { order: 1; }

  .cards-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 400px) {
  .nav-brand-name { font-size: 0.8125rem; }
}
