/* The page is a Jot note. Colours are the app's own papers (Cream, White,
   True Dark) and their inks; the type is the system monospace the app
   defaults to; every line sits on the 28px pitch the dot grid is drawn at. */

:root {
  --lh: 28px;            /* one line, and one row of dots */
  --pitch-x: 22px;       /* dot spacing across, as in the app */
  --margin: 15ch;        /* the results column */
  --col: 46rem;
  --font: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

:root[data-paper="cream"] {
  --paper: #F7F0E1;
  --chrome: #EBE1CE;
  --ink: #2E271C;
  --secondary: #6B5E4A;
  --accent: #2E6A47;
  --link: #1A5CB8;
  --guide: rgba(102, 87, 61, 0.22);
  --mark: rgba(214, 170, 60, 0.30);
  --rule: rgba(46, 39, 28, 0.12);
  color-scheme: light;
}

:root[data-paper="white"] {
  --paper: #FFFFFF;
  --chrome: #F1F1F5;
  --ink: #1C1C1E;
  --secondary: #636366;
  --accent: #2E6A47;
  --link: #1A5CB8;
  --guide: rgba(0, 0, 0, 0.16);
  --mark: rgba(255, 204, 0, 0.32);
  --rule: rgba(0, 0, 0, 0.10);
  color-scheme: light;
}

:root[data-paper="dark"] {
  --paper: #131315;
  --chrome: #1C1C1E;
  --ink: #E8E5E0;
  --secondary: #A39D94;
  --accent: #7AC78F;
  --link: #85B8ED;
  --guide: rgba(255, 255, 255, 0.14);
  --mark: rgba(255, 214, 10, 0.24);
  --rule: rgba(255, 255, 255, 0.10);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
/* `.l` sets display, which would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--paper);
  background-image: radial-gradient(circle, var(--guide) 1px, transparent 1.3px);
  background-size: var(--pitch-x) var(--lh);
  background-position: calc(var(--pitch-x) / 2) calc(var(--lh) / 2);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: var(--lh);
  font-variant-ligatures: none;
  -webkit-font-smoothing: antialiased;
}

/* The note's header bar, like the app's. */
.chrome {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  height: var(--lh);
  padding: 0 12px;
  background: color-mix(in srgb, var(--chrome) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
  font-size: 12px;
  color: var(--secondary);
}
.chrome-title { font-weight: 600; color: var(--ink); }
.chrome-spacer { flex: 1; }
.chrome-button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0 8px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.chrome-button:hover { background: var(--rule); color: var(--ink); }

/* The note. */
.note {
  max-width: calc(var(--col) + var(--margin));
  margin: 0 auto;
  padding: calc(var(--lh) * 2) calc(var(--pitch-x) * 2) calc(var(--lh) * 3);
}

/* A line of the note. Text flows normally (it may wrap onto more rows of
   the grid); the margin on the right is kept clear for its answer. */
.l {
  position: relative;
  display: block;
  min-height: var(--lh);
  margin: 0;
  padding-right: calc(var(--margin) + var(--pitch-x));
  font-size: inherit;
  font-weight: inherit;
  line-height: var(--lh);
}

/* A line's answer, in the margin, like the app's results. */
.r {
  position: absolute;
  top: 0;
  right: 0;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Folded markdown markers: there, but faint, the way the app shows them. */
.mk { color: var(--secondary); opacity: 0.55; font-weight: 400; }
.h1 { font-weight: 700; font-size: 15px; }
.h2 { font-weight: 700; }
.muted { color: var(--secondary); }
.indent { display: inline-block; width: 2ch; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, textarea:focus-visible, input:focus-visible + .box {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 3px;
}

/* The download: a key-shaped button that still sits on one line of the note. */
.download {
  display: inline-block;
  height: 24px;
  margin: 2px 0;
  padding: 0 10px;
  line-height: 22px;
  border: 1px solid var(--accent);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--accent);
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.download:hover { text-decoration: none; background: color-mix(in srgb, var(--accent) 18%, transparent); }
.download:active { transform: translateY(1px); border-bottom-width: 1px; margin-bottom: 3px; }
.chrome-download { color: var(--accent); font-weight: 600; }

code, kbd {
  font: inherit;
  color: var(--ink);
  background: var(--rule);
  border-radius: 4px;
  padding: 1px 4px;
}
kbd { background: none; border: 1px solid var(--rule); border-bottom-width: 2px; padding: 0 4px; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }
b { font-weight: 700; }

.copy {
  font: inherit;
  color: var(--link);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.copy[data-done] { color: var(--accent); }

/* The live scratchpad: a textarea, with the answers laid over the margin. */
.pad {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--margin);
  column-gap: var(--pitch-x);
  margin: 0;
  border-left: 2px solid var(--accent);
  padding-left: calc(var(--pitch-x) - 2px);
  margin-left: calc(var(--pitch-x) * -1);
}
.pad textarea {
  grid-column: 1;
  grid-row: 1;
  display: block;
  width: 100%;
  min-height: calc(var(--lh) * 3);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  caret-color: var(--accent);
  font: inherit;
  line-height: var(--lh);
  white-space: pre;
  overflow-x: auto;
  overflow-y: hidden;
  resize: none;
  tab-size: 4;
}
.pad textarea:focus-visible { outline: none; }
.pad textarea::selection { background: var(--mark); }
.pad-results {
  grid-column: 2;
  grid-row: 1;
  pointer-events: none;
}
.pad-results div {
  height: var(--lh);
  text-align: right;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Lists. "- " is two characters; wrapped lines hang under the text. */
.bullets, .todos { list-style: none; margin: 0; padding: 0; }
.bullets .l { padding-left: 2ch; text-indent: -2ch; }
.bullets .r { text-indent: 0; }
#news .item { padding-left: 2ch; text-indent: -2ch; }
#news .item.depth-1 { margin-left: 2ch; }
#news .item.depth-2 { margin-left: 4ch; }
#news .item.depth-3 { margin-left: 6ch; }
/* "- [ ] " is six characters; wrapped lines hang under the text. */
.todo { cursor: pointer; padding-left: 6ch; text-indent: -6ch; }
.todo input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.todo .box { color: var(--secondary); }
.todo .box::before { content: "- [ ] "; white-space: pre; }
.todo input:checked + .box::before { content: "- [x] "; color: var(--accent); }
.todo input:checked ~ .t { color: var(--secondary); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--secondary) 60%, transparent); }
.todo input:checked ~ .t code, .todo input:checked ~ .t kbd, .todo input:checked ~ .t mark { color: var(--secondary); }
.todo .r { text-indent: 0; }

/* Display modes. */
.modes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: calc(var(--pitch-x) * 2);
  align-items: start;
}
.mode-list { margin: 0; }
.mode-list .l { display: grid; grid-template-columns: 14ch minmax(0, 1fr); padding-right: 0; }
.mode-list dt { grid-column: 1; }
.mode-list dd { grid-column: 2; margin: 0; color: var(--secondary); }
.shot { margin: 0; width: 196px; }
.shot img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--rule);
}
.shot figcaption {
  font-size: 12px;
  line-height: var(--lh);
  color: var(--secondary);
}

/* The comparison, as a monospaced table in the note. On wide screens cells
   wrap, each wrapped line still one 28px row of the grid; on phones it keeps
   to one line per cell and scrolls sideways with the row labels pinned. */
.compare-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.compare-wrap:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.compare {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: var(--lh);
}
.compare th, .compare td {
  padding: 0 12px 0 0;
  text-align: left;
  font-weight: 400;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
}
.compare thead th { font-weight: 700; color: var(--ink); border-bottom-color: var(--secondary); white-space: nowrap; }
.compare thead th a { color: var(--ink); }
.compare tbody th { color: var(--secondary); width: 20ch; }
.compare td { color: var(--secondary); }
.compare .us { color: var(--accent); font-weight: 600; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 720px) {
  .compare { width: auto; }
  .compare th, .compare td { white-space: nowrap; }
  .compare tbody th, .compare thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--paper);
    width: auto;
  }
}

