/*
 * InkPick — components.css
 * Reusable widgets: buttons, dialogs, pen toolbar,
 * handwriting pad, ink chip, confirmation and exchange dialogs.
 */

/* ============================================================
   5. BUTTONS, DIALOGS, SETTINGS
   ============================================================ */
.btn {
  min-height: 44px; padding: .35rem 1rem;
  border: 1.5px solid var(--ink); border-radius: 10px;
  background: var(--card); cursor: pointer; font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--ink); }
.btn.danger  { color: var(--red); border-color: var(--red); background: var(--card); }
.icon-btn {
  min-width: 44px; min-height: 44px; border: 2px solid var(--line);
  border-radius: 10px; background: var(--card); cursor: pointer; font-size: 1.15rem;
}
.icon-btn:hover { border-color: var(--ink); }

dialog {
  border: 2px solid var(--ink); border-radius: 14px;
  background: var(--card); color: var(--ink);
  padding: 1.2rem; max-width: min(92vw, 560px); width: 100%;
  box-shadow: 6px 6px 0 rgba(0,0,0,.15);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h3 { margin: 0 0 .9rem; font-size: 1.15rem; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem;
  font-family: system-ui, sans-serif; font-size: .9rem; }
.field.row { flex-direction: row; align-items: center; gap: .6rem; }
.field select, .field input[type="text"] {
  min-height: 46px; padding: .3rem .55rem;
  border: 1.5px solid var(--line); border-radius: 8px; background: var(--paper);
}
.field.row label { cursor: pointer; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }
.dialog-actions .spacer { flex: 1; }
#settingsDialog .dialog-actions { margin-top: 0; }
#inkDialog #inkUndo, #inkDialog #inkRedo, #inkDialog #inkClear,
#settingsDialog .field.row #exportBtn, #settingsDialog .field.row #importBtn, #settingsDialog .field.row #resetBtn { flex: 1; }
#inkDialog .spacer { flex: 1 1 100%; }
.about { font-size: .8rem; color: var(--ink-soft); font-family: system-ui, sans-serif;
   line-height: 2.5rem; }
p.about { border-top: 1px solid var(--line); margin-top: 1rem; margin-bottom: 0; }
.about a { color: var(--accent); }
.dialog-head { display: flex; align-items: center; justify-content: space-between;
  gap: .6rem; margin-bottom: .9rem; }
#editInkField { padding-top: 11px; }
.dialog-head h3 { margin: 0; }
.edit-row { display: flex; align-items: center; gap: .55rem; margin-bottom: 1rem; }
.edit-row input {
  flex: 1; min-width: 0; min-height: 48px; padding: .3rem .4rem;
  border: none; border-bottom: 2px solid var(--line);
  background: transparent; font-family: inherit; font-size: 1.3rem; color: var(--ink);
}
.edit-row input:focus { border-bottom-color: var(--accent); outline: none; }
.bullet.checked::before {                /* dialog replica of a done checkbox */
  content: "✓";
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.star-toggle {
  width: 44px; height: 44px; flex: none;
  border: none; background: none; cursor: pointer; padding: 0;
  font-size: 1.5rem; line-height: 1; color: var(--line);
  border-radius: 10px;
  transition: color .15s, transform .15s;
}
.star-toggle:hover { background: var(--paper); }
.star-toggle.on { color: var(--gold); transform: scale(1.12); }

.confirm-text { margin: .2rem 0 1rem; font-family: system-ui, sans-serif;
  font-size: .95rem; white-space: pre-line; }
.exch-text { width: 100%; height: 170px; resize: vertical;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .74rem;
  border: 1.5px solid var(--line); border-radius: 8px;
  background: var(--paper); color: var(--ink); padding: .5rem; }

/* Handwriting canvas */
.ink-pad-wrap {
  border: 2px dashed var(--line); border-radius: 8px;
  background-image: radial-gradient(var(--dot) 1px, transparent 1.2px);
  background-size: 20px 20px;
}
.ink-pad {
  touch-action: none;
  width: 100%; height: 200px; display: block;
  background: transparent;
  cursor: crosshair;
}
/* Dark theme: only the strokes get their lightness inverted (transparent
   pixels are untouched), matching how saved drawings render. */
[data-theme="dark"] .ink-pad { filter: invert(1) hue-rotate(180deg); }
/* Attachment chip: the preview is the redraw button, ✕ removes.
   align-self prevents the flex column from stretching the image
   (ratio), and centers it in the panel. */
.ink-chip { position: relative; align-self: center; max-width: 100%; }
.ink-open { border: none; background: none; padding: 0; cursor: pointer; display: block; }
.ink-preview { display: block; max-height: 3.6em; width: auto; max-width: 100%;
  object-fit: contain; border: 2px dashed var(--line);
  border-radius: 8px; padding: 4px 8px; }
.ink-open:hover .ink-preview, .ink-open:focus-visible .ink-preview { border-color: var(--accent); }
.ink-x { position: absolute; top: -11px; right: -11px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--red); color: #fff;
  border: 2px solid var(--card); cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem; line-height: 1; font-weight: 700; }

.foot { max-width: 720px; margin: 0 auto 2.5rem; padding: 0 1rem;
  font-size: .78rem; color: var(--ink-soft); font-family: system-ui, sans-serif; }
.foot a { color: var(--accent); }


/* Grouping helpers (previously inline style attributes) */
#penHistory, #confirmChoices { display: contents; }
.swatch[data-color="#141414"] { --sw: #141414; }
.swatch[data-color="#2A4FA3"] { --sw: #2A4FA3; }
.swatch[data-color="#B23A2F"] { --sw: #B23A2F; }
.swatch[data-color="#1E7A3C"] { --sw: #1E7A3C; }
