/* Day and night. Light is the default and matches the colors the site already
   used (Bootstrap body, the Signet account chrome, and the lesson pages).
   Dark is built from the lesson navy (#10243e) and the account ink.
   --bg stays in step with THEME_COLORS in theme_controller.js
   (light #ffffff, dark #121820) and the head script. Key: uh-theme. */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --ink: #1c1917;
  --muted: #57534e;
  --grid: #e7e5e0;
  --accent: #0369a1;
  --field: #ffffff;
  --line: #c8c4bb;
  --button: #e7e5e0;
  --button-hover: #ddd9d2;
  --hover-wash: rgba(28, 25, 23, 0.06);
  --miss: #9f1239;
  --ok: #166534;
  --lesson-ink: #1c1c1c;
  --lesson-link: #0645ad;
  --lesson-muted: #666666;
  --lesson-goal: #555555;
  --lesson-line: #dddddd;
  --lesson-rule: #bbbbbb;
  --chip-bg: #eef3fb;
  --chip-line: #c6d6ee;
  --quote-bg: #f4f7fb;
  --quote-line: #d5e0ef;
  --navy: #10243e;
  --ok-bg: #d9f2d9;
  --ok-ink: #176117;
  --warn-bg: #f2e6c9;
  --warn-ink: #7a5a12;
  --crumb: #666666;
  /* Diagram and symbol SVG ink is black, so the plate and its caption stay dark-on-white in both themes. */
  --diagram-plate: #ffffff;
  --diagram-ink: #1c1c1c;
  --navbar-bg: #f8f8f8;
  --navbar-ink: #666666;
  --navbar-ink-hover: #333333;
  --navbar-active: #555555;
  --navbar-active-bg: #e7e7e7;
  --navbar-line: #e7e7e7;
  --navbar-toggle: #dddddd;
  --navbar-toggle-bar: #666666;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121820;
  --panel: #1b2433;
  --ink: #e7eef8;
  --muted: #a9b6c9;
  --grid: #2c3a4e;
  --accent: #9cc3f5;
  --field: #0e1520;
  --line: #3a4a60;
  --button: #243246;
  --button-hover: #2e4058;
  --hover-wash: rgba(156, 195, 245, 0.14);
  --miss: #ffb4c0;
  --ok: #8ee0a8;
  --lesson-ink: #e7eef8;
  --lesson-link: #9cc3f5;
  --lesson-muted: #a9b6c9;
  --lesson-goal: #c5d0e0;
  --lesson-line: #3a4a60;
  --lesson-rule: #4a5c74;
  --chip-bg: #1a2c44;
  --chip-line: #3d5c88;
  --quote-bg: #182433;
  --quote-line: #3d5c88;
  --navy: #9cc3f5;
  --ok-bg: #173322;
  --ok-ink: #8ee0a8;
  --warn-bg: #3a2e14;
  --warn-ink: #f0d090;
  --crumb: #a9b6c9;
  --diagram-plate: #ffffff;
  --diagram-ink: #1c1c1c;
  --navbar-bg: #10243e;
  --navbar-ink: #c5d4ea;
  --navbar-ink-hover: #ffffff;
  --navbar-active: #ffffff;
  --navbar-active-bg: #1a3a5c;
  --navbar-line: #1a3a5c;
  --navbar-toggle: #3d5c88;
  --navbar-toggle-bar: #c5d4ea;
}

body {
  background: var(--bg);
  color: var(--ink);
}

.navbar-default {
  background-color: var(--navbar-bg);
  border-color: var(--navbar-line);
}

.navbar-default .navbar-brand,
.navbar-default .navbar-nav > li > a {
  color: var(--navbar-ink);
}

.navbar-default .navbar-brand:hover,
.navbar-default .navbar-brand:focus {
  color: var(--navbar-ink-hover);
  background-color: transparent;
}

.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
  color: var(--navbar-ink-hover);
  background-color: transparent;
}

