/* Leafiy Todo — styling built on the DESIGN.md token system.
   Tokens (color/radius/spacing/type scale) come from ./tokens.css, which is
   generated from DESIGN.md. Line-heights (the one field the exporter omits)
   are the fixed --leading-* set below, mirrored from DESIGN.md typography. */

@import "./tokens.css";

:root {
  --leading-display: 1.05;
  --leading-headline-lg: 1.15;
  --leading-headline-md: 1.3;
  --leading-body-lg: 1.5;
  --leading-body-md: 1.5;
  --leading-body-sm: 1.45;
  --leading-label: 1;

  --ring: 0 0 0 4px var(--color-accent-soft);
  --motion: 180ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  background: var(--color-neutral);
  color: var(--color-on-surface);
  font-family: var(--font-body-lg);
  font-size: var(--size-body-lg);
  line-height: var(--leading-body-lg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  width: 100%;
  max-width: var(--space-container);
  padding: clamp(var(--space-xl), 8vw, 88px) var(--space-margin) var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* ---------- Header ---------- */

.app__header {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.eyebrow {
  margin: 0;
  font-family: var(--font-label-caps);
  font-size: var(--size-label-caps);
  font-weight: var(--weight-label-caps);
  letter-spacing: var(--tracking-label-caps);
  line-height: var(--leading-label);
  text-transform: uppercase;
  color: var(--color-tertiary);
}

.title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--size-display);
  font-weight: var(--weight-display);
  letter-spacing: var(--tracking-display);
  line-height: var(--leading-display);
  color: var(--color-primary);
}

.date {
  margin: 0;
  font-family: var(--font-body-md);
  font-size: var(--size-body-md);
  color: var(--color-on-surface-muted);
}

/* ---------- Composer ---------- */

.composer {
  display: flex;
  gap: var(--space-sm);
}

.composer__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 48px;
  padding: 0 var(--space-md);
  font-family: var(--font-body-lg);
  font-size: var(--size-body-lg);
  color: var(--color-on-surface);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--motion), box-shadow var(--motion);
}

.composer__input::placeholder {
  color: var(--color-on-surface-muted);
}

.composer__input:focus {
  outline: none;
  border-color: var(--color-tertiary);
  box-shadow: var(--ring);
}

.composer__error {
  margin: calc(-1 * var(--space-sm)) 0 0;
  font-family: var(--font-body-sm);
  font-size: var(--size-body-sm);
  color: var(--color-tertiary);
}

/* ---------- Buttons ---------- */

.btn {
  border: 0;
  cursor: pointer;
  font-family: var(--font-headline-md);
  transition: background-color var(--motion), transform var(--motion),
    color var(--motion);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn--primary {
  height: 44px;
  padding: 0 var(--space-lg);
  font-size: var(--size-headline-md);
  font-weight: var(--weight-headline-md);
  color: var(--color-neutral);
  background: var(--color-primary);
  border-radius: var(--radius-md);
}

.btn--primary:hover {
  background: var(--color-accent-hover);
}

.btn--ghost {
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-body-sm);
  font-size: var(--size-body-sm);
  font-weight: 500;
  color: var(--color-on-surface-muted);
  background: transparent;
  border-radius: var(--radius-sm);
}

.btn--ghost:hover {
  color: var(--color-primary);
  background: var(--color-surface-muted);
}

/* ---------- Toolbar (filters + count) ---------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.filters {
  display: flex;
  gap: var(--space-xs);
}

.chip {
  height: 32px;
  padding: 0 var(--space-md);
  cursor: pointer;
  font-family: var(--font-body-sm);
  font-size: var(--size-body-sm);
  font-weight: 500;
  color: var(--color-on-surface-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  transition: background-color var(--motion), color var(--motion),
    border-color var(--motion);
}

.chip:hover {
  color: var(--color-primary);
}

.chip:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.chip[aria-pressed="true"] {
  color: var(--color-neutral);
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.count {
  font-family: var(--font-label-mono);
  font-size: var(--size-label-mono);
  font-weight: var(--weight-label-mono);
  color: var(--color-on-surface-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- List ---------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--color-border);
}

.item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-xs);
  border-bottom: 1px solid var(--color-border);
  transition: background-color var(--motion);
}

.item:hover {
  background: var(--color-surface-muted);
}

.item.is-entering {
  animation: item-in var(--motion) both;
}

.item.is-leaving {
  animation: item-out 160ms ease-in forwards;
}

/* Checkbox */

.check {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  color: transparent;
  background: var(--color-surface);
  border: 1.5px solid var(--color-secondary);
  border-radius: var(--radius-full);
  transition: background-color var(--motion), border-color var(--motion),
    color var(--motion);
}

.check:hover {
  background: var(--color-accent-soft);
  border-color: var(--color-tertiary);
}

.check:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.check__mark {
  width: 15px;
  height: 15px;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  transition: stroke-dashoffset var(--motion);
}

.check[aria-checked="true"] {
  color: var(--color-on-accent);
  background: var(--color-tertiary);
  border-color: var(--color-tertiary);
}

.check[aria-checked="true"] .check__mark {
  stroke-dashoffset: 0;
}

/* Task text */

.item__text {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-body-lg);
  font-size: var(--size-body-lg);
  color: var(--color-on-surface);
  overflow-wrap: anywhere;
  transition: color var(--motion);
}

.item.is-done .item__text {
  color: var(--color-on-surface-muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

/* Delete */

.item__delete {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  color: var(--color-on-surface-muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity var(--motion), color var(--motion),
    background-color var(--motion);
}

.item__delete svg {
  width: 18px;
  height: 18px;
}

.item:hover .item__delete,
.item:focus-within .item__delete {
  opacity: 1;
}

.item__delete:hover {
  color: var(--color-primary);
  background: var(--color-surface-muted);
}

.item__delete:focus-visible {
  outline: none;
  opacity: 1;
  box-shadow: var(--ring);
}

/* ---------- Empty state ---------- */

.empty {
  padding: var(--space-xl) var(--space-md);
  text-align: center;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
}

.empty__title {
  margin: 0 0 var(--space-xs);
  font-family: var(--font-headline-lg);
  font-size: var(--size-headline-lg);
  font-weight: var(--weight-headline-lg);
  letter-spacing: var(--tracking-headline-lg);
  color: var(--color-primary);
}

.empty__hint {
  margin: 0;
  font-family: var(--font-body-md);
  font-size: var(--size-body-md);
  color: var(--color-on-surface-muted);
}

/* ---------- Footer ---------- */

.app__footer {
  display: flex;
  justify-content: flex-end;
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .check__mark {
    transition: none;
  }
}

@keyframes item-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes item-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 480px) {
  .toolbar {
    flex-wrap: wrap;
  }
  .btn--primary {
    padding: 0 var(--space-md);
  }
}

.eyebrow--link {
  display: inline-block;
  width: fit-content;
  text-decoration: none;
  transition: color var(--motion, 180ms) ease, transform 180ms ease;
}

.eyebrow--link:hover {
  color: var(--color-accent-hover);
  transform: translateX(-2px);
}

.eyebrow--link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--color-accent-soft);
  border-radius: var(--radius-sm);
}
