// sections2.jsx — News / Company / History / Recruit / Footer
// 記事データは news.json で管理（news-data.js が非同期ロード）

const { useState: useStateS2, useEffect, useCallback } = React;

// ── useNewsData フック — JSON非同期ロード対応 ────────────────────────
function useNewsData() {
  const [items, setItems] = useStateS2(window.NEWS_DATA || []);
  useEffect(() => {
    if (window.NEWS_DATA !== null) { setItems(window.NEWS_DATA); return; }
    const handler = () => setItems(window.NEWS_DATA || []);
    window.addEventListener('newsLoaded', handler, { once: true });
    return () => window.removeEventListener('newsLoaded', handler);
  }, []);
  return [items, setItems];
}

// ── 菱形（六角形）NEWバッジ ─────────────────────────────────────────
function NewBadge() {
  return (
    <span style={{
      display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
      width: 48, height: 54, flexShrink: 0,
      clipPath: 'polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%)',
      background: '#c0472a',
      color: '#fff', fontSize: 11, fontWeight: 700,
      letterSpacing: '.04em', fontFamily: 'sans-serif',
      userSelect: 'none',
    }}>New</span>
  );
}

// ── NewsCard — 統一カードテンプレート ───────────────────────────────
function NewsCard({ article, featured = false, onClick }) {
  const handleClick = (e) => {
    e.preventDefault();
    if (onClick) onClick(article);
  };
  return (
    <article className={`nc-card ${featured ? 'nc-card--featured' : ''}`}
      onClick={handleClick} style={{ cursor: 'pointer' }}>
      {featured ? (
        // ── ホーム大カード（画像あり）
        <>
          <div className="nc-thumb">
            <div className="nc-logo-mark" aria-hidden="true">
              <img src="assets/logo_koyo_gr.png" alt="" />
            </div>
            <img src={article.img} alt="" className="nc-thumb-img" />
          </div>
          <div className="nc-body">
            <div className="nc-meta">
              <time className="nc-date">{article.date}</time>
              <span className="nc-facility">{article.facility}</span>
              {article.is_new && <span className="nc-new-text">NEW</span>}
            </div>
            <h3 className="nc-title">{article.title}</h3>
            <p className="nc-summary">{article.summary}</p>
          </div>
        </>
      ) : (
        // ── 一覧行（テキスト中心：元サイト準拠）
        <div className="nc-row">
          <div className="nc-row-badge">
            {article.is_new ? <NewBadge /> : <span style={{ width: 48 }} />}
          </div>
          <div className="nc-row-body">
            <div className="nc-row-meta">
              <time className="nc-date">{article.date}</time>
              <a href={article.facility_url || '#'}
                className="nc-facility-link"
                onClick={e => e.stopPropagation()}
                target="_blank" rel="noopener noreferrer">
                {article.facility}
              </a>
            </div>
            <p className="nc-row-title">{article.title}</p>
            <p className="nc-row-summary">{article.summary}</p>
          </div>
        </div>
      )}
    </article>
  );
}

// ── ArticleDetail — 記事詳細テンプレート ────────────────────────────
function ArticleDetail({ article, onBack }) {
  if (!article) return null;
  return (
    <div className="ad-page">
      <style>{`
        .ad-page { max-width:860px; margin:0 auto; padding:0 40px 80px; }
        @media(max-width:680px){ .ad-page { padding:0 20px 60px; } }
        .ad-back { display:inline-flex; align-items:center; gap:8px; margin:28px 0 0; font-size:13px; color:#666; cursor:pointer; background:none; border:none; padding:0; letter-spacing:.06em; }
        .ad-back:hover { color:#4a7c3f; }
        .ad-header { margin:24px 0 0; padding-bottom:24px; border-bottom:2px solid #e8e4d8; }
        .ad-brand { display:flex; align-items:center; gap:10px; margin-bottom:20px; padding-bottom:16px; border-bottom:1px solid #eee; }
        .ad-brand img { height:28px; }
        .ad-brand span { font-size:11px; letter-spacing:.2em; color:#999; font-family:sans-serif; }
        .ad-meta { display:flex; align-items:center; gap:14px; margin-bottom:14px; flex-wrap:wrap; }
        .ad-date { font-size:13px; color:#888; }
        .ad-fac { font-size:12px; color:#c0472a; border-bottom:1px solid #c0472a; padding-bottom:1px; text-decoration:none; }
        .ad-new-badge { display:inline-flex; align-items:center; justify-content:center; width:40px; height:45px; clip-path:polygon(50% 0%,100% 25%,100% 75%,50% 100%,0% 75%,0% 25%); background:#c0472a; color:#fff; font-size:10px; font-weight:700; letter-spacing:.04em; }
        .ad-title { font-family:var(--f-serif,'Noto Serif JP',serif); font-size:clamp(18px,2.4vw,26px); font-weight:500; line-height:1.75; color:#222; margin:0; letter-spacing:.03em; }
        .ad-hero { margin:28px 0; position:relative; overflow:hidden; aspect-ratio:16/7; }
        .ad-hero img { width:100%; height:100%; object-fit:cover; display:block; }
        .ad-hero-brand { position:absolute; bottom:14px; right:14px; background:rgba(255,255,255,.88); padding:5px 10px; display:flex; align-items:center; gap:6px; }
        .ad-hero-brand img { height:18px; }
        .ad-body { font-size:15px; line-height:2; color:#444; }
        .ad-body p { margin:0 0 1.4em; }
        .ad-body strong { color:#222; font-weight:600; }
        .ad-body h4 { font-family:var(--f-serif,'Noto Serif JP',serif); font-size:17px; font-weight:500; margin:1.8em 0 .8em; color:#333; border-left:3px solid #4a7c3f; padding-left:12px; }
        .ad-body ul { padding-left:1.4em; margin:0 0 1.4em; }
        .ad-body li { margin-bottom:.6em; }
        .ad-ext { margin-top:36px; }
        .ad-ext a { display:inline-flex; align-items:center; gap:10px; padding:13px 32px; border:1px solid #333; font-size:13px; letter-spacing:.1em; color:#333; text-decoration:none; transition:background .2s,color .2s; }
        .ad-ext a:hover { background:#333; color:#fff; }
      `}</style>

      <button className="ad-back" onClick={onBack}>← 一覧に戻る</button>

      <header className="ad-header">
        {/* ブランドヘッダー（全記事共通） */}
        <div className="ad-brand">
          <img src="assets/logo_koyo_gr.png" alt="古窯グループ" />
          <span>KOYO GROUP NEWS</span>
        </div>
        <div className="ad-meta">
          {article.is_new && <div className="ad-new-badge">New</div>}
          <time className="ad-date">{article.date}</time>
          <a href={article.facility_url || '#'} className="ad-fac"
            target="_blank" rel="noopener noreferrer">{article.facility}</a>
        </div>
        <h1 className="ad-title">{article.title}</h1>
      </header>

      <div className="ad-hero">
        <img src={article.img} alt="" />
        <div className="ad-hero-brand">
          <img src="assets/logo_koyo_gr.png" alt="" />
        </div>
      </div>

      <div className="ad-body"
        dangerouslySetInnerHTML={{ __html: article.body || `<p>${article.summary}</p>` }} />

      {article.facility_url && article.facility_url !== '#' && (
        <div className="ad-ext">
          <a href={article.facility_url} target="_blank" rel="noopener noreferrer">
            詳細・ご予約はこちら <IconExternal />
          </a>
        </div>
      )}
    </div>
  );
}