.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
  color: var(--navbar-active);
  background-color: var(--navbar-active-bg);
}

.navbar-default .navbar-toggle {
  border-color: var(--navbar-toggle);
  background-color: transparent;
}

.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:focus {
  background-color: var(--navbar-active-bg);
}

.navbar-default .navbar-toggle .icon-bar {
  background-color: var(--navbar-toggle-bar);
}

.navbar-default .navbar-collapse,
.navbar-default .navbar-form {
  border-color: var(--navbar-line);
}

html[data-theme="dark"] .content a {
  color: var(--accent);
}

/* Bootstrap paints these as dark gray or dark red, which disappears on the night background. */
html[data-theme="dark"] :is(.text-primary, .text-info, a.text-primary, a.text-info) {
  color: var(--accent);
}

html[data-theme="dark"] :is(.text-success, a.text-success, .has-success :is(.help-block, .control-label, .radio, .checkbox, .radio-inline, .checkbox-inline)) {
  color: var(--ok);
}

html[data-theme="dark"] :is(.text-warning, a.text-warning, .has-warning :is(.help-block, .control-label, .radio, .checkbox, .radio-inline, .checkbox-inline)) {
  color: var(--warn-ink);
}

html[data-theme="dark"] :is(.text-danger, a.text-danger, .has-error :is(.help-block, .control-label, .radio, .checkbox, .radio-inline, .checkbox-inline)) {
  color: var(--miss);
}

html[data-theme="dark"] legend {
  color: var(--ink);
  border-bottom-color: var(--line);
}

/* These keep a light fill in both themes, so the type on them stays dark.
   Night tokens are light ink. Reset them here so a link or .text-* inside
   one of these surfaces resolves to a day color that still clears the fill. */
html[data-theme="dark"] :is(.well, .jumbotron, .thumbnail, .panel, .panel-heading, .panel-footer, .list-group-item, .dropdown-menu, .popover, .modal-content, .breadcrumb, .bg-success, .bg-info, .bg-warning, .bg-danger) {
  color: var(--diagram-ink);
  --ink: #1c1c1c;
  --muted: #57534e;
  --accent: #0369a1;
  --ok: #166534;
  --warn-ink: #7a5a12;
  --miss: #9f1239;
  --lesson-link: #0645ad;
  --lesson-muted: #666666;
  --lesson-goal: #555555;
  --crumb: #666666;
}

html[data-theme="dark"] :is(input, textarea, select, .form-control) {
  color-scheme: light;
}

/* Bootstrap's placeholder is #999 (2.8:1 on the white field). Inputs stay white in both themes.
   Each pseudo is its own rule: an unknown one in a group drops the whole rule. */
.form-control::-webkit-input-placeholder,
input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
  color: #5c5c5c;
  opacity: 1;
}
.form-control::-moz-placeholder,
input::-moz-placeholder,
textarea::-moz-placeholder {
  color: #5c5c5c;
  opacity: 1;
}
.form-control::placeholder,
input::placeholder,
textarea::placeholder {
  color: #5c5c5c;
  opacity: 1;
}

.text-muted,
.help-block,
caption,
:is(h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6) :is(small, .small),
blockquote footer,
blockquote small,
blockquote .small {
  color: var(--muted);
}

.alert a,
html[data-theme="dark"] .content .alert a {
  color: inherit;
}

/* Bootstrap blue #337ab7 is 4.56:1 on white and 4.18:1 on gray (#f5f5f5 / #eee).
   Warning brown #8a6d3b is 4.45:1 on that gray. Day colors below clear it.
   Night mode overrides these again with the day accent and warn-ink. */
:is(.well, .jumbotron, .breadcrumb, .panel-heading) :is(a, .text-primary, .text-info) {
  color: #236aa7;
}
:is(.well, .jumbotron, .breadcrumb, .panel-heading) :is(.text-warning, .has-warning .control-label, .has-warning .help-block) {
  color: #7a5a12;
}

