/*
 * Morse Labs shared theme — design tokens + base components.
 *
 * The Morse suite palette (agreed 2026-11-28): SwiftLoop's Standard greys with a
 * petrol accent, #1B6A86 (#237D9A for fills in dark mode). The teal #75E6DA is
 * a logo colour only, and the logo's navy #0D1F2D is the brand ground. Light is
 * the default; dark follows the OS (prefers-color-scheme) and can be forced with
 * data-color-scheme on <html>.
 *
 * Served at /branding/morse-theme.css. Apps link it and use the --ms-* tokens
 * (or the .ms-* helper classes). Pair with branding-toggle.js for the toggle.
 */
@import url("morse-notify.css");


/* Inter 4.1 (https://rsms.me/inter), the suite's interface font, the same files
   Pages, SwiftLoop and Bearing ship. Served from /branding/fonts so nothing is
   fetched from a font service (air-gapped). SIL Open Font License, fonts/Inter-OFL.txt. */
@font-face {
  font-family: "InterVariable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/branding/fonts/InterVariable.woff2") format("woff2");
}
@font-face {
  font-family: "InterVariable";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/branding/fonts/InterVariable-Italic.woff2") format("woff2");
}

:root {
  color-scheme: light dark;

  /* The Morse suite palette: SwiftLoop Standard greys with a petrol accent.
     The teal is a logo colour only; the logo's navy is the brand ground. */
  --ms-brand-ground:  #0D1F2D;
  --ms-brand-teal:    #75E6DA;

  --ms-bg:            #FFFFFF;   /* white page; cards keep their border */
  --ms-bg-pattern:    url("/branding/morse-tile-light.svg");
  --ms-surface:       #FFFFFF;
  --ms-surface-2:     #F9F9FB;
  --ms-text:          #1C2024;
  --ms-text-muted:    #696B6E;
  --ms-text-faint:    #8B8D98;
  --ms-accent:        #1B6A86;   /* suite petrol */
  --ms-accent-hover:  #14546B;
  --ms-accent-contrast:#FFFFFF;
  --ms-link:          #1B6A86;
  --ms-selected:      #E3F0F4;
  --ms-border:        #D9D9E0;
  --ms-input-bg:      #FFFFFF;
  --ms-input-border:  #8B8D98;
  --ms-focus:         #1B6A86;
  --ms-focus-ring:    rgba(27,106,134,0.18);
  --ms-hover:         rgba(28,32,36,0.07);   /* hover fill on the page background */
  --ms-radius:        6px;
  --ms-radius-card:   12px;
  --ms-shadow:        0 4px 24px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --ms-error:         #C4262B;
  --ms-error-bg:      #FDE8E8;
  --ms-warning:       #8A6100;
  --ms-info:          #1B6A86;
  /* Navy-ink marks on light surfaces; the teal mark is faint on white. */
  --ms-logo:          url("/branding/logo-navy.svg");
  --ms-logo-mark:     url("/branding/logo-mark-navy.svg");
  --ms-logo-mark-header: url("/branding/logo-mark-header-navy.svg");
  --ms-logo-wordmark: url("/branding/logo-wordmark-header-light.svg");
  --ms-font:          "InterVariable", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Dark. Follows the OS unless forced light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-color-scheme="light"]) {
    color-scheme: dark;
    --ms-bg:            #1D1D1F;
    --ms-bg-pattern:    url("/branding/morse-tile-dark.svg");
    --ms-surface:       #28292B;
    --ms-surface-2:     #36373A;
    --ms-text:          #EDEEF0;
    --ms-text-muted:    #9FA0A2;
    --ms-text-faint:    #80858E;
    --ms-accent:        #237D9A;
    --ms-accent-hover:  #1D6880;
    --ms-accent-contrast:#FFFFFF;
    --ms-link:          #8FD0E3;
    --ms-selected:      #1d3540;
    --ms-border:        #4A4E53;
    --ms-input-bg:      #1D1D1F;
    --ms-input-border:  #80858E;
    --ms-focus:         #4FA3BF;
    --ms-focus-ring:    rgba(79,163,191,0.30);
    --ms-hover:         rgba(237,238,240,0.09);
    --ms-shadow:        0 4px 24px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --ms-error:         #FF9592;
    --ms-error-bg:      #442E30;
    --ms-warning:       #F5D90A;
    --ms-info:          #8FD0E3;
    --ms-logo:          url("/branding/logo-dark.svg");
    --ms-logo-mark:     url("/branding/logo-mark.svg");
    --ms-logo-mark-header: url("/branding/logo-mark-header.svg");
    --ms-logo-wordmark: url("/branding/logo-wordmark-header-dark.svg");
  }
}
/* Explicit dark (toggle override). */
:root[data-color-scheme="dark"] {
  color-scheme: dark;
  --ms-bg:            #1D1D1F;
  --ms-bg-pattern:    url("/branding/morse-tile-dark.svg");
  --ms-surface:       #28292B;
  --ms-surface-2:     #36373A;
  --ms-text:          #EDEEF0;
  --ms-text-muted:    #9FA0A2;
  --ms-text-faint:    #80858E;
  --ms-accent:        #237D9A;
  --ms-accent-hover:  #1D6880;
  --ms-accent-contrast:#FFFFFF;
  --ms-link:          #8FD0E3;
  --ms-selected:      #1d3540;
  --ms-border:        #4A4E53;
  --ms-input-bg:      #1D1D1F;
  --ms-input-border:  #80858E;
  --ms-focus:         #4FA3BF;
  --ms-focus-ring:    rgba(79,163,191,0.30);
  --ms-hover:         rgba(237,238,240,0.09);
  --ms-shadow:        0 4px 24px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --ms-error:         #FF9592;
  --ms-error-bg:      #442E30;
  --ms-warning:       #F5D90A;
  --ms-info:          #8FD0E3;
  --ms-logo:          url("/branding/logo-dark.svg");
  --ms-logo-mark:     url("/branding/logo-mark.svg");
  --ms-logo-mark-header: url("/branding/logo-mark-header.svg");
  --ms-logo-wordmark: url("/branding/logo-wordmark-header-dark.svg");
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
.ms-body {
  background: var(--ms-bg);
  color: var(--ms-text);
  font-family: var(--ms-font);
  -webkit-font-smoothing: antialiased;
}
.ms-logo {
  width: 160px; height: 44px;
  background: var(--ms-logo) no-repeat center / contain;
}
/* Header lockup: the mark beside the stacked MORSE LABS wordmark, the same
   sizes as SwiftLoop's (branding/README.md, Header lockup). Two images, not
   logo-*.svg scaled down, so the wordmark keeps its height. The -header files
   are pixel-fitted for exactly these boxes (bars and caps on whole pixels), so
   keep the sizes as they are. */
.ms-lockup { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; }
.ms-lockup-mark { width: 36px; height: 28px; background: var(--ms-logo-mark-header) no-repeat center / contain; }
.ms-lockup-wordmark { width: 92px; height: 30px; background: var(--ms-logo-wordmark) no-repeat center / contain; }
.ms-card {
  background: var(--ms-surface);
  border: 1px solid var(--ms-border);
  border-radius: var(--ms-radius-card);
  box-shadow: var(--ms-shadow);
}
.ms-input {
  width: 100%; height: 40px; padding: 8px 12px;
  background: var(--ms-input-bg);
  color: var(--ms-text);
  border: 1px solid var(--ms-input-border);
  border-radius: var(--ms-radius);
  font-size: 14px; outline: none; box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
}
.ms-input:focus { border-color: var(--ms-focus); box-shadow: 0 0 0 3px var(--ms-focus-ring); }
.ms-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px;
  background: var(--ms-accent); color: var(--ms-accent-contrast);
  border: 1px solid var(--ms-accent); border-radius: var(--ms-radius);
  font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background .15s, transform .1s;
}
.ms-btn:hover { background: var(--ms-accent-hover); border-color: var(--ms-accent-hover); }
.ms-btn:active { transform: translateY(1px); }
.ms-link { color: var(--ms-link); text-decoration: none; }
.ms-link:hover { text-decoration: underline; }

