/* The phone client. One file, mobile-first, no framework.
 *
 * The old stylesheet was 1,288 lines because it laid out a card grid, a modal, a
 * study runner, an SVG figure with computed leader lines, and a music player.
 * This lays out a list, a sheet and a table. */

:root {
  /* The original Ila palette: iOS-style dark grey, not a blue-purple theme. */
  --bg: #1c1c1e;
  --panel: #2c2c2e;
  --line: #3a3a3c;
  --fg: #eee;
  --dim: #888;
  --accent: #3a82f7;
  --green: #30d158;
  --amber: #d4a72c;
  --red: #ff6b6b;
  --tap: 44px;            /* nothing tappable is smaller than this */
}

* { box-sizing: border-box; }

/* The `hidden` attribute works by `display: none` in the UA stylesheet, so ANY
 * author `display` rule beats it. #sheet is `display: flex`, which meant a
 * hidden sheet stayed a full-screen invisible overlay swallowing every tap on
 * the board -- the app was unusable and nothing but a real browser could see it.
 * Declared once, for every element, rather than per selector. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* The gate and the app swap on a class set during head parsing, so neither is
 * ever painted and then hidden. */
#app { display: none; }
html.unlocked #app { display: flex; flex-direction: column; height: 100%; }
html.unlocked #gate { display: none; }

#gate {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 1rem; padding: 1rem;
}
#gate h1 { font-weight: 400; letter-spacing: .1em; margin: 0; color: var(--accent); }
#gate-form { display: flex; gap: .5rem; }

input, textarea, button {
  font: inherit; color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .6rem .8rem;
  min-height: var(--tap);
}
button { cursor: pointer; }
button:active { background: var(--line); }

/* ------------------------------------------------------------------ chrome */

header {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: .5rem .75rem calc(.5rem + env(safe-area-inset-top, 0px));
  display: flex; flex-direction: column; gap: .5rem;
}
#crumb { font-size: .95rem; color: var(--dim); overflow-x: auto; white-space: nowrap; }
#crumb .crumb-root, #crumb .crumb { color: var(--accent); }
#crumb .crumb-sep { margin: 0 .35rem; }
#tabs { display: flex; gap: .4rem; }
/* `min-width: 0` because a flex item will not shrink below its content by
   default: with five tabs on a 360px phone the row overflowed the screen
   instead of dividing it. */
#tabs button {
  flex: 1; min-width: 0; padding: .4rem .2rem; min-height: 40px;
  font-size: .9rem; white-space: nowrap;
}
#tabs button.on { border-color: var(--accent); color: var(--accent); }

main { flex: 1; min-height: 0; overflow-y: auto; padding: .75rem; }

