/* news-modal.css */
/* ログイン後トップページの「お知らせ」モーダル（inc/dashboard/news-modal.php） */

/*
 * ヘッダーの再表示アイコン（ⓘ）。
 * 同じ並びの「メッセージ」「カート」「さがす」等は <a class="header-nav-link"> だが、
 * これだけ <button> のため、テーマ（Astra）側のグローバルな button リセット
 * （背景色・padding・角丸・白文字）を引き継いでしまい、青い矩形ボタンに見えていた。
 * サイズ・余白・文字サイズは .header-nav-link 側の指定にそのまま委ねるため、
 * ここでは button 固有の見た目だけを打ち消す（幅・高さは固定しない＝他項目と揃える）。
 */
/*
 * background/border/box-shadow/outline は :hover, :focus, :active もまとめて明示的にリセットする。
 * Astra（親テーマ）はカスタマイザーの「ボタン」設定で button 要素の :hover / :focus に
 * アクセントカラー（このサイトでは青系）の背景を動的に適用しており、通常時だけ background:none に
 * しても hover/focus 時に青背景が再び現れてしまうため、状態ごとに !important で確実に打ち消す。
 */
.header-news-modal-icon,
.header-news-modal-icon:hover,
.header-news-modal-icon:focus,
.header-news-modal-icon:active {
  -webkit-appearance: none;
  appearance: none;
  background: none !important;
  border: none !important;
  border-radius: 0;
  box-shadow: none !important;
  outline: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font: inherit;
}

.header-news-modal-icon i {
  border-radius: 50%;
  transition: background-color 0.15s ease, color 0.15s ease;
}

