@font-face {
  font-family: 'Instrument Serif';
  src: url('/fonts/instrument-serif-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+2000-206F, U+2122, U+2212, U+FEFF, U+FFFD;
}

/* ---------------------------------------------------------------
   madlener.io — warm paper, monochrome, monospace body with the
   name set in Instrument Serif.
   Light is the default; dark applies via system preference or the
   .dark / .light classes set by the dot toggle.
   --------------------------------------------------------------- */

:root {
  --bg: #faf9f6;
  --fg: #17191b;
  --muted: #70706a;
  --line: #e5e3dc;
  --underline: #948f82;
  --sel: rgba(23, 25, 27, .13);
}

@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --bg: #0b0c0d;
    --fg: #ebe9e3;
    --muted: #8a8b84;
    --line: #212325;
    --underline: #606466;
    --sel: rgba(235, 233, 227, .20);
  }
}

:root.dark {
  --bg: #0b0c0d;
  --fg: #ebe9e3;
  --muted: #8a8b84;
  --line: #212325;
  --underline: #606466;
  --sel: rgba(235, 233, 227, .20);
}

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

::selection { background: var(--sel); }

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light dark;
}

body {
  padding-inline: max(7vw, 1.35rem);
  padding-left: max(7vw, calc(1.35rem + env(safe-area-inset-left)));
  padding-right: max(7vw, calc(1.35rem + env(safe-area-inset-right)));
  font: 400 15px/2.05 ui-monospace, "SF Mono", SFMono-Regular, Menlo, "JetBrains Mono",
        "Roboto Mono", "Liberation Mono", monospace;
  background: var(--bg);
  color: var(--fg);
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
  transition: background .35s ease, color .35s ease;
}

main {
  max-width: 42rem;
  margin: 0 auto;
  padding: 14vh 0 8vh;
}

/* --- header ------------------------------------------------------ */

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .35em;
}

h1 {
  font-family: 'Instrument Serif', 'Iowan Old Style', Palatino, 'Palatino Linotype',
               Georgia, 'Times New Roman', serif;
  font-size: clamp(2rem, 8vw, 2.85rem);
  font-weight: 400;
  letter-spacing: -.01em;   /* serif wants far less negative tracking than the mono did */
  line-height: 1.1;
}

.role { margin-bottom: 2.2em; }

/* --- theme toggle ---------------------------------------- */

#theme {
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  margin: -.75rem;               /* keeps a 44px tap target without shifting layout */
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  cursor: pointer;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.dot {
  width: .62rem;
  height: .62rem;
  border-radius: 50%;
  background: var(--fg);
  display: block;
}

@media (hover: hover) {
  #theme:hover .dot { transform: scale(1.3); }
  .dot { transition: transform .2s ease; }
}

#theme:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: 50%; }

/* --- links & triggers -------------------------------------------- */

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--underline);
  transition: color .15s ease, border-color .15s ease;
}

a:hover, a:focus-visible {
  font-weight: 700;
  border-bottom-color: var(--fg);
}

.trigger {
  cursor: pointer;
  border-bottom: 1px dashed var(--underline);
  transition: border-color .15s ease;
}

.trigger:hover { font-weight: 700; border-bottom-color: var(--fg); }
.trigger.open { font-weight: 700; border-bottom-style: solid; border-bottom-color: var(--fg); }

/* --- expandable ascii trees --------------------------------------- */

.block { margin-bottom: 1.9em; }

.popup {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .38s cubic-bezier(.22, 1, .36, 1);
}

.popup.open { grid-template-rows: 1fr; }

.popup > .inner {
  overflow: hidden;
  min-height: 0;
  color: var(--muted);
  font-size: .88em;
  line-height: 1.8;   /* tighter than body copy so a tree reads as one block */
}

.popup.open > .inner { padding: .6em 0 .9em; }
.popup > .inner { transition: padding .38s cubic-bezier(.22, 1, .36, 1); }

.l {
  display: block;
  padding-left: 3ch;
  text-indent: -3ch;
  overflow-wrap: break-word;
  opacity: 0;
  transform: translateY(-.25em);
  transition: opacity .3s ease, transform .3s ease;
}

.l2 { padding-left: 6ch; text-indent: -6ch; }

.popup.open .l { opacity: 1; transform: none; }

.popup .l a { color: var(--fg); border-bottom-color: transparent; }
.popup .l a:hover, .popup .l a:focus-visible { font-weight: 700; border-bottom-color: var(--fg); }

.tag { font-style: italic; }

/* --- small screens ------------------------------------------------ */

@media (max-width: 34rem) {
  body { font-size: 14px; line-height: 1.95; }
  main { padding-top: 9vh; }
  .role { margin-bottom: 1.8em; }
  .popup > .inner { font-size: .92em; }
  /* tighter tree gutters so nested lines do not wrap awkwardly */
  .l2 { padding-left: 5ch; text-indent: -5ch; }
}

/* --- motion preferences ------------------------------------------- */

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