/*
Theme Name: Raymond Weil Child
Template: raymond-weil
Version: 1.0
*/
/*
Theme Name: rw
Theme URI: https://raymond-weil.jp
Author: Your Team
Description: Raymond Weil JP Renewal (WP + FutureShop redirect)
Version: 1.0.0
Text Domain: rw
*/
:root{
  --rw-bg:#ffffff;
  --rw-text:#111111;
  --rw-muted:rgba(17,17,17,.68);
  --rw-border:rgba(0,0,0,.10);

  --rw-container:1200px;
  --rw-gutter:24px;

  --rw-radius:18px;
  --rw-radius-sm:12px;

  --rw-space-2:8px;
  --rw-space-3:12px;
  --rw-space-4:16px;
  --rw-space-6:24px;
  --rw-space-8:32px;
  --rw-space-10:40px;

  --rw-shadow:0 18px 50px rgba(0,0,0,.10);
}

/* 全体をライト基調に寄せる（非商品ページ） */
body{
  background:var(--rw-bg);
  color:var(--rw-text);
}

.rw-container{
  max-width:var(--rw-container);
  padding:0 var(--rw-gutter);
  margin:0 auto;
}
.rw-section{
  padding: var(--rw-space-10) 0;
  border-bottom:1px solid var(--rw-border);
}
:root{
  --rw-bg:#fff;
  --rw-text:#111;
  --rw-muted:rgba(17,17,17,.68);
  --rw-border:rgba(0,0,0,.10);

  --rw-container:1200px;
  --rw-gutter:24px;

  --rw-radius:18px;
  --rw-radius-sm:12px;

  --rw-space-2:8px;
  --rw-space-3:12px;
  --rw-space-4:16px;
  --rw-space-6:24px;
  --rw-space-8:32px;
  --rw-space-10:40px;

  --rw-shadow:0 18px 50px rgba(0,0,0,.10);
}

body{background:var(--rw-bg);color:var(--rw-text);}
.rw-container{max-width:var(--rw-container);margin:0 auto;padding:0 var(--rw-gutter);}
/* =========================
   BELOW HERO: Tabs + Product rail (Mon-ready)
   ========================= */

/* 1) Hero直下の“間延び余白”を締める */
tabs-global,
.section-mea-product-home,
.section-mea-product-home .page-width,
.section-mea-product-home .page-width-full {
  margin-top: 0 !important;
}
.section-mea-product-home {
  padding-top: 28px !important;
  padding-bottom: 36px !important;
}
@media (min-width: 992px){
  .section-mea-product-home {
    padding-top: 44px !important;
    padding-bottom: 56px !important;
  }
}

/* 2) タブ（NEW ARRIVALS / TRENDING NOW…）の見た目を本国寄せ */
tabs-global .tabs,
.tabs-global .tabs,
.tabs .tabs__list,
.tabs .tabs__nav {
  display: flex;
  justify-content: center;
  gap: 44px;
  border: 0 !important;
}
tabs-global .tab,
.tabs .tab,
.tabs__item,
.tabs__button {
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 13px;
  opacity: .45;
}
tabs-global .tab.is-active,
.tabs .tab.is-active,
.tabs__item.is-active,
.tabs__button[aria-selected="true"]{
  opacity: .75;
}

/* 3) 商品レール：カードの“浮き”を消して、均一に */
.section-mea-product-home .card,
.section-mea-product-home .product-card,
.section-mea-product-home .card-wrapper {
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* 4) 画像の見え方（ズレ防止） */
.section-mea-product-home img {
  display: block;
  width: 100%;
  height: auto;
}

