/* Site-specific overrides on top of sphinx-wagtail-theme (Bootstrap). */

.messages .alert {
  border-radius: 0.375rem;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
}

.messages .alert-error {
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

.messages .alert-warning {
  background-color: #fff3cd;
  border: 1px solid #ffeeba;
  color: #856404;
}

.messages .alert-success {
  background-color: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
}

.messages .alert-info {
  background-color: #d1ecf1;
  border: 1px solid #bee5eb;
  color: #0c5460;
}

.rst-content .article-meta {
  color: var(--secondary);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.rst-content blockquote {
  border-inline-start: 4px solid var(--secondary);
  margin: 1rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  color: var(--secondary);
}

.rst-content code {
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  border-radius: 0.25rem;
  background: rgba(0, 0, 0, 0.06);
}

body.theme-dark .rst-content code {
  background: rgba(255, 255, 255, 0.1);
}

/* Django app templates (legacy Bootstrap class names). */
.app-content fieldset {
  background-color: var(--light);
  border: 1px solid rgba(0, 0, 0, 0.125);
  border-radius: 0.375rem;
  color: #212529;
  margin: 1.5rem 0;
  padding: 1rem;
}

.app-content legend {
  color: #212529;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0 0.25rem;
}

.app-content label {
  color: #212529;
  font-weight: 500;
  margin-right: 0.5rem;
}

body.theme-dark .app-content fieldset {
  background-color: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

body.theme-dark .app-content legend,
body.theme-dark .app-content label {
  color: rgba(255, 255, 255, 0.9);
}

body.theme-dark .app-content select,
body.theme-dark .app-content textarea,
body.theme-dark .app-content input[type="text"],
body.theme-dark .app-content input[type="number"],
body.theme-dark .app-content input[type="url"],
body.theme-dark .app-content input[type="email"],
body.theme-dark .app-content input[type="password"] {
  background-color: #1a1233;
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
}

.app-content select,
.app-content textarea,
.app-content input[type="text"],
.app-content input[type="number"],
.app-content input[type="url"],
.app-content input[type="email"],
.app-content input[type="password"] {
  background-color: #fff;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
  color: #212529;
  padding: 0.375rem 0.75rem;
}

.app-content textarea {
  font-family: var(--font-family-monospace);
  font-size: 0.875rem;
  line-height: 1.5;
  width: 100%;
}

.app-content input[type="submit"],
.app-content input[type="button"],
.app-content input[type="reset"],
.app-content .button {
  background-color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 0.25rem;
  color: #fff;
  cursor: pointer;
  display: inline-block;
  font-weight: 500;
  margin-right: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.375rem 0.75rem;
}

.app-content input[type="submit"]:hover,
.app-content input[type="button"]:hover,
.app-content input[type="reset"]:hover,
.app-content .button:hover {
  filter: brightness(1.08);
}

.app-content .row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

@media (min-width: 768px) {
  .app-content .col-md-2 {
    flex: 0 0 calc(16.666% - 1rem);
  }

  .app-content .col-md-3 {
    flex: 0 0 calc(25% - 1rem);
  }

  .app-content .col-md-4 {
    flex: 0 0 calc(33.333% - 1rem);
  }

  .app-content .col-md-5 {
    flex: 0 0 calc(41.666% - 1rem);
  }

  .app-content .col-md-6 {
    flex: 0 0 calc(50% - 1rem);
  }

  .app-content .col-md-7 {
    flex: 0 0 calc(58.333% - 1rem);
  }

  .app-content .col-md-12 {
    flex: 0 0 100%;
  }
}

.app-content .alert {
  border-radius: 0.375rem;
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
}

.app-content .alert-success {
  background-color: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
}

.app-content .alert-error,
.app-content .alert-danger {
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

.app-content .alert-info {
  background-color: #d1ecf1;
  border: 1px solid #bee5eb;
  color: #0c5460;
}

.app-content .alert-warning {
  background-color: #fff3cd;
  border: 1px solid #ffeeba;
  color: #856404;
}

.app-content pre.success:not(.glyphchar),
.app-content pre.error,
.app-content pre.info {
  border-radius: 0.25rem;
  border: 1px solid rgba(0, 0, 0, 0.125);
  font-family: var(--font-family-monospace);
  font-size: 0.875rem;
  overflow-x: auto;
  padding: 1rem;
}

.app-content pre.success:not(.glyphchar) {
  background-color: #d4edda;
  color: #155724;
}

.app-content pre.error {
  background-color: #f8d7da;
  color: #721c24;
}

.app-content pre.info {
  background-color: #d1ecf1;
  color: #0c5460;
}

.app-content table.table-bordered {
  border-collapse: collapse;
  margin: 1.5rem 0;
  width: 100%;
}

.app-content table.table-bordered th,
.app-content table.table-bordered td {
  border: 1px solid rgba(0, 0, 0, 0.125);
  padding: 0.5rem;
  vertical-align: top;
}

.app-content table.table-striped tbody tr:nth-child(odd) {
  background-color: rgba(0, 0, 0, 0.03);
}

.app-content table.table-bordered caption {
  background-color: var(--light);
  border-bottom: 1px solid rgba(0, 0, 0, 0.125);
  caption-side: top;
  color: #212529;
  display: table-caption;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.65rem 0.75rem;
  text-align: center;
  width: 100%;
}

body.theme-dark .app-content table.table-bordered {
  border-color: rgba(255, 255, 255, 0.28);
}

body.theme-dark .app-content table.table-bordered th,
body.theme-dark .app-content table.table-bordered td {
  border: 1px solid rgba(255, 255, 255, 0.28);
}

body.theme-dark .app-content table.table-striped tbody tr:nth-child(odd) {
  background-color: rgba(255, 255, 255, 0.06);
}

body.theme-dark .app-content table.table-bordered caption {
  background-color: rgba(255, 255, 255, 0.1);
  border-bottom-color: rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.95);
}

body.theme-dark .rst-content .table-bordered,
body.theme-dark .rst-content table.table-bordered {
  border-color: rgba(255, 255, 255, 0.28);
}

body.theme-dark .rst-content .table-bordered th,
body.theme-dark .rst-content .table-bordered td,
body.theme-dark .rst-content table.table-bordered th,
body.theme-dark .rst-content table.table-bordered td {
  border-color: rgba(255, 255, 255, 0.28);
}

body.theme-dark .rst-content .table-striped tbody tr:nth-child(odd) {
  background-color: rgba(255, 255, 255, 0.06);
}

/* Sidebar column chrome (site layout; not the Bluesky widget itself). */
.sidebar-widgets {
  font-size: 0.875rem;
  max-height: 100vh;
  overflow: hidden auto;
  padding-top: 2.4rem;
}

.tree-menu .navlist-menu-level-1,
.tree-menu .navlist-menu-level-2 {
  list-style: none;
  margin: 0.25rem 0 0.5rem;
  padding-left: 1rem;
}

/* Always show nested page-tree items (theme hides ul unless .current). */
.site-toc .toc.tree-menu ul > li ul,
.site-toc .toc.tree-menu > ul .current > ul {
  display: block !important;
}

/* Non-link section labels (Recent Posts / Archive / Tags) match .toc a type. */
.tree-menu .tree-label {
  display: inline-block;
  line-height: 1.25;
  padding: 0.25rem 0;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

/* Rich-text image embed formats (Wagtail classes; styles not bundled by Wagtail).
   Formats emit <figure>/<figcaption> and omit HTML width/height; CSS controls layout. */
figure:has(> img.richtext-image) {
  margin: 1rem 0;
  max-width: 100%;
}

figure:has(> img.richtext-image) > img.richtext-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0;
}

figure:has(> img.richtext-image.full-width) {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 1rem auto;
}

figure:has(> img.richtext-image.full-width) > img.richtext-image {
  width: 100%;
}

/* Center format: figure is full width; image may be narrower (e.g. inline width). */
figure:has(> img.richtext-image.center) {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 100%;
  margin: 1rem auto;
}

figure:has(> img.richtext-image.center) > img.richtext-image {
  width: 100%;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

figure:has(> img.richtext-image.original) {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1rem auto;
}

figure:has(> img.richtext-image.original) > img.richtext-image {
  margin-left: auto;
  margin-right: auto;
}

figure:has(> img.richtext-image.left) {
  float: left;
  margin: 0 1rem 1rem 0;
}

figure:has(> img.richtext-image.right) {
  float: right;
  margin: 0 0 1rem 1rem;
}

figure:has(> img.richtext-image) > figcaption {
  margin-top: 0.35rem;
  font-size: 0.9em;
  line-height: 1.4;
  text-align: center;
  color: var(--color-fg-muted, #666);
}

/* Bare imgs (older body_html) still get fluid sizing. */
img.richtext-image {
  max-width: 100%;
  height: auto;
}

img.richtext-image.full-width,
img.richtext-image.center {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 1rem auto;
}

img.richtext-image.original {
  display: block;
  margin: 1rem auto;
}

img.richtext-image.left {
  float: left;
  margin: 0 1rem 1rem 0;
}

img.richtext-image.right {
  float: right;
  margin: 0 0 1rem 1rem;
}
