@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f7f9fc;
  --primary: #0f1e2d;
  --secondary: #5b6b7a;
  --accent: #1f4fd8;
  --card: #ffffff;
}

/* Prevent sticky header from covering anchored section titles */
:root {
  --header-offset: 72px; /* adjust if your header height changes */
}

section[id] {
  scroll-margin-top: calc(var(--header-offset) + 8px);
}

/* Provide header extra top padding on devices with a notch/status bar.
   Do NOT add the safe-area value again to scroll-padding-top because
   `--header-offset` is derived from `header.offsetHeight` (which already
   includes the `env(safe-area-inset-top)` padding). */
header {
  padding-top: env(safe-area-inset-top);
}

html {
  /* Use header-derived offset only to avoid double-counting the notch inset */
  scroll-padding-top: calc(var(--header-offset) + 8px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--primary);
  line-height: 1.55;
}

header { background: #ffffff; border-bottom: 1px solid #e3e7ee; position: sticky; top: 0; z-index: 100; }
.nav { max-width: 1200px; margin: 0 auto; padding: 0.75rem 2rem; display: flex; justify-content: space-between; align-items: center; }
.logo { font-weight: 600; font-size: 1.2rem; letter-spacing: 0.2px; }
.logo img.logo-icon { height: 1em; width: auto; vertical-align: -2px; margin-right: 0.5em; }
.nav a { margin-left: 2rem; text-decoration: none; color: var(--secondary); font-size: 0.95rem; }

.hero { background: linear-gradient(180deg, #ffffff, #f0f3f9); padding: 2rem 2rem 3rem; text-align: center; }
.hero-inner { max-width: 900px; margin: 0 auto; }
.hero h1 { font-size: 2.6rem; font-weight: 600; margin-bottom: 1.25rem; }
.hero p { font-size: 1.2rem; color: var(--secondary); max-width: 700px; margin: 0 auto; }

section { padding: 2.25rem 2rem; }
.container { max-width: 1200px; margin: 0 auto; }

.pillars, .services, .leadership { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 2rem; }

.card, .leader { background: var(--card); border-radius: 12px; padding: 2rem; box-shadow: 0 10px 30px rgba(0,0,0,0.05); }

img.generic { width: 100%; height: auto; border-radius: 12px; margin-bottom: 1rem; }
.hero .generic { width: auto; height: auto; max-width: none; max-height: none; display: block; margin: 1rem auto; }

/* Constrain the Raleigh page hero to prevent excessive sizing */
#raleigh-hero-img {
  width: 100%;
  max-width: 900px;
  height: auto;
  display: block;
  margin: 1rem auto;
  border-radius: 12px;
}

/* Use intrinsic size for About image but prevent overflow on small viewports */
#about .generic { width: auto; height: auto; max-width: 100%; display: block; margin: 1rem auto; }

/* Leadership headshots */
.leader { display: flex; align-items: flex-start; gap: 1rem; position: relative; }
.leader img.headshot { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: 0 0 64px; }
# Ensure headshots never exceed intended size
.leader img.headshot { max-width: 64px; display: block; }
.leader .meta { display: flex; flex-direction: column; }
.leader .meta strong { font-weight: 600; }
.leader .meta span { color: var(--secondary); font-size: 0.95rem; }

/* Contact icon/link for leadership entries */
.leader .meta .contact-link { margin-left: 0; margin-top: 0.5rem; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; color: var(--secondary); text-decoration: none; }
.leader .meta .contact-link svg { width: 20px; height: 20px; display: block; }
.leader .meta .contact-link:focus { outline: 3px solid rgba(31,79,216,0.16); outline-offset: 2px; }
.leader .meta .contact-link:hover { color: var(--accent); background: rgba(31,79,216,0.06); }

/* Corner placement for contact icon */
.leader .contact-link.corner { position: absolute; top: 12px; right: 12px; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--secondary); text-decoration: none; background: transparent; opacity: 0.9; }
.leader .contact-link.corner svg { width: 16px; height: 16px; display: block; }
.leader .contact-link.corner:focus { outline: 3px solid rgba(31,79,216,0.16); outline-offset: 2px; }
.leader .contact-link.corner:hover { color: var(--accent); background: rgba(31,79,216,0.06); opacity: 1; }

@media (max-width: 480px) {
  .leader .contact-link.corner { top: 8px; right: 8px; width: 24px; height: 24px; }
}

/* Nudge footer contact icon down slightly to align with text */
.contact-blurb .contact-link svg,
.footer-contact .contact-link svg { transform: translateY(3px); }

/* `.no-glitch` marks leader sections excluded from text swaps during glitches */

/* Ensure service images (officespace/boardroom) render the same size */
.services .card img.generic { width: auto; height: auto; max-width: 360px; display: block; margin: 0 auto 1rem; }

h2 { font-size: 1.85rem; font-weight: 600; margin-bottom: 1.1rem; }
h3 { margin-bottom: 0.75rem; font-weight: 500; }
p.muted { color: var(--secondary); }

/* Notice callout used for short announcements/promotions */
.notice-callout {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  background: linear-gradient(90deg, rgba(31,79,216,0.06), rgba(31,79,216,0.02));
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(15,30,45,0.04);
}
.notice-callout a { color: var(--secondary); font-weight: 800; text-decoration: underline; }

@media (max-width: 480px) {
  .notice-callout { padding: 0.7rem 0.8rem; }
}

/* Recruitment-specific tweaks to make the intake notice stand out */
.recruitment-callout {
  display: block;
  margin-top: 1rem;
  font-size: 1rem;
  color: var(--primary);
}
.recruitment-callout strong { color: var(--primary); font-weight: 700; }

/* Branch contact card styling for the Raleigh address block */
.branch-contact {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  background: var(--card);
  padding: 1rem 1.15rem;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(15,30,45,0.04);
  border: 1px solid rgba(15,30,45,0.04);
  margin-top: 1rem;
}
.branch-meta { flex: 1 1 auto; min-width: 0; }
.branch-name { font-weight: 700; font-size: 1.05rem; margin-bottom: 0.15rem; }
.branch-location { color: var(--secondary); font-size: 0.98rem; }
.branch-actions { display: flex; align-items: center; gap: 0.6rem; width: 100%; }
.branch-label { color: var(--secondary); font-weight: 600; margin-right: 0.25rem; }
.branch-email.contact-link,
.branch-email { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.6rem; border-radius: 8px; background: linear-gradient(90deg, rgba(31,79,216,0.04), rgba(31,79,216,0.02)); color: var(--accent); text-decoration: none; border: 1px solid rgba(31,79,216,0.06); }
.branch-email svg { transform: none; }
.branch-email .link-text { font-weight: 600; color: var(--primary); }

@media (max-width: 680px) {
  .branch-contact { flex-direction: column; align-items: flex-start; }
  .branch-actions { width: 100%; justify-content: flex-start; }
}

footer { background: #0f1e2d; color: #c7cfdb; padding: 2rem 2rem; }
footer .container { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 2rem; }
footer a { color: #c7cfdb; text-decoration: none; display: block; margin-bottom: 0.5rem; font-size: 0.9rem; }
.copyright { margin-top: 2rem; font-size: 0.8rem; color: #8e99aa; }

/* Subtle/static TV-noise overlay used during brief ARG "glitches" */
.glitch {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* allow interaction while overlay shows */
  /* place above all site content */
  z-index: 2147483646;
  opacity: 0; /* toggled by .active */
  /* match JS flash duration and provide smoother fade (slower pulse) */
  transition: opacity 1300ms linear;
}

/* two noisy layers to emulate TV static */
.glitch::before,
.glitch::after {
  content: '';
  /* use fixed so the layers truly sit above everything and don't get clipped by other stacking contexts */
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  display: block;
  pointer-events: none;
  z-index: 2147483647;
}

/* stronger, non-blended noise layers for visible TV static */

.glitch::before {
  /* very fine grain (1-2px noise) */
  background-image: linear-gradient(0deg, rgba(255,255,255,0.6) 50%, rgba(0,0,0,0.6) 50%);
  background-size: 2px 2px;
  /* provide a stronger dark base so noise is visible over light pages */
  background-color: rgba(0,0,0,0.65);
  /* increase layer intensity for a darker overall effect */
  opacity: 1;
  /* multiply helps darken bright content underneath so static shows */
  mix-blend-mode: multiply;
  filter: grayscale(100%) contrast(150%);
  /* animate background-position instead of transforming the layer to avoid
     visible seams/diagonal lines from pixel snapping during transforms */
  will-change: background-position;
  /* slower, less frantic grain movement */
  animation: noise-anim-fast 750ms steps(2) infinite;
}


.glitch::after {
  /* coarser grain + scanlines for depth */
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.12) 1px, transparent 1px),
    repeating-linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.05) 2px, transparent 2px, transparent 4px);
  background-size: 5px 5px, 100% 6px;
  /* stronger for darker feel */
  background-color: rgba(0,0,0,0.35);
  opacity: 1;
  /* allow scanlines to darken the page beneath */
  mix-blend-mode: multiply;
  will-change: background-position;
  /* slower, smooth scanline drift */
  animation: noise-anim-slow 1500ms steps(3) infinite reverse;
}