/* The first-launch heads-up: amber edge and a tinted wash, so it reads as a
   warning in the note rather than one more muted line. */
:root[data-paper="cream"] { --warn: #8A5A12; --warn-wash: rgba(214, 150, 40, 0.14); }
:root[data-paper="white"] { --warn: #8A5A12; --warn-wash: rgba(214, 150, 40, 0.12); }
:root[data-paper="dark"]  { --warn: #E6B45E; --warn-wash: rgba(230, 180, 94, 0.12); }
.heads-up {
  margin: var(--lh) 0 0 calc(var(--pitch-x) * -1);
  padding: 0 0 0 calc(var(--pitch-x) - 3px);
  border-left: 3px solid var(--warn);
  background: var(--warn-wash);
  border-radius: 0 8px 8px 0;
}
.heads-up .l { padding-right: var(--pitch-x); }
.heads-up b { color: var(--ink); }
.heads-up #heads-up-title, .heads-up #heads-up-title .mk { color: var(--warn); opacity: 1; }
.heads-up #heads-up-title b { color: var(--warn); }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps .l { padding-left: 3ch; text-indent: -3ch; counter-increment: step; }
.steps .l::before { content: counter(step) ". "; color: var(--warn); font-weight: 700; }

/* Buy me a coffee: a details block, closed until asked for. */
.coffee summary { list-style: none; cursor: pointer; }
.coffee summary::-webkit-details-marker { display: none; }
.coffee-button {
  display: inline-block;
  height: 24px;
  margin: 2px 0;
  padding: 0 10px;
  line-height: 22px;
  border: 1px solid var(--warn);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--warn);
  font-weight: 700;
  background: var(--warn-wash);
}
.coffee summary:hover .coffee-button { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.coffee[open] .coffee-button::after { content: " ×"; }
.coffee summary:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 6px; }
.coffee-body { padding: var(--lh) 0 0 2ch; }
.upi-qr {
  display: block;
  width: 168px;
  height: 168px;
  margin: 0 0 calc(var(--lh) - 8px);
  padding: 8px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--rule);
  image-rendering: pixelated;
}
/* The upi:// link only does anything on a phone with a UPI app. */
@media (min-width: 721px) and (hover: hover) { .hide-desktop { display: none; } }

/* Paper picker. */
.paper-pick {
  font: inherit;
  color: var(--link);
  background: none;
  border: 0;
  padding: 0 2px;
  cursor: pointer;
}
.paper-pick[aria-pressed="true"] { color: var(--ink); font-weight: 700; }
.paper-pick + .paper-pick::before { content: "· "; color: var(--secondary); font-weight: 400; }

/* The caret at the end of the note. */
.caret {
  display: inline-block;
  width: 2px;
  height: 18px;
  vertical-align: -3px;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .caret { animation: none; }
}

/* Small phones: the header keeps to one line, and the download's version
   note drops under the button instead of colliding with it. */
@media (max-width: 420px) {
  .dl-line { padding-right: 0; }
  .dl-line .r { position: static; display: block; color: var(--secondary); }
  .chrome { padding: 0 6px; gap: 0; }
  .chrome-button { padding: 0 6px; }
  .paper-label { display: none; }
}

/* Phones: the margin narrows and the screenshot moves under the list. */
@media (max-width: 640px) {
  :root { --margin: 11ch; }
  body { font-size: 13px; }
  .note { padding-left: var(--pitch-x); padding-right: var(--pitch-x); }
  .pad { margin-left: calc(var(--pitch-x) * -1); }
  .modes { grid-template-columns: 1fr; }
  .shot { width: 160px; margin-top: var(--lh); }
  .mode-list .l { grid-template-columns: 12ch minmax(0, 1fr); }
}
