/* Reusable components: nav, buttons, chips, cards, diff, tables, forms */

/* ---------- navbar ---------- */
.bar {
  position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.bar-inner { display: flex; align-items: center; gap: 20px; height: 100%; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 800 19px/1 var(--f-display); font-stretch: 112%; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-mark .bm-bg { fill: #101828; stroke: var(--border); stroke-width: 1; }
.brand-mark .bm-line { fill: var(--mark); }
.nav { display: flex; align-items: center; gap: clamp(10px, 1.4vw, 20px); margin-inline: auto; }
.nav a {
  position: relative; color: var(--ink-2); text-decoration: none; white-space: nowrap;
  font: 500 14px/1 var(--f-body); padding: 8px 2px;
}
.nav a:hover { color: var(--ink); }
.nav a::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--mark); transform: scaleX(0); transition: transform .2s; }
.nav a[aria-current="true"], .nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="true"]::after, .nav a[aria-current="page"]::after { transform: scaleX(1); }
.bar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.nav + .bar-actions { margin-left: 0; }
.theme-btn {
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
  background: var(--sheet); border: 1px solid var(--border); border-radius: var(--r-md);
  font: 500 12.5px var(--f-mono); color: var(--ink);
}
.theme-btn:hover { border-color: var(--ink-2); }
.menu-btn { display: none; width: 40px; height: 38px; border: 1px solid var(--border); background: var(--sheet); border-radius: var(--r-md); padding: 0; place-items: center; }
.menu-btn .bars, .menu-btn .bars::before, .menu-btn .bars::after { display: block; width: 18px; height: 2px; background: var(--ink); border-radius: 2px; content: ""; position: relative; }
.menu-btn .bars::before { position: absolute; top: -6px; }
.menu-btn .bars::after { position: absolute; top: 6px; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(5, 8, 16, .55); opacity: 0; pointer-events: none; transition: opacity .25s; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 70; width: min(340px, 86vw);
  background: var(--sheet); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  padding: 16px 20px 28px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
  transform: translateX(100%); visibility: hidden; transition: transform .28s ease, visibility 0s .28s;
}
.drawer.open { transform: none; visibility: visible; transition: transform .28s ease; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.drawer a.dl { display: block; padding: 13px 4px; border-bottom: 1px solid var(--border); color: var(--ink); text-decoration: none; font-weight: 500; }
.drawer a.dl[aria-current="true"], .drawer a.dl[aria-current="page"] { color: var(--ink); box-shadow: inset 3px 0 0 var(--mark); padding-left: 12px; }
.drawer .btn { margin-top: 18px; width: 100%; }
.drawer-close { width: 38px; height: 38px; border: 1px solid var(--border); background: var(--bg); border-radius: var(--r-md); font-size: 20px; line-height: 1; }

@media (max-width: 1180px) {
  .nav { display: none; }
  .menu-btn { display: grid; }
  .bar-actions { margin-left: auto; }
}
@media (max-width: 560px) { .bar-actions .btn { display: none; } .theme-btn .theme-label { display: none; } .theme-btn { width: 40px; padding: 0; justify-content: center; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 22px; border-radius: var(--r-md);
  font: 600 15px var(--f-body); text-decoration: none; border: 1px solid transparent; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .15s;
}
.btn-lg { height: 52px; padding: 0 26px; }
.btn-primary { background: var(--mark); color: var(--mark-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--mark) 88%, white); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--ink-2); background: var(--sheet); }
.btn-dark { height: 38px; padding: 0 16px; font-size: 14px; background: var(--ink); color: var(--paper); }
.btn-dark:hover { background: color-mix(in srgb, var(--ink) 85%, var(--cobalt)); }
.btn[disabled] { opacity: .7; cursor: progress; }
.btn .spinner { display: none; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn[aria-busy="true"] .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- chips + badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font: 600 11.5px/1 var(--f-mono); padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--ink-2); white-space: nowrap; }
.chip.hard { border-color: color-mix(in srgb, var(--del-fg) 40%, transparent); color: var(--del-fg); }
.chip.soft { border-color: color-mix(in srgb, var(--warn-fg) 40%, transparent); color: var(--warn-fg); }
.chip.pop { background: var(--mark); color: var(--mark-ink); border-color: var(--mark); }
.chip.purple { color: var(--purple); border-color: color-mix(in srgb, var(--purple) 40%, transparent); }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-flex; align-items: center; gap: 7px; font: 500 12px/1 var(--f-mono); padding: 7px 11px; border-radius: var(--r-sm); background: var(--sheet); border: 1px solid var(--border); color: var(--ink); }
.badge .icon { color: var(--green); }

