/*
 * ZeroPier (zeropier.com)
 * Typography: self-hosted Schibsted Grotesk + Commit Mono (SIL OFL 1.1)
 */

@font-face {
  font-family: 'Schibsted Grotesk';
  src: url('/fonts/schibsted-grotesk-400-800.woff2') format('woff2');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Commit Mono';
  src: url('/fonts/commit-mono-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Commit Mono';
  src: url('/fonts/commit-mono-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f7f8fa;
  --well: #f1f3f6;
  --ink: #111318;
  --text: #3a3f47;
  --muted: #68707c;
  --subtle: #8b93a0;
  --rule: #e6e8ee;
  --rule-strong: #cdd2dc;
  --accent: #2c5282;
  --accent-wash: #edf3f9;
  --green: #1d6b43;
  --green-wash: #e6f4ec;

  --font-sans: 'Schibsted Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'Commit Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --measure: 820px;
  --gutter: clamp(20px, 4.5vw, 40px);
}

@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0d0f12;
    --surface: #13161b;
    --well: #181c22;
    --ink: #eceef2;
    --text: #c0c5ce;
    --muted: #848c99;
    --subtle: #626a76;
    --rule: #21252d;
    --rule-strong: #343b47;
    --accent: #7aa7db;
    --accent-wash: #162231;
    --green: #5fc48d;
    --green-wash: #13281d;
  }
}

@media screen {
  :root[data-theme='dark'] {
    color-scheme: dark;
    --bg: #0d0f12;
    --surface: #13161b;
    --well: #181c22;
    --ink: #eceef2;
    --text: #c0c5ce;
    --muted: #848c99;
    --subtle: #626a76;
    --rule: #21252d;
    --rule-strong: #343b47;
    --accent: #7aa7db;
    --accent-wash: #162231;
    --green: #5fc48d;
    --green-wash: #13281d;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.985rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color 0.14s ease, text-decoration-color 0.14s ease;
}

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

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

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 10px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-decoration: none;
}

.skip-link:focus {
  left: 16px;
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  border-bottom: 1px solid var(--rule);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.04rem;
  letter-spacing: -0.02em;
}

.brand:hover {
  color: var(--ink);
}

.brand-mark {
  width: 22px;
  height: 22px;
  display: block;
  flex-shrink: 0;
}

.brand-mark .s {
  stroke: var(--ink);
}

.brand-mark .m {
  stroke: var(--subtle);
}

.brand-mark .a {
  stroke: var(--accent);
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.8vw, 26px);
}

.nav a {
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
}

.nav a:hover {
  color: var(--ink);
}

.theme-btn {
  appearance: none;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  padding: 4px 9px;
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.14s ease, border-color 0.14s ease, background-color 0.14s ease;
}

.theme-btn:hover {
  color: var(--ink);
  border-color: var(--rule-strong);
  background: var(--surface);
}

/* ==========================================================================
   Intro
   ========================================================================== */

.intro {
  padding-block: clamp(48px, 8vw, 84px) clamp(36px, 5vw, 56px);
  border-bottom: 1px solid var(--rule);
}

h1 {
  margin: 0 0 18px;
  color: var(--ink);
  font-size: clamp(1.9rem, 1.35rem + 1.8vw, 2.75rem);
  font-weight: 650;
  line-height: 1.14;
  letter-spacing: -0.028em;
  max-width: 24ch;
}

.lede {
  margin: 0 0 24px;
  font-size: 1.06rem;
  line-height: 1.65;
  color: var(--text);
  max-width: 60ch;
}

.intro-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
}

.intro-links a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.intro-links a:hover {
  text-decoration-color: var(--accent);
}

/* ==========================================================================
   Sections
   ========================================================================== */

.section {
  padding-block: clamp(40px, 5.5vw, 60px);
  border-bottom: 1px solid var(--rule);
}

.section:last-of-type {
  border-bottom: 0;
}

.section-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 22px;
}

h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.015em;
}

/* ==========================================================================
   Projects Ledger (scales cleanly to 10+ projects)
   ========================================================================== */

.filters {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.filter-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 10px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.14s ease, background-color 0.14s ease, border-color 0.14s ease;
}

