/* =====================================================================
   The Office — "Newsroom" theme (v4): the website's look, inside the office.
   Load LAST of the office's own sheets (tokens, legacy, components, layout,
   glass, then this). The room itself stays pixel art; only what is round it
   changes: the website's eight colours (welcome.css: paper cream, soft ivory,
   cubicle taupe, olive gray, ink navy, walnut, burnt orange, muted plum),
   Fraunces for titles, and two modes.

   Two modes, on <html data-theme>:
     dark  (Night) — the default sheet below: ink-navy chrome and panels,
                     ivory type, burnt-orange actions, lit-olive presence.
     light (Day)   — [data-theme="light"]: paper-cream chrome, ivory panels,
                     ink-navy type, the same burnt orange.
   js/theme-boot.js sets the attribute before the first paint: the person's
   choice (the sun/moon button in the top bar), else the device's setting.

   As in glass.css, some things keep a fill of their own whatever the mode
   ("islands"). Three kinds, each re-pointing --ink and friends:
     accent   — burnt-orange and danger fills: ivory text, both modes
     selected — "on" states: ivory fill with navy text at night, navy fill
                with ivory text by day
     paper    — speech bubbles, tooltips, the whiteboard: light paper, navy text

   Contrast (WCAG 2.2), night: ivory on --surface 12.1:1, taupe (--ink-muted)
   on --surface 7.3:1 and on --surface-2 6.3:1, ivory on --primary 4.8:1,
   orange-soft (--accent-ink) on --surface 7.4:1. Day: navy on ivory 9.7:1,
   --ink-muted on ivory 6.2:1 and on cream 5.8:1, --accent-ink on ivory 6.0:1,
   ivory on navy (--selected) 9.7:1.
   ===================================================================== */

/* ------------------------------------------------------------ Night (dark): the default */
:root {
  /* chrome: the frame round the room */
  --bg: #18222a;
  --bg-raised: rgba(34, 49, 60, 0.96);
  --bg-sunk: rgba(250, 248, 242, 0.05);
  --chrome-text: #faf8f2;      /* 15.4:1 on --bg */
  --chrome-muted: #c8c1b3;     /*  9.4:1 on --bg */
  --chrome-fill: rgba(250, 248, 242, 0.06);
  --chrome-fill-hover: rgba(250, 248, 242, 0.11);
  --chrome-fill-press: rgba(250, 248, 242, 0.16);
  --chrome-line: rgba(200, 193, 179, 0.3);
  --chrome-line-soft: rgba(200, 193, 179, 0.14);

  /* panels */
  --surface: #22313c;          /* the website's night navy */
  --surface-2: #2a3b48;
  --surface-3: #34485a;
  --surface-input: #1b2730;
  --ink: #faf8f2;
  --ink-muted: #c8c1b3;
  --ink-placeholder: #a39c8e;  /* 5.3:1 on --surface-input */
  --ink-on-dark: #faf8f2;
  --line: rgba(200, 193, 179, 0.18);

  /* brand & action: burnt orange, as on the site */
  --primary: #b9532b;          /* ivory on it 4.8:1 */
  --primary-hover: #c8633a;
  --primary-press: #9e4523;
  --on-primary: #faf8f2;
  --accent-ink: #f2b48f;       /* burnt orange on navy (the site's --orange-soft) */
  --selected: #faf8f2;         /* "on": ivory, navy text */
  --on-selected: #22313c;
  --selected-edge: rgba(34, 49, 60, 0.25);
  --gold-ink: #e3c49a;         /* the admin's crown: walnut, lit */
  --rose-ink: #b9532b;         /* unread badges: ivory text 4.8:1 */
  --sage: #a3ae84;             /* people count: navy text 5.8:1 */
  --sky: #a9bdd0;
  --head: 'Riyal', 'Fraunces', 'Rubik', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* feedback */
  --success: #b9c49a;
  --success-soft: rgba(163, 174, 132, 0.16);
  --warning: #e3c49a;
  --warning-soft: rgba(227, 196, 154, 0.14);
  --danger: #ef8a7e;           /* as text on panels */
  --danger-soft: rgba(239, 138, 126, 0.15);
  --danger-fill: #b3363c;      /* as a fill: ivory text 5.7:1 */
  --live: #e0625a;

  /* characters */
  --yazan: #a9bdd0;
  --yazan-soft: rgba(169, 189, 208, 0.14);
  --habib: #b9c49a;
  --habib-soft: rgba(163, 174, 132, 0.15);

  /* presence: lit olive, as on the site */
  --here: #a3ae84;
  --idle: #e3c49a;
  --away: #8a8d7a;

  /* focus */
  --focus: #f2b48f;
  --focus-on-dark: #f2b48f;

  /* depth: navy-tinted, and the site's offset card shadow */
  --sh-1: 0 1px 2px rgba(8, 14, 18, 0.35);
  --sh-2: 0 12px 30px -10px rgba(8, 14, 18, 0.55);
  --sh-3: 0 16px 40px -12px rgba(8, 14, 18, 0.65);
  --sh-4: 0 30px 70px -20px rgba(8, 14, 18, 0.75);
  --offset: 4px 4px 0 #111a20;
  --scrim: rgba(17, 26, 32, 0.62);
  --glass: rgba(34, 49, 60, 0.92);
  --edge: 1px solid rgba(200, 193, 179, 0.18);
  --edge-soft: 1px solid rgba(200, 193, 179, 0.1);
  --field-edge: rgba(200, 193, 179, 0.3);

  color-scheme: dark;
}

