/*
 * crft.sh shared UI kit — Cult UI look (halo buttons, border beam, floating panels)
 * Served at /_ui/cult.css on mntr.crft.sh and crft.sh. Source: ~/ui-kit/
 * Font: JetBrains Mono Nerd Font, subset to Latin text faces + one icon face
 * (Nerd Font BMP private-use glyphs, only downloaded when a page uses an icon).
 */

@font-face { font-family: "JBM Nerd"; src: url("fonts/jbm-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0020-007E, U+00A0-024F, U+2000-27BF; }
@font-face { font-family: "JBM Nerd"; src: url("fonts/jbm-SemiBold.woff2") format("woff2"); font-weight: 500 650; font-display: swap; unicode-range: U+0020-007E, U+00A0-024F, U+2000-27BF; }
@font-face { font-family: "JBM Nerd"; src: url("fonts/jbm-ExtraBold.woff2") format("woff2"); font-weight: 700 900; font-display: swap; unicode-range: U+0020-007E, U+00A0-024F, U+2000-27BF; }
@font-face { font-family: "JBM Nerd"; src: url("fonts/jbm-icons.woff2") format("woff2"); font-weight: 400; font-display: block; unicode-range: U+E000-F8FF; }
@font-face { font-family: "JBM Nerd"; src: url("fonts/jbm-icons.woff2") format("woff2"); font-weight: 500 650; font-display: block; unicode-range: U+E000-F8FF; }
@font-face { font-family: "JBM Nerd"; src: url("fonts/jbm-icons.woff2") format("woff2"); font-weight: 700 900; font-display: block; unicode-range: U+E000-F8FF; }

:root {
  --paper: #F3F5F4;
  --raised: #FFFFFF;
  --ink: #1C2420;
  --mute: #5F6C65;
  --line: #DCE2DE;
  --track: #E4E9E6;
  --fresh: #2F8F6B;
  --soon: #B97C0B;
  --over: #C2453A;
  --learn: #8A9690;
  --halo: 47 143 107;
  --shadow: 0 1px 0 rgb(28 36 32 / .04), 0 8px 24px -12px rgb(28 36 32 / .18);
  --font: "JBM Nerd", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121614;
    --raised: #1A201D;
    --ink: #E6ECE8;
    --mute: #93A09A;
    --line: #26302B;
    --track: #252E2A;
    --fresh: #4DB88E;
    --soon: #E0A93A;
    --over: #E8695D;
    --learn: #6E7B75;
    --halo: 77 184 142;
    --shadow: 0 1px 0 rgb(0 0 0 / .3), 0 10px 28px -14px rgb(0 0 0 / .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* Components with their own display (e.g. the flex toast) must still hide */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--font);
  min-height: 100dvh;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea, select { font: inherit; color: inherit; }

a { color: inherit; text-underline-offset: 3px; }

:focus-visible { outline: 2px solid var(--fresh); outline-offset: 2px; }

/* ── Layout ─────────────────────────────────────────────────────────────── */

.shell { max-width: 760px; margin: 0 auto; }
.shell.narrow { max-width: 480px; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 28px 0 20px;
}

.top h1, .title {
  margin: 0;
  font: 800 2.125rem/1 var(--font);
  letter-spacing: -.04em;
}

.top .lede { margin: 6px 0 0; }

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--mute);
  font-size: .875rem;
  text-decoration: none;
}

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

.section-title {
  margin: 32px 0 12px;
  font: 650 1.0625rem/1.2 var(--font);
  letter-spacing: -.02em;
}

.lede { margin: 0 0 20px; color: var(--mute); }
.muted { color: var(--mute); }
.stack { display: grid; gap: 12px; }

/* ── Card ───────────────────────────────────────────────────────────────── */

.card {
  position: relative;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
  isolation: isolate;
}

:where(a.card) { display: block; }
a.card { text-decoration: none; transition: transform .15s ease; }
a.card:active { transform: scale(.985); }

/* Border beam (Cult UI): only on things that need attention */
@property --beam {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.beam { --beam-color: var(--over); border-color: transparent; }

.beam::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1.5px;
  background: conic-gradient(from var(--beam), transparent 0 62%, var(--beam-color) 80%, color-mix(in srgb, var(--beam-color) 45%, white) 88%, transparent 96%), var(--line);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: beam 3.2s linear infinite;
  pointer-events: none;
  z-index: -1;
}

@keyframes beam { to { --beam: 360deg; } }

/* ── Buttons ────────────────────────────────────────────────────────────── */

/* Halo button (Cult UI) */
.halo {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: none;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 99px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  font-size: .9375rem;
  text-decoration: none;
  cursor: pointer;
  isolation: isolate;
  transition: transform .15s ease;
}

.halo::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: inherit;
  background: radial-gradient(closest-side, rgb(var(--halo) / .55), transparent);
  opacity: 0;
  z-index: -1;
  transition: opacity .35s ease, transform .35s ease;
  transform: scale(.8);
}

