/* jamesshapiro.com site header: src/styles/global.css via src/lib/site-header.ts. */
.site-header, #nav-animation-stage {
  --bg:          #F7F2E8;
  --bg-deep:     #EFE8D9;
  --paper:       #FFFFFF;
  --ink:         #1A1410;
  --ink-soft:    #3A332D;
  --muted:       #574E44;
  --rule:        #1A1410;
  --accent:      #B33A30;
  --accent-ink:  #7A2520;
  --highlight:   #F2C14E;

  --font-display: Georgia, 'Times New Roman', Times, serif;
  --font-sans:    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --shadow-raised: 4px 4px 0 var(--ink);
  --shadow-sunk:   2px 2px 0 var(--ink);

  --radius: 4px;
}
.site-header { font-family: var(--font-sans); font-size: 16px; line-height: 1.55; color: var(--ink); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.site-header *, .site-header *::before, .site-header *::after { margin: 0; padding: 0; box-sizing: border-box; }
.site-header a, .site-header a:hover { color: inherit; text-decoration: none; }
.site-header .wrap { max-width: 720px; margin: 0 auto; padding: 0 clamp(20px, 4vw, 48px); }
/* ─── Header / Nav ─────────────────────────────────────────────── */
.site-header {
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.98rem;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand-mark, .brand-mark-inv {
  display: inline-grid;
  place-items: center;
  text-align: center;
  width: 1.1em; height: 1.1em;
  font-family: var(--font-display);
  font-size: inherit;
  font-weight: 800;
  line-height: 1;
  vertical-align: baseline;
}
.brand-mark {
  background: var(--accent-ink);
  color: var(--bg);
  position: relative;
  z-index: 2;
}
.brand-mark-inv {
  background: var(--bg);
  color: var(--accent-ink);
  position: relative;
  z-index: 1;
}
.brand .bl {
  display: inline-block;
  transform: translate(var(--x, 0), var(--y, 0));
  animation: brand-ripple 900ms linear infinite paused both;
  /* Rest 410ms into the steady-state ripple (one 900ms period plus 410ms
     back) so the wave is already pronounced before the first hover. */
  animation-delay: calc(var(--i, 0) * 70ms - 1310ms);
}
.brand-gap {
  display: inline-block;
  width: 10px;
}
@keyframes brand-ripple {
  0%, 100% { transform: translate(var(--x, 0), var(--y, 0)); }
  12.5%    { transform: translate(var(--x, 0), calc(var(--y, 0) - 5.66px)); }
  25%      { transform: translate(var(--x, 0), calc(var(--y, 0) - 8px)); }
  37.5%    { transform: translate(var(--x, 0), calc(var(--y, 0) - 5.66px)); }
  50%      { transform: translate(var(--x, 0), var(--y, 0)); }
  62.5%    { transform: translate(var(--x, 0), calc(var(--y, 0) + 5.66px)); }
  75%      { transform: translate(var(--x, 0), calc(var(--y, 0) + 8px)); }
  87.5%    { transform: translate(var(--x, 0), calc(var(--y, 0) + 5.66px)); }
}
@media (hover: hover) {
  .brand:hover .bl {
    animation-play-state: running;
    will-change: transform;
  }
}
html[data-ipad="true"] .brand:hover .bl {
  animation-play-state: running;
  will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
  /* Outranks the site-wide animation: none below so the frozen 410ms frame
     stays; the important shorthand pins play-state, so hover never runs it. */
  .brand .bl {
    animation: brand-ripple 900ms linear infinite paused both !important;
    animation-delay: calc(var(--i, 0) * 70ms - 1310ms) !important;
  }
}
.b-up { position: relative; top: -1px; }
.b-down { position: relative; top: 1px; }
.nav {
  display: flex;
  gap: 20px;
  font-size: 0.84rem;
  font-weight: 500;
}
.nav a { position: relative; padding-bottom: 2px; isolation: isolate; overflow: visible; }
.nav a[aria-current="page"]::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 2px;
  background: var(--accent);
  transition: opacity 180ms cubic-bezier(0.22, 1, 0.36, 1);
}
/* Games & Theory, About and Experiments wear a border of their own (suits, plus signs, Pac-Man).
   With a mouse it shows on hover or keyboard focus, so the bar makes way only then. On touch it
   shows the whole time the section is current (src/scripts/nav-animation.ts), so the bar is not
   drawn there, unless reduced motion keeps the border away. [data-hovered] is the hover as
   src/scripts/nav-animation.ts sees it, which also counts a cursor resting on the tab as the
   page opens; the browser's :hover waits for that cursor to move. */
.nav a[data-nav-animation="home"][aria-current="page"]:is(:hover, [data-hovered])::after,
.nav a[data-nav-animation="home"][aria-current="page"]:focus-visible::after,
.nav a[data-nav-animation="experiments"][aria-current="page"]:is(:hover, [data-hovered])::after,
.nav a[data-nav-animation="experiments"][aria-current="page"]:focus-visible::after,
.nav a[data-nav-animation="about"][aria-current="page"]:is(:hover, [data-hovered])::after,
.nav a[data-nav-animation="about"][aria-current="page"]:focus-visible::after { opacity: 0; }
@media (hover: none) and (pointer: coarse) and (prefers-reduced-motion: no-preference) {
  .nav a[data-nav-animation="home"][aria-current="page"]::after,
  .nav a[data-nav-animation="experiments"][aria-current="page"]::after,
  .nav a[data-nav-animation="about"][aria-current="page"]::after { display: none; }
}
/* Fractal-lightning halo (Approach F). The bolts themselves are generated by
   src/scripts/fractal-lightning.ts. The halo is a cornsilk rect behind the text,
   drawn via ::before so there's no layout shift. */
.nav a::before {
  content: '';
  position: absolute;
  inset: -2px -6px 0 -6px;
  background: transparent;
  border-radius: 3px;
  transition: background-color 180ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: -1;
}
@media (hover: hover) {
  .nav a:is(:hover, [data-hovered])::before,
  .nav a:focus-visible::before {
    background: #FFF8DC;
  }
}
html[data-ipad="true"] .nav a:is(:hover, [data-hovered])::before {
  background: #FFF8DC;
}
.nav a:focus-visible::before {
  background: #FFF8DC;
}
@media (prefers-reduced-motion: reduce) {
  .nav a:is(:hover, [data-hovered]),
  .nav a:focus-visible { color: var(--accent-ink); }
}

.nav-wrap-sm { display: none; }

/* Selected touch animations occupy their own row and scroll with the page.
   Keep this space while paused offscreen so scrolling never moves the content. */
#nav-animation-stage {
  position: relative;
  pointer-events: none;
  overflow: hidden;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
}
#nav-animation-stage[data-unavailable="true"] { display: none; }
#nav-animation-stage[data-animation="home"] {
  height: calc(min(360px, 75vw - 18px) + 17px);
}
#nav-animation-stage[data-animation="about"] { height: 280px; }
#nav-animation-stage[data-animation="experiments"] { height: 510px; }
#nav-animation-stage .hx-j-grid {
  grid-template-columns: repeat(2, minmax(0, 150px));
  grid-template-rows: repeat(6, 70px);
  justify-content: center;
}
#nav-animation-stage .hx-j-cell { width: 100%; }
@media (min-width: 660px) {
  #nav-animation-stage[data-animation="experiments"] { height: 300px; }
  #nav-animation-stage .hx-j-grid {
    grid-template-columns: repeat(4, 150px);
    grid-template-rows: repeat(3, 70px);
  }
}

@media (max-width: 575px) {
  .site-header .wrap { gap: 12px; }
  .brand { font-size: 0.85rem; letter-spacing: 0.5px; }
  .nav {
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 16px;
    row-gap: 6px;
    font-size: 0.78rem;
    line-height: 1.2;
    text-align: right;
    justify-items: end;
  }
  .nav a { padding-bottom: 0; }
  .nav a[aria-current="page"]::after { bottom: -2px; }
  .nav-wrap-sm { display: inline; }
}

@media (max-width: 460px) {
  .site-header .wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .brand { align-self: center; }
  .nav {
    grid-template-columns: repeat(4, 1fr);
    column-gap: 8px;
    row-gap: 0;
    justify-items: stretch;
    text-align: center;
    font-size: 0.74rem;
  }
  .nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2px 0;
  }
}
