/* Roomwright design tokens. Owner: shell (see docs/CONTRACT.md, section 8).
   Idea: a drafting table. Quiet neutral chrome, crisp drafting paper, CAD-blue selection and
   orange AI "redlines". Every colour is defined once here with light-dark(); everyone else uses the
   variables. Colour tokens are registered with @property so getComputedStyle() returns a resolved
   rgb() value (canvas code reads them), and :root[data-theme] can force a scheme for testing. */

/* ---------- registered colour tokens (resolve light-dark() at computed-value time) ---------- */
@property --rw-bg { syntax: '<color>'; inherits: true; initial-value: #FFFFFF; }
@property --rw-bg-subtle { syntax: '<color>'; inherits: true; initial-value: #F6F6F4; }
@property --rw-bg-raised { syntax: '<color>'; inherits: true; initial-value: #FFFFFF; }
@property --rw-bg-hover { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --rw-bg-active { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --rw-line { syntax: '<color>'; inherits: true; initial-value: #E5E5E0; }
@property --rw-line-strong { syntax: '<color>'; inherits: true; initial-value: #D0D0C9; }
@property --rw-ink { syntax: '<color>'; inherits: true; initial-value: #16181B; }
@property --rw-ink-2 { syntax: '<color>'; inherits: true; initial-value: #50555C; }
@property --rw-ink-3 { syntax: '<color>'; inherits: true; initial-value: #6E737A; }
@property --rw-primary { syntax: '<color>'; inherits: true; initial-value: #16181B; }
@property --rw-primary-hover { syntax: '<color>'; inherits: true; initial-value: #2A2D32; }
@property --rw-on-primary { syntax: '<color>'; inherits: true; initial-value: #FFFFFF; }
@property --rw-select { syntax: '<color>'; inherits: true; initial-value: #2F6BFF; }
@property --rw-select-hover { syntax: '<color>'; inherits: true; initial-value: #2259E6; }
@property --rw-select-tint { syntax: '<color>'; inherits: true; initial-value: rgba(47, 107, 255, 0.1); }
@property --rw-select-line { syntax: '<color>'; inherits: true; initial-value: rgba(47, 107, 255, 0.45); }
@property --rw-focus-ring { syntax: '<color>'; inherits: true; initial-value: rgba(47, 107, 255, 0.28); }
@property --rw-ai { syntax: '<color>'; inherits: true; initial-value: #EC5A1F; }
@property --rw-ai-hover { syntax: '<color>'; inherits: true; initial-value: #D84E15; }
@property --rw-ai-tint { syntax: '<color>'; inherits: true; initial-value: #FFF2EC; }
@property --rw-ai-ink { syntax: '<color>'; inherits: true; initial-value: #B43C0B; }
@property --rw-ai-line { syntax: '<color>'; inherits: true; initial-value: #F7CDB9; }
@property --rw-on-ai { syntax: '<color>'; inherits: true; initial-value: #FFFFFF; }
@property --rw-ok { syntax: '<color>'; inherits: true; initial-value: #12A150; }
@property --rw-ok-tint { syntax: '<color>'; inherits: true; initial-value: #E7F6EE; }
@property --rw-ok-ink { syntax: '<color>'; inherits: true; initial-value: #0B7A3B; }
@property --rw-warn { syntax: '<color>'; inherits: true; initial-value: #B7791F; }
@property --rw-warn-tint { syntax: '<color>'; inherits: true; initial-value: #FBF3E3; }
@property --rw-warn-ink { syntax: '<color>'; inherits: true; initial-value: #87570F; }
@property --rw-danger { syntax: '<color>'; inherits: true; initial-value: #D92D20; }
@property --rw-danger-hover { syntax: '<color>'; inherits: true; initial-value: #C0261A; }
@property --rw-danger-tint { syntax: '<color>'; inherits: true; initial-value: #FDECEA; }
@property --rw-danger-ink { syntax: '<color>'; inherits: true; initial-value: #B42318; }
@property --rw-scrim { syntax: '<color>'; inherits: true; initial-value: rgba(16, 18, 21, 0.32); }
@property --rw-tooltip-bg { syntax: '<color>'; inherits: true; initial-value: #1C1F23; }
@property --rw-tooltip-ink { syntax: '<color>'; inherits: true; initial-value: #FFFFFF; }
@property --rw-tooltip-ink-2 { syntax: '<color>'; inherits: true; initial-value: #A9AEB6; }
@property --rw-tooltip-line { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --rw-kbd-bg { syntax: '<color>'; inherits: true; initial-value: #FFFFFF; }
@property --rw-kbd-line { syntax: '<color>'; inherits: true; initial-value: #D9D9D3; }
@property --rw-skeleton { syntax: '<color>'; inherits: true; initial-value: #EEEEEA; }
@property --rw-skeleton-hi { syntax: '<color>'; inherits: true; initial-value: #F8F8F6; }
@property --rw-highlight { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --rw-shadow-color-soft { syntax: '<color>'; inherits: true; initial-value: rgba(16, 18, 21, 0.06); }
@property --rw-shadow-color { syntax: '<color>'; inherits: true; initial-value: rgba(16, 18, 21, 0.1); }
@property --rw-shadow-color-strong { syntax: '<color>'; inherits: true; initial-value: rgba(16, 18, 21, 0.24); }
@property --cv-bg { syntax: '<color>'; inherits: true; initial-value: #F4F4F1; }
@property --cv-grid { syntax: '<color>'; inherits: true; initial-value: #E7E7E2; }
@property --cv-grid-major { syntax: '<color>'; inherits: true; initial-value: #D7D7D0; }
@property --cv-wall { syntax: '<color>'; inherits: true; initial-value: #2A2D31; }
@property --cv-wall-ext { syntax: '<color>'; inherits: true; initial-value: #1C1E21; }
@property --cv-ink { syntax: '<color>'; inherits: true; initial-value: #2A2D31; }
@property --cv-dim { syntax: '<color>'; inherits: true; initial-value: #6B7078; }
@property --cv-furn-stroke { syntax: '<color>'; inherits: true; initial-value: #3C4046; }
@property --cv-furn-fill { syntax: '<color>'; inherits: true; initial-value: #FFFFFF; }
@property --cv-furn-detail { syntax: '<color>'; inherits: true; initial-value: #9EA3AA; }
@property --cv-glass { syntax: '<color>'; inherits: true; initial-value: #7FA9DA; }
@property --cv-ai { syntax: '<color>'; inherits: true; initial-value: #EC5A1F; }
@property --cv-ai-tint { syntax: '<color>'; inherits: true; initial-value: rgba(236, 90, 31, 0.1); }
@property --cv-select { syntax: '<color>'; inherits: true; initial-value: #2F6BFF; }
@property --cv-select-tint { syntax: '<color>'; inherits: true; initial-value: rgba(47, 107, 255, 0.1); }
@property --cv-warn { syntax: '<color>'; inherits: true; initial-value: #B7791F; }
@property --cv-room-living { syntax: '<color>'; inherits: true; initial-value: #E9EFE1; }
@property --cv-room-kitchen { syntax: '<color>'; inherits: true; initial-value: #F6EDDC; }
@property --cv-room-dining { syntax: '<color>'; inherits: true; initial-value: #F3EAE3; }
@property --cv-room-bedroom { syntax: '<color>'; inherits: true; initial-value: #E7EBF5; }
@property --cv-room-bathroom { syntax: '<color>'; inherits: true; initial-value: #DFEEF1; }
@property --cv-room-office { syntax: '<color>'; inherits: true; initial-value: #ECE8F4; }
@property --cv-room-hall { syntax: '<color>'; inherits: true; initial-value: #EFEFEB; }
@property --cv-room-storage { syntax: '<color>'; inherits: true; initial-value: #EAEAE5; }
@property --cv-room-laundry { syntax: '<color>'; inherits: true; initial-value: #E6EEF0; }
@property --cv-room-garage { syntax: '<color>'; inherits: true; initial-value: #E8E8E8; }
@property --cv-room-garden { syntax: '<color>'; inherits: true; initial-value: #DCEAD2; }
@property --cv-room-patio { syntax: '<color>'; inherits: true; initial-value: #EAE6DF; }
@property --cv-room-balcony { syntax: '<color>'; inherits: true; initial-value: #E8E4DC; }
@property --cv-room-other { syntax: '<color>'; inherits: true; initial-value: #EFEFEF; }

:root {
  color-scheme: light dark;

  /* ---------- chrome ---------- */
  --rw-bg: light-dark(#FFFFFF, #111316);              /* panels, bars */
  --rw-bg-subtle: light-dark(#F6F6F4, #16191D);       /* hovers, inputs, wells */
  --rw-bg-raised: light-dark(#FFFFFF, #1B1E23);       /* popovers, menus, modals, floating bars */
  --rw-bg-hover: light-dark(rgba(22, 24, 27, 0.05), rgba(236, 237, 239, 0.06));   /* ghost hover on any surface */
  --rw-bg-active: light-dark(rgba(22, 24, 27, 0.09), rgba(236, 237, 239, 0.1));   /* pressed */
  --rw-line: light-dark(#E5E5E0, #262A30);            /* borders, dividers */
  --rw-line-strong: light-dark(#D0D0C9, #363B43);     /* input borders */
  --rw-ink: light-dark(#16181B, #ECEDEF);             /* text */
  --rw-ink-2: light-dark(#50555C, #A9AEB6);           /* secondary text */
  --rw-ink-3: light-dark(#6E737A, #868C96);           /* hints; ≥ 4.5:1 on --rw-bg in both schemes (WCAG AA) */
  --rw-primary: light-dark(#16181B, #F1F2F4);
  --rw-primary-hover: light-dark(#2B2E33, #FFFFFF);
  --rw-on-primary: light-dark(#FFFFFF, #111316);

  /* ---------- meaning: selection (CAD blue) ---------- */
  --rw-select: light-dark(#2F6BFF, #6A97FF);
  --rw-select-hover: light-dark(#2259E6, #82A8FF);
  --rw-select-tint: light-dark(rgba(47, 107, 255, 0.1), rgba(106, 151, 255, 0.16));
  --rw-select-line: light-dark(rgba(47, 107, 255, 0.45), rgba(106, 151, 255, 0.5));
  --rw-focus-ring: light-dark(rgba(47, 107, 255, 0.26), rgba(106, 151, 255, 0.34));

  /* ---------- meaning: AI (redline orange) ---------- */
  --rw-ai: light-dark(#EC5A1F, #FF7A45);
  --rw-ai-hover: light-dark(#D84E15, #FF8B5C);
  --rw-ai-tint: light-dark(#FFF2EC, #2B1B13);
  --rw-ai-ink: light-dark(#B43C0B, #FFA27A);           /* AI text on --rw-ai-tint */
  --rw-ai-line: light-dark(#F7CDB9, #4D2B1A);          /* borders of AI surfaces */
  --rw-on-ai: light-dark(#FFFFFF, #FFFFFF);

  /* ---------- meaning: status ---------- */
  --rw-ok: light-dark(#12A150, #3CCB7F);
  --rw-ok-tint: light-dark(#E7F6EE, rgba(60, 203, 127, 0.14));
  --rw-ok-ink: light-dark(#0B7A3B, #6EE0A2);
  --rw-warn: light-dark(#B7791F, #E0A33A);
  --rw-warn-tint: light-dark(#FBF3E3, rgba(224, 163, 58, 0.14));
  --rw-warn-ink: light-dark(#87570F, #F0BF6A);
  --rw-danger: light-dark(#D92D20, #F97066);
  --rw-danger-hover: light-dark(#C0261A, #FB8A82);
  --rw-danger-tint: light-dark(#FDECEA, rgba(249, 112, 102, 0.14));
  --rw-danger-ink: light-dark(#B42318, #FDA29B);

  /* ---------- overlays ---------- */
  --rw-scrim: light-dark(rgba(16, 18, 21, 0.32), rgba(0, 0, 0, 0.56));
  --rw-tooltip-bg: light-dark(#1C1F23, #2B2F36);
  --rw-tooltip-ink: light-dark(#FFFFFF, #ECEDEF);
  --rw-tooltip-ink-2: light-dark(#A9AEB6, #A9AEB6);
  --rw-tooltip-line: light-dark(transparent, #3A3F47);
  --rw-kbd-bg: light-dark(#FFFFFF, #23272D);
  --rw-kbd-line: light-dark(#D9D9D3, #3A3F47);
  --rw-skeleton: light-dark(#EEEEEA, #1D2025);
  --rw-skeleton-hi: light-dark(#F8F8F6, #262A30);
  --rw-highlight: light-dark(transparent, rgba(255, 255, 255, 0.045));   /* top edge light on raised dark surfaces */

  /* ---------- shadows (light: soft graphite; dark: deeper, black-based) ---------- */
  --rw-shadow-color-soft: light-dark(rgba(16, 18, 21, 0.06), rgba(0, 0, 0, 0.36));
  --rw-shadow-color: light-dark(rgba(16, 18, 21, 0.1), rgba(0, 0, 0, 0.46));
  --rw-shadow-color-strong: light-dark(rgba(16, 18, 21, 0.24), rgba(0, 0, 0, 0.62));
  --rw-shadow-xs: 0 1px 1px var(--rw-shadow-color-soft);
  --rw-shadow-sm: 0 1px 2px var(--rw-shadow-color-soft), 0 2px 6px var(--rw-shadow-color-soft);
  --rw-shadow-float: 0 1px 2px var(--rw-shadow-color-soft), 0 8px 24px var(--rw-shadow-color);
  --rw-shadow-modal: 0 24px 64px var(--rw-shadow-color-strong);

  /* ---------- canvas (drafting paper) ---------- */
  --cv-bg: light-dark(#F4F4F1, #0C0E11);
  --cv-grid: light-dark(#E7E7E2, #181B20);
  --cv-grid-major: light-dark(#D7D7D0, #232830);
  --cv-wall: light-dark(#2A2D31, #D6D9DE);
  --cv-wall-ext: light-dark(#1C1E21, #E9EBEE);
  --cv-ink: light-dark(#2A2D31, #D5D8DD);
  --cv-dim: light-dark(#6B7078, #8A9099);
  --cv-furn-stroke: light-dark(#3C4046, #AAB0B8);
  --cv-furn-fill: light-dark(#FFFFFF, #1A1D22);
  --cv-furn-detail: light-dark(#9EA3AA, #5E646D);
  --cv-glass: light-dark(#7FA9DA, #5E86B5);
  --cv-ai: light-dark(#EC5A1F, #FF7A45);                         /* AI redlines */
  --cv-ai-tint: light-dark(rgba(236, 90, 31, 0.1), rgba(255, 122, 69, 0.14));
  --cv-select: light-dark(#2F6BFF, #6A97FF);
  --cv-select-tint: light-dark(rgba(47, 107, 255, 0.1), rgba(106, 151, 255, 0.16));
  --cv-warn: light-dark(#B7791F, #E0A33A);
  --cv-room-living: light-dark(#E9EFE1, #1C2419);
  --cv-room-kitchen: light-dark(#F6EDDC, #2A2417);
  --cv-room-dining: light-dark(#F3EAE3, #272019);
  --cv-room-bedroom: light-dark(#E7EBF5, #1B2030);
  --cv-room-bathroom: light-dark(#DFEEF1, #16262A);
  --cv-room-office: light-dark(#ECE8F4, #221E2C);
  --cv-room-hall: light-dark(#EFEFEB, #1C1E21);
  --cv-room-storage: light-dark(#EAEAE5, #1E1F20);
  --cv-room-laundry: light-dark(#E6EEF0, #1A2326);
  --cv-room-garage: light-dark(#E8E8E8, #1F1F1F);
  --cv-room-garden: light-dark(#DCEAD2, #17251A);
  --cv-room-patio: light-dark(#EAE6DF, #24211C);
  --cv-room-balcony: light-dark(#E8E4DC, #22201B);
  --cv-room-other: light-dark(#EFEFEF, #1E2023);

  /* ---------- type ---------- */
  --rw-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --rw-font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --rw-text-xs: 11px;     /* status bar, badges */
  --rw-text-sm: 12px;     /* secondary, field labels */
  --rw-text-md: 13px;     /* body, controls */
  --rw-text-lg: 15px;     /* panel and section titles (600) */
  --rw-text-xl: 20px;     /* modal titles (600) */
  --rw-text-2xl: 28px;    /* start dialog headline (600, -0.02em) */
  --rw-leading: 1.45;
  --rw-weight-medium: 500;
  --rw-weight-semibold: 600;

  /* ---------- spacing (4 px grid) ---------- */
  --rw-space-0: 0;
  --rw-space-0-5: 2px;
  --rw-space-1: 4px;
  --rw-space-1-5: 6px;
  --rw-space-2: 8px;
  --rw-space-2-5: 10px;
  --rw-space-3: 12px;
  --rw-space-4: 16px;
  --rw-space-5: 20px;
  --rw-space-6: 24px;
  --rw-space-8: 32px;
  --rw-space-10: 40px;
  --rw-space-12: 48px;
  --rw-space-16: 64px;

  /* ---------- shape ---------- */
  --rw-radius-xs: 4px;
  --rw-radius-sm: 6px;    /* controls */
  --rw-radius-md: 8px;    /* tool buttons, thumbnails */
  --rw-radius-lg: 10px;   /* cards, panels, popovers, floating bars */
  --rw-radius-xl: 14px;   /* modals */
  --rw-radius-full: 999px;
  --rw-radius-control: var(--rw-radius-sm);
  --rw-radius-card: var(--rw-radius-lg);
  --rw-radius-modal: var(--rw-radius-xl);

  /* ---------- sizes ---------- */
  --rw-control-h: 32px;
  --rw-control-h-sm: 28px;
  --rw-control-h-lg: 40px;
  --rw-topbar-h: 52px;
  --rw-rail-w: 56px;
  --rw-drawer-w: 288px;
  --rw-panel-w: 340px;
  --rw-status-h: 30px;
  --rw-bottombar-h: 56px;

  /* ---------- layers ---------- */
  --rw-z-canvas: 1;
  --rw-z-viewport-overlay: 5;
  --rw-z-docked: 10;
  --rw-z-drawer-overlay: 30;
  --rw-z-panel-overlay: 32;
  --rw-z-sheet: 40;
  --rw-z-popover: 1000;
  --rw-z-modal: 2000;
  --rw-z-toast: 3000;
  --rw-z-tooltip: 4000;

  /* ---------- motion (120-180 ms ease-out; none under prefers-reduced-motion) ---------- */
  --rw-dur-1: 120ms;
  --rw-dur-2: 150ms;
  --rw-dur-3: 180ms;
  --rw-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --rw-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Force a scheme (testing, or an in-app appearance setting). */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-reduced-motion: reduce) {
  :root { --rw-dur-1: 0ms; --rw-dur-2: 0ms; --rw-dur-3: 0ms; }
}