// ── AiNewsPanel — AI記事生成パネル ──────────────────────────────────
function AiNewsPanel({ onAdd, onClose }) {
  const [prompt, setPrompt] = useStateS2('');
  const [loading, setLoading] = useStateS2(false);
  const [error, setError] = useStateS2('');
  const [preview, setPreview] = useStateS2(null);

  const generate = async () => {
    if (!prompt.trim()) { setError('指示内容を入力してください。'); return; }
    setLoading(true); setError(''); setPreview(null);
    try {
      const res = await fetch('/api/ai-news', {
        method: 'POST', headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ prompt: prompt.trim() }),
      });
      if (!res.ok) throw new Error(`HTTP ${res.status}`);
      const data = await res.json();
      if (!data.title) throw new Error('記事データが不正です。');
      const now = new Date();
      const dateStr = `${now.getFullYear()}/${now.getMonth()+1}/${String(now.getDate()).padStart(2,'0')}`;
      setPreview({
        ...data,
        id: `ai-${Date.now()}`,
        date: data.date || dateStr,
        is_new: true,
        facility: data.facility || data.cat || 'お知らせ',
        facility_url: data.facility_url || '#',
        img: data.img || 'assets/img_koyo.jpg',
        body: data.body || `<p>${data.summary}</p>`,
      });
    } catch(e) {
      setError(`エラーが発生しました: ${e.message}`);
    } finally { setLoading(false); }
  };

  return (
    <div style={{ position:'fixed', inset:0, zIndex:200, background:'rgba(0,0,0,.55)', display:'flex', alignItems:'center', justifyContent:'center' }}
      onClick={e => e.target===e.currentTarget && onClose()}>
      <div style={{ background:'#fff', borderRadius:4, padding:'36px 40px', maxWidth:600, width:'90%', boxShadow:'0 20px 60px rgba(0,0,0,.3)', position:'relative' }}>
        <button onClick={onClose} style={{ position:'absolute', top:16, right:20, background:'none', border:'none', fontSize:22, cursor:'pointer', color:'#999' }}>×</button>
        <h3 style={{ margin:'0 0 6px', fontSize:17, fontWeight:600, letterSpacing:'.06em' }}>✨ AIでお知らせを生成</h3>
        <p style={{ margin:'0 0 20px', fontSize:13, color:'#888' }}>日本語で指示を入力してください</p>
        <textarea value={prompt} onChange={e => setPrompt(e.target.value)}
          placeholder="例：山形プリンの新商品「さくらんぼプリン」が6月1日に発売されることをお知らせする記事を書いてください。"
          style={{ width:'100%', minHeight:120, padding:'12px 14px', border:'1px solid #ddd', fontSize:14, lineHeight:1.8, resize:'vertical', boxSizing:'border-box' }} />
        {error && <p style={{ color:'#c00', fontSize:13, margin:'8px 0 0' }}>{error}</p>}
        {preview && (
          <div style={{ margin:'16px 0', padding:'14px 16px', background:'#f9f5ec', border:'1px solid #e8e4d8' }}>
            <p style={{ margin:'0 0 4px', fontSize:12, color:'#888' }}>{preview.date} ／ {preview.facility}</p>
            <p style={{ margin:0, fontSize:14, fontWeight:600 }}>{preview.title}</p>
            <p style={{ margin:'6px 0 0', fontSize:13, color:'#666' }}>{preview.summary}</p>
          </div>
        )}
        <div style={{ display:'flex', gap:10, marginTop:18 }}>
          <button onClick={generate} disabled={loading}
            style={{ flex:1, padding:'12px', background:'#1a1410', color:'#fff', border:'none', fontSize:14, cursor:loading?'wait':'pointer', letterSpacing:'.08em' }}>
            {loading ? '生成中...' : '生成する'}
          </button>
          {preview && (
            <button onClick={() => { onAdd(preview); onClose(); }}
              style={{ flex:1, padding:'12px', background:'#4a7c3f', color:'#fff', border:'none', fontSize:14, cursor:'pointer', letterSpacing:'.08em' }}>
              ✓ このまま追加
            </button>
          )}
        </div>
      </div>
    </div>
  );
}