.filter-btn:hover {
  color: var(--ink);
  background: var(--surface);
}

.filter-btn[aria-pressed='true'] {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--rule-strong);
  font-weight: 700;
}

.filter-count {
  color: var(--subtle);
  font-weight: 400;
  margin-left: 4px;
}

.ledger {
  border-top: 1px solid var(--rule);
}

.entry {
  border-bottom: 1px solid var(--rule);
}

.entry[hidden] {
  display: none;
}

.entry-row {
  display: grid;
  grid-template-columns: 152px minmax(0, 1fr) auto;
  gap: 10px 20px;
  align-items: baseline;
  padding: 16px 6px;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.entry-row:hover {
  background: var(--surface);
}

.entry-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.entry-name {
  font-family: var(--font-mono);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.015em;
}

.entry-meta {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--muted);
}

.entry-summary {
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.55;
  color: var(--text);
}

.entry-actions {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: nowrap;
}

.entry-actions a {
  text-decoration: none;
  color: var(--muted);
}

.entry-actions a:hover {
  color: var(--accent);
}

.expand-btn {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--muted);
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.14s ease, color 0.14s ease, background-color 0.14s ease;
}

.expand-btn:hover {
  border-color: var(--rule-strong);
  color: var(--ink);
}

.entry[data-open='true'] .expand-btn {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-wash);
}

.entry-drawer {
  padding: 0 6px 18px;
}

.entry-drawer[hidden] {
  display: none;
}

.drawer-inner {
  margin-left: 172px;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
}

.drawer-detail {
  margin: 0 0 13px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
}

.install-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  background: var(--well);
  border: 1px solid var(--rule);
  border-radius: 3px;
  margin-bottom: 12px;
}

.install-cmd {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.81rem;
  color: var(--ink);
  scrollbar-width: none;
}

.install-cmd::-webkit-scrollbar {
  display: none;
}

.prompt {
  color: var(--subtle);
  user-select: none;
}

.copy-btn {
  flex-shrink: 0;
  padding: 3px 9px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--bg);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  transition: color 0.14s ease, border-color 0.14s ease, background-color 0.14s ease;
}

.copy-btn:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.copy-btn.copied {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-wash);
}

.drawer-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.drawer-specs {
  color: var(--muted);
}

.drawer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.drawer-links a {
  text-decoration: none;
  color: var(--ink);
}

.drawer-links a:hover {
  color: var(--accent);
}

/* ==========================================================================
   Performance & Correctness
   ========================================================================== */

.eng-list {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.eng-item {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  gap: 8px 24px;
  padding-block: 18px;
  border-bottom: 1px solid var(--rule);
  align-items: baseline;
}

.eng-item dt {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.eng-item dd {
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.62;
  color: var(--text);
}

.eng-item code {
  font-size: 0.87em;
  color: var(--ink);
}

/* ==========================================================================
   About & Security
   ========================================================================== */

.about-copy {
  margin: 0 0 22px;
  max-width: 64ch;
  font-size: 0.95rem;
  line-height: 1.65;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--rule);
}

.contact-cell {
  padding: 13px 16px 13px 0;
  border-bottom: 1px solid var(--rule);
}

.contact-k {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 3px;
}

.contact-v {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: var(--ink);
}

.contact-v a {
  text-decoration: none;
}

.contact-v a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--rule);
  padding-block: 24px 36px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--muted);
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

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

.footer-links a:hover {
  color: var(--ink);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 720px) {
  .entry-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    padding: 15px 0;
  }

  .entry-id {
    grid-column: 1;
    flex-direction: row;
    align-items: baseline;
    gap: 10px;
  }

  .entry-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .entry-summary {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .entry-drawer {
    padding: 0 0 16px;
  }

  .drawer-inner {
    margin-left: 0;
  }

  .eng-item {
    grid-template-columns: 1fr;
    gap: 5px;
  }

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

  .nav .hide-sm {
    display: none;
  }
}

@media print {
  .theme-btn,
  .copy-btn,
  .expand-btn,
  .filters {
    display: none !important;
  }
}
