/*
  Front desk demo.
  Colours, type sizes, radii and shadows follow Magic's design tokens
  (Admin/src/design-system/tokens.css). No font files are bundled: the display
  face falls back to a system serif where Magic's own is not installed.

  The idea: a front desk before dawn. The call side is Prussian night with a
  dawn glow rising behind the Call button; the board is the paper ledger
  beside it.
*/

:root {
  color-scheme: light dark;

  --prussian: #052b42;
  --cerulean: #1c3792;
  --sky: #a7c5f1;
  --cream: #fbeed5;
  --horizon: #ffb786;
  --dawn: #e3520c;
  --ink: #050607;
  --graphite: #14181c;
  --paper: #ffffff;

  --text: #050607;
  --text-2: #68757f;
  --page: #f4f6f7;
  --card: #ffffff;
  --line: #e6eaed;
  --line-2: #ccd3d8;

  --success: #1e7a54;
  --success-soft: #e4f2ec;
  --warning: #b7791f;
  --warning-soft: #fdf3dc;
  --danger: #c0341a;
  --danger-soft: #fcebe1;
  --info: #1c3792;
  --info-soft: #e8ecf9;
  --neutral-soft: #e6eaed;

  --on-night: #ffffff;
  --on-night-2: rgb(255 255 255 / 0.66);
  --on-night-line: rgb(255 255 255 / 0.14);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --shadow-xs: 0 1px 2px rgb(5 43 66 / 0.06);
  --shadow-md: 0 8px 24px rgb(5 43 66 / 0.09);
  --shadow-glow: 0 8px 32px rgb(227 82 12 / 0.34);
  --focus: #a7c5f1;

  --font-display: "Advercase", ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-text: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #ffffff;
    --text-2: rgb(255 255 255 / 0.62);
    --page: #0b0e11;
    --card: #14181c;
    --line: rgb(255 255 255 / 0.08);
    --line-2: rgb(255 255 255 / 0.14);
    --success: #6fcfa4;
    --success-soft: rgb(30 122 84 / 0.22);
    --warning: #e8b45c;
    --warning-soft: rgb(183 121 31 / 0.22);
    --danger: #ff8a6e;
    --danger-soft: rgb(192 52 26 / 0.24);
    --info: #a7c5f1;
    --info-soft: rgb(28 55 146 / 0.3);
    --neutral-soft: rgb(255 255 255 / 0.08);
    --shadow-xs: none;
    --shadow-md: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[hidden] { display: none !important; }

h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--on-night-2);
}

/* ---- The night side: shared by the lock screen and the call panel -------- */

.lock, .desk {
  position: relative;
  isolation: isolate;
  color: var(--on-night);
  background:
    radial-gradient(120% 56% at 50% 118%, rgb(227 82 12 / 0.62) 0%, rgb(255 183 134 / 0.2) 36%, rgb(255 183 134 / 0) 64%),
    radial-gradient(70% 40% at 12% -6%, rgb(28 55 146 / 0.55) 0%, rgb(28 55 146 / 0) 70%),
    linear-gradient(180deg, #031c2c 0%, var(--prussian) 52%, #0a3552 100%);
}

/* A little grain, so the gradients read as light and not as a screen. */
.lock::before, .desk::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.16;
  mix-blend-mode: soft-light;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
}

/* ---- Lock screen --------------------------------------------------------- */

.lock {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.lock-card {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.lock-card h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(30px, 7vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.lede { color: var(--on-night-2); font-size: 17px; }

.code-row { display: flex; gap: 8px; margin-top: 10px; }

.code-row input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--on-night-line);
  border-radius: var(--radius-md);
  background: rgb(255 255 255 / 0.08);
  color: var(--on-night);
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 0.18em;
}
.code-row input::placeholder {
  color: rgb(255 255 255 / 0.42);
  font-family: var(--font-text);
  letter-spacing: 0;
  font-size: 15px;
}

.code-row button {
  height: 52px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--dawn);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-glow);
  transition: transform 0.15s ease, filter 0.15s ease;
}
.code-row button:hover { filter: brightness(1.08); }
.code-row button:active { transform: translateY(1px); }
.code-row button:disabled { opacity: 0.6; }

.lock-error { color: var(--horizon); font-size: 15px; }

/* ---- Layout -------------------------------------------------------------- */

/* One column on a phone: the call panel is as tall as its content and the board follows. */
.app { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr; align-content: start; }

.desk {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 36px 24px 22px;
  text-align: center;
}

.board { padding: 28px 20px 48px; }

@media (min-width: 900px) {
  .app { grid-template-columns: minmax(380px, 5fr) 6fr; }
  .desk {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    padding: 48px 40px 26px;
    gap: 24px;
  }
  .board { padding: 48px 44px 64px; }
}

/* ---- The call panel ------------------------------------------------------ */

.desk-head { display: grid; gap: 10px; animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }

.desk-head h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(30px, 5.4vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.dial {
  display: grid;
  justify-items: center;
  gap: 14px;
  margin-top: 8px;
  animation: rise 0.7s 0.08s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.call {
  --level: 0;
  position: relative;
  width: 148px;
  height: 148px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #ff7a36 0%, var(--dawn) 58%, #c2440a 100%);
  color: #fff;
  box-shadow: var(--shadow-glow), inset 0 1px 0 rgb(255 255 255 / 0.28);
  transition: transform 0.18s ease, background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
.call:hover:not(:disabled) { transform: scale(1.03); }
.call:active:not(:disabled) { transform: scale(0.98); }
.call:disabled { filter: saturate(0.35) brightness(0.8); box-shadow: none; }

.call-label {
  position: relative;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* Two rings around the button. Idle: slow breathing. In a call: they follow the voice. */
.halo {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1px solid rgb(255 183 134 / 0.5);
  pointer-events: none;
  animation: breathe 4.2s ease-in-out infinite;
}
.halo-2 { inset: -30px; border-color: rgb(255 183 134 / 0.22); animation-delay: 0.7s; }

.dial[data-state="connecting"] .halo {
  border-style: dashed;
  border-color: rgb(255 255 255 / 0.6);
  animation: spin 2.4s linear infinite;
}
.dial[data-state="connecting"] .halo-2 { animation-direction: reverse; animation-duration: 3.6s; }

.dial.in-call .call {
  background: var(--paper);
  color: var(--dawn);
  box-shadow: 0 10px 36px rgb(3 28 44 / 0.5), inset 0 0 0 1px rgb(5 43 66 / 0.08);
}
.dial.in-call .halo {
  animation: none;
  border-color: rgb(167 197 241 / 0.75);
  transform: scale(calc(1 + var(--level) * 0.28));
  opacity: calc(0.35 + var(--level) * 0.65);
  transition: transform 0.09s linear, opacity 0.09s linear;
}
.dial.in-call .halo-2 { transform: scale(calc(1 + var(--level) * 0.5)); border-color: rgb(167 197 241 / 0.35); }
.dial.in-call[data-state="speaking"] .halo { border-color: rgb(255 183 134 / 0.85); }
.dial.in-call[data-state="speaking"] .halo-2 { border-color: rgb(255 183 134 / 0.4); }

.status {
  min-height: 21px;
  color: var(--on-night-2);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.mute {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--on-night-line);
  border-radius: var(--radius-pill);
  background: rgb(255 255 255 / 0.06);
  color: var(--on-night);
  font-size: 13px;
  font-weight: 600;
}
.mute[aria-pressed="true"] { background: var(--cream); color: var(--prussian); border-color: transparent; }

.problem {
  max-width: 34ch;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgb(255 183 134 / 0.16);
  border: 1px solid rgb(255 183 134 / 0.4);
  color: var(--cream);
}

.hint { max-width: 36ch; color: var(--on-night-2); text-wrap: balance; }

.phones {
  width: min(360px, 100%);
  padding-top: 16px;
  border-top: 1px solid var(--on-night-line);
  animation: rise 0.7s 0.16s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.phones-title { font-size: 13px; color: var(--on-night-2); margin-bottom: 8px; }
.phone-list { display: grid; gap: 2px; }
.phone-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px;
}
.phone-list li + li { border-top: 1px dashed var(--on-night-line); }
.phone-list span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--on-night-2);
}
.phone-list a {
  color: var(--on-night);
  font-family: var(--font-mono);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  border-bottom: 1px solid rgb(255 183 134 / 0.6);
  white-space: nowrap;
}
.phone-list a:hover { color: var(--horizon); }

.transcript {
  width: min(520px, 100%);
  max-height: 260px;
  overflow-y: auto;
  padding: 14px 16px;
  border: 1px solid var(--on-night-line);
  border-radius: var(--radius-lg);
  background: rgb(3 28 44 / 0.46);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  text-align: left;
  display: grid;
  gap: 12px;
  scrollbar-width: thin;
}
@media (min-width: 900px) { .transcript { flex: 1 1 160px; min-height: 120px; max-height: none; } }

.line { display: grid; gap: 2px; animation: rise 0.3s ease both; }
.line .speaker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sky);
}
.line.user .speaker { color: var(--horizon); }
/* Indian scripts sit taller than Latin; give every line room. */
.line p { font-size: 16px; line-height: 1.6; overflow-wrap: anywhere; }

.desk-foot {
  margin-top: auto;
  padding-top: 8px;
  font-size: 13px;
  color: rgb(255 255 255 / 0.74);
  text-wrap: balance;
}

/* ---- The board ----------------------------------------------------------- */

.board-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line-2);
}
.board-head h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.board-head p { color: var(--text-2); }

.live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
  white-space: nowrap;
}
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: blink 2s ease-in-out infinite; }
.live.stale i { background: var(--line-2); animation: none; }

.cards { display: grid; gap: 10px; max-width: 640px; }

.empty {
  padding: 28px 20px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-md);
  color: var(--text-2);
  text-align: center;
  text-wrap: balance;
}

.card {
  padding: 14px 16px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-xs);
  display: grid;
  gap: 4px;
}
.card.fresh { animation: arrive 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both; }

.card header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--text-2);
}
.card time { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag {
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--neutral-soft);
  color: var(--text-2);
  white-space: nowrap;
}
.card.booked .tag { background: var(--success-soft); color: var(--success); }
.card.moved .tag { background: var(--info-soft); color: var(--info); }
.card.handoff .tag { background: var(--warning-soft); color: var(--warning); }

.card h3 { font-size: 17px; font-weight: 600; line-height: 1.3; }
.card p { color: var(--text-2); overflow-wrap: anywhere; line-height: 1.5; }

.card.urgent { border-color: var(--danger); background: var(--danger-soft); }
.card.urgent .tag { background: var(--danger); color: #fff; }
.card.urgent h3 { color: var(--danger); }
.card.urgent p { color: var(--text); }

/* ---- Motion -------------------------------------------------------------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes arrive {
  0% { opacity: 0; transform: translateY(-12px) scale(0.98); box-shadow: 0 0 0 3px rgb(227 82 12 / 0.5), var(--shadow-md); }
  40% { opacity: 1; transform: none; box-shadow: 0 0 0 3px rgb(227 82 12 / 0.5), var(--shadow-md); }
  100% { box-shadow: 0 0 0 0 rgb(227 82 12 / 0), var(--shadow-xs); }
}
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.07); opacity: 0.35; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
