/* ============================================================
   TeamBoard - theme + premium polish layer
   Loaded AFTER app.css so the dark theme (in app.css :root) stays
   exactly as built, while this file adds:
     1. light-theme token overrides under [data-theme="light"]
     2. a few new tokens so hardcoded dark values can flip per theme
     3. the dark/light toggle control styling
     4. tasteful Apple-level micro-interactions + loading states
   The whole theme is expressed in CSS custom properties, so no view
   code knows which theme is active. The dawl brand identity (Brand
   Orange #EB522A, Nunito ExtraBold + DM Mono, lowercase "dawl" +
   orange-dot wordmark) is shared by both themes; the espresso brand
   rail stays dark in BOTH so the brand anchor never weakens.
   ============================================================ */

/* ---- New tokens, dark defaults (match the original hardcoded values
        so dark mode is visually identical to before). ---- */
:root {
  /* AA nudge: the original --ink-faint (#82828f) landed at ~4.1:1 on the
     paper-2 hover/chip fill, just under AA 4.5. Lift it a touch so muted meta
     text (counts, empty chips, timestamps) clears AA on every dark surface.
     The core brand palette (orange, canvas, cards, primary/secondary text) is
     unchanged - this only touches the faintest tier. */
  --ink-faint: #9a9aa8;
  --rail-accent: #ff7d57;        /* active rail link text (bright on dark rail) */
  --btn-hover: #2a2a35;          /* secondary button hover fill */
  --seg-track: var(--surface);   /* segmented control (view toggle) track */
  --seg-active: #2f2f3a;         /* segmented control active pill */
  --cell-hover: var(--surface);  /* inline-edit cell hover fill */
  --scrim: rgba(0, 0, 0, 0.6);   /* modal / drawer backdrop */
  --drag-shadow: 0 22px 50px rgba(0, 0, 0, 0.7);
  --focus-ring: var(--accent);
}

/* ============================================================
   LIGHT THEME
   A clean premium light surface carrying the same design language.
   Warm off-white canvas (not stark white), white raised cards, the
   same Brand Orange accent, dark-on-orange CTAs. The brand rail stays
   dark (its tokens are intentionally NOT overridden here).
   ============================================================ */
html[data-theme="light"] {
  color-scheme: light;

  /* Canvas + elevation */
  --paper: #f6f5f2;          /* warm off-white canvas */
  --paper-2: #eceae6;        /* hover / subtle fill */
  --surface: #ffffff;        /* topbar, inputs */
  --surface-raised: #ffffff; /* cards, menus, raised panels */

  /* Text (AA on the light canvas / white cards) */
  --ink: #1b1b22;            /* primary text */
  --ink-soft: #53535d;       /* secondary copy (AA) */
  --ink-faint: #62626b;      /* meta / muted labels (AA on canvas AND paper-2 fill) */
  --line: #e6e4df;           /* borders & rules */
  --line-strong: #d3d1ca;    /* stronger borders */

  /* Accent: brand orange (CTA bg stays orange with dark ink for AA) */
  --accent: #eb522a;
  --accent-strong: #d8421b;  /* hover on solid CTA */
  --accent-text: #b8400f;    /* orange as text / icon on light (AA ~5:1) */
  --accent-soft: rgba(235, 82, 42, 0.12);
  /* --accent-ink intentionally inherited (dark text on solid orange = AA) */

  /* Feedback (darkened for legibility on light) */
  --danger: #c0291b;
  --danger-soft: rgba(192, 41, 27, 0.12);
  --warn: #9a6700;
  --overdue: #c0291b;
  --success: #15803d;

  /* Shadows: softer + cooler on light */
  --shadow-sm: 0 1px 2px rgba(24, 24, 31, 0.06);
  --shadow: 0 6px 20px rgba(24, 24, 31, 0.10);
  --shadow-lg: 0 20px 50px rgba(24, 24, 31, 0.18);

  /* New tokens, light values */
  --btn-hover: #f0eee9;
  --seg-track: #ecebe6;
  --seg-active: #ffffff;
  --cell-hover: #f0eee9;
  --scrim: rgba(28, 28, 36, 0.34);
  --drag-shadow: 0 22px 50px rgba(24, 24, 31, 0.28);
}

html[data-theme="light"] body { color-scheme: light; }