/* 5) レールの左右余白（本国っぽく広め） */
.section-mea-product-home .page-width,
.section-mea-product-home .page-width-full {
  padding-left: 60px;
  padding-right: 60px;
}
@media (max-width: 991px){
  .section-mea-product-home .page-width,
  .section-mea-product-home .page-width-full {
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* 6) スライダー矢印が邪魔なら控えめに（ある場合だけ効く） */
.section-mea-product-home .swiper-button-prev,
.section-mea-product-home .swiper-button-next {
  opacity: .55;
}
.section-mea-product-home .swiper-button-prev:hover,
.section-mea-product-home .swiper-button-next:hover {
  opacity: .9;
}
/* まず「透明overlayが常時ON」を殺す（応急処置） */
.main-menu__overlay,
.main-menu__bg,
#BurgerMenu-Overlay,
.burger-menu__overlay,
.drawer__overlay {
  pointer-events: none !important;
}

/* 開いた時だけクリックを許可する（active / is-open の時だけ） */
search-drawer.active .drawer__overlay,
localization-drawer.active .drawer__overlay,
#BurgerMenu.is-open ~ #BurgerMenu-Overlay,
#BurgerMenu-Overlay.is-open {
  pointer-events: auto !important;
}


add_action('wp_enqueue_scripts', function () {
  if (!is_page('freelancer-collection')) return; // スラッグに合わせて変えてOK

  $js = <<<'JS'
(() => {
  const SKU_RX = /(\d{4}-[A-Z0-9]{2,}-\d{5})/;

  const replaceLinks = () => {
    const cards = document.querySelectorAll('.swiper-slide card-wrapper');
    if (!cards.length) return false;

    cards.forEach(card => {
      // すでに処理済みはスキップ
      if (card.dataset.rwLinkDone === '1') return;

      const img = card.querySelector('img[src]');
      const src = img?.getAttribute('src') || '';
      const m = src.match(SKU_RX);
      if (!m) return;

      const sku = m[1];
      const jpUrl = 'https://raymond-weil.jp/c/mens/freelancer/' + sku;

      // カード内のリンク全部差し替え（aが複数あるため）
      card.querySelectorAll('a[href]').forEach(a => a.setAttribute('href', jpUrl));

      card.dataset.rwLinkDone = '1';
    });

    return true;
  };

  // Swiper/カスタム要素の描画が遅いのでリトライ
  const boot = () => {
    let tries = 0;
    const timer = setInterval(() => {
      tries++;
      const ok = replaceLinks();
      if (ok || tries > 40) clearInterval(timer); // 最大約8秒
    }, 200);
  };

  window.addEventListener('load', boot);
})();
JS;

  // 既に読み込まれているスクリプトにインラインで追加（handleは適宜）
  wp_add_inline_script('jquery-core', $js, 'after');
});

/* FV: PC left / SP bottom */
@media (min-width: 576px){ /* d-sm-* に合わせる */
  [data-rw-fv-slider] .section-hero__item .content{
    position:absolute;
    inset:0;
    display:flex;
    justify-content:flex-start; /* 左固定 */
    align-items:stretch;
    pointer-events:none;
  }
  [data-rw-fv-slider] .section-hero__item .bg-wrap{
    width:min(640px, 42vw);
    height:100%;
    justify-content:center;
    align-items:flex-start; /* 左寄せ */
    text-align:left;        /* 左寄せ */
    pointer-events:auto;
  }
  [data-rw-fv-slider] .section-hero__item .text-center{ text-align:left !important; }
}

@media (max-width: 575px){
  [data-rw-fv-slider] .section-hero__item .content{
    position:static; /* 下固定（画像の下に流す） */
  }
  [data-rw-fv-slider] .section-hero__item .bg-wrap{
    width:100%;
    padding:16px 16px 24px;
  }
}
/* ヘッダーを最前面に */
.site-header,
.header,
.header-wrapper,
header,
.rw-header {
  position: relative;
  z-index: 10050;
}

/* ヘッダー内はクリックできるように */
.site-header *, .header * , header * {
  pointer-events: auto;
}

/* “常時出てしまっているoverlay”候補を無効化（開いてる時だけ有効にするのが理想） */
.drawer__overlay,
.menu-drawer__overlay,
.modal-overlay,
.overlay,
.rw-overlay {
  pointer-events: none;
}
.page .rw-section__head{
	display:none;
}
.section{margin-top:6rem; margin-bottom:6rem;}
main section:first-child .section{margin-top:0!important;}
.breadcrumbs p{margin:0;}
.breadcrumbs p br{display:none!important}
.rw-sidebox{display:none;}
@media (min-width: 768px) {
.footer__navigation {padding: 0;}
}

