:root {
  color-scheme: light;
  --viewer-background: #fff;
  --viewer-surface: #f7f7f7;
  --viewer-toolbar: var(--viewer-fill-soft);
  --viewer-primary: rgba(0, 0, 0, 0.9);
  --viewer-secondary: rgba(0, 0, 0, 0.6);
  --viewer-tertiary: rgba(0, 0, 0, 0.45);
  --viewer-fill: rgba(0, 0, 0, 0.05);
  --viewer-fill-hover: rgba(0, 0, 0, 0.08);
  --viewer-fill-active: rgba(0, 0, 0, 0.1);
  --viewer-fill-soft: rgba(0, 0, 0, 0.03);
  --viewer-sidebar: #f5f5f5;
  --toolbar-height: 44px;
  --thumbnail-panel-width: 184px;
  --thumbnail-width: 160px;
  --thumbnail-height: 90px;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --viewer-background: #121212;
  --viewer-surface: #1f1f1f;
  --viewer-toolbar: var(--viewer-fill-soft);
  --viewer-primary: rgba(255, 255, 255, 0.84);
  --viewer-secondary: rgba(255, 255, 255, 0.56);
  --viewer-tertiary: rgba(255, 255, 255, 0.42);
  --viewer-fill: rgba(255, 255, 255, 0.1);
  --viewer-fill-hover: rgba(255, 255, 255, 0.14);
  --viewer-fill-active: rgba(255, 255, 255, 0.18);
  --viewer-fill-soft: rgba(255, 255, 255, 0.05);
  --viewer-sidebar: var(--viewer-fill);
}

@font-face {
  font-family: 'MiSans VF';
  src: url('./fonts/MiSansVF.woff2') format('woff2');
  font-display: swap;
  font-style: normal;
  font-weight: 100 900;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

html {
  background: var(--viewer-background);
}

body {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  color: var(--viewer-primary);
  background: var(--viewer-surface);
  font-family:
    'MiSans VF',
    'MiSans',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
}

#presentation-toolbar {
  position: relative;
  z-index: 5;
  display: grid;
  height: var(--toolbar-height);
  min-height: var(--toolbar-height);
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 8px 20px;
  background: var(--viewer-toolbar);
}

#sidebar-toggle {
  grid-column: 1;
  justify-self: start;
}

#pagination-controls {
  display: flex;
  grid-column: 2;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

#fullscreen-toggle {
  grid-column: 3;
  justify-self: end;
}

.toolbar-button {
  display: inline-flex;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--viewer-primary);
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
  transition:
    color 150ms ease,
    background-color 150ms ease,
    transform 150ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .toolbar-button:hover:not(:disabled),
  .thumbnail-button:hover {
    background: var(--viewer-fill-hover);
  }
}

.toolbar-button:active:not(:disabled),
.thumbnail-button:active {
  background: var(--viewer-fill-active);
  transform: scale(0.96);
}

#sidebar-toggle:active {
  transform: none;
}

.toolbar-button:focus-visible {
  background: var(--viewer-fill-hover);
  outline: none;
}

.thumbnail-button:focus-visible {
  outline: 2px solid var(--viewer-primary);
  outline-offset: 1px;
}

.toolbar-button:disabled {
  color: var(--viewer-primary);
  cursor: default;
  opacity: 0.3;
}

.toolbar-icon {
  display: block;
  width: 20px;
  height: 20px;
  background: currentColor;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: 20px 20px;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: 20px 20px;
}

.toolbar-icon-pages {
  -webkit-mask-image: url('./icons/pages.svg');
  mask-image: url('./icons/pages.svg');
}

.toolbar-icon-previous {
  -webkit-mask-image: url('./icons/previous.svg');
  mask-image: url('./icons/previous.svg');
}

.toolbar-icon-next {
  -webkit-mask-image: url('./icons/next.svg');
  mask-image: url('./icons/next.svg');
}

.toolbar-icon-expand {
  -webkit-mask-image: url('./icons/expand.svg');
  mask-image: url('./icons/expand.svg');
}

body[data-fullscreen='true'] .toolbar-icon-expand {
  -webkit-mask-image: url('./icons/close.svg');
  mask-image: url('./icons/close.svg');
}

#slide-indicator {
  display: flex;
  width: 52px;
  min-width: 52px;
  gap: 8px;
  align-items: center;
  padding: 0;
  color: var(--viewer-primary);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 330;
  line-height: 23px;
  text-align: center;
}

