/* Signet component primitives — transcribed from DESIGN.md §2–§8.
 * Update this file when DESIGN.md changes. No silent drift.
 *
 * CSS custom properties carry the runtime color values. Light/dark follow
 * the system via prefers-color-scheme. Structural tokens (space, layout,
 * motion) are also exposed here for components to reference.
 *
 * Fonts (Inter, Berkeley Mono) are bundled under src/fonts/ per the C10
 * chunk description; @font-face declarations below assume that path will
 * exist. Missing fonts are a bug, not a fallback — §4.
 */

/* ---------- Fonts ---------- */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('../fonts/Inter-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: block;
  src: url('../fonts/Inter-Medium.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: block;
  src: url('../fonts/Inter-SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: 'Berkeley Mono';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('../fonts/BerkeleyMono-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Berkeley Mono';
  font-style: normal;
  font-weight: 600;
  font-display: block;
  src: url('../fonts/BerkeleyMono-SemiBold.woff2') format('woff2');
}

/* ---------- Tokens (custom properties) ----------
 * Dots in DESIGN.md token names become dashes in CSS (bg.app -> --bg-app).
 */

:root {
  /* §2.1 Identity palette — fixed across modes. */
  --identity-1:  #4ADE80;
  --identity-2:  #60A5FA;
  --identity-3:  #C084FC;
  --identity-4:  #FB923C;
  --identity-5:  #F472B6;
  --identity-6:  #2DD4BF;
  --identity-7:  #F87171;
  --identity-8:  #FBBF24;
  --identity-9:  #818CF8;
  --identity-10: #94A3B8;

  /* §2.2 Surface — light */
  --bg-app:       #FFFFFF;
  --bg-surface:   #FAFAFA;
  --bg-raised:    #FFFFFF;
  --bg-hover:     rgba(0, 0, 0, 0.04);
  --bg-selected:  rgba(0, 0, 0, 0.08);
  --bg-overlay:   rgba(0, 0, 0, 0.40);
  --divider:      rgba(0, 0, 0, 0.10);
  --border-input: rgba(0, 0, 0, 0.15);

  /* §2.3 Text — light */
  --text-primary:   rgba(0, 0, 0, 0.90);
  --text-secondary: rgba(0, 0, 0, 0.60);
  --text-tertiary:  rgba(0, 0, 0, 0.40);
  --text-meta:      rgba(0, 0, 0, 0.50);
  --text-disabled:  rgba(0, 0, 0, 0.30);
  --text-onAccent:  #FFFFFF;

  /* §2.4 Semantic — identical across modes */
  --accent:  #60A5FA;
  --success: #4ADE80;
  --warning: #FB923C;
  --error:   #F87171;
  --agent:   #60A5FA;

  /* §3 Spacing */
  --space-0: 0;
  --space-1: 2px;
  --space-2: 4px;
  --space-3: 8px;
  --space-4: 12px;
  --space-5: 16px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;
  --space-9: 64px;

  /* §3.1 Layout constants */
  --layout-titlebar:  28px;
  --layout-statusbar: 20px;
  --layout-leftRail:  184px;
  --layout-detail:    836px;
  --layout-tabStrip:  36px;
  --layout-row:       56px;

  /* §5.1 Motion */
  --motion-instant: 0ms;
  --motion-fast:    100ms;
  --motion-base:    200ms;
  --motion-slow:    1000ms;
  --motion-pulse:   2000ms;

  /* §5.2 Easing */
  --ease-standard:   cubic-bezier(0.2, 0, 0, 1);
  --ease-decelerate: cubic-bezier(0, 0, 0, 1);
  --ease-linear:     linear;

  /* §6 Elevation — shadows only; z-index is applied per-class below */
  --shadow-dropdown: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-palette:  0 8px 32px rgba(0, 0, 0, 0.25);
  --shadow-modal:    0 8px 32px rgba(0, 0, 0, 0.25);
  --shadow-toast:    0 4px 16px rgba(0, 0, 0, 0.20);
  --shadow-tooltip:  0 2px 8px rgba(0, 0, 0, 0.15);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-app:       #0E0E0E;
    --bg-surface:   #161616;
    --bg-raised:    #1C1C1C;
    --bg-hover:     rgba(255, 255, 255, 0.04);
    --bg-selected:  rgba(255, 255, 255, 0.08);
    --bg-overlay:   rgba(0, 0, 0, 0.60);
    --divider:      rgba(255, 255, 255, 0.10);
    --border-input: rgba(255, 255, 255, 0.15);

    --text-primary:   rgba(255, 255, 255, 0.90);
    --text-secondary: rgba(255, 255, 255, 0.60);
    --text-tertiary:  rgba(255, 255, 255, 0.40);
    --text-meta:      rgba(255, 255, 255, 0.50);
    --text-disabled:  rgba(255, 255, 255, 0.30);
  }
}

/* ---------- App chrome defaults ---------- */

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* §9 Focus — 2px accent outline, 2px offset, always visible on keyboard focus. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- §8.1 Row (thread list) ---------- */

.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--layout-row);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-surface);
  position: relative;
  cursor: default;
  transition: background-color var(--motion-fast) var(--ease-standard);
}
.row:hover { background: var(--bg-hover); }
.row[aria-selected='true'] { background: var(--bg-selected); }
.row[aria-selected='true']::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
}
.row__marker {
  font-size: 8px;
  line-height: 1;
  color: var(--text-primary);
  width: 8px;
  text-align: center;
  flex: 0 0 auto;
}
.row__sender {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 0 0 auto;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row__subject {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
}
.row__snippet {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}
.row__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
  margin-left: auto;
  flex: 0 0 auto;
}
.row__time {
  font-family: 'Berkeley Mono', monospace;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-tertiary);
}
.row__agent {
  font-size: 10px;
  color: var(--agent);
}

