/* =====================================================================
   Casa Rovesto — App Shell (theme-neutralizing base + SPA stage layout)

   Style handle: 'cr-app-shell' (registered by CR_Assets; depends on
   'cr-tokens' for the design-token custom properties).

   Purpose: strip the active theme's chrome around the storefront SPA and
   give #cr-app-stage / .cr-app a clean, mobile-first base. The theme
   overrides #main p, #main h1-h4 with !important (documented gotcha from
   the beatshouse build), so those resets are scoped under #main and use
   !important to win. NO player / audio CSS — visual theming for products,
   grids, lookbook etc. lives in cr-store.css and cr-cart-checkout.css.

   Mobile-first: base rules target phones; min-width breakpoints scale up.
   44px minimum touch targets; prefers-reduced-motion respected.
   ===================================================================== */

/* ── Theme chrome reset ──────────────────────────────────────────────
   Flatten the common theme wrappers so the app stage spans full width
   with no inherited padding, max-width or background. Both bare and
   #main-scoped selectors are listed because themes vary on where they
   apply layout constraints. */
.cr-full-page #page,
.cr-full-page #main,
.cr-full-page .site,
.cr-full-page .site-content,
.cr-full-page .site-main,
.cr-full-page .wp-site-blocks,
.cr-full-page .entry-content,
.cr-full-page .entry,
.cr-full-page article,
.cr-full-page .page-content,
.cr-full-page .page-header,
.cr-full-page .post-thumbnail,
.cr-full-page .wp-block-post-content,
.cr-full-page .has-global-padding {
  margin: 0 !important;
  padding: 0 !important;
  max-width: none !important;
  width: 100% !important;
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* Theme p / h overrides — the theme sets these with !important under
   #main, so we must out-specify + !important to neutralize them inside
   the app stage. (See beatshouse WP Gotcha.) */
#main .cr-app p,
#main .cr-app h1,
#main .cr-app h2,
#main .cr-app h3,
#main .cr-app h4,
#main .cr-app h5,
#main .cr-app h6,
.cr-app p,
.cr-app h1,
.cr-app h2,
.cr-app h3,
.cr-app h4,
.cr-app h5,
.cr-app h6 {
  color: inherit !important;
  font-family: inherit !important;
}

/* ── App stage base layout (mobile-first) ───────────────────────────── */
#cr-app-stage,
.cr-app {
  display: block;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  /* Token-driven with safe fallbacks so the stage renders even if
     cr-tokens.css failed to load. */
  box-sizing: border-box;
  min-height: 60vh;
  color: var(--cr-color-text, #1a1a1a);
  background: var(--cr-color-bg, transparent);
  font-family: var(--cr-font-body, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  font-size: var(--cr-font-size-base, 16px);
  line-height: var(--cr-line-base, 1.5);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

#cr-app-stage {
  /* Account for fixed headers / safe-area on notched devices. */
  padding: var(--cr-stage-pad-top, 16px)
           var(--cr-stage-pad-x, 16px)
           var(--cr-stage-pad-bottom, 48px);
  padding-top: max(var(--cr-stage-pad-top, 16px), env(safe-area-inset-top, 0px));
  transition: opacity .12s ease;
}

/* Inner content gets a readable max-width while the stage stays full-bleed. */
.cr-app > * {
  max-width: var(--cr-content-max, 1200px);
  margin-left: auto;
  margin-right: auto;
}

/* Box model + media sanity inside the app. */
.cr-app *,
.cr-app *::before,
.cr-app *::after {
  box-sizing: border-box;
}
.cr-app img,
.cr-app picture,
.cr-app video,
.cr-app svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ── Links ── */
.cr-app a {
  color: var(--cr-color-link, currentColor);
  text-decoration: none;
}
.cr-app a:hover,
.cr-app a:focus-visible {
  text-decoration: underline;
}

/* ── Touch targets ──
   Any interactive control inside the app honors a 44px minimum target. */
.cr-app a[href],
.cr-app button,
.cr-app [role="button"],
.cr-app input[type="button"],
.cr-app input[type="submit"],
.cr-app .cr-btn {
  min-height: 44px;
  min-width: 44px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Generic button reset (visual styling lives in cr-store.css). */
.cr-app .cr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  appearance: none;
  border: 0;
  font: inherit;
  line-height: 1;
}

/* ── Focus visibility (accessibility) ── */
.cr-app :focus-visible {
  outline: 2px solid var(--cr-color-focus, #1a1a1a);
  outline-offset: 2px;
}

/* ── SPA loading affordance ──
   Mirrors the inline #cr-spa-loading-inline block in cr-full-page.php so the
   bar works both before this stylesheet loads and after. The router toggles
   .cr-spa-loading on #cr-app-stage during navigation. */
#cr-app-stage.cr-spa-loading {
  pointer-events: none;
  opacity: .45;
}
#cr-app-stage.cr-spa-loading::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 999999;
  background: linear-gradient(
    90deg,
    var(--cr-color-accent, currentColor) 0%,
    var(--cr-color-accent, currentColor) 60%,
    transparent 100%
  );
  animation: crSpaBar .9s ease-in-out infinite;
}
@keyframes crSpaBar {
  0%   { transform: scaleX(0);  transform-origin: left; opacity: 1; }
  70%  { transform: scaleX(.9); transform-origin: left; opacity: 1; }
  100% { transform: scaleX(1);  transform-origin: left; opacity: 0; }
}

/* ── Breakpoints (mobile-first, min-width up) ───────────────────────── */
@media (min-width: 600px) {
  #cr-app-stage {
    padding: var(--cr-stage-pad-top, 24px)
             var(--cr-stage-pad-x, 24px)
             var(--cr-stage-pad-bottom, 64px);
  }
}
@media (min-width: 900px) {
  #cr-app-stage {
    padding: var(--cr-stage-pad-top, 32px)
             var(--cr-stage-pad-x, 40px)
             var(--cr-stage-pad-bottom, 80px);
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  #cr-app-stage { transition: none; }
  #cr-app-stage.cr-spa-loading::before { animation: none; }
}

/* ==========================================================================
   NAVIGATION
   ========================================================================== */
:root {
  --cr-header-h: 60px;
  --cr-font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --cr-font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
}

/* Push page content below fixed header */
.cr-full-page body,
body.cr-full-page {
  background: var(--cr-color-paper, #F4F0E9);
  color: var(--cr-color-ink, #16130F);
  font-family: var(--cr-font-body);
  margin: 0;
  padding-top: var(--cr-header-h);
}

.cr-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--cr-z-header, 200);
  height: var(--cr-header-h);
  background: var(--cr-color-paper, #F4F0E9);
  border-bottom: 1px solid var(--cr-line, #E0D9CC);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.cr-nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--cr-container, 1280px);
  margin: 0 auto;
  padding: 0 var(--cr-space-5, 1.5rem);
  gap: var(--cr-space-5, 1.5rem);
}

/* Logo / wordmark */
.cr-nav__logo {
  font-family: var(--cr-font-display);
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cr-color-ink, #16130F);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.cr-nav__logo:hover { text-decoration: none; opacity: 0.72; }
.cr-nav__logo-break { display: none; }

/* Desktop nav links */
.cr-nav__links {
  display: none;
  gap: var(--cr-space-6, 2rem);
  align-items: center;
}
.cr-nav__link {
  font-size: var(--cr-text-xs, 0.6875rem);
  letter-spacing: var(--cr-tracking-wide, 0.14em);
  text-transform: uppercase;
  color: var(--cr-color-ink, #16130F);
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.15s;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
}
.cr-nav__link:hover,
.cr-nav__link--active {
  opacity: 1;
  text-decoration: none;
  border-bottom-color: var(--cr-color-ink, #16130F);
}

/* Right-side icons */
.cr-nav__actions {
  display: flex;
  align-items: center;
  gap: var(--cr-space-2, 0.5rem);
  flex-shrink: 0;
}
.cr-nav__icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--cr-color-ink, #16130F);
  text-decoration: none;
  position: relative;
  border-radius: var(--cr-radius-sm, 4px);
  transition: opacity 0.15s;
}
.cr-nav__icon-btn:hover { opacity: 0.6; text-decoration: none; }

/* Cart badge */
.cr-nav__cart-btn { gap: 0; }
.cr-nav__cart-count {
  position: absolute;
  top: 6px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--cr-color-accent, #9A5B3F);
  color: var(--cr-on-accent, #F4F0E9);
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.cr-nav__cart-count:empty { display: none; }

/* Hamburger (mobile only) */
.cr-nav__hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.cr-nav__ham-bar {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--cr-color-ink, #16130F);
  transition: transform 0.2s, opacity 0.2s;
}

/* Mobile drawer */
.cr-nav__drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(80vw, 320px);
  background: var(--cr-color-paper, #F4F0E9);
  z-index: calc(var(--cr-z-header, 200) + 10);
  transform: translateX(-100%);
  transition: transform 0.3s var(--cr-ease-out, cubic-bezier(0.16,1,0.3,1));
  padding: var(--cr-space-6, 2rem) var(--cr-space-5, 1.5rem);
  display: flex;
  flex-direction: column;
}
.cr-nav__drawer--open { transform: translateX(0); }

.cr-nav__drawer-inner { display: flex; flex-direction: column; gap: var(--cr-space-3, 0.75rem); }

.cr-nav__drawer-close {
  align-self: flex-end;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--cr-color-ink, #16130F);
  margin-bottom: var(--cr-space-3, 0.75rem);
}

.cr-nav__drawer-brand {
  font-family: var(--cr-font-display);
  font-size: 1rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding-bottom: var(--cr-space-4, 1rem);
  border-bottom: 1px solid var(--cr-line, #E0D9CC);
  margin-bottom: var(--cr-space-2, 0.5rem);
}

.cr-nav__drawer-link {
  font-size: var(--cr-text-base, 0.9375rem);
  letter-spacing: 0.04em;
  color: var(--cr-color-ink, #16130F);
  text-decoration: none;
  padding: var(--cr-space-3, 0.75rem) 0;
  border-bottom: 1px solid var(--cr-line, #E0D9CC);
  display: block;
}
.cr-nav__drawer-link:hover { opacity: 0.6; text-decoration: none; }

/* Overlay */
.cr-nav__overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 19, 15, 0.4);
  z-index: calc(var(--cr-z-header, 200) + 5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.cr-nav__overlay--visible { opacity: 1; pointer-events: all; }
body.cr-nav-open { overflow: hidden; }

/* ── Desktop breakpoint ── */
@media (min-width: 768px) {
  :root { --cr-header-h: 64px; }
  .cr-nav__hamburger { display: none; }
  .cr-nav__links { display: flex; }
  .cr-nav__logo-break { display: inline; }
}

/* ── WP admin bar offset (logged-in editors/admins) ── */
.admin-bar .cr-nav__bar { top: 32px; }
@media screen and (max-width: 782px) {
  .admin-bar .cr-nav__bar { top: 46px; }
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.cr-footer {
  margin-top: var(--cr-space-10, 8rem);
  border-top: 1px solid var(--cr-line, rgba(244,240,233,0.12));
}
.cr-footer__inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--cr-space-7, 3rem);
  max-width: var(--cr-container, 1280px);
  margin: 0 auto;
  padding: var(--cr-space-8, 4rem) var(--cr-space-5, 1.5rem) var(--cr-space-7, 3rem);
}
.cr-footer__logo {
  font-family: var(--cr-font-display);
  font-size: 1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: inherit;
  text-decoration: none;
  display: block;
  margin-bottom: var(--cr-space-3, 0.75rem);
}
.cr-footer__logo:hover { text-decoration: none; opacity: 0.7; }
.cr-footer__tagline {
  font-size: var(--cr-text-xs, 0.6875rem);
  letter-spacing: 0.1em;
  opacity: 0.55;
  margin: 0;
}
.cr-footer__nav,
.cr-footer__contact {
  display: flex;
  flex-direction: column;
  gap: var(--cr-space-2, 0.5rem);
}
.cr-footer__nav-heading {
  font-size: var(--cr-text-xs, 0.6875rem);
  letter-spacing: var(--cr-tracking-wide, 0.14em);
  text-transform: uppercase;
  opacity: 0.45;
  margin-bottom: var(--cr-space-2, 0.5rem);
  display: block;
}
.cr-footer__link {
  font-size: var(--cr-text-sm, 0.8125rem);
  color: inherit;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.cr-footer__link:hover { opacity: 1; text-decoration: none; }
.cr-footer__bottom {
  border-top: 1px solid rgba(244, 240, 233, 0.12);
  padding: var(--cr-space-4, 1rem) var(--cr-space-5, 1.5rem);
  text-align: center;
  font-size: var(--cr-text-xs, 0.6875rem);
  letter-spacing: 0.06em;
  opacity: 0.45;
  max-width: var(--cr-container, 1280px);
  margin: 0 auto;
}
@media (min-width: 640px) {
  .cr-footer__inner {
    grid-template-columns: 2fr 1fr 1fr;
    gap: var(--cr-space-6, 2rem);
  }
}

/* Prevent body bg from bleeding behind footer in cr-invert */
.cr-full-page .cr-footer.cr-invert {
  background: var(--cr-color-paper, #16130F);
  color: var(--cr-color-ink, #F4F0E9);
}
