/* shell.css -- page shell for every Data@Spark page: base reset over
   Bootstrap/CKAN, mockup C masthead on paper, skip link, flash, breadcrumb, footer,
   global buttons + form controls. Values are copied from Atlas
   (spark-portfolio/atlas/app/globals.css, components/Gallery.tsx masthead,
   components/AuthStrip.tsx); deviations are marked "a11y:" where an Atlas grey
   fails WCAG AA on white and the tokens.css AA grey is used instead.
   Loads after CKAN's /base/css/main.css, before home/search/dataset/pages.css,
   so those files win at equal specificity. */

/* ---------- Base reset (Atlas globals.css body/a/::selection) ---------- */
:root {
  /* Bootstrap reads these for body, so CKAN widgets inherit Atlas type. */
  --bs-body-font-family: var(--sp-body);
  --bs-body-color: var(--sp-ink);
  --bs-body-bg: var(--sp-paper);
  --bs-body-font-size: 15px;
  --bs-body-line-height: 1.55;
}
@media (max-width: 600px) {
  :root { --sp-gutter: 16px; } /* Atlas .spark-gutter at <=600px */
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sp-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--sp-ink);
  background: var(--sp-paper);     /* mockup C paper, every page */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: rgba(15, 163, 146, 0.25); }

a { color: var(--sp-accent-text); text-decoration: none; }
a:hover { color: var(--sp-accent-deep); text-decoration: underline; text-underline-offset: 2px; }

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4 {
  font-family: var(--sp-display);
  font-weight: 700;
  color: var(--sp-ink);
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin: 0 0 0.5em;
}
h1, .h1 { font-size: 30px; }   /* Atlas h1.page */
h2, .h2 { font-size: 22px; }
h3, .h3 { font-size: 17px; font-weight: 600; }
h4, .h4, h5, h6 { font-size: 15px; font-weight: 600; }

