/* ============================================================
   リセット・ベース
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* 日付色 */
  --color-sun: #d32f2f;
  --color-sat: #1565c0;
  /* セル背景 */
  --color-holiday-bg: #fff5f5;
  --color-sat-bg: #f0f4ff;
  --color-today-bg: #fffde7;
  --color-today-border: #f9a825;
  /* ボーダー・テキスト */
  --color-border: #ccc;
  --color-text: #222;
  --color-sub: #888;
  --color-rokuyou: #999;
  /* ナビ */
  --color-nav-bg: #f8f8f8;
  --color-nav-text: var(--color-text);
  --color-nav-sub-text: #555;
  /* カレンダーヘッダー行（曜日ラベル） */
  --color-header-bg: #444;
  --color-header-text: #fff;
  --color-sun-label: #ff8a80;
  --color-sat-label: #82b1ff;
  /* ボタン */
  --color-btn-primary: #1565c0;
  --color-btn-primary-hover: #0d47a1;
  --color-btn-secondary: #555;
  --color-btn-print: #2e7d32;
  --font-main: 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
}


html, body {
  font-family: var(--font-main);
  background: #f0f0f0;
  color: var(--color-text);
  font-size: 14px;
}

/* ============================================================
   ナビゲーション
   ============================================================ */
.nav-controls {
  background: var(--color-nav-bg);
  color: var(--color-nav-text);
  border-bottom: 1px solid #ddd;
  padding: 8px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-sub {
  display: flex;
  gap: 16px;
  justify-content: flex-end;
  max-width: 1100px;
  margin: 0 auto 4px;
}

.nav-sub-link {
  font-size: 0.8rem;
  color: var(--color-nav-sub-text);
  text-decoration: none;
  padding: 2px 6px;
  border-radius: 3px;
  transition: background 0.12s, color 0.12s;
}

.nav-sub-link:hover {
  background: rgba(128,128,128,0.2);
  color: var(--color-nav-text);
}

.nav-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  max-width: 1100px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.nav-year {
  display: flex;
  gap: 4px;
}

.nav-month {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-title {
  font-size: 1.4rem;
  font-weight: bold;
  min-width: 160px;
  text-align: center;
  white-space: nowrap;
  color: var(--color-nav-text);
  flex: 1; /* 年ビュー時にタイトルが中央になるよう */
}

.nav-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ============================================================
   ボタン
   ============================================================ */
.btn {
  padding: 6px 14px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: var(--font-main);
  transition: background 0.15s;
}

.btn-primary {
  background: var(--color-btn-primary);
  color: white;
}
.btn-primary:hover {
  background: var(--color-btn-primary-hover);
}

.btn-secondary {
  background: var(--color-btn-secondary);
  color: white;
}
.btn-secondary:hover {
  background: #333;
}

.btn-print {
  background: var(--color-btn-print);
  color: white;
}
.btn-print:hover {
  background: #1b5e20;
}


/* 縦/横トグル */
.nav-orient {
  display: flex;
  border: 1px solid #aaa;
  border-radius: 4px;
  overflow: hidden;
}

.btn-orient {
  background: white;
  color: #555;
  border: none;
  border-radius: 0;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-orient + .btn-orient {
  border-left: 1px solid #aaa;
}

.btn-orient.active {
  background: var(--color-btn-primary);
  color: white;
}

.btn-orient:not(.active):hover {
  background: #e8e8e8;
}

/* ============================================================
   広告エリア
   ============================================================ */
.ad-container {
  max-width: 1100px;
  margin: 8px auto;
  min-height: 90px;
  background: #e8e8e8;
  border: 1px dashed #bbb;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 0.75rem;
}

.ad-container:empty::before {
  content: '広告スペース';
}

/* ============================================================
   カレンダー本体 — スクリーンレイアウト
   スクリーンと印刷は独立したレイアウト。
   印刷スタイルは @media print / app.js 動的注入で完全上書き。
   ============================================================ */
.calendar-wrapper {
  /* スクリーン: ナビバーと同じ最大幅で横いっぱい */
  width: calc(100vw - 32px);
  max-width: 1100px;
  margin: 8px auto;
  background: white;
  box-shadow: 0 0 0 1px #ddd; /* border の代わりに使用（グリッドボーダーと重複しない） */
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 横向きボタンは印刷方向を変えるだけ。スクリーン表示は変化しない */
body.orient-landscape .calendar-wrapper {
  /* 画面レイアウトは縦/横で同じ */
}

/* 画面タイトル（印刷プレビュー兼用） */
.calendar-wrapper::before {
  content: attr(data-title);
  display: block;
  text-align: center;
  font-size: clamp(0.85rem, 3vmin, 1.6rem);
  font-weight: bold;
  padding: 0.25em 0;
  flex-shrink: 0;
  line-height: 1.3;
}

.calendar-header-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--color-header-bg);
  color: var(--color-header-text);
  flex-shrink: 0;
}

.day-label {
  text-align: center;
  padding: 6px 0;
  font-weight: bold;
  font-size: 0.85rem;
}

.day-label.sun { color: var(--color-sun-label); }
.day-label.sat { color: var(--color-sat-label); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: white; /* 月末の空きグリッドスペースに背景が透けないよう明示 */
  /* グリッド外枠（上端・左端）を明示。右端・下端はセルの border で構成 */
  border-top:  1px solid #999;
  border-left: 1px solid #999;
}

/* ============================================================
   日付セル
   ============================================================ */
.day-cell {
  /* var() を使わず固定色（薄いと消えるため #999 を使用） */
  border-right:  1px solid #999;
  border-bottom: 1px solid #999;
  border-top:    none;
  border-left:   none;
  min-height: 90px;
  padding: 4px 6px;
  position: relative;
  background: white;
  overflow: hidden;
}

/* 最終列は右ボーダーを保持（ wrapper に依存しない） */
.day-cell:nth-child(7n) {
  border-right: 1px solid #999;
}

.day-cell.empty {
  background: #fafafa;
}

.day-cell.sunday .day-num,
.day-cell.holiday .day-num {
  color: var(--color-sun);
}

.day-cell.saturday .day-num {
  color: var(--color-sat);
}

.day-cell.sunday,
.day-cell.holiday {
  background: var(--color-holiday-bg);
}

.day-cell.saturday {
  background: var(--color-sat-bg);
}

.day-cell.today {
  background: var(--color-today-bg);
  box-shadow: inset 0 0 0 2px var(--color-today-border);
}

.day-num {
  font-size: 1.1rem;
  font-weight: bold;
  line-height: 1;
  display: inline-block;
}

.day-today-mark {
  display: inline-block;
  width: 28px;
  height: 28px;
  background: var(--color-today-border);
  border-radius: 50%;
  color: white;
  text-align: center;
  line-height: 28px;
  font-size: 1.0rem;
  font-weight: bold;
  margin-left: 2px;
}

.holiday-name {
  font-size: 0.65rem;
  color: var(--color-sun);
  display: block;
  margin-top: 2px;
  line-height: 1.2;
  word-break: keep-all;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.rokuyou {
  position: absolute;
  bottom: 4px;
  right: 5px;
  font-size: 0.62rem;
  color: var(--color-rokuyou);
}

/* ============================================================
   補助情報エリア
   ============================================================ */
.aux-info {
  max-width: 1100px;
  margin: 6px auto;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px 16px;
  font-size: 0.85rem;
  color: #444;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.aux-sep {
  color: #ccc;
}

.aux-item strong {
  color: var(--color-btn-primary);
}

/* ============================================================
   印刷時は非表示にするクラス
   ============================================================ */
.screen-only {
  /* 画面表示時は通常表示 */
}

/* 六曜非表示オプション（ボタン OFF 時に body へ付与） */
body.hide-rokuyou .rokuyou {
  display: none !important;
}

/* ============================================================
   印刷スタイル
   ============================================================ */
@media print {
  html, body {
    background: white;
    font-size: 10pt;
    margin: 0;
    padding: 0;
    height: 100%; /* vh は印刷で使えないため % を使う */
  }

  /* 印刷時非表示 */
  .nav-controls,
  .aux-info,
  .ad-container,
  .screen-only {
    display: none !important;
  }

  /* 印刷時はwrapperをページ全体に固定配置（height:100%連鎖より確実） */
  .calendar-wrapper {
    position: fixed;
    inset: 0;             /* top/right/bottom/left = 0 でページ全体に */
    width: 100%;
    height: 100%;
    aspect-ratio: auto;   /* アスペクト比を解除して高さを優先 */
    max-width: none;
    max-height: none;
    margin: 0;
    border: none;
    border-radius: 0;
  }

  /* 印刷タイトル: フォントサイズ・パディングを印刷向けに上書き */
  .calendar-wrapper::before {
    font-size: 18pt !important;
    padding: 4mm 0 3mm 0 !important;
    line-height: 1.2 !important;
  }

  .calendar-header-row {
    background: var(--color-header-bg) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .day-label.sun { color: var(--color-sun-label) !important; }
  .day-label.sat { color: var(--color-sat-label) !important; }

  .calendar-grid {
    flex: 1;
    min-height: 0;
    height: 100%;
    grid-auto-rows: 1fr;
    align-content: stretch;
    /* gap方式: グリッド背景色を線として見せる */
    background: #999 !important;
    gap: 1px !important;
    border: 1px solid #999 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .day-cell {
    border: none !important;
    min-height: 0 !important;
    break-inside: avoid;
    overflow: hidden;
    background: white !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .day-cell.empty {
    background: #fafafa !important;
  }

  .day-cell.sunday,
  .day-cell.holiday {
    background: #fff5f5 !important;
  }

  .day-cell.saturday {
    background: #f0f4ff !important;
  }

  .day-cell.today {
    background: white !important;
    box-shadow: none !important;
  }

  /* @page はapp.jsで動的注入（縦/横対応）。JSが無効な場合のフォールバック */
  @page {
    size: A4 portrait;
    margin: 0;
  }
}

/* ============================================================
   レスポンシブ（スマホ）
   モバイルではアスペクト比固定を解除し、通常フローに戻す
   ============================================================ */
@media (max-width: 600px) {
  .nav-top {
    flex-direction: column;
    gap: 6px;
  }

  .nav-title {
    font-size: 1.1rem;
    min-width: 120px;
  }

  /* スマホではアスペクト比固定を解除 */
  .calendar-wrapper {
    aspect-ratio: auto;
    max-height: none;
    max-width: none;
    height: auto;
  }

  .calendar-wrapper::before {
    display: none; /* スマホはナビバーのタイトルのみ表示 */
  }

  .calendar-grid {
    flex: none;
  }

  .day-cell {
    min-height: 56px;
    padding: 2px 3px;
  }

  .day-num {
    font-size: 0.85rem;
  }

  .holiday-name {
    font-size: 0.55rem;
  }

  .rokuyou {
    font-size: 0.5rem;
  }

  .aux-info {
    font-size: 0.75rem;
    flex-direction: column;
    align-items: flex-start;
  }

  .aux-sep {
    display: none;
  }
}

/* ============================================================ */
/* サイトフッター                                               */
/* ============================================================ */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  margin-top: 2rem;
  font-size: 0.85rem;
  color: #666;
  border-top: 1px solid #e5e7eb;
}
.site-footer a {
  color: #555;
  text-decoration: none;
}
.site-footer a:hover {
  text-decoration: underline;
}
.footer-sep {
  margin: 0 0.6rem;
  color: #ccc;
}

/* ============================================================ */
/* 静的ページ（プライバシーポリシー・お問い合わせ）             */
/* ============================================================ */
.static-page {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1.5rem 3rem;
  line-height: 1.8;
  color: #333;
}
.static-page h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #2563eb;
}
.static-page h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 2rem 0 0.6rem;
  color: #1e3a8a;
}
.static-page p, .static-page li {
  margin: 0.6rem 0;
  color: #444;
}
.static-page ul {
  padding-left: 1.5rem;
}
.static-page .updated {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 1.5rem;
}

/* お問い合わせフォーム */
.contact-form {
  max-width: 560px;
  margin: 1.5rem 0;
}
.form-group {
  margin-bottom: 1.2rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
  font-size: 0.95rem;
}
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  box-sizing: border-box;
  background: #fff;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: 2px solid #2563eb;
  border-color: transparent;
}
.form-group textarea {
  min-height: 140px;
  resize: vertical;
}
.btn-submit {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 0.7rem 2rem;
  font-size: 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.btn-submit:hover {
  background: #1d4ed8;
}
