/* ============================================================
   engine/slide.css — コアエンジン層（編集不要）
   16:9ロック / ナビUI / スケーリング / PDF出力
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--color-chrome, #111);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── デッキ（常に 1280×720） ── */
.deck {
  width: 1280px;
  height: 720px;
  position: relative;
  flex-shrink: 0;
  transform-origin: center center;
  touch-action: pan-y;
  user-select: none;
}

/* ── スライド共通 ── */
.slide {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: var(--sp-xl, 64px);
  background: var(--color-bg, #0f0f0f);
  color: var(--color-fg, #f0f0ee);
  overflow: hidden;
}
.slide.is-active { display: flex; }

/* ── 背景画像フォールバック（印刷用） ── */
.slide-bg-print { display: none; }

/* ── ナビUI（deck の外側に固定） ── */
.slide-ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}

.slide-counter {
  position: absolute;
  bottom: 1.5rem;
  left: 2rem;
  font-size: .7rem;
  font-family: var(--font-mono, monospace);
  color: rgba(255,255,255,.25);
  letter-spacing: .08em;
}

.slide-nav {
  position: absolute;
  bottom: 1.25rem;
  right: 1.5rem;
  display: flex;
  gap: .375rem;
  pointer-events: all;
}

.slide-nav button {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.5);
  padding: .35rem .9rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: .7rem;
  letter-spacing: .06em;
  transition: background .12s, color .12s;
}
.slide-nav button:hover {
  background: rgba(255,255,255,.15);
  color: rgba(255,255,255,.9);
}

@media (max-width: 760px), (max-height: 520px) and (max-width: 960px), (hover: none) and (pointer: coarse) {
  body {
    width: 100dvw;
    height: 100dvh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
  }

  .slide-ui {
    width: 100dvw;
    height: 100dvh;
    inset: 0 auto auto 0;
  }

  .slide-counter {
    top: calc(.75rem + env(safe-area-inset-top, 0px));
    bottom: auto;
    left: .75rem;
    padding: .35rem .48rem;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 999px;
    background: rgba(0,0,0,.24);
    color: rgba(255,255,255,.55);
    backdrop-filter: blur(12px);
  }

  .slide-nav {
    left: max(.5rem, env(safe-area-inset-left, 0px));
    right: max(.5rem, env(safe-area-inset-right, 0px));
    bottom: calc(.5rem + env(safe-area-inset-bottom, 0px));
    justify-content: flex-start;
    gap: .25rem;
    overflow-x: auto;
    padding: .25rem;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 12px;
    background: rgba(0,0,0,.36);
    box-shadow: 0 14px 42px rgba(0,0,0,.3);
    backdrop-filter: blur(16px) saturate(150%);
    scrollbar-width: none;
  }
  .slide-nav::-webkit-scrollbar { display: none; }

  .slide-nav button {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
    padding: 0 .72rem;
    border-radius: 9px;
    background: rgba(255,255,255,.1);
    color: rgba(255,255,255,.78);
    font-size: .68rem;
    font-weight: 800;
  }

  .slide-nav button:active {
    background: rgba(255,255,255,.2);
    color: #fff;
  }

  #btn-prev,
  #btn-next { min-width: 58px; }

  #btn-fs { min-width: 50px; }

  body.is-presenting .slide-counter,
  body.is-presenting .slide-nav {
    background: rgba(0,0,0,.5);
  }
}

/* ── スライド内ページ番号（JSで注入） ── */
.slide-page-num {
  position: absolute;
  bottom: 20px;
  right: 28px;
  font-family: var(--font-mono, monospace);
  font-size: .75rem;
  color: var(--color-num, rgba(0,0,0,.18));
  letter-spacing: .1em;
  pointer-events: none;
  z-index: 20;
}

/* ============================================================
   Overview Mode — Oキーで全スライドをグリッド表示
   ============================================================ */

body.overview-active {
  overflow: hidden;
}
body.overview-active .deck { display: none; }
body.overview-active .slide-ui { display: none; }