// ── News — ホームページ用（最新 HOME_LIMIT 件） ──────────────────────
function News() {
  const [newsItems, setNewsItems] = useNewsData();
  const [showPanel, setShowPanel] = useStateS2(false);
  const [selected, setSelected] = useStateS2(null);

  const addArticle = (article) => {
    if (window.NEWS_DATA) window.NEWS_DATA.unshift(article);
    setNewsItems(prev => [article, ...prev]);
  };

  const limit = window.HOMEPAGE_NEWS_LIMIT || 4;
  const homeItems = newsItems.slice(0, limit);
  const featured = homeItems[0];
  const subItems = homeItems.slice(1);

  if (selected) return (
    <div style={{ paddingTop: 40 }}>
      <ArticleDetail article={selected} onBack={() => setSelected(null)} />
    </div>
  );

  return (
    <>
    <section id="news" style={{ padding:'72px 0', background:'#fff', borderTop:'1px solid #e8e4d8' }}>
      <style>{`
        .news-wrap { max-width:1100px; margin:0 auto; padding:0 48px; }
        @media(max-width:780px){ .news-wrap { padding:0 20px; } }
        .news-box { display:flex; gap:36px; margin-top:36px; }
        @media(max-width:820px){ .news-box { flex-direction:column; } }

        /* 大カード */
        .nc-card--featured { flex:0 0 400px; display:flex; flex-direction:column; gap:14px; }
        @media(max-width:820px){ .nc-card--featured { flex:none; } }
        .nc-thumb { position:relative; overflow:hidden; aspect-ratio:16/10; background:#eee; }
        .nc-thumb-img { width:100%; height:100%; object-fit:cover; display:block; transition:transform 1.2s; }
        .nc-card--featured:hover .nc-thumb-img { transform:scale(1.04); }
        .nc-logo-mark { position:absolute; bottom:10px; right:10px; z-index:2; background:rgba(255,255,255,.85); padding:4px 8px; }
        .nc-logo-mark img { height:15px; display:block; }
        .nc-body { display:flex; flex-direction:column; gap:8px; }
        .nc-meta { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
        .nc-date { font-size:12px; color:#888; }
        .nc-facility { font-size:12px; color:#c0472a; border-bottom:1px solid #c0472a; }
        .nc-new-text { background:#c0472a; color:#fff; font-size:10px; padding:1px 7px; font-weight:700; letter-spacing:.06em; }
        .nc-title { font-family:var(--f-serif,'Noto Serif JP',serif); font-size:15px; line-height:1.7; color:#333; margin:0; }
        .nc-summary { font-size:13px; color:#666; line-height:1.9; margin:0; }

        /* テキスト一覧行 */
        .news-list-col { flex:1; border-top:1px solid #e8e4d8; }
        .nc-row { display:flex; gap:16px; padding:18px 0; border-bottom:1px solid #e8e4d8; cursor:pointer; }
        .nc-row:hover { background:#faf8f4; }
        .nc-row-badge { display:flex; align-items:flex-start; padding-top:4px; flex-shrink:0; }
        .nc-row-body { flex:1; display:flex; flex-direction:column; gap:6px; }
        .nc-row-meta { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
        .nc-facility-link { font-size:12px; color:#c0472a; border-bottom:1px solid #c0472a; text-decoration:none; }
        .nc-facility-link:hover { opacity:.7; }
        .nc-row-title { font-family:var(--f-serif,'Noto Serif JP',serif); font-size:14px; line-height:1.65; color:#333; margin:0; }
        .nc-row-summary { font-size:13px; color:#666; line-height:1.8; margin:0; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }

        .news-more { margin-top:28px; }
        .news-more button { display:inline-block; padding:11px 32px; border:1px solid #333; color:#333; font-size:13px; letter-spacing:.1em; background:none; cursor:pointer; transition:background .2s,color .2s; }
        .news-more button:hover { background:#333; color:#fff; }
      `}</style>

      <div className="news-wrap">
        <h3 className="main-title">
          <span className="jp">新着情報</span>
          <em className="en">Information</em>
        </h3>
        <div className="news-box">
          {featured && <NewsCard article={featured} featured={true} onClick={setSelected} />}
          <div className="news-list-col">
            {subItems.map((n, i) => (
              <NewsCard key={n.id || i} article={n} onClick={setSelected} />
            ))}
          </div>
        </div>
        <div className="news-more">
          <button onClick={() => window._navigate && window._navigate('/news')}>
            お知らせ一覧を見る（全{newsItems.length}件）
          </button>
        </div>
      </div>
    </section>

    <button onClick={() => setShowPanel(true)} style={{
      position:'fixed', right:24, bottom:24, zIndex:100,
      background:'#1a1410', color:'#fff', border:'none', borderRadius:50,
      padding:'13px 20px', fontSize:13, fontWeight:600, cursor:'pointer',
      letterSpacing:'.06em', boxShadow:'0 4px 20px rgba(0,0,0,.35)',
      display:'flex', alignItems:'center', gap:8, transition:'transform .2s',
    }}
      onMouseEnter={e => e.currentTarget.style.transform='translateY(-2px)'}
      onMouseLeave={e => e.currentTarget.style.transform=''}>
      ✨ AIでお知らせ更新
    </button>
    {showPanel && <AiNewsPanel onAdd={addArticle} onClose={() => setShowPanel(false)} />}
    </>
  );
}

