/*
 * Coryton apps: shared design tokens and base components.  1.0.0
 *
 * ADOPTED 2026-11-13: the Portal look is the standard for every Coryton app
 * (Craig's decision, chosen from three versions side by side).
 *
 * One source for the look every Coryton app shares. Read design/DESIGN.md
 * before changing anything here.
 *
 * Two layers:
 *   1. Tokens: CSS custom properties on :root. Every app should take these.
 *      The names are the ones the Portal, Decant Manager and RFT Board
 *      already use, and the ones Improve's widget reads from its host, so
 *      taking them changes nothing that already works.
 *   2. Components: `cy-` classes. Optional. An app may keep its own
 *      classes (`pt-`, `dm-`, ...) as long as they are built on the tokens.
 *
 * No fonts are downloaded and nothing here reaches the network.
 */

:root {
  /* ---- brand ----------------------------------------------------------- */
  --navy: #0d2858;      /* header, headings, the Coryton colour */
  --navy-2: #16294f;    /* darker navy: header hover, overlays */
  --navy-3: #1e3766;    /* lighter navy: avatar, raised items on navy */
  --teal: #0d9488;      /* primary action, header rule, focus */
  --teal-2: #0b7d73;    /* primary action hover */

  /* ---- status: these mean something, never use them for decoration ---- */
  --green: #059669;     /* good, done, improving */
  --amber: #d97706;     /* attention, waiting, needs a decision */
  --red: #b91c1c;       /* bad, failed; the update banner */
  --red-dark: #7f1d1d;  /* "your work did not save": the one bar never hidden */
  --green-bg: #d1fae5;  --green-fg: #065f46;
  --amber-bg: #fef3c7;  --amber-fg: #92400e;
  --red-bg: #fee2e2;    --red-fg: #991b1b;
  --info-bg: #e0f2f1;   --info-fg: #0b5f58;

  /* ---- surfaces and text ----------------------------------------------- */
  --paper: #f4f6f8;     /* page background */
  --card: #ffffff;      /* cards, panels, inputs */
  --chip: #eef2f6;      /* chips, hover fill, quiet backgrounds */
  --ink: #10192e;       /* body text */
  --ink-soft: #566079;  /* secondary text, labels */
  --border: #d9dfe8;    /* card and input borders */
  --line: #d9dfe8;      /* rules and dividers (Improve's widget reads this) */

  /* ---- chart series, in order ------------------------------------------ */
  --series-1: #0d2858;
  --series-2: #0d9488;
  --series-3: #d97706;
  --series-4: #7c3aed;
  --series-5: #64748b;

  /* ---- shape, depth, type ---------------------------------------------- */
  --radius: 10px;       /* cards, tiles, panels */
  --radius-sm: 6px;     /* buttons, inputs */
  --radius-pill: 999px; /* chips */
  --shadow: 0 1px 2px rgba(16, 25, 46, 0.06);
  --shadow-up: 0 10px 28px rgba(16, 25, 46, 0.12);
  --focus: 0 0 0 3px rgba(13, 148, 136, 0.45);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 11.5px;    /* chips, captions */
  --text-sm: 12.5px;    /* secondary text */
  --text: 14px;         /* body */
  --text-lg: 16.5px;    /* card titles */
  --text-xl: 18px;      /* app name in the header */
  --text-2xl: 22px;     /* page titles */

  --header-rule: 4px;   /* the teal line under the navy header */
  --content-max: 1180px;
}

/* ======================================================================== */
/* Components. Optional: take what fits.                                     */
/* ======================================================================== */

.cy-body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: var(--text)/1.5 var(--font);
}
.cy-mono { font-family: var(--font-mono); font-size: var(--text-sm); }

