/* Misul Computing — a research note.
   Set in our own typefaces, self-hosted: Misul Display (geometric, variable)
   and Misul Mono. A warm paper, a left-aligned document, numbered sections. */

@font-face {
  font-family: "Misul Display"; src: url("/fonts/MisulDisplay.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Misul Mono"; src: url("/fonts/MisulMono-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Misul Mono"; src: url("/fonts/MisulMono-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --bg: #fbfaf7;            /* a faintly warm paper */
  --ink: #14130f;
  --text: #232019;
  --muted: rgba(38, 34, 26, 0.55);
  --faint: rgba(38, 34, 26, 0.40);
  --rule: rgba(40, 34, 22, 0.16);
  --accent: #2e5fe0;        /* Misul blue — used scarcely */
  --serif: "Misul Display", "Helvetica Neue", Arial, sans-serif;
  --mono: "Misul Mono", ui-monospace, "Courier New", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light dark;
  background: var(--bg);          /* fill edge-to-edge, incl. behind system bars */
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* legacy Edge */
}
html::-webkit-scrollbar { width: 0; height: 0; display: none; }   /* Chrome, Safari */

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: #e7e3d8; }
a { color: inherit; text-decoration: none; }

/* ============ Minimal scrollbar (native bar hidden) ============ */
.scrollbar {
  position: fixed; top: 10px; bottom: 10px; right: 6px; width: 3px; z-index: 100;
  background: var(--rule); border-radius: 3px;
  opacity: 0; transition: opacity 0.3s ease;
}
.scrollbar.active { opacity: 1; }
.scrollbar-thumb {
  position: absolute; left: 0; right: 0; top: 0; height: 28px;
  background: var(--ink); border-radius: 3px; cursor: grab; will-change: transform;
}
.scrollbar-thumb:active { cursor: grabbing; }

.paper {
  max-width: 700px;
  margin: 0 auto;
  /* Edge-to-edge: content clears notches/system bars, the bg fills the rest. */
  padding:
    max(clamp(2rem, 5vw, 3.75rem), env(safe-area-inset-top))
    max(clamp(1.5rem, 5vw, 2.5rem), env(safe-area-inset-right))
    max(clamp(2.5rem, 6vw, 4rem), env(safe-area-inset-bottom))
    max(clamp(1.5rem, 5vw, 2.5rem), env(safe-area-inset-left));
  text-align: center;
}

/* ============ Masthead (large M stacked over the wordmark, centred) ============ */
.letterhead {
  display: flex; flex-direction: column; align-items: center; gap: 0.8rem;
  padding-bottom: clamp(1.75rem, 4vw, 2.75rem); border-bottom: 1px solid var(--rule);
}
.brand { display: inline-flex; flex-direction: column; align-items: center; gap: 0.8rem; color: var(--ink); }
.brand-mark { width: 66px; height: 66px; display: block; }
.brand-name {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.7rem, 1.25rem + 1.6vw, 2.2rem);
  letter-spacing: 0.005em; color: var(--ink);
}

/* ============ Document ============ */
.doc { margin-top: clamp(3rem, 9vw, 6.5rem); }

.titleblock { margin-bottom: clamp(1.75rem, 4vw, 2.5rem); }
.title {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(2.2rem, 1.3rem + 3.2vw, 3.6rem);
  line-height: 1.07; letter-spacing: -0.015em; color: var(--ink);
  max-width: 15ch; margin: 0 auto;
}

/* ============ Lead statement (a deck, not an abstract) ============ */
.lead-in {
  font-size: clamp(1.15rem, 1rem + 0.7vw, 1.45rem);
  line-height: 1.45; color: var(--ink); max-width: 32rem;
  margin: 0 auto clamp(2.75rem, 6vw, 4rem);
}

/* ============ Numbered sections (centred) ============ */
.section {
  padding-top: clamp(1.6rem, 3vw, 2.2rem); margin-bottom: clamp(1.5rem, 3vw, 2.2rem);
  border-top: 1px solid var(--rule);
}
.section-no {
  display: block; font-family: var(--mono); font-size: 0.75rem;
  letter-spacing: 0.12em; color: var(--faint); margin-bottom: 0.6rem;
}
.section-title {
  font-family: var(--serif); font-weight: 600; font-size: 1.25rem;
  letter-spacing: -0.005em; color: var(--ink); margin-bottom: 0.5rem;
}
.section-main p { max-width: 44ch; margin: 0 auto; }

/* ============ Footer (all Misul Mono, centred) ============ */
.footer {
  margin-top: clamp(3rem, 8vw, 5rem); padding-top: clamp(1.6rem, 3vw, 2.2rem);
  border-top: 1px solid var(--rule); font-family: var(--mono); color: var(--muted);
}
.footer-mark { display: inline-flex; color: var(--ink); }
.footer-mark svg { width: 28px; height: 28px; display: block; }
.footer-line { font-size: 12px; letter-spacing: 0.04em; margin-top: 1rem; }
.founder-link { color: var(--accent); }
.founder-link:hover { text-decoration: underline; }
.footer-etym { font-size: 12px; letter-spacing: 0.04em; color: var(--faint); margin-top: 1.6rem; }
.footer-etym .word { color: var(--muted); }

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

/* ============ Dark mode (system; a warm charcoal, not pure black) ============ */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #20201e;
    --ink: #f2f1ee;
    --text: #e7e5e1;
    --muted: rgba(231, 229, 225, 0.55);
    --faint: rgba(231, 229, 225, 0.38);
    --rule: rgba(231, 229, 225, 0.15);
    --accent: #7193f1;
  }
  ::selection { background: rgba(231, 229, 225, 0.20); }
}

@media (prefers-reduced-motion: reduce) { * { transition-duration: 0.01ms !important; } }
