/* public/styles.css — adapted from input/mockup.html (ADR-010).
 * Visual fidelity is locked: every dimension, color, gradient, and shadow
 * traces back to either input/mockup.html or input/ui-spec.md.
 *
 * Layout order:
 *   1. Custom properties (palette tokens — single source of truth here).
 *   2. Reset + base body.
 *   3. App header (title, subline, legend, toggles, primary buttons).
 *   4. Project row (.row + .head + .stream).
 *   5. Task tile (.task, .t-name, .meta, .status, .deadline).
 *   6. + tile (.task-add).
 *   7. Action icons (archive, trash, X) — additions over the mockup.
 *   8. 3D toggle override (body.flat ...).
 *   9. Archive opacity + badge.
 *   10. Toast.
 *   11. Inline editor + spinner (ADR-005).
 *   12. Login screen.
 */

/* ------------------------------------------------------------------------- */
/* 1. Custom properties — palette + tokens                                    */
/* ------------------------------------------------------------------------- */

:root {
  /* Brand + neutrals — sourced from input/mockup.html. */
  --c-brand:        #4c4cff;
  --c-brand-hover:  #3a3aff;
  --c-bg:           #f8fafc;
  --c-text:         #1e293b;
  --c-text-soft:    #475569;
  --c-text-muted:   #64748b;
  --c-text-dim:     #94a3b8;
  --c-border:       #cdcde2;
  --c-overdue:      #dc2626;

  /* Status colors. */
  --c-status-new:         #94a3b8;
  --c-status-in-progress: #f59e0b;
  --c-status-done:        #10b981;

  /* Toast. */
  --c-toast-bg:   #fee2e2;
  --c-toast-fg:   #991b1b;

  /* Cylinder gradients (3D ON). */
  --grad-row:  linear-gradient(
    to bottom,
    #ebebf3 0%,
    #f8f8fd 25%,
    #ffffff 50%,
    #f8f8fd 75%,
    #dedeea 100%
  );
  --grad-head: linear-gradient(
    to bottom,
    #d6d7e2 0%,
    #ededf5 25%,
    #f4f4fc 50%,
    #ececf3 75%,
    #c8c8d8 100%
  );

  --shadow-row: 0 4px 10px rgba(76, 76, 255, 0.14);
}

/* ------------------------------------------------------------------------- */
/* 2. Reset + base                                                            */
/* ------------------------------------------------------------------------- */

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  margin: 0;
  padding: 24px;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.4;
}

/* ------------------------------------------------------------------------- */
/* 3. App header                                                              */
/* ------------------------------------------------------------------------- */

.app-header { margin-bottom: 24px; max-width: 1400px; }

.app-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.app-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

h1.app-title { margin: 0; font-size: 22px; font-weight: 600; line-height: 1.2; }

.app-subtitle { color: var(--c-text-muted); font-size: 13px; margin: 0; }

.app-legend {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  flex-wrap: wrap;
  font-size: 12px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--c-text-soft);
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.app-toggles {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--c-text-soft);
  cursor: pointer;
  user-select: none;
}
.switch input { cursor: pointer; }

/* Buttons. */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}
.btn-primary {
  background: var(--c-brand);
  color: #fff;
}
.btn-primary:hover  { background: var(--c-brand-hover); }
.btn-primary:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }

.btn-secondary {
  background: transparent;
  color: var(--c-text-soft);
  border: 1px solid var(--c-border);
}
.btn-secondary:hover { background: #f0f0fa; color: var(--c-text); }
.btn-secondary:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }

/* ------------------------------------------------------------------------- */
/* 4. Project row (.row + .head + .stream)                                    */
/* ------------------------------------------------------------------------- */

.lanes { display: block; }

.row {
  display: flex;
  align-items: stretch;
  margin-bottom: 16px;
  background: var(--grad-row);
  width: max-content;
  border-radius: 6px 0 0 6px;
  box-shadow: var(--shadow-row);
  position: relative;
}

.head {
  width: 240px;
  flex-shrink: 0;
  padding: 7px 16px;
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
  background: var(--grad-head);
  border-radius: 6px 0 0 6px;
  position: sticky;
  left: 0;
  z-index: 1;
}

.p-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
  color: #0f172a;
  cursor: text;
  outline: none;
  word-break: break-word;
}

.p-type {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 10px;
  align-self: flex-start;
  color: white;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.stream {
  display: flex;
  padding: 0;
  align-items: stretch;
}

/* ------------------------------------------------------------------------- */
/* 5. Task tile                                                               */
/* ------------------------------------------------------------------------- */

.task {
  width: 180px;
  flex-shrink: 0;
  min-height: 70px;
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
  position: relative;
}
.task:last-child { border-right: none; }

.t-name {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  flex: 1;
  line-height: 1.3;
  color: var(--c-text);
  min-height: 48px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--c-border);
  cursor: text;
  word-break: break-word;
}

/* AC-08.3 — done strikethrough. */
.task.s-done .t-name { color: var(--c-text-dim); text-decoration: line-through; }

.meta { display: flex; height: 22px; }