/* ---------- cards / callouts ---------- */
.card { background: var(--sheet); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 22px; min-width: 0; }
.glass { background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--shadow); }
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%); }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .glass { background: var(--sheet); } }
.callout { border-left: 3px solid var(--mark); background: color-mix(in srgb, var(--mark) 10%, var(--sheet)); padding: 16px 20px; border-radius: 0 var(--r-md) var(--r-md) 0; }
.callout p { color: var(--ink); font-size: 15px; }
.callout strong { font-weight: 700; }
.callout.green { border-color: var(--green); background: color-mix(in srgb, var(--green) 9%, var(--sheet)); }
.callout .src { display: inline-block; margin-top: 4px; padding: 5px 0; font: 500 13px var(--f-mono); }

/* ---------- diff viewer ---------- */
.diff { margin: 0; font: 400 12.5px/1.75 var(--f-mono); overflow-x: auto; background: var(--sheet); }
.diff .ln { display: grid; grid-template-columns: 44px 18px minmax(max-content, 1fr); }
.diff .n { color: var(--gutter); text-align: right; padding-right: 10px; user-select: none; }
.diff .s { color: var(--gutter); user-select: none; }
.diff .c { padding-right: 16px; white-space: pre; }
.diff .del { background: var(--del-bg); } .diff .del .s, .diff .del .c { color: var(--del-fg); }
.diff .add { background: var(--add-bg); } .diff .add .s, .diff .add .c { color: var(--add-fg); }
.diff .ctx .c { color: var(--ink); }
.diff mark.hl { background: var(--mark); color: var(--mark-ink); border-radius: 2px; padding: 0 1px; }
.diff.boxed { border: 1px solid var(--border); border-radius: var(--r-md); }

/* ---------- code panes ---------- */
.fp { font: 400 12.5px/1.7 var(--f-mono); background: var(--code-bg); color: var(--code-fg); border-radius: var(--r-md); padding: 14px 16px; overflow-x: auto; white-space: pre; margin: 0; }
.fp .d { color: var(--code-dim); } .fp .s { color: var(--code-str); } .fp .k { color: var(--code-kw); } .fp .v { color: var(--mark); }
.cmd { background: var(--code-bg); border-radius: var(--r-lg); overflow: hidden; min-width: 0; }
.cmd header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.cmd header span { font: 500 12px var(--f-mono); color: var(--code-dim); }
.copy { border: 1px solid rgba(255,255,255,.22); background: transparent; color: var(--code-fg); font: 500 12px var(--f-mono); border-radius: var(--r-sm); padding: 5px 11px; }
.copy:hover { border-color: var(--mark); color: var(--mark); }
.cmd pre { margin: 0; padding: 14px; color: var(--code-fg); font: 400 13px/1.7 var(--f-mono); overflow-x: auto; }
.cmd pre .d { color: var(--code-dim); }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.feature-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.feature-table th, .feature-table td { text-align: left; vertical-align: top; padding: 16px 12px; border-top: 1px solid var(--border); }
.feature-table tr:last-child th, .feature-table tr:last-child td { border-bottom: 1px solid var(--border); }
.feature-table th { width: 30%; font: 600 15px var(--f-body); }
.feature-table th small { display: block; font: 500 12px var(--f-mono); color: var(--gutter); margin-top: 4px; }
.feature-table td { color: var(--ink-2); }
@media (max-width: 640px) { .feature-table th, .feature-table td { display: block; width: auto; } .feature-table td { border-top: 0; padding-top: 0; } }
.matrix, .compare { border-collapse: collapse; width: 100%; font-size: 14px; }
.matrix { min-width: 680px; }
.compare { min-width: 560px; }
.matrix th, .matrix td, .compare th, .compare td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: center; }
.matrix th:first-child, .matrix td:first-child, .compare th:first-child, .compare td:first-child { text-align: left; }
.matrix thead th, .compare thead th { font: 600 12px var(--f-mono); color: var(--ink-2); letter-spacing: .04em; text-transform: uppercase; }
.matrix td:first-child, .compare td:first-child { font-weight: 600; }
.compare tbody th { font-weight: 600; text-align: left; }
.y { color: var(--add-fg); font-weight: 700; }
.p { color: var(--warn-fg); font: 600 12px var(--f-mono); }
.no { color: var(--gutter); }