// ── NewsListPage — /news ページ用（全件一覧・ページネーション） ───────
function NewsListPage() {
  const [newsItems] = useNewsData();
  const [selected, setSelected] = useStateS2(null);
  const [showPanel, setShowPanel] = useStateS2(false);
  const [page, setPage] = useStateS2(0);

  const PAGE_SIZE = window.NEWS_PAGE_SIZE || 10;
  const totalPages = Math.ceil(newsItems.length / PAGE_SIZE);
  const start = page * PAGE_SIZE;
  const pageItems = newsItems.slice(start, start + PAGE_SIZE);

  if (selected) return (
    <div style={{ paddingTop: 40 }}>
      <ArticleDetail article={selected} onBack={() => setSelected(null)} />
      <Footer />
    </div>
  );

  return (
    <>
    <section style={{ background:'#fff' }}>
      <style>{`
        /* ── /news ページ ── */
        .nl-hero { position:relative; height:240px; overflow:hidden; display:flex; align-items:flex-end; }
        .nl-hero-bg { position:absolute; inset:0; background:url('assets/img_koyo.jpg') center/cover; filter:brightness(.65); }
        .nl-hero-title { position:relative; z-index:2; padding:28px 48px; font-family:var(--f-serif,'Noto Serif JP',serif); font-size:clamp(24px,3vw,36px); font-weight:500; letter-spacing:.35em; color:#fff; }
        @media(max-width:680px){ .nl-hero-title { padding:20px 24px; letter-spacing:.15em; } }

        .nl-wrap { max-width:960px; margin:0 auto; padding:52px 48px 80px; }
        @media(max-width:680px){ .nl-wrap { padding:36px 20px 60px; } }
        .nl-count { font-size:14px; color:#444; margin-bottom:24px; letter-spacing:.04em; }
        .nl-count em { font-style:normal; color:#888; font-size:13px; margin-left:8px; }

        .nl-list { list-style:none; margin:0; padding:0; border-top:1px solid #e8e4d8; }
        .nl-item { border-bottom:1px solid #e8e4d8; }
        .nl-item .nc-row { padding:20px 0; }
        .nl-item .nc-row-title { font-size:15px; }
        .nl-item .nc-row-summary { -webkit-line-clamp:2; }

        .nl-pagination { display:flex; gap:8px; justify-content:center; margin-top:40px; flex-wrap:wrap; }
        .nl-pager { width:36px; height:36px; border:1px solid #ddd; background:#fff; font-size:13px; cursor:pointer; display:grid; place-items:center; transition:background .2s,color .2s; }
        .nl-pager.on { background:#333; color:#fff; border-color:#333; }
        .nl-pager:hover:not(.on) { background:#f5f0e8; }
      `}</style>

      <div className="nl-hero">
        <div className="nl-hero-bg" />
        <h2 className="nl-hero-title">新 着 情 報</h2>
      </div>

      <div className="nl-wrap">
        <p className="nl-count">
          全{newsItems.length}件中
          <em>{start + 1}件〜{Math.min(start + PAGE_SIZE, newsItems.length)}件を表示しています。</em>
        </p>
        <ul className="nl-list">
          {pageItems.map((n, i) => (
            <li key={n.id || i} className="nl-item">
              <NewsCard article={n} onClick={setSelected} />
            </li>
          ))}
        </ul>
        {totalPages > 1 && (
          <div className="nl-pagination">
            {Array.from({ length: totalPages }, (_, i) => (
              <button key={i} className={`nl-pager ${page === i ? 'on' : ''}`}
                onClick={() => { setPage(i); window.scrollTo(0,0); }}>
                {i + 1}
              </button>
            ))}
          </div>
        )}
      </div>
    </section>

    <button onClick={() => setShowPanel(true)} style={{
      position:'fixed', right:24, bottom:24, zIndex:100,
      background:'#1a1410', color:'#fff', border:'none', borderRadius:50,
      padding:'13px 20px', fontSize:13, fontWeight:600, cursor:'pointer',
      letterSpacing:'.06em', boxShadow:'0 4px 20px rgba(0,0,0,.35)',
      display:'flex', alignItems:'center', gap:8,
    }}>✨ AIでお知らせ更新</button>
    {showPanel && <AiNewsPanel onAdd={(a) => { if(window.NEWS_DATA) window.NEWS_DATA.unshift(a); window.location.reload(); }} onClose={() => setShowPanel(false)} />}
    </>
  );
}


