/* ==========================================================================
   Banksia Collections Portal: custom design system on top of Bootstrap 4.3
   Direction: an archival reading room. Warm paper, deep warm ink, one ochre
   accent, editorial serif display (Fraunces) with Inter body text.
   All colors are OKLCH tokens; no raw hex outside :root. Modern browsers only
   (Chrome/Edge 111+, Safari 15.4+, Firefox 113+).
   ========================================================================== */

:root {
  /* Brand: one hue, ember/ochre 40 */
  --brand-hue: 40;
  --brand-50:  oklch(97% 0.020 var(--brand-hue));
  --brand-100: oklch(94% 0.045 var(--brand-hue));
  --brand-200: oklch(88% 0.075 var(--brand-hue));
  --brand-300: oklch(80% 0.105 var(--brand-hue));
  --brand-400: oklch(72% 0.140 var(--brand-hue));
  --brand-500: oklch(64% 0.165 var(--brand-hue));
  --brand-600: oklch(56% 0.170 var(--brand-hue));
  --brand-700: oklch(46% 0.150 var(--brand-hue));
  --brand-800: oklch(36% 0.115 var(--brand-hue));
  --brand-900: oklch(26% 0.080 var(--brand-hue));

  --accent:          var(--brand-500);
  --accent-strong:   var(--brand-600);
  --accent-contrast: oklch(98% 0.015 var(--brand-hue));
  --link:            oklch(35% 0.115 var(--brand-hue));

  /* Ink and surfaces: tinted, never pure gray */
  --ink:           oklch(19% 0.020 var(--brand-hue));
  --ink-muted:     oklch(30% 0.022 var(--brand-hue));
  --paper:         oklch(98% 0.009 var(--brand-hue));
  --surface-1:     oklch(96.5% 0.011 var(--brand-hue));
  --surface-2:     oklch(94.5% 0.014 var(--brand-hue));
  --surface-3:     oklch(91.5% 0.017 var(--brand-hue));
  --border:        oklch(89% 0.015 var(--brand-hue));
  --border-strong: oklch(80% 0.022 var(--brand-hue));
  --brand-surface: var(--brand-100);
  --brand-ink:     var(--brand-900);

  /* Signal colors, used only semantically */
  --success: oklch(58% 0.14 150);
  --danger:  oklch(52% 0.19 25);
  --warning: oklch(68% 0.13 75);

  /* Type */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   clamp(1.1rem, 1.05rem + 0.25vw, 1.25rem);
  --text-xl:   clamp(1.3rem, 1.2rem + 0.5vw, 1.6rem);
  --text-2xl:  clamp(1.6rem, 1.4rem + 1vw, 2.2rem);
  --text-3xl:  clamp(2rem, 1.7rem + 1.5vw, 3rem);
  --text-4xl:  clamp(2.4rem, 1.9rem + 2.5vw, 4.2rem);

  --leading-display: 1.05;
  --leading-body: 1.65;
  --tracking-display: -0.02em;
  --tracking-label: 0.08em;

  /* Space: 8pt rhythm */
  --space-3xs: 0.25rem;
  --space-2xs: 0.5rem;
  --space-xs: 0.75rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 4rem;
  --space-section: var(--space-xl);

  /* Radius scale */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 999px;

  /* Motion */
  --dur-fast: 180ms;
  --dur-base: 260ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Elevation: tinted with the brand hue */
  --shadow-1: 0 1px 2px oklch(20% 0.02 var(--brand-hue) / 0.06);
  --shadow-2: 0 4px 12px oklch(20% 0.02 var(--brand-hue) / 0.08);
  --shadow-3: 0 16px 40px oklch(20% 0.02 var(--brand-hue) / 0.12);
  --shadow-brand: 0 8px 24px oklch(55% 0.17 var(--brand-hue) / 0.22);

  --focus-ring: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent-strong);
}

/* ---------- Base ---------- */

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .navbar-brand {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--ink);
}

h1 { font-size: var(--text-4xl); line-height: var(--leading-display); letter-spacing: var(--tracking-display); }
h2 { font-size: var(--text-3xl); line-height: 1.1; }
h3 { font-size: var(--text-xl); }

p { max-width: 70ch; }

a { color: var(--link); }
a:hover { color: var(--brand-900); }

.eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--ink-muted);
  margin-bottom: var(--space-2xs);
}

.section { padding: var(--space-section) 0; }
.section-head { margin-bottom: var(--space-md); }
.section-head p { color: var(--ink-muted); margin-bottom: 0; }