.halo:active { transform: scale(.96); }
.halo:active::after, .halo.pulse::after { opacity: 1; transform: scale(1.15); }

.halo.quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.halo.danger { background: transparent; color: var(--over); border: 1px solid var(--line); }
.halo.small { min-height: 36px; padding: 0 14px; font-size: .875rem; }
.halo.block { width: 100%; }
.halo:disabled { opacity: .5; cursor: default; }

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--raised);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  text-decoration: none;
}

.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

/* Segmented pill nav */
.pills {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--raised);
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.pills a {
  flex: none;
  padding: 8px 14px;
  border-radius: 99px;
  font-size: .875rem;
  text-decoration: none;
  color: var(--mute);
}

.pills a[aria-current="page"] { background: var(--ink); color: var(--paper); }

/* ── Forms (Halo input) ─────────────────────────────────────────────────── */

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .875rem; color: var(--mute); }

.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  font-size: 1rem;
  transition: border-color .2s ease, box-shadow .2s ease;
  -webkit-appearance: none;
  appearance: none;
}

textarea.input { min-height: 280px; resize: vertical; line-height: 1.5; }

.input:focus { outline: none; border-color: var(--fresh); box-shadow: 0 0 0 4px rgb(var(--halo) / .18); }

.error { color: var(--over); font-size: .9375rem; margin: 0 0 14px; }

/* ── Data display ───────────────────────────────────────────────────────── */

.facts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  margin: 0;
  border-radius: 16px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
}

.facts.three { grid-template-columns: repeat(3, 1fr); }
.facts div { background: var(--raised); padding: 12px 14px; }
.facts dt { font-size: .8125rem; color: var(--mute); }
.facts dd { margin: 2px 0 0; font: 700 1.25rem/1.2 var(--font); letter-spacing: -.02em; }

.rows { list-style: none; margin: 0; padding: 0; }

.rows li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.rows li:last-child { border-bottom: 0; }
.rows .main { min-width: 0; }
.rows .main > * { overflow-wrap: anywhere; }
.rows .sub { color: var(--mute); font-size: .8125rem; }

/* Same specificity as page classes, so a page's own padding (e.g. .log) wins */
.flush { padding: 0; }

/* Status pill */
.pill {
  --tone: var(--fresh);
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 12%, transparent);
}

.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.soon { --tone: var(--soon); }
.pill.over { --tone: var(--over); }
.pill.idle { --tone: var(--learn); }

/* Depletion bar */
.bar {
  --tone: var(--fresh);
  position: relative;
  height: 8px;
  border-radius: 99px;
  background: var(--track);
  overflow: hidden;
}

.bar.soon { --tone: var(--soon); }
.bar.over { --tone: var(--over); }

.bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--p) * 100%);
  border-radius: inherit;
  background: var(--tone);
  transition: width .6s cubic-bezier(.2, .8, .2, 1);
}

.icon { font-family: var(--font); font-style: normal; line-height: 1; }

/* ── Toast ──────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  opacity: 0;
  width: min(440px, calc(100% - 32px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 10px 18px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 18px;
  box-shadow: 0 12px 32px -12px rgb(0 0 0 / .5);
  transition: opacity .25s ease, transform .3s cubic-bezier(.22, 1.2, .36, 1);
  z-index: 20;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.toast button {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: color-mix(in srgb, var(--paper) 16%, transparent);
  font-weight: 600;
  cursor: pointer;
}

.foot { margin-top: 32px; color: var(--mute); font-size: .8125rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation: none !important; }
}
