/* =====================================================================
   ATELIER — a considered to-do
   Warm-dark canvas · coral accent · Fraunces × Space Mono · grain
   ===================================================================== */

/* ---------- Theme tokens ---------- */
:root {
  --font-display: "Fraunces", Georgia, serif;
  --font-mono: "Space Mono", ui-monospace, monospace;

  --radius: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Dark (default) */
  --bg: #15110e;
  --bg-elev: #1c1814;
  --bg-card: #211c17;
  --border: rgba(245, 237, 226, 0.08);
  --border-strong: rgba(245, 237, 226, 0.16);
  --fg: #f5ede2;
  --fg-soft: #c9bfb0;
  --muted: #8a8071;
  --accent: #ff6b4a;
  --accent-soft: rgba(255, 107, 74, 0.14);
  --accent-glow: rgba(255, 107, 74, 0.45);
  --amber: #f0a868;
  --done: rgba(255, 107, 74, 0.55);
  --shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
}

[data-theme="light"] {
  --bg: #f4ede1;
  --bg-elev: #efe6d6;
  --bg-card: #fffdf8;
  --border: rgba(38, 26, 16, 0.1);
  --border-strong: rgba(38, 26, 16, 0.18);
  --fg: #241a10;
  --fg-soft: #4a3e2e;
  --muted: #8a7c66;
  --accent: #d8431f;
  --accent-soft: rgba(216, 67, 31, 0.1);
  --accent-glow: rgba(216, 67, 31, 0.3);
  --amber: #c47814;
  --done: rgba(216, 67, 31, 0.5);
  --shadow: 0 30px 60px -25px rgba(80, 50, 20, 0.3);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  transition: background 0.5s var(--ease), color 0.5s var(--ease);
}

button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
ul { list-style: none; }
input { font: inherit; color: inherit; }

::selection { background: var(--accent); color: #15110e; }

/* ---------- Atmosphere ---------- */
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.glow {
  position: fixed; border-radius: 50%; filter: blur(120px);
  pointer-events: none; z-index: 0; opacity: 0.5;
  transition: opacity 0.6s var(--ease);
}
.glow--coral {
  width: 520px; height: 520px;
  background: var(--accent-glow);
  top: -180px; right: -160px;
}
.glow--amber {
  width: 440px; height: 440px;
  background: var(--amber);
  opacity: 0.18; bottom: -200px; left: -140px;
}
[data-theme="light"] .glow--coral { opacity: 0.3; }
[data-theme="light"] .glow--amber { opacity: 0.22; }

/* ---------- Shell ---------- */
.shell {
  position: relative; z-index: 2;
  max-width: 680px; margin: 0 auto;
  padding: 40px 28px 80px;
  display: flex; flex-direction: column; gap: 32px;
}

/* ---------- Header ---------- */
.header { display: flex; align-items: center; justify-content: space-between; }

.brand {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-display);
  font-weight: 600; font-size: 1.35rem; letter-spacing: -0.02em;
}
.brand__mark { color: var(--accent); transform: rotate(45deg); display: inline-block; font-size: 0.85em; }
.brand__name { font-style: italic; }

/* Theme toggle */
.theme-toggle { padding: 6px; border-radius: 999px; }
.theme-toggle__track {
  display: block; width: 56px; height: 30px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  position: relative;
  transition: background 0.4s var(--ease);
}
.theme-toggle__thumb {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  transition: transform 0.45s var(--ease);
}
[data-theme="light"] .theme-toggle__thumb { transform: translateX(26px); }

/* ---------- Hero ---------- */
.hero { animation: rise 0.9s var(--ease-out) both; }
.hero__date {
  font-size: 0.72rem; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 18px;
}
.hero__title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2.4rem, 7vw, 4.2rem);
  line-height: 0.98; letter-spacing: -0.03em;
  color: var(--fg);
}
.hero__title em { font-style: italic; font-weight: 500; }
.hero__accent { color: var(--accent); font-style: italic; font-weight: 500; }
.hero__lede {
  margin-top: 22px; max-width: 42ch;
  color: var(--fg-soft); font-size: 0.95rem; line-height: 1.7;
}

/* ---------- Composer ---------- */
.composer {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 8px 8px 20px;
  box-shadow: var(--shadow);
  transition: border-color 0.3s var(--ease), transform 0.3s var(--ease);
  animation: rise 0.9s var(--ease-out) 0.08s both;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft);
}
.composer__plus {
  color: var(--accent); font-size: 1.4rem; line-height: 1;
  transition: transform 0.3s var(--ease);
}
.composer:focus-within .composer__plus { transform: rotate(90deg); }
.composer__input {
  flex: 1; border: none; background: none; outline: none;
  font-size: 1rem; padding: 12px 4px;
}
.composer__input::placeholder { color: var(--muted); }
.composer__submit {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #15110e;
  font-weight: 700; font-size: 0.82rem; letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 12px 18px; border-radius: var(--radius-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.3s var(--ease);
}
.composer__submit:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -8px var(--accent-glow); }
.composer__submit:active { transform: translateY(0); }
.composer__kbd {
  font-size: 1rem; opacity: 0.6; transform: translateY(-1px);
}

