/*
  What only the hub has (specs/in-progress/hub-pages-and-site-theme.md). The rest of the hub's
  look is the website's shared theme, site-theme/theme.css and site-theme/fonts.css, which
  hub/templates/page.html loads before this file. Change the shared look there (in
  CharmersAIMarketingWebsite's theme/, then tools/update-site-theme), never by copying its rules here.

  JupyterHub's Bootstrap style sheet loads before the theme. The admin page adds its own copy of
  Bootstrap after this file, so the rules for its pages start with `html`, which makes them more
  specific.

  The image copies this file, site-theme/ and branding/ to JupyterHub's static folder, as
  /hub/static/charmersai/ (hub/Dockerfile).
*/

/* --- The hub's colours: a Mist page, white fields and Pine buttons in the light theme ---
   The public site's pages are white with Night buttons; the hub uses two greener colours from the
   same palette so that its buttons do not read as black. In the dark theme the hub is the site's
   own: dark green with Lamplight buttons. A tenant's button colours come after this, from page.html. */
/* A field's edge a shade darker than the website's #8A9A93, which is 2.9:1 on white: #7F8F88 reaches
   3.4:1 on a white field and 3.1:1 on Mist, as the brand guide's suggestion 5 (hub-page-style.md). */
:root {
  --canvas: var(--mist); --field-bg: var(--white); --surface: var(--white); --field-border: #7f8f88;
  --action: var(--pine); --on-action: var(--white); --action-hover: #18583f; --action-pressed: #18583f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --canvas: var(--bg); --field-bg: var(--bg); --field-border: #8a9a93; --action-pressed: var(--action-hover); }
}
:root[data-theme="dark"] { --canvas: var(--bg); --field-bg: var(--bg); --field-border: #8a9a93; --action-pressed: var(--action-hover); }
.button--ink:active { background: var(--action-pressed); }

/* JupyterHub's Bootstrap draws from these; they follow the theme. */
html:root {
  --bs-body-font-family: var(--font-text); --bs-body-font-size: 1rem; --bs-body-line-height: 1.55;
  --bs-body-bg: var(--canvas); --bs-body-color: var(--text); --bs-emphasis-color: var(--text);
  --bs-secondary-color: var(--text-muted); --bs-heading-color: inherit;
  --bs-border-color: var(--border); --bs-link-color: var(--link); --bs-link-hover-color: var(--link);
  --bs-link-color-rgb: 29, 107, 79; --bs-link-hover-color-rgb: 29, 107, 79;
  --bs-tertiary-bg: var(--surface); --bs-secondary-bg: var(--surface);
  --bs-focus-ring-color: var(--link); --bs-border-radius: var(--radius-control);
}
/* JupyterHub's "requires JavaScript" note names the framework: the pages that need it say so themselves. */
#noscript { display: none; }

/* --- The header bar: the theme's, with the account menu on the right --- */
.hub-header { background: var(--canvas); }
.hub-nav ul { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-6); margin: 0; padding: 0; list-style: none; }
.hub-nav a, .hub-account summary {
  display: inline-flex; align-items: center; min-height: 2.75rem; padding: var(--space-2) 0;
  color: var(--text); font: 400 var(--text-sm) / 1.2 var(--font-text); text-decoration: none;
}
.hub-nav a:hover, .hub-account summary:hover { color: var(--link); text-decoration: underline; }
.hub-account { position: relative; }
.hub-account summary { cursor: pointer; list-style: none; gap: var(--space-2); color: var(--link); max-width: min(16rem, 42vw); }
.hub-account summary::-webkit-details-marker { display: none; }
.hub-account summary::after {
  content: ""; flex: none; width: 0.45em; height: 0.45em; margin-top: -0.2em;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg);
}
.hub-account[open] summary::after { margin-top: 0.2em; transform: rotate(225deg); }
/* A long email address shortens with "…" rather than pushing the bar wider than a phone. */
.hub-account summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; }
.hub-account > ul {
  position: absolute; z-index: 10; right: 0; top: calc(100% + var(--space-1)); min-width: 11rem;
  display: grid; gap: 0; padding: var(--space-2); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-float);
}
.hub-account > ul a { display: flex; width: 100%; padding: var(--space-2) var(--space-3); border-radius: var(--radius-control); }
.hub-account-email { padding: var(--space-2) var(--space-3); color: var(--text-muted); font-size: var(--text-xs); overflow-wrap: anywhere; border-bottom: 1px solid var(--border); margin-bottom: var(--space-1); }
/* The bar keeps the wordmark and the account menu on one line on a phone. */
.hub-header .bar { flex-wrap: nowrap; }
.hub-nav { min-width: 0; }
@media (max-width: 40rem) {
  .hub-header .bar { flex-wrap: wrap; }
  .hub-nav { margin-left: auto; }
}

