/* ==========================================================================
   layout.css — ページ構造、ヘッダー、2カラム、ボトムシート
   ========================================================================== */

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 var(--space-4) calc(var(--space-8) + env(safe-area-inset-bottom, 0px));
  padding-left: max(var(--space-4), env(safe-area-inset-left, 0px));
  padding-right: max(var(--space-4), env(safe-area-inset-right, 0px));
}

/* --------------------------------------------------------------------------
   ヘッダー
   -------------------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 calc(-1 * var(--space-4));
  padding: calc(env(safe-area-inset-top, 0px) + 6px) var(--space-4) 6px;
  color: var(--on-bg);
}
/* 背景は常時ほぼ不透明（スクロール位置で変えない）。下のカードの文字が透けないように
   --bg-top（グラデーション上端色 = 文字コントラストを保証した色）+ すりガラス + 下端の影 */
.app-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--bg-top);
  opacity: 0.97;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.10);
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .app-header::before {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
}

/* ?view=umbrella|weekly などで scrollIntoView したとき、固定ヘッダーの下に見出しが隠れないように */
.main section {
  scroll-margin-top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 8px);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: var(--tap);
}
.place-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 4px 10px 4px 6px;
  margin-left: -6px;
  border-radius: var(--radius-sm);
  color: inherit;
  font-weight: 700;
  font-size: 17px;
  max-width: calc(100% - 100px);
}
.place-btn:active { background: rgba(127, 127, 127, 0.18); }
.place-btn .wi { width: 20px; height: 20px; opacity: 0.9; }
.place-btn .wi-chev { width: 16px; height: 16px; opacity: 0.75; }
.place-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-actions { display: flex; gap: 2px; margin-right: -8px; }
.header-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 20px;
  padding-left: 2px;
  font-size: var(--fs-sub);
  font-variant-numeric: tabular-nums;
  color: var(--on-bg-sub);
}

/* 地点チップ列 */
.place-chips {
  display: flex;
  gap: var(--space-2);
  margin: 2px calc(-1 * var(--space-4)) var(--space-3);
  padding: 2px var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.place-chips::-webkit-scrollbar { display: none; }

/* --------------------------------------------------------------------------
   メイン
   -------------------------------------------------------------------------- */
.main {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.col {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.app-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  color: var(--on-bg-sub);
  text-align: center;
  font-size: var(--fs-sub);
}
.app-footer .credit a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.app-footer .btn-share {
  color: var(--on-bg);
  border-color: currentColor;
  background: rgba(127, 127, 127, 0.14);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* --------------------------------------------------------------------------
   PC: 2カラム（≥900px）
   -------------------------------------------------------------------------- */
@media (min-width: 900px) {
  .app {
    max-width: 1100px;
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
  .app-header {
    margin: 0 calc(-1 * var(--space-6));
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
  .place-chips {
    margin-left: calc(-1 * var(--space-6));
    margin-right: calc(-1 * var(--space-6));
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
  .main {
    display: grid;
    grid-template-columns: 400px minmax(0, 1fr);
    gap: var(--space-4);
    align-items: start;
  }
  .col { gap: var(--space-4); }
  /* 左列はビューポートより高くなり得る（アドバイスが多い日）ので既定では sticky にしない。
     十分に高い画面（左列 ≒ 1000px が収まる）のときだけ追従させる */
  .col-main { align-self: start; }
  .app-footer { flex-direction: row; justify-content: space-between; }
}
@media (min-width: 900px) and (min-height: 1100px) {
  .col-main { position: sticky; top: calc(var(--header-h) + 8px); }
}

/* --------------------------------------------------------------------------
   ボトムシート
   -------------------------------------------------------------------------- */
.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 20, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fade-in var(--dur) var(--ease) both;
}
.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px - env(safe-area-inset-top, 0px));
  max-height: calc(100dvh - 48px - env(safe-area-inset-top, 0px));
  background: var(--card-strong);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  color: var(--text);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-lg);
  animation: sheet-up 280ms var(--ease) both;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet-wrap.is-closing .sheet { animation: sheet-down 200ms ease-in both; }
.sheet-wrap.is-closing .sheet-backdrop { animation: fade-out 200ms ease-in both; }

.sheet-handle {
  width: 36px; height: 4px;
  margin: 8px auto 0;
  border-radius: 2px;
  background: var(--border-strong);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px var(--space-3) 6px var(--space-5);
}
.sheet-title { font-size: 18px; font-weight: 700; }
.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* 中央寄せ（オンボーディング） */
.sheet-wrap-center { justify-content: center; align-items: center; padding: var(--space-4); }
.sheet-wrap-center .sheet {
  width: 100%;
  max-width: 420px;
  border-radius: 24px;
  animation: pop-in 280ms var(--ease) both;
}

@media (min-width: 900px) {
  .sheet-wrap { justify-content: center; align-items: center; padding: var(--space-4); }
  .sheet { width: 100%; max-width: 480px; border-radius: 24px; animation: pop-in 240ms var(--ease) both; }
}

@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sheet-down { from { transform: translateY(0); } to { transform: translateY(100%); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
