/* ==========================================================================
   The Safety Apprentice — shared site chrome
   Edit this file, not the generated HTML. Run `python3 build.py` to rebuild.

   Per-page accent colours and content width come from CSS custom properties
   set by the base template from each page's `accent` / `content_width`.
   ========================================================================== */

:root {
  --paper: #F8F3EC;
  --card: #FFFCF7;
  --ink: #2C2520;
  --ink-body: #4A413A;
  --ink-soft: #6B6058;
  --ink-faint: #8B7E72;
  --ink-dim: #A89E94;
  --line: #E8E0D4;
  --line-strong: #E0D6C8;

  /* overridden per page */
  --accent: #B85C38;
  --accent-2: #C2793D;
  --accent-3: #A45B5B;
  --content-width: 720px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
/* The navbar is fixed, so anything scrolled to via an in-page link would land
   underneath it. Keep every potential anchor target clear of it. */
[id] { scroll-margin-top: 90px; }
body {
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-family: 'DM Sans', sans-serif;
  color: var(--ink);
}
::selection { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--ink); }

@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-2%, -2%); }
  30% { transform: translate(3%, -1%); }
  50% { transform: translate(-1%, 3%); }
  70% { transform: translate(2%, 1%); }
  90% { transform: translate(-3%, 2%); }
}
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* film grain overlay */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 1000; opacity: 0.025;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  animation: grain 4s steps(6) infinite;
}

/* --------------------------------------------------------------- map bg -- */
.map-bg {
  position: absolute; top: 0; left: 0; right: 0; height: 900px;
  overflow: hidden; pointer-events: none; z-index: 0;
}
.map-bg__img {
  position: absolute; inset: 0; top: -300px;
  background-image: url('neurons.png');
  background-size: cover; background-position: center; background-repeat: no-repeat;
  opacity: 0.10; filter: saturate(0.4) sepia(0.25);
}
.map-bg__fade-bottom {
  position: absolute; bottom: 0; left: 0; right: 0; height: 350px;
  background: linear-gradient(to top, var(--paper) 0%, var(--paper) 15%, transparent 100%);
}
.map-bg__fade-top {
  position: absolute; top: 0; left: 0; right: 0; height: 80px;
  background: linear-gradient(to bottom, var(--paper) 0%, transparent 100%);
}

