/* The public pages' sheet: the landing page's own look, lifted out so every
   page under /typewriters/ and /writing/ is set the same way without carrying
   a copy of the landing's stylesheet. The tokens are the landing's tokens; the
   desk — machine over sheet — is the landing's hero desk with generic ids, so
   public/demo.js can drive it on any page. Nothing in here is the app's. */

:root {
  --paper: #F7F6F2; --paper-edge: #E4E2DC; --ribbon: #17161A; --enamel: #3A3D3C;
  --enamel-light: #6E7270; --ribbon-red: #A81E12; --seafoam: #7FA895;
  --ui: "JetBrains Mono", "Berkeley Mono", ui-monospace, Menlo, Consolas, monospace;
  --prose: "Courier Prime", "Courier New", Courier, monospace;
}
* { box-sizing: border-box; border-radius: 0; }
html, body { margin: 0; background: var(--paper); color: var(--ribbon); }
body { font-family: var(--ui); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ribbon-red); outline-offset: 2px; }

/* --- the bar ------------------------------------------------------------- */
header.bar {
  position: sticky; top: 0; z-index: 20; background: var(--paper);
  display: flex; align-items: stretch; justify-content: space-between;
  border-bottom: 1px solid var(--paper-edge);
}
.mark {
  padding: 14px 18px; background: var(--enamel); color: var(--paper);
  font-size: 13px; font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; outline: 1px solid transparent; outline-offset: -1px;
  transition: transform .08s ease-in, box-shadow .08s ease-in, background .08s ease-in, color .08s ease-in;
}
header.bar nav { display: flex; align-items: stretch; gap: 0; margin-right: auto; font-size: 13px; }
header.bar nav a { text-decoration: none; color: var(--enamel); padding: 0 12px; display: inline-flex; align-items: center;
  transition: transform .08s ease-in, box-shadow .08s ease-in, background .08s ease-in, color .08s ease-in; outline: 1px solid transparent; outline-offset: -1px; }