.meta .status {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: white;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.meta .deadline {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--c-text-soft);
  background: transparent;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

/* AC-09.4 — overdue. */
.deadline.overdue { color: var(--c-overdue); font-weight: 600; }
.deadline.empty   { color: var(--c-border); }

/* ------------------------------------------------------------------------- */
/* 6. + tile                                                                  */
/* ------------------------------------------------------------------------- */

.task.task-add {
  cursor: pointer;
  align-items: center;
  justify-content: center;
  background: transparent;
}
.task.task-add .add-plus {
  font-size: 32px;
  color: var(--c-brand);
  font-weight: 300;
  line-height: 1;
  user-select: none;
}
.task.task-add:hover { background: rgba(76, 76, 255, 0.06); }

/* ------------------------------------------------------------------------- */
/* 7. Action icons (additions over the mockup; per ui-spec.md)                */
/* ------------------------------------------------------------------------- */

/* Archive + trash icons inside .head, top-right, hover-visible. */
.head-actions {
  position: absolute;
  top: 6px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.row:hover .head-actions { opacity: 1; }

.icon-btn {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--c-text-dim);
  transition: color 0.15s ease;
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
}
.icon-btn:hover { color: var(--c-text-soft); }
.icon-btn:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }
.icon-btn svg { width: 100%; height: 100%; display: block; }

/* X icon on .task — top-right, hover-visible. */
.task-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
  color: var(--c-text-dim);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.task:hover .task-delete { opacity: 1; }
.task-delete:hover { color: var(--c-overdue); }
.task-delete:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; opacity: 1; }
.task-delete svg { width: 100%; height: 100%; display: block; }

/* ------------------------------------------------------------------------- */
/* 8. 3D toggle (body.flat) — flat overrides                                  */
/* ------------------------------------------------------------------------- */

body.flat .row {
  background: #fafafd;
  box-shadow: none;
  border: 1px solid var(--c-border);
}
body.flat .head {
  background: #f0f0fa;
}

/* ------------------------------------------------------------------------- */
/* 9. Archive opacity + badge                                                 */
/* ------------------------------------------------------------------------- */

.row.archived { opacity: 0.7; }

.archive-badge {
  font-size: 10px;
  color: var(--c-text-dim);
  align-self: flex-start;
  letter-spacing: 0.02em;
}

/* ------------------------------------------------------------------------- */
/* 10. Toast                                                                  */
/* ------------------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-toast-bg);
  color: var(--c-toast-fg);
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  max-width: calc(100vw - 48px);
}
.toast[hidden] { display: none; }

.toast-close {
  background: transparent;
  border: none;
  color: var(--c-toast-fg);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  font-family: inherit;
}
.toast-close:focus-visible { outline: 2px solid var(--c-toast-fg); outline-offset: 2px; }

/* ------------------------------------------------------------------------- */
/* 11. Inline editors + spinner (ADR-005)                                     */
/* ------------------------------------------------------------------------- */

.edit-input,
.edit-select,
.edit-date {
  font-family: inherit;
  font-size: inherit;
  /* Force dark text — these editors are inserted INSIDE .p-type / .status
     elements that have white text on a colored badge background. Inheriting
     color from the parent makes both the closed select and the dropdown
     options white-on-white (invisible). */
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 2px 6px;
  background: #fff;
  outline: none;
  width: 100%;
  min-width: 0;
}
.edit-input:focus,
.edit-select:focus,
.edit-date:focus {
  border-color: var(--c-brand);
}
/* Native <option> elements in some browsers (notably Chromium on Linux)
   inherit color from the host <select>'s computed style rather than from
   the rule above — be explicit so dropdown menu items stay readable. */
.edit-select option {
  color: var(--c-text);
  background: #fff;
}

/* When an editor is wired into .p-name (head), match the head font size. */
.p-name .edit-input { font-size: 14px; font-weight: 600; padding: 0 4px; }
.t-name .edit-input { font-size: 13px; font-weight: 500; padding: 2px 6px; }

/* When the deadline editor is open we still show the clear link inline. */
.deadline-editor {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 0 4px;
}
.deadline-editor .edit-date {
  flex: 1;
  font-size: 11px;
  padding: 0 4px;
  height: 18px;
}
.deadline-clear {
  background: transparent;
  border: none;
  color: var(--c-text-soft);
  cursor: pointer;
  font-size: 10px;
  font-family: inherit;
  padding: 0;
  text-decoration: underline;
}
.deadline-clear:hover { color: var(--c-text); }
.deadline-clear:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--c-border);
  border-top-color: var(--c-brand);
  border-radius: 50%;
  animation: pt-spin 0.6s linear infinite;
  vertical-align: middle;
  margin-left: 6px;
}
@keyframes pt-spin {
  to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------------------- */
/* 12. Login screen (per input/ui-spec.md "Login screen")                     */
/* ------------------------------------------------------------------------- */

body.login-page {
  background: var(--c-bg);
  padding: 0;
}

.login-card {
  max-width: 360px;
  margin: 12vh auto 0;
  padding: 32px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(76, 76, 255, 0.10);
}

.login-title {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 600;
  color: var(--c-text);
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--c-text-soft);
}

.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--c-text);
  background: #fff;
}
.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
  outline: none;
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px rgba(76, 76, 255, 0.12);
}

.login-submit {
  width: 100%;
  padding: 10px 16px;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
  justify-content: center;
}
.login-submit:disabled {
  background: var(--c-text-dim);
  cursor: progress;
}

.login-error {
  color: var(--c-toast-fg);
  background: var(--c-toast-bg);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.3;
}
.login-error[hidden] { display: none; }
