/* Theme: tokens and base components for the task app.
 *
 * Replaces nocturne.css. One accent (emerald), neutral greys, light and dark.
 * The page follows the device setting; <html data-theme="light|dark"> pins one
 * (set by the toggle in the rail). Every color, size and radius the screens use
 * comes from here; app.css only lays things out.
 *
 * Radius rule: containers 12px, controls 8px, tags and menu rows 6px,
 * avatars and dots round. Spacing is a 4px grid. Text is never below 12px. */

/* ── Light (default) ───────────────────────────────────────────────────── */
:root {
  color-scheme: light;

  --bg:            #f3f4f5;
  --surface:       #fcfcfc;
  --surface-2:     #fefefe;   /* popovers, menus: one step above a surface */
  --sunken:        #e8eaec;   /* progress tracks, wells */
  --hover:         rgba(23, 25, 28, .05);
  --press:         rgba(23, 25, 28, .09);

  --text:          #17191c;
  --text-2:        #4a4f57;   /* secondary: notes, labels */
  --text-3:        #696e77;   /* meta: dates, counts. Still 4.5:1 on --bg */

  --border:        #e1e3e6;
  --border-strong: #cbcfd4;

  --accent:        #0f7a55;
  --accent-hover:  #0b6646;
  --accent-soft:   #e2f1eb;
  --accent-ink:    #0a5a3e;   /* accent text on --accent-soft */
  --on-accent:     #f4fbf8;

  --hold:          #9aa0a8;   /* on-hold progress */
  --danger:        #b3302f;
  --danger-soft:   #fbeaea;

  /* Departments: six hues that stay apart from each other and from the
     accent. Used only for dots and the department bars, never for text. */
  --dept-marketing: #c2508a;
  --dept-sales:     #b47714;
  --dept-it:        #3a6fd8;
  --dept-finance:   #7158c9;
  --dept-ops:       #2f7f96;
  --dept-ceo:       #6f747d;

  --shadow-sm: 0 0 0 1px var(--border), 0 1px 2px rgba(23, 25, 28, .04);
  --shadow-md: 0 0 0 1px var(--border), 0 8px 24px rgba(23, 25, 28, .10);
  --shadow-lg: 0 0 0 1px var(--border-strong), 0 20px 48px rgba(23, 25, 28, .16);
  --scrim:     rgba(23, 25, 28, .32);

  --font-body: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "Cascadia Mono", monospace;

  --text-xs:   12px;
  --text-sm:   13px;
  --text-base: 14px;
  --text-md:   16px;
  --text-lg:   20px;
  --text-xl:   28px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --ease: cubic-bezier(.16, 1, .3, 1);

  /* Old names still read by inline styles in a few templates. */
  --color-bg: var(--bg);
  --color-surface: var(--surface);
  --color-text: var(--text);
  --color-accent: var(--accent);
  --color-divider: var(--border);
}

