/* چک‌لیست — components + shared layout */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 50% at 100% -10%, var(--bg-glow), transparent 55%),
    radial-gradient(ellipse 50% 40% at 0% 100%, rgba(95, 212, 232, 0.04), transparent 50%),
    var(--bg);
}

button, input { font: inherit; color: inherit; margin: 0; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ——— Layout ——— */
.shell {
  width: min(100%, var(--shell-width));
  margin-inline: auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-inline: var(--s-4);
}

.shell__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  gap: var(--s-3);
  padding-block: var(--s-2);
}

.shell__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--s-8);
}

/* ——— Brand ——— */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text);
  text-decoration: none;
  min-height: var(--tap);
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand__mark {
  width: 1.75rem;
  height: 1.75rem;
  color: var(--accent);
  flex-shrink: 0;
}
.brand__name {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  letter-spacing: 0;
  line-height: 1;
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--tap);
  padding: 0 var(--s-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  transition:
    background var(--t-fast),
    border-color var(--t-fast),
    color var(--t-fast),
    transform var(--t-fast),
    opacity var(--t-fast);
}
.btn svg { width: 1.125rem; height: 1.125rem; flex-shrink: 0; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--primary:active:not(:disabled) { background: var(--accent-active); }

.btn--secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn--secondary:hover:not(:disabled) { background: var(--surface-hover); }

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}

.btn--danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn--danger:hover:not(:disabled) {
  background: rgba(240, 117, 103, 0.22);
  color: var(--danger-hover);
}

.btn--icon {
  width: var(--tap);
  min-width: var(--tap);
  padding: 0;
}

.btn--sm {
  min-height: 2.25rem;
  padding-inline: var(--s-3);
  font-size: var(--fs-sm);
}

/* ——— Fields ——— */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field__label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
}
.field__input,
.input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--s-4);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.field__input::placeholder,
.input::placeholder { color: var(--text-faint); }
.field__input:hover,
.input:hover { border-color: rgba(237, 234, 228, 0.22); }
.field__input:focus-visible,
.input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ——— Card ——— */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-sm);
}

/* ——— Progress ——— */
.progress {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.progress__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
}
.progress__label {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.progress__label strong {
  color: var(--text);
  font-weight: var(--fw-medium);
}
.progress__track {
  height: 0.25rem;
  background: var(--surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  width: 0;
  transition: width var(--t);
}

/* ——— Segmented filter ——— */
.segmented {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.1875rem;
  gap: 0.125rem;
}
.segmented__btn {
  flex: 1;
  min-height: 2.375rem;
  padding: 0 var(--s-2);
  border-radius: calc(var(--radius-md) - 3px);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.segmented__btn:hover { color: var(--text); }
.segmented__btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ——— Item row ——— */
.item-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.item {
  --item-color: var(--border-strong);
  --item-soft: transparent;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.125rem;
  min-height: 4rem;
  padding: 0.375rem 0.5rem;
  background:
    linear-gradient(to left, var(--item-soft), transparent 42%),
    var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--item-color);
  border-radius: var(--radius-md);
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast), transform var(--t-fast);
}
.item:hover { background:
  linear-gradient(to left, var(--item-soft), transparent 42%),
  var(--surface-hover);
}
.item--rose   { --item-color: var(--color-rose);   --item-soft: var(--color-rose-soft); }
.item--amber  { --item-color: var(--color-amber);  --item-soft: var(--color-amber-soft); }
.item--lime   { --item-color: var(--color-lime);   --item-soft: var(--color-lime-soft); }
.item--cyan   { --item-color: var(--color-cyan);   --item-soft: var(--color-cyan-soft); }
.item--blue   { --item-color: var(--color-blue);   --item-soft: var(--color-blue-soft); }
.item--violet { --item-color: var(--color-violet); --item-soft: var(--color-violet-soft); }

.item--done {
  background:
    linear-gradient(to left, var(--item-soft), transparent 50%),
    transparent;
}
.item--done .item__text {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--text-faint);
}

.item--editing {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  z-index: 2;
}

.item--dragging {
  opacity: 0.8;
  transform: scale(1.015);
  box-shadow: var(--shadow-lg);
  z-index: 3;
  cursor: grabbing;
}