/* ---------- Controls ---------- */
.controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  animation: rise 0.9s var(--ease-out) 0.16s both;
}
.segment {
  display: inline-flex; padding: 4px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 999px; position: relative;
}
.segment__btn {
  padding: 8px 18px; border-radius: 999px;
  font-size: 0.78rem; letter-spacing: 0.04em;
  color: var(--muted); position: relative; z-index: 2;
  transition: color 0.3s var(--ease);
}
.segment__btn.is-active { color: #15110e; font-weight: 700; }
[data-theme="light"] .segment__btn.is-active { color: #fffdf8; }

.progress { display: flex; align-items: center; gap: 12px; }
.progress__count {
  font-size: 0.72rem; color: var(--muted); letter-spacing: 0.06em;
  white-space: nowrap;
}
.progress__bar {
  display: block; width: 96px; height: 5px;
  background: var(--bg-elev); border-radius: 999px; overflow: hidden;
  border: 1px solid var(--border);
}
.progress__fill {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--amber), var(--accent));
  border-radius: 999px;
  transition: width 0.6s var(--ease);
}

/* ---------- Task list ---------- */
.tasks { display: flex; flex-direction: column; gap: 10px; }
.task {
  display: flex; align-items: center; gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  position: relative; overflow: hidden;
  animation: pop-in 0.5s var(--ease-out) both;
  transition: border-color 0.3s var(--ease), transform 0.3s var(--ease), background 0.3s var(--ease);
}
.task:hover { border-color: var(--border-strong); transform: translateX(4px); }
.task.is-removing { animation: pop-out 0.4s var(--ease) forwards; }

.task::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent);
  transform: scaleY(0); transform-origin: center;
  transition: transform 0.4s var(--ease);
}
.task:hover::before { transform: scaleY(1); }

/* Custom checkbox */
.check {
  flex: none; width: 26px; height: 26px;
  border-radius: 8px;
  border: 1.5px solid var(--border-strong);
  display: grid; place-items: center;
  cursor: pointer; position: relative;
  transition: all 0.3s var(--ease);
}
.check:hover { border-color: var(--accent); }
.check__svg {
  width: 14px; height: 14px; stroke: #15110e;
  stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 24; stroke-dashoffset: 24;
  transition: stroke-dashoffset 0.35s var(--ease) 0.05s;
}
.task.is-done .check {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 16px -4px var(--accent-glow);
}
.task.is-done .check__svg { stroke-dashoffset: 0; }

.task__text {
  flex: 1; font-size: 0.98rem; color: var(--fg);
  transition: color 0.3s var(--ease); word-break: break-word;
}
.task.is-done .task__text { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--done); }

.task__time {
  font-size: 0.68rem; color: var(--muted); letter-spacing: 0.04em;
  white-space: nowrap;
}

.task__delete {
  flex: none; opacity: 0;
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  color: var(--muted);
  transform: translateX(6px);
  transition: all 0.3s var(--ease);
}
.task:hover .task__delete { opacity: 1; transform: translateX(0); }
.task__delete:hover { background: var(--accent-soft); color: var(--accent); }
.task__delete svg { width: 16px; height: 16px; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 56px 20px;
  color: var(--muted);
  animation: rise 0.6s var(--ease-out) both;
}
.empty__icon {
  font-size: 2.4rem; color: var(--accent); opacity: 0.5;
  animation: spin 8s linear infinite; display: inline-block;
}
.empty__title { font-family: var(--font-display); font-size: 1.4rem; color: var(--fg-soft); margin-top: 14px; font-style: italic; }
.empty__sub { font-size: 0.85rem; margin-top: 6px; }

/* ---------- Footer ---------- */
.footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 18px; border-top: 1px dashed var(--border-strong);
  animation: rise 0.5s var(--ease-out) both;
}
.footer__count { font-size: 0.78rem; color: var(--muted); letter-spacing: 0.04em; }
.footer__clear {
  font-size: 0.78rem; color: var(--muted);
  padding: 8px 14px; border-radius: 8px;
  transition: all 0.3s var(--ease);
}
.footer__clear:hover { color: var(--accent); background: var(--accent-soft); }

.signature {
  text-align: center; font-size: 0.7rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted); margin-top: 8px;
}

/* ---------- Animations ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pop-out {
  to { opacity: 0; transform: translateX(40px) scale(0.95); height: 0; padding-top: 0; padding-bottom: 0; margin: 0; border-width: 0; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .shell { padding: 28px 18px 64px; gap: 26px; }
  .composer { padding: 6px 6px 6px 16px; flex-wrap: wrap; }
  .composer__input { min-width: 0; flex-basis: 100%; order: 2; padding: 8px 4px 10px; }
  .composer__plus { order: 1; }
  .composer__submit { order: 3; margin-left: auto; }
  .controls { justify-content: center; }
  .progress { width: 100%; justify-content: space-between; }
  .progress__bar { flex: 1; max-width: 180px; }
  .task__time { display: none; }
}

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