/* ---------- forms ---------- */
.form { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }
.field label, .field legend { display: block; font: 600 13.5px var(--f-body); margin-bottom: 6px; padding: 0; }
.field .req { color: var(--del-fg); margin-left: 2px; }
.field .opt { font-weight: 400; color: var(--gutter); }
.control { position: relative; }
input, select, textarea {
  background: var(--bg-3); border: 1.5px solid var(--border); border-radius: var(--r-md);
  color: var(--ink); font: 400 15px var(--f-body); padding: 10px 14px; width: 100%;
  transition: border-color .15s; min-height: 44px;
}
textarea { resize: vertical; min-height: 110px; }
input::placeholder, textarea::placeholder { color: var(--ink-2); opacity: .85; }
input:focus, select:focus, textarea:focus { border-color: var(--cobalt); outline: 2px solid color-mix(in srgb, var(--cobalt) 25%, transparent); outline-offset: 0; }
.field.is-invalid input, .field.is-invalid select, .field.is-invalid textarea { border-color: var(--del-fg); }
.field.is-valid input, .field.is-valid select, .field.is-valid textarea { border-color: color-mix(in srgb, var(--add-fg) 60%, var(--border)); padding-right: 38px; }
.field.is-valid .control::after {
  content: ""; position: absolute; right: 14px; top: 14px; width: 14px; height: 8px;
  border-left: 2px solid var(--add-fg); border-bottom: 2px solid var(--add-fg); transform: rotate(-45deg); pointer-events: none;
}
.field-msg { min-height: 0; margin-top: 5px; font: 500 12.5px/1.4 var(--f-body); color: var(--del-fg); }
.field-msg:empty { display: none; }
.field-hint { margin-top: 5px; font-size: 12.5px; color: var(--ink-2); }
.counter { text-align: right; font: 500 12px var(--f-mono); color: var(--gutter); margin-top: 4px; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; border: 0; padding: 0; margin: 0; }
@media (max-width: 560px) { .checks { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 10px; font-size: 14.5px; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--cobalt); flex: none; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-error { border: 1px solid color-mix(in srgb, var(--del-fg) 50%, transparent); background: var(--del-bg); color: var(--del-fg); border-radius: var(--r-md); padding: 12px 14px; font-size: 14px; }
.form-error a { color: inherit; font-weight: 600; }
.success { text-align: center; padding: 36px 16px; display: grid; gap: 12px; justify-items: center; }
.success .tick { width: 56px; height: 56px; border-radius: 50%; background: var(--add-bg); color: var(--add-fg); display: grid; place-items: center; }
.success .tick .icon { width: 28px; height: 28px; stroke-width: 2.4; }
.success h3 { font-size: 22px; font-weight: 800; font-stretch: 112%; }
.success p { color: var(--ink-2); max-width: 42ch; }

/* ---------- small helpers (kept out of markup so the CSP can forbid inline styles) ---------- */
.btn-block { width: 100%; }
.sub--lg { margin-top: 56px; }
.flush { padding: 0; }
.fieldset-reset { border: 0; padding: 0; margin: 0; min-width: 0; }

/* theme button: icon-only (state is in the tooltip and aria-label) */
.theme-btn .theme-label { display: none; }
.theme-btn { width: 40px; padding: 0; justify-content: center; font-size: 16px; }
.btn-dark[aria-current="page"] { box-shadow: 0 0 0 2px var(--mark); }

/* wordmark: AIRA with "by Securobe" beneath */
.wm { display: inline-flex; flex-direction: column; gap: 3px; line-height: 1; }
.wm small { font: 500 9.5px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.brand .wm { font: 800 21px/1 var(--f-display); font-stretch: 112%; }
.brand .wm small { font-stretch: normal; }

/* brand logo: light + dark artwork, swapped with the theme */
.brand { gap: 0; }
.brand-logo { display: block; height: 48px; width: auto; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}
@media (max-width: 860px) { .brand-logo { height: 40px; } }
.foot-grid .brand-logo { height: 72px; }
