/* Web/PWA 追加スタイル: 拡張版 styles.css の上に重ねる */

/* popup.html を index.html として全画面で使うための調整 */
body.web-index {
  width: auto;
  min-height: 100dvh;
}

body.web-index .popup-main {
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

body.web-index .app-bar,
body.web-index .popup-footer {
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* ---------------- 通知ピル（インストール・更新） ---------------- */

.web-pill {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 10px 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.web-pill-label {
  flex: 1;
}

.web-pill-action {
  border: 0;
  border-radius: 9px;
  padding: 8px 14px;
  background: #5b7cfa;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.web-pill-close {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 6px 8px;
  cursor: pointer;
}

/* マウス操作または横幅十分ではタブバーが無い分、通知ピルは下端に寄せる */
@media (hover: hover) and (pointer: fine), (min-width: 861px) {
  .web-pill {
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

/* ---------------- 表示モードの Web ボタン ---------------- */

.web-wl {
  opacity: 0.45;
}

.web-wl.is-on {
  opacity: 1;
  outline: 2px solid #5b7cfa;
  outline-offset: 1px;
}

.web-wl.is-floating {
  position: fixed;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 60;
}

/* 下部タブバー表示時はフローティングボタンをタブバーに被せない */
@media (hover: none) and (max-width: 860px), (pointer: coarse) and (max-width: 860px) {
  .web-wl.is-floating {
    bottom: calc(84px + env(safe-area-inset-bottom));
  }
}

.web-back {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 10px;
  z-index: 60;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  text-decoration: none;
  opacity: 0.85;
}

/* 表示モードの「戻る」ボタンが上部バーのタイトルに被らないよう、
 * ボタンがあるときはトップバーの左余白を確保する。 */
body.display:has(.web-back) .topbar {
  padding-left: 96px;
}

/* ---------------- 保存インジケータ・許可状態 ---------------- */

.web-save-state {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
}

.web-save-state.is-visible {
  opacity: 1;
}

.web-perm-state {
  font-weight: 700;
}

/* 警告ボックスのリンク化（今日ページ） */
#periods-warning.is-link {
  cursor: pointer;
}

#status-card.is-link {
  cursor: pointer;
}

/* ---------------- 設定: 科目フィルター・導線 ---------------- */

.web-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.web-filter input[type='search'] {
  flex: 1;
  min-width: 0;
}

.web-filter-count {
  white-space: nowrap;
}

.web-pattern-link {
  margin: 4px 0 12px;
  text-decoration: none;
  display: inline-block;
}

/* ---------------- タップしやすさ ---------------- */

@media (pointer: coarse) {
  .tt-week-nav .icon-btn,
  .tt-week-nav .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .settings-menu-item {
    padding: 12px 14px;
  }

  .icon-btn {
    min-width: 40px;
    min-height: 40px;
  }
}

/* ---------------- モーション配慮・フォーカス ---------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
