/*
 * Перетаскивание: доска задач, таймлайн, связи в графе, порядок целей и проектов.
 * Цвета — из переменных application.css.
 */

:root { --ease-sea: cubic-bezier(.2, .8, .2, 1); }

/* ——— Переключатель вида ——— */
.view-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-3); }
.view-switch a { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.view-switch a svg { width: 16px; height: 16px; }
.view-switch a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ——— Доска ——— */
.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 14px;
  overflow-x: auto; padding-bottom: 12px; align-items: start;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
}
@media (max-width: 899px) {
  .board { grid-auto-columns: 85vw; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 12px; scroll-padding: 0 16px; }
}
.board-col {
  scroll-snap-align: start; display: flex; flex-direction: column; min-height: 140px; max-height: calc(100vh - 230px);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius, 16px);
}
.board-col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; }
.board-col-head h3 { flex: 1; min-width: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-col-head .dot-status { width: 16px; height: 16px; margin: 0; cursor: default; }
.board-col-head .dot-status svg { width: 10px; height: 10px; }
.board-col-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.board-count { min-width: 24px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--surface-3); color: var(--ink-2); font: 700 12px/22px var(--font-head); text-align: center; transition: transform .25s var(--ease-sea); }
.board-col-waiting .board-count { background: var(--wait-soft); color: var(--wait); }
.board-col-done .board-count { background: var(--ok-soft); color: var(--ok); }

.board-list { flex: 1; overflow-y: auto; padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.board-list:empty::after { content: "Перетащите сюда"; display: grid; place-items: center; height: 70px; border: 1.5px dashed var(--line-2); border-radius: 12px; color: var(--ink-3); font-size: 13px; }

.board-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px 10px;
  box-shadow: var(--shadow); cursor: grab; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: transform .2s var(--ease-sea), box-shadow .2s var(--ease-sea), opacity .2s;
}
.board-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.board-card:active { cursor: grabbing; }
.board-card-title { display: block; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.board-card-note { margin: 5px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.4; }
.board-card-note::before { content: "↳ "; color: var(--ink-3); }
.board-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; font-size: 12px; }
.board-card-who { margin-left: auto; }
.board-card.is-overdue { box-shadow: inset 3px 0 0 var(--fire), var(--shadow); }
.board-card.is-done .board-card-title { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--line-2); }
.board-card.is-ghost { opacity: .35; border-style: dashed; box-shadow: none; }
.board-card.is-chosen { box-shadow: var(--shadow-lg); }
.board-card.is-dragging { transform: rotate(2deg) scale(1.02); box-shadow: var(--shadow-lg); }
.board-card.is-saving { opacity: .7; }

/* Всплеск при броске в «Готово» — круг расходится, как по воде. */
.board-card.is-splash { position: relative; animation: card-pop .5s var(--ease-sea); }
.board-card.is-splash::after {
  content: ""; position: absolute; inset: -2px; border-radius: 16px; pointer-events: none;
  box-shadow: 0 0 0 0 var(--ok); animation: card-ripple .7s var(--ease-sea) forwards;
}
@keyframes card-pop { 40% { transform: scale(1.04); } }
@keyframes card-ripple { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } to { box-shadow: 0 0 0 18px transparent; } }

.board-add { padding: 0 10px 10px; }
.board-add input[type=text] { height: 38px; font-size: 14px; background: transparent; border-style: dashed; }
.board-add input[type=text]:focus { background: var(--surface); border-style: solid; }

.board-dialog { border: 0; border-radius: 18px; padding: 22px; width: min(380px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
.board-dialog::backdrop { background: rgba(5, 20, 35, .45); backdrop-filter: blur(3px); }
.board-dialog[open] { animation: dialog-in .25s var(--ease-sea); }
.board-dialog h3 { font-size: 18px; margin-bottom: 4px; }
.board-dialog input { margin: 12px 0 14px; }
.board-dialog .actions { justify-content: flex-end; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ——— Порядок целей и проектов ——— */
.sortable-item { position: relative; }
.sortable-item > .card { height: 100%; }
.grip {
  position: absolute; z-index: 3; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 8px; border: 0;
  display: grid; place-items: center; background: transparent; color: var(--ink-3); cursor: grab; touch-action: none; padding: 0;
  opacity: .55; transition: opacity .2s, background .2s;
}
.grip svg { width: 16px; height: 16px; }
.sortable-item:hover .grip, .grip:focus-visible { opacity: 1; background: var(--surface-3); }
@media (hover: none) { .grip { opacity: .9; } }
.sortable-item.is-ghost { opacity: .35; }
.sortable-item.is-dragging .card { box-shadow: var(--shadow-lg); transform: rotate(1deg); }

/* ——— Таймлайн ——— */
.tl-bar[data-drag] { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.tl-bar[data-drag]:active { cursor: grabbing; }
.tl-bar .tl-resize { position: absolute; top: 0; right: 0; bottom: 0; width: 10px; cursor: ew-resize; }
.tl-bar .tl-resize::after { content: ""; position: absolute; right: 3px; top: 6px; bottom: 6px; width: 2px; border-radius: 1px; background: currentColor; opacity: .5; }
.tl-bar.is-dragging { box-shadow: var(--shadow-lg); z-index: 4; transition: none; }
.tl-bar.is-saving { opacity: .6; }
.tl-hint {
  position: fixed; z-index: 60; pointer-events: none; padding: 6px 10px; border-radius: 10px;
  background: var(--ink); color: var(--bg); font: 700 12px/1.2 var(--font-head); white-space: nowrap;
  transform: translate(-50%, -130%); box-shadow: var(--shadow-lg);
}

/* ——— Граф: ручка для связи ——— */
.graph .link-handle { fill: var(--surface); stroke: var(--accent); stroke-width: 2; cursor: crosshair; opacity: 0; transition: opacity .2s; }
.graph .node:hover .link-handle, .graph.is-linking .link-handle { opacity: 1; }
@media (hover: none) { .graph .link-handle { opacity: .9; } }
.graph .link-draft { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-dasharray: 6 5; pointer-events: none; }
.graph .node.is-target rect { stroke: var(--accent); stroke-width: 2.5; }
.graph-hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  .board-card, .board-card.is-splash, .board-card.is-splash::after, .board-dialog[open] { animation: none !important; transition: none !important; }
}

.sortable-item.has-grip > .card { padding-right: 44px; }