.item__reorder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.25rem;
}
.item__move {
  width: 2.25rem;
  min-width: 2.25rem;
  min-height: 1.75rem;
  height: 1.75rem;
  color: var(--text-faint);
  border-radius: var(--radius-sm);
}
.item__move svg { width: 0.875rem; height: 0.875rem; }
.item__move:hover { color: var(--text); background: var(--surface-2); }
.item__grip {
  display: none;
  width: 2.25rem;
  min-width: 2.25rem;
  min-height: 2.5rem;
  color: var(--text-faint);
  cursor: grab;
  border-radius: var(--radius-sm);
}
.item__grip:hover { color: var(--text); background: var(--surface-2); }
.item__grip svg { width: 1rem; height: 1rem; }

@media (min-width: 640px) {
  .item__move { display: none; }
  .item__grip { display: grid; place-items: center; }
  .item__reorder { width: 2.5rem; }
}

/* Checkbox — 22px visual, 44px hit area */
.checkbox {
  flex-shrink: 0;
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
}
.checkbox__box {
  width: 1.375rem;
  height: 1.375rem;
  border: 2px solid var(--border-strong);
  border-radius: 0.375rem;
  display: grid;
  place-items: center;
  background: transparent;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.checkbox__box svg {
  width: 0.875rem;
  height: 0.875rem;
  stroke: var(--accent-text);
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 16;
  stroke-dashoffset: 16;
  opacity: 0;
  transform: scale(0.7);
  transition: stroke-dashoffset 200ms var(--ease), opacity var(--t-fast), transform var(--t-fast);
}
.checkbox:hover .checkbox__box { border-color: var(--accent); }
.item--done .checkbox__box,
.checkbox[aria-checked="true"] .checkbox__box {
  background: var(--accent);
  border-color: var(--accent);
}
.item--done .checkbox__box svg,
.checkbox[aria-checked="true"] .checkbox__box svg {
  opacity: 1;
  transform: scale(1);
  stroke-dashoffset: 0;
}

.item__body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  padding-inline: 0.125rem var(--s-1);
}
.item__text {
  font-size: var(--fs-base);
  line-height: var(--lh-tight);
  overflow: hidden;
  text-overflow: ellipsis;
}
.item__edit-input {
  width: 100%;
  min-height: 2.25rem;
  padding: 0 var(--s-2);
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
}
.item__edit-input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.item__actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 0;
}
.item__actions .btn--icon {
  width: 2.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  color: var(--text-faint);
}
.item__actions .btn--icon:hover { color: var(--text); }
.item__actions .btn--icon.btn--danger:hover { color: var(--danger); background: var(--danger-soft); }

/* Color dot + popover */
.color-dot {
  width: 2.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  position: relative;
}
.color-dot__swatch {
  width: 1.125rem;
  height: 1.125rem;
  border-radius: var(--radius-full);
  background: var(--item-color);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px color-mix(in srgb, var(--item-color) 45%, transparent);
  transition: transform var(--t-fast);
}
.color-dot:hover .color-dot__swatch,
.color-dot[aria-expanded="true"] .color-dot__swatch {
  transform: scale(1.12);
}

.color-popover {
  position: absolute;
  top: calc(100% + 0.35rem);
  inset-inline-end: 0;
  z-index: 10;
  display: none;
  gap: var(--s-1);
  padding: var(--s-2);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
}
.color-popover.is-open { display: flex; }
.color-popover--above {
  top: auto;
  bottom: calc(100% + 0.35rem);
}

.swatch {
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  border-radius: var(--radius-full);
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.swatch:hover { transform: scale(1.08); }
.swatch.is-selected,
.swatch[aria-selected="true"] {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--swatch);
}
.swatch--rose   { --swatch: var(--color-rose); }
.swatch--amber  { --swatch: var(--color-amber); }
.swatch--lime   { --swatch: var(--color-lime); }
.swatch--cyan   { --swatch: var(--color-cyan); }
.swatch--blue   { --swatch: var(--color-blue); }
.swatch--violet { --swatch: var(--color-violet); }