/* ---------- §8.2 Identity pill ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  min-width: 24px;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--space-2);
  font-family: 'Berkeley Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-onAccent);
  /* Background is assigned per-instance via inline style or a slot class. */
}
.pill--on-light { color: #000000; }

.pill--slot-1  { background: var(--identity-1); }
.pill--slot-2  { background: var(--identity-2); }
.pill--slot-3  { background: var(--identity-3); }
.pill--slot-4  { background: var(--identity-4); }
.pill--slot-5  { background: var(--identity-5); }
.pill--slot-6  { background: var(--identity-6); }
.pill--slot-7  { background: var(--identity-7); }
.pill--slot-8  { background: var(--identity-8); }
.pill--slot-9  { background: var(--identity-9); }
.pill--slot-10 { background: var(--identity-10); }

/* ---------- §8.3 Button ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 var(--space-4);
  border-radius: var(--space-2);
  border: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--motion-fast) var(--ease-standard);
}
.button:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.button--primary {
  background: var(--accent);
  color: var(--text-onAccent);
}
.button--primary:hover { filter: brightness(0.92); }

.button--secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-input);
}
.button--secondary:hover { background: var(--bg-hover); }

.button--ghost {
  background: transparent;
  color: var(--text-primary);
}
.button--ghost:hover { background: var(--bg-hover); }

.button--danger {
  background: var(--error);
  color: var(--text-onAccent);
}
.button--danger:hover { filter: brightness(0.92); }

/* ---------- §8.4 Input ---------- */

.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.input-group__label {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-secondary);
}
.input {
  height: 32px;
  padding: 0 var(--space-3);
  border-radius: var(--space-2);
  background: var(--bg-raised);
  border: 1px solid var(--border-input);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--motion-fast) var(--ease-standard);
}
.input::placeholder { color: var(--text-tertiary); }
.input:focus {
  border: 2px solid var(--accent);
  /* Compensate 1px → 2px border growth so content doesn't jump. */
  padding: 0 calc(var(--space-3) - 1px);
}
.input:disabled { opacity: 0.4; }
.input-group--error .input { border-color: var(--error); }
.input-group__error {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--error);
}