footer {
  padding: .5rem .75rem calc(.5rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  color: var(--amber); font-size: .9rem;
}

.hint { color: var(--dim); font-size: .9rem; }
.empty { color: var(--dim); }

/* ------------------------------------------------------------------- board */

.tiles { list-style: none; margin: 0; padding: 0; }
.tile {
  display: flex; align-items: center; gap: .5rem;
  min-height: var(--tap);
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: .5rem;
  background: var(--panel);
}
.tile.with-preview { flex-direction: column; align-items: stretch; gap: .35rem; }
/* The pinned CLAUDE.md, set apart from the board it describes. This is the blank
 * line the TUI draws above it -- the note is last on both, so the gap is a top
 * margin here and there is no cursor on this side to park anywhere. */
.tile.pinned { margin-top: 1.5rem; }
.tile-head { display: flex; align-items: baseline; gap: .5rem; }
.tile-head .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tile-given { color: var(--dim); font-style: italic; font-size: .9rem; }
.tile .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* The whole body, never clipped. The old board view faded it out at 160px,
 * which hid the tail of every answer long enough to be worth reviewing -- and
 * reviewing is what the board view is for. */
.preview { font-size: .92rem; color: #ccc; }
.preview p { margin: .25rem 0; overflow-wrap: anywhere; }
.preview h2, .preview h3, .preview h4 { font-size: 1rem; margin: .4rem 0 .15rem; }
.preview ul, .preview ol { margin: .25rem 0; padding-left: 1.1rem; }
.preview /* A .txt card: the text, and no markdown applied to it. pre-wrap rather than
   plain pre because these files hold a whole pasted paragraph on one line, and
   `pre` would give it a horizontal scrollbar the length of the answer. Not
   monospace: it is prose, not code -- pre.code is the other thing. */
pre.text {
  white-space: pre-wrap; overflow-wrap: anywhere; margin: 0;
  font: inherit; color: inherit;
}

pre.code { margin: .25rem 0; font-size: .85rem; }
.preview pre.text { margin: .25rem 0; font-size: .9rem; }

.preview-list { list-style: none; margin: .15rem 0 0; padding: 0; font-size: .92rem; }
.preview-list li { display: flex; gap: .5rem; align-items: baseline; }
.preview-list .box { color: var(--dim); width: 1em; flex: none; }
.preview-list li.done .box { color: var(--green); }
.preview-list li.done .item { color: var(--dim); }
.preview-list .item { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.preview-list .age { font-size: .8rem; white-space: nowrap; }
.tile.board .name { color: var(--fg); font-weight: 600; }
/* A knowledge deck was a blue pill in the original, not another colour of text. */
.tile.board.knowledge .name {
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0 .6rem;
}
.tile .count { color: var(--dim); font-variant-numeric: tabular-nums; }
.tag {
  font-size: .75rem; color: var(--dim);
  border: 1px solid var(--line); border-radius: 6px; padding: 0 .35rem;
}

/* Fresh is grey, not green -- the original had this right. Green draws the eye
 * to the items that need nothing done to them. */
.age-fresh { color: #666; }
.age-aging { color: var(--amber); }
.age-stale { color: var(--red); }
.age-none { color: #555; }

/* -------------------------------------------------------------------- card */

#sheet {
  position: fixed; inset: 0; z-index: 3;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding: calc(.75rem + env(safe-area-inset-top, 0px)) .75rem
           calc(.75rem + env(safe-area-inset-bottom, 0px));
}
/* Fixed height with an internally scrolling body, for the reason the old modal
 * documented: view and edit mode swap different elements into the same slot, and
 * a box that sizes itself to whichever is showing resizes under your finger. */
#sheet-inner { flex: 1; min-height: 0; overflow-y: auto; }
#sheet-close {
  position: absolute; top: calc(.5rem + env(safe-area-inset-top, 0px)); right: .5rem;
  width: var(--tap); height: var(--tap);
  font-size: 1.5rem; line-height: 1; padding: 0;
}
#sheet h2 { margin: 0 3rem .25rem 0; color: var(--fg); font-size: 1.2rem; }
#sheet .given { color: var(--dim); font-style: italic; margin: .25rem 0; }
#sheet .url { margin: .25rem 0; overflow-wrap: anywhere; }
#sheet a { color: var(--accent); }

.rendered { padding-bottom: 2rem; }
.rendered h2, .rendered h3, .rendered h4 { color: var(--accent); margin: 1rem 0 .25rem; }
.rendered p { margin: .5rem 0; overflow-wrap: anywhere; }
.rendered ul, .rendered ol { margin: .5rem 0; padding-left: 1.25rem; }
.rendered code { color: var(--amber); }

/* A .txt card: the text, and no markdown applied to it. pre-wrap rather than
   plain pre because these files hold a whole pasted paragraph on one line, and
   `pre` would give it a horizontal scrollbar the length of the answer. Not
   monospace: it is prose, not code -- pre.code is the other thing. */
pre.text {
  white-space: pre-wrap; overflow-wrap: anywhere; margin: 0;
  font: inherit; color: inherit;
}

pre.code {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem; overflow-x: auto; margin: .5rem 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem;
}
pre.code.mine { border-color: var(--amber); }

.editor {
  width: 100%; height: 100%; min-height: 50vh; resize: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.checklist { list-style: none; margin: .5rem 0; padding: 0; }
.checklist li {
  display: flex; align-items: center; gap: .5rem;
  min-height: var(--tap); border-bottom: 1px solid var(--line);
}
.checklist label { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }
.checklist input[type=checkbox] {
  width: 24px; height: 24px; min-height: 0; flex: none; accent-color: var(--accent);
}
.checklist .item { overflow-wrap: anywhere; }
.checklist .item.done { color: var(--dim); }
.checklist .age { font-size: .8rem; white-space: nowrap; }

.pdf { margin-top: 1rem; }
.btn {
  display: inline-block; text-decoration: none;
  background: var(--panel); border: 1px solid var(--accent); color: var(--accent);
  border-radius: 8px; padding: .6rem 1rem; min-height: var(--tap);
}

/* -------------------------------------------------------------------- body */

table.body { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
table.body th {
  text-align: left; color: var(--dim); font-weight: 400; width: 4.5rem;
  font-family: ui-monospace, monospace;
}
table.body td { padding: .15rem 0 .15rem .5rem; }
table.body input { width: 100%; text-align: right; }
#body h3 { color: var(--accent); font-size: 1rem; margin: 1rem 0 .25rem; }

#pad-text { width: 100%; min-height: 60vh; }

@media (min-width: 700px) {
  main, header, footer { max-width: 46rem; margin-inline: auto; }
  #sheet { padding-inline: max(.75rem, calc((100vw - 46rem) / 2)); }
}
