/* ==========================================================================
   butterflyfx.us  ·  shared stylesheet
   A plain, fast, content first portfolio. No framework, no build step, one
   stylesheet. Light and dark both defined explicitly so the page never borrows
   a colour it did not choose.
   ========================================================================== */

:root {
  --bg:        #fbfbfa;
  --surface:   #ffffff;
  --surface-2: #f4f5f7;
  --border:    #e2e5ea;
  --border-2:  #cfd4dc;

  --text:      #14171c;
  --text-2:    #4a5260;
  --text-3:    #737d8c;

  --accent:    #0f6d94;
  --accent-2:  #0a5372;
  --accent-bg: #e8f3f8;

  --good:      #14713f;
  --good-bg:   #e6f4ec;
  --warn:      #8a5a00;
  --warn-bg:   #fdf3df;
  --stop:      #a3282d;
  --stop-bg:   #fbeaea;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
          "Helvetica Neue", Arial, sans-serif;

  --maxw: 1080px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 22, 32, .04), 0 4px 16px -8px rgba(16, 22, 32, .10);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0e1116;
    --surface:   #151a21;
    --surface-2: #1b2129;
    --border:    #272e38;
    --border-2:  #384250;

    --text:      #e9edf2;
    --text-2:    #a8b3c1;
    --text-3:    #7b8695;

    --accent:    #5cc2e8;
    --accent-2:  #8ad6f5;
    --accent-bg: #102a36;

    --good:      #62d69a;
    --good-bg:   #102b1e;
    --warn:      #e0b155;
    --warn-bg:   #2e2413;
    --stop:      #f0888c;
    --stop-bg:   #2e1618;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px -8px rgba(0, 0, 0, .5);
  }
}

:root[data-theme="dark"] {
  --bg:        #0e1116;
  --surface:   #151a21;
  --surface-2: #1b2129;
  --border:    #272e38;
  --border-2:  #384250;
  --text:      #e9edf2;
  --text-2:    #a8b3c1;
  --text-3:    #7b8695;
  --accent:    #5cc2e8;
  --accent-2:  #8ad6f5;
  --accent-bg: #102a36;
  --good:      #62d69a;
  --good-bg:   #102b1e;
  --warn:      #e0b155;
  --warn-bg:   #2e2413;
  --stop:      #f0888c;
  --stop-bg:   #2e1618;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px -8px rgba(0, 0, 0, .5);
}

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

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

img { max-width: 100%; height: auto; }

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

h1, h2, h3, h4 { line-height: 1.22; margin: 0 0 .5rem; letter-spacing: -.011em; font-weight: 650; }
h1 { font-size: clamp(1.9rem, 4.4vw, 2.7rem); letter-spacing: -.022em; }
h2 { font-size: clamp(1.35rem, 2.8vw, 1.7rem); }
h3 { font-size: 1.08rem; }
p  { margin: 0 0 1rem; }

code, kbd, pre { font-family: var(--mono); }
code:not(pre code) {
  font-size: .875em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .1em .38em;
  white-space: nowrap;
}
pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: .845rem;
  line-height: 1.6;
  margin: 0 0 1.2rem;
}
pre code { background: none; border: 0; padding: 0; white-space: pre; }

/* ---------- layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 1.5rem; }
.narrow { max-width: 760px; }
section { padding: 3.1rem 0; }
section + section { border-top: 1px solid var(--border); }
.lede { font-size: 1.08rem; color: var(--text-2); max-width: 64ch; }

/* ---------- header ---------- */
.masthead {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--border);
}
.masthead .row {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 1.4rem;
  padding: .72rem 1.5rem; flex-wrap: wrap;
}
.brand {
  font-weight: 680; color: var(--text); margin-right: auto;
  display: flex; align-items: baseline; gap: .5rem; font-size: 1rem;
}
.brand:hover { text-decoration: none; }
.brand .sub { color: var(--text-3); font-weight: 400; font-size: .82rem; }
.masthead nav { display: flex; gap: 1.15rem; flex-wrap: wrap; }
.masthead nav a { color: var(--text-2); font-size: .91rem; }
.masthead nav a.here { color: var(--text); font-weight: 600; }