/* ── Light/dark toggle ────────────────────────────────────────────────────── */
.ms-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  width: 34px; height: 34px; justify-content: center;
  background: var(--ms-surface); color: var(--ms-text-muted);
  border: 1px solid var(--ms-border); border-radius: var(--ms-radius);
  cursor: pointer; transition: color .15s, border-color .15s;
}
.ms-toggle:hover { color: var(--ms-accent); border-color: var(--ms-accent); }
.ms-theme-toggle .ms-sun  { display: none; }
.ms-theme-toggle .ms-moon { display: inline; }
:root[data-color-scheme="dark"] .ms-theme-toggle .ms-sun  { display: inline; }
:root[data-color-scheme="dark"] .ms-theme-toggle .ms-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-color-scheme="light"]) .ms-theme-toggle .ms-sun  { display: inline; }
  :root:not([data-color-scheme="light"]) .ms-theme-toggle .ms-moon { display: none; }
}

/* ── Header bar ───────────────────────────────────────────────────────────── */
/* The one Morse header (branding/header-bar.md), modelled on SwiftLoop. A 64px
   full-width bar on the page background, no border or shadow: 14px top and
   bottom, 24px each side, 36px controls. Left: .ms-header-brand (the fitted mark
   and the product name, or the full .ms-lockup in the launcher). Right, in
   order: product controls (.ms-header-btn), the bell (.ms-header-bell), then
   the account menu (.ms-account). Pair with morse-account-menu.js. */
.ms-header {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 64px; padding: 14px 24px; box-sizing: border-box;
  flex-shrink: 0;
  background: var(--ms-bg); border: 0; box-shadow: none;
  color: var(--ms-text);
  font-family: var(--ms-font); font-size: 15px; line-height: 1.2;
}
.ms-header-brand {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
  color: var(--ms-text); text-decoration: none;
}
.ms-header-brand .ms-lockup-mark { flex-shrink: 0; }
.ms-header-product { font-size: 16px; font-weight: 600; white-space: nowrap; }
.ms-header-app { font-weight: 500; color: var(--ms-text-muted); }
/* Grows to push the controls right; holds breadcrumbs and the like. */
.ms-header-fill { flex: 1 1 auto; min-width: 0; }
.ms-header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }

/* Product controls: icon and label, 36px tall, 6px radius. */
.ms-header-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; min-width: 36px; padding: 0 8px; box-sizing: border-box;
  background: none; border: 0; border-radius: 6px;
  color: var(--ms-text-muted); font: inherit; font-size: 15px;
  text-decoration: none; cursor: pointer; flex-shrink: 0;
  transition: background .12s, color .12s;
}
.ms-header-btn:hover,
.ms-header-btn[aria-expanded="true"],
.ms-header-btn.active { background: var(--ms-hover); color: var(--ms-text); }
.ms-header-btn:focus-visible,
.ms-account-trigger:focus-visible,
.ms-account-item:focus-visible { outline: 2px solid var(--ms-focus); outline-offset: 1px; }
.ms-header-btn svg { flex-shrink: 0; }
/* The bell and its badge, dropdown and toasts: morse-notify.css, imported above. */

/* ── Account menu ─────────────────────────────────────────────────────────── */
/* The trigger is the user's name (16px 600) and a caret, no avatar; its right
   edge sits on the bar's 24px padding. The menu is a disclosure: a button with
   aria-expanded and a panel (hidden when closed). */
.ms-account { position: relative; flex-shrink: 0; }
.ms-account-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 6px; box-sizing: border-box; max-width: 280px;
  background: none; border: 0; border-radius: 6px;
  color: var(--ms-text); font: inherit; font-size: 16px; font-weight: 600;
  cursor: pointer; transition: background .12s;
}
.ms-account-trigger:hover,
.ms-account-trigger[aria-expanded="true"] { background: var(--ms-hover); }
.ms-account-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-account-person { display: none; flex-shrink: 0; color: var(--ms-text-muted); }
.ms-account-caret { flex-shrink: 0; width: 10px; height: 10px; color: var(--ms-text-muted); }
.ms-account-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 1000;
  display: flex; flex-direction: column;
  width: max-content; min-width: 260px; max-width: min(360px, calc(100vw - 32px));
  padding: 6px; box-sizing: border-box;
  background: var(--ms-surface); border: 1px solid var(--ms-border); border-radius: 10px;
  box-shadow: var(--ms-shadow);
  color: var(--ms-text); font-family: var(--ms-font); font-size: 15px; font-weight: 400; line-height: 1.35;
  text-align: left;
}
.ms-account-menu[hidden] { display: none; }
.ms-account-identity { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; }
.ms-account-tick { flex-shrink: 0; width: 16px; height: 16px; margin-top: 2px; color: var(--ms-accent); }
.ms-account-identity-text { min-width: 0; overflow-wrap: anywhere; }
.ms-account-identity-name { font-weight: 600; }
.ms-account-identity-email { color: var(--ms-text-muted); }
.ms-account-identity-org { margin-top: 2px; font-size: 13px; color: var(--ms-text-muted); }
.ms-account-sep { height: 1px; margin: 6px 4px; background: var(--ms-border); }
.ms-account-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; box-sizing: border-box;
  background: none; border: 0; border-radius: 6px;
  color: var(--ms-text); font: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.ms-account-item:hover { background: var(--ms-hover); }
.ms-account-item svg { flex-shrink: 0; width: 16px; height: 16px; color: var(--ms-text-muted); }
.ms-account-theme { padding: 4px; }

/* Three-way theme switch: system, light, dark. Native radios, so arrow keys
   move the choice. Sets data-color-scheme and the ms-color-scheme key that
   branding-toggle.js reads; "system" clears both. */
.ms-theme-switch {
  display: flex; width: 100%; box-sizing: border-box; gap: 2px; padding: 2px; margin: 0; min-width: 0;
  background: var(--ms-bg); border: 1px solid var(--ms-border); border-radius: 6px;
}
.ms-theme-switch label { position: relative; display: flex; flex: 1 1 0; cursor: pointer; }
.ms-theme-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.ms-theme-switch-opt {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; height: 28px; border-radius: 4px; color: var(--ms-text-muted);
}
.ms-theme-switch label:hover .ms-theme-switch-opt { color: var(--ms-text); }
.ms-theme-switch input:checked + .ms-theme-switch-opt {
  background: var(--ms-surface); color: var(--ms-text); box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}
.ms-theme-switch input:focus-visible + .ms-theme-switch-opt { outline: 2px solid var(--ms-focus); outline-offset: 1px; }
.ms-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Narrow screens: icons only. Control labels and the name go; the trigger
   becomes a person icon and the caret. */
@media (max-width: 767.98px) {
  .ms-header-label { display: none; }
  .ms-header-btn { padding: 0; width: 36px; }
  .ms-account-name { display: none; }
  .ms-account-person { display: block; }
}