/* ------------------------------------------------------------ Day (light) */
:root[data-theme="light"] {
  --bg: #f3f0e7;               /* paper cream */
  --bg-raised: rgba(250, 248, 242, 0.97);
  --bg-sunk: #e9e4d8;
  --chrome-text: #2f4352;      /* ink navy, 9.0:1 on cream */
  --chrome-muted: #5c5f4f;     /* 5.8:1 on cream, 5.1:1 on --bg-sunk */
  --chrome-fill: rgba(47, 67, 82, 0.04);
  --chrome-fill-hover: rgba(47, 67, 82, 0.08);
  --chrome-fill-press: rgba(47, 67, 82, 0.13);
  --chrome-line: #a39c8e;      /* 3.0:1 on cream: a control's edge */
  --chrome-line-soft: #ddd7ca;

  --surface: #faf8f2;          /* soft ivory */
  --surface-2: #f3f0e7;        /* paper cream */
  --surface-3: #e9e4d8;
  --surface-input: #fffdf8;
  --ink: #2f4352;
  --ink-muted: #5c5f4f;
  --ink-placeholder: #6b6e5d;  /* 5.0:1 on --surface-input */
  --ink-on-dark: #faf8f2;
  --line: #ddd7ca;

  --primary: #b9532b;
  --primary-hover: #a84a26;
  --primary-press: #9e4523;
  --on-primary: #faf8f2;
  --accent-ink: #9e4523;       /* burnt orange as text on ivory */
  --selected: #2f4352;         /* "on": ink navy, ivory text */
  --on-selected: #faf8f2;
  --selected-edge: rgba(17, 26, 32, 0.3);
  --gold-ink: #6b4c37;         /* walnut */
  --rose-ink: #b9532b;
  --sage: #a3ae84;
  --sky: #46586a;

  --success: #4d5240;
  --success-soft: #e2e5d3;
  --warning: #7a4a10;
  --warning-soft: #f4ead6;
  --danger: #a3363c;
  --danger-soft: #f6e1dd;
  --danger-fill: #a3363c;
  --live: #b3363c;

  --yazan: #34487a;
  --yazan-soft: #e3e8ef;
  --habib: #4d5240;
  --habib-soft: #e2e5d3;

  --here: #6e7d4a;             /* 4.3:1 on ivory: a dot, always with its shape */
  --idle: #b07a24;
  --away: #a39c8e;

  --focus: #b9532b;
  --focus-on-dark: #b9532b;

  --sh-1: 0 1px 2px rgba(34, 49, 60, 0.08);
  --sh-2: 0 1px 2px rgba(34, 49, 60, 0.05), 0 10px 24px -12px rgba(34, 49, 60, 0.22);
  --sh-3: 0 2px 4px rgba(34, 49, 60, 0.06), 0 22px 40px -20px rgba(34, 49, 60, 0.32);
  --sh-4: 0 6px 10px rgba(34, 49, 60, 0.08), 0 40px 80px -30px rgba(34, 49, 60, 0.45);
  --offset: 4px 4px 0 #c8c1b3;  /* cubicle taupe, as on the site's cards */
  --scrim: rgba(34, 49, 60, 0.42);
  --glass: rgba(250, 248, 242, 0.94);
  --edge: 1px solid #c8c1b3;
  --edge-soft: 1px solid #ddd7ca;
  --field-edge: #a39c8e;

  color-scheme: light;
}

