/*!
 * calendar-v1.css — 共有カレンダーの基本CSS（任意）
 * 並び（7列のマス目、吹き出しの位置）と、最低限の見た目だけを持つ。
 * すべて :where() で包んであるので、サイトのCSSで簡単に上書きできる（強さ0）。
 *
 * 主なクラス:
 *   .gcal / .gcal--inline / .gcal--icon / .gcal--auto / .is-loading / .is-ready / .is-error / .is-stale
 *   .gcal-nav .gcal-prev .gcal-title .gcal-next
 *   .gcal-grid .gcal-week .gcal-head .gcal-dow(.is-sat/.is-sun …)
 *   .gcal-day(.is-today/.is-past/.is-outside/.has-items/.区分クラス/.is-sat/.is-holiday …) .gcal-date .gcal-holiday
 *   .gcal-items .gcal-item(.区分クラス) .gcal-text .gcal-time
 *   .gcal-week.has-spans  .gcal-span.gcal-item(.区分クラス/.is-cont-prev/.is-cont-next/.is-past)  ※inline型の2日以上の予定の帯
 *   .gcal-mark(.区分クラス)  ※icon型
 *   .gcal-popup .gcal-popup-head .gcal-popup-date .gcal-popup-close
 *   .gcal-legend .gcal-legend-item(.区分クラス) .gcal-swatch .gcal-legend-label
 */

:where(.gcal) { position: relative; font-size: 14px; line-height: 1.4; }
:where(.gcal) *, :where(.gcal) *::before, :where(.gcal) *::after { box-sizing: border-box; }
:where(.gcal-body) { position: relative; }

/* 読み込み中・エラー */
:where(.gcal-loading, .gcal-error) { margin: 0; padding: 1.5em 1em; text-align: center; }
:where(.gcal [data-gcal-fallback]) { padding: 1em; }

/* 見出しと月の切り替え */
:where(.gcal-nav) { display: grid; grid-template-columns: 3em 1fr 3em; align-items: center; text-align: center; }
:where(.gcal-title) { font-weight: bold; font-size: 1.15em; padding: .5em 0; }
:where(.gcal-prev, .gcal-next) {
  font: inherit; font-size: 1.6em; line-height: 1; padding: .3em 0; margin: 0;
  background: none; border: 0; color: inherit; cursor: pointer;
}
:where(.gcal-prev, .gcal-next):disabled { opacity: .25; cursor: default; }