/* Light selection: brand-orange wash with dark text. */
html[data-theme="light"] ::selection { background: rgba(235, 82, 42, 0.22); color: #1b1b22; }

/* ============================================================
   Token-flip overrides for spots that used hardcoded dark values.
   Same specificity as the originals; this file loads later, so these
   win. In dark mode the tokens resolve to the original values, so
   dark is unchanged.
   ============================================================ */
.btn:hover { background: var(--btn-hover); border-color: var(--ink-faint); }
.viewtoggle { background: var(--seg-track); }
.viewtoggle button.active { background: var(--seg-active); color: var(--ink); box-shadow: var(--shadow-sm); }
html[data-theme="light"] .viewtoggle button.active { border: 1px solid var(--line); }
.cell-edit:hover { border-color: var(--line); background: var(--cell-hover); }
.cell-trigger:hover { border-color: var(--line); background: var(--cell-hover); }
.rail-link.active { color: var(--rail-accent); }
.rail-link.active .count { color: var(--rail-accent); }
.scrim { background: var(--scrim); }

/* The grid header sits on a card in light mode: keep it a touch off the card
   so columns read as a header band, not blank space. */
html[data-theme="light"] table.grid th { background: #faf9f7; }
html[data-theme="light"] tr.sub-row td { background: #faf9f7; }

/* Kanban columns read better with a faint tint on the light canvas. */
html[data-theme="light"] .kcol { background: #f1efeb; }

/* ============================================================
   Theme toggle control: fixed top-right, present on every view.
   ============================================================ */
.theme-toggle-root {
  position: fixed;
  top: 13px;
  right: 16px;
  z-index: 880;            /* above content + topbar, below overlays/scrim (900+) */
}
.theme-toggle-root .theme-toggle {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease),
    color 0.16s var(--ease), transform 0.12s var(--ease), box-shadow 0.16s var(--ease);
}
.theme-toggle-root .theme-toggle:hover {
  color: var(--accent-text);
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.theme-toggle-root .theme-toggle:active { transform: translateY(0); }
.theme-toggle-root .theme-toggle svg {
  transition: transform 0.4s var(--ease), opacity 0.2s var(--ease);
}
.theme-toggle-root .theme-toggle:hover svg { transform: rotate(28deg); }

/* Reserve space at the top-right of the topbar so the action cluster never
   slides under the fixed toggle. */
.topbar { padding-right: 66px; }
@media (max-width: 920px) { .topbar { padding-right: 58px; } }

/* ============================================================
   Premium polish: micro-interactions + refined detail.
   Tasteful and subtle, never flashy. All motion respects
   prefers-reduced-motion (the global guard in app.css zeroes
   transition/animation durations).
   ============================================================ */

/* The scrollable content region is focused programmatically (tabindex=-1)
   on every route change for screen-reader/keyboard orientation. It is NOT an
   interactive control, so suppress the focus ring that would otherwise frame
   the whole viewport. Genuine keyboard focus on real controls is untouched. */
#view-content:focus,
#view-content:focus-visible { outline: none; }

/* Slightly tighter, offset focus ring with a soft halo: crisp for keyboard
   users, not heavy. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 5px;
}

/* Buttons: add a subtle lift on hover for the primary CTA, keep the press. */
.btn { transition: background 0.14s var(--ease), border-color 0.14s var(--ease),
  color 0.14s var(--ease), transform 0.08s var(--ease), box-shadow 0.16s var(--ease); }
.btn-primary:hover { box-shadow: 0 4px 14px var(--accent-soft); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

/* Cards lift a touch more smoothly on hover. */
.list-card, .grid-wrap { transition: box-shadow 0.2s var(--ease), border-color 0.18s var(--ease); }
.list-card:hover { box-shadow: var(--shadow); }

/* BUGFIX: the roster picker renders each row as a <button class="lrow">. A
   bare button carries the UA default background (a mid-gray system color under
   color-scheme: dark), which bled through behind the rows - washing them out
   and dropping the email text below AA. Give picker buttons an explicit raised
   surface so they read as real cards and text contrast is correct. */
.login-panel button.lrow {
  background: var(--surface-raised);
  color: var(--ink);
}
.login-panel button.lrow:hover { background: var(--paper-2); }

/* List rows: a subtle accent edge on hover/focus so the click target is clear. */
.lrow { position: relative; transition: background 0.12s var(--ease); }
.lrow::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform 0.16s var(--ease);
}
.lrow:hover::before, .lrow:focus-visible::before { transform: scaleY(1); }

/* Section caret + expand chevrons rotate smoothly (already animated; reinforce). */
.section-head .caret, .item-title-cell .expand-btn { transition: transform 0.2s var(--ease), background 0.13s var(--ease); }

/* Rail links: a faint slide-in of the accent on hover. */
.rail-link { position: relative; }

/* ---- Kanban drag-and-drop: smooth, responsive, no jank ---- */
.kcard {
  transition: box-shadow 0.16s var(--ease), transform 0.12s var(--ease),
    border-color 0.16s var(--ease), opacity 0.12s var(--ease);
  will-change: transform;
}
.kcard:hover { transform: translateY(-2px); }
.kcard.dragging {
  opacity: 0.55;
  transform: scale(1.02) rotate(0.6deg);
  box-shadow: var(--drag-shadow);
  cursor: grabbing;
}
.kcol {
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease),
    box-shadow 0.16s var(--ease);
}
.kcol.drop-active {
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}
/* A clear drop affordance: a dashed lane that appears in the active column. */
.kcol.drop-active .kcol-body::after {
  content: "Drop here";
  display: block;
  border: 1.5px dashed var(--accent);
  border-radius: var(--radius);
  color: var(--accent-text);
  font-size: 12px;
  text-align: center;
  padding: 12px;
  margin-top: 2px;
  background: var(--accent-soft);
  animation: droppulse 1.4s var(--ease) infinite;
}
@keyframes droppulse { 0%,100% { opacity: 0.7; } 50% { opacity: 1; } }
/* keyboard pick target highlight */
.kcol.kbd-target { outline: 2px dashed var(--accent); outline-offset: -4px; }

/* ---- Drawer + modal: a touch more polish on enter ---- */
.drawer-tabs button { transition: color 0.14s var(--ease), border-color 0.14s var(--ease); }
.menu-item { transition: background 0.1s var(--ease), padding-left 0.12s var(--ease); }
.menu-item:hover, .menu-item.focused { padding-left: 13px; }

/* Chips: gentle pop so a status change reads as a real state change. */
.chip.status { transition: background 0.18s var(--ease), color 0.18s var(--ease); }

/* BUGFIX: the empty status/priority chips carry the class "empty" (e.g.
   "chip priority empty"), which collided with the empty-STATE container rule
   `.empty { padding: 64px 24px }` (same specificity, later in app.css). That
   inflated every empty chip to ~147px tall and stretched table rows to ~214px.
   Restore the proper chip padding with a higher-specificity selector. */
.chip.empty,
.chip.status.empty,
.chip.priority.empty {
  padding: 3px 11px;
  margin: 0;
  max-width: none;
  text-align: center;
}

/* Inputs: smoother focus halo. */
.input, .select, .textarea,
.filterbar .search-wrap input, .comment-compose textarea {
  transition: border-color 0.14s var(--ease), box-shadow 0.16s var(--ease), background 0.14s var(--ease);
}

/* ---- Loading states ---- */

/* Boot spinner: shown while the app shell is mounting (#app[aria-busy=true],
   set in index.html and flipped to false once the shell renders). Gives a
   premium first-load state instead of a blank canvas. */
#app[aria-busy="true"] {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
}
#app[aria-busy="true"]::after {
  content: "";
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: tb-spin 0.8s linear infinite;
}
#app[aria-busy="true"] noscript { display: none; }

/* Reusable inline spinner (available to any view that wants one). */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: tb-spin 0.7s linear infinite;
  vertical-align: middle;
}
.spinner.lg { width: 28px; height: 28px; border-width: 3px; }

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

/* The live-dot pulse already reads as "polling"; make sure it eases nicely. */
.live-dot .pulse { transition: background 0.2s var(--ease); }

/* Empty-state art: a softer, more intentional treatment. */
.empty .art { transition: transform 0.2s var(--ease); }
.empty:hover .art { transform: scale(1.04); }

/* Avatar ring tightens on light so initials read crisply. */
html[data-theme="light"] .avatar { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }

/* Reduced-motion: also disable the spinner spin + drop pulse so nothing moves. */
@media (prefers-reduced-motion: reduce) {
  #app[aria-busy="true"]::after, .spinner { animation: none; }
  .kcard.dragging { transform: none; }
}