/* Fraunces is Latin only: an Arabic office keeps Rubik for titles */
:root:lang(ar) { --head: var(--font); }

/* ------------------------------------------------------------ islands */
/* accent: burnt orange and danger fills, ivory text in both modes */
.btn.primary, .btn.danger, .btn.send, .btn.mic[aria-pressed="true"], .chat-form .btn.mic[aria-pressed="true"],
.icon-btn.danger, .icon-btn.accent, .dock .tool.on-air, .msg.mine .text, .live-pill, .faces-self-hidden, .face-you,
.voice-note .play {
  --ink: #faf8f2;
  --ink-muted: rgba(250, 248, 242, 0.86);
  --accent-ink: #faf8f2;
  color: #faf8f2;
}
/* the edit field sits inside your own (orange) bubble: the bubble turns --ink ivory but still hands the field a
   cream --surface-input, so its text must be ink navy, in both modes */
.msg.mine .msg-edit { --ink: #2f4352; --ink-placeholder: #6b6e5d; color: #2f4352; background: #fffdf8; }
.btn.danger, .icon-btn.danger, .dock .tool.on-air, .btn.mic[aria-pressed="true"], .chat-form .btn.mic[aria-pressed="true"],
.live-pill, .faces-self-hidden, .face-you, .meeting-bar .rec-chip { background: var(--danger-fill); border-color: transparent; }

/* selected: "on" states */
.btn.on, .btn[aria-pressed="true"], .icon-btn.on, .icon-btn[aria-pressed="true"],
.tool.on, .tool[aria-pressed="true"], .tool[aria-expanded="true"],
.tab-item[aria-current] .tab-ic, .tab-item.on .tab-ic, .tab-item[aria-expanded="true"] .tab-ic,
.room-tab[aria-current], .room-tab.on,
.seg > [aria-checked="true"], .seg > [aria-pressed="true"], .seg > [aria-selected="true"], .seg > .on,
.chip[aria-pressed="true"], .chip[aria-checked="true"], .chip.on, .klanes .chip[aria-selected="true"],
.list-row[aria-checked="true"], .gesture-grid .g[aria-pressed="true"], .tray-items button[aria-pressed="true"],
.datepick-day.chosen, .datepick.open .datepick-btn, .cam-split.on .cam-pick, .faces-ctl[aria-pressed="true"],
.cr-step[aria-current="step"] .cr-step-num, .cr-body[aria-checked="true"], .cr-tile[aria-checked="true"] {
  --ink: var(--on-selected);
  --ink-muted: var(--on-selected);
  --accent-ink: var(--on-selected);
  --gold-ink: var(--on-selected);
  color: var(--on-selected);
}
.room-tab[aria-current], .room-tab.on { background: var(--selected); box-shadow: var(--sh-1); }
.room-tab[aria-current] .room-count, .room-tab.on .room-count { background: var(--here); color: #22313c; }
.cr-step[aria-current="step"] .cr-step-num, .cr-body[aria-checked="true"], .cr-tile[aria-checked="true"] { border-color: var(--selected); }
@media (hover: hover) { .cr-tile[aria-checked="true"]:hover { border-color: var(--selected); } }
.switch input:checked::after { background: var(--on-selected); }

/* paper: light paper, navy text, in both modes */
.paper, .bubble, .uno-table, .uno-name, .wb-canvas, canvas.qr, .tooltip, .badge.dark, .bg-pick .px {
  --ink: #2f4352;
  --ink-muted: #5c5f4f;
  --ink-placeholder: #6b6e5d;
  --accent-ink: #9e4523;
  --gold-ink: #6b4c37;
  --warning: #7a4a10;
  --success: #4d5240;
  --danger: #a3363c;
  --surface: #faf8f2;
  --surface-2: #f3f0e7;
  --surface-3: #e9e4d8;
  --surface-input: #fffdf8;
  --edge: 1px solid #c8c1b3;
  --field-edge: #a39c8e;
}
.tooltip, .badge.dark { background: #faf8f2; color: #2f4352; border: 1px solid #c8c1b3; }
:root[data-theme="light"] :is(.tooltip, .badge.dark) { background: #2f4352; color: #faf8f2; border-color: transparent; }
.tooltip kbd { background: rgba(47, 67, 82, 0.1); }
:root[data-theme="light"] .tooltip kbd { background: rgba(250, 248, 242, 0.18); }

/* "You" keeps the app's coral, in both modes */
.tag.me { --ink: #2b1a14; background: #ff7a59; color: #2b1a14; }

/* Yazan's question bubble: navy at night is the panel, so his own blue */
.yp-q { --ink: #faf8f2; background: #34487a; color: #faf8f2; }

/* ------------------------------------------------------------ type: Fraunces for titles */
.dialog-head h2, .decor-head h2, .office-btn .office-name, .chat-title, .menu-head strong, .faces-head h2 {
  font-family: var(--head);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.office-btn { font-family: var(--head); font-size: 1.1875rem; font-weight: 600; }
.dialog-head h2 { font-size: 1.5rem; }
:root:lang(ar) .dialog-head h2 { font-size: var(--fs-h2); font-weight: var(--fw-bold); }
:root:lang(ar) .office-btn { font-size: 1.0625rem; font-weight: var(--fw-heavy); }

/* ------------------------------------------------------------ the frame round the room */
.btn { background: var(--surface-2); color: var(--ink); }
@media (hover: hover) { .btn:hover { background: var(--surface-3); } }
.btn.primary { background: var(--primary); box-shadow: 0 2px 0 var(--primary-press); }
@media (hover: hover) { .btn.primary:hover { background: var(--primary-hover); } }
.btn.on, .btn[aria-pressed="true"] { background: var(--selected); }
.btn.ghost { background: transparent; }
.icon-btn.accent { background: var(--primary); box-shadow: 0 2px 0 var(--primary-press); }
@media (hover: hover) { .icon-btn.accent:hover { background: var(--primary-hover); } }
.icon-btn.on, .icon-btn[aria-pressed="true"] { background: var(--selected); border-color: transparent; }

.rooms { border-color: var(--chrome-line-soft); }
#room { box-shadow: 0 0 0 1px rgba(200, 193, 179, 0.12), var(--offset), 0 24px 60px -20px rgba(8, 14, 18, 0.55); }
.dock { border-color: var(--chrome-line-soft); background: var(--glass); box-shadow: var(--sh-3); }
.chat { border: var(--edge); background: var(--surface); box-shadow: var(--offset); }
.chat-form { border-color: var(--chrome-line-soft); }
.here-row { background: var(--success-soft); }
.msg .text { background: var(--surface-2); }
.msg.mine .text { background: var(--primary); }
.banner, .banner.offline, .banner.live { border-color: var(--chrome-line-soft); }
.banner .px { color: var(--accent-ink); }
.desk-style.on { border-color: var(--primary); background: rgba(185, 83, 43, 0.14); }
.meeting-now { background: rgba(185, 83, 43, 0.14); }
.joy { border-color: rgba(250, 248, 242, 0.32); background: rgba(24, 34, 42, 0.45); }
.kcard .kopen:hover { background: transparent; }

/* panels and cards: the site's offset shadow under every sheet of paper */
.card, .popover, .menu, .habib-panel, .yazan-panel { box-shadow: var(--offset), var(--sh-4); }
.toast { box-shadow: var(--offset), var(--sh-3); }

/* task cards: index cards on the board */
.kcol { background: var(--surface-2); border: var(--edge-soft); }
/* (glass.css made them a light island; here they follow the mode, so their tokens are spelled out per mode) */
.kcard {
  --ink: #faf8f2; --ink-muted: #c8c1b3; --ink-placeholder: #a39c8e; --accent-ink: #f2b48f;
  --gold-ink: #e3c49a; --warning: #e3c49a; --success: #b9c49a; --danger: #ef8a7e;
  --surface: #22313c; --surface-2: #2a3b48; --surface-3: #3d5266; --surface-input: #1b2730;
  --edge: 1px solid rgba(200, 193, 179, 0.22); --field-edge: rgba(200, 193, 179, 0.3);
  border: var(--edge); background: #34485a; color: var(--ink);
  box-shadow: 2px 2px 0 rgba(8, 14, 18, 0.45);
}
.board-cu .kcard { background: #34485a; }

/* ------------------------------------------------------------ Day: what glass.css drew for a dark page only */
:root[data-theme="light"] .kcard {
  --ink: #2f4352; --ink-muted: #5c5f4f; --ink-placeholder: #6b6e5d; --accent-ink: #9e4523;
  --gold-ink: #6b4c37; --warning: #7a4a10; --success: #4d5240; --danger: #a3363c;
  --surface: #faf8f2; --surface-2: #f3f0e7; --surface-3: #e9e4d8; --surface-input: #fffdf8;
  --edge: 1px solid #c8c1b3; --field-edge: #a39c8e;
  background: #fffdf8; box-shadow: 2px 2px 0 #c8c1b3;
}
:root[data-theme="light"] .board-cu .kcard { background: #fffdf8; }
:root[data-theme="light"] .kcol { background: var(--surface-2); }
:root[data-theme="light"] .room-tab[aria-current], :root[data-theme="light"] .room-tab.on { box-shadow: 0 1px 2px rgba(34, 49, 60, 0.18); }
:root[data-theme="light"] .tag { -webkit-backdrop-filter: none; backdrop-filter: none; }
:root[data-theme="light"] .avatar { box-shadow: 0 0 0 2px #ddd7ca; }
:root[data-theme="light"] .here-who .avatar, :root[data-theme="light"] .here-row .avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
:root[data-theme="light"] #room { box-shadow: var(--offset); }
:root[data-theme="light"] .joy { border-color: rgba(47, 67, 82, 0.3); background: rgba(250, 248, 242, 0.55); }
:root[data-theme="light"] .joy-knob { background: #2f4352; }
:root[data-theme="light"] .float-btn, :root[data-theme="light"] .float-pill { border-color: #c8c1b3; color: var(--chrome-text); }
:root[data-theme="light"] .banner, :root[data-theme="light"] .banner.offline, :root[data-theme="light"] .banner.live { border-color: #c8c1b3; }
:root[data-theme="light"] .chat-form .btn.mic:not([aria-pressed="true"]) { color: var(--chrome-muted); }
:root[data-theme="light"] .switch input::after { background: #faf8f2; box-shadow: 0 1px 2px rgba(34, 49, 60, 0.3); }
:root[data-theme="light"] .switch input { background: #ddd7ca; }
:root[data-theme="light"] .switch input:checked { background: var(--selected); }
:root[data-theme="light"] .yp-offer, :root[data-theme="light"] .yp-ask { border-color: #c3ccd8; }
:root[data-theme="light"] .yp-desk { border-color: #d3dae3; }
:root[data-theme="light"] .yp-task.flagged { border-color: #e0c48f; }

/* ------------------------------------------------------------ the mode button (top bar) */
.theme-btn .px { width: 20px; height: 20px; }
.theme-btn .ic-sun { display: none; }
:root[data-theme="dark"] .theme-btn .ic-moon, :root:not([data-theme]) .theme-btn .ic-moon { display: none; }
:root[data-theme="dark"] .theme-btn .ic-sun, :root:not([data-theme]) .theme-btn .ic-sun { display: block; }

/* the office's own logo: the wordmark made for each mode */
.office-logo.for-light { display: none; }
:root[data-theme="light"] .office-logo.for-dark { display: none; }
:root[data-theme="light"] .office-logo.for-light { display: block; }

@media (prefers-reduced-motion: no-preference) {
  /* the switch between modes eases rather than flashes */
  :root.theme-easing, :root.theme-easing * {
    transition: background-color 220ms ease, border-color 220ms ease, color 220ms ease, fill 220ms ease !important;
  }
}