/* マス目 */
:where(.gcal-week) { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
:where(.gcal-dow) { text-align: center; font-weight: bold; padding: .3em 0; }
:where(.gcal-day) {
  min-width: 0; padding: 0 0 3px;
  border-right: 1px solid #d5d9de; border-bottom: 1px solid #d5d9de;
  overflow-wrap: break-word;
}
:where(.gcal-week) > :where(.gcal-day):first-child { border-left: 1px solid #d5d9de; }
:where(.gcal-head) + :where(.gcal-week) > :where(.gcal-day) { border-top: 1px solid #d5d9de; }
:where(.gcal-date) { display: block; text-align: center; font-weight: bold; padding: 2px 0; }
:where(.gcal-day.is-past) { opacity: .45; }
:where(.gcal-day.is-today) :where(.gcal-date) { background: #ffe95a; color: #222; }
:where(.gcal-holiday) { display: block; text-align: center; font-size: .75em; line-height: 1.2; overflow-wrap: break-word; }

/* 週ごとに「日付・祝日名・（帯の段）・予定」の段をそろえる（祝日名や帯がある週は、ほかの日の予定やアイコンも同じ高さから始まる）。
   帯の段の数は、共有JSが週ごとに --gcal-span-rows（例：" auto auto"）で渡す。
   subgrid が使えない古いブラウザでは、そろわないだけで表示はされる */
:where(.gcal-week:not(.gcal-head)) { grid-template-rows: auto auto var(--gcal-span-rows,) 1fr; }
/* マスの高さは週の行で決める（マスは週の段を借りているので、.gcal-day の min-height は効かない）。
   予定のない週でもマスが正方形になり、予定が多い週はその分伸びる。
   形を変えるときはサイトのCSSで上書きする（例：aspect-ratio: 7 / 1.2 で少し縦長、auto で予定の分だけ） */
:where(.gcal-week:not(.gcal-head)) { aspect-ratio: 7 / 1; }
:where(.gcal-week:not(.gcal-head)) > :where(.gcal-day) {
  display: grid; grid-row: 1 / -1; grid-template-rows: subgrid; align-content: start;
}
:where(.gcal-day) > :where(.gcal-date) { grid-row: 1; }
:where(.gcal-day) > :where(.gcal-holiday) { grid-row: 2; }
:where(.gcal-day) > :where(.gcal-items, .gcal-mark) { grid-row: -2 / -1; align-self: start; }
/* 帯がある週：1日の予定も週の段に入れる（帯が通っていない日は、空いている段に詰める）。
   各予定の段は共有JSが grid-row で決める。帯がない週は、マスの中に積むだけ */
:where(.gcal-week.has-spans) > :where(.gcal-day) > :where(.gcal-items) {
  display: grid; grid-row: 3 / -1; grid-template-rows: subgrid; align-content: start;
}
/* 段の中のカードは、段の高さまで伸ばさず元の高さのまま上にそろえる */
:where(.gcal-week.has-spans) > :where(.gcal-day) > :where(.gcal-items) > :where(.gcal-item) { align-self: start; }

/* 予定（inline型のマス内・icon型の吹き出し共通） */
:where(.gcal-items) { list-style: none; margin: 0; padding: 0 2px; }
:where(.gcal-item) {
  margin-top: 3px; padding: 2px 4px; border-radius: 4px;
  font-size: .8em; line-height: 1.35; background: #eef2f7; color: #222;
}
:where(.gcal-text) { display: block; }
:where(.gcal-time) { display: block; font-size: .9em; opacity: .75; }

/* inline型：2日以上の予定の帯（週ごとに1本。マスの上に重ねる。位置は共有JSが grid-column・grid-row で決める）
   色は .gcal-item と区分のクラスがそのまま効く。帯だけ変えたいときは .gcal-span で上書きする */
:where(.gcal-span) { position: relative; z-index: 1; min-width: 0; margin: 3px 2px 0; align-self: start; }
:where(.gcal-span.is-cont-prev) { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
:where(.gcal-span.is-cont-next) { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
:where(.gcal-span.is-past) { opacity: .45; }

/* icon型：マークとタップで出る吹き出し */
:where(.gcal-mark) {
  display: block; width: 2em; height: 2em; margin: 4px auto 0; padding: 0;
  border: 0; border-radius: 50%; background: #2a8f6a; cursor: pointer;
}
:where(.gcal-popup) {
  position: absolute; z-index: 20; width: min(320px, calc(100% - 16px));
  padding: .8em 1em 1em; border-radius: 10px;
  background: #fff; color: #222; box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
:where(.gcal-popup)::before {
  content: ""; position: absolute; top: -7px; left: calc(var(--gcal-arrow-x, 50%) - 7px);
  border: 7px solid transparent; border-top: 0; border-bottom-color: #fff;
}
:where(.gcal-popup):focus { outline: none; }
:where(.gcal-popup-head) { display: flex; justify-content: space-between; align-items: center; gap: 1em; margin-bottom: .3em; }
:where(.gcal-popup-date) { font-weight: bold; }
:where(.gcal-popup-close) {
  font: inherit; font-size: 1.3em; line-height: 1; width: 1.6em; height: 1.6em; padding: 0;
  border: 0; border-radius: 50%; background: #eee; color: #444; cursor: pointer;
}
:where(.gcal-popup) :where(.gcal-item) { font-size: 1em; padding: .5em .6em; margin-top: .5em; }

/* 凡例 */
:where(.gcal-legend) { display: flex; flex-wrap: wrap; gap: .4em 1.2em; list-style: none; margin: .8em 0 0; padding: 0; }
:where(.gcal-legend-item) { display: inline-flex; align-items: center; gap: .4em; }
:where(.gcal-swatch) { display: inline-block; width: 1em; height: 1em; border-radius: 3px; background: #2a8f6a; }

/* フォーカスが見えるように */
:where(.gcal) button:focus-visible { outline: 2px solid #2b6cd4; outline-offset: 2px; }