/* ——— Invite row ——— */
.invite {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.25rem 0.25rem 0.25rem var(--s-3);
  min-height: var(--tap);
}
.invite__label {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  flex-shrink: 0;
}
.invite__url {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

/* ——— Composer (add item) ——— */
.composer {
  display: flex;
  gap: var(--s-2);
  align-items: center;
}
.composer .input { flex: 1; }

/* ——— Toolbar (filters + clear) ——— */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.toolbar .segmented { flex: 1; }
.toolbar .btn { flex-shrink: 0; }

@media (max-width: 399px) {
  .toolbar { flex-wrap: wrap; }
  .toolbar .segmented { flex-basis: 100%; }
  .toolbar .btn { margin-inline-start: auto; }
}

/* ——— Toast ——— */
.toast {
  position: fixed;
  bottom: var(--s-6);
  left: 50%;
  transform: translateX(-50%) translateY(0.5rem);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 2.75rem;
  padding: 0 var(--s-4);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t), transform var(--t);
  z-index: 30;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.toast svg { color: var(--success); width: 1.125rem; height: 1.125rem; }

/* ——— Empty state ——— */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--s-8) var(--s-4);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  gap: var(--s-3);
}
.empty__icon {
  width: 3rem;
  height: 3rem;
  color: var(--accent);
  opacity: 0.85;
}
.empty__title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
}
.empty__hint {
  margin: 0;
  max-width: 18rem;
  font-size: var(--fs-md);
  color: var(--text-muted);
}

/* ——— Status / invalid page ——— */
.status {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 4.25rem var(--s-2) var(--s-8);
  gap: var(--s-4);
}
.status__icon {
  width: 3.25rem;
  height: 3.25rem;
  color: var(--text-muted);
}
.status__title {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
}
.status__hint {
  margin: 0;
  max-width: 22rem;
  color: var(--text-muted);
  font-size: var(--fs-md);
}

/* ——— Landing pieces ——— */
.hero { padding-top: var(--s-4); }
.hero__title {
  margin: 0 0 var(--s-3);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
}
.hero__title em {
  font-style: normal;
  color: var(--accent);
}
.hero__lead {
  margin: 0 0 var(--s-6);
  color: var(--text-muted);
  font-size: var(--fs-md);
}

.create-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.create-form .btn { width: 100%; }

.steps {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-2);
  margin-top: var(--s-6);
}
@media (min-width: 520px) {
  .steps { grid-template-columns: repeat(3, 1fr); gap: var(--s-3); }
}
.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--s-4);
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
}
@media (min-width: 520px) {
  .step { flex-direction: column; align-items: flex-start; gap: var(--s-2); }
}
.step__num {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  display: grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.step__title {
  margin: 0 0 0.125rem;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}
.step p {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: 1.6;
}

.preview {
  margin-top: var(--s-6);
}
.preview__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-faint);
  margin: 0 0 var(--s-2);
}

/* List page heading */
.list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  margin: var(--s-2) 0 var(--s-4);
}
.list-head__title {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
}
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.stack-4 { display: flex; flex-direction: column; gap: var(--s-4); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* ——— Compact mobile tweaks ——— */
@media (max-width: 639px) {
  .shell__main { padding-bottom: var(--s-5); }
  .hero { padding-top: 0.15rem; }
  .hero__title { font-size: 1.5rem; }
  .hero__lead { margin-bottom: var(--s-4); }
  .create-form .card,
  .card { padding: var(--s-4); }
  .steps { margin-top: var(--s-4); gap: var(--s-2); }
  .step { padding: var(--s-3) var(--s-4); }
  .preview { margin-top: var(--s-4); }
  .preview .item { min-height: 2.75rem; padding-block: 0.25rem; }
  .preview .checkbox { width: 2.25rem; height: 2.25rem; }
  .preview .color-dot { width: 1.75rem; min-width: 1.75rem; min-height: 1.75rem; }

  .list-head { margin: 0.1rem 0 0.5rem; }
  .list-head__title { font-size: 1.375rem; }
  .stack-4 { gap: 0.55rem; }
  .item { min-height: 3.25rem; }
  .item-list { gap: 0.35rem; }
  .item--editing .item__actions { display: none; }
  .progress__row { align-items: center; }
  .progress__row .btn { margin-inline-start: auto; flex-shrink: 0; }
  .page-list .shell__main { padding-bottom: 4.25rem; }
}