/* Atlas focus ring, verbatim. Bootstrap's blurry box-shadow rings are removed below. */
:focus-visible { outline: 2px solid var(--sp-accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Page container ---------- */
.main {
  background: none;
  padding: 0 0 96px;               /* Atlas .wrap bottom padding */
}
#content.container,
.sp-home > .container,             /* CKAN's home template has no #content */
.site-footer > .container {
  width: 100%;
  max-width: calc(var(--sp-col) + 2 * var(--sp-gutter));
  padding-left: var(--sp-gutter);
  padding-right: var(--sp-gutter);
  margin: 0 auto;
}
/* CKAN draws the content area as a bordered white box with a grey rule
   down the sidebar; Atlas has neither. */
.wrapper {
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  min-height: 0;
}
.wrapper::before { display: none !important; }

/* CKAN's generic .module chrome (login, user, admin and any page no area
   overrides): grey heading bar -> Atlas mono section label. Area css files
   load later and override this where they own the page. */
.module-heading {
  background: none;
  border: 0;
  padding: 24px 1.5rem 0;          /* lines up with .module-content's 1.5rem */
  margin: 0;
  font-family: var(--sp-mono);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sp-faint);          /* a11y: Atlas --muted #8a8a8a */
}
.module-content p a.btn:link { text-decoration: none; }

/* ---------- Skip link ---------- */
body > .visually-hidden-focusable:focus-within {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1100;
}
body > .visually-hidden-focusable a {
  display: inline-block;
  font: 600 11.5px/1 var(--sp-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: var(--sp-ink);
  border-radius: 6px;
  padding: 10px 14px;
  text-decoration: none;
}

/* ---------- Masthead (mockup C .mast) ---------- */
.sp-mast {
  background: #fff;
  border-bottom: 1px solid var(--sp-rule);
  padding: 0 var(--sp-gutter);
}
.sp-mast-in {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 68px;
  max-width: var(--sp-col);
  margin: 0 auto;
}
.sp-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
  white-space: nowrap;
}
.sp-brand:hover { text-decoration: none; }
.sp-brand img { width: 36px; height: 36px; border-radius: 50%; display: block; }
.sp-brand b { font: 600 15px/1 var(--sp-display); color: var(--sp-ink); }
.sp-crumb { font: 500 12px/1 var(--sp-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--sp-ink2); }

.sp-navs { margin-left: auto; display: flex; align-items: center; gap: 22px; }
.sp-nav ul,
.sp-account ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 22px;
}
.sp-nav a,
.sp-account a,
.sp-account button {
  display: block;
  font: 500 15px/20px var(--sp-body);
  color: var(--sp-ink);
  background: none;
  border: 0;
  padding: 24px 0;                 /* 20 + 48 = the 68px masthead row */
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.sp-account a, .sp-account button { color: var(--sp-ink2); font-size: 14px; }
.sp-nav a:hover,
.sp-account a:hover,
.sp-account button:hover { color: var(--sp-accent-text); text-decoration: none; }
.sp-nav li.active > a { box-shadow: inset 0 -2px 0 var(--sp-accent); }
.sp-account form { margin: 0; }
.sp-account { display: flex; align-items: center; gap: 22px; }
.sp-account::before { content: ""; width: 1px; height: 16px; background: var(--sp-rule); }
.sp-account a.sp-me { color: var(--sp-accent-text); max-width: 16ch; overflow: hidden; text-overflow: ellipsis; }

/* Narrow: mockup C hides its nav; CKAN needs it, so it drops to a second row. */
@media (max-width: 900px) {
  .sp-mast-in { flex-wrap: wrap; height: auto; row-gap: 0; }
  .sp-brand { height: 60px; }
  .sp-navs {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
    column-gap: 18px;
    row-gap: 0;
    border-top: 1px solid var(--sp-rule2);
  }
  .sp-nav ul, .sp-account ul { flex-wrap: wrap; column-gap: 18px; row-gap: 0; }
  .sp-account { gap: 18px; }
  .sp-nav a, .sp-account a, .sp-account button { font-size: 14px; padding: 11px 0; }
}
@media (max-width: 420px) {
  .sp-account::before { display: none; }
  .sp-nav-out { display: none; }       /* Atlas link: the about page links it too */
}

/* ---------- Flash messages + alerts ---------- */
.flash-messages .alert { margin: 18px 0 0; box-shadow: none; }
.alert {
  font-size: 14.5px;
  line-height: 1.5;
  border: 1px solid var(--sp-line);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--sp-ink);
  background: var(--sp-bg-soft);
}
.alert-dismissible { padding-right: 48px; }       /* room for CKAN's JS-added .btn-close */
.alert-dismissible .btn-close { padding: 15px 16px; }
.alert a { color: inherit; text-decoration: underline; }
/* Atlas admin status palette (ok / amber / danger) */
.alert-success { color: #1f7a4d; background: #e4f4ec; border-color: #bfe6cf; }
.alert-info { color: var(--sp-accent-deep);  /* a11y: accent-text is 4.40:1 on the wash */ background: var(--sp-accent-wash); border-color: color-mix(in oklab, #0fa392 28%, #fff); }
.alert-warning { color: #7a5400;  /* a11y: #9a6a00 is 4.29:1 */ background: #fdf3dd; border-color: #f3e2b3; }
.alert-error, .alert-danger { color: #b3261e; background: #fdeceb; border-color: #f4c7c3; }

/* ---------- Breadcrumb (Atlas "← Back to gallery" link style) ---------- */
.toolbar { margin: 0 0 22px; padding: 22px 0 0; }  /* Atlas back link: margin-bottom 22 */
.toolbar:not(:has(.breadcrumb)) { display: none; }   /* CKAN renders it empty on pages without crumbs */
.toolbar .breadcrumb {
  float: none;
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  font-family: var(--sp-mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--sp-faint);
}
.toolbar .breadcrumb li { padding-left: 0; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar .breadcrumb li + li::before,
.toolbar .breadcrumb li:not(:first-child)::before {
  content: "/";
  float: none;
  padding: 0 8px;
  color: #c4c4c4;
}
.toolbar .breadcrumb a { color: var(--sp-faint); text-decoration: none; }
.toolbar .breadcrumb a:hover { color: var(--sp-ink); }
.toolbar .breadcrumb .active,
.toolbar .breadcrumb .active a { color: var(--sp-ink); }
.toolbar .home i { display: none; }
.toolbar .home span { display: inline; }
@media (max-width: 575.98px) {
  .toolbar .breadcrumb { color: var(--sp-faint); text-shadow: none; }
}

/* ---------- Footer (mockup C: one quiet line on the paper, then mono links) ---------- */
.site-footer {
  background: none;
  border-top: 1px solid var(--sp-rule);
  padding: 28px 0 48px;
  margin-top: 40px;
}
.sp-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px 40px;
}
.sp-foot-about {
  margin: 0;
  max-width: 72ch;
  font-size: 14px;
  line-height: 1.55;
  color: var(--sp-ink2);
}
.sp-foot-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
}
.site-footer .sp-foot-links a {
  font-family: var(--sp-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sp-ink2);
  text-decoration: none;
}
.site-footer .sp-foot-links a:hover { color: var(--sp-ink); }
/* CKAN language selector (footer_lang block) */
.sp-foot .lang-select { flex-basis: 100%; }
.site-footer .sp-foot .lang-select .form-group { flex-direction: row; align-items: center; gap: 10px; width: auto; margin: 0; }
.site-footer .sp-foot .lang-select label { margin: 0; font: 400 10.5px/1 var(--sp-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--sp-faint); }
.site-footer .sp-foot .lang-select label::after { content: none; }
.sp-foot .lang-select select { width: auto; max-width: 100%; }
/* select2 widget CKAN's autocomplete module swaps in for the select */
.sp-foot .lang-container { width: 200px !important; max-width: 100%; }
.sp-foot .lang-container .select2-choice { height: auto; padding: 7px 12px; border: 1px solid var(--sp-field); border-radius: 7px; background: #fff; box-shadow: none; font-size: 13px; color: var(--sp-ink); }
/* select2 focuses an offscreen input, so the ring goes on the visible box */
.sp-foot .lang-container.select2-container-active .select2-choice { border-color: var(--sp-accent); box-shadow: 0 0 0 1px var(--sp-accent); }
.sp-foot .lang-container .select2-choice .select2-arrow { border: 0; background: none; top: 50%; margin-top: -13px; }

/* ---------- Buttons (Atlas .btn / .btn-accent / .btn-ghost / .btn-sm) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 7px;
  white-space: nowrap;
  font-family: var(--sp-display);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  padding: 12px 21px;              /* Atlas 13px 22px, less the 1px border */
  box-shadow: none;
  transition: transform .15s, box-shadow .15s, background .15s, border-color .15s;
}
.btn:hover { text-decoration: none; }
.btn:focus, .btn:active, .btn.active,
.btn-check:focus + .btn, .btn:active:focus { box-shadow: none; }
.btn:focus:not(:focus-visible) { outline: 0; }
/* main.css `.btn:focus{outline:0}` (0,2,0) beats the global :focus-visible ring */
.btn:focus-visible { outline: 2px solid var(--sp-accent); outline-offset: 2px; }

.btn-primary,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active {
  color: #fff;
  background-color: var(--sp-accent-text);   /* a11y: Atlas --accent-d #0a7d70 ~= this */
  border-color: transparent;
}
.btn-primary:hover {
  color: #fff;
  background-color: var(--sp-accent-deep);
  border-color: transparent;
  transform: translateY(-2px);
}

.btn-default, .btn-secondary, .btn-light, .btn-outline-secondary,
.btn-default:focus, .btn-secondary:focus, .btn-light:focus {
  color: var(--sp-sec);
  background-color: #fff;
  border: 1px solid var(--sp-field);
  font-weight: 500;
}
.btn-default:hover, .btn-secondary:hover, .btn-light:hover, .btn-outline-secondary:hover {
  color: var(--sp-ink);
  background-color: #fff !important;  /* CKAN sets this hover with !important */
  border-color: #bdbdbd;
}

.btn-danger, .btn-danger:hover, .btn-danger:focus { color: #fff; background-color: #b3261e; border-color: transparent; }

.btn-sm, .btn-xs, .btn-group-sm > .btn {
  font-family: var(--sp-mono);
  font-size: 11.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
}
.btn-link { color: var(--sp-accent-text); font-weight: 500; padding-left: 0; padding-right: 0; }

/* ---------- Form controls (Atlas .fld + .lab + .hint) ---------- */
.form-control,
.form-select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--sp-field);
  border-radius: 7px;
  font-size: 14.5px;
  font-family: var(--sp-body);
  line-height: 1.4;
  background-color: #fff;
  color: var(--sp-ink);
  box-shadow: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-select { padding-right: 36px; cursor: pointer; }
/* Atlas .fld:focus turns the border accent; the extra 1px ring keeps it a
   visible 2px focus indicator since Bootstrap removes the outline. */
.form-control:focus,
.form-select:focus {
  border-color: var(--sp-accent);
  box-shadow: 0 0 0 1px var(--sp-accent);
  outline: 0;
}
textarea.form-control { min-height: 84px; line-height: 1.5; resize: vertical; }
.form-control::placeholder { color: var(--sp-faint); }  /* a11y: Atlas #aeaeae */
.form-control:disabled, .form-control[readonly] { background-color: var(--sp-bg-soft); }

.form-label,
.control-label {
  display: block;
  font-family: var(--sp-mono);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sp-faint);          /* a11y: Atlas --muted #8a8a8a */
  margin-bottom: 7px;
}
.control-required { color: var(--sp-accent-text); }
.info-block, .form-text { font-size: 12px; line-height: 1.45; color: var(--sp-faint); margin-top: 6px; }
.form-group { margin-bottom: 20px; }
input[type="checkbox"], input[type="radio"], .form-check-input { accent-color: var(--sp-accent-text); }
.form-check-input:checked { background-color: var(--sp-accent-text); border-color: var(--sp-accent-text); }
.form-check-input:focus { box-shadow: none; border-color: var(--sp-accent); }

@media (prefers-reduced-motion: reduce) {
  .btn, .form-control, .form-select { transition: none; }
  .btn-primary:hover { transform: none; }
}