/* ---- header: navy bar, teal rule, app name, who is signed in ------------ */
.cy-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 18px;
  padding: 12px 24px; background: var(--navy); color: #fff;
  border-bottom: var(--header-rule) solid var(--teal);
}
.cy-brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; min-width: 0; }
.cy-brand-name { font-size: var(--text-xl); font-weight: 700; letter-spacing: 0.2px; }
.cy-brand-sub { font-size: 12px; color: #b9c4dc; }
.cy-back { font-size: var(--text-sm); color: #b9c4dc; text-decoration: none; }
.cy-back:hover { color: #fff; text-decoration: underline; }
.cy-build { font-family: var(--font-mono); font-size: 11px; color: #9fb0d1; }

/* ---- page ---------------------------------------------------------------- */
.cy-main { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 22px 24px 40px; box-sizing: border-box; }
.cy-h1 { font-size: var(--text-2xl); color: var(--navy); margin: 0 0 6px; }
.cy-h2 { font-size: var(--text-lg); color: var(--navy); margin: 0 0 8px; }
.cy-muted { color: var(--ink-soft); }

/* ---- buttons --------------------------------------------------------------- */
.cy-btn {
  display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 13px; font-weight: 600;
  min-height: 36px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; line-height: 1.3;
  white-space: nowrap; box-sizing: border-box;
}
.cy-btn:hover:not(:disabled) { background: var(--chip); }
.cy-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cy-btn--primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.cy-btn--primary:hover:not(:disabled) { background: var(--teal-2); border-color: var(--teal-2); }
.cy-btn--danger { background: var(--card); border-color: var(--red); color: var(--red); }
.cy-btn--danger:hover:not(:disabled) { background: var(--red-bg); }
.cy-btn--ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.35); min-height: 30px; padding: 5px 11px; font-size: 12px; }
.cy-btn--ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.cy-btn--small { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.cy-btn:focus-visible, .cy-input:focus-visible, .cy-card:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---- form fields ------------------------------------------------------------ */
.cy-label { display: block; font-size: var(--text-xs); font-weight: 600; color: var(--ink-soft); margin: 0 0 4px; }
.cy-input {
  font: inherit; width: 100%; box-sizing: border-box; min-height: 38px; padding: 7px 11px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card); color: var(--ink);
}

/* ---- cards and tiles ---------------------------------------------------------- */
.cy-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; box-shadow: var(--shadow);
}
/* A tile is a card with a coloured top edge; set --acc to change it. */
.cy-tile {
  --acc: var(--teal);
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 16px 18px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--ink); text-decoration: none; overflow: hidden;
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out;
}
.cy-tile::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--acc); }
a.cy-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-up); }
.cy-tile-name { font-size: var(--text-lg); font-weight: 700; color: var(--navy); }
.cy-stat { font-size: 28px; font-weight: 700; color: var(--navy); line-height: 1.1; }

/* ---- chips ------------------------------------------------------------------- */
.cy-chip {
  display: inline-block; font-size: var(--text-xs); font-weight: 600; padding: 2px 9px;
  border-radius: var(--radius-pill); background: var(--chip); color: var(--navy);
}
.cy-chip--good { background: var(--green-bg); color: var(--green-fg); }
.cy-chip--warn { background: var(--amber-bg); color: var(--amber-fg); }
.cy-chip--bad  { background: var(--red-bg);   color: var(--red-fg); }

/* ---- banners: one bar across the top, one meaning per colour ----------------
 * --update  a new version is ready. RED, so it is not missed (Craig,
 *           2026-11-13), with an "Update now" button.
 * --warn    act soon (a test build, a session about to expire).
 * --error   something failed and the person must know (did not save).
 *           Darker red, and placed ABOVE the update banner when both show.
 * Banners sit in the page flow above the header, never position:fixed over
 * it, so nothing is covered and nothing has to pad the body by hand.
 */
.cy-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 9px 24px; font-size: 13px; line-height: 1.4; border-bottom: 1px solid transparent;
}
.cy-banner-text { flex: 1; min-width: 12em; }
.cy-banner-text strong { font-weight: 700; }
.cy-banner--update { background: var(--red); color: #fff; }
.cy-banner--update .cy-btn { background: #fff; border-color: #fff; color: var(--red); }
.cy-banner--warn   { background: var(--amber-bg); color: var(--amber-fg); border-color: #fcd34d; }
.cy-banner--error  { background: var(--red-dark); color: #fff; border-color: #450a0a; }
.cy-banner--error .cy-btn { background: #fff; border-color: #fff; color: var(--red-dark); }

@media print { .cy-banner { display: none !important; } }
@media (max-width: 600px) {
  .cy-header, .cy-banner { padding-left: 16px; padding-right: 16px; }
  .cy-main { padding: 16px 16px 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .cy-tile { transition: none; }
  a.cy-tile:hover { transform: none; }
}
