/* ==========================================================================
   Base layer
   Element-level styling and utilities layered on top of Oscar's Bootstrap 4.
   Direction-agnostic throughout: physical left/right is expressed with CSS
   logical properties (margin-inline-start, inset-inline-end, ...) so the same
   file serves both LTR and RTL without a build step.
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background-color: var(--color-background);
  /* Anchors should not disappear under the sticky header. --header-offset
     rather than --navbar-height: the sticky element is the whole
     .header.container, which is both bars, so using one bar's height left
     anchored headings hidden underneath. */
  scroll-padding-top: calc(var(--header-offset) + var(--space-4));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* --- Headings ---------------------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
  font-family: var(--font-sans);
  color: var(--color-text);
  font-weight: 600;
  line-height: var(--line-height-heading);
  letter-spacing: -0.01em;
}

h1,
.h1 {
  font-size: var(--font-size-2xl);
}
h2,
.h2 {
  font-size: var(--font-size-xl);
}
h3,
.h3 {
  font-size: var(--font-size-lg);
}

.page-header h1,
#content_inner h1 {
  font-size: var(--font-size-2xl);
  font-weight: 600;
  margin-bottom: var(--space-2);
  letter-spacing: -0.015em;
}

.page-header {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-5);
}

/* --- Links -------------------------------------------------------------- */

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover,
a:focus {
  color: var(--color-primary-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --- Focus: always visible, never removed ------------------------------- */

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

/* Fallback for engines without :focus-visible */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
}

a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
  box-shadow: var(--shadow-focus);
  outline: none;
}

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-4);
  top: -100px;
  z-index: 2000;
  padding: var(--space-3) var(--space-4);
  background: var(--color-primary);
  color: #fff;
  border-radius: 0 0 var(--radius) var(--radius);
  font-weight: 600;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
  color: #fff;
  text-decoration: none;
}

/* --- Forms -------------------------------------------------------------- */

.form-control,
.form-select,
select.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="number"],
textarea.form-control {
  font-family: inherit;
  font-size: var(--font-size-base);
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control::placeholder {
  color: var(--color-muted);
  opacity: 0.75;
}

.form-control:focus,
.form-control:focus:focus-visible {
  background-color: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
  outline: none;
}

label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.form-text,
.helptext,
.help-block {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

/* Django's default error widget */
.errorlist {
  list-style: none;
  margin: var(--space-1) 0 0;
  padding: 0;
  color: var(--color-danger);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.errorlist li {
  margin-bottom: 2px;
}

.invalid-feedback,
.field-errors {
  color: var(--color-danger);
}

/* --- Tables ------------------------------------------------------------- */

table {
  color: var(--color-text);
}

.table {
  border-color: var(--color-border);
}

.table th,
.table thead th {
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-primary-softer);
  padding: var(--space-3);
}

.table td {
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
  vertical-align: middle;
}

.table-hover tbody tr:hover {
  background-color: var(--color-primary-softer);
}

/* --- Breadcrumbs -------------------------------------------------------- */

.breadcrumb {
  background: transparent;
  padding: 0;
  margin-bottom: var(--space-4);
  font-size: var(--font-size-sm);
}

.breadcrumb-item + .breadcrumb-item::before {
  color: var(--color-border-strong);
}

.breadcrumb-item.active {
  color: var(--color-muted);
}

/* --- Alerts ------------------------------------------------------------- */

.alert {
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: var(--font-size-base);
  padding: var(--space-3) var(--space-4);
}

.alert-success {
  color: var(--color-success);
  background-color: var(--color-success-bg);
  border-color: rgba(47, 125, 93, 0.22);
}

.alert-danger,
.alert-error {
  color: var(--color-danger);
  background-color: var(--color-danger-bg);
  border-color: rgba(163, 58, 69, 0.22);
}

.alert-warning {
  color: var(--color-warning);
  background-color: var(--color-warning-bg);
  border-color: rgba(138, 106, 31, 0.22);
}

.alert-info {
  color: var(--color-info);
  background-color: var(--color-info-bg);
  border-color: rgba(53, 97, 125, 0.22);
}

/* --- Utilities ---------------------------------------------------------- */

.text-muted,
.muted {
  color: var(--color-muted) !important;
}

.container {
  max-width: var(--container-max);
}

/* Restrained section rhythm on top of Oscar's page wrapper. */
.content {
  line-height: var(--line-height-base);
}

.page {
  padding-top: var(--space-5);
  padding-bottom: var(--space-7);
}

.page_inner {
  width: 100%;
}

#content_inner {
  min-height: 12rem;
}

hr {
  border-top: 1px solid var(--color-border);
  opacity: 1;
}

/* Selection colour, theme-tinted. */
::selection {
  background: var(--color-accent-soft);
  color: var(--color-primary-dark);
}