/* ---------- Focus ---------- */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- Navbar ---------- */

.navbar-portal {
  background: var(--paper);
  border-bottom: 1px solid var(--border);
}

.navbar-portal .navbar-brand {
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-display);
  color: var(--ink);
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

.navbar-portal .navbar-brand .brand-mark {
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  border-radius: var(--radius-full);
  background: var(--accent-strong);
  margin-right: 0.4em;
  vertical-align: 0.08em;
}

.navbar-portal .nav-link {
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.navbar-portal .nav-link:hover,
.navbar-portal .nav-link:focus {
  color: var(--ink);
}

.navbar-portal .navbar-toggler {
  border-color: var(--border-strong);
  min-height: 44px;
  min-width: 44px;
}

/* ---------- Buttons ---------- */

.btn-brand,
.btn-outline-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 48px;
  padding: 0.55rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--text-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              background var(--dur-fast) linear,
              border-color var(--dur-fast) linear;
}

.btn-brand {
  background: var(--brand-900);
  color: var(--accent-contrast);
}

.btn-brand:hover,
.btn-brand:focus {
  background: var(--brand-900);
  color: var(--accent-contrast);
  transform: translateY(-2px);
  box-shadow: var(--shadow-brand);
}

.btn-brand:active { transform: translateY(0) scale(0.97); box-shadow: none; }
.btn-brand[disabled] { opacity: 0.65; transform: none; box-shadow: none; cursor: not-allowed; }

.btn-outline-brand {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn-outline-brand:hover,
.btn-outline-brand:focus {
  background: var(--surface-1);
  border-color: var(--ink-muted);
  color: var(--ink);
}

.btn-outline-brand:active { transform: scale(0.97); }

/* ---------- Alerts (Bootstrap alert, custom skin) ---------- */

.alert-portal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: var(--text-sm);
}

.alert-portal .alert-heading {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  margin-bottom: var(--space-3xs);
}

.alert-portal .alert-link { color: var(--link); font-weight: 600; }

.alert-portal--info    { border-left-color: var(--accent-strong); }
.alert-portal--warning { border-left-color: var(--warning); }
.alert-portal--danger { border-left-color: var(--danger); }
.alert-portal--success { border-left-color: var(--success); }

/* ---------- Cards ---------- */

.card-portal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--ink);
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}

.card-portal:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-2);
}

.card-portal .card-title { font-size: var(--text-lg); }

.card-portal .card-body { padding: var(--space-md); }
.card-portal .card-text { font-size: var(--text-sm); color: var(--ink-muted); }
.card-portal .card-meta {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  margin-bottom: var(--space-2xs);
}

/* ---------- Media plates (placeholder imagery) ---------- */

.plate {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-2);
}

.plate svg { display: block; width: 100%; height: auto; }

.plate-caption {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: var(--space-2xs);
}

/* ---------- Status badges ---------- */

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.35em 0.75em;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
}

.badge-status::before {
  content: "";
  width: 0.5em;
  height: 0.5em;
  border-radius: var(--radius-full);
  background: currentColor;
}

.badge-status--open    { background: oklch(93% 0.055 150); color: oklch(29% 0.09 150); }
.badge-status--restricted { background: oklch(92% 0.07 75);  color: oklch(29% 0.09 75); }
.badge-status--sensitive  { background: oklch(92% 0.05 25);  color: oklch(36% 0.13 25); }
.badge-status--closed  { background: oklch(88% 0.012 var(--brand-hue)); color: oklch(27% 0.025 var(--brand-hue)); }
.badge-status--workflow { background: oklch(91% 0.018 var(--brand-hue)); color: oklch(28% 0.028 var(--brand-hue)); }

/* ---------- Protocol chips ---------- */

.protocol-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  padding: 0.3em 0.8em;
  margin: 0 0.4em 0.4em 0;
}

.protocol-chip::before {
  content: "";
  width: 0.45em;
  height: 0.45em;
  border-radius: var(--radius-full);
  background: var(--accent-strong);
  flex: none;
}

.protocol-list { margin: 0; padding: 0; list-style: none; }
.protocol-list li {
  padding: var(--space-2xs) 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}
.protocol-list li:last-child { border-bottom: 0; }
.protocol-list .protocol-name { font-weight: 600; }
.protocol-list .protocol-action { color: var(--ink-muted); display: block; }

/* ---------- Breadcrumb ---------- */

