/* ============================================================
   fjordxy
   Palette: bases / bases-light  — https://code.bas.es/bases/themes
   Type:    IBM Plex Sans + IBM Plex Mono
   ============================================================ */

/* ── bases (dark) — the default ─────────────────────────── */
:root {
  color-scheme: dark;

  --bg:            #141210;
  --bg-sunken:     #0e0c0a;
  --surface:       #1a1815;
  --surface-2:     #201e1a;
  --surface-3:     #2c2924;
  --border:        #2c2924;
  --border-strong: #3a3630;

  --fg:        #ede8de;
  --fg-muted:  #857e75;
  --fg-faint:  #4a4640;

  --primary:          #4a9f82;
  --primary-hover:    #57b090;
  --primary-contrast: #141210;
  --primary-a12:      rgba(74, 159, 130, 0.12);
  --primary-a30:      rgba(74, 159, 130, 0.30);

  --orange: #e07800;
  --blue:   #5a8fcc;

  --selection-bg: #4a9f82;
  --selection-fg: #141210;

  --shadow: 0 -1px 0 var(--border), 0 -12px 32px rgba(0, 0, 0, 0.45);

  /* type */
  --font-sans: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* metrics */
  --bar-h: 4.75rem;
  --rail-w: 13rem;
  --ease: cubic-bezier(0.33, 0.1, 0.15, 1);
  --dur: 420ms;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* ── bases-light ────────────────────────────────────────── */
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;

    --bg:            #f7f4ee;
    --bg-sunken:     #ede8de;
    --surface:       #fdfcf8;
    --surface-2:     #ede8de;
    --surface-3:     #dbd6cc;
    --border:        #dbd6cc;
    --border-strong: #c4bfb3;

    --fg:        #1a1814;
    --fg-muted:  #7c7469;
    --fg-faint:  #bab5aa;

    --primary:          #2a5f4f;
    --primary-hover:    #3d7a66;
    --primary-contrast: #f7f4ee;
    --primary-a12:      rgba(42, 95, 79, 0.12);
    --primary-a30:      rgba(42, 95, 79, 0.30);

    --orange: #b35800;
    --blue:   #1e5799;

    --selection-bg: #2a5f4f;
    --selection-fg: #f7f4ee;

    --shadow: 0 -1px 0 var(--border), 0 -12px 32px rgba(0, 0, 0, 0.08);
  }
}

/* ── reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 100%;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

::selection { background: var(--selection-bg); color: var(--selection-fg); }

a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--primary-hover); }

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

.skip {
  position: fixed; top: 0; left: 0; z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--primary); color: var(--primary-contrast);
  font-family: var(--font-mono); font-size: 0.8125rem;
  transform: translateY(-120%);
}
.skip:focus { transform: none; }

kbd {
  font-family: var(--font-mono);
  font-size: 0.875em;
  font-weight: 500;
  line-height: 1;
  display: inline-block;
  padding: 0.24em 0.42em;
  color: var(--fg);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface-2);
  padding: 0.12em 0.34em;
  border-radius: 3px;
}

/* ============================================================
   The grid
   Categories are rows (j/k). Pages are columns within a row (h/l).
   ============================================================ */

.grid { --row: 0; }

/* Without JS the grid is just a readable stack of everything. */
html:not(.js) .grid { padding-bottom: 4rem; }
html:not(.js) .rail,
html:not(.js) .keys,
html:not(.js) .crumb,
html:not(.js) .statusline { display: none; }

html.js body { overflow: hidden; }

html.js .grid {
  position: fixed;
  inset: 0;
  transform: translate3d(0, calc(var(--row) * -100dvh), 0);
  transition: transform var(--dur) var(--ease);
}

html.js .cat {
  --col: 0;
  display: flex;
  height: 100dvh;
  width: 100%;
  transform: translate3d(calc(var(--col) * -100%), 0, 0);
  transition: transform var(--dur) var(--ease);
}