.slide-overview {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: hsl(0 0% 7%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.slide-overview-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid hsl(0 0% 15%);
  flex-shrink: 0;
}

.slide-overview-title {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 13px;
  font-weight: 500;
  color: hsl(0 0% 55%);
  letter-spacing: .02em;
}

.slide-overview-count {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  color: hsl(0 0% 40%);
  margin-right: auto;
}

.slide-overview-close {
  background: transparent;
  border: 1px solid hsl(0 0% 20%);
  color: hsl(0 0% 70%);
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  transition: background .12s, color .12s;
}
.slide-overview-close:hover {
  background: hsl(0 0% 15%);
  color: hsl(0 0% 95%);
}

.slide-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  padding: 24px 32px;
  overflow-y: auto;
  flex: 1;
}
@media (max-width: 1400px) { .slide-overview-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .slide-overview-grid { grid-template-columns: repeat(2, 1fr); } }

.slide-overview-thumb {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  background: hsl(0 0% 12%);
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.slide-overview-thumb:hover {
  border-color: hsl(0 0% 30%);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.slide-overview-thumb.is-current {
  border-color: hsl(0 0% 60%);
  box-shadow: 0 0 0 1px hsl(0 0% 60%);
}
.slide-overview-thumb.is-dragging {
  opacity: .4;
}
.slide-overview-thumb.is-dragover {
  border-color: hsl(200 60% 50%);
  box-shadow: 0 0 0 2px hsl(200 60% 50% / .3);
}

.slide-overview-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  position: relative;
  background: #fff;
  pointer-events: none;
}

.slide-overview-iframe {
  width: 1280px;
  height: 720px;
  border: none;
  transform-origin: top left;
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.slide-overview-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: hsl(0 0% 10%);
}

.slide-overview-num {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  font-weight: 500;
  color: hsl(0 0% 50%);
  letter-spacing: .04em;
}

.slide-overview-type {
  font-size: 11px;
  color: hsl(0 0% 38%);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

/* スクロールバー */
.slide-overview-grid::-webkit-scrollbar { width: 6px; }
.slide-overview-grid::-webkit-scrollbar-track { background: transparent; }
.slide-overview-grid::-webkit-scrollbar-thumb { background: hsl(0 0% 20%); border-radius: 3px; }

/* ── PDF / 印刷 ── */
@media print {
  @page { size: 254mm 142.875mm; margin: 0; }

  * { print-color-adjust: exact !important; -webkit-print-color-adjust: exact !important; }

  /* フォントweight正規化: 印刷では2段階のみ */
  * { font-weight: 400 !important; }
  strong, b, h1, h2, h3, .bold, .tag { font-weight: 600 !important; }

  html, body {
    width: 254mm;
    height: auto;
    display: block;
    background: transparent;
    overflow: visible;
  }

  .deck {
    transform: none !important;
    position: static;
    width: 254mm;
    height: auto;
    display: block;
  }

  .slide {
    position: relative !important;
    display: flex !important;
    width: 254mm;
    height: 142.875mm;
    z-index: 0;
    break-after: page;
    overflow: hidden;
  }

  .deck > .slide:last-of-type {
    break-after: auto;
    page-break-after: auto;
  }

  /* 背景画像フォールバック（CSS background-imageは印刷で消える） */
  .slide-bg-print {
    display: block !important;
    position: absolute !important;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
  }

  /* リスト要素の位置補正 */
  .list li { position: relative; }

  /* 丸型要素のアスペクト比補正 */
  [style*="border-radius: 50%"],
  .circle { aspect-ratio: 1/1; }

  .slide-ui { display: none !important; }
}


/* ============================================================
   発表者ツール（presenter.html / スピーカーノート / 黒画面）
   ============================================================ */

.slide-notes,
.speaker-notes { display: none !important; }
body.notes-on .speaker-notes {
  display: block !important;
}

.slide-blackout {
  position: fixed; inset: 0; background: #000; z-index: 999990;
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.slide-blackout.is-on { opacity: 1; pointer-events: auto; cursor: pointer; }

body.slide-follower .slide-ui { display: none !important; }

body.is-fullscreen .slide-ui { opacity: 0; transition: opacity .25s; }
body.is-fullscreen .slide-ui .slide-nav { pointer-events: none; }
body.is-fullscreen.slide-ui-peek .slide-ui { opacity: 1; }
body.is-fullscreen.slide-ui-peek .slide-ui .slide-nav { pointer-events: all; }

body.slide-present .slide-ui { display: none !important; }
body.slide-present .speaker-notes { display: none !important; }
body.slide-present {
  background: #0b0c0e;
}

html:fullscreen,
html:-webkit-full-screen {
  background: #0b0c0e;
}

html:fullscreen body,
html:-webkit-full-screen body {
  background: #0b0c0e;
}

.present-gate {
  position: fixed; inset: 0; z-index: 999995;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 120% at 50% 38%, #17181d 0%, #0b0c0e 70%);
  color: #fff; font-family: "Noto Sans JP", "Hiragino Sans", system-ui, sans-serif;
  text-align: center; cursor: pointer;
}

.present-pill {
  position: fixed; top: 14px; right: 14px; z-index: 999996;
  display: none; align-items: center; gap: 8px;
  background: #b97514; color: #fff; border: 0; border-radius: 100px;
  font-family: "Noto Sans JP", "Hiragino Sans", system-ui, sans-serif;
  font-size: 13px; font-weight: 700; padding: 9px 18px; cursor: pointer;
  box-shadow: 0 6px 22px rgba(0,0,0,.35);
}
.present-pill:hover { background: #d88a1c; }

.present-gate .pg-btn-secondary {
  display: block; width: 100%; margin-top: 14px;
  background: transparent; color: rgba(255,255,255,.82);
  border: 1px solid rgba(255,255,255,.22); border-radius: 12px;
  font-size: .95rem; font-weight: 700; padding: 14px 24px; cursor: pointer;
  box-shadow: none; transition: background .15s, border-color .15s;
}
.present-gate .pg-btn-secondary:hover {
  background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.38);
}

.present-gate .pg-error {
  margin-top: 16px; font-size: .85rem; color: #ffb4a8; font-weight: 600;
}

.present-gate .pg-status {
  margin-top: 18px; font-size: .88rem; font-weight: 700; letter-spacing: .02em;
}
.present-gate .pg-status[data-ok="1"] { color: #57d38c; }
.present-gate .pg-status[data-ok="0"] { color: #ffcf7a; }

.present-chromewarn {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 999996; display: none; max-width: 92vw;
  background: #b97514; color: #fff; border-radius: 100px;
  font: 700 13px/1.5 "Noto Sans JP", "Hiragino Sans", system-ui, sans-serif;
  padding: 10px 22px; pointer-events: none;
  box-shadow: 0 6px 22px rgba(0,0,0,.35);
}

.present-gate-card { max-width: 560px; padding: 0 32px; }
.present-gate .pg-eyebrow {
  font: 700 11px/1 var(--font-mono, ui-monospace, monospace);
  letter-spacing: .24em; color: #38b6df; text-transform: uppercase; margin-bottom: 18px;
}
.present-gate .pg-title { font-size: 2rem; font-weight: 900; letter-spacing: .01em; margin-bottom: 16px; }
.present-gate .pg-desc { font-size: 1rem; line-height: 1.9; color: rgba(255,255,255,.62); margin-bottom: 30px; }
.present-gate .pg-desc b { color: #fff; font-weight: 700; }
.present-gate .pg-btn {
  background: #0B7DA3; color: #fff; border: 0; border-radius: 12px;
  font-size: 1.1rem; font-weight: 700; padding: 16px 34px; cursor: pointer;
  letter-spacing: .02em; transition: background .15s, transform .08s;
  box-shadow: 0 10px 34px rgba(11,125,163,.4);
}
.present-gate .pg-btn:hover { background: #38b6df; }
.present-gate .pg-btn:active { transform: translateY(1px); }
.present-gate .pg-hint { margin-top: 22px; font-size: .8rem; color: rgba(255,255,255,.4); letter-spacing: .03em; }

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