/* --- The page: the theme's heading block, inside the wrapper --- */
.hub-main > .wrap > * { margin: 0; min-width: 0; }
.hub-main > .wrap { justify-items: start; }
.hub-main > .wrap > :is(table, section, .table-responsive, #react-admin-hook) { justify-self: stretch; }
/* JupyterHub's own pages put their content in Bootstrap's centred .container: align it to the wrapper. */
.hub-main .container, .hub-main .container-fluid { max-width: none; margin: 0; padding-inline: 0; }
/* A task's page (sign in, join, password ...): heading, notice, form and other ways in, 24 px apart. */
.hub-task { display: grid; gap: var(--space-6); justify-items: start; width: 100%; }
.hub-task > * { margin: 0; }
/* Error pages: the website's 404 rhythm (.page-hero > .wrap's gap, then .stack-lg's margins). */
.hub-error { display: grid; gap: var(--space-6); justify-items: start; }
/* "You're signed out.", before the heading. */
.hub-confirmation { border-inline-start-color: var(--link); }

/* --- Forms: the theme's column of fields, with the hub's password field and alternatives --- */
.hub-main .form-column { width: 100%; }
.form-column .button { margin-top: var(--space-2); }
.form-column .actions { margin-top: var(--space-2); }
.form-column .actions .button { margin-top: 0; }
/* The show-password button, inside the field at its right. */
.password-field { position: relative; }
.password-field input { padding-right: 3.25rem !important; }
.password-field button {
  position: absolute; top: 1px; right: 1px; bottom: 1px; width: 3rem;
  display: flex; align-items: center; justify-content: center; padding: 0;
  color: var(--text-muted); background: transparent; border: 0; border-radius: 0 5px 5px 0; cursor: pointer;
}
.password-field button:hover { color: var(--text); }
.password-field svg { width: 1.25rem; height: 1.25rem; }
.password-field [aria-pressed="true"] .eye-open, .password-field [aria-pressed="false"] .eye-shut { display: none; }
/* Another way in (an emailed link, an organisation's sign-in, the course code), under a rule. */
.hub-alt { display: grid; gap: var(--space-4); width: 100%; max-width: var(--form-max); margin-top: var(--space-2) !important; padding-top: var(--space-6); border-top: 1px solid var(--border); }
.hub-alt > * { margin: 0; }
p.hub-alt { display: block; }
.hub-alt .form-column { gap: var(--space-4); }
.login_message { max-width: 48ch; }

/* --- A workspace starting, stopping or waking: the ring beside the heading ---
   The workspace restart page's ring: 20 px, an open segment, one turn a second, in the link
   colour. Decorative: the heading says what is happening. With reduced motion it stands still. */
.hub-busy { display: flex; align-items: center; gap: var(--space-4); }
.hub-busy::after {
  content: ""; flex: none; width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid var(--link); border-right-color: transparent; animation: wr-spin 1s linear infinite;
}
@keyframes wr-spin { to { transform: rotate(360deg); } }
.hub-state [hidden] { display: none !important; }
/* The stopped page's sentence and its button, 24 px apart, as on a task's page. */
.hub-start-now { display: grid; gap: var(--space-6); justify-items: start; }
.hub-start-now > * { margin: 0; }
.hub-start-now[hidden] { display: none; }

/* A destructive action: "Stop workspace" on account home and "Restart workspace" on the restart page. Signal text and border on the page's own background.
   Only the hub has one, so it lives here rather than in the shared theme (move it there if the website
   ever needs one). --danger is #FF9B8F in the dark theme, and a tenant's colours do not replace it. */
.button--danger { background: transparent; color: var(--danger); border-color: currentColor; }
.button--danger:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.button--danger:active { background: color-mix(in srgb, var(--danger) 16%, transparent); }
/* The home page's heading takes focus when it asks "Stop your workspace?". */
#workspace-heading:focus { outline: none; }
#stop-question { margin: var(--space-4) 0 0; max-width: 60ch; }

/* --- Workspace restart (hub/templates/workspace-restart/): its steps, in the link colour --- */
.wr-kept ul { margin: var(--space-2) 0 0; padding-left: 1.25em; }
.wr-kept li + li { margin-top: var(--space-1); }
.hub-main code { color: inherit; font-family: var(--font-mono); overflow-wrap: anywhere; }
.wr-steps { display: grid; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.wr-steps li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-1) 0; color: var(--text-muted); }
.wr-steps li::before {
  content: ""; flex: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--field-border); box-sizing: border-box;
}
.wr-steps li[data-state="current"] { color: var(--text); font-weight: 700; }
.wr-steps li[data-state="current"]::before { border-color: var(--link); border-right-color: transparent; animation: wr-spin 1s linear infinite; }
.wr-steps li[data-state="done"]::before { background: var(--link); border-color: var(--link); }
.wr-steps li[data-state="failed"] { color: var(--danger); font-weight: 700; }
.wr-steps li[data-state="failed"]::before { border-color: var(--danger); }
#wr-heading:focus { outline: none; }