html[data-theme="dark"] .content :is(.breadcrumb, .well, .panel, .dropdown-menu, .modal-content, .list-group-item, .jumbotron, .thumbnail, .bg-success, .bg-info, .bg-warning, .bg-danger) a {
  color: #0369a1;
}

.close,
.close:hover,
.close:focus {
  color: inherit;
  text-shadow: none;
  opacity: 1;
}

.dropdown-header,
.breadcrumb > .active {
  color: #666666;
}

.navbar-default .navbar-nav > li.active > a,
.navbar-default .navbar-nav > li.active > a:hover,
.navbar-default .navbar-nav > li.active > a:focus {
  box-shadow: inset 0 -3px 0 var(--accent);
  font-weight: 700;
}

/* One row: wordmark, section links, theme switch, account.
   A float after Bootstrap's navbar-collapse clearfix drops onto a second row. */
.navbar > .container {
  display: flex;
  align-items: center;
}

.navbar > .container::before,
.navbar > .container::after,
.navbar > .container > .navbar-header::before,
.navbar > .container > .navbar-header::after {
  content: none;
  display: none;
}

.navbar > .container > .navbar-header {
  float: none;
  display: flex;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
  margin-right: 0;
  margin-left: 0;
}

.navbar > .container > .navbar-header .navbar-brand {
  float: none;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
}

.navbar > .container > .navbar-header .navbar-brand .logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 40px;
}

.navbar > .container > .navbar-collapse {
  flex: 1 1 auto;
  min-width: 0;
}

.navbar > .container > .app-chrome__end {
  float: none;
  display: flex;
  align-items: center;
  flex: none;
  gap: 8px;
  max-width: 100%;
  margin: 0;
}

.navbar .app-chrome__end .app-account__name {
  white-space: nowrap;
}

.navbar .app-chrome__end .app-account__label {
  display: inline-block;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

@media (min-width: 768px) {
  .navbar > .container {
    flex-wrap: nowrap;
  }

  /* Links keep one line. The wordmark gives up width before the row wraps. */
  .navbar > .container > .navbar-header {
    flex: 0 1 auto;
  }

  .navbar > .container > .navbar-collapse {
    flex: 0 0 auto;
  }

  .navbar > .container > .navbar-collapse .navbar-nav {
    display: flex;
    float: none;
    flex-wrap: nowrap;
  }

  .navbar > .container > .navbar-collapse .navbar-nav > li {
    float: none;
  }

  .navbar > .container > .app-chrome__end {
    margin-left: auto;
  }
}

.app-theme {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-shadow: none;
  cursor: pointer;
}

.app-theme:hover {
  color: var(--ink);
  background: var(--button-hover);
}

.app-theme:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Light is the default, so the moon (offer night) shows until data-theme=dark. */
.app-theme__sun { display: none; }
.app-theme__moon { display: block; }

html[data-theme="dark"] .app-theme__sun { display: block; }
html[data-theme="dark"] .app-theme__moon { display: none; }

@media (max-width: 767px) {
  .navbar > .container {
    flex-wrap: wrap;
  }

  .navbar > .container > .navbar-header {
    flex: 1 1 0;
    order: 1;
    overflow: hidden;
  }

  .navbar > .container > .navbar-header .navbar-brand {
    height: auto;
    padding: 8px 8px 8px 0;
  }

  .navbar > .container > .app-chrome__end {
    order: 2;
    justify-content: flex-end;
    width: auto;
    margin: 0;
  }

  .navbar > .container > .navbar-toggle {
    float: none;
    order: 3;
    margin: 8px 0 8px 8px;
  }

  .navbar > .container > .navbar-collapse {
    order: 4;
    flex: 1 0 100%;
    margin-right: 0;
    margin-left: 0;
  }

  .navbar > .container > .navbar-collapse .navbar-nav {
    margin-right: 0;
    margin-left: 0;
  }

  .navbar .app-chrome__end .app-account__label {
    max-width: 6.5rem;
  }
}