/* ------------------------------------------------------------------ nav -- */
.nav-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 16px 32px; display: flex; align-items: center;
  justify-content: space-between; transition: all 0.35s ease;
}
.nav-bar.scrolled {
  background: rgba(248, 243, 236, 0.88);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(232, 224, 212, 0.13);
  padding: 12px 32px;
}
.nav-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav-logo__icon {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, #B85C38 0%, #C2793D 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(184, 92, 56, 0.25);
  color: #FFFFFF;                 /* the shield, not the tile */
}
.nav-logo__icon svg { width: 20px; height: 20px; display: block; }
.nav-logo__text {
  font-family: 'Lora', serif; font-weight: 700; font-size: 18px; color: var(--ink);
}
.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-link {
  font-size: 13.5px; font-weight: 500; color: var(--ink-soft); text-decoration: none;
  padding: 8px 14px; border-radius: 8px; transition: all 0.2s ease;
}
.nav-link:hover { background: rgba(184, 92, 56, 0.06); }
.nav-link--cta {
  margin-left: 6px; font-weight: 600; color: #FFFCF7;
  background: linear-gradient(135deg, #B85C38 0%, #C2793D 100%);
  padding: 8px 16px; border-radius: 8px;
  box-shadow: 0 2px 8px rgba(184, 92, 56, 0.2);
}
.nav-link--cta:hover {
  background: linear-gradient(135deg, #B85C38 0%, #C2793D 100%);
  box-shadow: 0 4px 14px rgba(184, 92, 56, 0.3);
}
.nav-group { position: relative; }
.nav-link--group {
  font-family: inherit; font-size: 13.5px; font-weight: 500; color: var(--ink-soft);
  background: none; border: none; cursor: pointer;
  padding: 8px 14px; border-radius: 8px; transition: all 0.2s ease;
  display: inline-flex; align-items: center; gap: 6px;
}
.nav-link--group:hover { background: rgba(184, 92, 56, 0.06); color: var(--ink); }
.nav-caret {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; flex-shrink: 0; opacity: 0.7;
  transition: transform 0.2s ease;
}
.nav-caret svg { width: 100%; height: 100%; display: block; }
.nav-group.open > .nav-link--group { background: rgba(184, 92, 56, 0.08); color: var(--ink); }
.nav-group.open .nav-caret { transform: rotate(180deg); }
.nav-group--active > .nav-link--group { color: #B85C38; }
.nav-link[aria-current="page"], .nav-menu a[aria-current="page"] {
  color: #B85C38; font-weight: 600;
}
.nav-menu {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 208px;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: rgba(255, 252, 247, 0.97);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 36px rgba(120, 80, 40, 0.14), 0 3px 10px rgba(120, 80, 40, 0.06);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}
.nav-group.open .nav-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.nav-menu a {
  font-size: 13.5px; font-weight: 500; color: var(--ink-soft); text-decoration: none;
  padding: 9px 12px; border-radius: 8px; white-space: nowrap; transition: all 0.2s ease;
}
.nav-menu a:hover { background: rgba(184, 92, 56, 0.07); color: var(--ink); }
.nav-toggle {
  display: none; font-size: 18px; line-height: 1; color: var(--ink);
  background: none; border: none; cursor: pointer;
  padding: 8px 10px; border-radius: 8px; transition: background 0.2s ease;
}
.nav-toggle:hover { background: rgba(184, 92, 56, 0.06); }

@media (max-width: 880px) {
  .nav-bar, .nav-bar.scrolled { padding: 12px 18px; }
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute; top: 100%; left: 12px; right: 12px;
    display: none; flex-direction: column; align-items: stretch; gap: 2px;
    padding: 10px; border: 1px solid var(--line); border-radius: 14px;
    background: rgba(248, 243, 236, 0.98);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 14px 36px rgba(120, 80, 40, 0.14);
    max-height: calc(100vh - 90px); overflow-y: auto;
  }
  .nav-links.open { display: flex; }
  .nav-link--cta { margin-left: 0; margin-top: 6px; text-align: center; }
  .nav-group { position: static; }
  /* full-width rows in the panel: bigger text, and a caret you can actually aim at */
  .nav-link, .nav-link--group { font-size: 15px; padding: 11px 14px; }
  .nav-link--group { width: 100%; justify-content: space-between; }
  .nav-caret { width: 28px; height: 28px; opacity: 0.85; }
  .nav-menu a { font-size: 14.5px; padding: 10px 12px; }
  .nav-menu {
    position: static; opacity: 1; visibility: visible; transform: none;
    display: none; background: none; border: none; box-shadow: none;
    padding: 2px 0 6px 12px; min-width: 0;
  }
  .nav-group.open .nav-menu { display: flex; }
  .nav-menu a { white-space: normal; }
}

/* ----------------------------------------------------------------- hero -- */
.hero {
  text-align: center; padding: 140px 32px 40px;
  max-width: 780px; margin: 0 auto; position: relative; z-index: 1;
}
.hero h1 {
  font-family: 'Lora', serif; font-size: clamp(36px, 5.5vw, 58px);
  font-weight: 700; color: var(--ink); line-height: 1.15; margin-bottom: 20px;
  animation: fadeInUp 0.8s ease both; animation-delay: 0.2s;
}
.hero h1 span, .hero h1 .accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-2), var(--accent-3));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p.tagline, .hero p.lede {
  font-size: 18px; color: var(--ink-soft); line-height: 1.7;
  max-width: 600px; margin: 0 auto;
  animation: fadeInUp 0.8s ease both; animation-delay: 0.35s;
}

.divider {
  width: 48px; height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  margin: 40px auto 56px; opacity: 0.5; position: relative; z-index: 1;
}

/* -------------------------------------------------------------- content -- */
.content {
  max-width: var(--content-width); margin: 0 auto; padding: 0 32px;
  position: relative; z-index: 1;
}

.fade-in {
  opacity: 0; transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.fade-in.visible { opacity: 1; transform: translateY(0); }

/* ------------------------------------------------------- item cards -- */
/* A grid of comparable items as cards. Used by fellowships and funding,
   where the entries are things you weigh up rather than scan past.
   Accent colours come from the page's --accent. */

.items-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.item {
  background: var(--card); border-radius: 16px; border: 1px solid var(--line);
  padding: 24px 24px 20px; position: relative;
  transition: all 0.35s cubic-bezier(0.23, 1, 0.32, 1);
  box-shadow: 0 2px 8px rgba(120, 80, 40, 0.04);
}
.item:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(120, 80, 40, 0.1), 0 4px 12px rgba(120, 80, 40, 0.05);
}
.item__type {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 8px;
}
.item__name {
  font-family: 'Lora', serif; font-size: 19px; font-weight: 600;
  color: var(--ink); margin-bottom: 8px; line-height: 1.3;
}
.item__desc {
  font-size: 14px; color: var(--ink-soft); line-height: 1.6; margin-bottom: 14px;
}
.item__meta { display: flex; flex-wrap: wrap; gap: 8px; }
.item__tag {
  font-size: 11.5px; font-weight: 500; color: var(--ink-faint);
  background: rgba(240, 233, 223, 0.85); border: 1px solid var(--line-strong);
  padding: 4px 10px; border-radius: 100px;
}
.item__tag--highlight {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  border-color: color-mix(in srgb, var(--accent) 15%, transparent);
}

