/* Body Echoes website UI kit — responsive helpers (kit-local, not a token file) */

/* ---- No page-level horizontal scroll, ever. Only垂直滾動 on the page itself.
        `overflow-x: clip` contains any bleed WITHOUT making body a scroll
        container (so position:sticky headers / mini-nav keep working, which
        `overflow-x:hidden` would break). Inner rails can still scroll-x. ---- */
html, body { width: 100%; max-width: 100%; margin: 0; overflow-x: clip; }
#root, main { max-width: 100%; overflow-x: clip; }
img, video, svg { max-width: 100%; }

/* ---- Prevent CSS-grid / flex blowout: a child with wide content (e.g. the
        full-bleed sticky mini-nav, a long word, a rail) must be allowed to
        shrink below its content size instead of stretching the track past the
        viewport. This is the usual cause of "responsive layout overflows on
        mobile". ---- */
.be-2col > *, .be-aside-grid > *, .be-grid-2 > *, .be-grid-3 > *, .be-grid-4 > * { min-width: 0; }

/* ---- Keyboard focus ring: every interactive element, mouse clicks stay clean ---- */
a:focus-visible, button:focus-visible, [tabindex]:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}
/* ---- Pressed feedback for plain links/buttons that don't carry their own JS press ---- */
@media (hover: hover) {
  a:active, button:active { filter: brightness(0.96); }
}

/* Background brand-wordmark marquee (4 copies → translate 50% = seamless loop) */
@keyframes be-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.be-marquee { animation-name: be-marquee; animation-timing-function: linear; animation-iteration-count: infinite; will-change: transform; }
@media (prefers-reduced-motion: reduce) { .be-marquee { animation: none; } }

/* Mobile drawer: services accordion slide-in */
@keyframes be-acc-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { [style*="be-acc-in"] { animation: none !important; } }

/* Mobile drawer panel: soft fade + slide-down on open */
@keyframes be-drawer-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { [style*="be-drawer-in"] { animation: none !important; } }

