/* SPDX-License-Identifier: AGPL-3.0-or-later */
/* doing nothing and knowing everything: the notebook's night, c0unt only */
@font-face { font-family: 'c0unt-r'; src: url('../f/c0unt-r.woff2') format('woff2'); font-display: block; }
@font-face { font-family: 'c0unt-h'; src: url('../f/c0unt-h.woff2') format('woff2'); font-display: block; }

:root {
  --ground: #171614; --bone: #e8e2d2; --thin: #b4ad9d; --dim: #8f897c; --faint: #6f6a60;
  --coral: #f27068; --squiggle: #ec5a55; --hair: #4a4640;
  --size: 22px; --row: 1.45;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--ground); color: var(--bone); -webkit-text-size-adjust: 100%; }
body { margin: 0; font: var(--size) / var(--row) 'c0unt-r'; }
#book { max-width: 1000px; margin: 0 auto; padding: 28px 16px 8px; }
a { color: inherit; }

h1, h2 { font: 44px / 1.15 'c0unt-h'; color: var(--coral); margin: 0 0 18px; font-weight: normal; letter-spacing: -.01em; }
.cell { position: relative; padding-right: 22px; margin-bottom: 40px; }
/* the notebook's outer cell bracket */
.cell::after { content: ''; position: absolute; right: 0; top: 4px; bottom: 4px; width: 7px; border: 1px solid var(--hair); border-left: 0; }

.wires { list-style: none; margin: 0; padding: 0 0 0 clamp(0px, 8vw, 96px); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 14px; position: relative; }

.line {
  all: unset; display: block; padding: 3px 0; min-height: 36px; cursor: pointer;
  font: inherit; color: var(--bone); white-space: pre-wrap; overflow-wrap: anywhere;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ink { position: relative; display: inline-block; }
.careless, .ghost { display: none; }
.sq { text-decoration: underline wavy var(--squiggle); text-decoration-thickness: 1px; text-underline-offset: .22em; text-decoration-skip-ink: none; }

/* what the wire comes to */
.line, .line .full, .line .ghost { transition: color .5s, -webkit-text-stroke-color .5s, opacity .5s; }
.as-written { font-family: 'c0unt-r'; color: var(--bone); }
.w-1, .w-0 { font-family: 'c0unt-h'; color: var(--bone); }
.w-H, .w-L, .w-W { font-family: 'c0unt-r'; color: var(--thin); }
.w-Z { font-family: 'c0unt-h'; color: transparent; -webkit-text-stroke: 1px var(--bone); }
.w-U { font-family: 'c0unt-r'; color: var(--faint); }
.w-X { font-family: 'c0unt-h'; color: var(--bone); }
.w-X .ghost, .w-W .ghost {
  display: block; position: absolute; inset: 0; color: transparent; -webkit-text-stroke: 1px var(--bone);
  transform: translate(.11em, -.09em); pointer-events: none;
}
.w-W .ghost { -webkit-text-stroke-color: var(--dim); }
.w-dc { font-family: 'c0unt-r'; color: var(--bone); }
.w-dc .full { display: none; }
.w-dc .careless { display: inline; }
.w-Z .sq, .w-X .ghost .sq { text-decoration-color: var(--squiggle); }

/* the margin: the wire, you, and when you have done nothing for a while, everything */
.margin { display: grid; grid-template-columns: 1.1em 1.1em 9.5ch; align-items: baseline; column-gap: 6px; padding-right: 14px; font: 15px / 1 'c0unt-h'; position: relative; min-height: 36px; align-content: center; }
.margin::after { content: ''; position: absolute; right: 0; top: 7px; bottom: 7px; width: 5px; border: 1px solid var(--hair); border-left: 0; transition: border-width .2s; }
.wire { font-weight: normal; color: var(--bone); text-align: center; }
.you { font: 13px / 1 'c0unt-r'; color: var(--dim); text-align: center; }
.known { font: 13px / 1 'c0unt-r'; color: var(--dim); letter-spacing: .12em; opacity: 0; transition: opacity .3s; white-space: pre; }
.known.shown { opacity: 1; transition: opacity .9s; }
.row.driving .margin::after { border-color: var(--dim); }
.row.driving .you { color: var(--bone); }
.row:focus-within .margin::after { border-width: 3px 3px 3px 0; border-color: var(--bone); }
.line:focus-visible { outline: none; }

.ask { margin: 8px 0 30px; padding: 14px 0 0 clamp(0px, 8vw, 96px); border-top: 1px solid var(--hair); }
#q { margin: 0 0 6px; font: 18px / 1.3 'c0unt-r'; color: var(--dim); }
#answer { font: 22px / 1.3 'c0unt-h'; letter-spacing: .14em; text-decoration: none; color: var(--bone); overflow-wrap: anywhere; display: inline-block; padding: 4px 0; }
#answer:focus-visible { outline: none; text-decoration: underline wavy var(--dim); }

footer { max-width: 1000px; margin: 0 auto; padding: 0 16px 28px; display: flex; flex-wrap: wrap; gap: 6px 22px; font: 13px / 1.4 'c0unt-r'; color: var(--dim); }
footer a { text-decoration: none; padding: 6px 0; }
footer a:focus-visible, footer a:hover { text-decoration: underline wavy; outline: none; }
.noscript { max-width: 1000px; margin: 0 auto; padding: 0 16px 20px; font-size: 15px; color: var(--dim); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* small screens: lines wrap, the margin keeps the wire and you, and everything goes under the line */
@media (max-width: 759px) {
  :root { --size: 16px; --row: 1.35; }
  #book { padding: 18px 14px 6px; }
  h1, h2 { font-size: 28px; margin-bottom: 10px; }
  .cell { padding-right: 14px; margin-bottom: 26px; }
  .wires { padding-left: 0; }
  .row { grid-template-columns: minmax(0, 1fr) 1.1em 1.1em; grid-template-rows: auto 13px; column-gap: 6px; }
  .line { grid-row: 1; padding: 5px 0 1px; min-height: 32px; }
  .margin { display: contents; }
  .margin::after { display: none; }
  .wire, .you { grid-row: 1; align-self: center; }
  .margin .wire { grid-column: 2; }
  .margin .you { grid-column: 3; }
  .known { grid-row: 2; grid-column: 1 / -1; font-size: 11px; align-self: start; }
  .row::after { content: ''; position: absolute; right: -9px; top: 6px; bottom: 15px; width: 4px; border: 1px solid var(--hair); border-left: 0; }
  .row.driving::after { border-color: var(--dim); }
  .row:focus-within::after { border-width: 3px 3px 3px 0; border-color: var(--bone); }
  .ask { padding-left: 0; }
  #q { font-size: 15px; }
  #answer { font-size: 17px; letter-spacing: .06em; }
  footer { padding: 0 14px 24px; }
}
@media (pointer: coarse) { .line { min-height: 40px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