.is-hidden { display: none !important; }
/* =========================
   BELOW HERO: Tabs + Product rail (Mon-ready)
   ========================= */

/* 1) Hero直下の“間延び余白”を締める */
tabs-global,
.section-mea-product-home,
.section-mea-product-home .page-width,
.section-mea-product-home .page-width-full {
  margin-top: 0 !important;
}
.section-mea-product-home {
  padding-top: 28px !important;
  padding-bottom: 36px !important;
}
@media (min-width: 992px){
  .section-mea-product-home {
    padding-top: 44px !important;
    padding-bottom: 56px !important;
  }
}

/* 2) タブ（NEW ARRIVALS / TRENDING NOW…）の見た目を本国寄せ */
tabs-global .tabs,
.tabs-global .tabs,
.tabs .tabs__list,
.tabs .tabs__nav {
  display: flex;
  justify-content: center;
  gap: 44px;
  border: 0 !important;
}
tabs-global .tab,
.tabs .tab,
.tabs__item,
.tabs__button {
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 13px;
  opacity: .45;
}
tabs-global .tab.is-active,
.tabs .tab.is-active,
.tabs__item.is-active,
.tabs__button[aria-selected="true"]{
  opacity: .75;
}

/* 3) 商品レール：カードの“浮き”を消して、均一に */
.section-mea-product-home .card,
.section-mea-product-home .product-card,
.section-mea-product-home .card-wrapper {
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* 4) 画像の見え方（ズレ防止）
.section-mea-product-home img {
  display: block;
  width: 100%;
  height: auto;
}*/
.section-mea-product-home img {
    display: block;
    width: auto;
    height: auto;
}
/* 5) レールの左右余白（本国っぽく広め） */
.section-mea-product-home .page-width,
.section-mea-product-home .page-width-full {
  padding-left: 60px;
  padding-right: 60px;
}
@media (max-width: 991px){
  .section-mea-product-home .page-width,
  .section-mea-product-home .page-width-full {
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* 6) スライダー矢印が邪魔なら控えめに（ある場合だけ効く） */
.section-mea-product-home .swiper-button-prev,
.section-mea-product-home .swiper-button-next {
  opacity: .55;
}
.section-mea-product-home .swiper-button-prev:hover,
.section-mea-product-home .swiper-button-next:hover {
  opacity: .9;
}
/* まず「透明overlayが常時ON」を殺す（応急処置） */
.main-menu__overlay,
.main-menu__bg,
#BurgerMenu-Overlay,
.burger-menu__overlay,
.drawer__overlay {
  pointer-events: none !important;
}

/* 開いた時だけクリックを許可する（active / is-open の時だけ） */
search-drawer.active .drawer__overlay,
localization-drawer.active .drawer__overlay,
#BurgerMenu.is-open ~ #BurgerMenu-Overlay,
#BurgerMenu-Overlay.is-open {
  pointer-events: auto !important;
}


add_action('wp_enqueue_scripts', function () {
  if (!is_page('freelancer-collection')) return; // スラッグに合わせて変えてOK

  $js = <<<'JS'
(() => {
  const SKU_RX = /(\d{4}-[A-Z0-9]{2,}-\d{5})/;

  const replaceLinks = () => {
    const cards = document.querySelectorAll('.swiper-slide card-wrapper');
    if (!cards.length) return false;

    cards.forEach(card => {
      // すでに処理済みはスキップ
      if (card.dataset.rwLinkDone === '1') return;

      const img = card.querySelector('img[src]');
      const src = img?.getAttribute('src') || '';
      const m = src.match(SKU_RX);
      if (!m) return;

      const sku = m[1];
      const jpUrl = 'https://raymond-weil.jp/c/mens/freelancer/' + sku;

      // カード内のリンク全部差し替え（aが複数あるため）
      card.querySelectorAll('a[href]').forEach(a => a.setAttribute('href', jpUrl));

      card.dataset.rwLinkDone = '1';
    });

    return true;
  };

  // Swiper/カスタム要素の描画が遅いのでリトライ
  const boot = () => {
    let tries = 0;
    const timer = setInterval(() => {
      tries++;
      const ok = replaceLinks();
      if (ok || tries > 40) clearInterval(timer); // 最大約8秒
    }, 200);
  };

  window.addEventListener('load', boot);
})();
JS;

  // 既に読み込まれているスクリプトにインラインで追加（handleは適宜）
  wp_add_inline_script('jquery-core', $js, 'after');
});