/* cards that are themselves links */
a.item { display: block; text-decoration: none; color: inherit; }
.item__go {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 14px;
  font-size: 12.5px; font-weight: 600; color: var(--accent);
  opacity: 0.6; transition: all 0.3s ease;
}
a.item:hover .item__go { opacity: 1; transform: translateX(3px); }

@media (max-width: 720px) {
  .items-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------- directory listings -- */
/* A scannable list of comparable items: one hairline-separated row each,
   no boxes or shadows. Used by fellowships, conferences and geography.
   Picks up the page accent automatically via --accent. */

.group { margin-bottom: 52px; }
.group:last-of-type { margin-bottom: 0; }
.group__head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding-bottom: 12px; border-bottom: 2px solid var(--ink);
}
.group__icon { font-size: 20px; line-height: 1; }
.group__name {
  font-family: 'Lora', serif; font-size: 22px; font-weight: 600;
  color: var(--ink); margin: 0;
}
.group__count {
  font-size: 12px; font-weight: 600; color: var(--ink-faint);
  margin-left: auto; white-space: nowrap;
}

.rows { display: block; }

/* the rows pattern has its own top padding; the card grid does not */
.group__head + .items-grid { margin-top: 20px; }
.row {
  display: block; text-decoration: none; color: inherit;
  padding: 22px 0 20px; border-bottom: 1px solid var(--line);
  transition: padding 0.25s ease;
}
a.row:hover { padding-left: 10px; }
a.row:hover .row__name { color: var(--accent); }
a.row:hover .row__go { opacity: 1; transform: translateX(3px); }
a.row:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.row__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin-bottom: 6px;
}
.row__name {
  font-family: 'Lora', serif; font-size: 19px; font-weight: 600;
  color: var(--ink); line-height: 1.3; transition: color 0.25s ease;
}
.row__where {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--accent);
  white-space: nowrap; flex-shrink: 0;
}
.row__desc {
  font-size: 14.5px; color: var(--ink-soft); line-height: 1.65;
  margin: 0; max-width: 74ch;
}
.row__tags {
  display: flex; flex-wrap: wrap; margin-top: 10px;
  font-size: 12.5px; color: var(--ink-faint);
}
.row__tags span:not(:last-child)::after {
  content: '·'; margin: 0 8px; opacity: 0.55;
}
.row__tags .hl { color: var(--accent); font-weight: 600; }
.row__go {
  display: inline-block; margin-top: 12px;
  font-size: 12.5px; font-weight: 600; color: var(--accent);
  opacity: 0.55; transition: all 0.25s ease;
}

@media (max-width: 620px) {
  .row__head { flex-direction: column; gap: 4px; }
  .row__where { align-self: flex-start; }
  a.row:hover { padding-left: 0; }
}

/* ------------------------------------------------------------- consult -- */
/* Site-level CTA shown at the foot of every page. Deliberately kept in the
   brand terracotta rather than the page accent, so it reads as chrome. */
.consult-wrap {
  max-width: var(--content-width); margin: 72px auto 0; padding: 0 32px;
  position: relative; z-index: 1;
}
.consult {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid #B85C38;
  border-radius: 14px; padding: 24px 28px;
  box-shadow: 0 2px 8px rgba(120, 80, 40, 0.04);
}
.consult__icon { font-size: 30px; line-height: 1; }
.consult__text { flex: 1 1 340px; }
.consult__title {
  font-family: 'Lora', serif; font-size: 18px; font-weight: 600;
  color: var(--ink); margin: 0 0 6px;
}
.consult__desc { font-size: 14.5px; color: var(--ink-soft); margin: 0; line-height: 1.6; }
.consult__link {
  flex: 0 0 auto; font-size: 14.5px; font-weight: 600; text-decoration: none;
  color: var(--card); background: linear-gradient(135deg, #B85C38 0%, #C2793D 100%);
  padding: 12px 22px; border-radius: 10px; transition: all 0.25s ease;
  box-shadow: 0 2px 8px rgba(184, 92, 56, 0.2);
}
.consult__link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(184, 92, 56, 0.28);
}

@media (max-width: 720px) {
  .consult-wrap { margin-top: 52px; padding: 0 20px; }
  .consult { padding: 22px 20px; }
  .consult__link { width: 100%; text-align: center; }
}

/* --------------------------------------------------------------- footer -- */
.footer {
  border-top: 1px solid var(--line-strong); padding: 40px 32px;
  text-align: center; margin-top: 80px; position: relative; z-index: 1;
}
.footer p { font-size: 13.5px; color: var(--ink-faint); line-height: 1.7; }
.footer p.small { font-size: 12px; color: var(--ink-dim); margin-top: 12px; }
.footer a {
  color: var(--ink-faint); text-decoration: underline; text-underline-offset: 3px;
  transition: color 0.2s ease;
}
.footer a:hover { color: #B85C38; }

@media (max-width: 720px) {
  .content { padding: 0 20px; }
  .hero { padding: 120px 20px 40px; }
}