// ── COMPANY + 会社沿革 ───────────────────────────────────────────────
const HISTORY_ALL = [
  { y:'1951', body:'300坪で客室数7部屋の自炊旅館から営業を開始', cat:'旅館事業' },
  { y:'1958', body:'館内の敷地から1,300年前の須恵器の窯跡が発見', cat:'旅館事業' },
  { y:'1960', body:'古い窯跡に因み「古窯」に社名を変更', cat:'旅館事業' },
  { y:'1964', body:'(株)旅館古窯 創立', cat:'旅館事業' },
  { y:'1976', body:'第1期大型設備投資「雪の館」完成', cat:'旅館事業' },
  { y:'1982', body:'第2期大型設備投資「月の館」完成\n東京銀座に「日本料理古窯」オープン', cat:'レストラン事業' },
  { y:'1988', body:'第3期大型設備投資「花の館」完成', cat:'旅館事業' },
  { y:'1993', body:'初代佐藤信二社長が会長へ\n2代目 佐藤信幸専務が社長に就任', cat:'旅館事業' },
  { y:'1994', body:'山形産業賞受賞', cat:'旅館事業' },
  { y:'1997', body:'第4期大型設備投資「緑の館」完成', cat:'旅館事業' },
  { y:'1999', body:'ISO9001取得', cat:'旅館事業' },
  { y:'2001', body:'プロが選ぶ日本のホテル・旅館100選で全国総合第2位', cat:'旅館事業' },
  { y:'2006', body:'2005年度JTBお客様アンケート91点\n楽天プレミアム東北アワード賞受賞', cat:'旅館事業' },
  { y:'2007', body:'「雪の館」の客室一部改装・旧丹野ホテルに男子寮新設\nプロが選ぶ日本のホテル・旅館100選でも全国総合第3位', cat:'旅館事業' },
  { y:'2008', body:'ウェルハートピア黒沢取得\n黒沢温泉「悠湯の郷ゆさ」オープン', cat:'旅館事業' },
  { y:'2009', body:'「緑の館」を改装\nプロが選ぶ日本のホテル・旅館100選、全国総合第2位受賞', cat:'旅館事業' },
  { y:'2016', body:'8月　かみのやま温泉「おやど森の音」をオープン', cat:'旅館事業' },
  { y:'2017', body:'6月　代表取締役社長に佐藤洋詩恵、代表取締役専務に佐藤太一が就任', cat:'旅館事業' },
  { y:'2018', body:'4月　悠湯の郷ゆさ　露天風呂付客室「春夏秋冬」オープン\n9月　株式会社古窯ホールディングス設立\n11月　山形プリン　県内初のプリン専門店オープン', cat:'レストラン事業' },
  { y:'2019', body:'2月　あつみ温泉　萬国屋　経営継承\n2月　コンタクトセンター　新設・事務所改装\n4月　日本の宿古窯　雪の館全館温泉付き客室リニューアルオープン\n4月　日本の宿古窯　新レストランぎおん　リニューアルオープン', cat:'旅館事業' },
];
const HIST_CATS = ['全て', '旅館事業', 'レストラン事業', '体験事業'];

