/* ==========================================================================
   To-Do Milestones — Neubrutalist design system
   Generated with the ui-ux-pro-max skill: Brutalism/Neubrutalism style,
   variance 9 (bold/asymmetric), motion 8 (complex choreography).
   Hard offset shadows instead of blur, 0px radius, thick borders, flat
   saturated color, Space Grotesk + Space Mono. All motion respects
   prefers-reduced-motion (see bottom of file).
   ========================================================================== */

:root {
  color-scheme: light;

  --surface-1: #ffffff;       /* card surface */
  --surface-2: #efece2;       /* page background (raw paper) */
  --text-primary: #0a0a0a;
  --text-secondary: #33322d;
  --text-muted: #6b695f;

  --ink: #0a0a0a;              /* border / shadow ink */
  --border: var(--ink);
  --border-width: 3px;
  --shadow-color: var(--ink);

  --accent: #ff3b00;           /* primary CTA, brand */
  --accent-ink: #0a0a0a;       /* text on accent */
  --accent-2: #ffe603;         /* secondary accent: progress, highlights */
  --accent-2-ink: #0a0a0a;

  --status-good: #00a844;
  --status-good-ink: #0a0a0a;
  --status-warning: #d68a00;
  --status-critical: #d6002b;
  --status-critical-ink: #ffffff;

  --gridline: rgba(10, 10, 10, 0.08);
  --baseline: var(--ink);

  --series-1: var(--accent);
  --series-1-track: #f4d9cc;

  --font-display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Space Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --ease-brutal: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #141414;
    --surface-2: #0a0a0a;
    --text-primary: #fafafa;
    --text-secondary: #cfcfc9;
    --text-muted: #8f8d84;

    --ink: #fafafa;
    --border: var(--ink);
    --shadow-color: var(--accent);

    --accent: #ff5722;
    --accent-ink: #0a0a0a;
    --accent-2: #ffe603;
    --accent-2-ink: #0a0a0a;

    --status-good: #00e676;
    --status-good-ink: #0a0a0a;
    --status-warning: #ffca28;
    --status-critical: #ff5252;
    --status-critical-ink: #0a0a0a;

    --gridline: rgba(250, 250, 250, 0.08);
    --baseline: var(--ink);

    --series-1-track: #4a2210;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #141414;
  --surface-2: #0a0a0a;
  --text-primary: #fafafa;
  --text-secondary: #cfcfc9;
  --text-muted: #8f8d84;

  --ink: #fafafa;
  --border: var(--ink);
  --shadow-color: var(--accent);

  --accent: #ff5722;
  --accent-ink: #0a0a0a;
  --accent-2: #ffe603;
  --accent-2-ink: #0a0a0a;

  --status-good: #00e676;
  --status-good-ink: #0a0a0a;
  --status-warning: #ffca28;
  --status-critical: #ff5252;
  --status-critical-ink: #0a0a0a;

  --gridline: rgba(250, 250, 250, 0.08);
  --baseline: var(--ink);

  --series-1-track: #4a2210;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-display);
  background:
    repeating-linear-gradient(
      0deg, var(--gridline), var(--gridline) 1px, transparent 1px, transparent 32px
    ),
    repeating-linear-gradient(
      90deg, var(--gridline), var(--gridline) 1px, transparent 1px, transparent 32px
    ),
    var(--surface-2);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 16px 72px;
}

h1 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin: 0 0 6px;
  line-height: 1.05;
}

h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  margin: 0;
}

.subtitle {
  color: var(--text-secondary);
  margin: 0 0 24px;
  font-size: 14px;
  max-width: 60ch;
}

/* Accent as text color fails AA on the light surfaces (checked: ~3:1), so
   links stay high-contrast ink with the accent carried by the underline. */
a {
  color: var(--text-primary);
  font-weight: 700;
  text-decoration-line: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* ---------- Surfaces: cards get thick borders + hard offset shadow ---------- */

.card {
  background: var(--surface-1);
  border: var(--border-width) solid var(--border);
  border-radius: 0;
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: 6px 6px 0 0 var(--shadow-color);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-tile {
  background: var(--surface-1);
  border: var(--border-width) solid var(--border);
  border-radius: 0;
  padding: 16px 18px;
  box-shadow: 5px 5px 0 0 var(--shadow-color);
}

.stat-tile .label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.stat-tile .value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}

section h2 {
  margin: 32px 0 14px;
  padding-bottom: 8px;
  border-bottom: var(--border-width) solid var(--border);
}

/* ---------- Forms ---------- */

form.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

form.inline-form .field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

form.inline-form label,
.field label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

input, textarea {
  font: inherit;
  font-family: var(--font-display);
  color: var(--text-primary);
  background: var(--surface-1);
  border: 2px solid var(--baseline);
  border-radius: 0;
  padding: 9px 10px;
  min-height: 44px;
}

input[name="estimated_hours"],
input[name="s-hours"],
input[type="number"] {
  font-family: var(--font-mono);
}

input:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Buttons: hard shadow that "pushes in" on press ---------- */

button {
  font: inherit;
  font-family: var(--font-display);
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  border: var(--border-width) solid var(--border);
  border-radius: 0;
  padding: 10px 18px;
  min-height: 44px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 13px;
  box-shadow: 4px 4px 0 0 var(--shadow-color);
  transition: transform 140ms var(--ease-brutal), box-shadow 140ms var(--ease-brutal), background-color 140ms;
}

button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 0 var(--shadow-color);
}

button:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 0 var(--shadow-color);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: 4px 4px 0 0 var(--shadow-color);
}

button.secondary {
  background: var(--surface-1);
  color: var(--text-primary);
}

button.danger {
  background: var(--surface-1);
  color: var(--status-critical);
  border-color: var(--status-critical);
  box-shadow: 4px 4px 0 0 var(--status-critical);
}

button.danger:hover { box-shadow: 6px 6px 0 0 var(--status-critical); }
button.danger:active { box-shadow: 0 0 0 0 var(--status-critical); }

.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.15em;
  flex-shrink: 0;
}

button .icon { margin-right: 6px; }

.error-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--status-critical);
  color: var(--status-critical-ink);
  border: var(--border-width) solid var(--border);
  border-radius: 0;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 4px 4px 0 0 var(--shadow-color);
  animation: slide-snap 220ms var(--ease-brutal);
}

/* ---------- To-Do cards ---------- */

.todo-card .todo-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.todo-title {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: -0.005em;
}

.todo-desc {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 4px 0 0;
}

.todo-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin: 14px 0 8px;
}

/* Progress meter: hard-bordered track, fill animates via transform scaleX */

.meter {
  height: 16px;
  border: 2px solid var(--baseline);
  border-radius: 0;
  background: var(--series-1-track);
  overflow: hidden;
  margin: 10px 0 6px;
  position: relative;
}

.meter .fill {
  height: 100%;
  width: 100%;
  background: var(--accent-2);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 600ms var(--ease-brutal);
  background-image: repeating-linear-gradient(
    135deg, rgba(10,10,10,0.12) 0 6px, transparent 6px 12px
  );
}

.allocation-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.allocation-hint.ok {
  color: var(--status-good-ink);
  background: var(--status-good);
  border: 2px solid var(--border);
  padding: 3px 8px;
}

ul.milestone-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.milestone-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 2px solid var(--baseline);
  border-radius: 0;
  background: var(--surface-1);
}

.milestone-row.complete {
  background: repeating-linear-gradient(
    135deg, var(--surface-1) 0 8px, var(--surface-2) 8px 16px
  );
}

.milestone-row.complete .m-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.milestone-row .m-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.milestone-row .m-hours {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Custom checkbox: real (visually-hidden) input + sibling box, so the
   checkmark is a real SVG element rather than ::before/::after on <input>
   (replaced elements don't render generated content in any browser). */

.checkbox-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -10px;
  flex-shrink: 0;
  cursor: pointer;
}

.checkbox-wrap input[type="checkbox"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.checkbox-box {
  width: 22px;
  height: 22px;
  border: 2px solid var(--baseline);
  background: var(--surface-1);
  display: grid;
  place-content: center;
  flex-shrink: 0;
  pointer-events: none;
}

.checkbox-box .icon {
  width: 14px;
  height: 14px;
  color: var(--accent-ink);
  transform: scale(0);
  transition: transform 200ms var(--ease-pop);
}

.checkbox-wrap input[type="checkbox"]:checked ~ .checkbox-box {
  background: var(--status-good);
}

.checkbox-wrap input[type="checkbox"]:checked ~ .checkbox-box .icon {
  transform: scale(1);
}

.checkbox-wrap input[type="checkbox"]:focus-visible ~ .checkbox-box {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

button.icon-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  box-shadow: none;
  padding: 6px;
  min-height: 32px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.icon-btn:hover {
  transform: none;
  color: var(--status-critical);
  box-shadow: none;
}

button.icon-btn:active {
  transform: scale(0.85);
  box-shadow: none;
}

button.icon-btn .icon { margin-right: 0; }

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

/* ---------- Charts ---------- */

.chart-card svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chart-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 2px solid var(--border);
  border-radius: 0;
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  box-shadow: 3px 3px 0 0 var(--shadow-color);
  transform: translate(-50%, -110%);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.1s ease;
}

.chart-tooltip .t-date {
  color: var(--text-muted);
  margin-bottom: 2px;
  font-family: var(--font-display);
}

.chart-tooltip .t-value {
  color: var(--text-primary);
  font-weight: 700;
}

.chart-wrap {
  position: relative;
}

.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px 0;
  text-align: center;
  border: 2px dashed var(--baseline);
}

@media (max-width: 520px) {
  .todo-head { flex-direction: column; }
}

/* ---------- AI suggestion editor ---------- */

.suggest-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggest-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 2px solid var(--baseline);
  border-radius: 0;
  background: var(--surface-1);
}

.suggest-row input[name="s-title"] {
  flex: 1;
}

.suggest-row input[name="s-hours"] {
  width: 90px;
}

.suggest-summary {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin: 6px 0 10px;
}

.suggest-summary.ok {
  color: var(--status-good-ink);
  background: var(--status-good);
  display: inline-block;
  padding: 3px 8px;
  border: 2px solid var(--border);
}

.spinner-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 10px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.spinner-text::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 3px solid var(--baseline);
  border-top-color: var(--accent);
  flex-shrink: 0;
  animation: spin 700ms linear infinite;
}

/* ==========================================================================
   Motion — stagger entrance, snap transitions, chart draw-in.
   Every rule above is a compositor-safe transform/opacity animation, and
   the whole system is switched off below for prefers-reduced-motion.
   ========================================================================== */

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

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

.stagger-in {
  animation: stagger-in 420ms var(--ease-brutal) both;
}

.chart-line-draw {
  transition: stroke-dashoffset 700ms var(--ease-brutal);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