/* active state — visible static */
.glitch.active { opacity: 0.95; }

/* permanent state: stop motion and lighten the static */
.glitch.permanent { opacity: 0.35; }
.glitch.permanent::before,
.glitch.permanent::after {
  animation: none !important;
  mix-blend-mode: normal;
}
.glitch.permanent::before {
  /* much lighter darkening so images remain visible */
  background-color: rgba(0,0,0,0.12);
  filter: grayscale(100%) contrast(105%);
}
.glitch.permanent::after {
  background-color: rgba(0,0,0,0.02);
  filter: none;
}

@keyframes noise-anim-fast {
  0% { background-position: 0px 0px; }
  100% { background-position: 3px -3px; }
}

@keyframes noise-anim-slow {
  0% { background-position: 0px 0px; }
  100% { background-position: -6px 6px; }
}

/* Mobile hamburger menu */
@media (max-width: 768px) {
  .nav {
    position: relative;
    justify-content: flex-start;
    margin: 0;
    padding-left: 0;
  }
  
  .nav nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e3e7ee;
    border-top: none;
    flex-direction: column;
    padding: 1rem 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  }
  
  .nav nav.active {
    display: flex;
  }
  
  .nav nav a {
    margin: 0;
    padding: 0.75rem 2rem;
    border-bottom: 1px solid #f0f3f9;
  }
  
  .nav nav a:last-child {
    border-bottom: none;
  }
  
  .hamburger {
    display: block;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
    width: 40px;
    height: 28px;
    position: relative;
    -webkit-tap-highlight-color: transparent;
  }
  
  .hamburger span {
    position: absolute;
    left: 50%;
    width: 20px;
    height: 2px;
    background: var(--primary);
    transform-origin: center;
    transition: transform 200ms ease, opacity 180ms ease, top 180ms ease;
    margin: 0;
  }

  .hamburger span:nth-child(1) { top: 8px; transform: translateX(-50%); }
  .hamburger span:nth-child(2) { top: 13px; transform: translateX(-50%); }
  .hamburger span:nth-child(3) { top: 18px; transform: translateX(-50%); }

  .hamburger.active span:nth-child(1) {
    top: 13px;
    transform: translateX(-50%) rotate(45deg);
  }

  .hamburger.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-50%) scaleX(0.8);
  }

  .hamburger.active span:nth-child(3) {
    top: 13px;
    transform: translateX(-50%) rotate(-45deg);
  }
}

@media (min-width: 769px) {
  .hamburger,
  .hamburger span {
    display: none !important;
  }
}

/* Preferences form spacing */
.prefs-form fieldset { border: 0; padding: 0; margin: 0; }
.prefs-form .pref-item { margin-bottom: 0.9rem; }
.prefs-form label { display: flex; align-items: center; gap: 0.75rem; font-size: 1rem; color: var(--primary); }
.prefs-form input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; }
.prefs-form .muted { margin-top: 1rem; color: var(--secondary); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Inline error for locked preferences */
.pref-error {
  display: none;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-left: 4px solid var(--accent);
  background: rgba(31, 79, 216, 0.06); /* subtle accent background */
  color: var(--primary);
  font-size: 0.95rem;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(15,30,45,0.03);
}
.pref-error.visible { display: block; }
.pref-error::before {
  content: "Note ";
  font-weight: 700;
  margin-right: 0.45rem;
  color: var(--primary);
}
