/* ccs-azure-sched/ansible/roles/portal_web/files/portal.css
 *
 * The one stylesheet of the CCS Azure service portal, azure.ccs.uky.edu.
 * Installed by roles/portal_web as /portal.css and read by every page of the site: the public
 * pages, /my/ and /admin/. System fonts only; nothing is loaded from any other site.
 *
 * The system it defines - the tokens, the components and the layout rules - is written up in
 * ccs-azure-sched/docs/31-portal-design.md, which is also where "how to add a page" lives.
 * Class names the page scripts set themselves (flag / flag.fresh / flag.stale, scroll, note,
 * num, tabs button.on) are part of the contract with those scripts: change them in both places
 * or not at all.
 */

/* ------------------------------------------------------------------ 1. tokens */
:root {
  color-scheme: light dark;

  /* ink and paper */
  --ink: #16191f;          /* body text */
  --ink-soft: #3b424c;     /* secondary text that is still text */
  --muted: #5c6672;        /* labels, captions, table headings */
  --line: #d7dce3;         /* borders */
  --line-soft: #e8ebf0;    /* rules inside a card */
  --bg: #f4f6f8;           /* the page */
  --surface: #ffffff;      /* a card */
  --surface-2: #f0f2f6;    /* a panel inside a card: script boxes, table headers */

  /* the one accent: UK blue */
  --accent: #0033a0;
  --accent-ink: #0033a0;   /* accent used as text on the page background */
  --accent-soft: #e7edf9;  /* accent as a wash behind a chosen column or a badge */
  --accent-line: #9db2da;

  --danger: #b00020;
  --danger-soft: #fdecef;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .07);
  --gutter: 16px;          /* the side gutter, phone included */
  --page: 72rem;           /* the content column */

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e7e9ec;
    --ink-soft: #c6cad1;
    --muted: #9aa3b0;
    --line: #333a45;
    --line-soft: #2a303a;
    --bg: #14171c;
    --surface: #1b1f26;
    --surface-2: #232933;
    --accent: #8fb0ff;
    --accent-ink: #9dbaff;
    --accent-soft: #1e2a45;
    --accent-line: #3f5a8f;
    --danger: #ff8f9b;
    --danger-soft: #3a1c22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

/* ------------------------------------------------------------------ 2. page frame */
html {
  font: 16px/1.55 var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
body { margin: 0; background: var(--bg); }

/* Several components below set a display of their own; a page script that hides an element with
   the hidden attribute must still win. Every page relies on this. */
[hidden] { display: none !important; }

/* The bar at the top of every page: the site name and the small nav. Full width, its contents
   held to the same column as the page. */
.site {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.site-inner {
  max-width: var(--page);
  margin-inline: auto;
  padding: .6rem var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem 1.25rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: .01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand .brand-name span { color: var(--muted); font-weight: 400; }
/* The CCS logo, left of the site name in the bar at the top of every page. It is served from
   this host as /ccs-logo.jpg (roles/portal_web/files/public/ccs-logo.jpg); the max-height is
   what keeps it from taking over the bar on a phone. */
.brand-logo {
  height: 36px;
  max-height: 36px;
  width: auto;
  flex: 0 0 auto;
  border-radius: var(--radius-sm);
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .15rem .35rem;
  margin-inline-start: auto;
}
.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: .92rem;
  padding: .25rem .5rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.site-nav a:hover { background: var(--surface-2); color: var(--ink); }
.site-nav a[aria-current="page"] {
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}

main {
  max-width: var(--page);
  margin-inline: auto;
  padding: 1.25rem var(--gutter) 3.5rem;
}
/* A page whose tables need more than the 72rem column (the price page, issue #370) carries
   class "wide" on its body: its column, the bar at the top included, runs to 90rem, and its
   prose keeps a readable measure. The notices and the footer stay the width of their card. */
.wide main, .wide .site-inner { max-width: 90rem; }
.wide main :is(p, li):not(.notice, .flag, .page-foot) { max-width: 60rem; }

/* ------------------------------------------------------------------ 3. typographic scale */
h1, h2, h3 { line-height: 1.25; }
.page-head { margin: 0 0 1.1rem; }
.page-head h1 { font-size: 1.75rem; margin: 0 0 .3rem; letter-spacing: -.01em; }
.page-head .lede { margin: 0; color: var(--muted); max-width: 46rem; }
.page-head .who { margin: .4rem 0 0; font-size: .9rem; color: var(--muted); }
h2 { font-size: 1.14rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }
p { margin: .6rem 0; }
a { color: var(--accent-ink); }
small, .small { font-size: .85rem; }
code, kbd { font-family: var(--mono); font-size: .92em; }
code {
  background: var(--surface-2);
  border-radius: 3px;
  padding: .05em .3em;
}
strong { font-weight: 650; }

/* The captions that carry the meaning of a figure: small, quiet, never a wall. */
.note, .hint {
  color: var(--muted);
  font-size: .88rem;
  margin: .5rem 0;
}
.note { max-width: 58rem; }

/* ------------------------------------------------------------------ 4. cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.1rem;
  margin: 0 0 1.1rem;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card > h2, .card > legend, .card-title {
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .75rem;
}
.card > h3 { margin-top: .9rem; }
.card.plain { box-shadow: none; }
/* One of several task cards: the one whose commands the page is about to write. The radio
   inside the card is the signal that does not need colour; this is the wash beside it.
   portal-admin.js rewrites the whole class attribute of these cards, so nothing else may
   live there. */
.card.chosen-task {
  border-color: var(--accent-line);
  box-shadow: inset 4px 0 0 var(--accent), var(--shadow);
}

/* A numbered step in a form. */
.step > h2::before, .step > legend::before {
  content: attr(data-step);
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-inline-end: .5rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: .78rem;
  vertical-align: -.3rem;
}

/* ------------------------------------------------------------------ 5. layout rules
   Two columns from 62rem up, one column below it. The script panel and the wide tables are
   always the full width of the content column. */
.cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
}
@media (min-width: 62rem) {
  .cols { grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr); }
  .cols > .full { grid-column: 1 / -1; }
}
.full { min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }

/* ------------------------------------------------------------------ 6. facts and figures
   A fact is a large number with a small label under it: the queue card and the money headline. */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: .1rem 1rem;
}
.fact {
  padding: .45rem 0;
  border-top: 1px solid var(--line-soft);
  min-width: 0;
}
.facts > .fact:nth-child(-n+2) { border-top: 0; }
.fact-value {
  display: block;
  font-size: 1.32rem;
  font-weight: 650;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.fact-label {
  display: block;
  font-size: .78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.fact-sub { display: block; font-size: .82rem; color: var(--muted); }
.fact.wide { grid-column: 1 / -1; }
.fact.accent .fact-value { color: var(--accent-ink); }

/* The headline figure of a money page. */
.kpis:empty { display: none; }
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: .75rem;
  margin: 0 0 1.1rem;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .8rem .9rem;
}
.kpi-label {
  display: block;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.kpi-value {
  display: block;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  margin-top: .15rem;
  overflow-wrap: anywhere;
}
.kpi-sub { display: block; font-size: .82rem; color: var(--muted); margin-top: .1rem; }
.kpi.headline { border-color: var(--accent-line); background: var(--accent-soft); }
.kpi.headline .kpi-value { color: var(--accent-ink); font-size: 2.1rem; }

/* A short sentence that must not be missed, in the middle of a form. */
.callout {
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: .55rem .75rem;
  margin: .75rem 0 0;
}
.callout .big {
  font-size: 1.15rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ 7. banners and notices */
.flag, .banner {
  display: block;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: .65rem .85rem;
  margin: 0 0 1rem;
  font-size: .92rem;
}
.flag.fresh { color: var(--ink-soft); border-left-color: var(--accent); }
.flag.stale {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger);
  font-weight: 600;
}
/* The quiet one: something is not connected yet, and that is expected. */
.notice {
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: .6rem .8rem;
  color: var(--muted);
  font-size: .88rem;
}
/* The loud one: the estimates notice. Same box as .notice, but it is meant to be read, so it
   takes the body ink, the body size and a solid accent border instead of the dashed grey.
   The sentence itself goes in a <strong>. */
.notice.loud {
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-left: 4px solid var(--accent);
  color: var(--ink);
  font-size: 1rem;
  margin: 0 0 1rem;
}
.notice.loud strong { font-weight: 650; }
.notice.loud a { color: var(--accent-ink); }

.warn {
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  margin: .5rem 0;
}

/* ------------------------------------------------------------------ 8. tables
   Figures are right-aligned and use tabular figures, so a column of dollars lines up. The page
   scripts put the class "num" on a cell that holds a number. */
table {
  border-collapse: collapse;
  width: 100%;
  font-size: .93rem;
}
caption { text-align: left; color: var(--muted); font-size: .85rem; padding-bottom: .4rem; }
th, td {
  text-align: left;
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
thead th {
  font-weight: 600;
  font-size: .8rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody th { font-weight: 500; color: var(--ink-soft); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
.num, td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* A table wider than the screen scrolls inside its own box rather than pushing the page out. */
.scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.scroll > table { min-width: 34rem; }
.card > .scroll { border: 0; border-radius: 0; background: transparent; }
.card > .scroll > table { min-width: 30rem; }

/* A dense table: the price page's tables, which have to fit a 1280px laptop with no sideways
   scrollbar (issue #370). Type at .9rem with tabular figures throughout; a column head may wrap
   onto two lines instead of pushing the table wider; and the first column holds the name with
   its one-line description under it (the span.hint the scripts write), wide enough that the
   description is two lines at most and never a tall sliver. On a phone the table still scrolls
   inside .scroll, never the page. */
table.dense { font-size: .9rem; font-variant-numeric: tabular-nums; }
table.dense thead th { white-space: normal; vertical-align: bottom; }
table.dense thead th .hint {
  display: block;
  margin: 0;
  font-size: .72rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}
table.dense tbody th[scope="row"] { min-width: 17rem; }
table.dense tbody th br { display: none; }
table.dense tbody th .hint {
  display: block;
  margin: .1rem 0 0;
  font-size: .8rem;
  font-weight: 400;
  line-height: 1.35;
  white-space: normal;
}

/* The chosen column of a two-column comparison, and the one that was not chosen. */
th.chosen, td.chosen { background: var(--accent-soft); }
th.chosen { color: var(--accent-ink); }
td.chosen { font-weight: 650; color: var(--ink); }
th.chosen { box-shadow: inset 0 3px 0 var(--accent); }
th.unchosen, td.unchosen { color: var(--muted); }
.badge {
  display: inline-block;
  margin-top: .2rem;
  padding: .05rem .4rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
@media (prefers-color-scheme: dark) { .badge { color: #101318; } }

/* ------------------------------------------------------------------ 9. forms */
fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0 0 1.1rem;
  padding: .9rem 1.1rem 1.1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}
legend {
  padding: 0 .35rem;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
label { display: block; margin: .5rem 0 .2rem; font-weight: 600; font-size: .92rem; }
.field { min-width: 0; }
.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: .6rem .9rem;
}
input[type="text"], input[type="number"], input[type="search"], textarea, select {
  font: inherit;
  width: 100%;
  box-sizing: border-box;
  padding: .4rem .5rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="radio"], input[type="checkbox"] { width: auto; margin: 0 .4rem 0 0; accent-color: var(--accent); }
.choice { display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center; }
.choice label, label.inline {
  display: inline-flex;
  align-items: center;
  gap: .1rem;
  font-weight: 400;
  margin: .2rem 0;
}
.row input[type="number"] { max-width: 6.5rem; }

button, .btn {
  font: inherit;
  font-weight: 600;
  padding: .42rem .9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--accent-line); color: var(--accent-ink); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
@media (prefers-color-scheme: dark) { button.primary { color: #101318; } }
button.primary:hover { filter: brightness(1.08); color: #fff; }
@media (prefers-color-scheme: dark) { button.primary:hover { color: #101318; } }

/* Tabs: the script sets class "on" on the chosen one and clears the others, so nothing else
   may live in those elements' class attribute. */
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1.1rem; }
.tabs button { background: var(--surface); }
.tabs button.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------ 10. the script panel
   One component for every block of text a reader copies: the job script, the sacctmgr lines, the
   dry run. Monospace, full width, never wrapped - a wrapped #SBATCH line with a comment column
   is unreadable - and it scrolls sideways inside its own box. The copy button belongs to the
   panel and sits in its bar. */
.script-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin: 0 0 1.1rem;
}
.script-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  padding: .5rem .75rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.script-title {
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.script-bar .spacer { margin-inline-start: auto; }
.script-bar .hint, .script-bar .note { margin: 0; }
.script-bar .said { font-size: .85rem; color: var(--accent-ink); }
.script-box {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: .75rem .9rem;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: .82rem;
  line-height: 1.45;
  white-space: pre;            /* never wrap: the comment column has to stay a column */
  overflow: auto;
  tab-size: 8;
  resize: vertical;
}
textarea.script-box { min-height: 34rem; }   /* the whole #SBATCH header without scrolling */
pre.script-box { min-height: 6rem; max-height: 34rem; }
@media (max-width: 40rem) {
  textarea.script-box { min-height: 22rem; font-size: .78rem; }
}

/* A plain pre that is not a copy panel. */
pre:not(.script-box) {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .75rem .9rem;
  overflow-x: auto;
  white-space: pre;
  font-family: var(--mono);
  font-size: .85rem;
}

/* ------------------------------------------------------------------ 11. lists and the footer */
main ul, main ol { padding-inline-start: 1.25rem; }
main li { margin: .3rem 0; }
ul.plain { list-style: none; padding-inline-start: 0; }
ul.plain li { margin: .55rem 0; }
.page-foot {
  margin-top: 2rem;
  padding-top: .9rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .88rem;
}
.page-foot a { color: var(--accent-ink); }

/* ------------------------------------------------------------------ 12. phone
   375px with a 16px gutter and no sideways scroll of the page itself. */
@media (max-width: 30rem) {
  .page-head h1 { font-size: 1.4rem; }
  .brand-logo { height: 28px; max-height: 28px; }
  .card { padding: .85rem .9rem 1rem; }
  fieldset { padding: .8rem .9rem 1rem; }
  .kpi-value { font-size: 1.45rem; }
  .kpi.headline .kpi-value { font-size: 1.8rem; }
  .site-nav { margin-inline-start: 0; }
}

/* ------------------------------------------------------------------ 13. the workflow drawing
   The one drawing on the site, on workflow.html: the local ECC lane, the remote Azure lane and
   the four numbered steps between them, as inline SVG. It is sized by its viewBox, so it is
   read whole on a 360px phone with no sideways scroll, and it is capped in width on a laptop
   so it stays a drawing and not a poster. Every colour is a token, so it follows the dark
   theme like the rest of the page; the step number takes the badge's ink. */
.diagram { margin: .75rem auto 1rem; max-width: 34rem; }
.diagram svg { display: block; width: 100%; height: auto; font-family: var(--sans); }
.diagram .lane { fill: var(--surface-2); stroke: var(--line); stroke-width: 1; }
.diagram .lane-title {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  text-anchor: middle;
}
.diagram .box { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.diagram .box.remote { stroke: var(--accent-line); }
.diagram .box.aside { stroke-dasharray: 4 3; }
.diagram .label { fill: var(--ink); font-size: 12px; font-weight: 650; text-anchor: middle; }
.diagram .sub { fill: var(--muted); font-size: 10px; text-anchor: middle; }
.diagram .mono { font-family: var(--mono); font-size: 9.5px; }
.diagram .person { fill: var(--accent); }
.diagram .arrow { stroke: var(--accent); stroke-width: 1.6; fill: none; }
.diagram .arrow.faint { stroke: var(--muted); stroke-dasharray: 4 3; }
.diagram .head { fill: var(--accent); }
.diagram .head.faint { fill: var(--muted); }
.diagram .arrow-label { fill: var(--accent-ink); font-size: 10px; font-weight: 700; text-anchor: middle; }
.diagram .arrow-label.faint { fill: var(--muted); }
.diagram .step { fill: var(--accent); }
.diagram .step-n { fill: #fff; font-size: 10px; font-weight: 700; text-anchor: middle; }
@media (prefers-color-scheme: dark) { .diagram .step-n { fill: #101318; } }