/* FV: PC left / SP bottom */
@media (min-width: 576px){ /* d-sm-* に合わせる */
  [data-rw-fv-slider] .section-hero__item .content{
    position:absolute;
    inset:0;
    display:flex;
    justify-content:flex-start; /* 左固定 */
    align-items:stretch;
    pointer-events:none;
  }
  [data-rw-fv-slider] .section-hero__item .bg-wrap{
    width:min(640px, 42vw);
    height:100%;
    justify-content:center;
    align-items:flex-start; /* 左寄せ */
    text-align:left;        /* 左寄せ */
    pointer-events:auto;
  }
  [data-rw-fv-slider] .section-hero__item .text-center{ text-align:left !important; }
}

@media (max-width: 575px){
  [data-rw-fv-slider] .section-hero__item .content{
    position:static; /* 下固定（画像の下に流す） */
  }
  [data-rw-fv-slider] .section-hero__item .bg-wrap{
    width:100%;
    padding:16px 16px 24px;
  }
}
/* ヘッダーを最前面に */
.site-header,
.header,
.header-wrapper,
header,
.rw-header {
  position: relative;
  z-index: 10050;
}

/* ヘッダー内はクリックできるように */
.site-header *, .header * , header * {
  pointer-events: auto;
}

/* “常時出てしまっているoverlay”候補を無効化（開いてる時だけ有効にするのが理想） */
.drawer__overlay,
.menu-drawer__overlay,
.modal-overlay,
.overlay,
.rw-overlay {
  pointer-events: none;
}
.page .rw-section__head{
	display:none;
}
.section{margin-top:6rem; margin-bottom:6rem;}
main section:first-child .section{margin-top:0!important;}
.breadcrumbs p{margin:0;}
.breadcrumbs p br{display:none!important}
.rw-sidebox{display:none;}
@media (min-width: 768px) {
.footer__navigation {padding: 0;}
}

.is-hidden { display: none !important; }

/*旧サイト対策*/
.section-hero .wysiwyg {
	font-size:1.2rem;
}
.content-for-layout .section:first-child {
    margin-top: 0;
    padding-top: 125px;
}
.content-for-layout .section:first-child {
    margin-top: 0;
    padding-top: 0;
}
#header{
	height: 0!important;
	padding:0!important
		overflow: hidden;
	visibility: hidden;
	pointer-events: none;
	display:none;
}
/*[hidden] { display: none !important; }*/
html, body {
  overflow-x: hidden;
}

.section-hero a:visited{
	color:#fff!important;}

main#primary {padding-top: 0px;!important margin-top:-100px;}
h1.entry-title{
	line-height:1.6em;
}
.post, .page {
    margin: 0;
    margin-top: -30px;
}
article.item .entry-content .single_content p, article.campaign-fair .entry-content .single_content p, article.information .entry-content .single_content p, article.press .entry-content .single_content p {
    font-size: 14px;
    font-weight: 400;
    margin-bottom: 1.5em;
	line-height:1.6;
}
article.item .entry-content, article.campaign-fair .entry-content, article.information .entry-content, article.press .entry-content {
    margin-bottom: 40px;
}
article.item .entry-content .single_content button, article.campaign-fair .entry-content .single_content button, article.information .entry-content .single_content button, article.press .entry-content .single_content button{
    font-size: 14px;
    font-weight: 400;
}
article.item .entry-content header,article.campaign-fair .entry-content header, article.information .entry-content header, article.press .entry-content header{
    position: relative;
    z-index: 8000!important;
}

#primary header{
	position: relative;
    z-index: 8000!important;
}
.page-transfer {
    padding-top: 20px !important;
}