/* scratch.css — Notes module, editorial two-column layout.
   Filename kept for backward compat (existing index.html links to it);
   contents fully replaced for Drop 5. */

.notes-view {
  background: var(--paper);
  min-height: 100%;
}

/* ---------- Body grid ---------- */
.notes-body {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: calc(100vh - 220px);
}

/* ---------- List rail ---------- */
.notes-list {
  border-right: 1px solid var(--rule);
  padding: 24px 28px;
  overflow-y: auto;
}
.notes-list-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.notes-search {
  position: relative;
}
.notes-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--mid);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.notes-list-items {
  display: flex;
  flex-direction: column;
}
.notes-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--rule);
  padding: 14px 4px;
  cursor: pointer;
  font-family: var(--sans);
  transition: background var(--dur-fast) ease;
}
.notes-list-item:hover { background: rgba(80, 80, 80, 0.04); }
.notes-list-item.active { background: var(--paper-2); }
/* Legacy header rule retained for QuickCapture / other consumers. */
.notes-list-item-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  gap: 12px;
}

/* ---------- Apple-Notes-style row layout ---------- */
.notes-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.notes-row-title {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
  margin: 0;
  /* Single-line clamp, ellipsis when too long. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notes-row-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  min-width: 0;
}
.notes-row-date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--mid);
  flex-shrink: 0;
}
.notes-row-snippet {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--mid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.notes-row-client {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--mid);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Square thumbnail, paper-on-paper. Border keeps it visible on the same
   warm background; rounded corners match Apple Notes' card preview. */
.notes-row-thumb {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notes-row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---------- Detail pane ---------- */
.notes-detail {
  padding: 32px 56px 56px;
  max-width: 820px;
}
.notes-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 18px;
  gap: 16px;
  flex-wrap: wrap;
}

/* ---------- "Sketch" tag ---------- */
/* Small italic-serif chip shown beside the client label on rows / detail
   header for notes that have an attached sketch PNG. */
.notes-kind-chip {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  padding: 1px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Sketch modal (notepad-page sized) ---------- */
/* Full-bleed modal so the canvas can be a real page rather than a card.
   overflow: hidden cancels .modal's default overflow: auto — otherwise the
   whole modal scrolls instead of the inner .sketch-scroll wrapper (which
   then has nothing to scroll itself). */
.sketch-modal {
  width: min(1280px, 96vw) !important;
  max-width: 96vw !important;
  max-height: 96vh;
  height: 96vh;
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
}
/* The body inside the modal needs to fill the remaining height (modal -
   header - footer) and stop growing past it, so the .sketch-scroll inside
   actually constrains and overflows the canvas. */
.sketch-modal > .body.sketch-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.sketch-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
}
.sketch-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.sketch-name {
  flex: 1;
  min-width: 220px;
  font-family: var(--serif);
  font-size: 20px;
  font-style: italic;
  padding: 10px 12px;
}
.sketch-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.sketch-hint {
  font-size: 12px;
  margin-left: auto;
}
/* Scroll arrows — large, obvious, and chunky for finger taps on a tablet. */
.sketch-scroll-btn {
  min-width: 44px;
  min-height: 36px;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  padding: 6px 12px;
}
/* Pen-weight pickers — three buttons each holding a nib glyph (a black
   filled circle whose pixel size matches the relative pen thickness). */
.sketch-pen-size {
  min-width: 32px;
  min-height: 32px;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sketch-pen-dot {
  display: inline-block;
  background: currentColor;
  border-radius: 50%;
  flex-shrink: 0;
}
/* Thin vertical hairline between tool groups (pen/eraser · weights · actions). */
.sketch-tool-sep {
  display: inline-block;
  width: 1px;
  height: 22px;
  background: var(--rule);
  margin: 0 4px;
}
/* Scroll viewport — the canvas inside is taller than this so the user
   scrolls down a continuous page. The scrollbar is permanently visible
   and wide enough to grab with a finger so it's the only way to scroll —
   touches on the canvas itself are 100% drawing input (palm-safe). */
.sketch-scroll {
  flex: 1;
  min-height: 60vh;
  overflow-y: scroll;          /* scroll, not auto, so the bar stays visible */
  overflow-x: hidden;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fff;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* Force the scrollbar to render on platforms that hide it by default. */
  scrollbar-gutter: stable;
}
/* Custom-style the scrollbar so it's tablet-finger sized: 18px wide ink
   handle on a paper-2 track, always visible. WebKit covers Chrome / Edge /
   Safari. Firefox falls back to scrollbar-color below. */
.sketch-scroll::-webkit-scrollbar {
  width: 18px;
  background: var(--paper-2);
}
.sketch-scroll::-webkit-scrollbar-thumb {
  background: rgba(26, 26, 26, 0.5);
  border: 4px solid var(--paper-2);
  border-radius: 9px;
  min-height: 60px;
}
.sketch-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(26, 26, 26, 0.75);
}
.sketch-scroll {
  scrollbar-color: rgba(26, 26, 26, 0.5) var(--paper-2);
  scrollbar-width: auto;
}
/* The actual drawing surface — a tall "page" the user scrolls through.
   1800px is roughly two full screens on most tablets so there's real
   room to write. touch-action: none means a finger or palm anywhere on
   the canvas does NOTHING (no draw, no scroll) — drawing is restricted
   to pen/mouse input. This is the palm-rejection fix; scrolling is via
   the visible scrollbar only. */
.sketch-canvas {
  display: block;
  width: 100%;
  height: 1800px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}
.sketch-err {
  font-size: 12px;
  color: var(--ink);
  font-style: italic;
}
@media (max-width: 860px) {
  .sketch-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .sketch-hint { display: none; }
  /* Phone canvases narrower — slightly shorter so the file stays sane. */
  .sketch-canvas { height: 1400px; }
}

/* ---------- Inline handwritten pages (read mode) ---------- */
/* All sketches stacked vertically under the body. Each page sits in its
   own paper card; clicking opens that specific page in the editor. */
.note-sketch-inline {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.note-sketch-page { display: flex; flex-direction: column; gap: 6px; }
.note-sketch-page-label {
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mid);
}
.note-sketch-inline-btn {
  display: block;
  width: 100%;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
}
.note-sketch-inline-btn:hover {
  border-color: var(--rule-strong);
}
.note-sketch-inline-btn img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.note-sketch-inline-loading {
  padding: 24px;
  font-style: italic;
  color: var(--mid);
  font-family: var(--serif);
  font-size: 15px;
  text-align: center;
}

/* ---------- Editor (notepad feel) ---------- */
/* When editing, the detail pane widens to give a real page of room to
   write. Read mode keeps its 820px max for comfortable line length. */
.notes-detail:has(.notes-editor) {
  max-width: 1080px;
}
.notes-editor {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.notes-editor-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
/* The big writing surface — a white sheet on the warm desk, so the
   typing area reads as its own page rather than empty screen. */
.notes-pad {
  flex: 1;
  width: 100%;
  min-height: 60vh;
  background: #FFFFFF;
  border: 1px solid var(--rule);
  outline: none;
  padding: 28px 32px;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.75;
  color: var(--ink);
  resize: vertical;
  box-shadow: 0 1px 0 rgba(26, 26, 26, 0.04), 0 8px 24px rgba(26, 26, 26, 0.05);
  transition: border-color 140ms ease;
}
.notes-pad:focus { border-color: var(--rule-strong); }
.notes-pad::placeholder {
  color: var(--mid);
  font-style: italic;
  opacity: 0.7;
}

/* ---------- Quick capture (⌘J) ---------- */
.quick-capture-scrim {
  position: fixed; inset: 0;
  background: rgba(26, 26, 26, 0.18);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  z-index: 1000;
}
.quick-capture {
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  width: min(640px, 92vw);
  padding: 18px 20px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.quick-capture-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.quick-capture-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .notes-body {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .notes-list {
    border-right: none;
    border-bottom: 1px solid var(--rule);
    padding: 18px 20px;
    max-height: 60vh;
  }
  .notes-detail {
    padding: 24px 20px 56px;
    max-width: none;
  }
}
