/* ==========================================================================
   Public viewer — toolbar, paged/scroll display, presentation mode, print
   ========================================================================== */

html,
body {
  margin: 0;
  padding: 0;
}
body.viewer {
  background: #dfe9f4;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif;
  color: #1d2633;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  letter-spacing: -0.02em;
}

/* ---------- toolbar ---------- */

.toolbar {
  position: relative;
  z-index: 30;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #d9e3ef;
}
.tb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.tb-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #1c6fd8;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  flex: 0 0 auto;
}
.tb-name {
  font-size: 14px;
  font-weight: 700;
  color: #0f2d55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-name em {
  font-style: normal;
  color: #5b6676;
  font-weight: 500;
}
.tb-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.tb {
  appearance: none;
  border: 1px solid #cfe3f8;
  background: #fff;
  color: #0f2d55;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 8px 13px;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.tb:hover {
  background: #f5f9fe;
  border-color: #9fc9ee;
}
.tb:active {
  transform: translateY(1px);
}
.tb .ico {
  font-size: 13px;
  color: #1c6fd8;
}
.tb-primary {
  background: #1c6fd8;
  border-color: #1c6fd8;
  color: #fff;
}
.tb-primary:hover {
  background: #1a63c2;
  border-color: #1a63c2;
}
.tb-primary .ico {
  color: #fff;
}
.tb-ghost {
  background: transparent;
  border-color: transparent;
  color: #5b6676;
}
.tb-ghost:hover {
  background: #eaf4fd;
  border-color: transparent;
}

/* ---------- stage / deck ---------- */

#stage {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  padding: 14px;
}
#deck-wrap {
  position: relative;
  flex: 0 0 auto;
}
.deck {
  transform-origin: top left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 26px;
}
.deck .page {
  box-shadow: 0 12px 34px rgba(15, 45, 85, 0.16);
  border-radius: 2px;
}

/* paged mode: one page on screen */
body.paged .deck {
  gap: 0;
}
body.paged .page {
  display: none;
}
body.paged .page.active {
  display: block;
}
/* no-JS fallback so the first page is still readable */
body.paged:not(.js-ready) .page:first-child {
  display: block;
}

/* ---------- export mode (PNG / PPTX capture) ----------
   html2canvas cannot capture display:none nodes, so during an export every
   page is laid out at its natural size with no transform. */
body.exporting #stage {
  display: block !important;
  overflow: visible !important;
  padding: 0 !important;
}
body.exporting #deck-wrap {
  width: auto !important;
  height: auto !important;
}
body.exporting .deck {
  display: block !important;
  transform: none !important;
  gap: 0 !important;
}
body.exporting .deck .page {
  display: block !important;
  margin: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}
body.exporting .toolbar,
body.exporting .nav {
  visibility: hidden;
}

/* scroll mode: everything stacked and scrollable */
body.scrollmode #stage {
  align-items: flex-start;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 14px 28px;
}

/* ---------- bottom navigation ---------- */

.nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid #d9e3ef;
  position: relative;
  z-index: 30;
}
.nav > button {
  appearance: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid #cfe3f8;
  background: #fff;
  color: #1c6fd8;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.15s;
}
.nav > button:hover {
  background: #eaf4fd;
}
.nav > button:disabled {
  opacity: 0.35;
  cursor: default;
}
.counter {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #1c6fd8;
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: 3px;
  align-items: baseline;
}
.counter b {
  font-size: 17px;
  font-weight: 900;
}
.counter span {
  color: #5b6676;
  font-weight: 500;
}
.dots {
  display: flex;
  gap: 6px;
  margin: 0 auto 0 8px;
}
.dots button {
  appearance: none;
  width: 20px;
  height: 5px;
  border-radius: 3px;
  border: 0;
  background: #cfe3f8;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, width 0.15s;
}
.dots button[aria-current='true'] {
  background: #1c6fd8;
  width: 30px;
}
.hint {
  margin: 0;
  font-size: 12px;
  color: #8fa3bb;
  white-space: nowrap;
}
.scrollmode .hint,
.scrollmode .dots,
.scrollmode .counter,
.scrollmode .nav > button {
  display: none;
}
.scrollmode .nav {
  justify-content: center;
}
.scrollmode .nav .hint {
  display: block;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translate(-50%, 20px);
  background: #0f2d55;
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 30px;
  box-shadow: 0 10px 30px rgba(15, 45, 85, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 90;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- presentation mode ---------- */

.present {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #0b1a2e;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0;
}
.present.on {
  display: flex;
}
.present-deck {
  flex: 1 1 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.present-deck .page {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.present-deck .page:not(.active) {
  display: none;
}
.present-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  width: 100%;
  box-sizing: border-box;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.present-bar .tb {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.present-bar .tb:hover {
  background: rgba(255, 255, 255, 0.2);
}
.present-bar .tb-primary {
  background: #1c6fd8;
  border-color: #1c6fd8;
}
.present-counter {
  margin: 0 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.present-counter b {
  font-size: 17px;
}

/* ---------- print: one A4-landscape sheet per page ---------- */

@page {
  size: A4 landscape;
  margin: 0;
}

@media print {
  html,
  body {
    background: #fff !important;
    overflow: visible !important;
    height: auto !important;
    display: block !important;
  }
  .toolbar,
  .nav,
  .toast,
  .present {
    display: none !important;
  }
  #stage {
    display: block !important;
    overflow: visible !important;
    padding: 0 !important;
  }
  #deck-wrap {
    width: auto !important;
    height: auto !important;
  }
  .deck {
    display: block !important;
    gap: 0 !important;
    transform: none !important;
  }
  .deck .page {
    display: block !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    break-after: page;
    page-break-after: always;
    break-inside: avoid;
    page-break-inside: avoid;
    /* Keep the design's native 1123×794px canvas. At 96dpi that is exactly
       A4 landscape (297.1 × 210.0 mm), so the layout is never re-flowed and
       every measurement stays pixel-accurate. */
    width: 1123px !important;
    height: 794px !important;
  }
  .deck .page:last-child {
    break-after: auto;
    page-break-after: auto;
  }
  .deck .page.cover {
    padding: 0 !important;
  }
  /* keep the frame padding proportional when the canvas resizes for print */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .is img {
    print-color-adjust: exact;
  }
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .tb .lbl {
    display: none;
  }
  .tb {
    padding: 8px 10px;
  }
  .tb-brand .tb-name em {
    display: none;
  }
  .hint {
    display: none;
  }
  .dots {
    margin-left: auto;
    margin-right: auto;
  }
}
@media (max-width: 560px) {
  .toolbar {
    padding: 8px 10px;
    gap: 8px;
  }
  .tb-actions {
    gap: 5px;
  }
  .tb {
    font-size: 12px;
    padding: 7px 9px;
  }
  #stage {
    padding: 8px;
  }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