html.js .page {
  flex: 0 0 100%;
  width: 100%;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

/* Off-grid pages fade back so motion reads as travel, not a cut. */
html.js .page { transition: opacity var(--dur) var(--ease); }
html.js .page[inert] { opacity: 0.25; }

@media (prefers-reduced-motion: reduce) {
  html.js .grid, html.js .cat, html.js .page { transition: none; }
  html.js .page[inert] { opacity: 1; }
}

/* ── page content ───────────────────────────────────────── */
.page-in {
  max-width: 40rem;
  margin: 0 auto;
  padding: 6.5rem 1.75rem calc(var(--bar-h) + var(--safe-b) + 3rem);
}

@media (min-width: 861px) {
  .page-in {
    padding: 8rem 3rem 6rem;
    margin-left: max(calc(var(--rail-w) + 4rem), calc(50% - 20rem));
    margin-right: 3rem;
  }
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 0 0 1.75rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
.eyebrow .count { color: var(--fg-faint); letter-spacing: 0.08em; }

h1 {
  font-size: clamp(2.75rem, 9vw, 4.25rem);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.035em;
  margin: 0 0 1.25rem;
}

h2 {
  font-size: clamp(1.85rem, 5.5vw, 2.5rem);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin: 0 0 1.25rem;
}

p { margin: 0 0 1.15rem; max-width: 34rem; }

.lede {
  font-size: 1.1875rem;
  line-height: 1.55;
  color: var(--fg);
  margin-bottom: 1.75rem;
}

p:not(.lede):not(.eyebrow):not(.note):not(.meta):not(.onward) { color: var(--fg-muted); }
p strong { color: var(--fg); font-weight: 600; }

.meta {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--fg-faint);
  margin-bottom: 1.5rem;
}

.note {
  font-size: 0.875rem;
  color: var(--fg-faint);
  border-left: 2px solid var(--border-strong);
  padding-left: 1rem;
  margin-top: 2rem;
}

.keylist { list-style: none; margin: 1.75rem 0; padding: 0; }
.keylist li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--fg-muted);
  max-width: 34rem;
}
.keylist li:first-child { border-top: 1px solid var(--border); }

.entries { margin: 1.75rem 0; max-width: 34rem; }
.entries dt {
  font-weight: 600;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}
.entries .year {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--fg-faint);
}
.entries dd { margin: 0.3rem 0 1rem; color: var(--fg-muted); }

/* "read more" affordance — points at the l key rather than being a link */
.onward {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  color: var(--fg-muted);
  margin-top: 2.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}
.onward::before {
  content: 'l';
  font-size: 1rem;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-a12);
  border: 1px solid var(--primary-a30);
  border-radius: 3px;
  padding: 0.18em 0.5em;
  line-height: 1;
}
.onward::after { content: '→'; color: var(--fg-faint); }

/* ============================================================
   Chrome
   ============================================================ */
.chrome {
  position: fixed;
  left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.75rem;
  pointer-events: none;
}
.chrome--top {
  top: 0;
  background: linear-gradient(to bottom, var(--bg) 45%, transparent);
}
.chrome > * { pointer-events: auto; }

.wordmark {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg);
  text-decoration: none;
}
.wordmark::before { content: '~/'; color: var(--fg-faint); }

.crumb {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--fg-muted);
  margin: 0;
}
.crumb-sep { color: var(--fg-faint); margin: 0 0.4em; }
.crumb-page { color: var(--primary); }

/* ── desktop rail ───────────────────────────────────────── */
.rail {
  display: none;
  position: fixed;
  top: 50%;
  left: 3rem;
  transform: translateY(-50%);
  z-index: 20;
  width: var(--rail-w);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

@media (min-width: 861px) {
  html.js .rail { display: block; }
}

.rail-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0;
  color: var(--fg-faint);
  transition: color 200ms var(--ease);
}
.rail-row[data-current] { color: var(--fg); }

.rail-label {
  flex: 0 0 auto;
  min-width: 5rem;
  letter-spacing: 0.02em;
}
.rail-row[data-current] .rail-label { color: var(--primary); font-weight: 500; }

.rail-dots { display: flex; gap: 0.3rem; align-items: center; }
.rail-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background 200ms var(--ease), transform 200ms var(--ease);
}
.rail-row[data-current] .rail-dot { background: var(--fg-faint); }
.rail-dot[data-on] { background: var(--primary); transform: scale(1.5); }

/* ── desktop statusline ─────────────────────────────────── */
.chrome--bottom {
  bottom: 0;
  padding-bottom: calc(1.1rem + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 45%, transparent);
}
.statusline {
  display: none;
  width: 100%;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-faint);
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.statusline kbd { font-size: 0.8125rem; margin-right: 0.2em; }
.sl-pos { color: var(--fg-muted); }

@media (min-width: 861px) {
  html.js .statusline { display: flex; }
}

/* ============================================================
   The four keys — mobile / touch
   ============================================================ */
.keys {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  height: calc(var(--bar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--bg-sunken);
  box-shadow: var(--shadow);
}

@media (max-width: 860px), (pointer: coarse) {
  html.js .keys { display: grid; grid-template-columns: repeat(4, 1fr); }
  html.js .statusline { display: none; }
}

.key {
  appearance: none;
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  font-family: var(--font-mono);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.key:first-child { border-left: 0; }

.key-letter {
  font-size: 1.3125rem;
  font-weight: 500;
  line-height: 1;
}
.key-cap {
  font-size: 0.625rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: 0.25em;
}
.key-arrow { color: var(--fg-faint); }

.key:active { background: var(--primary-a12); }
.key:active .key-letter { color: var(--primary); }

.key[disabled] {
  color: var(--fg-faint);
  cursor: default;
}
.key[disabled] .key-cap,
.key[disabled] .key-arrow { color: var(--fg-faint); opacity: 0.5; }

/* screen-reader-only live region */
.live {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