/* ── Dark ──────────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111314; --surface: #181a1c; --surface-2: #202326; --sunken: #26292d;
    --hover: rgba(235, 237, 239, .05); --press: rgba(235, 237, 239, .09);
    --text: #ebedef; --text-2: #a8acb3; --text-3: #888c94;
    --border: #272a2e; --border-strong: #383c42;
    --accent: #3fb68b; --accent-hover: #5cc79e; --accent-soft: #14302a; --accent-ink: #84d8b6; --on-accent: #06140f;
    --hold: #6c7179; --danger: #e27575; --danger-soft: #3a1e20;
    --dept-marketing: #e07aa9; --dept-sales: #e2a64a; --dept-it: #6f9cf0;
    --dept-finance: #9d8ae0; --dept-ops: #5fb0c6; --dept-ceo: #8d929b;
    --shadow-sm: 0 0 0 1px var(--border);
    --shadow-md: 0 0 0 1px var(--border-strong), 0 10px 28px rgba(0, 0, 0, .45);
    --shadow-lg: 0 0 0 1px var(--border-strong), 0 20px 50px rgba(0, 0, 0, .55);
    --scrim: rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111314; --surface: #181a1c; --surface-2: #202326; --sunken: #26292d;
  --hover: rgba(235, 237, 239, .05); --press: rgba(235, 237, 239, .09);
  --text: #ebedef; --text-2: #a8acb3; --text-3: #888c94;
  --border: #272a2e; --border-strong: #383c42;
  --accent: #3fb68b; --accent-hover: #5cc79e; --accent-soft: #14302a; --accent-ink: #84d8b6; --on-accent: #06140f;
  --hold: #6c7179; --danger: #e27575; --danger-soft: #3a1e20;
  --dept-marketing: #e07aa9; --dept-sales: #e2a64a; --dept-it: #6f9cf0;
  --dept-finance: #9d8ae0; --dept-ops: #5fb0c6; --dept-ceo: #8d929b;
  --shadow-sm: 0 0 0 1px var(--border);
  --shadow-md: 0 0 0 1px var(--border-strong), 0 10px 28px rgba(0, 0, 0, .45);
  --shadow-lg: 0 0 0 1px var(--border-strong), 0 20px 50px rgba(0, 0, 0, .55);
  --scrim: rgba(0, 0, 0, .55);
}

/* ── Base ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: var(--text-base); line-height: 1.5;
  font-feature-settings: "ss01"; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
p { margin: 0 0 var(--space-3); }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
img { display: block; max-width: 100%; }
code { font-family: var(--font-mono); font-size: .92em; }
.text-muted { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }

.hr { height: 1px; border: 0; margin: var(--space-3) 0; background: var(--border); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 36px; padding: 0 var(--space-3);
  font: inherit; font-size: var(--text-base); font-weight: 500; line-height: 1; white-space: nowrap;
  color: var(--text); background: transparent; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--radius-md);
  transition: background-color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn i { font-size: 16px; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-3); color: var(--text); }
.btn-ghost { color: var(--text-2); padding: 0 var(--space-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-ghost:active { background: var(--press); }
.btn-icon { width: 36px; padding: 0; }
.btn-block { width: 100%; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: var(--text-sm); font-weight: 500; color: var(--text-2); }
.input {
  width: 100%; min-height: 38px; padding: 8px 12px;
  font: inherit; font-size: var(--text-base); color: var(--text); caret-color: var(--accent);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--text-3); }
.input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea.input { min-height: 96px; resize: vertical; }
select.input { cursor: pointer; }

.radio { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--text-base); }
.radio input, .seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.radio .dot {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--border-strong); background: var(--surface);
}
.radio:hover .dot { border-color: var(--accent); }
.radio input:checked + .dot {
  border-color: var(--accent); background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--surface);
}
.radio input:focus-visible + .dot { outline: 2px solid var(--accent); outline-offset: 2px; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--sunken); border-radius: var(--radius-md);
}
.seg-opt {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 30px; padding: 0 var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--text-sm); color: var(--text-2); cursor: pointer;
}
.seg-opt:hover { color: var(--text); }
.seg-opt:has(input:checked) { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow-sm); }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.card-title { font-size: var(--text-md); font-weight: 600; }
.card-body { margin: 0; font-size: var(--text-sm); color: var(--text-2); }
.card-meta { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--text-3); }
.elev-sm { box-shadow: var(--shadow-sm); }
.elev-md { box-shadow: var(--shadow-md); }
.elev-lg { box-shadow: var(--shadow-lg); }

/* ── Tags ──────────────────────────────────────────────────────────────── */
/* Status language, shared by the log, roadmap and members:
   accent = done, outline = in progress, neutral = on hold, ghost = not started. */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 22px; padding: 0 8px; border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: 500; line-height: 1; white-space: nowrap;
}
.tag-accent  { background: var(--accent-soft); color: var(--accent-ink); }
.tag-accent-2 { background: var(--accent-soft); color: var(--accent-ink); }
.tag-outline { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent-ink); }
.tag-neutral { background: var(--sunken); color: var(--text-2); }
.tag-ghost   { box-shadow: inset 0 0 0 1px var(--border-strong); color: var(--text-3); }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.table th {
  padding: var(--space-2) var(--space-3); text-align: left; white-space: nowrap;
  font-size: var(--text-xs); font-weight: 500; color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
.table td { padding: 10px var(--space-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .12s var(--ease); }
.table tbody tr:hover { background: var(--hover); }

/* ── Dialog ────────────────────────────────────────────────────────────── */
.dialog-backdrop { position: fixed; inset: 0; display: grid; place-items: center; padding: var(--space-4); background: var(--scrim); }
.dialog {
  width: min(460px, 100%); display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-5); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.dialog-title { font-size: var(--text-md); font-weight: 600; }
.dialog-body { font-size: var(--text-base); color: var(--text-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); }

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