@media (max-width: 1100px) {
  .be-grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 920px) {
  .be-2col { grid-template-columns: 1fr !important; gap: 36px !important; }
  .be-grid-3 { grid-template-columns: repeat(2, 1fr) !important; }
  .be-aside-grid { grid-template-columns: 1fr !important; gap: 40px !important; }
}
/* Footer: 3-col → 2-col on tablet → single column (accordion) on phones */
@media (max-width: 880px) {
  .be-foot-grid { grid-template-columns: 1fr 1fr !important; gap: 36px 40px !important; }
}
@media (max-width: 700px) {
  .be-foot-grid { grid-template-columns: 1fr !important; gap: 0 !important; }
}
/* Horizontal card rail (mobile carousels) — hide scrollbar, keep momentum scroll */
.be-hscroll { scrollbar-width: none; -ms-overflow-style: none; }
.be-hscroll::-webkit-scrollbar { display: none; }
/* Pure-CSS card rail: grid on desktop → horizontal scroll-snap on phones (case/article features) */
@media (max-width: 700px) {
  .be-rail { display: flex !important; grid-template-columns: none !important; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 calc(-1 * clamp(20px,4.5vw,32px)); padding: 2px clamp(20px,4.5vw,32px) 12px; gap: 14px !important; scrollbar-width: none; }
  .be-rail::-webkit-scrollbar { display: none; }
  .be-rail > * { flex: 0 0 80%; scroll-snap-align: start; }
}
/* Mini-nav: hide the scrollbar on the horizontal tab strip (mobile service page) */
.be-mininav > div::-webkit-scrollbar { display: none; }
@media (max-width: 620px) {
  .be-grid-4, .be-grid-2 { grid-template-columns: 1fr !important; }
  /* Cases / articles cards stay 2-up and shrink with the screen (no giant single card) */
  .be-cardgrid { grid-template-columns: repeat(2, 1fr) !important; gap: 12px !important; }
  .be-cardgrid .be-cardbody { padding: 14px 14px 16px !important; }
  .be-cardgrid .be-cardtitle { font-size: 15.5px !important; line-height: 1.35 !important; }
  .be-cardgrid .be-cardexc { font-size: 13px !important; line-height: 1.65 !important; }
  /* other 3-up grids still collapse to one column */
  .be-grid-3:not(.be-cardgrid) { grid-template-columns: 1fr !important; }
  /* filter bar: horizontal scroll strip instead of wrapping into a tall block */
  .be-filterbar { flex-wrap: nowrap !important; overflow-x: auto; margin: 0 calc(-1 * clamp(20px,4.5vw,32px)) 28px !important; padding: 2px clamp(20px,4.5vw,32px); -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .be-filterbar::-webkit-scrollbar { display: none; }
  .be-filterbar > button { flex-shrink: 0; padding: 10px 15px !important; min-height: 40px !important; }
}
/* tighten section padding on small screens */
@media (max-width: 760px) {
  section { padding-top: 52px !important; padding-bottom: 52px !important; }
  /* List pages with a diagonal hero: keep the filter bar clear of the slanted photo edge */
  section.be-listsec { padding-top: 84px !important; }
}
@media (max-width: 480px) {
  section { padding-top: 44px !important; padding-bottom: 44px !important; }
}
/* ---- Photos: scale down on small screens so they don't dominate the page.
        Stacked feature/about/contact photos use a gentler ratio and a viewport
        height cap (object-fit:cover crops, never distorts). ---- */
@media (max-width: 640px) {
  .be-2col img, .be-aside-grid img {
    aspect-ratio: 4 / 3 !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: 46vh;
    object-fit: cover;
  }
}
/* ---- Founder portrait: rounded (no diagonal), head anchored to the top so it's
        never cropped, and the frame grows taller on bigger screens to reveal
        progressively more of the lower body. ---- */
.be-founder-img { object-position: center 8% !important; }
@media (min-width: 641px)  { .be-founder-img { aspect-ratio: 1 / 1 !important; max-height: none !important; } }
@media (min-width: 1025px) { .be-founder-img { aspect-ratio: 4 / 5 !important; } }

/* ============================================================
   MOTION SYSTEM — restrained, breathing, body-awareness pace.
   Implemented with CSS transitions + a tiny IntersectionObserver
   (motion.js). WordPress-portable: copy these rules + motion.js.
   Tokens: --ease, --dur, --dur-slow live in tokens/spacing.css.
   ============================================================ */

/* ---- Scroll reveal: fade + gentle rise. JS adds .is-in when in view.
        Stagger inside a [data-reveal-group] via the --rd delay. ---- */
[data-reveal]{
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 1.6s var(--ease), transform 1.6s var(--ease);
  transition-delay: var(--rd, 0ms);
  will-change: opacity, transform;
}
[data-reveal].is-in{ opacity: 1; transform: none; will-change: auto; }
[data-reveal="fade"]{ transform: none; }
[data-reveal="left"]{ transform: translateX(-30px); }
[data-reveal="right"]{ transform: translateX(30px); }
[data-reveal="scale"]{ transform: scale(.96); }
/* Hero photo: always visible; settle-in zoom plays when revealed (class may be
   reset by React on the <img>, so the base state must never hide it). */
[data-reveal="hero"]{ opacity: 1; transform: none; }
[data-reveal="hero"].is-in{ animation: be-heroin 2.4s var(--ease) both; }
@keyframes be-heroin { from { transform: scale(1.08); } to { transform: scale(1); } }

/* ---- Card lift + photo zoom (hover-capable pointers only) ---- */
.be-card{ transition: transform var(--dur-slow) var(--ease), box-shadow var(--dur-slow) var(--ease), border-color var(--dur-slow) var(--ease); }
.be-card img{ transition: transform .65s var(--ease); }
@media (hover: hover){
  .be-card:hover{ transform: translateY(-5px); box-shadow: var(--shadow-lift); border-color: var(--border-soft); }
  .be-card:hover img{ transform: scale(1.045); }
}

/* ---- Arrow nudge: wrap a "→" in <span class="be-arrow"> ---- */
.be-arrow{ display: inline-block; transition: transform .35s var(--ease); }
@media (hover: hover){
  a:hover .be-arrow, button:hover .be-arrow{ transform: translateX(5px); }
}

/* ---- Reading progress bar (article pages) ---- */
.be-progress{
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 80;
  background: var(--accent); transform: scaleX(0); transform-origin: 0 50%;
  transition: transform .12s linear; pointer-events: none;
}

/* ---- Sticky service mini-nav ---- */
.be-mininav{ transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.be-mininav a{ position: relative; transition: color var(--dur) var(--ease); }
.be-mininav a::after{
  content: ""; position: absolute; left: 0; right: 100%; bottom: -1px; height: 2px;
  background: var(--accent); transition: right var(--dur) var(--ease);
}
.be-mininav a[data-active]::after{ right: 0; }

/* ---- Lightbox (case galleries / prose images) ---- */
[data-lightbox]{ cursor: zoom-in; }
.be-lb{
  position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center;
  padding: 5vw; background: rgba(20,18,16,.84); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .35s var(--ease);
}
.be-lb.is-open{ opacity: 1; pointer-events: auto; }
.be-lb img{
  max-width: 100%; max-height: 90vh; border-radius: var(--r-md);
  transform: scale(.96); transition: transform .4s var(--ease);
  box-shadow: 0 30px 90px rgba(0,0,0,.55);
}
.be-lb.is-open img{ transform: scale(1); }
.be-lb-close{
  position: absolute; top: 22px; right: 26px; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer; display: grid; place-items: center;
}

/* ---- Service-flow step cards: lightweight motion + hover/tap interaction ---- */
.be-step { transition: transform .42s var(--ease), box-shadow .42s var(--ease), border-color .42s var(--ease); outline: none; -webkit-tap-highlight-color: transparent; }
/* coloured accent bar that grows from the left edge on hover / focus / tap */
.be-step::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); transform: scaleY(0); transform-origin: top; transition: transform .42s var(--ease); z-index: 2; }
/* big ghost step number sitting behind the content */
.be-stepghost { position: absolute; right: 18px; top: 0; font-family: var(--font-serif); font-size: 78px; font-weight: 600; line-height: 1; color: var(--accent); opacity: .05; pointer-events: none; transition: opacity .42s var(--ease), transform .42s var(--ease); transform: translateY(2px); z-index: 0; }
.be-stepnode { transition: background .42s var(--ease), color .42s var(--ease), transform .55s cubic-bezier(.34,1.56,.64,1); }
.be-stepnode svg { transition: transform .42s var(--ease); }
/* reveal: nodes pop (scale) as each card scrolls in. No opacity here — the card's
   own [data-reveal] handles the fade, and a scale-only pre-state stays VISIBLE
   even if a frame is dropped, so the icon can never get stuck invisible. */