function Company() {
  const [activeCat, setActiveCat] = useState('全て');
  const filtered = activeCat === '全て' ? HISTORY_ALL : HISTORY_ALL.filter(h => h.cat === activeCat);
  return (
    <section id="company" style={{ background:'#fff', borderTop:'1px solid #e8e4d8' }}>
      <style>{`
        /* ── 会社概要ヒーロー ── */
        .co-hero { position:relative; height:340px; overflow:hidden; display:flex; align-items:flex-end; }
        @media(max-width:780px){ .co-hero { height:200px; } }
        .co-hero-bg { position:absolute; inset:0; background:url('assets/img_koyo.jpg') center/cover no-repeat; filter:brightness(.68); transition:transform 8s ease; }
        .co-hero:hover .co-hero-bg { transform:scale(1.04); }
        .co-hero-title { position:relative; z-index:2; padding:28px 48px; font-family:var(--f-serif,'Noto Serif JP',serif); font-size:clamp(26px,3.2vw,40px); font-weight:500; letter-spacing:.4em; color:#fff; text-shadow:0 2px 12px rgba(0,0,0,.35); }
        @media(max-width:780px){ .co-hero-title { padding:20px 24px; letter-spacing:.2em; } }

        .co-wrap { max-width:1100px; margin:0 auto; padding:0 48px; }
        @media(max-width:780px){ .co-wrap { padding:0 20px; } }
        .co-phil { padding:72px 0 56px; }
        .co-phil .inner { display:grid; grid-template-columns:1fr 1.1fr; gap:64px; align-items:center; }
        @media(max-width:820px){ .co-phil .inner { grid-template-columns:1fr; gap:28px; } }
        .co-quote { font-family:var(--f-serif,'Noto Serif JP',serif); font-size:clamp(20px,2.2vw,26px); font-weight:500; line-height:2; letter-spacing:.06em; color:#333; border-left:3px solid #4a7c3f; padding-left:24px; margin:0; }
        .co-desc { font-size:14.5px; line-height:2.1; color:#555; margin:0; }
        .co-table-wrap { padding-bottom:56px; border-bottom:1px solid #e8e4d8; }
        .co-table { width:100%; border-collapse:collapse; }
        .co-table tr { border-bottom:1px solid #e8e4d8; }
        .co-table tr:first-child { border-top:1px solid #e8e4d8; }
        .co-table th,.co-table td { padding:20px 16px; text-align:left; vertical-align:top; font-size:14px; line-height:1.85; }
        .co-table th { width:150px; font-family:var(--f-serif,'Noto Serif JP',serif); font-weight:500; color:#555; letter-spacing:.06em; white-space:nowrap; }
        .co-table td { color:#333; }
        @media(max-width:580px){ .co-table th,.co-table td { display:block; padding:8px 0; width:auto; } .co-table th { border:none; color:#888; font-size:12px; padding-top:14px; } }
        .co-map { margin:48px 0; }
        .co-map iframe { width:100%; height:360px; border:none; display:block; }
        .co-history { padding:64px 0 80px; }
        .hist-sec-title { font-family:var(--f-serif,'Noto Serif JP',serif); font-size:clamp(18px,2vw,22px); font-weight:500; letter-spacing:.1em; color:#333; margin-bottom:24px; display:flex; align-items:baseline; gap:16px; }
        .hist-sec-title em { font-style:italic; font-family:'Crimson Text',Georgia,serif; font-size:15px; letter-spacing:.2em; color:#888; }
        .hist-tabs { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:32px; }
        .hist-tab { padding:8px 20px; border:1px solid #bbb; background:#fff; color:#555; font-size:13px; letter-spacing:.06em; cursor:pointer; font-family:var(--f-serif,'Noto Serif JP',serif); transition:background .2s,color .2s; }
        .hist-tab.on { background:#333; color:#fff; border-color:#333; }
        .hist-tab:hover:not(.on) { background:#f5f0e8; }
        .hist-list { border-top:1px solid #e8e4d8; }
        .hist-row { display:grid; grid-template-columns:72px 1fr; gap:28px; padding:20px 0; border-bottom:1px solid #e8e4d8; }
        @media(max-width:520px){ .hist-row { grid-template-columns:52px 1fr; gap:14px; } }
        .hist-row .hy { font-family:'Crimson Text',Georgia,serif; font-style:italic; font-size:26px; color:#4a7c3f; line-height:1; padding-top:3px; }
        .hist-row .hb { font-size:14px; line-height:1.95; color:#333; white-space:pre-line; }
      `}</style>
      <div className="co-hero"><div className="co-hero-bg"/><h2 className="co-hero-title">会 社 概 要</h2></div>
      <div className="co-wrap">
        <div className="co-phil">
          <h3 className="main-title"><span className="jp">会社概要</span><em className="en">Company</em></h3>
          <div className="inner">
            <p className="co-quote">今日、この瞬間に、<br />最高の山形を。</p>
            <p className="co-desc">働く上での価値観の多様化が進む一方で、企業側に求められる要素にも変化があります。山形や東京で旅館やレストラン展開を進めることで「場所」「仕事」「時間」「やりがい」など自身の適性をよりマッチさせることができるのが古窯グループの一つの魅力です。</p>
          </div>
        </div>
        <div className="co-table-wrap">
          <table className="co-table">
            <tbody>
              <tr><th>会社名</th><td>株式会社 旅館古窯<br />（持株会社：株式会社 古窯ホールディングス）</td></tr>
              <tr><th>所在地</th><td>〒999-3292　山形県上山市葉山 5-20</td></tr>
              <tr><th>設立</th><td>1964年5月（創業 1951年10月）</td></tr>
              <tr><th>資本金</th><td>3,300万円</td></tr>
              <tr><th>代表者</th><td>代表取締役社長　佐藤 洋詩恵（女将）<br />代表取締役専務　佐藤 太一（兼 悠湯の郷 ゆさ 総支配人）<br />常務取締役　　　佐藤 奈美（若女将）<br />会長　　　　　　佐藤 信幸</td></tr>
              <tr><th>事業内容</th><td>宿泊サービスを始め、ブライダル事業、飲食・レストランなど、山形を主としてサービス業を展開しております。</td></tr>
              <tr><th>運営施設</th><td>日本の宿 古窯 ／ 悠湯の郷 ゆさ ／ おやど 森の音 ／ 山形県あつみ温泉 萬国屋 ／ 山形プリン ／ KOYO Wedding</td></tr>
            </tbody>
          </table>
        </div>
        <div className="co-map">
          <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3183.31!2d140.27274!3d38.22785!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x5f8a31f9c8a1f0b5%3A0x5cdfe02a97254ca9!2z5pel5pys44GuIOWPjOec!5e0!3m2!1sja!2sjp!4v1" title="古窯グループ地図" allowFullScreen="" loading="lazy" />
          <p style={{fontSize:12,color:'#888',marginTop:8,textAlign:'right'}}><a href="https://goo.gl/maps/mp7T5cAxmrEKWSZVA" target="_blank" rel="noopener noreferrer" style={{color:'#4a7c3f'}}>大きな地図で見る</a></p>
        </div>
        <div className="co-history">
          <p className="hist-sec-title">会社沿革 <em>History</em></p>
          <div className="hist-tabs">
            {HIST_CATS.map(c => (
              <button key={c} className={`hist-tab ${activeCat === c ? 'on' : ''}`} onClick={() => setActiveCat(c)}>{c}</button>
            ))}
          </div>
          <div className="hist-list">
            {filtered.map((h, i) => (
              <div key={`${h.y}-${i}`} className="hist-row">
                <div className="hy">{h.y}</div>
                <div className="hb">{h.body}</div>
              </div>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

function History() { return null; }


// ── RECRUIT ────────────────────────────────────────────────────────
function Recruit() {
  return (
    <section id="recruit" className="rc" data-screen-label="07 Recruit">
      <style>{`
        .rc{position:relative;overflow:hidden;background:var(--cream)}
        .rc .grid{display:grid;grid-template-columns:1fr 1fr;min-height:540px}
        @media(max-width:960px){.rc .grid{grid-template-columns:1fr}}
        .rc .vis{position:relative;background:#1b1612}
        .rc .vis img{width:100%;height:100%;object-fit:cover;opacity:.85}
        .rc .vis::after{content:"";position:absolute;inset:0;background:linear-gradient(135deg,rgba(0,0,0,.25),rgba(0,0,0,.05))}
        .rc .vis .stamp{position:absolute;left:32px;top:32px;font-family:var(--f-en);font-style:italic;font-size:13px;letter-spacing:.22em;color:#fff;z-index:2}
        .rc .vis .vert{position:absolute;right:32px;bottom:32px;writing-mode:vertical-rl;font-family:var(--f-serif);font-size:13px;letter-spacing:.6em;color:#fff;z-index:2}
        .rc .body{padding:90px 64px;display:flex;flex-direction:column;justify-content:center;position:relative}
        @media(max-width:720px){.rc .body{padding:60px var(--pad-x)}}
        .rc .body h2{margin:14px 0 24px}
        .rc .body .lead{margin-bottom:32px}
        .rc .body .roles{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;margin-top:8px}
        @media(max-width:520px){.rc .body .roles{grid-template-columns:1fr}}
        .rc .body .role{padding:14px 16px;border:1px solid var(--line);background:transparent;display:flex;align-items:center;justify-content:space-between;gap:10px}
        .rc .body .role .n{font-family:var(--f-serif);font-size:14px;font-weight:500}
        .rc .body .role .t{font-family:var(--f-en);font-style:italic;font-size:10.5px;letter-spacing:.18em;color:var(--accent)}
        .rc .body .actions{display:flex;gap:12px;flex-wrap:wrap;margin-top:32px}
      `}</style>
      <div className="grid">
        <div className="vis">
          <img src="assets/img_intr.jpg" alt="" />
          <span className="stamp">Recruit ／ 2025–2026</span>
          <span className="vert">山形で、はたらく。</span>
        </div>
        <div className="body">
          <div className="sec-title" style={{marginBottom:0}}>
            <span className="en">Recruit</span>
            <span className="jp">採用情報</span>
          </div>
          <h2 className="h-section">古窯グループで、<br />私たちと一緒に働きませんか？</h2>
          <p className="lead">
            働くメンバー一人一人が山形の魅力を伝えるパフォーマーであり、「山形で働くこと」そのものが自然と山形のファンを増やすことにつながっていく会社です。「お客様の喜びを我が喜びとする」様々な職種が集まり、協力して一つのサービスを提供する仲間を募集しています。
          </p>
          <div className="roles">
            <div className="role"><span className="n">接客職</span><span className="t">Service</span></div>
            <div className="role"><span className="n">調理職</span><span className="t">Culinary</span></div>
            <div className="role"><span className="n">予約・フロント</span><span className="t">Front Desk</span></div>
            <div className="role"><span className="n">総務・経理</span><span className="t">Admin</span></div>
            <div className="role"><span className="n">企画・広報</span><span className="t">Planning</span></div>
            <div className="role"><span className="n">パート・アルバイト</span><span className="t">Part-time</span></div>
          </div>
          <div className="actions">
            <a className="btn btn-accent" href="#recruit-detail">採用情報の詳細はこちら <IconArrow /></a>
            <a className="btn" href="#entry">エントリー</a>
          </div>
        </div>
      </div>
    </section>
  );
}

// ── FOOTER ─────────────────────────────────────────────────────────
function Footer() {
  return (
    <footer className="ft" data-screen-label="Footer">
      <style>{`
        .ft{background:var(--ink);color:var(--cream);padding:90px 0 30px}
        .ft .top{display:grid;grid-template-columns:1.3fr 1fr 1fr 1fr;gap:48px;margin-bottom:64px}
        @media(max-width:960px){.ft .top{grid-template-columns:1fr 1fr;gap:36px}}
        @media(max-width:520px){.ft .top{grid-template-columns:1fr}}
        .ft .brand{display:flex;gap:14px;align-items:center}
        .ft .brand .mark{width:46px;height:46px;border-radius:50%;background:var(--cream);color:var(--ink);
          display:grid;place-items:center;font-family:var(--f-serif);font-size:20px;font-weight:500}
        .ft .brand .name{font-family:var(--f-serif);font-size:18px;letter-spacing:.16em}
        .ft .brand .sub{font-family:var(--f-en);font-style:italic;letter-spacing:.18em;color:var(--accent-2);font-size:11px;margin-top:4px}
        .ft .addr{font-size:13px;color:rgba(250,246,236,.7);margin:20px 0 0;line-height:1.95;max-width:30ch}
        .ft h5{margin:0 0 18px;font-family:var(--f-serif);font-size:14px;letter-spacing:.12em;color:var(--cream);font-weight:500;
          padding-bottom:12px;border-bottom:1px solid rgba(250,246,236,.18)}
        .ft h5 .en{display:block;font-family:var(--f-en);font-style:italic;font-size:11px;color:var(--accent-2);letter-spacing:.2em;margin-top:3px;font-weight:400}
        .ft ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:10px}
        .ft a{color:rgba(250,246,236,.78);font-size:13.5px;line-height:1.7;display:inline-flex;align-items:center;gap:8px;font-family:var(--f-sans)}
        .ft a:hover{color:var(--accent-2)}
        .ft a .ext{font-size:9px}

        .ft .group-logos{padding:48px 0;border-top:1px solid rgba(250,246,236,.12);border-bottom:1px solid rgba(250,246,236,.12);
          display:flex;flex-wrap:wrap;gap:48px 56px;align-items:center;justify-content:center}
        .ft .group-logos a{display:flex;align-items:center;gap:10px;color:var(--cream);font-family:var(--f-serif);font-size:14px;letter-spacing:.06em}
        .ft .group-logos a:hover{color:var(--accent-2);opacity:.85}
        .ft .group-logos img{height:34px;max-width:140px;object-fit:contain;filter:brightness(0) invert(1);opacity:.85}
        .ft .group-logos a:hover img{opacity:1}

        .ft .bottom{margin-top:30px;padding-top:20px;display:flex;justify-content:space-between;flex-wrap:wrap;gap:14px;
          font-family:var(--f-en);font-style:italic;font-size:11px;letter-spacing:.16em;color:rgba(250,246,236,.55)}
      `}</style>
      <div className="wrap">
        <div className="top">
          <div>
            <div className="brand">
              <span className="mark">古</span>
              <div>
                <div className="name">古窯グループ</div>
                <div className="sub">KOYO GROUP, YAMAGATA</div>
              </div>
            </div>
            <p className="addr">〒999-3292<br />山形県上山市葉山 5-20<br />TEL 023-672-5454</p>
          </div>
          <div>
            <h5>サイトメニュー<span className="en">Site Map</span></h5>
            <ul>
              <li><a href="#top">HOME</a></li>
              <li><a href="#concept">私たちの想い</a></li>
              <li><a href="#facilities">グループ施設</a></li>
              <li><a href="#news">新着情報</a></li>
            </ul>
          </div>
          <div>
            <h5>会社情報<span className="en">About Us</span></h5>
            <ul>
              <li><a href="#company">会社概要</a></li>
              <li><a href="#history">会社沿革</a></li>
              <li><a href="#recruit">採用情報</a></li>
              <li><a href="#privacy">プライバシーポリシー</a></li>
            </ul>
          </div>
          <div>
            <h5>お問い合わせ<span className="en">Contact</span></h5>
            <ul>
              <li><a href="#contact">お問い合わせフォーム</a></li>
              <li><a href="tel:023-672-5454">TEL 023-672-5454</a></li>
              <li><span style={{color:'rgba(250,246,236,.55)',fontSize:12}}>平日 9:00 — 17:30</span></li>
            </ul>
          </div>
        </div>

        <div className="group-logos">
          <a href="https://www.koyoga.com/" target="_blank" rel="noopener noreferrer">
            <img src="assets/logo_koyo.png" alt="日本の宿 古窯" />
            <span className="ext"><IconExternal /></span>
          </a>
          <a href="https://www.dosayusa.jp/" target="_blank" rel="noopener noreferrer">
            <img src="assets/logo_yusa.png" alt="悠湯の郷ゆさ" />
            <span className="ext"><IconExternal /></span>
          </a>
          <a href="http://www.mori-ne.com/" target="_blank" rel="noopener noreferrer">
            <img src="assets/logo_mori.png" alt="おやど 森の音" />
            <span className="ext"><IconExternal /></span>
          </a>
          <a href="http://www.bankokuya.jp/" target="_blank" rel="noopener noreferrer">
            <img src="assets/logo_ban.png" alt="あつみ温泉 萬国屋" />
            <span className="ext"><IconExternal /></span>
          </a>
          <a href="https://yamagata-purin.com/" target="_blank" rel="noopener noreferrer">
            <img src="assets/logo_prin.png" alt="山形プリン" />
            <span className="ext"><IconExternal /></span>
          </a>
          <a href="https://www.koyoga.com/wedding/" target="_blank" rel="noopener noreferrer">
            <img src="assets/logo_wedd.png" alt="KOYO Wedding" />
            <span className="ext"><IconExternal /></span>
          </a>
        </div>

        <div className="bottom">
          <span>© 1951–2026 Koyo Holdings, Inc. All Rights Reserved.</span>
          <span>Yamagata, Japan ／ Since 1951</span>
        </div>
      </div>
    </footer>
  );
}

Object.assign(window, { News, NewsListPage, NewsCard, ArticleDetail, History, Company, Recruit, Footer });
