/* Crochet mode: chart, current-row strip, big buttons, notes. Reuses the tokens in app.css. */

#panel-crochet { --cr-pad-h: 136px; }

/* Toolbar */
.cr-toolbar { flex-wrap: nowrap; }
.cr-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 38px; padding: 0 14px 0 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.cr-toggle:hover { color: var(--text); border-color: var(--muted); }
.cr-toggle[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.cr-note-btn { position: relative; }
.cr-note-btn.has-note::after {
  content: ''; position: absolute; top: 7px; right: 7px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface);
}
.cr-menu .menu-pop { left: auto; right: 0; }

.cr-viewport { min-height: 180px; }
.cr-viewport canvas { cursor: pointer; }

/* Current-row strip */
.cr-strip {
  position: relative; flex: none;
  padding: 12px 14px 12px; border-top: 1px solid var(--line);
  background: var(--surface);
}
.cr-bar { position: absolute; left: 0; right: 0; top: -1px; height: 4px; background: color-mix(in srgb, var(--line) 70%, transparent); }
.cr-bar i { display: block; height: 100%; background: var(--done); border-radius: 0 2px 2px 0; transition: width .3s ease; }

.cr-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.cr-row { margin: 0; font: 700 24px/1.15 var(--font-display); letter-spacing: -.015em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cr-of { color: var(--muted); font-weight: 560; font-size: 17px; }
.cr-dir {
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  background: color-mix(in srgb, var(--highlight) 30%, transparent); color: var(--text);
  font-size: 14px; font-weight: 600;
}
.cr-tick { display: inline-flex; align-items: center; gap: 3px; color: var(--done); font-size: 14px; font-weight: 650; white-space: nowrap; }
.cr-tick .ico { width: 16px; height: 16px; stroke-width: 2.4; }
.cr-pct { margin-left: auto; color: var(--muted); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

.cr-banner {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 10px 0 0; padding: 9px 12px; border-radius: 10px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--text); font-weight: 600;
}
.cr-banner .ico { color: var(--accent); margin-top: 2px; }
.cr-banner p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 4.6em; overflow: auto; }
.cr-banner.arrive { animation: cr-arrive .9s ease; }
@keyframes cr-arrive {
  0% { transform: scale(.97); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  40% { transform: scale(1.01); box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent); }
  100% { transform: none; box-shadow: none; }
}

.cr-line { margin: 8px 0 0; font-size: 14px; font-weight: 560; color: var(--text); }
.cr-empty { margin: 10px 0 2px; color: var(--muted); }

.cr-chips {
  display: flex; align-items: center; gap: 4px;
  margin: 10px -14px 0; padding: 2px 14px 4px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.cr-chips::-webkit-scrollbar { display: none; }
.cr-chips.more-left { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 28px); mask-image: linear-gradient(90deg, transparent 0, #000 28px); }
.cr-chips.more-right { -webkit-mask-image: linear-gradient(270deg, transparent 0, #000 28px); mask-image: linear-gradient(270deg, transparent 0, #000 28px); }
.cr-chips.more-left.more-right { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%); }
.cr-chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  min-height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  color: var(--text); font-size: 16px; font-weight: 650; white-space: nowrap; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.cr-chip i { width: 13px; height: 13px; border-radius: 2px; border: 2px solid var(--chart-ink); }
.cr-chip.bl i { background: var(--chart-ink); }
.cr-chip.past { opacity: .45; }
.cr-chip.on {
  background: color-mix(in srgb, var(--highlight) 38%, var(--surface));
  border-color: var(--highlight); box-shadow: 0 0 0 2px var(--highlight);
}
.cr-chip.gap { cursor: default; border-style: dashed; background: transparent; color: var(--muted); font-weight: 560; font-size: 14px; }
.cr-arrow { flex: none; color: var(--muted); font-size: 14px; }

.cr-info {
  display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px;
  color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums;
}
.cr-left { color: var(--accent); font-weight: 700; }

/* Big buttons */
.cr-pad { display: grid; gap: 10px; }
.cr-pad-sq, .cr-pad-rows { display: grid; gap: 10px; }
.cr-pad-sq { grid-template-columns: 1fr 1fr; }
.cr-pad-rows { grid-template-columns: 1fr 1.5fr 1fr; }
.cr-btn { min-height: 56px; padding: 0 10px; border-radius: 12px; font-size: 15px; white-space: normal; line-height: 1.15; text-align: center; touch-action: manipulation; }
.cr-btn .ico { width: 22px; height: 22px; stroke-width: 2; }
.cr-next { flex-direction: row-reverse; }
.cr-finish { font-size: 17px; font-weight: 700; }
.cr-finish .ico { width: 24px; height: 24px; stroke-width: 2.6; }
.cr-rowbtn { flex-direction: column; gap: 2px; font-size: 13px; }
.cr-btn:disabled { opacity: .4; cursor: default; }
.cr-btn:disabled:hover { border-color: var(--line); }
.cr-btn:active:not(:disabled) { transform: scale(.98); }

/* Notes and progress */
.cr-note-card h3 label { cursor: text; }
.cr-note-card textarea { min-height: 76px; }
.cr-note-list { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 0; font-size: 13px; }
.cr-note-jump {
  min-height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); color: var(--text); font-size: 13px; font-weight: 560; cursor: pointer;
}
.cr-note-jump:hover { border-color: var(--muted); }
.cr-progress-card .facts > div { grid-template-columns: 84px 1fr; }
.cr-progress-card .facts dd { overflow-wrap: anywhere; }
.cr-keys { margin-bottom: 0; }

@media (pointer: coarse) {
  .cr-keys { display: none; }
}
/* Touch screens keep :hover after a tap; don't let a tapped button look selected. */
@media (hover: none) {
  .cr-btn:hover, .cr-toggle:hover, .cr-note-jump:hover { border-color: var(--line); }
  .cr-toggle[aria-pressed="true"]:hover { border-color: var(--ink); }
}

/* Mac and tablet: the side panel is narrow, so Finish row gets its own wide button on top. */
@media (min-width: 721px) {
  .cr-pad-rows { order: -1; grid-template-columns: 1fr 1fr; }
  .cr-finish { grid-column: 1 / -1; order: -1; min-height: 64px; font-size: 19px; }
  .cr-pad-sq .cr-btn { flex-direction: column; gap: 2px; font-size: 13px; }
}

/* Phone: chart and strip fill the screen, the buttons sit just above the tab bar for one thumb. */
@media (max-width: 720px) {
  #panel-crochet.has-project { gap: 10px; }
  #panel-crochet .cr-main {
    height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 32px - 10px - var(--cr-pad-h));
    min-height: 290px;
  }
  .cr-toolbar { gap: 4px; }
  .cr-toggle { min-height: 40px; }
  .cr-strip { padding: 10px 12px; }
  .cr-chips { margin: 8px -12px 0; padding: 2px 12px 4px; }
  .cr-row { font-size: 22px; }
  .cr-of { font-size: 16px; }
  .cr-dir { font-size: 13px; padding: 2px 9px; }
  .cr-info { gap: 2px 12px; font-size: 13px; margin-top: 6px; }
  .cr-pad { padding: 8px; gap: 8px; }
  .cr-pad-sq, .cr-pad-rows { gap: 8px; }
  .cr-btn { min-height: 56px; }
}
@media (max-width: 380px) {
  .cr-head { gap: 8px; }
  .cr-btn { font-size: 14px; }
  .cr-finish { font-size: 16px; }
}

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