.be-step:not(.is-in) .be-stepnode { transform: scale(.7); }
/* hover (desktop), focus (keyboard) and active (mobile tap) all light the card up */
.be-step:hover, .be-step:focus-visible, .be-step:active, .be-step.be-active { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--accent-soft) !important; }
.be-step:hover::before, .be-step:focus-visible::before, .be-step:active::before, .be-step.be-active::before { transform: scaleY(1); }
.be-step:hover .be-stepnode, .be-step:focus-visible .be-stepnode, .be-step:active .be-stepnode, .be-step.be-active .be-stepnode { background: var(--accent) !important; color: #fff !important; transform: scale(1.06); }
.be-step:hover .be-stepnode svg, .be-step:focus-visible .be-stepnode svg, .be-step:active .be-stepnode svg, .be-step.be-active .be-stepnode svg { transform: rotate(-6deg) scale(1.05); }
.be-step:hover .be-stepghost, .be-step:focus-visible .be-stepghost, .be-step:active .be-stepghost, .be-step.be-active .be-stepghost { opacity: .12; transform: translateY(0); }
/* phones have no hover — give a clear press state */
@media (hover: none) {
  .be-step:active { transform: scale(.985); }
}

/* ---- Reduced motion: reveal everything, drop transforms ---- */
@media (prefers-reduced-motion: reduce){
  [data-reveal]{ opacity: 1 !important; transform: none !important; transition: none !important; }
  .be-card:hover, .be-card:hover img{ transform: none !important; }
  .be-marquee{ animation: none !important; }
  .be-step .be-stepnode{ transform: none !important; opacity: 1 !important; }
}