#remaining-slides {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--viewer-tertiary);
}

#presentation-stage {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex: 1;
  gap: 0;
  padding: 0;
  overflow: hidden;
  background: transparent;
}

body[data-sidebar-open='true'] #presentation-stage {
  gap: 16px;
  padding-right: 16px;
}

#thumbnail-panel {
  position: relative;
  width: var(--thumbnail-panel-width);
  min-width: 0;
  flex: 0 0 var(--thumbnail-panel-width);
  overflow: hidden;
  background: var(--viewer-sidebar);
  transition:
    flex-basis 180ms cubic-bezier(0.23, 1, 0.32, 1),
    width 180ms cubic-bezier(0.23, 1, 0.32, 1);
}

body[data-sidebar-open='false'] #thumbnail-panel {
  width: 0;
  flex-basis: 0;
}

#thumbnail-scroller {
  width: 100%;
  height: 100%;
  overflow: hidden auto;
  background: var(--viewer-sidebar);
  scrollbar-width: none;
}

#thumbnail-scroller::-webkit-scrollbar {
  display: none;
}

#thumbnail-list {
  display: flex;
  width: var(--thumbnail-panel-width);
  min-height: 100%;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  padding: 12px;
  margin: 0;
  list-style: none;
}

#thumbnail-list li {
  position: relative;
  width: var(--thumbnail-width);
  height: var(--thumbnail-height);
}

.thumbnail-button {
  position: relative;
  display: block;
  width: var(--thumbnail-width);
  height: var(--thumbnail-height);
  padding: 0;
  overflow: hidden;
  color: var(--viewer-primary);
  cursor: pointer;
  background: var(--viewer-background);
  border: 0;
  border-radius: 10px;
  transition:
    background-color 150ms ease,
    transform 150ms ease;
}

.thumbnail-preview {
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.thumbnail-preview > [data-pptx-thumbnail='true'] {
  border-radius: 10px;
}

.thumbnail-number {
  position: absolute;
  right: 8px;
  bottom: 6px;
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  color: #f5f5f5;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 450;
  line-height: 23px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  pointer-events: none;
}

#thumbnail-scrollbar {
  position: absolute;
  top: 0;
  right: 0;
  width: 2px;
  height: 100%;
  pointer-events: none;
}

#thumbnail-scrollbar-thumb {
  position: absolute;
  top: 0;
  right: 0;
  display: block;
  width: 2px;
  height: 38px;
  background: var(--viewer-primary);
  transform: translateY(0);
}

#slide-viewport {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex: 1;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
}

body[data-sidebar-open='true'] #slide-viewport {
  align-items: center;
}

#viewer {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
  background: var(--viewer-background);
  border-radius: 12px;
  flex: 0 0 auto;
  outline: none;
}

body[data-sidebar-open='false'] #viewer {
  border-radius: 0;
}

#viewer > div {
  box-shadow: none !important;
}

#viewer:empty {
  visibility: hidden;
}

#status {
  position: fixed;
  inset: var(--toolbar-height) 0 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--viewer-secondary);
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  background: var(--viewer-surface);
  opacity: 1;
  transition: opacity 180ms cubic-bezier(0.23, 1, 0.32, 1);
}

#status[data-hidden='true'] {
  pointer-events: none;
  opacity: 0;
}

#status-text {
  max-width: 360px;
  margin: 0;
}

.skeleton {
  display: flex;
  width: min(200px, 60%);
  flex-direction: column;
  gap: 8px;
}

.skeleton span {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--viewer-fill) 25%,
    var(--viewer-fill-soft) 50%,
    var(--viewer-fill) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
}

.skeleton span:last-child {
  width: 70%;
  align-self: center;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }

  to {
    background-position: -200% 0;
  }
}

body[data-mobile='true'] {
  --toolbar-height: 44px;
}

body[data-mobile='true'] #presentation-toolbar {
  padding-right: 12px;
  padding-left: 12px;
}

body[data-mobile='true'] #presentation-stage {
  gap: 0;
  padding: 0;
}

body[data-mobile='true'] #thumbnail-panel {
  display: none;
}

body[data-mobile='true'] #viewer {
  border-radius: 0;
}

/* Keep reduced-motion handling independent from the iframe's own width. */
@media (prefers-reduced-motion: reduce) {
  #status,
  #thumbnail-panel,
  .toolbar-button,
  .thumbnail-button {
    transition-duration: 0.01ms;
  }

  .skeleton span {
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
  }
}