.breadcrumb-portal { background: transparent; padding-left: 0; margin-bottom: 0; }
.breadcrumb-portal .breadcrumb-item a { color: var(--ink-muted); padding-top: 0.65rem; padding-bottom: 0.65rem; }
.breadcrumb-portal .breadcrumb-item a:hover { color: var(--ink); }
.breadcrumb-portal .breadcrumb-item.active { color: var(--ink); }

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

.form-portal label { font-weight: 600; font-size: var(--text-sm); }

.form-portal .form-control,
.form-portal select.form-control {
  min-height: 48px;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: var(--text-base);
}

.form-portal .form-control:focus {
  border-color: var(--accent-strong);
  box-shadow: var(--focus-ring);
  outline: none;
}

.form-portal textarea.form-control { min-height: 120px; }

.form-portal .form-text { font-size: var(--text-xs); color: var(--ink-muted); }

.form-portal .custom-control-label { font-weight: 500; font-size: var(--text-sm); padding-top: 0.75rem; padding-bottom: 0.75rem; }
.form-portal .custom-control-label::before { top: 1rem; }
.form-portal .custom-control-label::after { top: 1rem; }

.form-portal .custom-control-input:checked ~ .custom-control-label::before {
  background-color: var(--accent-strong);
  border-color: var(--accent-strong);
}

/* ---------- Steps ---------- */

.step {
  border-top: 2px solid var(--border);
  padding-top: var(--space-sm);
}

.step-number {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--accent-strong);
  line-height: 1;
}

.step h3 { margin-top: var(--space-2xs); }
.step p { color: var(--ink-muted); font-size: var(--text-sm); }

/* ---------- Details tables ---------- */

.table-portal { font-size: var(--text-sm); }
.table-portal th {
  width: 38%;
  font-weight: 600;
  color: var(--ink-muted);
  border-top: 0;
  padding-left: 0;
}
.table-portal td { border-top: 1px solid var(--border); padding-right: 0; }
.table-portal tr:first-child th,
.table-portal tr:first-child td { border-top: 0; }

/* ---------- Timeline (assessment history) ---------- */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 var(--space-sm) 1.5rem; }
.timeline li::before {
  content: "";
  position: absolute;
  left: 0.3rem;
  top: 0.35rem;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  background: var(--accent-strong);
}
.timeline li::after {
  content: "";
  position: absolute;
  left: 0.53rem;
  top: 1rem;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.timeline li:last-child::after { display: none; }
.timeline .timeline-date { font-size: var(--text-xs); color: var(--ink-muted); letter-spacing: var(--tracking-label); text-transform: uppercase; }
.timeline .timeline-title { font-weight: 600; font-size: var(--text-sm); }
.timeline p { font-size: var(--text-sm); color: var(--ink-muted); margin-bottom: 0; }

/* ---------- Footer ---------- */

.footer-portal {
  border-top: 1px solid var(--border);
  background: var(--surface-1);
  padding: var(--space-lg) 0 var(--space-md);
  margin-top: var(--space-xl);
}

.footer-portal .footer-ack {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  max-width: 72ch;
}

.footer-portal .footer-cols h4 {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--ink-muted);
  font-family: var(--font-body);
  font-weight: 600;
}

.footer-portal .footer-cols a {
  display: block;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  padding: 0.6rem 0;
}

.footer-portal .footer-cols a:hover { color: var(--ink); }

.footer-small {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--ink-muted);
  border-top: 1px solid var(--border);
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
}

/* ---------- Hero ---------- */

.hero { padding: var(--space-xl) 0 var(--space-lg); }

.hero-title { max-width: 20ch; margin: 0; }

.hero-sub {
  font-size: var(--text-lg);
  color: var(--ink-muted);
  max-width: 56ch;
  margin-top: var(--space-sm);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
  margin-top: var(--space-md);
}

/* ---------- Header rows: title and status badge share the line ---------- */

.header-row h1, .header-row h3 { flex: 1 1 0%; min-width: 0; padding-right: var(--space-sm); }
@media (max-width: 767.98px) {
  .header-row h1, .header-row h3 { flex: 0 1 auto; }
}
.header-row .badge-status { flex: 0 0 auto; }

/* ---------- Reveal on scroll ---------- */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 480ms var(--ease-out), transform 480ms var(--ease-out);
}

.js [data-reveal][data-shown] { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js [data-reveal] { opacity: 1; transform: none; transition: none; }
  .card-portal, .btn-brand, .btn-outline-brand { transition: none; }
}