header.bar nav a[aria-current="page"] { color: var(--ribbon); box-shadow: inset 0 -3px 0 var(--ribbon); }
.open { display: inline-flex; align-items: center; padding: 0 18px; font-size: 13px; text-decoration: none; border-left: 1px solid var(--paper-edge); }
.open.signup { background: var(--ribbon); color: var(--paper); font-weight: 600; }
header.bar nav a, header.bar .open, .mark { margin-bottom: -1px; }
@media (hover: hover) {
  .mark:hover, header.bar nav a:hover, header.bar .open:hover { transform: translateY(2px); background: #FFFFFF; color: var(--ribbon); outline-color: var(--ribbon); box-shadow: 0 2px 4px rgba(23, 22, 26, .18); }
}
@media (prefers-reduced-motion: reduce) { .mark, header.bar nav a, header.bar .open { transition: none; } }

/* --- the page ------------------------------------------------------------ */
.page { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.lead-grid { max-width: 1240px; margin: 0 auto; padding: 30px 20px 28px; display: grid; grid-template-columns: 5fr 6fr; gap: 36px; align-items: center; border-bottom: 1px solid var(--paper-edge); }
.lead-grid > * { min-width: 0; }
.kicker { margin: 0 0 8px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--enamel-light); }
.kicker a { text-decoration: none; }
.kicker a:hover { text-decoration: underline; }
h1 { margin: 0; font-family: var(--prose); font-weight: 700; line-height: 1.05; letter-spacing: -.01em; font-size: clamp(36px, 5vw, 64px); text-wrap: balance; }
h1 .sub { display: block; margin-top: 8px; font-family: var(--ui); font-weight: 400; font-size: 16px; letter-spacing: 0; color: var(--enamel); }
p.lead { margin: 22px 0 0; max-width: 46ch; font-family: var(--prose); font-size: 20px; line-height: 1.45; color: var(--enamel); }
.ctas { margin-top: 22px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.ctas .fine { font-size: 13px; color: var(--enamel-light); flex-basis: 100%; margin: 0; }
.cta { display: inline-block; padding: 12px 18px; background: var(--enamel); color: var(--paper); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.cta.primary { padding: 16px 26px; font-size: 17px; background: var(--ribbon); }
.cta.quiet { background: transparent; color: var(--enamel); border: 1px solid var(--enamel); }
@media (hover: hover) {
  .cta:hover { background: var(--ribbon); }
  .cta.primary:hover { background: #FFFFFF; color: var(--ribbon); box-shadow: 0 0 0 1px var(--ribbon), 0 3px 8px rgba(23, 22, 26, .22); }
  .cta.quiet:hover { background: var(--enamel); color: var(--paper); }
}

/* Sections: a label column and the matter, the landing's own grid. */
section { display: grid; grid-template-columns: 220px 1fr; gap: 24px; padding: 40px 0; border-top: 1px solid var(--paper-edge); }
section:first-of-type { border-top: 0; }
section[id] { scroll-margin-top: 56px; }
section h2 { margin: 0; font-size: 20px; font-weight: 500; line-height: 1.3; }
section h2 small { display: block; margin-top: 4px; font-size: 13px; font-weight: 400; color: var(--enamel-light); }
.matter { max-width: 62ch; }
.matter p { margin: 0 0 16px; font-family: var(--prose); font-size: 17px; line-height: 1.6; }
.matter p:last-child { margin-bottom: 0; }
.matter h3 { margin: 26px 0 8px; font-size: 16px; font-weight: 500; }
.matter ul, .matter ol { margin: 0 0 16px; padding-left: 20px; font-family: var(--prose); font-size: 17px; line-height: 1.6; }
.matter li { margin-bottom: 6px; }
.matter blockquote { margin: 0 0 16px; padding-left: 14px; border-left: 2px solid var(--paper-edge); font-family: var(--prose); font-style: italic; font-size: 17px; line-height: 1.55; }
.matter blockquote cite { display: block; margin-top: 4px; font-style: normal; font-family: var(--ui); font-size: 13px; color: var(--enamel-light); }
.matter .aside { font-family: var(--ui); font-size: 13px; color: var(--enamel-light); }
/* Figures in a table: a spec sheet, ruled the way a service manual rules one. */
table.spec { border-collapse: collapse; width: 100%; max-width: 62ch; margin: 0 0 16px; font-size: 14px; }
table.spec th, table.spec td { text-align: left; vertical-align: top; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--paper-edge); }
table.spec th { font-weight: 500; color: var(--enamel); width: 40%; }
table.spec td .tag { font-size: 11px; color: var(--enamel-light); margin-left: 6px; }
/* The provenance tags the repository uses, so a page says which figures were
   measured and which were estimated, the way the build does. */
.tag { font-family: var(--ui); }
/* An exercise card: the rule, the ask, and a way onto the machine. */
.exercise { border: 1px solid var(--paper-edge); padding: 16px 18px; margin: 0 0 14px; display: grid; gap: 8px; max-width: 62ch; }
.exercise .rule { font-family: var(--ui); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--enamel-light); }
.exercise b { font-size: 16px; font-weight: 500; }
.exercise p { margin: 0; font-family: var(--prose); font-size: 16px; line-height: 1.55; }
.exercise .try { justify-self: start; }
/* Sources and the author, at the foot. */
.sources { font-size: 13px; color: var(--enamel); }
.sources ol { padding-left: 20px; margin: 0; }
.sources li { margin-bottom: 6px; }
.byline { font-size: 13px; color: var(--enamel-light); margin: 0 0 12px; }
footer.foot { border-top: 1px solid var(--paper-edge); padding: 18px 20px; font-size: 13px; color: var(--enamel-light); display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
footer.foot a { color: var(--enamel); }
.next { border-top: 1px solid var(--paper-edge); background: var(--paper-edge); }
.next div { max-width: 1100px; margin: 0 auto; padding: 40px 20px; display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; }
.next h2 { font-family: var(--prose); font-weight: 400; font-size: 20px; line-height: 1.4; margin: 0; }
.next p { margin: 6px 0 0; font-size: 13px; color: var(--enamel-light); }

/* --- the desk: machine over sheet -------------------------------------- */
#demo-desk { display: grid; grid-template-columns: 1fr; gap: 10px; justify-items: center; align-self: start; min-width: 0; position: relative; }
#demo-model { margin: -6px 0 0; text-align: center; line-height: 1.5; font-family: var(--ui); font-size: 16px; font-weight: 500; color: var(--ribbon); }
#demo-model b { font-weight: 500; }
#demo-model .sub { font-weight: 400; color: var(--enamel); }
#demo-stage { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 260px; }
#demo-stage, #demo-desk, #demo-sheet-wrap { min-width: 0; max-width: 100%; }
#demo-machine { position: absolute; top: 0; left: var(--mx, 0px); width: 100%; height: 100%; overflow: hidden; opacity: 0; transition: opacity .45s ease-out; }
#demo-machine.live { opacity: 1; }
#demo-machine .tw-gl { display: block; width: 100%; height: 100%; max-width: 100%; cursor: pointer; touch-action: none; }
#demo-hear { position: absolute; right: 42px; top: 11px; z-index: 3; margin: 0; font-family: var(--ui); font-size: 12px; color: var(--enamel-light); white-space: nowrap; pointer-events: none; opacity: .85; transition: opacity .3s ease-out; }
#demo-hear::after { content: ' \2192'; }
#demo-desk.heard #demo-hear { opacity: 0; }
#demo-sound { position: absolute; right: 6px; top: 6px; z-index: 3; width: 32px; height: 32px; padding: 0; background: none; border: 0; cursor: pointer; color: var(--enamel); opacity: .8; }
#demo-sound svg { display: block; width: 20px; height: 20px; margin: 0 auto; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#demo-sound .off { display: none; }
#demo-sound[aria-pressed="false"] .on { display: none; }
#demo-sound[aria-pressed="false"] .off { display: block; }
#demo-sound:focus-visible { outline: 2px solid var(--ribbon-red); outline-offset: 0; }
#demo-sheet-wrap { display: flex; flex-direction: column; align-items: center; min-width: 0; max-width: 100%; position: relative; }
#demo-sheet {
  position: relative; box-sizing: content-box;
  --adv: 10.2px; --pad-top: 30px; --pad-bot: 34px; --page-h: 340px; --gap-h: 0px;
  --band: calc(var(--pad-top) + var(--page-h) + var(--pad-bot));
  --block: calc(var(--page-h) + var(--gap-h));
  padding: var(--pad-top) calc(var(--adv) * 5) var(--pad-bot);
  background-color: #F4F0E5;
  background-image:
    radial-gradient(ellipse 60px 40px at 82% 18%, rgba(140, 96, 40, .10), transparent 70%),
    radial-gradient(ellipse 40px 30px at 14% 74%, rgba(140, 96, 40, .09), transparent 70%),
    radial-gradient(ellipse 90px 50px at 60% 92%, rgba(120, 84, 36, .07), transparent 70%),
    radial-gradient(circle 6px at 36% 40%, rgba(120, 84, 36, .14), transparent 80%),
    radial-gradient(circle 4px at 70% 63%, rgba(120, 84, 36, .12), transparent 80%);
  box-shadow: inset 0 0 38px rgba(110, 78, 30, .15), inset 0 0 4px rgba(110, 78, 30, .14), 3px 4px 0 rgba(23, 22, 26, .12);
  transform: rotate(-.5deg);
  height: var(--page-h); overflow: hidden;
}
#demo-sheet::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: repeating-linear-gradient(to bottom,
    rgba(110, 78, 30, .35) 0 1px, transparent 1px calc(var(--band) - 1px),
    rgba(110, 78, 30, .35) calc(var(--band) - 1px) var(--band),
    transparent var(--band) var(--block));
}
#demo-paper { box-sizing: content-box; display: block; position: relative; z-index: 1; background: transparent; border: 0; outline: none; resize: none; padding: 0; height: auto; overflow-y: hidden; min-height: var(--page-h); caret-color: transparent; tab-size: 4; color: #2B2520; }
#demo-sheet .strikes { position: absolute; inset: 0; pointer-events: none; z-index: 2; color: #2B2520; }
#demo-sheet .strikes i { position: absolute; font-style: normal; white-space: pre; transform-origin: 50% 60%; animation: strike-ink .2s cubic-bezier(.2, .9, .3, 1) both; }
@keyframes strike-ink {
  0%   { transform: translateY(1px) scale(1.08); text-shadow: 0 0 4px rgba(43, 37, 32, .75); opacity: 1; }
  55%  { transform: none; text-shadow: 0 0 1px rgba(43, 37, 32, .35); opacity: 1; }
  100% { transform: none; text-shadow: none; opacity: 0; }
}
.tw-cursor { position: absolute; width: var(--adv); height: 1.2em; z-index: 2; background: #F7F6F2; mix-blend-mode: difference; pointer-events: none; }
.tw-cursor[hidden] { display: none; }
.tw-cursor.idle { animation: tw-blink 1.06s steps(1) infinite; }
@keyframes tw-blink { 50% { opacity: 0; } }
.tw-mirror { position: absolute; visibility: hidden; pointer-events: none; white-space: pre-wrap; overflow-wrap: break-word; word-wrap: break-word; box-sizing: content-box; }
#demo-tip { position: absolute; left: 22px; bottom: 34px; margin: 0; z-index: 3; background: var(--ribbon); color: var(--paper); font-size: 13px; padding: 7px 11px; }
#demo-tip i { position: absolute; left: 18px; top: -7px; border: 7px solid transparent; border-top: 0; border-bottom-color: var(--ribbon); }
#demo-tip.gone { display: none; }
#demo-refuse { min-height: 1.5em; margin-top: 8px; font-size: 13px; color: var(--ribbon); }
#demo-refuse.on { color: var(--ribbon-red); }
@media (prefers-reduced-motion: reduce) {
  #demo-machine, #demo-hear { transition: none; }
  #demo-sheet .strikes i, .tw-cursor.idle { animation: none; }
}
@media (max-width: 960px) { .lead-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  header.bar { flex-wrap: wrap; }
  .mark, header.bar .open { white-space: nowrap; }
  header.bar nav { order: 9; flex-basis: 100%; margin: 0; padding: 0 6px; border-top: 1px solid var(--paper-edge); overflow-x: auto; scrollbar-width: none; }
  header.bar nav::-webkit-scrollbar { display: none; }
  header.bar nav a { padding: 10px 8px; margin: 0; white-space: nowrap; }
  section { grid-template-columns: 1fr; gap: 10px; padding: 28px 0; }
  section[id] { scroll-margin-top: 88px; }
  .next div { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .lead-grid { padding: 28px 16px 24px; gap: 26px; }
  #demo-machine { aspect-ratio: 4 / 3; min-height: 0; }
  #demo-hear { display: none; }
  .cta.primary { width: 100%; text-align: center; }
}