/* ---------- §8.5 Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: signet-fade-in var(--motion-fast) var(--ease-standard);
}
.modal {
  width: 400px;
  max-width: 560px;
  padding: var(--space-6);
  border-radius: var(--space-2);
  background: var(--bg-raised);
  box-shadow: var(--shadow-modal);
}
.modal--auto { width: auto; }

/* ---------- §8.6 Command palette (⌘K) ---------- */

.palette {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  width: 560px;
  background: var(--bg-raised);
  border-radius: var(--space-2);
  box-shadow: var(--shadow-palette);
  z-index: 200;
  overflow: hidden;
}
.palette__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 40px;
  padding: 0 var(--space-4);
}
.palette__glyph {
  font-family: 'Berkeley Mono', monospace;
  font-size: 13px;
  color: var(--text-tertiary);
}
.palette__input {
  flex: 1;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
}
.palette__input::placeholder { color: var(--text-tertiary); }
.palette__divider {
  height: 1px;
  background: var(--divider);
}
.palette__results {
  max-height: calc(36px * 8);
  overflow-y: auto;
}
.palette__result {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 36px;
  padding: 0 var(--space-4);
  position: relative;
  cursor: default;
}
.palette__result[aria-selected='true'] { background: var(--bg-hover); }
.palette__result[aria-selected='true']::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
}
.palette__result-name {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.2;
}
.palette__result-desc {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.2;
}

/* ---------- §8.7 Toast ---------- */

.toast {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  max-width: 320px;
  height: 36px;
  padding: 0 var(--space-4);
  display: inline-flex;
  align-items: center;
  border-radius: var(--space-2);
  background: var(--bg-raised);
  box-shadow: var(--shadow-toast);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  z-index: 400;
  animation:
    signet-fade-in var(--motion-base) var(--ease-standard),
    signet-fade-out var(--motion-base) var(--ease-standard) 2200ms forwards;
}

/* ---------- §8.8 Tab (GTD strip) ---------- */

.tab-strip {
  display: flex;
  align-items: stretch;
  height: var(--layout-tabStrip);
  border-bottom: 1px solid var(--divider);
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 var(--space-4);
  background: transparent;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: default;
  transition: background-color var(--motion-fast) var(--ease-standard);
}
.tab:hover { background: var(--bg-hover); }
.tab[aria-selected='true'] { color: var(--text-primary); }
.tab[aria-selected='true']::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent);
}
.tab__count {
  margin-left: var(--space-2);
  color: var(--text-tertiary);
}

/* ---------- §8.9 Card (inline proposal) ---------- */

.card {
  padding: var(--space-4);
  border-radius: var(--space-2);
  background: var(--bg-raised);
  border-left: 2px solid var(--accent);
  /* No shadow — inline cards sit in content flow. */
}
.card__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
}
.card__agent {
  color: var(--agent);
  font-size: 10px;
}
.card__shortcuts {
  margin-left: auto;
  font-family: 'Berkeley Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary);
}
.card__divider {
  height: 1px;
  background: var(--divider);
  margin: var(--space-3) 0;
}
.card__body {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-primary);
}
.card__footer {
  margin-top: var(--space-3);
  font-family: 'Berkeley Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary);
}
.card--approving {
  animation: signet-fade-out var(--motion-slow) var(--ease-standard) forwards;
}

/* ---------- §8.10 Dropdown (identity picker) ---------- */

.dropdown {
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-raised);
  border-radius: var(--space-2);
  box-shadow: var(--shadow-dropdown);
  z-index: 100;
}
.dropdown__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 36px;
  padding: 0 var(--space-4);
  cursor: default;
}
.dropdown__row:hover,
.dropdown__row[aria-selected='true'] {
  background: var(--bg-hover);
}
.dropdown__name {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
}
.dropdown__email {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-secondary);
  margin-left: auto;
}

/* ---------- §8.11 Divider ---------- */

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

/* ---------- Animations ---------- */

@keyframes signet-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes signet-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Agent ◉ pulse for in-flight proposals (§5.1 motion.pulse = 2000ms). */
@keyframes signet-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
.row__agent--pulsing,
.card__agent--pulsing {
  animation: signet-pulse var(--motion-pulse) var(--ease-linear) infinite;
}
