/* ==========================================================================
   Engineering Notes — base, header, footer, cover
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 22px;
  width: 100%;
  max-width: var(--kb-max);
  height: var(--header-h);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.025em;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  width: 11px;
  height: 11px;
  background: var(--yellow);
  border-radius: 1px;
}

.topnav {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 2px;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.topnav a:hover {
  color: var(--ink);
  background: var(--warm);
}

.topnav a[aria-current="page"] {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--yellow);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1;
  color: var(--faint);
  background: var(--paper);
}

.topnav a[aria-current="page"] .tab-count {
  border-color: var(--line-strong);
  color: var(--ink);
  background: var(--yellow);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.theme-toggle:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.mobile-nav {
  display: none;
  position: relative;
}

.mobile-nav summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  list-style: none;
}

.mobile-nav summary::-webkit-details-marker {
  display: none;
}

.mobile-nav summary::after {
  content: "+";
  font-family: var(--mono);
  color: var(--faint);
}

.mobile-nav[open] summary::after {
  content: "−";
}

.mobile-nav summary:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.mobile-nav-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(300px, calc(100vw - 32px));
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--paper);
  box-shadow: 5px 5px 0 var(--hard);
  z-index: 60;
}

.mobile-nav-panel a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 2px;
  color: var(--muted);
  font-size: 13.5px;
  text-decoration: none;
}

.mobile-nav-panel a:hover,
.mobile-nav-panel a[aria-current="page"] {
  color: var(--ink);
  background: var(--warm);
}

/* Footer ---------------------------------------------------------------- */
.site-footer {
  margin-top: 72px;
  padding: 28px 0 36px;
  background: var(--warm);
  border-top: 1px solid var(--line);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px 32px;
  width: 100%;
  max-width: var(--kb-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.footer-title {
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.footer-meta {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-content: start;
}

.footer-links a {
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-sample {
  flex-basis: 100%;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

/* Shared ---------------------------------------------------------------- */
.eyebrow {
  margin-bottom: 10px;
  color: var(--purple);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-strong);
}

.section-head h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-head a {
  color: var(--purple);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.section-head a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-yellow,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 2px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn-yellow {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #020a0f;
}

.btn-yellow:hover {
  background: var(--yellow-strong);
  border-color: var(--yellow-strong);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-ghost:hover {
  background: var(--warm);
}

.badge-featured {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border: 1px solid var(--purple);
  border-radius: 2px;
  color: var(--purple);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
}

/* Cover ----------------------------------------------------------------- */
.cover {
  --cover-bg: var(--warm);
  --cover-text: var(--ink);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  min-height: 140px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--cover-bg);
  color: var(--cover-text);
}

.cover-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.cover-cat {
  min-width: 0;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: 0.015em;
  overflow-wrap: anywhere;
  opacity: 0.82;
}

.cover-no {
  flex: none;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  opacity: 0.62;
}

.cover-title {
  position: relative;
  z-index: 1;
  max-width: 13ch;
  font-size: clamp(1.15rem, 2.2vw, 1.45rem);
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}

.cover-keys {
  position: relative;
  z-index: 1;
  padding-top: 8px;
  border-top: 1px solid currentColor;
  font-size: 9.5px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
  opacity: 0.68;
}

.cover-ghost {
  position: absolute;
  right: 6px;
  bottom: -18px;
  z-index: 0;
  font-family: var(--mono);
  font-size: 78px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.09em;
  color: currentColor;
  opacity: 0.08;
  pointer-events: none;
}

.cover--yellow {
  --cover-bg: var(--yellow);
  --cover-text: #020a0f;
}

.cover--lilac {
  --cover-bg: var(--purple-soft);
  --cover-text: var(--ink);
}

.cover--shell {
  --cover-bg: var(--warm);
  --cover-text: var(--ink);
}

.cover--ink {
  --cover-bg: var(--invert-bg);
  --cover-text: var(--invert-text);
}

.cover--pale {
  --cover-bg: var(--yellow-soft);
  --cover-text: var(--ink);
}

.cover--violet {
  --cover-bg: #e9dcff;
  --cover-text: #020a0f;
}

.cover--sand {
  --cover-bg: #efe9df;
  --cover-text: #020a0f;
}

.cover--grape {
  --cover-bg: #3a1a6e;
  --cover-text: #f4f1eb;
}

.cover--gray {
  --cover-bg: #e9eaec;
  --cover-text: #020a0f;
}

[data-theme="dark"] .cover--violet {
  --cover-bg: #1d1630;
  --cover-text: #f3f1ec;
}

[data-theme="dark"] .cover--sand {
  --cover-bg: #241f18;
  --cover-text: #f3f1ec;
}

[data-theme="dark"] .cover--gray {
  --cover-bg: #1b1d20;
  --cover-text: #f3f1ec;
}

[data-theme="dark"] .cover--grape {
  --cover-bg: #2a1450;
  --cover-text: #f4f1eb;
}

/* Empty states ---------------------------------------------------------- */
.empty-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--warm);
  padding: 26px;
}

.empty-panel h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.empty-panel p {
  max-width: 52ch;
  margin-top: 8px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--muted);
}

.empty-panel .btn-ghost {
  margin-top: 16px;
}

/* Responsive ------------------------------------------------------------ */
@media (max-width: 900px) {
  .topnav {
    display: none;
  }

  .mobile-nav {
    display: block;
  }

  .theme-toggle,
  .mobile-nav summary {
    height: 44px;
  }
}

@media (max-width: 480px) {
  .header-inner {
    gap: 12px;
  }

  .brand {
    font-size: 14px;
  }

  .theme-toggle,
  .mobile-nav summary {
    height: 44px;
  }
}
