/* =========================================================================
   BRAIN — homepage: canvas, sidebar nav, tour button, callout
   (the identity header is global — see base.css .site-header)
   ========================================================================= */

/* --- Canvas & vignette --- */
#home-view {
  position: fixed; inset: 0;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--ink);
  transition: opacity var(--dur-med) var(--ease-cine);
}
#home-view[hidden] { display: none !important; }

.brain-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  transition: opacity var(--dur-slow) var(--ease-cine);
}
.brain-canvas:active { cursor: grabbing; }
.brain-canvas.is-region { cursor: pointer; }

.brain-vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 120% at 50% 46%, transparent 50%, rgba(0,0,0,.62) 100%);
}

/* --- Dive flash: accent bloom during the plunge into a region --- */
.dive-flash {
  position: fixed; inset: 0; z-index: 40;
  pointer-events: none; opacity: 0;
  background:
    radial-gradient(120% 120% at 50% 50%, var(--flash, #22d3ee) 0%, transparent 55%);
  mix-blend-mode: screen;
  will-change: opacity, transform;
}
.dive-flash.is-firing { animation: dive-flash .8s var(--ease-cine) forwards; }
@keyframes dive-flash {
  0%   { opacity: 0; transform: scale(1.4); }
  60%  { opacity: .72; }
  100% { opacity: 0; transform: scale(.96); }
}
@media (prefers-reduced-motion: reduce) {
  .dive-flash.is-firing { animation: none; }
}

/* --- Tour button (lives in the header slot) --- */
.tour-btn {
  display: inline-flex; align-items: center; gap: 9px;
  height: 40px; padding: 0 15px 0 13px;
  border-radius: 999px;
  border: 1px solid var(--hairline-2);
  background: rgba(10,13,20,.55);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--ink);
  font-family: var(--font-mono); font-size: .7rem;
  letter-spacing: .08em; text-transform: uppercase;
  transition: border-color .28s, color .28s, background .28s;
}
.tour-btn:hover { border-color: rgba(34,211,238,.4); color: var(--ink-hi); }
.tour-btn.is-playing {
  border-color: rgba(34,211,238,.55);
  color: var(--ink-hi);
  background: rgba(14,18,28,.75);
}
.tour-btn__icon { display: inline-flex; width: 15px; height: 15px; color: var(--cyan); }

/* --- Left panel (sidebar) --- */
.home-panel {
  position: absolute;
  left: clamp(20px, 3.4vw, 44px);
  top: clamp(120px, 21vh, 240px);
  z-index: 6;
  width: min(340px, 42vw);
  display: flex; flex-direction: column; gap: 22px;
  pointer-events: none;
}
.home-panel__intro {
  margin: 0; max-width: 30ch;
  font-weight: 300; font-size: .98rem; line-height: 1.55;
  color: var(--ink-mut); letter-spacing: .005em;
}
.home-panel__nav-wrap {
  display: flex; flex-direction: column; gap: 9px;
  pointer-events: auto;
}
.home-panel__kicker {
  font-family: var(--font-mono); font-size: .62rem;
  letter-spacing: .24em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 2px;
}

/* Region navigation buttons */
.region-nav { display: flex; flex-direction: column; gap: 4px; }

.region-nav__item {
  all: unset; box-sizing: border-box;
  cursor: pointer;
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; border-radius: 11px;
  border: 1px solid transparent;
  transition: background .26s var(--ease-cine), border-color .26s, transform .26s var(--ease-cine);
}
.region-nav__item:hover,
.region-nav__item.is-active {
  background: rgba(14,18,28,.72);
  border-color: color-mix(in srgb, var(--item-accent, var(--cyan)) 45%, transparent);
  transform: translateX(3px);
}
/* all:unset above strips the default focus ring — restore a visible one */
.region-nav__item:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
.region-nav__dot {
  width: 9px; height: 9px; border-radius: 2px; flex: none;
  background: var(--item-accent, var(--cyan));
  box-shadow: 0 0 10px var(--item-accent, var(--cyan));
  opacity: .85;
}
.region-nav__col { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.region-nav__label {
  font-family: var(--font-display); font-weight: 600;
  font-size: .98rem; color: var(--ink-hi);
  letter-spacing: -.01em; line-height: 1.15;
}
.region-nav__lobe {
  font-family: var(--font-mono); font-size: .6rem;
  letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-faint);
}

/* --- Callout card --- */
.callout {
  position: fixed; left: 0; top: 0; z-index: 8;
  pointer-events: none;
  opacity: 0; transform: translateY(4px);
  transition: opacity .3s var(--ease-cine), transform .3s var(--ease-cine);
  width: 230px;
}
.callout.is-visible { opacity: 1; transform: translateY(0); }
.callout__inner {
  border-radius: 13px;
  border: 1px solid var(--hairline-2);
  background: linear-gradient(180deg, rgba(14,18,28,.94), rgba(8,10,16,.94));
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 22px 55px rgba(0,0,0,.5);
  padding: 13px 15px;
}
.callout__head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.callout__dot {
  width: 8px; height: 8px; border-radius: 2px; flex: none;
  background: var(--cyan); box-shadow: 0 0 10px var(--cyan);
}
.callout__kicker {
  font-family: var(--font-mono); font-size: .58rem;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.callout__title {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.02rem; color: var(--ink-hi);
  letter-spacing: -.01em; margin-bottom: 5px;
}
.callout__desc { font-size: .8rem; line-height: 1.45; color: var(--ink-mut); }

/* Marker on the cortex */
.callout-marker {
  position: fixed; left: 0; top: 0; z-index: 7;
  pointer-events: none; opacity: 0;
  transform: translate(-50%, -50%);
  transition: opacity .3s;
}
.callout-marker.is-visible { opacity: 1; }
.callout-marker span {
  display: block; width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.8);
  box-shadow: 0 0 12px rgba(255,255,255,.5);
}

/* Mobile-only lead: on desktop the intro paragraph frames the concept */
.home-lead { display: none; }

/* =========================================================================
   RESPONSIVE — mobile / tablet (≤1024px, incl. iPad Pro portrait):
   full-bleed brain backdrop + a floating content sheet over the lower third,
   echoing the desktop full-bleed canvas without copying its side-panel layout.
   NOTE: 1024 is the single layout breakpoint — kept in sync with
   brain-scene._syncMode() and main.js so the 3D framing never disagrees with
   the page layout at medium (tablet) widths.
   ========================================================================= */
@media (max-width: 1024px) {
  /* the brain is the full-bleed backdrop, filling the whole viewport height */
  .brain-canvas,
  .brain-vignette {
    inset: 0; top: 0; left: 0; right: 0;
    width: 100%; height: 100vh; height: 100svh;
  }
  .brain-vignette {
    background: radial-gradient(118% 82% at 50% 33%, transparent 40%, rgba(0,0,0,.6) 100%);
  }

  /* content sheet: floats over the lower brain, fading up from the void */
  .home-panel {
    position: fixed; inset: auto 0 0 0; top: auto;
    transform: none; width: 100%;
    padding: 104px clamp(16px, 5vw, 26px) calc(22px + env(safe-area-inset-bottom));
    gap: 20px; align-items: stretch;
    background: linear-gradient(180deg,
      rgba(5,6,10,0) 0%, rgba(5,6,10,.5) 22%,
      rgba(5,6,10,.87) 48%, rgba(5,6,10,.96) 70%);
    pointer-events: none;             /* taps fall through to the brain … */
  }
  .home-panel__intro,
  .home-panel__kicker { display: none; }

  /* --- Mobile lead / concept framing --- */
  .home-lead { display: flex; flex-direction: column; gap: 7px; pointer-events: none; }
  .home-lead__kicker {
    font-family: var(--font-mono); font-size: .6rem;
    letter-spacing: .28em; text-transform: uppercase;
    color: var(--cyan);
  }
  .home-lead__title {
    font-family: var(--font-display); font-weight: 700;
    font-size: clamp(1.5rem, 6.6vw, 2.05rem); line-height: 1.08;
    letter-spacing: -.02em; color: var(--ink-hi); margin: 0;
  }
  .home-lead__sub {
    font-size: .85rem; line-height: 1.5; color: var(--ink-mut);
    max-width: 44ch; margin: 0;
  }

  /* --- Category grid: elegant glass cards, clear hierarchy --- */
  .home-panel__nav-wrap { width: 100%; pointer-events: auto; gap: 0; transition: opacity .4s var(--ease-cine); }
  .home-lead { transition: opacity .4s var(--ease-cine); }
  .region-nav {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 9px; width: 100%;
  }
  .region-nav__item {
    display: flex; align-items: center; gap: 11px;
    padding: 13px; border-radius: 14px;
    border: 1px solid var(--hairline-2);
    background: rgba(9,12,19,.66);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    transition: border-color .25s, background .25s, transform .2s var(--ease-cine);
  }
  .region-nav__item:hover { transform: none; }   /* no hover translate on touch */
  .region-nav__item:active {
    transform: scale(.975);
    border-color: color-mix(in srgb, var(--item-accent, var(--cyan)) 55%, transparent);
  }
  .region-nav__item.is-active {
    transform: none;
    border-color: color-mix(in srgb, var(--item-accent, var(--cyan)) 60%, transparent);
    background: color-mix(in srgb, var(--item-accent, var(--cyan)) 15%, rgba(9,12,19,.66));
  }
  .region-nav__dot { width: 8px; height: 8px; }
  .region-nav__col { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .region-nav__label { font-size: .9rem; line-height: 1.1; }
  .region-nav__lobe {                 /* restore the lobe caption for hierarchy */
    display: block; font-size: .53rem; letter-spacing: .12em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  .site-header__role { display: none; }

  /* On a phone there's no hover, so the floating callout would only ever appear
     during the tour — and those dynamic cards shouldn't show on mobile. Hide it
     (and the cortex marker); the nav grid's active-item highlight already tracks
     which region the brain is showing, and it stays visible throughout. */
  .callout { display: none !important; }
  .callout-marker { display: none !important; }
}

/* Narrow phones: one clean column reads better than cramped pairs */
@media (max-width: 380px) {
  .region-nav { grid-template-columns: 1fr; gap: 8px; }
  .home-panel { gap: 16px; }
}

/* Short viewports (landscape phones): tighten the sheet so the brain breathes */
@media (max-width: 1024px) and (max-height: 620px) {
  .home-lead__sub { display: none; }
  .home-lead { gap: 4px; }
  .home-panel { padding-top: 72px; gap: 12px; }
}
