/* =====================================================================
   The Office — app layout (v2). Load order: tokens.css, components.css, layout.css.
   Three zones: where you are (top bar), what you do (dock / bottom bar),
   who you talk to (chat column / chat sheet). ui.js keeps adding the same
   state classes it adds: .phone .landscape .chat-open .sheet-up (the chat or the tray is out) .decor .typing
   (not .sheet: that is the bottom-sheet component)
   ===================================================================== */

/* Rubik, self-hosted (SIL Open Font License). Subset files: latin + arabic, variable weight 400–800. */
@font-face {
  font-family: 'Rubik';
  src: url('/fonts/rubik-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Rubik';
  src: url('/fonts/rubik-arabic.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

body {
  background: var(--bg);
  background-image: radial-gradient(ellipse at 40% 28%, #333a47 0%, var(--bg) 62%);
}

/* ------------------------------------------------------------ desktop and tablet: top bar over two columns */
.app {
  display: grid;
  height: 100dvh;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-w);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top" "stage side";
  padding-inline: var(--safe-l) var(--safe-r);
}
.app > .topbar { grid-area: top; }
.app > .stage { grid-area: stage; }
.app > .side { grid-area: side; }
.app > .bottom-bar { display: none; }

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* the room and its dock sit together in the middle of what is left */
  gap: var(--s-3);
  min-width: 0;
  min-height: 0;
  padding: var(--s-1) var(--s-3) var(--s-3) var(--s-4);
}
.room-wrap { position: relative; flex: none; line-height: 0; touch-action: manipulation; }
#room { display: block; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; }
.overlay { position: absolute; inset: 0; pointer-events: none; line-height: 1.3; }
.stage-top { display: contents; }
.stage .meeting-bar, .stage .pa-bar { align-self: stretch; max-width: 100%; flex: none; }
.stage .dock { flex: none; max-width: 100%; }
#room { cursor: pointer; }
.stage .banner { position: absolute; top: var(--s-3); left: 50%; transform: translateX(-50%); z-index: var(--z-room-ui); max-width: calc(100% - 24px); }
.habib-status { position: absolute; inset-inline-start: var(--s-2); bottom: var(--s-2); z-index: var(--z-room-ui); }
.habib-panel, .yazan-panel { position: absolute; z-index: var(--z-room-ui); }
.yazan-panel { inset-inline-end: var(--s-2); bottom: var(--s-2); max-height: calc(100% - 16px); }

.side { display: flex; flex-direction: column; gap: var(--s-2); min-height: 0; padding: 0 var(--s-3) var(--s-3) 0; padding-inline: 0 var(--s-3); }
.side .chat, .side .decor-bar { flex: 1; min-height: 0; }
.app.decor .side .chat { display: none; }
.app:not(.phone) .phone-only { display: none !important; }
.tablet-chat-btn { display: none; }
#people-pill:empty { display: none; }

/* notices land over the room, clear of the chat column */
@media (min-width: 1024px) { .app:not(.phone) ~ .toasts { inset-inline-end: var(--sidebar-w); } }

/* the room scales by whole numbers when it can (render.js picks the factor); the frame stays crisp */
@media (min-width: 1760px) and (min-height: 1000px) { :root { --sidebar-w: 400px; } }

/* tablet: chat becomes a side sheet you open, the room gets the width */
@media (max-width: 1023px) and (min-width: 700px) {
  .app:not(.phone) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "stage"; }
  .app:not(.phone) > .side {
    position: fixed; inset-block: calc(var(--topbar-h) + var(--safe-t)) 0; inset-inline-end: 0;
    z-index: var(--z-popover); width: min(380px, 92vw); padding: var(--s-2);
    transform: translateX(105%); transition: transform var(--dur-slow) var(--ease-out);
  }
  [dir="rtl"] .app:not(.phone) > .side { transform: translateX(-105%); }
  .app:not(.phone).chat-open > .side, .app:not(.phone).decor > .side { transform: none; }
  .app:not(.phone) .tablet-chat-btn { display: inline-flex; }
  .app:not(.phone) .dock .tool .label { display: none; }
  .app:not(.phone) .me-pill .me-text { display: none; }
  .app:not(.phone) .me-pill { padding-inline-end: var(--s-1); }
}
/* a narrow desktop window: the voice buttons keep their icons, the dock keeps its words */
@media (max-width: 1180px) and (min-width: 700px) {
  .app:not(.phone) .voice-tools .icon-btn:not(#btn-voice) .label { display: none; }
  .app:not(.phone) .voice-tools .icon-btn:not(#btn-voice):not(.mic-pick):not(.cam-pick) { padding: 0; width: var(--ctl-h); }
}

/* ------------------------------------------------------------ phone: room fills, bars top and bottom */
.app.phone {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top" "stage" "bar";
}
.app.phone > .bottom-bar { display: grid; grid-area: bar; }
.app.phone .dock, .app.phone .clock-split { display: none; } /* (on a phone: Me → Clock in) */
/* the office menu on a phone: its icon at the top left */
.app.phone .office-btn { flex: none; width: var(--tap); height: var(--tap); padding: 0; justify-content: center; }
.app.phone .office-btn .office-name, .app.phone .office-btn > .px { display: none; }
.app.phone .office-btn .office-ic { display: inline-flex; }
.app.phone .topbar { gap: var(--s-2); padding: calc(var(--s-1) + var(--safe-t)) var(--s-3) var(--s-1); min-height: 52px; }
.app.phone .rooms { flex: 1; }
.app.phone .topbar .spacer { display: none; }
.app.phone .voice-tools .icon-btn { width: var(--tap); height: var(--tap); padding: 0; }
.app.phone .voice-tools .label, .app.phone .voice-count { display: none; }
/* the sign that it is listening for Habib or Yazan stays, even where the voice count goes */
.app .voice-tools .name-ear:not([hidden]) { display: inline-block; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rooms.more-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
[dir="rtl"] .rooms.more-r { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent); }

.app.phone .stage { display: block; padding: 0; overflow: hidden; }
/* clipped, and never scrolled: the name tags and the panels inside it are placed in its own coordinates */
.app.phone .room-wrap { position: absolute; inset: 0; overflow: hidden; overflow: clip; }
.app.phone .stage-top { position: absolute; z-index: var(--z-room-ui); top: var(--s-3); inset-inline: var(--s-3) 64px; display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); pointer-events: none; }
.app.phone .stage-top > * { pointer-events: auto; max-width: 100%; }
.app.phone #btn-zoom { position: absolute; z-index: var(--z-room-ui); top: var(--s-3); inset-inline-end: var(--s-3); }
.app.phone .habib-status { position: static; }
.app.phone .habib-panel, .app.phone .yazan-panel { inset-inline: var(--s-2); bottom: var(--s-2); width: auto; max-height: min(70%, 460px); }

/* over the bottom of the room: the message peek on the start side, the joystick on the end side */
.app.phone .side {
  grid-area: stage; z-index: var(--z-chrome);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: var(--s-2) var(--s-3) var(--s-3); pointer-events: none;
}
.app.phone .pad { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-2); pointer-events: none; }
.app.phone .pad > * { pointer-events: auto; }
.app.phone .pad .joy { margin-inline-start: auto; }
.app.phone .chat, .app.phone .decor-bar { display: none; }
.app.phone.chat-open .chat,
.app.phone.decor .decor-bar {
  display: flex; position: fixed; inset-inline: 0; bottom: calc(var(--bottombar-h) + var(--safe-b));
  height: min(520px, 62dvh); z-index: var(--z-modal);
  border-radius: 20px 20px 0 0; border-bottom: 0; box-shadow: var(--sh-4);
  pointer-events: auto; animation: sheet-in var(--dur-slow) var(--ease-out);
}
.app.phone.decor > .bottom-bar { display: none; }
.app.phone.decor .decor-bar { bottom: 0; padding-bottom: var(--safe-b); height: min(380px, 46dvh); } /* arranging: the room needs to show */
.app.phone.chat-open .pad .joy, .app.phone.decor .pad, .app.phone.typing .joy { visibility: hidden; }
/* asking Yazan or one of the AI team on a phone: the panel's Ask button sits where the joystick is */
.app.phone:has(#yazan-panel:not([hidden])) .joy, .app.phone:has(#agent-panel:not([hidden])) .joy { visibility: hidden; }
/* a dialog on a phone is a sheet from the bottom */
.app.phone ~ .modal { align-items: flex-end; padding: var(--safe-t) 0 0; }
.app.phone ~ .modal .card { width: 100%; max-height: 92dvh; border-bottom: 0; border-radius: 20px 20px 0 0; padding-bottom: var(--safe-b); animation: sheet-in var(--dur-slow) var(--ease-out); }
.app.phone ~ .modal .card:not(.dialog) { padding-bottom: calc(var(--s-5) + var(--safe-b)); }
.app.phone ~ .toasts { top: calc(var(--topbar-h) + var(--safe-t) + 60px); }
.app.phone .bottom-bar .badge { min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; font-size: 11px; }
.peek { display: flex; align-items: center; gap: var(--s-2); max-width: min(240px, 60vw); padding: 6px var(--s-3) 6px 6px; border: var(--edge); border-radius: 16px 16px 16px 4px; background: var(--surface-input); color: var(--ink); box-shadow: var(--sh-2); font-size: var(--fs-small); font-weight: var(--fw-semibold); line-height: 1.25; text-align: start; }

/* phone on its side: one top row, the bar becomes a rail on the end side, joystick on the start side */
.app.phone.landscape {
  grid-template-columns: minmax(0, 1fr) 76px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top" "stage bar";
}
.app.phone.landscape > .bottom-bar { grid-template-columns: none; grid-template-rows: repeat(5, minmax(0, 1fr)); border-top: 0; border-inline-start: 1px solid var(--chrome-line-soft); padding: 0 var(--safe-r) var(--safe-b) 0; }
.app.phone.landscape .tab-item { min-height: 0; }
.app.phone.landscape .pad .joy { margin-inline-start: 0; margin-inline-end: auto; }
.app.phone.landscape .pad .peek { order: 2; margin-inline-start: auto; }
.app.phone.landscape.chat-open .chat { inset-inline: auto calc(76px + var(--safe-r)); bottom: 0; top: 52px; height: auto; width: min(360px, 48vw); border-radius: 16px 0 0 0; }

/* ------------------------------------------------------------ embedded as a Discord Activity (main.js marks the body)
   The office button stays: on a computer it is the only way to the office menu. */
.in-discord .app .dock .tool .label { display: none; }
.in-discord .app .topbar { min-height: 48px; }

/* the faces panel: beside the room, on the inline end of the stage. The room
   gets what is left (ui.layout() reads the padding), so nothing is covered:
   not the room, not the dock, not the voice buttons. */
.stage { --faces-w: 360px; }
.stage.with-faces { padding-inline-end: calc(var(--faces-w) + var(--s-3) * 2); }
.stage.with-faces:has(.faces.sharing) { --faces-w: 240px; }
@media (max-width: 1180px) { .stage { --faces-w: 280px; } }
.app:not(.phone) .faces {
  position: absolute; z-index: var(--z-room-ui);
  top: var(--faces-top, var(--s-1)); bottom: var(--faces-bottom, var(--s-3));
  inset-inline-end: var(--s-3); width: var(--faces-w);
}
.app:not(.phone) .stage.faces-full .faces { inset-inline-start: var(--s-4); width: auto; }
.app:not(.phone) .stage.faces-full #room-wrap { visibility: hidden; }

/* a computer: the faces take the chat's column, which grows to give them
   room (wider still with "Make the faces bigger"); the chat is a press away */
@media (min-width: 1024px) {
  .app:not(.phone).faces-side { --sidebar-w: clamp(380px, 34vw, 640px); }
  .app:not(.phone).faces-side.faces-wide { --sidebar-w: clamp(480px, 52vw, 1100px); }
  .app:not(.phone).faces-side > .side .chat { display: none; }
  .app:not(.phone).faces-side > .side .faces { position: static; flex: 1; min-height: 0; width: auto; }
}

/* someone's shared screen, in the room's place (placed by ui.placeShareStage) */
.share-stage {
  position: absolute; z-index: var(--z-room-ui);
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--r-lg); background: #0e1014; box-shadow: var(--sh-2);
}
.share-stage[hidden] { display: none; }
.stage.share-up #room-wrap, .stage.share-up .dock { visibility: hidden; }
.share-stage-video { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #0e1014; }
.share-stage-bar {
  position: absolute; inset-inline: 0; top: 0; display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2); pointer-events: none;
}
.share-stage-bar > * { pointer-events: auto; }
.share-stage-bar .spacer { flex: 1; pointer-events: none; }
.share-stage-who { padding: 4px var(--s-3); border-radius: var(--r-pill); background: rgba(28, 32, 38, 0.85); color: var(--chrome-text); font-size: var(--fs-small); font-weight: var(--fw-semibold); }
.share-stage-btn {
  display: inline-flex; align-items: center; gap: var(--s-2); height: var(--ctl-h); padding: 0 var(--s-3);
  border: 1px solid var(--chrome-line); border-radius: var(--r-sm); background: rgba(28, 32, 38, 0.85); color: var(--chrome-text);
  font: inherit; font-size: var(--fs-small); font-weight: var(--fw-semibold);
}
.share-stage-btn[hidden] { display: none; }
@media (hover: hover) { .share-stage-btn:hover { background: var(--bg-raised); } }
.share-stage-btn:focus-visible { outline: var(--focus-width) solid var(--focus-on-dark); outline-offset: var(--focus-offset); }
/* the controls fade while you watch, and come back on a move or a focus */
@media (hover: hover) {
  .share-stage .share-stage-bar { opacity: 0.35; transition: opacity var(--dur-base) var(--ease-out); }
  .share-stage:hover .share-stage-bar, .share-stage:focus-within .share-stage-bar { opacity: 1; }
}

/* expanded: the shared screen gets the whole stage (no meeting bar, no
   dock); on a computer the stage runs the full height on the left, and the
   top bar moves over the right-hand column with only the voice buttons, as
   icons, above the faces. Never the browser's full screen. */
.app.theater .stage { padding: var(--s-2); }
.app.theater .stage-top > :not(#faces), .app.theater .stage > .dock, .app.theater .banner { display: none !important; }
.app.theater .share-stage { border-radius: var(--r-md); }
@media (min-width: 1024px) {
  .app:not(.phone).theater { grid-template-areas: "stage top" "stage side"; }
  .app:not(.phone).theater > .topbar { padding-inline: 0 var(--s-3); gap: var(--s-2); }
  .app:not(.phone).theater .office-btn, .app:not(.phone).theater .rooms, .app:not(.phone).theater .clock-split,
  .app:not(.phone).theater .topbar .spacer, .app:not(.phone).theater .voice-count, .app:not(.phone).theater .tablet-chat-btn { display: none; }
  .app:not(.phone).theater .voice-tools { flex: 1; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-1); }
  .app:not(.phone).theater .voice-tools .icon-btn:not(#btn-voice) .label { display: none; }
  .app:not(.phone).theater .voice-tools .icon-btn:not(#btn-voice):not(.cam-pick):not(.mic-pick) { padding: 0; width: var(--ctl-h); }
}

/* a phone: a strip of faces over the top of the room, swiped sideways */
.app.phone .faces {
  flex-direction: row; gap: var(--s-2); padding: var(--s-1); max-width: 100%;
  overflow-x: auto; overflow-y: hidden; background: rgba(28, 32, 38, 0.72); border-radius: var(--r-md);
}
.app.phone .faces-head, .app.phone .faces-sub, .app.phone .faces-chips, .app.phone .faces-self-hidden { display: none; }
.app.phone .faces-grid { display: flex; gap: var(--s-1); }
.app.phone .face-tile { width: 112px; flex: none; }
.app.phone .face-acts, .app.phone .face-you { display: none; }
.app.phone .faces-note.on { position: absolute; margin: 0; top: 100%; inset-inline-start: 0; }