/* hover時のみ：アイコン部分（i）に軽い色変化。button本体には何も付けない */
.header-news-modal-icon:hover i {
  background-color: var(--color-bg-gray, #f5f5f5);
  color: var(--fanika-primary, #EC4899);
}

/* focus-visible時のみ：button全体に細いoutlineを1本。背景・アイコンの円は重ねない（二重装飾を避ける） */
.header-news-modal-icon:focus-visible {
  outline: 2px solid var(--fanika-primary, #EC4899);
  outline-offset: 2px;
  border-radius: 6px;
}

.news-modal[hidden] {
  display: none;
}

body.news-modal-open-lock {
  overflow: hidden;
}

/*
 * モーダルは JS 初期化時に document.body 直下へ移動される（news-modal.js）。
 * それでも position: fixed の基準が viewport からズレないよう、
 * 幅・高さ・余白を明示的にリセットしておく（祖先の overflow/transform 等の影響を受けても
 * 見た目のズレに気付きやすくするための保険）。
 */
.news-modal {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  margin: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.news-modal-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.news-modal-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 960px;
  max-height: 90vh;
  margin: 0 16px;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

/*
 * 閉じるボタン専用の領域。.news-modal-body（スクロール領域）とは別の兄弟要素として
 * 独立した高さ・余白を持たせ、本文側の見出し行（「一覧を見る」等）と座標が重ならないようにする。
 * z-indexで前面に強制するのではなく、実際にレイアウト上の領域を分けて解決する。
 */
.news-modal-header {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 52px;
  padding: 0.5em 0.75em;
  background: #fff;
  flex-shrink: 0;
}

/*
 * ×は文字グリフではなく、::before / ::after の2本の線をCSSで回転させて描画する。
 * フォントのベースライン・グリフ形状に依存すると、line-heightやflex中央揃えを使っても
 * 見た目の中心がずれるため（ブラウザ・画面幅によっても変わる）、幾何学的にボタン中心
 * （left/top: 50% + transform: translate(-50%, -50%)）へ配置する方式に統一する。
 */
.news-modal-close {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  background: none;
  border: none;
  border-radius: 50%;
  font-size: 0;
  line-height: 0;
  color: var(--color-text-gray, #6b7280);
  cursor: pointer;
}

.news-modal-close::before,
.news-modal-close::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
  transform-origin: center;
}

.news-modal-close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.news-modal-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.news-modal-close:hover {
  background: var(--color-bg-gray, #f5f5f5);
  color: var(--color-text-dark, #374151);
}

.news-modal-close:focus-visible {
  background: var(--color-bg-gray, #f5f5f5);
  color: var(--color-text-dark, #374151);
  outline: 2px solid var(--fanika-primary, #EC4899);
  outline-offset: 2px;
}

.news-modal-body {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5em 1.5em 1.5em;
}

/*
 * .top-news-section はトップページ用に「フルブリード」実装
 * （width: 100vw !important; margin: calc(-50vw + 50%) !important;）になっており、
 * 既存DOMをそのままモーダルへ移動するとダイアログ幅を突き破ってはみ出す。
 * ページ表示側の .top-news-section の定義（assets/css/fanika-top.css）は変更せず、
 * .news-modal 配下でのみ幅・余白・装飾を上書きする。
 */
.news-modal .top-news-section {
  width: 100% !important;
  max-width: none !important;
  min-width: 0;
  margin: 0 !important;
  left: auto;
  right: auto;
  transform: none;
  box-sizing: border-box;
  padding: 0;
  background: transparent;
  border-radius: 0;
}

/* 見出し（h2）と「一覧を見る」を横並びにする。
   DOM順は h2 → ul → .read-more のままだが、.top-news-list を flex コンテナ化し
   order プロパティで見た目上だけ「見出し行」を構成する（DOM構造・取得ロジックは変更しない）。 */
.news-modal .top-news-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
}

.news-modal .top-news-list h2 {
  order: 1;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.news-modal .top-news-list .read-more {
  order: 2;
  position: static;
  top: auto;
  right: auto;
  flex: 0 0 auto;
  margin-left: 1em;
}

.news-modal .top-news-list ul,
.news-modal .top-news-list .top-news-empty {
  order: 3;
  flex: 1 1 100%;
  width: 100%;
  min-width: 0;
  margin-top: 12px;
}

.news-modal .top-news-list li {
  min-width: 0;
}

.news-modal .top-news-list .news-title {
  flex: 1 1 auto;
  min-width: 0;
}

.news-modal .top-news-list .news-date,
.news-modal .top-news-list .news-label {
  flex-shrink: 0;
}

/* モーダル内では省略(...)ではなく折り返して全文を読めるようにする */
.news-modal .top-news-list .news-title a {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.news-modal-footer {
  flex-shrink: 0;
  padding: 1em 1.5em;
  border-top: 1px solid var(--color-border-light, #e5e7eb);
  background: #fff;
}

.news-modal-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75em 1em;
}

.news-modal-dismiss-label {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-size: 0.95rem;
  color: var(--color-text-dark, #374151);
  cursor: pointer;
  min-height: 44px;
  flex: 1 1 auto;
  min-width: 0;
}

.news-modal-dismiss-checkbox {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.news-modal-ok {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.5em 1.75em;
  flex-shrink: 0;
  font-size: 0.95rem;
  font-weight: bold;
  color: #fff;
  background: var(--fanika-primary, #EC4899);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.news-modal-ok:hover {
  background: var(--fanika-primary-600, #db2777);
}

.news-modal-ok:focus-visible {
  outline: 2px solid var(--fanika-primary, #EC4899);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .news-modal-footer-row {
    flex-direction: column;
    align-items: stretch;
  }

  .news-modal-ok {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .news-modal-dialog {
    margin: 0 16px;
    max-height: 85vh;
  }

  .news-modal-header {
    min-height: 48px;
    padding: 0.4em 0.5em;
  }

  .news-modal-body {
    padding: 0.5em 1em 1em;
  }

  .news-modal-footer {
    padding: 1em;
  }
}

/* Keep the modal; provide a distinct route to the full news page. */
.news-modal-archive-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  color: var(--fanika-ui-accent, #ec4899);
  font-weight: 700;
  text-decoration: underline;
  margin-bottom: 12px;
}
.news-modal-archive-link:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
