/*
 * InkPick — layout.css
 * Page structure: top bar, collection tabs, the notebook
 * sheet, picker bar, task list and add row.
 */

/* ============================================================
   2. BASE / LAYOUT — a single notebook page on a dot grid
   ============================================================ */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 18px; }
body {
  margin: 0; min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.3px);
  background-size: 24px 24px;
  font-family: "Caveat", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  line-height: 1.45;
}
button, input, select {
  font: inherit; color: inherit;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.topbar {
  display: flex; align-items: baseline; justify-content: space-between; gap: .8rem;
  max-width: 720px; margin: 0 auto; padding: 1rem 1rem .3rem;
}
.brand { font-size: 1.9rem; font-weight: 700; letter-spacing: .02em; }
.brand .brand-bullet { color: var(--accent); }
.tagline { display:block; font-size: .78rem; color: var(--ink-soft);
  font-family: system-ui, sans-serif; letter-spacing: .04em; }
.top-actions { display: flex; gap: .4rem; }

/* Collection tabs — like labelled index tabs on a journal edge */
.tabs {
  max-width: 720px; margin: .4rem auto 0; padding: 0 1rem;
  display: flex; gap: .45rem;
  flex-wrap: nowrap; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; white-space: nowrap;
  border: 1.5px solid var(--line); border-bottom: none;
  background: var(--card); color: var(--ink-soft);
  padding: .45rem .9rem; border-radius: 10px 10px 0 0;
  min-height: 44px; cursor: pointer;
}
.tab.active { color: var(--ink); border-color: var(--ink);
  font-weight: 600; box-shadow: var(--shadow); }
.tab-edit { margin-left: .45em; color: var(--accent); font-weight: 400; }
/* The "+" tab stays pinned on the right while the list scrolls under it */
.tab.add { color: var(--accent); font-weight: 700;
  position: sticky; right: 0; z-index: 1; background: var(--paper);
  box-shadow: -8px 0 8px -6px rgba(0,0,0,.25); }

/* The page itself */
.sheet {
  position: relative;
  max-width: 720px; margin: 0 auto 2rem;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 4px 14px 14px 4px;
  box-shadow: var(--shadow);
  padding: 1.1rem 1.1rem 1.4rem 78px;
  min-height: 60vh;
}
/* Red margin line, the signature of a ruled journal page — the marker travels along it */
.margin-line {
  position: absolute; top: 0; bottom: 0; left: 58px;
  border-left: 2px solid var(--red); opacity: .55;
}

/* ============================================================
   3. PICKER — big button, status line, and the travelling marker
   ============================================================ */
/* The pick button is a compact die sitting in the gutter, left of the
   red margin line; the text right of the line explains and also triggers it. */
.pickbar { display: flex; align-items: center; gap: 26px;
  margin: 0 0 1rem -68px; } /* button spans 10-52px: clear of the line at 58px */
.pick-btn {
  flex: none; width: 42px; height: 42px; padding: 0;
  border: 2px solid var(--ink); border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 1.45rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.pick-btn:active { transform: translate(1px,1px); }
.pick-btn[disabled], .pick-hint[disabled] { opacity: .55; cursor: wait; }
.pick-info { min-width: 0; }
.pick-hint {
  border: none; background: none; padding: 0; cursor: pointer;
  font-family: inherit; font-size: 1.35rem; font-weight: 700; color: var(--ink);
  text-decoration: underline dotted var(--accent);
  text-decoration-thickness: 2px; text-underline-offset: 5px;
}
.pick-status { font-size: .95rem; color: var(--ink-soft); min-height: 1.4em; }
.pick-status strong { color: var(--ink); }

/* The marker: sits in the left gutter, jumps in discrete steps (e-ink friendly) */
.marker {
  position: absolute; left: 14px; width: 36px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; color: var(--red);
  transition: none;
  pointer-events: none;
  text-shadow: var(--shadow);
}
.marker::after { content: "➤"; }

/* ============================================================
   4. TASK LIST — Bullet-Journal rows with signifier column
   ============================================================ */
.divider {
  display: flex; align-items: center; gap: .6rem;
  font-size: .8rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-soft); font-family: system-ui, sans-serif;
  margin: 1.2rem 0 .4rem;
}
.divider::after { content: ""; flex: 1; border-top: 2px dashed var(--line); }
.tasks { list-style: none; margin: 0; padding: 0; }
.task {
  display: flex; align-items: center; gap: .55rem;
  min-height: 52px; padding: .3rem .3rem .3rem var(--row-indent);
  border-bottom: 1px solid var(--line);
  position: relative;
}
.task:last-child { border-bottom: none; }
/* Priority star: a badge on the checkbox corner (keeps every row's
   checkbox at the same x position) */
.signifier { position: absolute; top: 0; right: -1px;
  font-size: .95rem; line-height: 1; color: var(--gold);
  font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; }
/* The state toggle is drawn as a checkbox: user testing showed the
   BuJo bullets (• / ×) were not obvious to tap. */
.bullet {
  width: 44px; height: 44px; flex: none;
  border: none; background: none; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  position: relative;
}
.bullet::before {
  content: ""; width: 27px; height: 27px;
  border: 2.5px solid var(--ink); border-radius: 7px;
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; line-height: 1; font-weight: 700;
  font-family: system-ui, sans-serif;
}
.bullet:hover { background: var(--paper); }
.task.done .bullet::before {
  content: "✓";
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.task-label {
  flex: 1; text-align: left; background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 1.3rem; color: var(--ink);
  padding: .35rem .2rem; min-height: 44px; display: flex; align-items: center; gap: .5rem;
}
.task.done .task-label { color: var(--ink-soft); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.recur-flag { font-size: .8rem; color: var(--accent);
  font-family: system-ui, sans-serif; border: 1px solid var(--accent);
  border-radius: 999px; padding: 0 .45em; }
.ink-img { height: 2.3em; width: auto; max-width: 100%; display: block; }
/* Dark theme: no white chip — invert lightness instead (black ink becomes
   white; colored strokes keep roughly the same hue, just lightened). */
[data-theme="dark"] .ink-img, [data-theme="dark"] .ink-preview { filter: invert(1) hue-rotate(180deg); }
.empty { color: var(--ink-soft); font-style: italic; padding: .6rem .2rem; }

/* Pen toolbar (handwriting dialog): two fixed rows — ink, then width —
   so wrapping and history swatches never shift the size controls around. */
.pen-tools { display: flex; flex-direction: column; gap: .55rem; margin-bottom: .7rem;
  font-family: system-ui, sans-serif; font-size: .85rem; color: var(--ink-soft); }
.pen-row { display: flex; align-items: center; gap: .5rem; }
.pen-label { flex: none; min-width: 5.2em; }
.pen-options { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; flex: 1; min-width: 0; }
.swatch {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--line); background: var(--sw, #141414); padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  position: relative;
}
/* Active = thicker ink border + a checkmark: readable even in e-ink mode */
.swatch.active { border: 3px solid var(--ink); }
.swatch.active::after {
  content: "✓"; font-weight: 900; font-size: 1.05rem;
  color: #fff; -webkit-text-stroke: 1px #000; paint-order: stroke fill;
}
.swatch.custom {
  background: conic-gradient(#e33, #ec0, #3b3, #0cc, #33e, #c3c, #e33);
  overflow: hidden;
}
.swatch.custom::before { content: "+"; font-size: 1.3rem; font-weight: 800;
  color: #fff; -webkit-text-stroke: 1px #000; paint-order: stroke fill; }
.swatch.custom input { position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; border: 0; padding: 0; }
.pen-size {
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
}
.pen-size.active { border: 3px solid var(--accent); background: var(--paper); }
.pen-size i { border-radius: 50%; background: currentColor; display: block; }
.pen-size[data-size="0.6"] i { width: 5px;  height: 5px; }
.pen-size[data-size="1"]   i { width: 9px;  height: 9px; }
.pen-size[data-size="1.8"] i { width: 15px; height: 15px; }
/* Live sample of the current pen (in the dialog header): instant feedback */
.pen-preview { display: inline-flex; align-items: center; min-width: 60px; justify-content: flex-end; }
.pen-preview i { display: block; width: 56px; border-radius: 999px; }

/* The picked row: a wobbly hand-drawn circle around it */
.task.picked::before {
  content: ""; position: absolute; inset: 2px -6px 2px -8px;
  border: 2.5px solid var(--accent);
  border-radius: 48% 12px 45% 14px / 14px 46% 12px 44%;
  transform: rotate(-.5deg);
  pointer-events: none;
}
.task.hop { background: var(--paper); }

/* Add-task row */
.addrow { display: flex; align-items: center; gap: .55rem; margin-top: .5rem;
  padding-left: var(--row-indent); }
.addrow .bullet-new { width: 44px; flex: none; display: flex; justify-content: center; }
.addrow .bullet-new::before { content: ""; width: 25px; height: 25px;
  border: 2px dashed var(--line); border-radius: 7px; }
.addrow input {
  flex: 1; min-width: 0;
  min-height: 48px; padding: .3rem .6rem;
  border: none; border-bottom: 2px solid var(--line);
  background: transparent; font-family: inherit; font-size: 1.25rem;
}
.addrow input:focus { border-bottom-color: var(--accent); outline: none; }

#addBtn { border-width: 2px; }