/* ---------- hero ---------- */
.hero { padding: 3.6rem 0 2.8rem; }
.hero h1 { margin-bottom: .7rem; }
.hero .role {
  font-family: var(--mono); font-size: .8rem; letter-spacing: .07em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 1rem;
}
.hero .lede { font-size: 1.16rem; }
.avail {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--good-bg); color: var(--good);
  border: 1px solid color-mix(in srgb, var(--good) 26%, transparent);
  border-radius: 999px; padding: .2rem .7rem;
  font-size: .8rem; font-weight: 600; margin-bottom: 1.1rem;
}
.avail::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--good); flex: none;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--accent); color: #fff;
  border: 1px solid var(--accent); border-radius: 8px;
  padding: .58rem 1.1rem; font-size: .92rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--accent-2); border-color: var(--accent-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border-2); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn-row { display: flex; gap: .65rem; flex-wrap: wrap; align-items: center; }

/* ---------- cards & grids ---------- */
.grid { display: grid; gap: 1.1rem; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  box-shadow: var(--shadow);
}
.card h3 { margin-bottom: .35rem; }
.card p:last-child { margin-bottom: 0; }
.card .kicker {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: .5rem;
}

/* featured project */
.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.6rem 1.7rem;
  box-shadow: var(--shadow);
}

/* ---------- metrics ---------- */
.metrics { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.metric {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .8rem .9rem;
}
.metric .n {
  font-family: var(--mono); font-size: 1.42rem; font-weight: 600;
  color: var(--text); display: block; line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.metric .l { font-size: .78rem; color: var(--text-3); display: block; margin-top: .2rem; }

/* ---------- tags ---------- */
.tags { display: flex; flex-wrap: wrap; gap: .38rem; margin: .7rem 0 0; padding: 0; list-style: none; }
.tags li {
  font-family: var(--mono); font-size: .755rem;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border); border-radius: 5px;
  padding: .14rem .45rem;
}

/* ---------- tables ---------- */
.tbl-scroll { overflow-x: auto; margin: 0 0 1.2rem; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .52rem .7rem; border-bottom: 1px solid var(--border); }
th { font-size: .77rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 600; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- callouts ---------- */
.note {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-2);
  border-radius: 8px;
  padding: .9rem 1.1rem;
  font-size: .93rem;
  color: var(--text-2);
  margin: 0 0 1.2rem;
}
.note.limit { border-left-color: var(--warn); background: var(--warn-bg); color: var(--text); }
.note.limit strong { color: var(--warn); }

/* ---------- pills ---------- */
.pill {
  display: inline-block; font-family: var(--mono); font-size: .73rem;
  font-weight: 600; border-radius: 5px; padding: .12rem .42rem;
  border: 1px solid transparent; white-space: nowrap;
}
.pill.ok   { background: var(--good-bg); color: var(--good); border-color: color-mix(in srgb, var(--good) 28%, transparent); }
.pill.stop { background: var(--stop-bg); color: var(--stop); border-color: color-mix(in srgb, var(--stop) 28%, transparent); }
.pill.info { background: var(--accent-bg); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 28%, transparent); }
.pill.mut  { background: var(--surface-2); color: var(--text-3); border-color: var(--border); }

/* ---------- lists ---------- */
.clean { list-style: none; padding: 0; margin: 0; }
.clean li { padding: .32rem 0 .32rem 1.15rem; position: relative; color: var(--text-2); }
.clean li::before {
  content: ""; position: absolute; left: 0; top: .82em;
  width: 5px; height: 5px; border-radius: 50%; background: var(--border-2);
}

/* ---------- footer ---------- */
footer {
  border-top: 1px solid var(--border);
  padding: 2.2rem 0 2.8rem;
  color: var(--text-3);
  font-size: .88rem;
}
footer .row { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: baseline; }
footer .row > :first-child { margin-right: auto; }
footer a { color: var(--text-2); }
.aside-research {
  margin-top: 1.4rem; padding-top: 1.1rem;
  border-top: 1px dashed var(--border);
  font-size: .84rem; color: var(--text-3);
}

/* ---------- utility ---------- */
.mono { font-family: var(--mono); }
.muted { color: var(--text-3); }
.small { font-size: .875rem; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.stack > * + * { margin-top: 1.1rem; }
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
:where(a, button, input, textarea, select):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  section { padding: 2.4rem 0; }
  .masthead nav { gap: .9rem; }
  .masthead nav a { font-size: .86rem; }
}

@media print {
  .masthead, .demo-panel { display: none; }
  body { background: #fff; color: #000; }
}