/* --- JupyterHub's Bootstrap pages (admin, API tokens) keep their own layout, a wide table, with the
   theme's type, colours and focus. Their buttons sit in table rows: the smaller 40 px button. --- */
html .btn {
  --bs-btn-font-family: var(--font-text); --bs-btn-font-weight: 700; --bs-btn-border-radius: var(--radius-control);
  --bs-btn-focus-box-shadow: none; display: inline-flex; align-items: center; justify-content: center; min-height: 2.5rem;
}
html .btn:focus-visible, html .nav-link:focus-visible, html .form-check-input:focus-visible,
html .page-link:focus-visible, html .btn-close:focus-visible { outline: 3px solid var(--link); outline-offset: 3px; box-shadow: none; }
html .btn-jupyter, html .btn-primary, html .btn-success {
  --bs-btn-color: var(--on-action); --bs-btn-bg: var(--action); --bs-btn-border-color: transparent;
  --bs-btn-hover-color: var(--on-action); --bs-btn-hover-bg: var(--action-hover); --bs-btn-hover-border-color: transparent;
  --bs-btn-active-color: var(--on-action); --bs-btn-active-bg: var(--action-pressed); --bs-btn-active-border-color: transparent;
  --bs-btn-disabled-color: var(--on-action); --bs-btn-disabled-bg: var(--action); --bs-btn-disabled-border-color: transparent;
}
html .btn-outline-secondary, html .btn-light, html .btn-secondary, html .btn-outline-primary {
  --bs-btn-color: var(--link); --bs-btn-bg: transparent; --bs-btn-border-color: var(--link);
  --bs-btn-hover-color: var(--link); --bs-btn-hover-bg: color-mix(in srgb, var(--link) 10%, transparent); --bs-btn-hover-border-color: var(--link);
  --bs-btn-active-color: var(--link); --bs-btn-active-bg: color-mix(in srgb, var(--link) 16%, transparent); --bs-btn-active-border-color: var(--link);
}
html .btn-danger, html .btn-outline-danger {
  --bs-btn-color: var(--danger); --bs-btn-bg: transparent; --bs-btn-border-color: var(--danger);
  --bs-btn-hover-color: var(--danger); --bs-btn-hover-bg: color-mix(in srgb, var(--danger) 10%, transparent); --bs-btn-hover-border-color: var(--danger);
  --bs-btn-active-color: var(--danger); --bs-btn-active-bg: color-mix(in srgb, var(--danger) 16%, transparent); --bs-btn-active-border-color: var(--danger);
}
html .server-dashboard-container .btn { border: 1px solid var(--bs-btn-border-color); }
html .form-control, html .form-select { color: var(--text); background-color: var(--field-bg); border-color: var(--field-border); }
html .form-control:focus, html .form-select:focus { border-color: var(--link); box-shadow: none; }
html .form-control:focus-visible, html .form-select:focus-visible { outline: 3px solid var(--link); outline-offset: 1px; }
html .form-check-input:checked { background-color: var(--link); border-color: var(--link); }
html .form-label { font-weight: 700; }
html .table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-striped-bg: color-mix(in srgb, var(--text) 4%, transparent); }
html #react-admin-hook .card { --bs-card-bg: var(--surface); --bs-card-border-color: var(--border); --bs-card-cap-bg: var(--surface); --bs-card-border-radius: var(--radius-card); }
html .properties-table .item.selected, html .properties-table-keyvalues .item.selected { color: var(--on-action); background-color: var(--action); }
